// Quantise in-place transformed coefficients (without LL subband prediction) const Picture quantise_transform_np(const Picture& transform, const int qIndex, const Array1D& qMatrix) { Picture result(transform.format()); result.y(quantise_transform_np(transform.y(), qIndex, qMatrix)); result.c1(quantise_transform_np(transform.c1(), qIndex, qMatrix)); result.c2(quantise_transform_np(transform.c2(), qIndex, qMatrix)); return result; }
const Picture inverse_quantise_transform_np(const Picture& qCoeffs, const int qIndex, const Array1D& qMatrix) { Picture result(qCoeffs.format()); result.y(inverse_quantise_transform_np(qCoeffs.y(), qIndex, qMatrix)); result.c1(inverse_quantise_transform_np(qCoeffs.c1(), qIndex, qMatrix)); result.c2(inverse_quantise_transform_np(qCoeffs.c2(), qIndex, qMatrix)); return result; }
// Quantise in-place transformed coefficients of a whole picture as slices // Using LL (DC) subband prediction // Uses a quantisation matrix const Picture quantise_transform(const Picture& transform, const Array2D& qIndices, const Array1D& qMatrix) { Picture result(transform.format()); result.y(quantise_transform(transform.y(), qIndices, qMatrix)); result.c1(quantise_transform(transform.c1(), qIndices, qMatrix)); result.c2(quantise_transform(transform.c2(), qIndices, qMatrix)); return result; }
const long long yss_for_slice(const Picture &inPicture, const int qIndex, const Array1D& qMatrix) { Picture trialSlice = quantise_transform_np(inPicture, qIndex, qMatrix); Picture restoredSlice = inverse_quantise_transform_np(trialSlice, qIndex, qMatrix); Array2D yDiff(restoredSlice.format().lumaShape()); std::transform(inPicture.y().data(), inPicture.y().data()+inPicture.y().num_elements(), restoredSlice.y().data(), yDiff.data(), std::minus<int>() ); std::transform(yDiff.data(), yDiff.data()+yDiff.num_elements(), yDiff.data(), yDiff.data(), std::multiplies<int>() ); return std::accumulate(yDiff.data(), yDiff.data()+yDiff.num_elements(), 0LL); }