Changeset 635 in 3DVCSoftware for branches/HTM-8.2-dev0-KWU


Ignore:
Timestamp:
14 Oct 2013, 20:13:58 (11 years ago)
Author:
kwu-htm
Message:

"JCT3V-E0227 : Inter-view MAD prediction for 3D multi-view video" is integrated by KWU. Configuration has changed by adding rate control for URQ and the integrated view-wise target bitrate allocation and inter-view MAD prediction.

Location:
branches/HTM-8.2-dev0-KWU
Files:
4 added
1 deleted
22 edited

Legend:

Unmodified
Added
Removed
  • branches/HTM-8.2-dev0-KWU/cfg/3D-HEVC/baseCfg_3view+depth.cfg

    r622 r635  
    224224RCForceIntraQP                      : 0                # Rate control: force intra QP to be equal to initial QP
    225225
     226DepthMADPred                        : 0                # 0: Disable Depth based MAD prediction for extended view 1: Enable Depth based MAD prediction for extended view
     227TargetBitAssign                     : 0                 # Manual assignment of target bit-rate
     228ViewWiseTargetBits                  : 950000 315000 358000              # View-wise target bit-rate setting
     229
     230#============ Rate Control URQ ======================
     231#RateControl                         : 0                # 0: Disable rate control 1: Enable rate control with total target
     232#DepthMADPred                       : 0                # 0: Disable Depth based MAD prediction for extended view 1: Enable Depth based MAD prediction for extended view
     233#TargetBitAssign                    : 0                 # Manual assignment of target bit-rate
     234#ViewWiseTargetBits                 : 952 315 360       # View-wise target bit-rate setting
     235#TargetBitrate                       : 1500             # input target bitrate when RateCtrl is enable
     236#NumLCUInUnit                        : 1                # Number of LCU in an Unit. Fraction is not allowed
     237
    226238#========== multiview coding tools ==========
    227239IvMvPred                            : 1                # Inter-view motion prediction
  • branches/HTM-8.2-dev0-KWU/cfg/3D-HEVC/fullCfg.cfg

    r622 r635  
    230230RCForceIntraQP                      : 0                # Rate control: force intra QP to be equal to initial QP
    231231
     232DepthMADPred                        : 0                # 0: Disable Depth based MAD prediction for extended view 1: Enable Depth based MAD prediction for extended view
     233TargetBitAssign                     : 0                 # Manual assignment of target bit-rate
     234ViewWiseTargetBits                  : 950000 315000 358000              # View-wise target bit-rate setting
     235
     236#============ Rate Control URQ ======================
     237#RateControl                         : 0                # 0: Disable rate control 1: Enable rate control with total target
     238#DepthMADPred                       : 0                # 0: Disable Depth based MAD prediction for extended view 1: Enable Depth based MAD prediction for extended view
     239#TargetBitAssign                    : 0                 # Manual assignment of target bit-rate
     240#ViewWiseTargetBits                 : 952 315 360       # View-wise target bit-rate setting
     241#TargetBitrate                       : 1500             # input target bitrate when RateCtrl is enable
     242#NumLCUInUnit                        : 1                # Number of LCU in an Unit. Fraction is not allowed
     243
    232244#========== multiview coding tools ==========
    233245IvMvPred                            : 1                # Inter-view motion prediction
  • branches/HTM-8.2-dev0-KWU/source/App/TAppEncoder/TAppEncCfg.cpp

    r630 r635  
    8282  m_codedPivotValue = NULL;
    8383  m_targetPivotValue = NULL;
     84
     85#if KWU_RC_MADPRED_E0227
     86  m_uiDepthMADPred = 0;
     87#endif
    8488}
    8589
     
    594598  ( "InitialQP",           m_RCInitialQP,               0, "Rate control: initial QP" )
    595599  ( "RCForceIntraQP",      m_RCForceIntraQP,        false, "Rate control: force intra QP to be equal to initial QP" )
    596 #else
    597   ("RateCtrl,-rc", m_enableRateCtrl, false, "Rate control on/off")
     600
     601#if KWU_RC_VIEWRC_E0227
     602  ("ViewWiseTargetBits, -vtbr" ,  m_pchViewTargetBits,  std::vector<Int>(1, 32), "View-wise target bit-rate setting")
     603  ("TargetBitAssign, -ta", m_bViewWiseRateCtrl, false, "View-wise rate control on/off")
     604#endif
     605#if KWU_RC_MADPRED_E0227
     606  ("DepthMADPred, -dm", m_uiDepthMADPred, (UInt)0, "Depth based MAD prediction on/off")
     607#endif
     608#else
     609  ("RateControl,-rc", m_enableRateCtrl, false, "Rate control on/off")
    598610  ("TargetBitrate,-tbr", m_targetBitrate, 0, "Input target bitrate")
    599611  ("NumLCUInUnit,-nu", m_numLCUInUnit, 0, "Number of LCUs in an Unit")
     612
     613#if KWU_RC_VIEWRC_E0227
     614  ("ViewWiseTargetBits, -vtbr" ,  m_pchViewTargetBits,  std::vector<Int>(1, 32), "View-wise target bit-rate setting")
     615  ("TargetBitAssign, -ta", m_bViewWiseRateCtrl, false, "View-wise rate control on/off")
     616#endif
     617#if KWU_RC_MADPRED_E0227
     618  ("DepthMADPred, -dm", m_uiDepthMADPred, (UInt)0, "Depth based MAD prediction on/off")
     619#endif
    600620#endif
    601621
     
    21592179    xConfirmPara( (numLCUInPic % m_numLCUInUnit) != 0, "total number of LCUs in a frame should be completely divided by NumLCUInUnit" );
    21602180
    2161     m_iMaxDeltaQP       = MAX_DELTA_QP;
     2181    //m_iMaxDeltaQP       = MAX_DELTA_QP;
    21622182    m_iMaxCuDQPDepth    = MAX_CUDQP_DEPTH;
    21632183  }
     
    23012321    printf("InitialQP                    : %d\n", m_RCInitialQP );
    23022322    printf("ForceIntraQP                 : %d\n", m_RCForceIntraQP );
     2323
     2324#if KWU_RC_MADPRED_E0227
     2325    printf("Depth based MAD prediction   : %d\n", m_uiDepthMADPred);
     2326#endif
     2327#if KWU_RC_VIEWRC_E0227
     2328    printf("View-wise Rate control       : %d\n", m_bViewWiseRateCtrl);
     2329    if(m_bViewWiseRateCtrl)
     2330    {
     2331
     2332      printf("ViewWiseTargetBits           : ");
     2333      for (int i = 0 ; i < m_iNumberOfViews ; i++)
     2334        printf("%d ", m_pchViewTargetBits[i]);
     2335      printf("\n");
     2336    }
     2337    else
     2338    {
     2339      printf("TargetBitrate                : %d\n", m_RCTargetBitrate );
     2340    }
     2341#endif
    23032342  }
    23042343#else
     
    23082347    printf("TargetBitrate                : %d\n", m_targetBitrate);
    23092348    printf("NumLCUInUnit                 : %d\n", m_numLCUInUnit);
     2349
     2350#if KWU_RC_MADPRED_E0227
     2351    printf("Depth based MAD prediction   : %d\n", m_uiDepthMADPred);
     2352#endif
     2353#if KWU_RC_VIEWRC_E0227
     2354    printf("View-wise Rate control       : %d\n", m_bViewWiseRateCtrl);
     2355    if(m_bViewWiseRateCtrl)
     2356    {
     2357
     2358      printf("ViewWiseTargetBits           : ");
     2359      for (int i = 0 ; i < m_iNumberOfViews ; i++)
     2360        printf("%d ", m_pchViewTargetBits[i]);
     2361      printf("\n");
     2362    }
     2363    else
     2364    {
     2365      printf("TargetBitrate                : %d\n", m_targetBitrate );
     2366    }
     2367#endif
    23102368  }
    23112369#endif
  • branches/HTM-8.2-dev0-KWU/source/App/TAppEncoder/TAppEncCfg.h

    r622 r635  
    367367  Int       m_RCInitialQP;                        ///< inital QP for rate control
    368368  Bool      m_RCForceIntraQP;                     ///< force all intra picture to use initial QP or not
     369
     370#if KWU_RC_VIEWRC_E0227
     371  vector<Int>     m_pchViewTargetBits;
     372  bool      m_bViewWiseRateCtrl;                              ///< Flag for using view-wise rate control
     373#endif
     374#if KWU_RC_MADPRED_E0227
     375  UInt       m_uiDepthMADPred;
     376#endif
    369377#else
    370378  Bool      m_enableRateCtrl;                                   ///< Flag for using rate control algorithm
    371379  Int       m_targetBitrate;                                 ///< target bitrate
    372380  Int       m_numLCUInUnit;                                  ///< Total number of LCUs in a frame should be completely divided by the NumLCUInUnit
     381
     382#if KWU_RC_VIEWRC_E0227
     383  vector<Int>     m_pchViewTargetBits;
     384  bool      m_bViewWiseRateCtrl;                              ///< Flag for using view-wise rate control
     385#endif
     386#if KWU_RC_MADPRED_E0227
     387  UInt       m_uiDepthMADPred;
     388#endif
    373389#endif
    374390  Int       m_useScalingListId;                               ///< using quantization matrix
  • branches/HTM-8.2-dev0-KWU/source/App/TAppEncoder/TAppEncTop.cpp

    r622 r635  
    512512  m_cTEncTop.setSignHideFlag(m_signHideFlag);
    513513#if RATE_CONTROL_LAMBDA_DOMAIN
    514   m_cTEncTop.setUseRateCtrl         ( m_RCEnableRateControl );
     514  if(!m_cTEncTop.getIsDepth())    //only for texture
     515    m_cTEncTop.setUseRateCtrl         ( m_RCEnableRateControl );
     516  else
     517    m_cTEncTop.setUseRateCtrl         ( 0 );
     518#if !KWU_RC_VIEWRC_E0227
    515519  m_cTEncTop.setTargetBitrate       ( m_RCTargetBitrate );
     520#endif
    516521  m_cTEncTop.setKeepHierBit         ( m_RCKeepHierarchicalBit );
    517522  m_cTEncTop.setLCULevelRC          ( m_RCLCULevelRC );
     
    519524  m_cTEncTop.setInitialQP           ( m_RCInitialQP );
    520525  m_cTEncTop.setForceIntraQP        ( m_RCForceIntraQP );
    521 #else
    522   m_cTEncTop.setUseRateCtrl     ( m_enableRateCtrl);
    523   m_cTEncTop.setTargetBitrate   ( m_targetBitrate);
    524   m_cTEncTop.setNumLCUInUnit    ( m_numLCUInUnit);
     526
     527#if KWU_RC_MADPRED_E0227
     528  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
     529  {
     530    m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_uiDepthMADPred       : 0);
     531
     532    if(m_cTEncTop.getUseDepthMADPred())
     533      m_cTEncTop.setCamParam(&m_cCameraData);
     534  }
     535#endif
     536#if KWU_RC_VIEWRC_E0227
     537  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
     538  {
     539    m_cTEncTop.setUseViewWiseRateCtrl(m_bViewWiseRateCtrl);
     540
     541    if(m_iNumberOfViews == 1)
     542    {
     543      if(m_bViewWiseRateCtrl)
     544      {
     545        m_cTEncTop.setTargetBitrate(m_pchViewTargetBits[layerIdInVps>>1]);
     546      }
     547      else
     548        m_cTEncTop.setTargetBitrate       ( m_RCTargetBitrate );
     549    }
     550    else
     551    {
     552      if(m_bViewWiseRateCtrl)
     553      {
     554        m_cTEncTop.setTargetBitrate(m_pchViewTargetBits[layerIdInVps>>1]);
     555      }
     556      else
     557      {
     558        if(m_iNumberOfViews == 2)
     559        {
     560          if(m_cTEncTop.getViewId() == 0)
     561            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*80)/100 );
     562          else if(m_cTEncTop.getViewId() == 1)
     563            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*20)/100 );
     564        }
     565        else if(m_iNumberOfViews == 3)
     566        {
     567          if(m_cTEncTop.getViewId() == 0)
     568            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*66)/100 );
     569          else if(m_cTEncTop.getViewId() == 1)
     570            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*17)/100 );
     571          else if(m_cTEncTop.getViewId() == 2)
     572            m_cTEncTop.setTargetBitrate              ( (m_RCTargetBitrate*17)/100 );
     573        }
     574        else
     575          m_cTEncTop.setTargetBitrate              ( m_RCTargetBitrate );
     576      }
     577    }
     578  }
     579#endif
     580#else
     581  if(!m_cTEncTop.getIsDepth())    //only for texture
     582  {
     583    m_cTEncTop.setUseRateCtrl         ( m_enableRateCtrl );
     584#if !KWU_RC_VIEWRC_E0227
     585    m_cTEncTop.setTargetBitrate       ( m_targetBitrate );
     586#endif
     587    m_cTEncTop.setNumLCUInUnit        ( m_numLCUInUnit);
     588  }
     589  else
     590    m_cTEncTop.setUseRateCtrl         ( 0 );
     591 
     592#if KWU_RC_MADPRED_E0227
     593  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
     594  {
     595    m_cTEncTop.setUseDepthMADPred(layerIdInVps ? m_uiDepthMADPred       : 0);
     596
     597    if(m_cTEncTop.getUseDepthMADPred())
     598      m_cTEncTop.setCamParam(&m_cCameraData);
     599  }
     600#endif
     601
     602#if KWU_RC_VIEWRC_E0227
     603  if(m_cTEncTop.getUseRateCtrl() && !m_cTEncTop.getIsDepth())
     604  {
     605    m_cTEncTop.setUseViewWiseRateCtrl(m_bViewWiseRateCtrl);
     606    if(m_iNumberOfViews == 1)
     607    {
     608      if(m_bViewWiseRateCtrl)
     609      {
     610        m_cTEncTop.setTargetBitrate(m_pchViewTargetBits[layerIdInVps>>1]);
     611      }
     612      else
     613        m_cTEncTop.setTargetBitrate       ( m_targetBitrate );
     614    }
     615    else
     616    {
     617      if(m_bViewWiseRateCtrl)
     618      {
     619        m_cTEncTop.setTargetBitrate(m_pchViewTargetBits[layerIdInVps>>1]);
     620      }
     621      else
     622      {
     623        if(m_iNumberOfViews == 2)
     624        {
     625          if(m_cTEncTop.getViewId() == 0)
     626            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*80)/100 );
     627          else if(m_cTEncTop.getViewId() == 1)
     628            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*20)/100 );
     629        }
     630        else if(m_iNumberOfViews == 3)
     631        {
     632          if(m_cTEncTop.getViewId() == 0)
     633            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*66)/100 );
     634          else if(m_cTEncTop.getViewId() == 1)
     635            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*17)/100 );
     636          else if(m_cTEncTop.getViewId() == 2)
     637            m_cTEncTop.setTargetBitrate              ( (m_targetBitrate*17)/100 );
     638        }
     639        else
     640          m_cTEncTop.setTargetBitrate              ( m_targetBitrate );
     641      }
     642    }
     643  }
     644#endif
    525645#endif
    526646  m_cTEncTop.setTransquantBypassEnableFlag(m_TransquantBypassEnableFlag);
     
    669789  for(Int layer=0; layer<m_numberOfLayers; layer++)
    670790  {
     791#if KWU_RC_MADPRED_E0227
     792    m_acTEncTopList[layer]->init( this );
     793#else
    671794    m_acTEncTopList[layer]->init( );
     795#endif
    672796  }
    673797#else
     
    789913      }
    790914    }
     915
     916#if !RATE_CONTROL_LAMBDA_DOMAIN
     917    for(Int layer=0; layer < m_numberOfLayers; layer++ )
     918    {
     919      if(m_acTEncTopList[layer]->getUseRateCtrl()  && !m_acTEncTopList[layer]->getIsDepth())
     920      {
     921        m_acTEncTopList[layer]->getRateCtrl()->updateRCGOPStatus();
     922      }
     923    }
     924#endif
     925
    791926    gopSize = maxGopSize;
    792927  }
  • branches/HTM-8.2-dev0-KWU/source/App/TAppEncoder/TAppEncTop.h

    r622 r635  
    5050#endif
    5151
     52#if KWU_RC_MADPRED_E0227
     53class TEncTop;
     54#endif
    5255//! \ingroup TAppEncoder
    5356//! \{
  • branches/HTM-8.2-dev0-KWU/source/Lib/TAppCommon/TAppComCamPara.cpp

    r608 r635  
    15261526}
    15271527#endif
     1528
     1529
     1530#if KWU_RC_MADPRED_E0227
     1531Void
     1532  TAppComCamPara::RCGetZNearZFar( Int iView, UInt uiFrame, Double& rdZNear, Double& rdZFar )
     1533{
     1534  UInt uiFoundLine = -1;
     1535  if( !xGetCameraDataRow( m_aiBaseViews[iView], uiFrame, uiFoundLine ) || !( m_aadCameraParameters[ uiFoundLine ].size() < 8 ) )
     1536  {
     1537    rdZNear = m_aadCameraParameters[ uiFoundLine ][ 6 ];
     1538    rdZFar  = m_aadCameraParameters[ uiFoundLine ][ 7 ];
     1539  }
     1540  else
     1541  {
     1542    std::cerr << "No ZNear or no ZFar for View " << (Double)iView / m_dViewNumPrec << " and Frame " << uiFrame << " given in CameraParameterFile" << std::endl;
     1543    exit( EXIT_FAILURE );
     1544  }
     1545}
     1546
     1547
     1548Void
     1549  TAppComCamPara::RCGetGeometryData( Int iView, UInt uiFrame, Double& rdFocalLength, Double& rdPosition, Double& rdCameraShift, Bool& rbInterpolated )
     1550{
     1551  UInt uiFoundLine = -1;
     1552  if ( !xGetCameraDataRow( m_aiBaseViews[iView], uiFrame, uiFoundLine ) )
     1553  {
     1554    AOT( m_aadCameraParameters[ uiFoundLine ].size() < 6 );
     1555    rbInterpolated = false;
     1556    rdFocalLength =  m_aadCameraParameters[ uiFoundLine ][ 3 ];
     1557    rdPosition    =  m_aadCameraParameters[ uiFoundLine ][ 4 ];
     1558    rdCameraShift =  m_aadCameraParameters[ uiFoundLine ][ 5 ];
     1559  }
     1560  else
     1561  {
     1562    UInt uiLeftViewLine;
     1563    UInt uiRightViewLine;
     1564    Int  iLeftView;
     1565    Int  iRightView;
     1566    Int  iDummy;
     1567
     1568    if( !xGetLeftRightView( iView, m_aiViewsInCfgFile, iLeftView, iRightView, iDummy, iDummy ) ||
     1569      xGetCameraDataRow( iLeftView,  uiFrame, uiLeftViewLine  )                             ||
     1570      xGetCameraDataRow( iRightView, uiFrame, uiRightViewLine )
     1571      )
     1572    {
     1573      std::cerr << "No Left or no Right View next to View " << (Double)iView / m_dViewNumPrec << " for Frame " << uiFrame << " given in CameraParameterFile" << std::endl;
     1574      AOT(true);
     1575      exit( EXIT_FAILURE );
     1576    }
     1577    AOT( m_aadCameraParameters[ uiLeftViewLine  ].size() < 6 );
     1578    AOT( m_aadCameraParameters[ uiRightViewLine ].size() < 6 );
     1579
     1580    // Linear Interpolation
     1581    Double dFactor = ( (Double)( iView - iLeftView ) ) / ( (Double)( iRightView - iLeftView ) );
     1582    rdFocalLength  = m_aadCameraParameters[ uiLeftViewLine ][ 3 ] + dFactor * ( m_aadCameraParameters[ uiRightViewLine ][ 3 ] - m_aadCameraParameters[ uiLeftViewLine ][ 3 ] );
     1583    rdPosition     = m_aadCameraParameters[ uiLeftViewLine ][ 4 ] + dFactor * ( m_aadCameraParameters[ uiRightViewLine ][ 4 ] - m_aadCameraParameters[ uiLeftViewLine ][ 4 ] );
     1584    rdCameraShift  = m_aadCameraParameters[ uiLeftViewLine ][ 5 ] + dFactor * ( m_aadCameraParameters[ uiRightViewLine ][ 5 ] - m_aadCameraParameters[ uiLeftViewLine ][ 5 ] );
     1585    rbInterpolated = true;
     1586  }
     1587}
     1588#endif
  • branches/HTM-8.2-dev0-KWU/source/Lib/TAppCommon/TAppComCamPara.h

    r608 r635  
    220220  Int**               getCodedScale             ()  { return m_aaiCodedScale;           }
    221221  Int**               getCodedOffset            ()  { return m_aaiCodedOffset;          }
     222
     223#if KWU_RC_MADPRED_E0227
     224  Void  RCGetZNearZFar             ( Int iView, UInt uiFrame, Double& rdZNear, Double& rdZFar );
     225  Void  RCGetGeometryData          ( Int dView, UInt uiFrame, Double& rdFocalLength, Double& rdPosition, Double& rdCameraShift, Bool& rbInterpolated );
     226#endif
    222227};
    223228
  • branches/HTM-8.2-dev0-KWU/source/Lib/TLibCommon/TComRdCost.cpp

    r622 r635  
    614614#endif
    615615
    616 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
     616#if (RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT) || KWU_RC_MADPRED_E0227
    617617UInt TComRdCost::getSADPart ( Int bitDepth, Pel* pelCur, Int curStride,  Pel* pelOrg, Int orgStride, UInt width, UInt height )
    618618{
  • branches/HTM-8.2-dev0-KWU/source/Lib/TLibCommon/TComRdCost.h

    r622 r635  
    343343#endif
    344344
    345 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
     345#if (RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT) || KWU_RC_MADPRED_E0227
    346346  UInt   getSADPart ( Int bitDepth, Pel* pelCur, Int curStride,  Pel* pelOrg, Int orgStride, UInt width, UInt height );
    347347#endif
  • branches/HTM-8.2-dev0-KWU/source/Lib/TLibCommon/TComSlice.cpp

    r622 r635  
    472472  {
    473473    // The variable NumPocTotalCurr is derived as specified in subclause 7.4.7.2. It is a requirement of bitstream conformance that the following applies to the value of NumPocTotalCurr:
    474     // “ If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
    475     // “ Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
     474    // ?If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
     475    // ?Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
    476476    if (getRapPicFlag())
    477477    {
     
    827827    // The variable NumPocTotalCurr is derived as specified in subclause 7.4.7.2. It is a requirement of bitstream conformance that the following applies to the value of NumPocTotalCurr:
    828828#if H_MV
    829     // – If nuh_layer_id is equal to 0 and the current picture is a BLA picture or a CRA picture, the value of NumPocTotalCurr shall be equal to 0.
    830     // – Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
     829    // ??If nuh_layer_id is equal to 0 and the current picture is a BLA picture or a CRA picture, the value of NumPocTotalCurr shall be equal to 0.
     830    // ??Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
    831831    if ( getRapPicFlag() && m_layerId == 0 )
    832832#else
    833     // – If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
    834     // – Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
     833    // ??If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.
     834    // ??Otherwise, when the current picture contains a P or B slice, the value of NumPocTotalCurr shall not be equal to 0.
    835835    if (getRapPicFlag())
    836836#endif
  • branches/HTM-8.2-dev0-KWU/source/Lib/TLibCommon/TypeDef.h

    r632 r635  
    306306#define TICKET_1090_FIX                             1
    307307
     308#if RATE_CONTROL_LAMBDA_DOMAIN
    308309#define RC_FIX                                      1  /// suggested fix for M0036
    309310#define RATE_CONTROL_INTRA                          1  ///< JCTVC-M0257, rate control for intra
     311#endif
     312#define KWU_RC_VIEWRC_E0227                         0  ///< JCT3V-E0227, view-wise target bitrate allocation
     313#define KWU_RC_MADPRED_E0227                        0  ///< JCT3V-E0227, inter-view MAD prediction
    310314
    311315#define MAX_CPB_CNT                     32  ///< Upper bound of (cpb_cnt_minus1 + 1)
  • branches/HTM-8.2-dev0-KWU/source/Lib/TLibEncoder/TEncCfg.h

    r622 r635  
    310310  Int       m_RCInitialQP;
    311311  Bool      m_RCForceIntraQP;
     312
     313#if KWU_RC_MADPRED_E0227
     314  UInt       m_uiDepthMADPred;
     315#endif
     316#if KWU_RC_VIEWRC_E0227
     317  Bool      m_bViewWiseRateCtrl;
     318#endif
    312319#else
    313320  Bool      m_enableRateCtrl;                                ///< Flag for using rate control algorithm
    314321  Int       m_targetBitrate;                                 ///< target bitrate
    315322  Int       m_numLCUInUnit;                                  ///< Total number of LCUs in a frame should be divided by the NumLCUInUnit
     323
     324#if KWU_RC_MADPRED_E0227
     325  UInt       m_uiDepthMADPred;
     326#endif
     327#if KWU_RC_VIEWRC_E0227
     328  Bool      m_bViewWiseRateCtrl;
     329#endif
    316330#endif
    317331  Bool      m_TransquantBypassEnableFlag;                     ///< transquant_bypass_enable_flag setting in PPS.
     
    826840  Bool      getForceIntraQP        ()              { return m_RCForceIntraQP;        }
    827841  Void      setForceIntraQP        ( Bool b )      { m_RCForceIntraQP = b;           }
     842
     843#if KWU_RC_MADPRED_E0227
     844  UInt      getUseDepthMADPred    ()                { return m_uiDepthMADPred;        }
     845  Void      setUseDepthMADPred    (UInt b)          { m_uiDepthMADPred    = b;        }
     846#endif
     847#if KWU_RC_VIEWRC_E0227
     848  Bool      getUseViewWiseRateCtrl    ()                { return m_bViewWiseRateCtrl;        }
     849  Void      setUseViewWiseRateCtrl    (Bool b)          { m_bViewWiseRateCtrl    = b;        }
     850#endif
    828851#else
    829852  Bool      getUseRateCtrl    ()                { return m_enableRateCtrl;    }
     
    833856  Int       getNumLCUInUnit   ()                { return m_numLCUInUnit;      }
    834857  Void      setNumLCUInUnit   (Int numLCUs)     { m_numLCUInUnit   = numLCUs; }
     858
     859#if KWU_RC_MADPRED_E0227
     860  UInt      getUseDepthMADPred    ()                { return m_uiDepthMADPred;        }
     861  Void      setUseDepthMADPred    (UInt b)          { m_uiDepthMADPred    = b;        }
     862#endif
     863#if KWU_RC_VIEWRC_E0227
     864  Bool      getUseViewWiseRateCtrl    ()                { return m_bViewWiseRateCtrl;        }
     865  Void      setUseViewWiseRateCtrl    (Bool b)          { m_bViewWiseRateCtrl    = b;        }
     866#endif
    835867#endif
    836868  Bool      getTransquantBypassEnableFlag()           { return m_TransquantBypassEnableFlag; }
  • branches/HTM-8.2-dev0-KWU/source/Lib/TLibEncoder/TEncCu.cpp

    r622 r635  
    103103 
    104104  m_bEncodeDQP = false;
    105 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
     105#if (RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT) || KWU_RC_MADPRED_E0227
    106106  m_LCUPredictionSAD = 0;
    107107  m_addSADDepth      = 0;
    108108  m_temporalSAD      = 0;
     109  m_spatialSAD       = 0;
    109110#endif
    110111
     
    241242 
    242243  m_bUseSBACRD        = pcEncTop->getUseSBACRD();
    243   m_pcRateCtrl        = pcEncTop->getRateCtrl();
     244  if(!pcEncTop->getIsDepth())
     245    m_pcRateCtrl        = pcEncTop->getRateCtrl();
     246  else
     247  {
     248    m_pcRateCtrl = NULL;
     249  }
    244250}
    245251
     
    256262  m_ppcTempCU[0]->initCU( rpcCU->getPic(), rpcCU->getAddr() );
    257263
    258 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
     264#if (RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT) || KWU_RC_MADPRED_E0227
    259265  m_addSADDepth      = 0;
    260266  m_LCUPredictionSAD = 0;
    261267  m_temporalSAD      = 0;
     268  m_spatialSAD       = 0;
    262269#endif
    263270
     
    464471
    465472#if RATE_CONTROL_LAMBDA_DOMAIN
    466   if ( m_pcEncCfg->getUseRateCtrl() )
     473  if ( m_pcEncCfg->getUseRateCtrl() && !m_pcEncCfg->getIsDepth() )
    467474  {
    468475    iMinQP = m_pcRateCtrl->getRCQP();
     
    470477  }
    471478#else
    472   if(m_pcEncCfg->getUseRateCtrl())
     479  if(m_pcEncCfg->getUseRateCtrl() && !m_pcEncCfg->getIsDepth())
    473480  {
    474481    Int qp = m_pcRateCtrl->getUnitQP();
     
    671678    }
    672679
    673 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
     680#if (RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT) || KWU_RC_MADPRED_E0227
    674681    if ( uiDepth <= m_addSADDepth )
    675682    {
    676683      m_LCUPredictionSAD += m_temporalSAD;
    677684      m_addSADDepth = uiDepth;
     685    }
     686#endif
     687#if !RATE_CONTROL_LAMBDA_DOMAIN
     688    if(m_pcEncCfg->getUseRateCtrl())
     689    {
     690      Int qp = m_pcRateCtrl->getUnitQP();
     691      iMinQP  = Clip3( MIN_QP, MAX_QP, qp);
     692      iMaxQP  = Clip3( MIN_QP, MAX_QP, qp);
    678693    }
    679694#endif
     
    10121027          {
    10131028            xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N );
     1029#if (RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT) || KWU_RC_MADPRED_E0227
     1030            if ( uiDepth <= m_addSADDepth )
     1031            {
     1032              m_LCUPredictionSAD += m_spatialSAD;
     1033              m_addSADDepth = uiDepth;
     1034            }
     1035#endif
    10141036            rpcTempCU->initEstData( uiDepth, iQP );
    10151037            if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth )
     
    11461168  }
    11471169#if RATE_CONTROL_LAMBDA_DOMAIN
    1148   if ( m_pcEncCfg->getUseRateCtrl() )
     1170  if ( m_pcEncCfg->getUseRateCtrl() && !m_pcEncCfg->getIsDepth() )
    11491171  {
    11501172    iMinQP = m_pcRateCtrl->getRCQP();
     
    11521174  }
    11531175#else
    1154   if(m_pcEncCfg->getUseRateCtrl())
     1176  if(m_pcEncCfg->getUseRateCtrl() && !m_pcEncCfg->getIsDepth())
    11551177  {
    11561178    Int qp = m_pcRateCtrl->getUnitQP();
     
    21022124#endif
    21032125
    2104 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
     2126#if RATE_CONTROL_LAMBDA_DOMAIN  && !M0036_RC_IMPROVEMENT
     2127#if KWU_RC_MADPRED_E0227
    21052128  if ( m_pcEncCfg->getUseRateCtrl() && m_pcEncCfg->getLCULevelRC() && ePartSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth )
     2129  {
     2130    UInt SAD = m_pcRdCost->getSADPart( g_bitDepthY, m_ppcPredYuvTemp[uhDepth]->getLumaAddr(), m_ppcPredYuvTemp[uhDepth]->getStride(),
     2131      m_ppcOrigYuv[uhDepth]->getLumaAddr(), m_ppcOrigYuv[uhDepth]->getStride(),
     2132      rpcTempCU->getWidth(0), rpcTempCU->getHeight(0) );
     2133    m_temporalSAD = (Int)SAD;
     2134  }
     2135#endif
     2136#endif
     2137#if !RATE_CONTROL_LAMBDA_DOMAIN  && KWU_RC_MADPRED_E0227
     2138  if ( m_pcEncCfg->getUseRateCtrl() && ePartSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth )
    21062139  {
    21072140    UInt SAD = m_pcRdCost->getSADPart( g_bitDepthY, m_ppcPredYuvTemp[uhDepth]->getLumaAddr(), m_ppcPredYuvTemp[uhDepth]->getStride(),
     
    22352268  rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
    22362269 
     2270#if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
     2271#if KWU_RC_MADPRED_E0227
     2272  UChar uhDepth = rpcTempCU->getDepth( 0 );
     2273  if ( m_pcEncCfg->getUseRateCtrl() && m_pcEncCfg->getLCULevelRC() && eSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth )
     2274  {
     2275    UInt SAD = m_pcRdCost->getSADPart( g_bitDepthY, m_ppcPredYuvTemp[uhDepth]->getLumaAddr(), m_ppcPredYuvTemp[uhDepth]->getStride(),
     2276      m_ppcOrigYuv[uhDepth]->getLumaAddr(), m_ppcOrigYuv[uhDepth]->getStride(),
     2277      rpcTempCU->getWidth(0), rpcTempCU->getHeight(0) );
     2278    m_spatialSAD = (Int)SAD;
     2279  }
     2280#endif
     2281#endif
     2282#if !RATE_CONTROL_LAMBDA_DOMAIN && KWU_RC_MADPRED_E0227
     2283  UChar uhDepth = rpcTempCU->getDepth( 0 );
     2284  if ( m_pcEncCfg->getUseRateCtrl() && eSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth )
     2285  {
     2286    UInt SAD = m_pcRdCost->getSADPart( g_bitDepthY, m_ppcPredYuvTemp[uhDepth]->getLumaAddr(), m_ppcPredYuvTemp[uhDepth]->getStride(),
     2287      m_ppcOrigYuv[uhDepth]->getLumaAddr(), m_ppcOrigYuv[uhDepth]->getStride(),
     2288      rpcTempCU->getWidth(0), rpcTempCU->getHeight(0) );
     2289    m_spatialSAD = (Int)SAD;
     2290  }
     2291#endif
    22372292  xCheckDQP( rpcTempCU );
    22382293  xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth);
  • branches/HTM-8.2-dev0-KWU/source/Lib/TLibEncoder/TEncCu.h

    r608 r635  
    102102  Bool                    m_bUseSBACRD;
    103103  TEncRateCtrl*           m_pcRateCtrl;
    104 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
     104#if (RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT) || KWU_RC_MADPRED_E0227
    105105  UInt                    m_LCUPredictionSAD;
    106106  Int                     m_addSADDepth;
    107107  Int                     m_temporalSAD;
     108  Int                     m_spatialSAD;
    108109#endif
    109110public:
     
    124125 
    125126  Void setBitCounter        ( TComBitCounter* pcBitCounter ) { m_pcBitCounter = pcBitCounter; }
    126 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
     127#if (RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT) || KWU_RC_MADPRED_E0227
    127128  UInt getLCUPredictionSAD() { return m_LCUPredictionSAD; }
    128129#endif
  • branches/HTM-8.2-dev0-KWU/source/Lib/TLibEncoder/TEncGOP.cpp

    r630 r635  
    153153#endif
    154154#endif
     155
     156#if !RATE_CONTROL_LAMBDA_DOMAIN
     157  m_pcRateCtrl           = pcTEncTop->getRateCtrl();
     158#endif
    155159}
    156160
     
    977981      }
    978982      m_pcRateCtrl->initRCPic( frameLevel );
     983
     984#if KWU_RC_MADPRED_E0227
     985      if(m_pcCfg->getLayerId() != 0)
     986        m_pcRateCtrl->getRCPic()->setIVPic( m_pcEncTop->getEncTop()->getTEncTop(0)->getRateCtrl()->getRCPic() );
     987      //getEncTop()->getEncTop();//->getTEncTop(0);//->getUseRateCtrl()->getRCPic();
     988#endif
     989
    979990      estimatedBits = m_pcRateCtrl->getRCPic()->getTargetBits();
    980991
     
    10211032      else    // normal case
    10221033      {
     1034#if KWU_RC_MADPRED_E0227
     1035        if(m_pcRateCtrl->getLayerID() != 0)
     1036        {
     1037          list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList();
     1038          lambda  = m_pcRateCtrl->getRCPic()->estimatePicLambdaIV( listPreviousPicture, pcSlice->getPOC() );
     1039          //printf("lambda : %lf\n", lambda);
     1040          sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture );
     1041        }
     1042        else
     1043        {
     1044#endif
    10231045        list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList();
    10241046#if RATE_CONTROL_INTRA
     
    10281050#endif
    10291051        sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture );
     1052#if KWU_RC_MADPRED_E0227
     1053        }
     1054#endif
    10301055      }
    10311056
     
    21912216      delete[] pcSubstreamsOut;
    21922217  }
    2193 #if !RATE_CONTROL_LAMBDA_DOMAIN
    2194   if(m_pcCfg->getUseRateCtrl())
    2195   {
    2196     m_pcRateCtrl->updateRCGOPStatus();
    2197   }
    2198 #endif
     2218
    21992219  delete pcBitstreamRedirect;
    22002220
  • branches/HTM-8.2-dev0-KWU/source/Lib/TLibEncoder/TEncGOP.h

    r622 r635  
    5757#include "TEncAnalyze.h"
    5858#include "TEncRateCtrl.h"
     59#if KWU_RC_MADPRED_E0227
     60#include "../App/TAppEncoder/TAppEncTop.h"
     61#endif
    5962#include <vector>
    6063
     
    176179  Void  preLoopFilterPicAll  ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits );
    177180#endif
    178  
     181
     182#if KWU_RC_MADPRED_E0227
     183  TEncTop* getEncTop() { return m_pcEncTop; }
     184#endif
     185
    179186  TEncSlice*  getSliceEncoder()   { return m_pcSliceEncoder; }
    180187  NalUnitType getNalUnitType( Int pocCurr, Int lastIdr );
  • branches/HTM-8.2-dev0-KWU/source/Lib/TLibEncoder/TEncRateCtrl.cpp

    r608 r635  
    537537  m_lastPicture  = NULL;
    538538#endif
     539
     540#if KWU_RC_MADPRED_E0227
     541  m_lastIVPicture = NULL;
     542#endif
     543
    539544  m_picActualHeaderBits = 0;
    540545#if !M0036_RC_IMPROVEMENT
     
    544549  m_picQP               = 0;
    545550  m_picLambda           = 0.0;
     551
     552#if KWU_RC_MADPRED_E0227
     553  m_IVtotalMAD            = 0.0;
     554#endif
    546555}
    547556
     
    621630}
    622631
     632#if KWU_RC_MADPRED_E0227
     633Void TEncRCPic::addToPictureLsitIV( list<TEncRCPic*>& listPreviousPictures )
     634{
     635  m_lastIVPicture = NULL;
     636  m_lastIVPicture = this;
     637}
     638
     639Void TEncRCPic::setIVPic( TEncRCPic* BaseRCPic )
     640{
     641  m_lastIVPicture = BaseRCPic;
     642}
     643#endif
     644
     645#if KWU_RC_MADPRED_E0227
     646Void TEncRCPic::create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures, Int LayerID )
     647#else
    623648Void TEncRCPic::create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures )
     649#endif
    624650{
    625651  destroy();
     
    673699      Int currHeight = ( (j == picHeightInLCU-1) ? picHeight - LCUHeight*(picHeightInLCU-1) : LCUHeight );
    674700      m_LCUs[LCUIdx].m_numberOfPixel = currWidth * currHeight;
     701
     702#if KWU_RC_MADPRED_E0227
     703      m_LCUs[LCUIdx].m_CUWidth = currWidth;
     704      m_LCUs[LCUIdx].m_CUHeight = currHeight;
     705      m_LCUs[LCUIdx].m_IVMAD = -1.0;
     706#endif
    675707    }
    676708  }
     
    683715  m_picLambda           = 0.0;
    684716
     717
     718#if KWU_RC_MADPRED_E0227
     719  m_LayerID = LayerID;
     720  m_lastIVPicture = NULL;
     721  m_IVtotalMAD            = 0.0;
     722#endif
     723
     724
    685725#if !M0036_RC_IMPROVEMENT
    686726  m_lastPicture = NULL;
    687727  list<TEncRCPic*>::reverse_iterator it;
     728  for ( it = listPreviousPictures.rbegin(); it != listPreviousPictures.rend(); it++ )
     729  {
     730    if ( (*it)->getFrameLevel() == m_frameLevel )
     731    {
     732      m_lastPicture = (*it);
     733      break;
     734    }
     735  }
     736#endif
     737
     738#if KWU_RC_MADPRED_E0227
     739  list<TEncRCPic*>::reverse_iterator it;
     740  if( m_LayerID != 0)
     741  {
     742    m_lastIVPicture = NULL;
     743    for ( it = listPreviousPictures.rbegin(); it != listPreviousPictures.rend(); it++ )
     744    {
     745      if ( (*it)->getLayerID() == 0 )
     746      {
     747        m_lastIVPicture = (*it);
     748        break;
     749      }
     750    }
     751  }
     752
     753  m_lastPicture = NULL;
    688754  for ( it = listPreviousPictures.rbegin(); it != listPreviousPictures.rend(); it++ )
    689755  {
     
    856922}
    857923
     924
     925#if KWU_RC_MADPRED_E0227
     926Double TEncRCPic::estimatePicLambdaIV( list<TEncRCPic*>& listPreviousPictures, Int CurPOC )
     927{
     928  Double alpha         = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha;
     929  Double beta          = m_encRCSeq->getPicPara( m_frameLevel ).m_beta;
     930  Double bpp       = (Double)m_targetBits/(Double)m_numberOfPixel;
     931  Double estLambda = alpha * pow( bpp, beta );
     932  Double lastLevelLambda = -1.0;
     933  Double lastPicLambda   = -1.0;
     934  Double lastValidLambda = -1.0;
     935  list<TEncRCPic*>::iterator it;
     936
     937  if(listPreviousPictures.size() == 0 || CurPOC%8 == 0)
     938  {
     939    lastLevelLambda = m_lastIVPicture->getPicActualLambda();
     940    lastPicLambda     = m_lastIVPicture->getPicActualLambda();
     941  }
     942  else
     943  {
     944    for ( it = listPreviousPictures.begin(); it != listPreviousPictures.end(); it++ )
     945    {
     946      if ( (*it)->getFrameLevel() == m_frameLevel )
     947      {
     948        lastLevelLambda = (*it)->getPicActualLambda();
     949      }
     950      lastPicLambda     = (*it)->getPicActualLambda();
     951
     952      if ( lastPicLambda > 0.0 )
     953      {
     954        lastValidLambda = lastPicLambda;
     955      }
     956    }
     957  }
     958
     959  if ( lastLevelLambda > 0.0 )
     960  {
     961    lastLevelLambda = Clip3( 0.1, 10000.0, lastLevelLambda );
     962    estLambda = Clip3( lastLevelLambda * pow( 2.0, -3.0/3.0 ), lastLevelLambda * pow( 2.0, 3.0/3.0 ), estLambda );
     963  }
     964
     965  if ( lastPicLambda > 0.0 )
     966  {
     967    lastPicLambda = Clip3( 0.1, 2000.0, lastPicLambda );
     968    estLambda = Clip3( lastPicLambda * pow( 2.0, -10.0/3.0 ), lastPicLambda * pow( 2.0, 10.0/3.0 ), estLambda );
     969  }
     970  else if ( lastValidLambda > 0.0 )
     971  {
     972    lastValidLambda = Clip3( 0.1, 2000.0, lastValidLambda );
     973    estLambda = Clip3( lastValidLambda * pow(2.0, -10.0/3.0), lastValidLambda * pow(2.0, 10.0/3.0), estLambda );
     974  }
     975  else
     976  {
     977    estLambda = Clip3( 0.1, 10000.0, estLambda );
     978  }
     979
     980  if ( estLambda < 0.1 )
     981  {
     982    estLambda = 0.1;
     983  }
     984
     985  m_estPicLambda = estLambda;
     986  return estLambda;
     987}
     988#endif
     989
     990
    858991#if RATE_CONTROL_INTRA
    859992Double TEncRCPic::getLCUTargetBpp(SliceType eSliceType) 
     
    9371070}
    9381071
     1072
     1073#if KWU_RC_MADPRED_E0227
     1074Double TEncRCPic::getLCUTargetBppforInterView( list<TEncRCPic*>& listPreviousPictures, TComDataCU* pcCU, Double BasePos, Double CurPos, Double FocalLen, Double Znear, Double Zfar, Int Direction, Int* iDisparity )
     1075{
     1076  Int   LCUIdx    = getLCUCoded();
     1077  Double bpp      = -1.0;
     1078  Int avgBits     = 0;
     1079#if !M0036_RC_IMPROVEMENT
     1080  Double totalMAD = -1.0;
     1081  Double MAD      = -1.0;
     1082#endif
     1083
     1084  Double totalMAD = -1.0;
     1085  Double MAD      = -1.0;
     1086
     1087  Double IVMAD      = -1.0;
     1088  Double SAD = 0.0;
     1089  Int     x, y;
     1090  Int Sum = 0;
     1091
     1092  {
     1093    Pel*  pOrg    = pcCU->getSlice()->getIvPic(false, 0)->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0);
     1094    Pel*  pRec    = pcCU->getSlice()->getIvPic(false, 0)->getPicYuvPred()->getLumaAddr(pcCU->getAddr(), 0);
     1095    Pel*  pDep    = pcCU->getSlice()->getIvPic(true, pcCU->getSlice()->getViewIndex())->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0);
     1096    Int   iStride = pcCU->getSlice()->getIvPic(true, pcCU->getSlice()->getViewIndex())->getPicYuvOrg()->getStride();
     1097
     1098    Int   iWidth  = m_LCUs[ LCUIdx ].m_CUWidth;
     1099    Int   iHeight = m_LCUs[ LCUIdx ].m_CUHeight;
     1100
     1101    for( y = 0 ; y < pcCU->getSlice()->getSPS()->getMaxCUHeight() ; y+=8)
     1102    {
     1103      for( x = 0 ; x < pcCU->getSlice()->getSPS()->getMaxCUWidth() ; x+=8)
     1104      {
     1105        Sum += pDep[x];
     1106      }
     1107      pDep += iStride;
     1108    }
     1109
     1110    Double AvgDepth = (Double)Sum/((pcCU->getSlice()->getSPS()->getMaxCUHeight()/8)*(pcCU->getSlice()->getSPS()->getMaxCUWidth()/8));
     1111
     1112    //Int iDisparity = pDepthGen->RCGetDisparityFromVirtDepth(0, (Int)AvgDepth);
     1113
     1114    Double dFL = FocalLen * abs( BasePos - CurPos );
     1115    Double dZ  = abs( 1.0 / Znear - 1.0 / Zfar ) * ((Double)(AvgDepth) / (( 1 << g_bitDepthY ) - 1) ) + abs(1.0 / Zfar);
     1116    *iDisparity = (Int)(Direction*dFL * dZ);
     1117    Int shift = DISTORTION_PRECISION_ADJUSTMENT(g_bitDepthY-8);
     1118
     1119    Int Disp = *iDisparity;
     1120    Int PosX, PosY;
     1121    pcCU->getPosInPic(0, PosX, PosY);
     1122    if((PosX + *iDisparity) < 0 || (PosX + *iDisparity + iWidth) >= pcCU->getSlice()->getSPS()->getMaxCUWidth())
     1123      Disp = 0;
     1124
     1125    for( y = 0; y < iHeight; y++ )
     1126    {
     1127      for( x = 0; x < iWidth; x++ )
     1128      {
     1129        SAD += abs( pOrg[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + Disp)]
     1130                  - pRec[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + Disp)] )>>shift;
     1131      }
     1132      pOrg += iStride;
     1133      pRec += iStride;
     1134    }
     1135    IVMAD = SAD / (Double)(iHeight * iWidth);
     1136    IVMAD = IVMAD * IVMAD;
     1137
     1138    m_LCUs[ LCUIdx ].m_IVMAD = IVMAD;
     1139    if(m_lastPicture)
     1140      m_LCUs[ LCUIdx ].m_MAD = m_lastPicture->getLCU(LCUIdx).m_MAD;
     1141
     1142    MAD = m_LCUs[ LCUIdx ].m_IVMAD;
     1143
     1144    if(m_lastPicture)
     1145    {
     1146      totalMAD = m_lastPicture->getTotalMAD();      // get total MAD of temporal frame
     1147      for ( Int i=0; i<LCUIdx; i++ )
     1148      {
     1149        totalMAD -= m_lastPicture->getLCU(i).m_MAD;
     1150      }
     1151    }
     1152    else
     1153    {
     1154      totalMAD = m_lastIVPicture->getTotalMAD();      // get total MAD of inter-view frame
     1155      for ( Int i=0; i<LCUIdx; i++ )
     1156      {
     1157        totalMAD -= m_lastIVPicture->getLCU(i).m_MAD;
     1158      }
     1159    }
     1160
     1161
     1162    if ( totalMAD > 0.1 )
     1163    {
     1164      avgBits = Int( (m_bitsLeft * MAD) / totalMAD );
     1165    }
     1166    else
     1167    {
     1168      avgBits = Int( (m_bitsLeft) / m_LCULeft );
     1169    }
     1170  }
     1171
     1172  if ( avgBits < 5 )
     1173  {
     1174    avgBits = 5;
     1175  }
     1176
     1177  bpp = ( Double )avgBits/( Double )m_LCUs[ LCUIdx ].m_numberOfPixel;
     1178  m_LCUs[ LCUIdx ].m_targetBits = avgBits;
     1179
     1180  return bpp;
     1181}
     1182#endif
     1183
     1184
     1185
     1186
    9391187Double TEncRCPic::getLCUEstLambda( Double bpp )
    9401188{
     
    11851433  }
    11861434  m_picLambda           = averageLambda;
    1187 #if !M0036_RC_IMPROVEMENT
     1435#if !M0036_RC_IMPROVEMENT || KWU_RC_MADPRED_E0227
     1436  m_totalMAD = 0;
    11881437  for ( Int i=0; i<m_numberOfLCU; i++ )
    11891438  {
     
    13931642
    13941643#if M0036_RC_IMPROVEMENT
     1644#if KWU_RC_MADPRED_E0227
     1645Void 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 )
     1646#else
    13951647Void 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] )
     1648#endif
    13961649#else
    13971650Void 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] )
     
    16071860  }
    16081861
     1862#if KWU_RC_MADPRED_E0227
     1863  setLayerID(LayerID);
     1864#endif
     1865
    16091866  delete[] bitsRatio;
    16101867  delete[] GOPID2Level;
     
    16141871{
    16151872  m_encRCPic = new TEncRCPic;
     1873#if KWU_RC_MADPRED_E0227
     1874  m_encRCPic->create( m_encRCSeq, m_encRCGOP, frameLevel, m_listRCPictures, m_LayerID );
     1875#else
    16161876  m_encRCPic->create( m_encRCSeq, m_encRCGOP, frameLevel, m_listRCPictures );
     1877#endif
    16171878}
    16181879
     
    18152076  m_sourceHeightInLCU        = (sourceHeight / maxCUHeight) + (( sourceHeight %  maxCUHeight) ? 1 : 0); 
    18162077  m_isLowdelay               = (sizeIntraPeriod == -1) ? true : false;
    1817   m_prevBitrate              = ( targetKbps << 10 );  // in units of 1,024 bps
    1818   m_currBitrate              = ( targetKbps << 10 );
     2078  m_prevBitrate              = ( targetKbps * 1000 );  // in units of 1,024 bps
     2079  m_currBitrate              = ( targetKbps * 1000 );
    18192080  m_frameRate                = frameRate;
    18202081  m_refFrameNum              = m_isLowdelay ? (sizeGOP) : (sizeGOP>>1);
     
    21922453
    21932454  Pel*  pOrg   = pcCU->getPic()->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0);
    2194   Pel*  pRec   = pcCU->getPic()->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), 0);
     2455  Pel*  pRec   = pcCU->getPic()->getPicYuvPred()->getLumaAddr(pcCU->getAddr(), 0);
    21952456  Int   stride = pcCU->getPic()->getStride();
    21962457
     
    22122473}
    22132474
     2475
     2476#if KWU_RC_MADPRED_E0227
     2477Void  TEncRateCtrl::updateLCUDataEnhancedView(TComDataCU* pcCU, UInt64 uiBits, Int iQP, Double BasePos, Double CurPos, Double FocalLen, Double Znear, Double Zfar, Int Direction)
     2478{
     2479  Int     x, y;
     2480  double dMAD = 0.0;
     2481  Int Sum = 0;
     2482  Double SAD = 0.0;
     2483
     2484  Pel*  pOrg    = pcCU->getSlice()->getIvPic(false, 0)->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0);
     2485  Pel*  pRec    = pcCU->getSlice()->getIvPic(false, 0)->getPicYuvPred()->getLumaAddr(pcCU->getAddr(), 0);
     2486  Pel*  pDep    = pcCU->getSlice()->getIvPic(true, pcCU->getSlice()->getViewIndex())->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0);
     2487  Int   iStride = pcCU->getSlice()->getIvPic(true, pcCU->getSlice()->getViewIndex())->getPicYuvOrg()->getStride();
     2488
     2489  Int   iWidth  = m_pcLCUData[m_indexLCU].m_widthInPixel;
     2490  Int   iHeight = m_pcLCUData[m_indexLCU].m_heightInPixel;
     2491
     2492  for( y = 0 ; y < pcCU->getSlice()->getSPS()->getMaxCUHeight() ; y+=8)
     2493  {
     2494    for( x = 0 ; x < pcCU->getSlice()->getSPS()->getMaxCUWidth() ; x+=8)
     2495    {
     2496      Sum += pDep[x];
     2497    }
     2498    pDep += iStride;
     2499  }
     2500
     2501  Double AvgDepth = (Double)Sum/((pcCU->getSlice()->getSPS()->getMaxCUHeight()/8)*(pcCU->getSlice()->getSPS()->getMaxCUWidth()/8));
     2502
     2503  //Int iDisparity = pDepthGen->RCGetDisparityFromVirtDepth(0, (Int)AvgDepth);
     2504
     2505  Double dFL = FocalLen * abs( BasePos - CurPos );
     2506  Double dZ  = abs( 1.0 / Znear - 1.0 / Zfar ) * ((Double)(AvgDepth) / (( 1 << g_bitDepthY ) - 1) ) + abs(1.0 / Zfar);
     2507  Int   iDisparity = (Int)(Direction*dFL * dZ);
     2508  Int shift = DISTORTION_PRECISION_ADJUSTMENT(g_bitDepthY-8);
     2509  Int Disp = iDisparity;
     2510
     2511  for( y = 0; y < iHeight; y++ )
     2512  {
     2513    for( x = 0; x < iWidth; x++ )
     2514    {
     2515      SAD += abs( pOrg[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + Disp)]
     2516      - pRec[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + Disp)] )>>shift;
     2517    }
     2518    pOrg += iStride;
     2519    pRec += iStride;
     2520  }
     2521  m_pcLCUData[m_indexLCU].m_qp   = iQP;
     2522  m_pcLCUData[m_indexLCU].m_costMAD  = (SAD /(Double)(iWidth*iHeight));
     2523  m_pcLCUData[m_indexLCU].m_bits = (Int)uiBits;
     2524}
     2525#endif
     2526
     2527
    22142528Double TEncRateCtrl::xAdjustmentBits(Int& reductionBits, Int& compensationBits)
    22152529{
  • branches/HTM-8.2-dev0-KWU/source/Lib/TLibEncoder/TEncRateCtrl.h

    r608 r635  
    9898  Int m_targetBitsLeft;
    9999#endif
     100
     101#if KWU_RC_MADPRED_E0227
     102  Double m_MAD;
     103
     104  Int m_CUWidth;
     105  Int m_CUHeight;
     106  Double m_IVMAD;
     107#endif
    100108};
    101109
     
    248256
    249257public:
     258#if KWU_RC_MADPRED_E0227
     259  Void create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures, Int LayerID );
     260#else
    250261  Void create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures );
     262#endif
    251263  Void destroy();
    252264
     265#if KWU_RC_MADPRED_E0227
     266  Double estimatePicLambdaIV( list<TEncRCPic*>& listPreviousPictures, Int CurPOC );
     267#endif
    253268#if !RATE_CONTROL_INTRA
    254269  Double estimatePicLambda( list<TEncRCPic*>& listPreviousPictures );
     
    267282  Double getLCUTargetBpp();
    268283#endif
     284
     285#if KWU_RC_MADPRED_E0227
     286  Double getLCUTargetBppforInterView( list<TEncRCPic*>& listPreviousPictures, TComDataCU* pcCU, Double BasePos, Double CurPos, Double FocalLen, Double Znear, Double Zfar, Int Direction, Int* iDisparity );
     287#endif
     288
    269289  Double getLCUEstLambda( Double bpp );
    270290  Int    getLCUEstQP( Double lambda, Int clipPicQP );
     
    282302
    283303  Void addToPictureLsit( list<TEncRCPic*>& listPreviousPictures );
     304
     305#if KWU_RC_MADPRED_E0227
     306  Void addToPictureLsitIV( list<TEncRCPic*>& listPreviousPictures );
     307  Void setIVPic( TEncRCPic* BaseRCPic );
     308#endif
     309
    284310#if !M0036_RC_IMPROVEMENT
    285311  Double getEffectivePercentage();
     
    322348#endif
    323349
     350#if KWU_RC_MADPRED_E0227
     351  Double getTotalMAD()                                    { return m_totalMAD; }
     352  Void   setTotalMAD( Double MAD )                        { m_totalMAD = MAD; }
     353
     354  Double getIVTotalMAD()                                    { return m_IVtotalMAD; }
     355  Void   setIVTotalMAD( Double MAD )                        { m_IVtotalMAD = MAD; }
     356#endif
     357
    324358  Int  getPicActualBits()                                 { return m_picActualBits; }
    325359  Int  getPicActualQP()                                   { return m_picQP; }
     
    330364  Void setPicEstLambda( Double lambda )                   { m_picLambda = lambda; }
    331365
     366#if KWU_RC_MADPRED_E0227
     367  Int getLayerID()                                         { return m_LayerID; }
     368  Void setLayerID(Int layerid)                              { m_LayerID = layerid; }
     369#endif
     370
    332371private:
    333372  TEncRCSeq* m_encRCSeq;
     
    361400  TEncRCPic* m_lastPicture;
    362401#endif
     402
     403#if KWU_RC_MADPRED_E0227
     404  Double m_totalMAD;
     405  TEncRCPic* m_lastPicture;
     406  Int m_LayerID;
     407  TEncRCPic* m_lastIVPicture;
     408  Double m_IVtotalMAD;
     409#endif
    363410};
    364411
     
    371418public:
    372419#if M0036_RC_IMPROVEMENT
     420#if KWU_RC_MADPRED_E0227
     421  Void 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 );
     422#else
    373423  Void 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] );
     424#endif
    374425#else
    375426  Void 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] );
     
    388439  list<TEncRCPic*>& getPicList() { return m_listRCPictures; }
    389440
     441#if KWU_RC_MADPRED_E0227
     442  Int getLayerID()                { return m_LayerID; }
     443  Void setLayerID(Int layerid)     { m_LayerID = layerid; }
     444#endif
     445
    390446private:
    391447  TEncRCSeq* m_encRCSeq;
     
    394450  list<TEncRCPic*> m_listRCPictures;
    395451  Int        m_RCQP;
     452
     453#if KWU_RC_MADPRED_E0227
     454  Int m_LayerID;
     455#endif
    396456};
    397457
     
    518578  Void          updataRCUnitStatus    ();
    519579  Void          updateLCUData         (TComDataCU* pcCU, UInt64 actualLCUBits, Int qp);
     580#if KWU_RC_MADPRED_E0227
     581  Void          updateLCUDataEnhancedView(TComDataCU* pcCU, UInt64 uiBits, Int iQP, Double BasePos, Double CurPos, Double FocalLen, Double Znear, Double Zfar, Int Direction);
     582#endif
    520583  Void          updateFrameData       (UInt64 actualFrameBits);
    521584  Double        xAdjustmentBits       (Int& reductionBits, Int& compensationBits);
  • branches/HTM-8.2-dev0-KWU/source/Lib/TLibEncoder/TEncSlice.cpp

    r622 r635  
    157157  m_pdRdPicQp         = (Double*)xMalloc( Double, m_pcCfg->getDeltaQpRD() * 2 + 1 );
    158158  m_piRdPicQp         = (Int*   )xMalloc( Int,    m_pcCfg->getDeltaQpRD() * 2 + 1 );
    159   m_pcRateCtrl        = pcEncTop->getRateCtrl();
     159  if(m_pcCfg->getUseRateCtrl())
     160    m_pcRateCtrl        = pcEncTop->getRateCtrl();
     161  else
     162    m_pcRateCtrl        = NULL;
    160163}
    161164
     
    321324  }
    322325#if !RATE_CONTROL_LAMBDA_DOMAIN
    323   if ( m_pcCfg->getUseRateCtrl())
     326  if ( m_pcCfg->getUseRateCtrl() && !m_pcCfg->getIsDepth())
    324327  {
    325328    dQP = m_pcRateCtrl->getFrameQP(rpcSlice->isReferenced(), rpcSlice->getPOC());
     
    11231126#endif
    11241127#if !RATE_CONTROL_LAMBDA_DOMAIN
    1125     if(m_pcCfg->getUseRateCtrl())
    1126     {
     1128    if(m_pcCfg->getUseRateCtrl() && !m_pcCfg->getIsDepth())
     1129    {
     1130#if KWU_RC_MADPRED_E0227
     1131      if(pcSlice->getLayerId() != 0 && m_pcCfg->getUseDepthMADPred() && !pcSlice->getIsDepth())
     1132      {
     1133        double Zn, Zf, FocalLength, Position, CamShift;
     1134        double BasePos;
     1135        bool bInterpolated;
     1136        Int Direction = pcSlice->getViewId() - pcCU->getSlice()->getIvPic(false, 0)->getViewId();
     1137
     1138        pcEncTop->getCamParam()->RCGetZNearZFar(pcSlice->getViewId(), pcSlice->getPOC(), Zn, Zf);
     1139        pcEncTop->getCamParam()->RCGetGeometryData(0, pcSlice->getPOC(), FocalLength, BasePos, CamShift, bInterpolated);
     1140        pcEncTop->getCamParam()->RCGetGeometryData(pcSlice->getViewId(), pcSlice->getPOC(), FocalLength, Position, CamShift, bInterpolated);
     1141
     1142        m_pcRateCtrl->updateLCUDataEnhancedView(pcCU, pcCU->getTotalBits(), pcCU->getQP(0), BasePos, Position, FocalLength, Zn, Zf, (Direction > 0 ? 1 : -1));
     1143      }
     1144#endif
    11271145      if(m_pcRateCtrl->calculateUnitQP())
    11281146      {
     
    12231241        else
    12241242        {
     1243#if KWU_RC_MADPRED_E0227
     1244          if(pcSlice->getLayerId() != 0 && m_pcCfg->getUseDepthMADPred() && !pcSlice->getIsDepth())
     1245          {
     1246            double Zn, Zf, FocalLength, Position, CamShift;
     1247            double BasePos;
     1248            bool bInterpolated;
     1249            Int Direction = pcSlice->getViewId() - pcCU->getSlice()->getIvPic(false, 0)->getViewId();
     1250            Int iDisparity;
     1251
     1252            pcEncTop->getCamParam()->RCGetZNearZFar(pcSlice->getViewId(), pcSlice->getPOC(), Zn, Zf);
     1253            pcEncTop->getCamParam()->RCGetGeometryData(0, pcSlice->getPOC(), FocalLength, BasePos, CamShift, bInterpolated);
     1254            pcEncTop->getCamParam()->RCGetGeometryData(pcSlice->getViewId(), pcSlice->getPOC(), FocalLength, Position, CamShift, bInterpolated);
     1255            bpp       = m_pcRateCtrl->getRCPic()->getLCUTargetBppforInterView( m_pcRateCtrl->getPicList(), pcCU,
     1256                            BasePos, Position, FocalLength, Zn, Zf, (Direction > 0 ? 1 : -1), &iDisparity );
     1257          }
     1258          else
     1259          {
     1260#endif
    12251261#if RATE_CONTROL_INTRA
    12261262          bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp(pcSlice->getSliceType());
     
    12391275          estQP     = m_pcRateCtrl->getRCPic()->getLCUEstQP    ( estLambda, pcSlice->getSliceQp() );
    12401276#endif
    1241 
     1277#if KWU_RC_MADPRED_E0227
     1278          }
     1279#endif
     1280#if KWU_RC_MADPRED_E0227
     1281          estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp );
     1282          estQP     = m_pcRateCtrl->getRCPic()->getLCUEstQP    ( estLambda, pcSlice->getSliceQp() );
     1283#endif
    12421284          estQP     = Clip3( -pcSlice->getSPS()->getQpBDOffsetY(), MAX_QP, estQP );
    12431285
     
    13411383#if TICKET_1090_FIX
    13421384#if RATE_CONTROL_LAMBDA_DOMAIN
    1343       if ( m_pcCfg->getUseRateCtrl() )
    1344       {
    1345 #if !M0036_RC_IMPROVEMENT
     1385      if ( m_pcCfg->getUseRateCtrl() && !m_pcCfg->getIsDepth() )
     1386      {
     1387#if !M0036_RC_IMPROVEMENT || KWU_RC_MADPRED_E0227
    13461388        UInt SAD    = m_pcCuEncoder->getLCUPredictionSAD();
    13471389        Int height  = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() );
     
    14061448    m_uiPicDist      += pcCU->getTotalDistortion();
    14071449#if !RATE_CONTROL_LAMBDA_DOMAIN
    1408     if(m_pcCfg->getUseRateCtrl())
     1450    if(m_pcCfg->getUseRateCtrl() && !m_pcCfg->getIsDepth())
    14091451    {
    14101452      m_pcRateCtrl->updateLCUData(pcCU, pcCU->getTotalBits(), pcCU->getQP(0));
     
    14271469  xRestoreWPparam( pcSlice );
    14281470#if !RATE_CONTROL_LAMBDA_DOMAIN
    1429   if(m_pcCfg->getUseRateCtrl())
     1471  if(m_pcCfg->getUseRateCtrl() && !m_pcCfg->getIsDepth())
    14301472  {
    14311473    m_pcRateCtrl->updateFrameData(m_uiPicTotalBits);
  • branches/HTM-8.2-dev0-KWU/source/Lib/TLibEncoder/TEncTop.cpp

    r622 r635  
    123123  if ( m_RCEnableRateControl )
    124124  {
     125#if KWU_RC_MADPRED_E0227
     126    m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight,
     127      g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList, getLayerId() );
     128#else
    125129    m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight,
    126130                      g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList );
    127   }
    128 #else
    129   m_cRateCtrl.create(getIntraPeriod(), getGOPSize(), getFrameRate(), getTargetBitrate(), getQP(), getNumLCUInUnit(), getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight);
     131#endif
     132  }
     133#else
     134  if(m_enableRateCtrl)
     135    m_cRateCtrl.create(getIntraPeriod(), getGOPSize(), getFrameRate(), getTargetBitrate(), getQP(), getNumLCUInUnit(), getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight);
    130136#endif
    131137  // if SBAC-based RD optimization is used
     
    224230  }
    225231  m_cLoopFilter.        destroy();
    226   m_cRateCtrl.          destroy();
    227232  // SBAC RD
    228233  if( m_bUseSBACRD )
     
    284289}
    285290
     291#if KWU_RC_MADPRED_E0227
     292Void TEncTop::init(TAppEncTop* pcTAppEncTop)
     293#else
    286294Void TEncTop::init()
     295#endif
    287296{
    288297  // initialize SPS
     
    310319  m_cCuEncoder.   init( this );
    311320 
     321#if KWU_RC_MADPRED_E0227
     322  m_pcTAppEncTop = pcTAppEncTop;
     323#endif
    312324  // initialize transform & quantization class
    313325  m_pcCavlcCoder = getCavlcCoder();
     
    739751    m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) );
    740752  }
     753#else
     754  if ( m_enableRateCtrl )
     755  {
     756    m_cPPS.setUseDQP(true);
     757    m_cPPS.setMaxCuDQPDepth( 0 );
     758    m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) );
     759  }
    741760#endif
    742761
  • branches/HTM-8.2-dev0-KWU/source/Lib/TLibEncoder/TEncTop.h

    r608 r635  
    6464// ====================================================================================================================
    6565
     66#if KWU_RC_MADPRED_E0227
     67class TAppEncTop;
     68#endif
    6669/// encoder class
    6770class TEncTop : public TEncCfg
     
    124127  TComScalingList         m_scalingList;                 ///< quantization matrix information
    125128  TEncRateCtrl            m_cRateCtrl;                    ///< Rate control class
     129
     130#if KWU_RC_MADPRED_E0227
     131  TAppEncTop*             m_pcTAppEncTop;
     132  TAppComCamPara*         m_cCamParam;
     133#endif
    126134 
    127135#if H_MV
     
    145153  Void      create          ();
    146154  Void      destroy         ();
     155#if KWU_RC_MADPRED_E0227
     156  Void      init            ( TAppEncTop* pcTAppEncTop );
     157#else
    147158  Void      init            ();
     159#endif
     160
    148161#if H_MV 
    149162  TComPicLists* getIvPicLists() { return m_ivPicLists; }
     
    185198  TEncSbac*               getRDGoOnSbacCoders   () { return  m_pcRDGoOnSbacCoders;   }
    186199  TEncRateCtrl*           getRateCtrl           () { return &m_cRateCtrl;             }
     200#if KWU_RC_MADPRED_E0227
     201  TAppEncTop*             getEncTop             () { return m_pcTAppEncTop; }
     202  TAppComCamPara*         getCamParam()                 { return m_cCamParam;}
     203  Void                    setCamParam(TAppComCamPara * pCamparam)                 { m_cCamParam = pCamparam;}
     204#endif
    187205  TComSPS*                getSPS                () { return  &m_cSPS;                 }
    188206  TComPPS*                getPPS                () { return  &m_cPPS;                 }
Note: See TracChangeset for help on using the changeset viewer.