Ticket #29: RDO_bit_estimate.patch

File RDO_bit_estimate.patch, 9.5 KB (added by tpoirier, 8 years ago)
  • Lib/TLibCommon/TypeDef.h

     
    4747//! \ingroup TLibCommon
    4848//! \{
    4949
     50#define FIX_RDOQ_BIT_ESTIMATE 1  // correct RDOQ uninitialized values in case of vertical scan
     51
    5052///////////////////////////////////////////////////////////
    5153// KTA tools section start
    5254///////////////////////////////////////////////////////////
  • Lib/TLibEncoder/TEncCavlc.cpp

     
    15221522  assert(0);
    15231523}
    15241524
    1525 Void TEncCavlc::estBit( estBitsSbacStruct* /*pcEstBitsCabac*/, Int /*width*/, Int /*height*/, ChannelType /*chType*/ )
     1525Void TEncCavlc::estBit( estBitsSbacStruct* /*pcEstBitsCabac*/, Int /*width*/, Int /*height*/, ChannelType /*chType*/
     1526#if FIX_RDOQ_BIT_ESTIMATE
     1527  , UInt /*uiScanIdx*/
     1528#endif
     1529  )
    15261530{
    15271531  // printf("error : no VLC mode support in this version\n");
    15281532  return;
  • Lib/TLibEncoder/TEncCavlc.h

     
    177177  Void codeKLTFlags      (TComTU &rTu, ComponentID component);
    178178#endif
    179179
    180   Void estBit            ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType );
     180  Void estBit            ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType
     181#if FIX_RDOQ_BIT_ESTIMATE
     182    , UInt uiScanIdx
     183#endif
     184    );
    181185
    182186  Void xCodePredWeightTable          ( TComSlice* pcSlice );
    183187
  • Lib/TLibEncoder/TEncEntropy.cpp

     
    12051205  }
    12061206}
    12071207
    1208 Void TEncEntropy::estimateBit (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, const ChannelType chType)
     1208Void TEncEntropy::estimateBit (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, const ChannelType chType
     1209#if FIX_RDOQ_BIT_ESTIMATE
     1210  , UInt uiScanIdx
     1211#endif
     1212  )
    12091213{
    12101214#if JVET_C0024_QTBT
    12111215  if (width==2 || height==2)
     
    12131217      return;   //don't use RDOQ for 2xn;
    12141218  }
    12151219
    1216   m_pcEntropyCoderIf->estBit ( pcEstBitsSbac, width, height, chType );
     1220  m_pcEntropyCoderIf->estBit ( pcEstBitsSbac, width, height, chType
     1221#if FIX_RDOQ_BIT_ESTIMATE
     1222    , uiScanIdx
     1223#endif
     1224    );
    12171225#else
    12181226  const UInt heightAtEntropyCoding = (width != height) ? (height >> 1) : height;
    12191227
  • Lib/TLibEncoder/TEncEntropy.h

     
    150150  virtual Void codeKLTFlags      (TComTU &rTu, ComponentID component) = 0;
    151151#endif
    152152  virtual Void codeSAOBlkParam   (SAOBlkParam& saoBlkParam, const BitDepths &bitDepths, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail, Bool onlyEstMergeInfo = false)    =0;
    153   virtual Void estBit               (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType) = 0;
     153  virtual Void estBit               (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType
     154#if FIX_RDOQ_BIT_ESTIMATE
     155    , UInt uiScanIdx
     156#endif
     157    ) = 0;
    154158
    155159  virtual Void codeExplicitRdpcmMode ( TComTU &rTu, const ComponentID compID ) = 0;
    156160
     
    323327
    324328  Void encodeCoeffNxN         ( TComTU &rTu, TCoeff* pcCoef, const ComponentID compID );
    325329
    326   Void estimateBit             ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType );
     330  Void estimateBit             ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType
     331#if FIX_RDOQ_BIT_ESTIMATE
     332    , UInt uiScanIdx
     333#endif
     334    );
    327335
    328336  Void encodeSAOBlkParam(SAOBlkParam& saoBlkParam, const BitDepths &bitDepths, Bool* sliceEnabled, Bool leftMergeAvail, Bool aboveMergeAvail){m_pcEntropyCoderIf->codeSAOBlkParam(saoBlkParam, bitDepths, sliceEnabled, leftMergeAvail, aboveMergeAvail, false);}
    329337
  • Lib/TLibEncoder/TEncSbac.cpp

     
    28032803 *   estimate bit cost for CBP, significant map and significant coefficients
    28042804 ****************************************************************************
    28052805 */
    2806 Void TEncSbac::estBit( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType )
     2806Void TEncSbac::estBit( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType
     2807#if FIX_RDOQ_BIT_ESTIMATE
     2808  , UInt uiScanIdx
     2809#endif
     2810  )
    28072811{
    28082812  estCBFBit( pcEstBitsSbac );
    28092813
     
    28132817  estSignificantMapBit( pcEstBitsSbac, width, height, chType );
    28142818
    28152819  // encode last significant position
    2816   estLastSignificantPositionBit( pcEstBitsSbac, width, height, chType );
     2820  estLastSignificantPositionBit( pcEstBitsSbac, width, height, chType
     2821#if FIX_RDOQ_BIT_ESTIMATE
     2822    , uiScanIdx
     2823#endif
     2824    );
    28172825
    28182826  // encode significant coefficients
    28192827  estSignificantCoefficientsBit( pcEstBitsSbac, chType );
     
    29632971 ****************************************************************************
    29642972 */
    29652973
    2966 Void TEncSbac::estLastSignificantPositionBit( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType )
     2974Void TEncSbac::estLastSignificantPositionBit( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType
     2975#if FIX_RDOQ_BIT_ESTIMATE
     2976  , UInt uiScanIdx
     2977#endif
     2978  )
    29672979{
    29682980  //--------------------------------------------------------------------------------------------------.
     2981#if FIX_RDOQ_BIT_ESTIMATE
     2982  // swap
     2983  if (uiScanIdx == SCAN_VER)
     2984  {
     2985    swap(width, height);
     2986  }
     2987#endif
    29692988
    29702989  //set up the number of channels
    29712990
  • Lib/TLibEncoder/TEncSbac.h

     
    214214  // for RD-optimizatioon
    215215  // -------------------------------------------------------------------------------------------------------------------
    216216
    217   Void estBit               (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType);
     217  Void estBit               (estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType
     218#if FIX_RDOQ_BIT_ESTIMATE
     219    , UInt uiScanIdx
     220#endif
     221    );
    218222  Void estCBFBit                     ( estBitsSbacStruct* pcEstBitsSbac );
    219223  Void estSignificantCoeffGroupMapBit( estBitsSbacStruct* pcEstBitsSbac, ChannelType chType );
    220224  Void estSignificantMapBit          ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType );
    221   Void estLastSignificantPositionBit ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType );
     225  Void estLastSignificantPositionBit ( estBitsSbacStruct* pcEstBitsSbac, Int width, Int height, ChannelType chType
     226#if FIX_RDOQ_BIT_ESTIMATE
     227    , UInt uiScanIdx
     228#endif
     229    );
    222230  Void estSignificantCoefficientsBit ( estBitsSbacStruct* pcEstBitsSbac, ChannelType chType );
    223231
    224232  Void codeExplicitRdpcmMode            ( TComTU &rTu, const ComponentID compID );
  • Lib/TLibEncoder/TEncSearch.cpp

     
    18811881  if( useTransformSkip ? m_pcEncCfg->getUseRDOQTS() : m_pcEncCfg->getUseRDOQ() )
    18821882#endif
    18831883  {
    1884     m_pcEntropyCoder->estimateBit( m_pcTrQuant->m_pcEstBitsSbac, uiWidth, uiHeight, chType );
     1884#if FIX_RDOQ_BIT_ESTIMATE
     1885    COEFF_SCAN_TYPE scanType = COEFF_SCAN_TYPE(pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, uiHeight, compID));
     1886#endif
     1887    m_pcEntropyCoder->estimateBit( m_pcTrQuant->m_pcEstBitsSbac, uiWidth, uiHeight, chType
     1888#if FIX_RDOQ_BIT_ESTIMATE
     1889      , scanType
     1890#endif
     1891      );
    18851892  }
    18861893
    18871894  //--- transform and quantization ---
     
    21922199    if (useTransformSkip ? m_pcEncCfg->getUseRDOQTS() : m_pcEncCfg->getUseRDOQ())
    21932200#endif
    21942201    {
    2195         m_pcEntropyCoder->estimateBit(m_pcTrQuant->m_pcEstBitsSbac, uiWidth, uiHeight, chType);
     2202#if FIX_RDOQ_BIT_ESTIMATE
     2203      COEFF_SCAN_TYPE scanType = COEFF_SCAN_TYPE(pcCU->getCoefScanIdx(uiAbsPartIdx, uiWidth, uiHeight, compID));
     2204#endif
     2205        m_pcEntropyCoder->estimateBit(m_pcTrQuant->m_pcEstBitsSbac, uiWidth, uiHeight, chType
     2206#if FIX_RDOQ_BIT_ESTIMATE
     2207          , scanType
     2208#endif
     2209          );
    21962210    }
    21972211
    21982212    //--- transform and quantization ---
     
    87208734
    87218735                          if ((compID != COMPONENT_Cr) && ((transformSkipModeId == 1) ? m_pcEncCfg->getUseRDOQTS() : m_pcEncCfg->getUseRDOQ()))
    87228736                          {
    8723                               m_pcEntropyCoder->estimateBit(m_pcTrQuant->m_pcEstBitsSbac, tuCompRect.width, tuCompRect.height, toChannelType(compID));
     8737#if FIX_RDOQ_BIT_ESTIMATE
     8738                            COEFF_SCAN_TYPE scanType = COEFF_SCAN_TYPE(pcCU->getCoefScanIdx(uiAbsPartIdx, tuCompRect.width, tuCompRect.height, compID));
     8739#endif
     8740                              m_pcEntropyCoder->estimateBit(m_pcTrQuant->m_pcEstBitsSbac, tuCompRect.width, tuCompRect.height, toChannelType(compID)
     8741#if FIX_RDOQ_BIT_ESTIMATE
     8742                                , scanType
     8743#endif
     8744                                );
    87248745                          }
    87258746
    87268747#if RDOQ_CHROMA_LAMBDA