Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibCommon/TComRdCost.h
- Timestamp:
- 13 Aug 2015, 17:38:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibCommon/TComRdCost.h
r1196 r1313 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 46 46 #include "TComSlice.h" 47 47 #include "TComRdCostWeightPrediction.h" 48 #if H_3D48 #if NH_3D 49 49 #include "../TLibRenderer/TRenModel.h" 50 #include "TComYuv.h" 51 #include "TComTU.h" 50 52 #endif 51 53 … … 53 55 //! \{ 54 56 55 #define FIX203 156 57 57 class DistParam; 58 58 class TComPattern; 59 #if H_3D59 #if NH_3D 60 60 class TComRdCost; 61 61 #endif … … 66 66 67 67 // for function pointer 68 typedef UInt (*FpDistFunc) (DistParam*);69 70 #if H_3D71 #if H_3D_VSO68 typedef Distortion (*FpDistFunc) (DistParam*); // TODO: can this pointer be replaced with a reference? - there are no NULL checks on pointer. 69 70 #if NH_3D 71 #if NH_3D_VSO 72 72 typedef Dist (TComRdCost::*FpDistFuncVSO) ( Int, Int, Pel*, Int, Pel*, Int, UInt, UInt, Bool ); 73 73 #endif … … 85 85 Int iStrideOrg; 86 86 Int iStrideCur; 87 #if H_3D_VSO87 #if NH_3D_VSO 88 88 // SAIT_VSO_EST_A0033 89 89 Pel* pVirRec; … … 91 91 Int iStrideVir; 92 92 #endif 93 #if H_3D_IC93 #if NH_3D_IC 94 94 Bool bUseIC; 95 95 #endif 96 #if H_3D_INTER_SDC96 #if NH_3D_SDC_INTER 97 97 Bool bUseSDCMRSAD; 98 98 #endif … … 103 103 Int bitDepth; 104 104 105 Bool bApplyWeight; // whether wei thed prediction is used or not106 wpScalingParam *wpCur; // weithed prediction scaling parameters for current ref107 UInt uiComp; // uiComp = 0 (luma Y), 1 (chroma U), 2 (chroma V)105 Bool bApplyWeight; // whether weighted prediction is used or not 106 WPScalingParam *wpCur; // weighted prediction scaling parameters for current ref 107 ComponentID compIdx; 108 108 109 109 // (vertical) subsampling shift (for reducing complexity) 110 110 // - 0 = no subsampling, 1 = even rows, 2 = every 4th, etc. 111 111 Int iSubShift; 112 112 113 113 DistParam() 114 114 { … … 123 123 iSubShift = 0; 124 124 bitDepth = 0; 125 #if H_3D_VSO125 #if NH_3D_VSO 126 126 // SAIT_VSO_EST_A0033 127 127 pVirRec = NULL; … … 129 129 iStrideVir = 0; 130 130 #endif 131 #if H_3D_INTER_SDC131 #if NH_3D_SDC_INTER 132 132 bUseSDCMRSAD = false; 133 133 #endif … … 137 137 /// RD cost computation class 138 138 class TComRdCost 139 : public TComRdCostWeightPrediction140 139 { 141 140 private: 142 141 // for distortion 143 144 #if AMP_SAD 145 FpDistFunc m_afpDistortFunc[64]; // [eDFunc] 146 #else 147 FpDistFunc m_afpDistortFunc[33]; // [eDFunc] 148 #endif 149 150 Double m_cbDistortionWeight; 151 Double m_crDistortionWeight; 142 143 FpDistFunc m_afpDistortFunc[DF_TOTAL_FUNCTIONS]; // [eDFunc] 144 CostMode m_costMode; 145 Double m_distortionWeight[MAX_NUM_COMPONENT]; // only chroma values are used. 152 146 Double m_dLambda; 153 147 Double m_sqrtLambda; 154 UInt m_uiLambdaMotionSAD; 155 UInt m_uiLambdaMotionSSE; 148 #if RExt__HIGH_BIT_DEPTH_SUPPORT 149 Double m_dLambdaMotionSAD[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/]; 150 Double m_dLambdaMotionSSE[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/]; 151 #else 152 UInt m_uiLambdaMotionSAD[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/]; 153 UInt m_uiLambdaMotionSSE[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/]; 154 #endif 156 155 Double m_dFrameLambda; 157 #if H_3D_VSO156 #if NH_3D_VSO 158 157 // SAIT_VSO_EST_A0033 159 158 static Double m_dDisparityCoeff; 160 159 #endif 161 160 162 161 // for motion cost 163 #if FIX203164 162 TComMv m_mvPredictor; 165 #else 166 UInt* m_puiComponentCostOriginP; 167 UInt* m_puiComponentCost; 168 UInt* m_puiVerCost; 169 UInt* m_puiHorCost; 170 #endif 163 #if RExt__HIGH_BIT_DEPTH_SUPPORT 164 Double m_dCost; 165 #else 171 166 UInt m_uiCost; 167 #endif 172 168 Int m_iCostScale; 173 #if !FIX203 174 Int m_iSearchLimit; 175 #endif 176 177 #if H_3D_DBBP 169 #if NH_3D_DBBP 178 170 Bool m_bUseMask; 179 171 #endif 180 172 181 173 public: 182 174 TComRdCost(); 183 175 virtual ~TComRdCost(); 184 185 #if H_3D_VSO 176 #if NH_3D_VSO 186 177 Double calcRdCost ( UInt uiBits, Dist uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT ); 187 178 Double calcRdCost64( UInt64 uiBits, Dist64 uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT ); 188 179 #else 189 Double calcRdCost ( UInt uiBits, UIntuiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );180 Double calcRdCost ( UInt uiBits, Distortion uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT ); 190 181 Double calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT ); 191 182 #endif 192 183 193 194 Void setCbDistortionWeight ( Double cbDistortionWeight) { m_cbDistortionWeight = cbDistortionWeight; }; 195 Void setCrDistortionWeight ( Double crDistortionWeight) { m_crDistortionWeight = crDistortionWeight; }; 196 Void setLambda ( Double dLambda ); 184 Void setDistortionWeight ( const ComponentID compID, const Double distortionWeight ) { m_distortionWeight[compID] = distortionWeight; } 185 Void setLambda ( Double dLambda, const BitDepths &bitDepths ); 197 186 Void setFrameLambda ( Double dLambda ) { m_dFrameLambda = dLambda; } 198 187 199 188 Double getSqrtLambda () { return m_sqrtLambda; } 200 #if H_3D_VSO189 #if NH_3D_VSO 201 190 // SAIT_VSO_EST_A0033 202 191 Void setDisparityCoeff( Double dDisparityCoeff ) { m_dDisparityCoeff = dDisparityCoeff; } … … 205 194 206 195 Double getLambda() { return m_dLambda; } 207 Double getChromaWeight () {return((m_cbDistortionWeight+m_crDistortionWeight)/2.0);} 208 196 Double getChromaWeight () { return ((m_distortionWeight[COMPONENT_Cb] + m_distortionWeight[COMPONENT_Cr]) / 2.0); } 197 198 Void setCostMode(CostMode m ) { m_costMode = m; } 199 209 200 // Distortion Functions 210 201 Void init(); 211 202 212 203 Void setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc, DistParam& rcDistParam ); 213 204 Void setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, DistParam& rcDistParam ); 214 205 Void setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false ); 215 206 Void setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false ); 216 217 #if H_3D_DBBP207 208 #if NH_3D_DBBP 218 209 Void setUseMask(Bool b) { m_bUseMask = b; } 219 210 #endif 220 221 UIntcalcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight );222 223 #if H_3D_FAST_DEPTH_INTRA224 UInt calcVAR(Pel* pi0, Int stride, Int width, Int height, Int cuDepth );211 212 Distortion calcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight ); 213 214 #if NH_3D_ENC_DEPTH 215 UInt calcVAR(Pel* pi0, Int stride, Int width, Int height, Int cuDepth, UInt maxCuWidth ); 225 216 #endif 217 226 218 // for motion cost 227 #if !FIX203 228 Void initRateDistortionModel( Int iSubPelSearchLimit ); 229 Void xUninit();230 #e ndif231 UInt xGetComponentBits( Int iVal );232 Void getMotionCost( Bool bSad, Int iAdd ) { m_uiCost = (bSad ? m_uiLambdaMotionSAD + iAdd : m_uiLambdaMotionSSE + iAdd); } 219 static UInt xGetExpGolombNumberOfBits( Int iVal ); 220 #if RExt__HIGH_BIT_DEPTH_SUPPORT 221 Void getMotionCost( Bool bSad, Int iAdd, Bool bIsTransquantBypass ) { m_dCost = (bSad ? m_dLambdaMotionSAD[(bIsTransquantBypass && m_costMode==COST_MIXED_LOSSLESS_LOSSY_CODING) ?1:0] + iAdd : m_dLambdaMotionSSE[(bIsTransquantBypass && m_costMode==COST_MIXED_LOSSLESS_LOSSY_CODING)?1:0] + iAdd); } 222 #else 223 Void getMotionCost( Bool bSad, Int iAdd, Bool bIsTransquantBypass ) { m_uiCost = (bSad ? m_uiLambdaMotionSAD[(bIsTransquantBypass && m_costMode==COST_MIXED_LOSSLESS_LOSSY_CODING) ?1:0] + iAdd : m_uiLambdaMotionSSE[(bIsTransquantBypass && m_costMode==COST_MIXED_LOSSLESS_LOSSY_CODING)?1:0] + iAdd); } 224 #endif 233 225 Void setPredictor( TComMv& rcMv ) 234 226 { 235 #if FIX203236 227 m_mvPredictor = rcMv; 237 #else238 m_puiHorCost = m_puiComponentCost - rcMv.getHor();239 m_puiVerCost = m_puiComponentCost - rcMv.getVer();240 #endif241 228 } 242 229 Void setCostScale( Int iCostScale ) { m_iCostScale = iCostScale; } 243 __inline UIntgetCost( Int x, Int y )230 __inline Distortion getCost( Int x, Int y ) 244 231 { 245 #if FIX203 232 #if RExt__HIGH_BIT_DEPTH_SUPPORT 233 return Distortion((m_dCost * getBits(x, y)) / 65536.0); 234 #else 246 235 return m_uiCost * getBits(x, y) >> 16; 247 #else248 return (( m_uiCost * (m_puiHorCost[ x * (1<<m_iCostScale) ] + m_puiVerCost[ y * (1<<m_iCostScale) ]) ) >> 16);249 236 #endif 250 237 } 251 UInt getCost( UInt b ) { return ( m_uiCost * b ) >> 16; } 252 UInt getBits( Int x, Int y ) 238 #if RExt__HIGH_BIT_DEPTH_SUPPORT 239 Distortion getCost( UInt b ) { return Distortion(( m_dCost * b ) / 65536.0); } 240 #else 241 Distortion getCost( UInt b ) { return ( m_uiCost * b ) >> 16; } 242 #endif 243 UInt getBits( Int x, Int y ) 253 244 { 254 #if FIX203 255 return xGetComponentBits((x << m_iCostScale) - m_mvPredictor.getHor()) 256 + xGetComponentBits((y << m_iCostScale) - m_mvPredictor.getVer()); 257 #else 258 return m_puiHorCost[ x * (1<<m_iCostScale)] + m_puiVerCost[ y * (1<<m_iCostScale) ]; 259 #endif 245 return xGetExpGolombNumberOfBits((x << m_iCostScale) - m_mvPredictor.getHor()) 246 + xGetExpGolombNumberOfBits((y << m_iCostScale) - m_mvPredictor.getVer()); 260 247 } 261 248 262 249 private: 263 264 static UIntxGetSSE ( DistParam* pcDtParam );265 static UIntxGetSSE4 ( DistParam* pcDtParam );266 static UIntxGetSSE8 ( DistParam* pcDtParam );267 static UIntxGetSSE16 ( DistParam* pcDtParam );268 static UIntxGetSSE32 ( DistParam* pcDtParam );269 static UIntxGetSSE64 ( DistParam* pcDtParam );270 static UIntxGetSSE16N ( DistParam* pcDtParam );271 #if H_3D_IC || H_3D_INTER_SDC250 251 static Distortion xGetSSE ( DistParam* pcDtParam ); 252 static Distortion xGetSSE4 ( DistParam* pcDtParam ); 253 static Distortion xGetSSE8 ( DistParam* pcDtParam ); 254 static Distortion xGetSSE16 ( DistParam* pcDtParam ); 255 static Distortion xGetSSE32 ( DistParam* pcDtParam ); 256 static Distortion xGetSSE64 ( DistParam* pcDtParam ); 257 static Distortion xGetSSE16N ( DistParam* pcDtParam ); 258 #if NH_3D_IC || NH_3D_SDC_INTER 272 259 static UInt xGetSADic ( DistParam* pcDtParam ); 273 260 static UInt xGetSAD4ic ( DistParam* pcDtParam ); … … 278 265 static UInt xGetSAD16Nic ( DistParam* pcDtParam ); 279 266 #endif 280 static UInt xGetSAD ( DistParam* pcDtParam ); 281 static UInt xGetSAD4( DistParam* pcDtParam );282 static UInt xGetSAD8( DistParam* pcDtParam );283 static UInt xGetSAD16( DistParam* pcDtParam );284 static UInt xGetSAD32( DistParam* pcDtParam );285 static UInt xGetSAD64( DistParam* pcDtParam );286 static UInt xGetSAD16N( DistParam* pcDtParam );287 288 #if H_3D_VSO267 268 static Distortion xGetSAD ( DistParam* pcDtParam ); 269 static Distortion xGetSAD4 ( DistParam* pcDtParam ); 270 static Distortion xGetSAD8 ( DistParam* pcDtParam ); 271 static Distortion xGetSAD16 ( DistParam* pcDtParam ); 272 static Distortion xGetSAD32 ( DistParam* pcDtParam ); 273 static Distortion xGetSAD64 ( DistParam* pcDtParam ); 274 static Distortion xGetSAD16N ( DistParam* pcDtParam ); 275 #if NH_3D_VSO 289 276 static UInt xGetVSD ( DistParam* pcDtParam ); 290 277 static UInt xGetVSD4 ( DistParam* pcDtParam ); … … 296 283 #endif 297 284 298 #if AMP_SAD 299 #if H_3D_IC || H_3D_INTER_SDC 285 #if NH_3D_IC || NH_3D_SDC_INTER 300 286 static UInt xGetSAD12ic ( DistParam* pcDtParam ); 301 287 static UInt xGetSAD24ic ( DistParam* pcDtParam ); 302 288 static UInt xGetSAD48ic ( DistParam* pcDtParam ); 303 289 #endif 304 static UInt xGetSAD12 ( DistParam* pcDtParam ); 305 static UInt xGetSAD24( DistParam* pcDtParam );306 static UInt xGetSAD48( DistParam* pcDtParam );307 308 #endif 309 310 #if H_3D_IC || H_3D_INTER_SDC290 291 static Distortion xGetSAD12 ( DistParam* pcDtParam ); 292 static Distortion xGetSAD24 ( DistParam* pcDtParam ); 293 static Distortion xGetSAD48 ( DistParam* pcDtParam ); 294 295 296 #if NH_3D_IC || NH_3D_SDC_INTER 311 297 static UInt xGetHADsic ( DistParam* pcDtParam ); 312 298 #endif 313 static UInt xGetHADs4 ( DistParam* pcDtParam ); 314 static UInt xGetHADs8 ( DistParam* pcDtParam ); 315 static UInt xGetHADs ( DistParam* pcDtParam ); 316 static UInt xCalcHADs2x2 ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep ); 317 static UInt xCalcHADs4x4 ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep ); 318 static UInt xCalcHADs8x8 ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep ); 319 #if H_3D_DBBP 299 300 static Distortion xGetHADs ( DistParam* pcDtParam ); 301 static Distortion xCalcHADs2x2 ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep ); 302 static Distortion xCalcHADs4x4 ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep ); 303 static Distortion xCalcHADs8x8 ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep ); 304 #if NH_3D_DBBP 320 305 static UInt xGetMaskedSSE ( DistParam* pcDtParam ); 321 306 static UInt xGetMaskedSAD ( DistParam* pcDtParam ); 322 307 static UInt xGetMaskedVSD ( DistParam* pcDtParam ); 323 308 #endif 324 309 310 325 311 public: 326 UInt getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText = TEXT_LUMA, DFunc eDFunc = DF_SSE ); 312 313 Distortion getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, const ComponentID compID, DFunc eDFunc = DF_SSE ); 327 314 328 315 #if KWU_RC_MADPRED_E0227 … … 330 317 #endif 331 318 332 #if H_3D_VSO333 // SAIT_VSO_EST_A0033 334 UInt getDistPartVSD( TComDataCU* pcCu, UInt uiPartOffset, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHad, DFunc eDFunc = DF_VSD);319 #if NH_3D_VSO 320 // SAIT_VSO_EST_A0033 321 UInt getDistPartVSD( TComDataCU* pcCu, UInt uiPartOffset, Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bHad, DFunc eDFunc = DF_VSD); 335 322 static UInt getVSDEstimate( Int dDM, Pel* pOrg, Int iOrgStride, Pel* pVirRec, Pel* pVirOrg, Int iVirStride, Int x, Int y ); 336 323 … … 365 352 Void setRenModel ( TRenModel* pcRenModel ) { m_pcRenModel = pcRenModel; } 366 353 TRenModel* getRenModel ( ) { return m_pcRenModel; } 367 Void setRenModelData ( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piData, Int iStride, Int iBlkWidth, Int iBlkHeight ); 354 Void setRenModelData ( const TComDataCU* pcCU, UInt uiAbsPartIndex, const TComYuv* pcYuv, const TComTURecurse* tuRecurseWithPU ); 355 Void setRenModelData ( const TComDataCU* pcCU, UInt uiAbsPartIndex, const Pel* piData, Int iStride, Int iBlkWidth, Int iBlkHeight ); 356 368 357 Void setLambdaVSO ( Double dLambda ); 369 358 Void setFrameLambdaVSO ( Double dLambda ) { m_dFrameLambdaVSO = dLambda; }; … … 384 373 Double getLambdaVSO () { return m_dLambdaVSO; } 385 374 386 Dist getDistPartVSO( TComDataCU* pcCU, UInt uiAbsPartIndex, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD );387 Double calcRdCostVSO ( UInt uiBits, Dist uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );375 Dist getDistPartVSO( TComDataCU* pcCU, UInt uiAbsPartIndex, Int bitdDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD ); 376 Double calcRdCostVSO ( UInt uiBits, Dist uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT ); 388 377 389 378 // SAIT_VSO_EST_A0033 … … 409 398 Dist xGetDistVSOMode4( Int iStartPosX, Int iStartPosY, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, Bool bSAD ); 410 399 411 #endif // H_3D_VSO 400 #endif // NH_3D_VSO 401 412 402 413 403 };// END CLASS DEFINITION TComRdCost
Note: See TracChangeset for help on using the changeset viewer.