Changeset 540 in SHVCSoftware for trunk/source/Lib/TLibEncoder/TEncSlice.cpp


Ignore:
Timestamp:
9 Jan 2014, 05:04:17 (11 years ago)
Author:
seregin
Message:

merge SHM-4.1-dev branch

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/source

  • trunk/source/Lib/TLibEncoder/TEncSlice.cpp

    r494 r540  
    295295    dQP += pdQPs[ rpcSlice->getPOC() ];
    296296  }
    297 #if !RATE_CONTROL_LAMBDA_DOMAIN
    298   if ( m_pcCfg->getUseRateCtrl())
    299   {
    300     dQP = m_pcRateCtrl->getFrameQP(rpcSlice->isReferenced(), rpcSlice->getPOC());
    301   }
    302 #endif
    303297  // ------------------------------------------------------------------------------------------------------------------
    304298  // Lambda computation
     
    386380  // store lambda
    387381  m_pcRdCost ->setLambda( dLambda );
    388 #if WEIGHTED_CHROMA_DISTORTION
    389382// for RDO
    390383  // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma.
    391   Double weight = 1.0;
     384  Double weight[2] = { 1.0, 1.0 };
    392385  Int qpc;
    393386  Int chromaQPOffset;
     
    395388  chromaQPOffset = rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb();
    396389  qpc = Clip3( 0, 57, iQP + chromaQPOffset);
    397   weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
    398   m_pcRdCost->setCbDistortionWeight(weight);
     390  weight[0] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
     391  m_pcRdCost->setCbDistortionWeight(weight[0]);
    399392
    400393  chromaQPOffset = rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr();
    401394  qpc = Clip3( 0, 57, iQP + chromaQPOffset);
    402   weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
     395  weight[1] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
     396  m_pcRdCost->setCrDistortionWeight(weight[1]);
     397
    403398#if JCTVC_M0259_LAMBDAREFINEMENT
    404399  if( rpcSlice->getLayerId() > 0 && m_ppcTEncTop[layerId]->getNumActiveRefLayers() && m_pcCfg->getGOPSize() >= 8 && rpcSlice->isIntra() == false && depth == 0 )
    405400  {
    406401    dLambda *= 1.1;
    407     weight *= 1.15;
    408   }
    409 #endif
    410   m_pcRdCost->setCrDistortionWeight(weight);
    411 #endif
    412 
     402    weight[1] *= 1.15;
     403    weight[0] *= 1.15;
     404
     405    m_pcRdCost ->setLambda( dLambda );
     406    m_pcRdCost->setCbDistortionWeight(weight[0]);
     407    m_pcRdCost->setCrDistortionWeight(weight[1]);
     408  }
     409#endif
     410
     411  const Double lambdaArray[3] = {dLambda, (dLambda / weight[0]), (dLambda / weight[1])};
     412 
    413413#if RDOQ_CHROMA_LAMBDA
    414414// for RDOQ
    415   m_pcTrQuant->setLambda( dLambda, dLambda / weight );
     415  m_pcTrQuant->setLambdas( lambdaArray );
    416416#else
    417417  m_pcTrQuant->setLambda( dLambda );
    418418#endif
    419419
    420 #if SAO_CHROMA_LAMBDA
    421420// For SAO
    422   rpcSlice   ->setLambda( dLambda, dLambda / weight );
    423 #else
    424   rpcSlice   ->setLambda( dLambda );
    425 #endif
     421  rpcSlice->setLambdas( lambdaArray );
    426422
    427423#if HB_LAMBDA_FOR_LDC
     
    430426
    431427#if SVC_EXTENSION
    432   if(m_pcCfg->getLayerId() > 0)
     428  if( m_pcCfg->getLayerId() > 0 && m_pcCfg->getNumActiveRefLayers() > 0 )
    433429  {
    434430    eSliceType=B_SLICE;
     
    500496
    501497  pcPic->setTLayer( m_pcCfg->getGOPEntry(iGOPid).m_temporalId );
    502 
    503498  if(eSliceType==I_SLICE)
    504499  {
     
    517512  rpcSlice->setSliceSegmentArgument ( m_pcCfg->getSliceSegmentArgument() );
    518513  rpcSlice->setMaxNumMergeCand        ( m_pcCfg->getMaxNumMergeCand()        );
     514#if HIGHER_LAYER_IRAP_SKIP_FLAG
     515  if (m_pcCfg->getSkipPictureAtArcSwitch() && m_pcCfg->getAdaptiveResolutionChange() > 0 && rpcSlice->getLayerId() == 1 && rpcSlice->getPOC() == m_pcCfg->getAdaptiveResolutionChange())
     516  {
     517    rpcSlice->setMaxNumMergeCand        ( 1 );
     518  }
     519#endif
    519520  xStoreWPparam( pPPS->getUseWP(), pPPS->getWPBiPred() );
    520521
     
    546547}
    547548
    548 #if RATE_CONTROL_LAMBDA_DOMAIN
    549549Void TEncSlice::resetQP( TComPic* pic, Int sliceQP, Double lambda )
    550550{
     
    555555  slice->setSliceQpBase ( sliceQP );
    556556  m_pcRdCost ->setLambda( lambda );
    557 #if WEIGHTED_CHROMA_DISTORTION
    558557  // for RDO
    559558  // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma.
    560   Double weight;
     559  Double weight[2] = { 1.0, 1.0 };
    561560  Int qpc;
    562561  Int chromaQPOffset;
     
    564563  chromaQPOffset = slice->getPPS()->getChromaCbQpOffset() + slice->getSliceQpDeltaCb();
    565564  qpc = Clip3( 0, 57, sliceQP + chromaQPOffset);
    566   weight = pow( 2.0, (sliceQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
    567   m_pcRdCost->setCbDistortionWeight(weight);
     565  weight[0] = pow( 2.0, (sliceQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
     566  m_pcRdCost->setCbDistortionWeight(weight[0]);
    568567
    569568  chromaQPOffset = slice->getPPS()->getChromaCrQpOffset() + slice->getSliceQpDeltaCr();
    570569  qpc = Clip3( 0, 57, sliceQP + chromaQPOffset);
    571   weight = pow( 2.0, (sliceQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
    572   m_pcRdCost->setCrDistortionWeight(weight);
    573 #endif
     570  weight[1] = pow( 2.0, (sliceQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
     571  m_pcRdCost->setCrDistortionWeight(weight[1]);
     572
     573  const Double lambdaArray[3] = {lambda, (lambda / weight[0]), (lambda / weight[1])};
    574574
    575575#if RDOQ_CHROMA_LAMBDA
    576576  // for RDOQ
    577   m_pcTrQuant->setLambda( lambda, lambda / weight );
     577  m_pcTrQuant->setLambdas( lambdaArray );
    578578#else
    579579  m_pcTrQuant->setLambda( lambda );
    580580#endif
    581581
    582 #if SAO_CHROMA_LAMBDA
    583582  // For SAO
    584   slice   ->setLambda( lambda, lambda / weight );
    585 #else
    586   slice   ->setLambda( lambda );
    587 #endif
     583  slice->setLambdas( lambdaArray );
    588584}
    589 #else
    590 /**
    591  - lambda re-computation based on rate control QP
    592  */
    593 Void TEncSlice::xLamdaRecalculation(Int changeQP, Int idGOP, Int depth, SliceType eSliceType, TComSPS* pcSPS, TComSlice* pcSlice)
    594 {
    595   Int qp;
    596   Double recalQP= (Double)changeQP;
    597   Double origQP = (Double)recalQP;
    598   Double lambda;
    599 
    600   // pre-compute lambda and QP values for all possible QP candidates
    601   for ( Int deltqQpIdx = 0; deltqQpIdx < 2 * m_pcCfg->getDeltaQpRD() + 1; deltqQpIdx++ )
    602   {
    603     // compute QP value
    604     recalQP = origQP + ((deltqQpIdx+1)>>1)*(deltqQpIdx%2 ? -1 : 1);
    605 
    606     // compute lambda value
    607     Int    NumberBFrames = ( m_pcCfg->getGOPSize() - 1 );
    608     Int    SHIFT_QP = 12;
    609     Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)NumberBFrames );
    610 #if FULL_NBIT
    611     Int    bitdepth_luma_qp_scale = 6 * (g_bitDepth - 8);
    612 #else
    613     Int    bitdepth_luma_qp_scale = 0;
    614 #endif
    615     Double qp_temp = (Double) recalQP + bitdepth_luma_qp_scale - SHIFT_QP;
    616 #if FULL_NBIT
    617     Double qp_temp_orig = (Double) recalQP - SHIFT_QP;
    618 #endif
    619     // Case #1: I or P-slices (key-frame)
    620     Double dQPFactor = m_pcCfg->getGOPEntry(idGOP).m_QPFactor;
    621     if ( eSliceType==I_SLICE )
    622     {
    623       dQPFactor=0.57*dLambda_scale;
    624     }
    625     lambda = dQPFactor*pow( 2.0, qp_temp/3.0 );
    626 
    627     if ( depth>0 )
    628     {
    629 #if FULL_NBIT
    630       lambda *= Clip3( 2.00, 4.00, (qp_temp_orig / 6.0) ); // (j == B_SLICE && p_cur_frm->layer != 0 )
    631 #else
    632       lambda *= Clip3( 2.00, 4.00, (qp_temp / 6.0) ); // (j == B_SLICE && p_cur_frm->layer != 0 )
    633 #endif
    634     }
    635 
    636     // if hadamard is used in ME process
    637     if ( !m_pcCfg->getUseHADME() )
    638     {
    639       lambda *= 0.95;
    640     }
    641 
    642 #if REPN_FORMAT_IN_VPS
    643     qp = max( -pcSlice->getQpBDOffsetY(), min( MAX_QP, (Int) floor( recalQP + 0.5 ) ) );
    644 #else
    645     qp = max( -pcSPS->getQpBDOffsetY(), min( MAX_QP, (Int) floor( recalQP + 0.5 ) ) );
    646 #endif
    647 
    648     m_pdRdPicLambda[deltqQpIdx] = lambda;
    649     m_pdRdPicQp    [deltqQpIdx] = recalQP;
    650     m_piRdPicQp    [deltqQpIdx] = qp;
    651   }
    652 
    653   // obtain dQP = 0 case
    654   lambda  = m_pdRdPicLambda[0];
    655   recalQP = m_pdRdPicQp    [0];
    656   qp      = m_piRdPicQp    [0];
    657 
    658   if( pcSlice->getSliceType( ) != I_SLICE )
    659   {
    660     lambda *= m_pcCfg->getLambdaModifier( depth );
    661   }
    662 
    663   // store lambda
    664   m_pcRdCost ->setLambda( lambda );
    665 #if WEIGHTED_CHROMA_DISTORTION
    666   // for RDO
    667   // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma.
    668   Double weight = 1.0;
    669   Int qpc;
    670   Int chromaQPOffset;
    671 
    672   chromaQPOffset = pcSlice->getPPS()->getChromaCbQpOffset() + pcSlice->getSliceQpDeltaCb();
    673   qpc = Clip3( 0, 57, qp + chromaQPOffset);
    674   weight = pow( 2.0, (qp-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
    675   m_pcRdCost->setCbDistortionWeight(weight);
    676 
    677   chromaQPOffset = pcSlice->getPPS()->getChromaCrQpOffset() + pcSlice->getSliceQpDeltaCr();
    678   qpc = Clip3( 0, 57, qp + chromaQPOffset);
    679   weight = pow( 2.0, (qp-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
    680   m_pcRdCost->setCrDistortionWeight(weight);
    681 #endif
    682 
    683 #if RDOQ_CHROMA_LAMBDA
    684   // for RDOQ
    685   m_pcTrQuant->setLambda( lambda, lambda / weight );
    686 #else
    687   m_pcTrQuant->setLambda( lambda );
    688 #endif
    689 
    690 #if SAO_CHROMA_LAMBDA
    691   // For SAO
    692   pcSlice   ->setLambda( lambda, lambda / weight );
    693 #else
    694   pcSlice   ->setLambda( lambda );
    695 #endif
    696 }
    697 #endif
    698585// ====================================================================================================================
    699586// Public member functions
     
    735622  }
    736623
    737 #if RATE_CONTROL_LAMBDA_DOMAIN
    738624  if ( m_pcCfg->getUseRateCtrl() )
    739625  {
     
    741627    assert(0);
    742628  }
    743 #endif
    744629
    745630  TComSlice* pcSlice        = rpcPic->getSlice(getSliceIdx());
     
    773658#endif
    774659    m_pcRdCost    ->setLambda              ( m_pdRdPicLambda[uiQpIdx] );
    775 #if WEIGHTED_CHROMA_DISTORTION
    776660    // for RDO
    777661    // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma.
    778662    Int iQP = m_piRdPicQp    [uiQpIdx];
    779     Double weight = 1.0;
     663    Double weight[2] = { 1.0, 1.0 };
    780664    Int qpc;
    781665    Int chromaQPOffset;
     
    783667    chromaQPOffset = pcSlice->getPPS()->getChromaCbQpOffset() + pcSlice->getSliceQpDeltaCb();
    784668    qpc = Clip3( 0, 57, iQP + chromaQPOffset);
    785     weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
    786     m_pcRdCost->setCbDistortionWeight(weight);
     669    weight[0] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
     670    m_pcRdCost->setCbDistortionWeight(weight[0]);
    787671
    788672    chromaQPOffset = pcSlice->getPPS()->getChromaCrQpOffset() + pcSlice->getSliceQpDeltaCr();
    789673    qpc = Clip3( 0, 57, iQP + chromaQPOffset);
    790     weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
    791     m_pcRdCost->setCrDistortionWeight(weight);
    792 #endif
    793 
     674    weight[1] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
     675    m_pcRdCost->setCrDistortionWeight(weight[1]);
     676
     677    const Double lambdaArray[3] = {m_pdRdPicLambda[uiQpIdx], (m_pdRdPicLambda[uiQpIdx] / weight[0]), (m_pdRdPicLambda[uiQpIdx] / weight[1])};
    794678#if RDOQ_CHROMA_LAMBDA
    795679    // for RDOQ
    796     m_pcTrQuant   ->setLambda( m_pdRdPicLambda[uiQpIdx], m_pdRdPicLambda[uiQpIdx] / weight );
     680    m_pcTrQuant->setLambdas( lambdaArray );
    797681#else
    798682    m_pcTrQuant   ->setLambda              ( m_pdRdPicLambda[uiQpIdx] );
    799683#endif
    800 #if SAO_CHROMA_LAMBDA
    801684    // For SAO
    802     pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdx], m_pdRdPicLambda[uiQpIdx] / weight );
    803 #else
    804     pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdx] );
    805 #endif
     685    pcSlice->setLambdas( lambdaArray );
    806686
    807687    // try compress
     
    830710#endif
    831711  m_pcRdCost    ->setLambda              ( m_pdRdPicLambda[uiQpIdxBest] );
    832 #if WEIGHTED_CHROMA_DISTORTION
    833712  // in RdCost there is only one lambda because the luma and chroma bits are not separated, instead we weight the distortion of chroma.
    834713  Int iQP = m_piRdPicQp    [uiQpIdxBest];
    835   Double weight = 1.0;
     714  Double weight[2] = { 1.0, 1.0 };
    836715  Int qpc;
    837716  Int chromaQPOffset;
     
    839718  chromaQPOffset = pcSlice->getPPS()->getChromaCbQpOffset() + pcSlice->getSliceQpDeltaCb();
    840719  qpc = Clip3( 0, 57, iQP + chromaQPOffset);
    841   weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
    842   m_pcRdCost->setCbDistortionWeight(weight);
     720  weight[0] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
     721  m_pcRdCost->setCbDistortionWeight(weight[0]);
    843722
    844723  chromaQPOffset = pcSlice->getPPS()->getChromaCrQpOffset() + pcSlice->getSliceQpDeltaCr();
    845724  qpc = Clip3( 0, 57, iQP + chromaQPOffset);
    846   weight = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
    847   m_pcRdCost->setCrDistortionWeight(weight);
    848 #endif
    849 
     725  weight[1] = pow( 2.0, (iQP-g_aucChromaScale[qpc])/3.0 );  // takes into account of the chroma qp mapping and chroma qp Offset
     726  m_pcRdCost->setCrDistortionWeight(weight[1]);
     727
     728  const Double lambdaArray[3] = {m_pdRdPicLambda[uiQpIdxBest], (m_pdRdPicLambda[uiQpIdxBest] / weight[0]), (m_pdRdPicLambda[uiQpIdxBest] / weight[1])};
    850729#if RDOQ_CHROMA_LAMBDA
    851730  // for RDOQ
    852   m_pcTrQuant   ->setLambda( m_pdRdPicLambda[uiQpIdxBest], m_pdRdPicLambda[uiQpIdxBest] / weight );
     731  m_pcTrQuant->setLambdas( lambdaArray );
    853732#else
    854733  m_pcTrQuant   ->setLambda              ( m_pdRdPicLambda[uiQpIdxBest] );
    855734#endif
    856 #if SAO_CHROMA_LAMBDA
    857735  // For SAO
    858   pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdxBest], m_pdRdPicLambda[uiQpIdxBest] / weight );
    859 #else
    860   pcSlice       ->setLambda              ( m_pdRdPicLambda[uiQpIdxBest] );
    861 #endif
     736  pcSlice->setLambdas( lambdaArray );
    862737}
    863738
    864739/** \param rpcPic   picture class
    865740 */
    866 #if RATE_CONTROL_INTRA
    867741Void TEncSlice::calCostSliceI(TComPic*& rpcPic)
    868742{
     
    903777  m_pcRateCtrl->getRCPic()->setTotalIntraCost(iSumHadSlice);
    904778}
    905 #endif
    906779
    907780Void TEncSlice::compressSlice( TComPic*& rpcPic )
     
    1031904  UInt uiTileStartLCU = 0;
    1032905  UInt uiTileLCUX     = 0;
    1033 
    1034906  Bool depSliceSegmentsEnabled = pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag();
    1035907  uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());
     
    1080952    pcCU->initCU( rpcPic, uiCUAddr );
    1081953
    1082 #if !RATE_CONTROL_LAMBDA_DOMAIN
    1083     if(m_pcCfg->getUseRateCtrl())
    1084     {
    1085       if(m_pcRateCtrl->calculateUnitQP())
    1086       {
    1087         xLamdaRecalculation(m_pcRateCtrl->getUnitQP(), m_pcRateCtrl->getGOPId(), pcSlice->getDepth(), pcSlice->getSliceType(), pcSlice->getSPS(), pcSlice );
    1088       }
    1089     }
    1090 #endif
    1091954    // inherit from TR if necessary, select substream to use.
    1092955    if( m_pcCfg->getUseSBACRD() )
     
    11631026      ((TEncBinCABAC*)m_pcRDGoOnSbacCoder->getEncBinIf())->setBinCountingEnableFlag(true);
    11641027
    1165 #if RATE_CONTROL_LAMBDA_DOMAIN
    11661028      Double oldLambda = m_pcRdCost->getLambda();
    11671029      if ( m_pcCfg->getUseRateCtrl() )
     
    11711033        Double bpp       = -1.0;
    11721034
    1173 #if M0036_RC_IMPROVEMENT
    11741035        if ( ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE && m_pcCfg->getForceIntraQP() ) || !m_pcCfg->getLCULevelRC() )
    1175 #else
    1176         if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE || !m_pcCfg->getLCULevelRC() )
    1177 #endif
    11781036        {
    11791037          estQP = pcSlice->getSliceQp();
     
    11811039        else
    11821040        {
    1183 #if RATE_CONTROL_INTRA
    11841041          bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp(pcSlice->getSliceType());
    11851042          if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE)
     
    11921049            estQP     = m_pcRateCtrl->getRCPic()->getLCUEstQP    ( estLambda, pcSlice->getSliceQp() );
    11931050          }
    1194 #else
    1195           bpp       = m_pcRateCtrl->getRCPic()->getLCUTargetBpp();
    1196           estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp );
    1197           estQP     = m_pcRateCtrl->getRCPic()->getLCUEstQP    ( estLambda, pcSlice->getSliceQp() );
    1198 #endif
    11991051
    12001052#if REPN_FORMAT_IN_VPS
     
    12051057
    12061058          m_pcRdCost->setLambda(estLambda);
    1207 #if M0036_RC_IMPROVEMENT
    12081059#if RDOQ_CHROMA_LAMBDA
    12091060          // set lambda for RDOQ
    12101061          Double weight=m_pcRdCost->getChromaWeight();
    1211           m_pcTrQuant->setLambda( estLambda, estLambda / weight );
     1062          const Double lambdaArray[3] = { estLambda, (estLambda / weight), (estLambda / weight) };
     1063          m_pcTrQuant->setLambdas( lambdaArray );
    12121064#else
    12131065          m_pcTrQuant->setLambda( estLambda );
    1214 #endif
    12151066#endif
    12161067        }
     
    12191070        pcCU->getSlice()->setSliceQpBase( estQP );
    12201071      }
    1221 #endif
    12221072
    12231073      // run CU encoder
    12241074      m_pcCuEncoder->compressCU( pcCU );
    1225 
    1226 #if !TICKET_1090_FIX
    1227 #if RATE_CONTROL_LAMBDA_DOMAIN
    1228       if ( m_pcCfg->getUseRateCtrl() )
    1229       {
    1230 #if !M0036_RC_IMPROVEMENT
    1231         UInt SAD    = m_pcCuEncoder->getLCUPredictionSAD();
    1232 #if REPN_FORMAT_IN_VPS
    1233         Int height  = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );
    1234         Int width   = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->>getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );
    1235 #else
    1236         Int height  = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );
    1237         Int width   = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );
    1238 #endif
    1239         Double MAD = (Double)SAD / (Double)(height * width);
    1240         MAD = MAD * MAD;
    1241         ( m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr) ).m_MAD = MAD;
    1242 #endif
    1243 
    1244         Int actualQP        = g_RCInvalidQPValue;
    1245         Double actualLambda = m_pcRdCost->getLambda();
    1246         Int actualBits      = pcCU->getTotalBits();
    1247         Int numberOfEffectivePixels    = 0;
    1248         for ( Int idx = 0; idx < rpcPic->getNumPartInCU(); idx++ )
    1249         {
    1250           if ( pcCU->getPredictionMode( idx ) != MODE_NONE && ( !pcCU->isSkipped( idx ) ) )
    1251           {
    1252             numberOfEffectivePixels = numberOfEffectivePixels + 16;
    1253             break;
    1254           }
    1255         }
    1256 
    1257         if ( numberOfEffectivePixels == 0 )
    1258         {
    1259           actualQP = g_RCInvalidQPValue;
    1260         }
    1261         else
    1262         {
    1263           actualQP = pcCU->getQP( 0 );
    1264         }
    1265         m_pcRdCost->setLambda(oldLambda);
    1266 #if RATE_CONTROL_INTRA
    1267         m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,
    1268           pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() );
    1269 #else
    1270         m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, m_pcCfg->getLCULevelRC() );
    1271 #endif
    1272       }
    1273 #endif
    1274 #endif
    12751075
    12761076      // restore entropy coder to an initial stage
     
    13061106      }
    13071107
    1308 #if TICKET_1090_FIX
    1309 #if RATE_CONTROL_LAMBDA_DOMAIN
    13101108      if ( m_pcCfg->getUseRateCtrl() )
    13111109      {
    1312 #if !M0036_RC_IMPROVEMENT
    1313         UInt SAD    = m_pcCuEncoder->getLCUPredictionSAD();
    1314 #if REPN_FORMAT_IN_VPS
    1315         Int height  = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );
    1316         Int width   = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );
    1317 #else
    1318         Int height  = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );
    1319         Int width   = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );
    1320 #endif
    1321         Double MAD = (Double)SAD / (Double)(height * width);
    1322         MAD = MAD * MAD;
    1323         ( m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr) ).m_MAD = MAD;
    1324 #endif
    13251110
    13261111        Int actualQP        = g_RCInvalidQPValue;
     
    13471132        m_pcRdCost->setLambda(oldLambda);
    13481133
    1349 #if RATE_CONTROL_INTRA
    13501134        m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda,
    13511135          pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() );
    1352 #else
    1353         m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, m_pcCfg->getLCULevelRC() );
    1354 #endif
    1355       }
    1356 #endif
    1357 #endif
     1136      }
    13581137    }
    13591138    // other case: encodeCU is not called
     
    13771156    m_dPicRdCost     += pcCU->getTotalCost();
    13781157    m_uiPicDist      += pcCU->getTotalDistortion();
    1379 #if !RATE_CONTROL_LAMBDA_DOMAIN
    1380     if(m_pcCfg->getUseRateCtrl())
    1381     {
    1382       m_pcRateCtrl->updateLCUData(pcCU, pcCU->getTotalBits(), pcCU->getQP(0));
    1383       m_pcRateCtrl->updataRCUnitStatus();
    1384     }
    1385 #endif
    13861158  }
    13871159  if ((pcSlice->getPPS()->getNumSubstreams() > 1) && !depSliceSegmentsEnabled)
     
    13981170  }
    13991171  xRestoreWPparam( pcSlice );
    1400 #if !RATE_CONTROL_LAMBDA_DOMAIN
    1401   if(m_pcCfg->getUseRateCtrl())
    1402   {
    1403     m_pcRateCtrl->updateFrameData(m_uiPicTotalBits);
    1404   }
    1405 #endif
    14061172}
    14071173
     
    16031369
    16041370    TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr );
     1371#if HM_CLEANUP_SAO
     1372    if ( pcSlice->getSPS()->getUseSAO() )
     1373    {
     1374      if (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma())
     1375      {
     1376        SAOBlkParam& saoblkParam = (rpcPic->getPicSym()->getSAOBlkParam())[uiCUAddr];
     1377        Bool sliceEnabled[NUM_SAO_COMPONENTS];
     1378        sliceEnabled[SAO_Y] = pcSlice->getSaoEnabledFlag();
     1379        sliceEnabled[SAO_Cb]= sliceEnabled[SAO_Cr]= pcSlice->getSaoEnabledFlagChroma();
     1380
     1381        Bool leftMergeAvail = false;
     1382        Bool aboveMergeAvail= false;
     1383        //merge left condition
     1384        Int rx = (uiCUAddr % uiWidthInLCUs);
     1385        if(rx > 0)
     1386        {
     1387          leftMergeAvail = rpcPic->getSAOMergeAvailability(uiCUAddr, uiCUAddr-1);
     1388        }
     1389
     1390        //merge up condition
     1391        Int ry = (uiCUAddr / uiWidthInLCUs);
     1392        if(ry > 0)
     1393        {
     1394          aboveMergeAvail = rpcPic->getSAOMergeAvailability(uiCUAddr, uiCUAddr-uiWidthInLCUs);
     1395        }
     1396
     1397        m_pcEntropyCoder->encodeSAOBlkParam(saoblkParam,sliceEnabled, leftMergeAvail, aboveMergeAvail);
     1398      }
     1399    }
     1400#else
    16051401    if ( pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()) )
    16061402    {
     
    16851481      }
    16861482    }
     1483#endif
     1484
    16871485#if ENC_DEC_TRACE
    16881486    g_bJustDoIt = g_bEncDecTraceEnable;
Note: See TracChangeset for help on using the changeset viewer.