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


Ignore:
Timestamp:
11 May 2012, 21:20:17 (12 years ago)
Author:
hschwarz
Message:

updated trunk (move to HM6.1)

File:
1 edited

Legend:

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

    r5 r56  
    22 * License, included below. This software may be subject to other third party
    33 * and contributor rights, including patent rights, and no such rights are
    4  * granted under this license.
     4 * granted under this license. 
    55 *
    6  * Copyright (c) 2010-2011, ISO/IEC
     6 * Copyright (c) 2010-2012, ITU/ISO/IEC
    77 * All rights reserved.
    88 *
     
    1515 *    this list of conditions and the following disclaimer in the documentation
    1616 *    and/or other materials provided with the distribution.
    17  *  * Neither the name of the ISO/IEC nor the names of its contributors may
     17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
    1818 *    be used to endorse or promote products derived from this software without
    1919 *    specific prior written permission.
     
    4141
    4242#include "CommonDef.h"
    43 #include "TComMVDRefData.h"
    44 #include "TComDataCU.h"
    4543#include "TComPattern.h"
    4644#include "TComMv.h"
    47 #ifdef WEIGHT_PRED
    48   #include "TComSlice.h"
    49   #include "TComRdCostWeightPrediction.h"
    50 #endif
    51 #include "TComYuv.h"
    52 #include "TComMVDRefData.h"
     45
     46#include "TComRdCost.h"
     47#include "TComSlice.h"
     48#include "TComRdCostWeightPrediction.h"
    5349#include "../TLibRenderer/TRenModel.h"
     50
     51//! \ingroup TLibCommon
     52//! \{
     53
     54#define FIX203 1
    5455
    5556class DistParam;
    5657class TComPattern;
    57 class TComRdCost;
     58class TComRdCost; 
    5859
    5960// ====================================================================================================================
     
    6465typedef UInt (*FpDistFunc) (DistParam*);
    6566
    66 //GT VSO
     67#if HHI_VSO
    6768typedef Dist (TComRdCost::*FpDistFuncVSO) ( Int, Int, Pel*, Int, Pel*, Int, UInt, UInt, Bool );
    68 //GT VSO end
    69 
    70 #ifdef ROUNDING_CONTROL_BIPRED
    71 typedef UInt (*FpDistFuncRnd) (DistParam*, Pel*, Bool);
    72 #endif
    73 
     69#endif
    7470// ====================================================================================================================
    7571// Class definition
     
    8884  Int   iStep;
    8985  FpDistFunc DistFunc;
    90 #ifdef ROUNDING_CONTROL_BIPRED
    91   FpDistFuncRnd DistFuncRnd;
    92 #endif
     86
    9387#if HHI_INTERVIEW_SKIP
    9488  Pel*  pUsed;
    9589  Int   iStrideUsed;
    9690#endif
    97 
    98 #ifdef WEIGHT_PRED
    99   Bool            applyWeight;      // whether weithed prediction is used or not
    100   wpScalingParam  *wpCur, *wpRef;   // weithed prediction scaling parameters for ref0 (or ref1) and ref1 (resp. ref0)
     91  Bool            bApplyWeight;     // whether weithed prediction is used or not
     92  wpScalingParam  *wpCur;           // weithed prediction scaling parameters for current ref
    10193  UInt            uiComp;           // uiComp = 0 (luma Y), 1 (chroma U), 2 (chroma V)
     94
     95#if NS_HAD
     96  Bool            bUseNSHAD;
    10297#endif
    10398
     
    105100  // - 0 = no subsampling, 1 = even rows, 2 = every 4th, etc.
    106101  Int   iSubShift;
    107 
     102 
    108103  DistParam()
    109104  {
     
    116111    iStep = 1;
    117112    DistFunc = NULL;
    118 #ifdef ROUNDING_CONTROL_BIPRED
    119     DistFuncRnd = NULL;
    120 #endif
    121113    iSubShift = 0;
    122114#if HHI_INTERVIEW_SKIP
     
    124116    iStrideUsed = 0;
    125117#endif
     118#if NS_HAD
     119    bUseNSHAD = false;
     120#endif
    126121  }
    127122};
     
    129124/// RD cost computation class
    130125class TComRdCost
    131 #ifdef WEIGHT_PRED
    132126  : public TComRdCostWeightPrediction
    133 #endif
    134127{
    135128private:
     
    137130  Int                     m_iBlkWidth;
    138131  Int                     m_iBlkHeight;
    139 
     132 
     133#if AMP_SAD
     134  FpDistFunc              m_afpDistortFunc[64]; // [eDFunc]
     135#else 
    140136  FpDistFunc              m_afpDistortFunc[33]; // [eDFunc]
    141 #ifdef ROUNDING_CONTROL_BIPRED
    142   FpDistFuncRnd           m_afpDistortFuncRnd[33];
    143 #endif
    144 
     137#endif 
     138 
     139#if WEIGHTED_CHROMA_DISTORTION
     140  Double                  m_chromaDistortionWeight;   
     141#endif
    145142  Double                  m_dLambda;
    146143  Double                  m_sqrtLambda;
     
    148145  UInt                    m_uiLambdaMotionSSE;
    149146  Double                  m_dFrameLambda;
    150 
     147 
    151148#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
    152149  Double                  m_dLambdaScale ;
    153150#endif
    154151  // for motion cost
     152#if FIX203
     153  TComMv                  m_mvPredictor;
     154#else
    155155  UInt*                   m_puiComponentCostOriginP;
    156156  UInt*                   m_puiComponentCost;
    157157  UInt*                   m_puiVerCost;
    158158  UInt*                   m_puiHorCost;
     159#endif
    159160  UInt                    m_uiCost;
    160161  Int                     m_iCostScale;
     162#if !FIX203
    161163  Int                     m_iSearchLimit;
    162 
     164#endif
     165 
    163166  Bool                    m_bUseMultiviewReg;
    164167  UInt                    m_uiLambdaMVReg;
     
    172175  UInt*                   m_puiVerRegCost;
    173176  TComMv                  m_cMultiviewOrgMvPred;
    174 
     177 
    175178public:
    176179  TComRdCost();
    177180  virtual ~TComRdCost();
    178 
    179   Double  calcRdCost  ( UInt   uiBits, Dist   uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
     181 
     182  Double  calcRdCost  ( UInt   uiBits, UInt   uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
    180183  Double  calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );
    181 
     184 
     185#if WEIGHTED_CHROMA_DISTORTION
     186  Void    setChromaDistortionWeight      ( Double chromaDistortionWeight) { m_chromaDistortionWeight = chromaDistortionWeight; };
     187#endif
    182188  Void    setLambda      ( Double dLambda );
    183189#if HHI_INTER_VIEW_MOTION_PRED
     
    185191#endif
    186192  Void    setFrameLambda ( Double dLambda ) { m_dFrameLambda = dLambda; }
    187 
     193 
    188194#if HHI_INTERVIEW_SKIP_LAMBDA_SCALE
    189195  Void   setLambdaScale  ( Double dLambdaScale) { m_dLambdaScale = dLambdaScale; }
     
    191197#endif
    192198  Double  getSqrtLambda ()   { return m_sqrtLambda; }
    193 
     199 
    194200  // Distortion Functions
    195201  Void    init();
    196 
     202 
    197203  Void    setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc, DistParam& rcDistParam );
    198204  Void    setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride,            DistParam& rcDistParam );
     205#if NS_HAD
     206  Void    setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false, Bool bUseNSHAD=false );
     207  Void    setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false, Bool bUseNSHAD=false );
     208#else
    199209  Void    setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false );
    200210  Void    setDistParam( DistParam& rcDP, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false );
    201 
    202 #ifdef ROUNDING_CONTROL_BIPRED
    203   Void    setDistParam_Bi( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride,            DistParam& rcDistParam );
    204   Void    setDistParam_Bi( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false );
    205 #endif
    206 
     211#endif
     212 
    207213  UInt    calcHAD         ( Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight );
    208 
     214 
    209215  // for motion cost
     216#if !FIX203
    210217  Void    initRateDistortionModel( Int iSubPelSearchLimit );
    211218  Void    xUninit();
     219#endif
    212220  UInt    xGetComponentBits( Int iVal );
    213   Void    getMotionCost( Bool bSad, Int iAdd )
    214   {
    215     m_uiCost        = ( bSad ? m_uiLambdaMotionSAD + iAdd : m_uiLambdaMotionSSE + iAdd );
    216     m_uiLambdaMVReg = ( bSad ? m_uiLambdaMVRegSAD         : m_uiLambdaMVRegSSE         );
    217   }
     221  Void    getMotionCost( Bool bSad, Int iAdd ) { m_uiCost = (bSad ? m_uiLambdaMotionSAD + iAdd : m_uiLambdaMotionSSE + iAdd); }
    218222  Void    setPredictor( TComMv& rcMv )
    219223  {
     224#if FIX203
     225    m_mvPredictor = rcMv;
     226#else
    220227    m_puiHorCost = m_puiComponentCost - rcMv.getHor();
    221228    m_puiVerCost = m_puiComponentCost - rcMv.getVer();
     229#endif
    222230  }
    223231  Void    setCostScale( Int iCostScale )    { m_iCostScale = iCostScale; }
    224232  __inline UInt getCost( Int x, Int y )
    225233  {
     234#if FIX203
     235    return m_uiCost * getBits(x, y) >> 16;
     236#else
    226237    return (( m_uiCost * (m_puiHorCost[ x * (1<<m_iCostScale) ] + m_puiVerCost[ y * (1<<m_iCostScale) ]) ) >> 16);
     238#endif
    227239  }
    228240  UInt    getCost( UInt b )                 { return ( m_uiCost * b ) >> 16; }
    229   UInt    getBits( Int x, Int y )           { return m_puiHorCost[ x * (1<<m_iCostScale)] + m_puiVerCost[ y * (1<<m_iCostScale) ]; }
     241  UInt    getBits( Int x, Int y )         
     242  {
     243#if FIX203
     244    return xGetComponentBits((x << m_iCostScale) - m_mvPredictor.getHor())
     245    +      xGetComponentBits((y << m_iCostScale) - m_mvPredictor.getVer());
     246#else
     247    return m_puiHorCost[ x * (1<<m_iCostScale)] + m_puiVerCost[ y * (1<<m_iCostScale) ];
     248#endif
     249  }
    230250
    231251  Void    setMultiviewReg( TComMv* pcMv )
     
    252272    return ( ( m_uiLambdaMVReg * ( m_puiHorRegCost[ x * ( 1 << m_iCostScale ) ] + m_puiVerRegCost[ y * ( 1 << m_iCostScale ) ] ) ) >> 16 );
    253273  }
    254 
     274 
    255275private:
    256 
     276 
    257277  static UInt xGetSSE           ( DistParam* pcDtParam );
    258278  static UInt xGetSSE4          ( DistParam* pcDtParam );
     
    262282  static UInt xGetSSE64         ( DistParam* pcDtParam );
    263283  static UInt xGetSSE16N        ( DistParam* pcDtParam );
    264 
     284 
    265285  static UInt xGetSAD           ( DistParam* pcDtParam );
    266286  static UInt xGetSAD4          ( DistParam* pcDtParam );
     
    270290  static UInt xGetSAD64         ( DistParam* pcDtParam );
    271291  static UInt xGetSAD16N        ( DistParam* pcDtParam );
    272 
    273   static UInt xGetSADs          ( DistParam* pcDtParam );
    274   static UInt xGetSADs4         ( DistParam* pcDtParam );
    275   static UInt xGetSADs8         ( DistParam* pcDtParam );
    276   static UInt xGetSADs16        ( DistParam* pcDtParam );
    277   static UInt xGetSADs32        ( DistParam* pcDtParam );
    278   static UInt xGetSADs64        ( DistParam* pcDtParam );
    279   static UInt xGetSADs16N       ( DistParam* pcDtParam );
     292 
     293#if AMP_SAD
     294  static UInt xGetSAD12         ( DistParam* pcDtParam );
     295  static UInt xGetSAD24         ( DistParam* pcDtParam );
     296  static UInt xGetSAD48         ( DistParam* pcDtParam );
     297
     298#endif
    280299
    281300  static UInt xGetHADs4         ( DistParam* pcDtParam );
     
    285304  static UInt xCalcHADs4x4      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    286305  static UInt xCalcHADs8x8      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
    287 
    288 #ifdef ROUNDING_CONTROL_BIPRED
    289 
    290   static UInt xGetSSE           ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    291   static UInt xGetSSE4          ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    292   static UInt xGetSSE8          ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    293   static UInt xGetSSE16         ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    294   static UInt xGetSSE32         ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    295   static UInt xGetSSE64         ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    296   static UInt xGetSSE16N        ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    297 
    298   static UInt xGetSAD           ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    299   static UInt xGetSAD4          ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    300   static UInt xGetSAD8          ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    301   static UInt xGetSAD16         ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    302   static UInt xGetSAD32         ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    303   static UInt xGetSAD64         ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    304   static UInt xGetSAD16N        ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    305 
    306   static UInt xGetSADs          ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    307   static UInt xGetSADs4         ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    308   static UInt xGetSADs8         ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    309   static UInt xGetSADs16        ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    310   static UInt xGetSADs32        ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    311   static UInt xGetSADs64        ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    312   static UInt xGetSADs16N       ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    313 
    314   static UInt xGetHADs4         ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    315   static UInt xGetHADs8         ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    316   static UInt xGetHADs          ( DistParam* pcDtParam, Pel* pRefY, Bool bRound );
    317   static UInt xCalcHADs2x2      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep, Pel* pRefY, Int refYStride, Bool bRound );
    318   static UInt xCalcHADs4x4      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep, Pel* pRefY, Int refYStride, Bool bRound );
    319   static UInt xCalcHADs8x8      ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep, Pel* pRefY, Int refYStride, Bool bRound );
    320 
    321 #endif
    322 
     306#if NS_HAD
     307  static UInt xCalcHADs16x4     ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
     308  static UInt xCalcHADs4x16     ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep );
     309#endif
     310 
    323311public:
    324312#if HHI_INTERVIEW_SKIP
    325313  UInt   getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, Pel* piUsed, Int iUsedStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc = DF_SSE );
    326314#endif
     315#if WEIGHTED_CHROMA_DISTORTION
     316  UInt   getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bWeighted = false, DFunc eDFunc = DF_SSE );
     317#else
    327318  UInt   getDistPart( Pel* piCur, Int iCurStride,  Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc = DF_SSE );
    328 
     319#endif
     320 
    329321#if HHI_VSO
    330322private:
     
    339331#endif
    340332
    341   TComPicYuv *            m_pcVideoPicYuv;
    342   TComPicYuv**            m_apRefPics;
    343   Int      ***            m_paaiShiftLUTs;
    344   UInt                    m_uiNumberRefPics;
    345333  Bool                    m_bUseVSO;
    346334  Bool                    m_bUseLambdaScaleVSO;
    347335  UInt                    m_uiVSOMode;
    348336
    349   FpDistFuncVSO m_fpDistortFuncVSO;
     337  FpDistFuncVSO           m_fpDistortFuncVSO;
    350338  TRenModel*              m_pcRenModel;
    351339public:
     
    356344  Void    setFrameLambdaVSO ( Double dLambda ) { m_dFrameLambdaVSO = dLambda; };
    357345
    358   Void    setRefDataFromMVDInfo( TComMVDRefData* pRefInfo );
    359346
    360347  Void    setUseVSO ( Bool bIn )         { m_bUseVSO = bIn; };
     
    386373};// END CLASS DEFINITION TComRdCost
    387374
     375//! \}
    388376
    389377#endif // __TCOMRDCOST__
    390 
Note: See TracChangeset for help on using the changeset viewer.