Commit 9eeccaee authored by Taoran Lu's avatar Taoran Lu

JVET-O0429 CRS lambda rounding fix

parent 2444ec96
......@@ -51,6 +51,7 @@
#include <cassert>
#define JVET_O0429_CRS_LAMBDA_FIX 1 // JVET-O0429: fix encoder lambda rounding used in CRS
......
......@@ -6399,7 +6399,11 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par
#endif
if (slice.getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && isChroma(compID) && slice.getLmcsChromaResidualScaleFlag())
{
#if JVET_O0429_CRS_LAMBDA_FIX
double cRescale = (double)(1 << CSCALE_FP_PREC) / (double)(tu.getChromaAdj());
#else
double cRescale = round((double)(1 << CSCALE_FP_PREC) / (double)(tu.getChromaAdj()));
#endif
m_pcTrQuant->setLambda(m_pcTrQuant->getLambda() / (cRescale*cRescale));
}
TCoeff currAbsSum = 0;
......@@ -6635,7 +6639,11 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par
if ( reshape )
{
#if JVET_O0429_CRS_LAMBDA_FIX
double cRescale = (double)(1 << CSCALE_FP_PREC) / (double)(tu.getChromaAdj());
#else
double cRescale = round((double)(1 << CSCALE_FP_PREC) / (double)(tu.getChromaAdj()));
#endif
m_pcTrQuant->setLambda(m_pcTrQuant->getLambda() / (cRescale*cRescale));
cbResi.scaleSignal(tu.getChromaAdj(), 1, tu.cu->cs->slice->clpRng(COMPONENT_Cb));
......
......@@ -1890,7 +1890,11 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp
if (flag && isChroma(compID) && slice.getLmcsChromaResidualScaleFlag() )
{
int cResScaleInv = tu.getChromaAdj();
#if JVET_O0429_CRS_LAMBDA_FIX
double cResScale = (double)(1 << CSCALE_FP_PREC) / (double)cResScaleInv;
#else
double cResScale = round((double)(1 << CSCALE_FP_PREC) / (double)cResScaleInv);
#endif
m_pcTrQuant->setLambda(m_pcTrQuant->getLambda() / (cResScale*cResScale));
if ( !jointCbCr ) // Joint CbCr signal is to be scaled in the case of joint chroma
piResi.scaleSignal(cResScaleInv, 1, tu.cu->cs->slice->clpRng(compID));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment