Changeset 608 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComRdCost.h


Ignore:
Timestamp:
1 Sep 2013, 22:47:26 (12 years ago)
Author:
tech
Message:

Merged DEV-2.0-dev0@604.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibCommon/TComRdCost.h

    r296 r608  
    44 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2012, ITU/ISO/IEC
     6 * Copyright (c) 2010-2013, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    4444#include "TComMv.h"
    4545
    46 #include "TComRdCost.h"
    4746#include "TComSlice.h"
    4847#include "TComRdCostWeightPrediction.h"
     48#if H_3D
    4949#include "../TLibRenderer/TRenModel.h"
     50#endif
    5051
    5152//! \ingroup TLibCommon
     
    5657class DistParam;
    5758class TComPattern;
     59#if H_3D
    5860class TComRdCost;
     61#endif
    5962
    6063// ====================================================================================================================
     
    6568typedef UInt (*FpDistFunc) (DistParam*);
    6669
    67 #if HHI_VSO
     70#if H_3D
     71#if H_3D_VSO
    6872typedef Dist (TComRdCost::*FpDistFuncVSO) ( Int, Int, Pel*, Int, Pel*, Int, UInt, UInt, Bool );
     73#endif
    6974#endif
    7075// ====================================================================================================================
     
    8085  Int   iStrideOrg;
    8186  Int   iStrideCur;
    82 #if SAIT_VSO_EST_A0033
     87#if H_3D_VSO
     88  // SAIT_VSO_EST_A0033
    8389  Pel*  pVirRec;
    8490  Pel*  pVirOrg;
    8591  Int   iStrideVir;
    8692#endif
     93#if H_3D_IC
     94  Bool  bUseIC;
     95#endif
     96#if LGE_INTER_SDC_E0156
     97  Bool  bUseSDCMRSAD;
     98#endif
    8799  Int   iRows;
    88100  Int   iCols;
    89101  Int   iStep;
    90 #if LGE_ILLUCOMP_B0045
    91   Bool  bUseIC;
    92 #endif
    93102  FpDistFunc DistFunc;
    94 
    95 #if HHI_INTERVIEW_SKIP
    96   Pel*  pUsed;
    97   Int   iStrideUsed;
    98 #endif
     103  Int   bitDepth;
     104
    99105  Bool            bApplyWeight;     // whether weithed prediction is used or not
    100106  wpScalingParam  *wpCur;           // weithed prediction scaling parameters for current ref
     
    113119    pOrg = NULL;
    114120    pCur = NULL;
    115 #if SAIT_VSO_EST_A0033
    116     pVirRec = NULL;
    117     pVirOrg = NULL;;
    118     iStrideVir = 0;
    119 #endif
    120121    iStrideOrg = 0;
    121122    iStrideCur = 0;
     
    125126    DistFunc = NULL;
    126127    iSubShift = 0;
    127 #if HHI_INTERVIEW_SKIP
    128     pUsed       = 0;
    129     iStrideUsed = 0;
    130 #endif
     128    bitDepth = 0;
    131129#if NS_HAD
    132130    bUseNSHAD = false;
     131#endif
     132#if H_3D_VSO
     133    // SAIT_VSO_EST_A0033
     134    pVirRec = NULL;
     135    pVirOrg = NULL;
     136    iStrideVir = 0;
     137#endif
     138#if LGE_INTER_SDC_E0156
     139    bUseSDCMRSAD = false;
    133140#endif
    134141  }
     
    151158 
    152159#if WEIGHTED_CHROMA_DISTORTION
    153   Double                  m_chromaDistortionWeight;   
     160  Double                  m_cbDistortionWeight;
     161  Double                  m_crDistortionWeight;
    154162#endif
    155163  Double                  m_dLambda;
     
    158166  UInt                    m_uiLambdaMotionSSE;
    159167  Double                  m_dFrameLambda;
    160 #if SAIT_VSO_EST_A0033
     168#if H_3D_VSO
     169  // SAIT_VSO_EST_A0033
    161170  static Double           m_dDisparityCoeff;
    162171#endif
    163172 
    164 #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
    165   Double                  m_dLambdaScale ;
    166 #endif
    167173  // for motion cost
    168174#if FIX203
     
    180186#endif
    181187 
    182   Bool                    m_bUseMultiviewReg;
    183   UInt                    m_uiLambdaMVReg;
    184   UInt                    m_uiLambdaMVRegSAD;
    185   UInt                    m_uiLambdaMVRegSSE;
    186   UInt*                   m_puiMultiviewRegCostHorOrgP;
    187   UInt*                   m_puiMultiviewRegCostVerOrgP;
    188   UInt*                   m_puiMultiviewRegCostHor;
    189   UInt*                   m_puiMultiviewRegCostVer;
    190   UInt*                   m_puiHorRegCost;
    191   UInt*                   m_puiVerRegCost;
    192   TComMv                  m_cMultiviewOrgMvPred;
    193  
    194188public:
    195189  TComRdCost();
    196190  virtual ~TComRdCost();
    197  
     191
     192#if H_3D_VSO
     193  Double  calcRdCost  ( UInt   uiBits, Dist   uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
     194  Double  calcRdCost64( UInt64 uiBits, Dist64 uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
     195#else
    198196  Double  calcRdCost  ( UInt   uiBits, UInt   uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
    199197  Double  calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
     198#endif
     199
    200200 
    201201#if WEIGHTED_CHROMA_DISTORTION
    202   Void    setChromaDistortionWeight      ( Double chromaDistortionWeight) { m_chromaDistortionWeight = chromaDistortionWeight; };
     202  Void    setCbDistortionWeight      ( Double cbDistortionWeight) { m_cbDistortionWeight = cbDistortionWeight; };
     203  Void    setCrDistortionWeight      ( Double crDistortionWeight) { m_crDistortionWeight = crDistortionWeight; };
    203204#endif
    204205  Void    setLambda      ( Double dLambda );
    205 #if H3D_IVMP
    206   Void    setLambdaMVReg ( Double dLambda );
    207 #endif
    208206  Void    setFrameLambda ( Double dLambda ) { m_dFrameLambda = dLambda; }
    209207 
    210 #if SAIT_VSO_EST_A0033
     208  Double  getSqrtLambda ()   { return m_sqrtLambda; }
     209#if H_3D_VSO
     210  // SAIT_VSO_EST_A0033
    211211  Void    setDisparityCoeff( Double dDisparityCoeff ) { m_dDisparityCoeff = dDisparityCoeff; }
    212212  Double  getDisparityCoeff()                         { return m_dDisparityCoeff; }
    213213#endif
    214214
    215 #if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
    216   Void   setLambdaScale  ( Double dLambdaScale) { m_dLambdaScale = dLambdaScale; }
    217   Double   getLambdaScale  ( ) { return m_dLambdaScale ; }
    218 #endif
    219   Double  getSqrtLambda ()   { return m_sqrtLambda; }
     215#if RATE_CONTROL_LAMBDA_DOMAIN
     216  Double  getLambda() { return m_dLambda; }
     217#if M0036_RC_IMPROVEMENT
     218  Double  getChromaWeight () {return((m_cbDistortionWeight+m_crDistortionWeight)/2.0);}
     219#endif
     220#endif
    220221 
    221222  // Distortion Functions
     
    226227#if NS_HAD
    227228  Void    setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false, Bool bUseNSHAD=false );
    228   Void    setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false, Bool bUseNSHAD=false );
     229  Void    setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false, Bool bUseNSHAD=false );
    229230#else
    230231  Void    setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false );
    231   Void    setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false );
    232 #endif
    233  
    234   UInt    calcHAD         ( Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight );
    235  
     232  Void    setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false );
     233#endif
     234 
     235  UInt    calcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight );
     236 
     237#if SCU_HS_FAST_DEPTH_INTRA_E0238
     238  UInt    calcVAR(Pel* pi0, Int stride, Int width, Int height, Int cuDepth);
     239#endif 
    236240  // for motion cost
    237241#if !FIX203
     
    240244#endif
    241245  UInt    xGetComponentBits( Int iVal );
    242   Void    getMotionCost( Bool bSad, Int iAdd )
    243 {
    244      m_uiCost = (bSad ? m_uiLambdaMotionSAD + iAdd : m_uiLambdaMotionSSE + iAdd);
    245     m_uiLambdaMVReg = ( bSad ? m_uiLambdaMVRegSAD         : m_uiLambdaMVRegSSE         );
    246 
    247    }
     246  Void    getMotionCost( Bool bSad, Int iAdd ) { m_uiCost = (bSad ? m_uiLambdaMotionSAD + iAdd : m_uiLambdaMotionSSE + iAdd); }
    248247  Void    setPredictor( TComMv& rcMv )
    249248  {
     
    274273#endif
    275274  }
    276 
    277   Void    setMultiviewReg( TComMv* pcMv )
    278   {
    279     if( pcMv )
    280     {
    281       m_bUseMultiviewReg    = true;
    282       m_puiHorRegCost       = m_puiMultiviewRegCostHor - pcMv->getHor();
    283       m_puiVerRegCost       = m_puiMultiviewRegCostVer - pcMv->getVer();
    284       m_cMultiviewOrgMvPred = *pcMv;
    285     }
    286     else
    287     {
    288       m_bUseMultiviewReg    = false;
    289       m_puiHorRegCost       = 0;
    290       m_puiVerRegCost       = 0;
    291       m_cMultiviewOrgMvPred.set( 0, 0 );
    292     }
    293   }
    294   __inline Bool     useMultiviewReg      () { return m_bUseMultiviewReg; }
    295   __inline TComMv&  getMultiviewOrgMvPred() { return m_cMultiviewOrgMvPred; }
    296   __inline UInt     getMultiviewRegCost  ( Int x, Int y )
    297   {
    298 #if FIX203
    299     return m_uiLambdaMVReg * getBits(x, y) >> 16;
    300 #else
    301     return ( ( m_uiLambdaMVReg * ( m_puiHorRegCost[ x * ( 1 << m_iCostScale ) ] + m_puiVerRegCost[ y * ( 1 << m_iCostScale ) ] ) ) >> 16 );
    302 #endif
    303   }
    304275 
    305276private:
    306277 
    307 #if LGE_ILLUCOMP_B0045
     278  static UInt xGetSSE           ( DistParam* pcDtParam );
     279  static UInt xGetSSE4          ( DistParam* pcDtParam );
     280  static UInt xGetSSE8          ( DistParam* pcDtParam );
     281  static UInt xGetSSE16         ( DistParam* pcDtParam );
     282  static UInt xGetSSE32         ( DistParam* pcDtParam );
     283  static UInt xGetSSE64         ( DistParam* pcDtParam );
     284  static UInt xGetSSE16N        ( DistParam* pcDtParam );
     285#if H_3D_IC || LGE_INTER_SDC_E0156
    308286  static UInt xGetSADic         ( DistParam* pcDtParam );
    309287  static UInt xGetSAD4ic        ( DistParam* pcDtParam );
     
    314292  static UInt xGetSAD16Nic      ( DistParam* pcDtParam );
    315293#endif
    316   static UInt xGetSSE           ( DistParam* pcDtParam );
    317   static UInt xGetSSE4          ( DistParam* pcDtParam );
    318   static UInt xGetSSE8          ( DistParam* pcDtParam );
    319   static UInt xGetSSE16         ( DistParam* pcDtParam );
    320   static UInt xGetSSE32         ( DistParam* pcDtParam );
    321   static UInt xGetSSE64         ( DistParam* pcDtParam );
    322   static UInt xGetSSE16N        ( DistParam* pcDtParam );
    323  
    324294  static UInt xGetSAD           ( DistParam* pcDtParam );
    325295  static UInt xGetSAD4          ( DistParam* pcDtParam );
     
    330300  static UInt xGetSAD16N        ( DistParam* pcDtParam );
    331301 
    332 #if SAIT_VSO_EST_A0033
     302#if H_3D_VSO
    333303  static UInt xGetVSD           ( DistParam* pcDtParam );
    334304  static UInt xGetVSD4          ( DistParam* pcDtParam );
     
    341311
    342312#if AMP_SAD
    343 #if LGE_ILLUCOMP_B0045
     313#if H_3D_IC || LGE_INTER_SDC_E0156
    344314  static UInt xGetSAD12ic       ( DistParam* pcDtParam );
    345315  static UInt xGetSAD24ic       ( DistParam* pcDtParam );
     
    349319  static UInt xGetSAD24         ( DistParam* pcDtParam );
    350320  static UInt xGetSAD48         ( DistParam* pcDtParam );
    351 #endif
    352 
    353 #if LGE_ILLUCOMP_B0045
     321
     322#endif
     323
     324#if H_3D_IC || LGE_INTER_SDC_E0156
    354325  static UInt xGetHADsic          ( DistParam* pcDtParam );
    355326#endif
     
    357328  static UInt xGetHADs8         ( DistParam* pcDtParam );
    358329  static UInt xGetHADs          ( DistParam* pcDtParam );
    359 
    360330  static UInt xCalcHADs2x2      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    361331  static UInt xCalcHADs4x4      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
     
    367337 
    368338public:
    369 #if HHI_INTERVIEW_SKIP
    370   UInt   getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, Pel* piUsed, Int iUsedStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc = DF_SSE );
    371 #endif
    372339#if WEIGHTED_CHROMA_DISTORTION
    373   UInt   getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bWeighted = false, DFunc eDFunc = DF_SSE );
    374 #else
    375   UInt   getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc = DF_SSE );
    376 #endif
    377  
    378 #if SAIT_VSO_EST_A0033
    379   UInt   getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, Pel* piVirRec, Pel* piVirOrg, Int iVirStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc = DF_VSD );
     340  UInt   getDistPart(Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText = TEXT_LUMA, DFunc eDFunc = DF_SSE );
     341#else
     342  UInt   getDistPart(Int bitDepth, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc = DF_SSE );
     343#endif
     344
     345#if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT
     346  UInt   getSADPart ( Int bitDepth, Pel* pelCur, Int curStride,  Pel* pelOrg, Int orgStride, UInt width, UInt height );
     347#endif
     348
     349#if H_3D_VSO
     350  // SAIT_VSO_EST_A0033
     351  UInt        getDistPartVSD( TComDataCU* pcCu, UInt uiPartOffset, Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHad, DFunc eDFunc = DF_VSD);
    380352  static UInt getVSDEstimate( Int dDM, Pel* pOrg, Int iOrgStride,  Pel* pVirRec, Pel* pVirOrg, Int iVirStride, Int x, Int y );
    381 #endif
    382 
    383 #if HHI_VSO
     353
    384354private:
    385355  Double                  m_dLambdaVSO;
     
    388358  UInt                    m_uiLambdaMotionSSEVSO;
    389359  Double                  m_dFrameLambdaVSO;
    390 
    391 #if HHI_VSO_DIST_INT
    392360  Bool                    m_bAllowNegDist;
    393 #endif
    394 #if SAIT_VSO_EST_A0033
     361  Bool                    m_bUseVSO;
     362  Bool                    m_bUseLambdaScaleVSO;
     363  UInt                    m_uiVSOMode;
     364
     365  FpDistFuncVSO           m_fpDistortFuncVSO;
     366  TRenModel*              m_pcRenModel;
     367
     368
     369  // SAIT_VSO_EST_A0033
    395370  TComPicYuv *            m_pcVideoRecPicYuv;
    396371  TComPicYuv *            m_pcDepthPicYuv;
    397372  Bool                    m_bUseEstimatedVSD;
    398 #endif
    399 #if LGE_WVSO_A0119
     373
     374  // LGE_WVSO_A0119
    400375  Int                     m_iDWeight;
    401376  Int                     m_iVSOWeight;
    402377  Int                     m_iVSDWeight;
    403378  Bool                    m_bUseWVSO;
    404 #endif
    405 
    406   Bool                    m_bUseVSO;
    407   Bool                    m_bUseLambdaScaleVSO;
    408   UInt                    m_uiVSOMode;
    409 
    410   FpDistFuncVSO           m_fpDistortFuncVSO;
    411   TRenModel*              m_pcRenModel;
     379
    412380public:
    413381
    414382  Void    setRenModel       ( TRenModel* pcRenModel ) { m_pcRenModel = pcRenModel; }
     383  TRenModel* getRenModel    ( )                       { return m_pcRenModel; }
    415384  Void    setRenModelData   ( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piData, Int iStride, Int iBlkWidth, Int iBlkHeight );
    416385  Void    setLambdaVSO      ( Double dLambda );
     
    420389  Void    setUseVSO ( Bool bIn )         { m_bUseVSO = bIn; };
    421390  Bool    getUseVSO ( )                  { return m_bUseVSO;};
    422 #if SAIT_VSO_EST_A0033
     391
     392  Bool    getUseRenModel ( )             { return (m_bUseVSO && m_uiVSOMode == 4); };
     393  Void    setUseLambdaScaleVSO(Bool bIn) { m_bUseLambdaScaleVSO = bIn; };
     394  Bool    getUseLambdaScaleVSO( )        { return m_bUseLambdaScaleVSO; };
     395
     396  Void    setVSOMode( UInt uiIn);
     397  UInt    getVSOMode( )                  { return m_uiVSOMode; }
     398  Void    setAllowNegDist ( Bool bAllowNegDist );
     399
     400  Double  getSqrtLambdaVSO ()   { return m_dSqrtLambdaVSO; }
     401  Double  getLambdaVSO ()       { return m_dLambdaVSO; }
     402
     403  Dist   getDistPartVSO( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD );
     404  Double calcRdCostVSO ( UInt   uiBits, Dist   uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
     405
     406  // SAIT_VSO_EST_A0033
    423407  Bool    getUseEstimatedVSD( )           { return m_bUseEstimatedVSD; };
    424408  Void    setUseEstimatedVSD( Bool bIn )  { m_bUseEstimatedVSD = bIn; };
     
    428412  TComPicYuv* getDepthPicYuv    ()                               { return m_pcDepthPicYuv; };
    429413  Void        setDepthPicYuv    ( TComPicYuv* pcDepthPicYuv )    { m_pcDepthPicYuv = pcDepthPicYuv; };
    430 #endif
    431 
    432   Bool    getUseRenModel ( )             { return (m_bUseVSO && m_uiVSOMode == 4); };
    433   Void    setUseLambdaScaleVSO(bool bIn) { m_bUseLambdaScaleVSO = bIn; };
    434   Bool    getUseLambdaScaleVSO( )        { return m_bUseLambdaScaleVSO; };
    435 
    436   Void    setVSOMode( UInt uiIn);
    437   UInt    getVSOMode( )                  { return m_uiVSOMode; }
    438 #if LGE_WVSO_A0119
     414
     415  // LGE_WVSO_A0119
    439416  Void    setUseWVSO ( Bool bIn )         { m_bUseWVSO = bIn; };
    440417  Bool    getUseWVSO ( )                  { return m_bUseWVSO;};
     
    445422  Void    setVSDWeight ( Int iVSDWeight ) { m_iVSDWeight = iVSDWeight; };
    446423  Int     getVSDWeight ()                 { return m_iVSDWeight; };
    447 #endif
    448 #if HHI_VSO_DIST_INT
    449   Void    setAllowNegDist ( Bool bAllowNegDist );
    450 #endif
    451 
    452 
    453   Double  getSqrtLambdaVSO ()   { return m_dSqrtLambdaVSO; }
    454   Double  getLambdaVSO ()       { return m_dLambdaVSO; }
    455 
    456   Dist    getDistVS( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD, UInt uiPlane );
    457   Double calcRdCostVSO( UInt   uiBits, Dist   uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
    458424
    459425private:
    460426  Dist xGetDistVSOMode4( Int iStartPosX, Int iStartPosY, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD );
    461427
    462 #endif // HHI_VSO
     428#endif // H_3D_VSO
    463429
    464430};// END CLASS DEFINITION TComRdCost
Note: See TracChangeset for help on using the changeset viewer.