Skip to content

Clean up lambda update code via unifying initializeLambda() function

In VTM, EncoderLib/EncSlice.cpp has

#if SHARP_LUMA_DELTA_QP
  dLambda = calculateLambda (...)
#else
  code block A with 80 lines of code, outdated

  iQP = Clip3( -rpcSlice->getSPS()->getQpBDOffset( CHANNEL_TYPE_LUMA ), MAX_QP, (int) floor( dQP + 0.5 ) );
#endif

and

double EncSlice::calculateLambda (...)
{
  code block B with 85 lines of code
}

while EncoderLib/EncCu.cpp has

void EncCu::updateLambda (...)
#if WCG_EXT && ER_CHROMA_QP_WCG_PPS
  if (useWCGChromaControl)
  {
    code block C with 60 lines of code

    int qpBDoffset = slice->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA);
    int iQP = Clip3(-qpBDoffset, MAX_QP, (int)floor((double)dQP + 0.5));
    m_pcSliceEncoder->setUpLambda(slice, dLambda, iQP);

    return;
  }
#endif

Note that code blocks A, B, and C are virtually identical. This merge request unifies blocks A, B, C into a new function

initializeLambda(),

thus saving about 140 lines of code, while also correcting some macro encapsulation around some related functions.

Merge request reports