Ticket #1090: Ticket1090.patch

File Ticket1090.patch, 3.2 KB (added by libin, 11 years ago)

patch for ticket #1090

  • Lib/TLibCommon/TypeDef.h

     
    5454
    5555#define RATE_CONTROL_LAMBDA_DOMAIN                  1  ///< JCTVC-K0103, rate control by R-lambda model
    5656#define M0036_RC_IMPROVEMENT                        1  ///< JCTVC-M0036, improvement for R-lambda model based rate control
     57#define TICKET_1090_FIX                             1
    5758
    5859#define MAX_CPB_CNT                     32  ///< Upper bound of (cpb_cnt_minus1 + 1)
    5960#define MAX_NUM_LAYER_IDS                64
  • Lib/TLibEncoder/TEncSlice.cpp

     
    10551055      // run CU encoder
    10561056      m_pcCuEncoder->compressCU( pcCU );
    10571057
     1058#if !TICKET_1090_FIX
    10581059#if RATE_CONTROL_LAMBDA_DOMAIN
    10591060      if ( m_pcCfg->getUseRateCtrl() )
    10601061      {
     
    10931094        m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, m_pcCfg->getLCULevelRC() );
    10941095      }
    10951096#endif
     1097#endif
    10961098     
    10971099      // restore entropy coder to an initial stage
    10981100      m_pcEntropyCoder->setEntropyCoder ( m_pppcRDSbacCoder[0][CI_CURR_BEST], pcSlice );
     
    11251127          m_pcBufferSbacCoders[uiTileCol].loadContexts(ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]);
    11261128        }
    11271129      }
     1130
     1131#if TICKET_1090_FIX
     1132#if RATE_CONTROL_LAMBDA_DOMAIN
     1133      if ( m_pcCfg->getUseRateCtrl() )
     1134      {
     1135#if !M0036_RC_IMPROVEMENT
     1136        UInt SAD    = m_pcCuEncoder->getLCUPredictionSAD();
     1137        Int height  = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );
     1138        Int width   = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() );
     1139        Double MAD = (Double)SAD / (Double)(height * width);
     1140        MAD = MAD * MAD;
     1141        ( m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr) ).m_MAD = MAD;
     1142#endif
     1143
     1144        Int actualQP        = g_RCInvalidQPValue;
     1145        Double actualLambda = m_pcRdCost->getLambda();
     1146        Int actualBits      = pcCU->getTotalBits();
     1147        Int numberOfEffectivePixels    = 0;
     1148        for ( Int idx = 0; idx < rpcPic->getNumPartInCU(); idx++ )
     1149        {
     1150          if ( pcCU->getPredictionMode( idx ) != MODE_NONE && ( !pcCU->isSkipped( idx ) ) )
     1151          {
     1152            numberOfEffectivePixels = numberOfEffectivePixels + 16;
     1153            break;
     1154          }
     1155        }
     1156
     1157        if ( numberOfEffectivePixels == 0 )
     1158        {
     1159          actualQP = g_RCInvalidQPValue;
     1160        }
     1161        else
     1162        {
     1163          actualQP = pcCU->getQP( 0 );
     1164        }
     1165        m_pcRdCost->setLambda(oldLambda);
     1166
     1167        m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, m_pcCfg->getLCULevelRC() );
     1168      }
     1169#endif
     1170#endif
    11281171    }
    11291172    // other case: encodeCU is not called
    11301173    else