Changeset 916 in SHVCSoftware for branches/SHM-upgrade/source/Lib/TLibCommon/TComRdCost.h
- Timestamp:
- 12 Nov 2014, 08:09:17 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-upgrade/source/Lib/TLibCommon/TComRdCost.h
r595 r916 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 6 * Copyright (c) 2010-2014, ITU/ISO/IEC … … 50 50 //! \{ 51 51 52 #define FIX203 153 54 52 class DistParam; 55 53 class TComPattern; … … 60 58 61 59 // for function pointer 62 typedef UInt (*FpDistFunc) (DistParam*);60 typedef Distortion (*FpDistFunc) (DistParam*); // TODO: can this pointer be replaced with a reference? - there are no NULL checks on pointer. 63 61 64 62 // ==================================================================================================================== … … 80 78 Int bitDepth; 81 79 82 Bool bApplyWeight; // whether wei thed prediction is used or not83 wpScalingParam *wpCur; // weithed prediction scaling parameters for current ref84 UInt uiComp; // uiComp = 0 (luma Y), 1 (chroma U), 2 (chroma V)80 Bool bApplyWeight; // whether weighted prediction is used or not 81 WPScalingParam *wpCur; // weighted prediction scaling parameters for current ref 82 ComponentID compIdx; 85 83 86 84 // (vertical) subsampling shift (for reducing complexity) 87 85 // - 0 = no subsampling, 1 = even rows, 2 = every 4th, etc. 88 86 Int iSubShift; 89 87 90 88 DistParam() 91 89 { … … 105 103 /// RD cost computation class 106 104 class TComRdCost 107 : public TComRdCostWeightPrediction108 105 { 109 106 private: 110 107 // for distortion 111 112 #if AMP_SAD 113 FpDistFunc m_afpDistortFunc[64]; // [eDFunc] 114 #else 115 FpDistFunc m_afpDistortFunc[33]; // [eDFunc] 116 #endif 117 118 Double m_cbDistortionWeight; 119 Double m_crDistortionWeight; 108 109 FpDistFunc m_afpDistortFunc[DF_TOTAL_FUNCTIONS]; // [eDFunc] 110 CostMode m_costMode; 111 Double m_distortionWeight[MAX_NUM_COMPONENT]; // only chroma values are used. 120 112 Double m_dLambda; 121 113 Double m_sqrtLambda; 122 UInt m_uiLambdaMotionSAD; 123 UInt m_uiLambdaMotionSSE; 114 #if RExt__HIGH_BIT_DEPTH_SUPPORT 115 Double m_dLambdaMotionSAD[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/]; 116 Double m_dLambdaMotionSSE[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/]; 117 #else 118 UInt m_uiLambdaMotionSAD[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/]; 119 UInt m_uiLambdaMotionSSE[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/]; 120 #endif 124 121 Double m_dFrameLambda; 125 122 126 123 // for motion cost 127 #if FIX203128 124 TComMv m_mvPredictor; 129 #else 130 UInt* m_puiComponentCostOriginP; 131 UInt* m_puiComponentCost; 132 UInt* m_puiVerCost; 133 UInt* m_puiHorCost; 134 #endif 125 #if RExt__HIGH_BIT_DEPTH_SUPPORT 126 Double m_dCost; 127 #else 135 128 UInt m_uiCost; 129 #endif 136 130 Int m_iCostScale; 137 #if !FIX203 138 Int m_iSearchLimit; 139 #endif 140 131 141 132 public: 142 133 TComRdCost(); 143 134 virtual ~TComRdCost(); 144 145 Double calcRdCost ( UInt uiBits, UIntuiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT );135 136 Double calcRdCost ( UInt uiBits, Distortion uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT ); 146 137 Double calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT ); 147 148 Void setCbDistortionWeight ( Double cbDistortionWeight) { m_cbDistortionWeight = cbDistortionWeight; }; 149 Void setCrDistortionWeight ( Double crDistortionWeight) { m_crDistortionWeight = crDistortionWeight; }; 138 139 Void setDistortionWeight ( const ComponentID compID, const Double distortionWeight ) { m_distortionWeight[compID] = distortionWeight; } 150 140 Void setLambda ( Double dLambda ); 151 141 Void setFrameLambda ( Double dLambda ) { m_dFrameLambda = dLambda; } 152 142 153 143 Double getSqrtLambda () { return m_sqrtLambda; } 154 144 155 145 Double getLambda() { return m_dLambda; } 156 Double getChromaWeight () {return((m_cbDistortionWeight+m_crDistortionWeight)/2.0);} 157 146 Double getChromaWeight () { return ((m_distortionWeight[COMPONENT_Cb] + m_distortionWeight[COMPONENT_Cr]) / 2.0); } 147 148 Void setCostMode(CostMode m ) { m_costMode = m; } 149 158 150 // Distortion Functions 159 151 Void init(); 160 152 161 153 Void setDistParam( UInt uiBlkWidth, UInt uiBlkHeight, DFunc eDFunc, DistParam& rcDistParam ); 162 154 Void setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, DistParam& rcDistParam ); 163 155 Void setDistParam( TComPattern* pcPatternKey, Pel* piRefY, Int iRefStride, Int iStep, DistParam& rcDistParam, Bool bHADME=false ); 164 156 Void setDistParam( DistParam& rcDP, Int bitDepth, Pel* p1, Int iStride1, Pel* p2, Int iStride2, Int iWidth, Int iHeight, Bool bHadamard = false ); 165 166 UIntcalcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight );167 157 158 Distortion calcHAD(Int bitDepth, Pel* pi0, Int iStride0, Pel* pi1, Int iStride1, Int iWidth, Int iHeight ); 159 168 160 // for motion cost 169 #if !FIX203170 Void initRateDistortionModel( Int iSubPelSearchLimit );171 Void xUninit();172 #endif173 161 UInt xGetComponentBits( Int iVal ); 174 Void getMotionCost( Bool bSad, Int iAdd ) { m_uiCost = (bSad ? m_uiLambdaMotionSAD + iAdd : m_uiLambdaMotionSSE + iAdd); } 162 #if RExt__HIGH_BIT_DEPTH_SUPPORT 163 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); } 164 #else 165 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); } 166 #endif 175 167 Void setPredictor( TComMv& rcMv ) 176 168 { 177 #if FIX203178 169 m_mvPredictor = rcMv; 179 #else180 m_puiHorCost = m_puiComponentCost - rcMv.getHor();181 m_puiVerCost = m_puiComponentCost - rcMv.getVer();182 #endif183 170 } 184 171 Void setCostScale( Int iCostScale ) { m_iCostScale = iCostScale; } 185 __inline UInt getCost( Int x, Int y ) 186 { 187 #if FIX203 172 __inline Distortion getCost( Int x, Int y ) 173 { 174 #if RExt__HIGH_BIT_DEPTH_SUPPORT 175 return Distortion((m_dCost * getBits(x, y)) / 65536.0); 176 #else 188 177 return m_uiCost * getBits(x, y) >> 16; 189 #else 190 return (( m_uiCost * (m_puiHorCost[ x * (1<<m_iCostScale) ] + m_puiVerCost[ y * (1<<m_iCostScale) ]) ) >> 16); 191 #endif 192 } 193 UInt getCost( UInt b ) { return ( m_uiCost * b ) >> 16; } 194 UInt getBits( Int x, Int y ) 195 { 196 #if FIX203 178 #endif 179 } 180 #if RExt__HIGH_BIT_DEPTH_SUPPORT 181 Distortion getCost( UInt b ) { return Distortion(( m_dCost * b ) / 65536.0); } 182 #else 183 Distortion getCost( UInt b ) { return ( m_uiCost * b ) >> 16; } 184 #endif 185 UInt getBits( Int x, Int y ) 186 { 197 187 return xGetComponentBits((x << m_iCostScale) - m_mvPredictor.getHor()) 198 188 + xGetComponentBits((y << m_iCostScale) - m_mvPredictor.getVer()); 199 #else 200 return m_puiHorCost[ x * (1<<m_iCostScale)] + m_puiVerCost[ y * (1<<m_iCostScale) ]; 201 #endif 202 } 203 189 } 190 204 191 private: 205 206 static UIntxGetSSE ( DistParam* pcDtParam );207 static UIntxGetSSE4 ( DistParam* pcDtParam );208 static UIntxGetSSE8 ( DistParam* pcDtParam );209 static UIntxGetSSE16 ( DistParam* pcDtParam );210 static UIntxGetSSE32 ( DistParam* pcDtParam );211 static UIntxGetSSE64 ( DistParam* pcDtParam );212 static UIntxGetSSE16N ( DistParam* pcDtParam );213 214 static UIntxGetSAD ( DistParam* pcDtParam );215 static UIntxGetSAD4 ( DistParam* pcDtParam );216 static UIntxGetSAD8 ( DistParam* pcDtParam );217 static UIntxGetSAD16 ( DistParam* pcDtParam );218 static UIntxGetSAD32 ( DistParam* pcDtParam );219 static UIntxGetSAD64 ( DistParam* pcDtParam );220 static UIntxGetSAD16N ( DistParam* pcDtParam );221 192 193 static Distortion xGetSSE ( DistParam* pcDtParam ); 194 static Distortion xGetSSE4 ( DistParam* pcDtParam ); 195 static Distortion xGetSSE8 ( DistParam* pcDtParam ); 196 static Distortion xGetSSE16 ( DistParam* pcDtParam ); 197 static Distortion xGetSSE32 ( DistParam* pcDtParam ); 198 static Distortion xGetSSE64 ( DistParam* pcDtParam ); 199 static Distortion xGetSSE16N ( DistParam* pcDtParam ); 200 201 static Distortion xGetSAD ( DistParam* pcDtParam ); 202 static Distortion xGetSAD4 ( DistParam* pcDtParam ); 203 static Distortion xGetSAD8 ( DistParam* pcDtParam ); 204 static Distortion xGetSAD16 ( DistParam* pcDtParam ); 205 static Distortion xGetSAD32 ( DistParam* pcDtParam ); 206 static Distortion xGetSAD64 ( DistParam* pcDtParam ); 207 static Distortion xGetSAD16N ( DistParam* pcDtParam ); 208 222 209 #if AMP_SAD 223 static UInt xGetSAD12 ( DistParam* pcDtParam ); 224 static UInt xGetSAD24 ( DistParam* pcDtParam ); 225 static UInt xGetSAD48 ( DistParam* pcDtParam ); 226 227 #endif 228 229 static UInt xGetHADs4 ( DistParam* pcDtParam ); 230 static UInt xGetHADs8 ( DistParam* pcDtParam ); 231 static UInt xGetHADs ( DistParam* pcDtParam ); 232 static UInt xCalcHADs2x2 ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep ); 233 static UInt xCalcHADs4x4 ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep ); 234 static UInt xCalcHADs8x8 ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep ); 235 210 static Distortion xGetSAD12 ( DistParam* pcDtParam ); 211 static Distortion xGetSAD24 ( DistParam* pcDtParam ); 212 static Distortion xGetSAD48 ( DistParam* pcDtParam ); 213 214 #endif 215 216 static Distortion xGetHADs ( DistParam* pcDtParam ); 217 static Distortion xCalcHADs2x2 ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep ); 218 static Distortion xCalcHADs4x4 ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep ); 219 static Distortion xCalcHADs8x8 ( Pel *piOrg, Pel *piCurr, Int iStrideOrg, Int iStrideCur, Int iStep ); 220 221 236 222 public: 237 UInt getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, TextType eText = TEXT_LUMA, DFunc eDFunc = DF_SSE ); 223 224 Distortion getDistPart(Int bitDepth, Pel* piCur, Int iCurStride, Pel* piOrg, Int iOrgStride, UInt uiBlkWidth, UInt uiBlkHeight, const ComponentID compID, DFunc eDFunc = DF_SSE ); 238 225 239 226 };// END CLASS DEFINITION TComRdCost
Note: See TracChangeset for help on using the changeset viewer.