Ignore:
Timestamp:
17 Oct 2013, 20:17:10 (11 years ago)
Author:
kwu-htm
Message:

Clean up and revised according to the guideline.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-8.2-dev0-KWU/source/Lib/TLibEncoder/TEncRateCtrl.cpp

    r636 r637  
    644644
    645645#if KWU_RC_MADPRED_E0227
    646 Void TEncRCPic::create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures, Int LayerID )
     646Void TEncRCPic::create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures, Int layerID )
    647647#else
    648648Void TEncRCPic::create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures )
     
    717717
    718718#if KWU_RC_MADPRED_E0227
    719   m_LayerID = LayerID;
     719  m_LayerID = layerID;
    720720  m_lastIVPicture = NULL;
    721721  m_IVtotalMAD            = 0.0;
     
    10741074
    10751075#if KWU_RC_MADPRED_E0227
    1076 Double TEncRCPic::getLCUTargetBppforInterView( list<TEncRCPic*>& listPreviousPictures, TComDataCU* pcCU, Double BasePos, Double CurPos, Double FocalLen, Double Znear, Double Zfar, Int Direction, Int* iDisparity )
     1076Double TEncRCPic::getLCUTargetBppforInterView( list<TEncRCPic*>& listPreviousPictures, TComDataCU* pcCU, Double basePos, Double curPos, Double focalLen, Double znear, Double zfar, Int direction, Int* disparity )
    10771077{
    10781078  Int   LCUIdx    = getLCUCoded();
     
    10981098    Int   iStride = pcCU->getSlice()->getIvPic(true, pcCU->getSlice()->getViewIndex())->getPicYuvOrg()->getStride();
    10991099
    1100     Int   iWidth  = m_LCUs[ LCUIdx ].m_CUWidth;
    1101     Int   iHeight = m_LCUs[ LCUIdx ].m_CUHeight;
     1100    Int   width  = m_LCUs[ LCUIdx ].m_CUWidth;
     1101    Int   height = m_LCUs[ LCUIdx ].m_CUHeight;
    11021102
    11031103    for( y = 0 ; y < pcCU->getSlice()->getSPS()->getMaxCUHeight() ; y+=8)
     
    11121112    Double AvgDepth = (Double)Sum/((pcCU->getSlice()->getSPS()->getMaxCUHeight()/8)*(pcCU->getSlice()->getSPS()->getMaxCUWidth()/8));
    11131113
    1114     //Int iDisparity = pDepthGen->RCGetDisparityFromVirtDepth(0, (Int)AvgDepth);
    1115 
    1116     Double dFL = FocalLen * abs( BasePos - CurPos );
    1117     Double dZ  = abs( 1.0 / Znear - 1.0 / Zfar ) * ((Double)(AvgDepth) / (( 1 << g_bitDepthY ) - 1) ) + abs(1.0 / Zfar);
    1118     *iDisparity = (Int)(Direction*dFL * dZ);
     1114    Double fL = focalLen * abs( basePos - curPos );
     1115    Double z  = abs( 1.0 / znear - 1.0 / zfar ) * ((Double)(AvgDepth) / (( 1 << g_bitDepthY ) - 1) ) + abs(1.0 / zfar);
     1116    *disparity = (Int)(direction*fL * z);
    11191117    Int shift = DISTORTION_PRECISION_ADJUSTMENT(g_bitDepthY-8);
    11201118
    1121     Int Disp = *iDisparity;
    1122     Int PosX, PosY;
    1123     pcCU->getPosInPic(0, PosX, PosY);
    1124     if((PosX + *iDisparity) < 0 || (PosX + *iDisparity + iWidth) >= pcCU->getSlice()->getSPS()->getMaxCUWidth())
    1125     {
    1126       Disp = 0;
    1127     }
    1128 
    1129     for( y = 0; y < iHeight; y++ )
    1130     {
    1131       for( x = 0; x < iWidth; x++ )
    1132       {
    1133         SAD += abs( pOrg[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + Disp)]
    1134                   - pRec[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + Disp)] )>>shift;
     1119    Int disp = *disparity;
     1120    Int posX, posY;
     1121    pcCU->getPosInPic(0, posX, posY);
     1122    if((posX + *disparity) < 0 || (posX + *disparity + width) >= pcCU->getSlice()->getSPS()->getMaxCUWidth())
     1123    {
     1124      disp = 0;
     1125    }
     1126
     1127    for( y = 0; y < height; y++ )
     1128    {
     1129      for( x = 0; x < width; x++ )
     1130      {
     1131        SAD += abs( pOrg[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + disp)]
     1132                  - pRec[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + disp)] )>>shift;
    11351133      }
    11361134      pOrg += iStride;
    11371135      pRec += iStride;
    11381136    }
    1139     IVMAD = SAD / (Double)(iHeight * iWidth);
     1137    IVMAD = SAD / (Double)(height * width);
    11401138    IVMAD = IVMAD * IVMAD;
    11411139
     
    14401438  m_picLambda           = averageLambda;
    14411439#if !M0036_RC_IMPROVEMENT || KWU_RC_MADPRED_E0227
     1440#if KWU_RC_MADPRED_E0227
    14421441  m_totalMAD = 0;
     1442#endif
    14431443  for ( Int i=0; i<m_numberOfLCU; i++ )
    14441444  {
     
    16491649#if M0036_RC_IMPROVEMENT
    16501650#if KWU_RC_MADPRED_E0227
    1651 Void TEncRateCtrl::init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Bool keepHierBits, Bool useLCUSeparateModel, GOPEntry  GOPList[MAX_GOP], Int LayerID )
     1651Void TEncRateCtrl::init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Bool keepHierBits, Bool useLCUSeparateModel, GOPEntry  GOPList[MAX_GOP], Int layerID )
    16521652#else
    16531653Void TEncRateCtrl::init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int keepHierBits, Bool useLCUSeparateModel, GOPEntry  GOPList[MAX_GOP] )
     
    18671867
    18681868#if KWU_RC_MADPRED_E0227
    1869   setLayerID(LayerID);
     1869  setLayerID(layerID);
    18701870#endif
    18711871
     
    20822082  m_sourceHeightInLCU        = (sourceHeight / maxCUHeight) + (( sourceHeight %  maxCUHeight) ? 1 : 0); 
    20832083  m_isLowdelay               = (sizeIntraPeriod == -1) ? true : false;
    2084 #if KWU_RC_MADPRED_E0227
    2085   m_prevBitrate              = ( targetKbps * 1000 );  // in units of 1,024 bps
    2086   m_currBitrate              = ( targetKbps * 1000 );
    2087 #else
     2084
    20882085  m_prevBitrate              = ( targetKbps << 10 );  // in units of 1,024 bps
    20892086  m_currBitrate              = ( targetKbps << 10 );
    2090 #endif
     2087
    20912088  m_frameRate                = frameRate;
    20922089  m_refFrameNum              = m_isLowdelay ? (sizeGOP) : (sizeGOP>>1);
     
    24862483
    24872484#if KWU_RC_MADPRED_E0227
    2488 Void  TEncRateCtrl::updateLCUDataEnhancedView(TComDataCU* pcCU, UInt64 uiBits, Int iQP, Double BasePos, Double CurPos, Double FocalLen, Double Znear, Double Zfar, Int Direction)
     2485Void  TEncRateCtrl::updateLCUDataEnhancedView(TComDataCU* pcCU, UInt64 uiBits, Int qp, Double basePos, Double curPos, Double focalLen, Double znear, Double zfar, Int direction)
    24892486{
    24902487  Int     x, y;
     
    24982495  Int   iStride = pcCU->getSlice()->getIvPic(true, pcCU->getSlice()->getViewIndex())->getPicYuvOrg()->getStride();
    24992496
    2500   Int   iWidth  = m_pcLCUData[m_indexLCU].m_widthInPixel;
    2501   Int   iHeight = m_pcLCUData[m_indexLCU].m_heightInPixel;
     2497  Int   width  = m_pcLCUData[m_indexLCU].m_widthInPixel;
     2498  Int   height = m_pcLCUData[m_indexLCU].m_heightInPixel;
    25022499
    25032500  for( y = 0 ; y < pcCU->getSlice()->getSPS()->getMaxCUHeight() ; y+=8)
     
    25112508
    25122509  Double AvgDepth = (Double)Sum/((pcCU->getSlice()->getSPS()->getMaxCUHeight()/8)*(pcCU->getSlice()->getSPS()->getMaxCUWidth()/8));
    2513 
    2514   //Int iDisparity = pDepthGen->RCGetDisparityFromVirtDepth(0, (Int)AvgDepth);
    2515 
    2516   Double dFL = FocalLen * abs( BasePos - CurPos );
    2517   Double dZ  = abs( 1.0 / Znear - 1.0 / Zfar ) * ((Double)(AvgDepth) / (( 1 << g_bitDepthY ) - 1) ) + abs(1.0 / Zfar);
    2518   Int   iDisparity = (Int)(Direction*dFL * dZ);
     2510  Double fL = focalLen * abs( basePos - curPos );
     2511  Double z  = abs( 1.0 / znear - 1.0 / zfar ) * ((Double)(AvgDepth) / (( 1 << g_bitDepthY ) - 1) ) + abs(1.0 / zfar);
     2512  Int   disparity = (Int)(direction*fL * z);
    25192513  Int shift = DISTORTION_PRECISION_ADJUSTMENT(g_bitDepthY-8);
    2520   Int Disp = iDisparity;
    2521 
    2522   for( y = 0; y < iHeight; y++ )
    2523   {
    2524     for( x = 0; x < iWidth; x++ )
    2525     {
    2526       SAD += abs( pOrg[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + Disp)]
    2527       - pRec[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + Disp)] )>>shift;
     2514  Int disp = disparity;
     2515
     2516  for( y = 0; y < height; y++ )
     2517  {
     2518    for( x = 0; x < width; x++ )
     2519    {
     2520      SAD += abs( pOrg[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + disp)]
     2521      - pRec[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + disp)] )>>shift;
    25282522    }
    25292523    pOrg += iStride;
    25302524    pRec += iStride;
    25312525  }
    2532   m_pcLCUData[m_indexLCU].m_qp   = iQP;
    2533   m_pcLCUData[m_indexLCU].m_costMAD  = (SAD /(Double)(iWidth*iHeight));
     2526  m_pcLCUData[m_indexLCU].m_qp   = qp;
     2527  m_pcLCUData[m_indexLCU].m_costMAD  = (SAD /(Double)(width*height));
    25342528  m_pcLCUData[m_indexLCU].m_bits = (Int)uiBits;
    25352529}
Note: See TracChangeset for help on using the changeset viewer.