Changeset 1389 in SHVCSoftware
- Timestamp:
- 4 Aug 2015, 03:02:06 (9 years ago)
- Location:
- branches/SHM-dev/source/Lib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/Lib/TLibCommon/TComRdCost.cpp
r1388 r1389 55 55 56 56 // Calculate RD functions 57 Double TComRdCost::calcRdCost( UInt uiBits, Distortion uiDistortion, Bool bFlag, DFunc eDFunc ) 58 { 59 Double dRdCost = 0.0; 60 Double dLambda = 0.0; 57 Double TComRdCost::calcRdCost( Double numBits, Double distortion, DFunc eDFunc ) 58 { 59 Double lambda = 1.0; 61 60 62 61 switch ( eDFunc ) … … 66 65 break; 67 66 case DF_SAD: 68 #if RExt__HIGH_BIT_DEPTH_SUPPORT 69 dLambda = m_dLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate. 70 #else 71 dLambda = (Double)m_uiLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate. 72 #endif 67 lambda = m_dLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate. 73 68 break; 74 69 case DF_DEFAULT: 75 dLambda =m_dLambda;70 lambda = m_dLambda; 76 71 break; 77 72 case DF_SSE_FRAME: 78 dLambda =m_dFrameLambda;73 lambda = m_dFrameLambda; 79 74 break; 80 75 default: … … 83 78 } 84 79 85 if (bFlag) //NOTE: this "bFlag" is never true 86 { 87 // Intra8x8, Intra4x4 Block only... 80 if (eDFunc == DF_SAD) 81 { 88 82 if (m_costMode != COST_STANDARD_LOSSY) 89 83 { 90 dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used.84 return ((distortion * 65536.0) / lambda) + numBits; // all lossless costs would have uiDistortion=0, and therefore this cost function can be used. 91 85 } 92 86 else 93 87 { 94 dRdCost = (((Double)uiDistortion) + ((Double)uiBits * dLambda));88 return distortion + (((numBits * lambda) ) / 65536.0); 95 89 } 96 90 } 97 91 else 98 92 { 99 if (eDFunc == DF_SAD) 100 { 101 if (m_costMode != COST_STANDARD_LOSSY) 102 { 103 dRdCost = ((Double(uiDistortion) * 65536) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used. 104 } 105 else 106 { 107 dRdCost = Double(uiDistortion) + ((Double(uiBits) * dLambda) / 65536.0); 108 } 93 if (m_costMode != COST_STANDARD_LOSSY) 94 { 95 return (distortion / lambda) + numBits; // all lossless costs would have uiDistortion=0, and therefore this cost function can be used. 109 96 } 110 97 else 111 98 { 112 if (m_costMode != COST_STANDARD_LOSSY) 113 { 114 dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used. 115 } 116 else 117 { 118 dRdCost = Double(uiDistortion) + (Double(uiBits) * dLambda); 119 } 120 } 121 } 122 123 return dRdCost; 124 } 125 126 Double TComRdCost::calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag, DFunc eDFunc ) 127 { 128 Double dRdCost = 0.0; 129 Double dLambda = 0.0; 130 131 switch ( eDFunc ) 132 { 133 case DF_SSE: 134 assert(0); 135 break; 136 case DF_SAD: 137 #if RExt__HIGH_BIT_DEPTH_SUPPORT 138 dLambda = m_dLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate. 139 #else 140 dLambda = (Double)m_uiLambdaMotionSAD[0]; // 0 is valid, because for lossless blocks, the cost equation is modified to compensate. 141 #endif 142 break; 143 case DF_DEFAULT: 144 dLambda = m_dLambda; 145 break; 146 case DF_SSE_FRAME: 147 dLambda = m_dFrameLambda; 148 break; 149 default: 150 assert (0); 151 break; 152 } 153 154 if (bFlag) //NOTE: this "bFlag" is never true 155 { 156 // Intra8x8, Intra4x4 Block only... 157 if (m_costMode != COST_STANDARD_LOSSY) 158 { 159 dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used. 160 } 161 else 162 { 163 dRdCost = (((Double)(Int64)uiDistortion) + ((Double)(Int64)uiBits * dLambda)); 164 } 165 } 166 else 167 { 168 if (eDFunc == DF_SAD) 169 { 170 if (m_costMode != COST_STANDARD_LOSSY) 171 { 172 dRdCost = ((Double(uiDistortion) * 65536) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used. 173 } 174 else 175 { 176 dRdCost = Double(uiDistortion) + ((Double(uiBits) * dLambda) / 65536.0); 177 } 178 } 179 else 180 { 181 if (m_costMode != COST_STANDARD_LOSSY) 182 { 183 dRdCost = (Double(uiDistortion) / dLambda) + Double(uiBits); // all lossless costs would have uiDistortion=0, and therefore this cost function can be used. 184 } 185 else 186 { 187 dRdCost = Double(uiDistortion) + (Double(uiBits) * dLambda); 188 } 189 } 190 } 191 192 return dRdCost; 99 return distortion + (numBits * lambda); 100 } 101 } 193 102 } 194 103 … … 197 106 m_dLambda = dLambda; 198 107 m_sqrtLambda = sqrt(m_dLambda); 199 #if RExt__HIGH_BIT_DEPTH_SUPPORT200 108 m_dLambdaMotionSAD[0] = 65536.0 * m_sqrtLambda; 201 109 m_dLambdaMotionSSE[0] = 65536.0 * m_dLambda; … … 207 115 m_dLambdaMotionSAD[1] = 65536.0 * sqrt(dLambda); 208 116 m_dLambdaMotionSSE[1] = 65536.0 * dLambda; 209 #else210 m_uiLambdaMotionSAD[0] = (UInt)floor(65536.0 * m_sqrtLambda);211 m_uiLambdaMotionSSE[0] = (UInt)floor(65536.0 * m_dLambda );212 #if FULL_NBIT213 dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12) / 3.0));214 #else215 dLambda = 0.57 * pow(2.0, ((LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME - 12 - 6 * (bitDepths.recon[CHANNEL_TYPE_LUMA] - 8)) / 3.0));216 #endif217 m_uiLambdaMotionSAD[1] = (UInt)floor(65536.0 * sqrt(dLambda));218 m_uiLambdaMotionSSE[1] = (UInt)floor(65536.0 * dLambda );219 #endif220 117 } 221 118 … … 268 165 m_costMode = COST_STANDARD_LOSSY; 269 166 270 #if RExt__HIGH_BIT_DEPTH_SUPPORT271 167 m_dCost = 0; 272 #else273 m_uiCost = 0;274 #endif275 168 m_iCostScale = 0; 276 169 } -
branches/SHM-dev/source/Lib/TLibCommon/TComRdCost.h
r1341 r1389 112 112 Double m_dLambda; 113 113 Double m_sqrtLambda; 114 #if RExt__HIGH_BIT_DEPTH_SUPPORT115 114 Double m_dLambdaMotionSAD[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/]; 116 115 Double m_dLambdaMotionSSE[2 /* 0=standard, 1=for transquant bypass when mixed-lossless cost evaluation enabled*/]; 117 #else118 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 #endif121 116 Double m_dFrameLambda; 122 117 123 118 // for motion cost 124 119 TComMv m_mvPredictor; 125 #if RExt__HIGH_BIT_DEPTH_SUPPORT126 120 Double m_dCost; 127 #else128 UInt m_uiCost;129 #endif130 121 Int m_iCostScale; 131 122 … … 134 125 virtual ~TComRdCost(); 135 126 136 Double calcRdCost ( UInt uiBits, Distortion uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT ); 137 Double calcRdCost64( UInt64 uiBits, UInt64 uiDistortion, Bool bFlag = false, DFunc eDFunc = DF_DEFAULT ); 127 Double calcRdCost( Double numBits, Double distortion, DFunc eDFunc = DF_DEFAULT ); 138 128 139 129 Void setDistortionWeight ( const ComponentID compID, const Double distortionWeight ) { m_distortionWeight[compID] = distortionWeight; } … … 160 150 // for motion cost 161 151 static UInt xGetExpGolombNumberOfBits( Int iVal ); 162 #if RExt__HIGH_BIT_DEPTH_SUPPORT163 152 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 #else165 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 #endif167 153 Void setPredictor( TComMv& rcMv ) 168 154 { … … 172 158 __inline Distortion getCost( Int x, Int y ) 173 159 { 174 #if RExt__HIGH_BIT_DEPTH_SUPPORT175 160 return Distortion((m_dCost * getBits(x, y)) / 65536.0); 176 #else 177 return m_uiCost * getBits(x, y) >> 16; 178 #endif 179 } 180 #if RExt__HIGH_BIT_DEPTH_SUPPORT 161 } 181 162 Distortion getCost( UInt b ) { return Distortion(( m_dCost * b ) / 65536.0); } 182 #else183 Distortion getCost( UInt b ) { return ( m_uiCost * b ) >> 16; }184 #endif185 163 UInt getBits( Int x, Int y ) 186 164 { -
branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp
r1387 r1389 2824 2824 Void TEncSearch::IPCMSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv* pcPredYuv, TComYuv* pcResiYuv, TComYuv* pcRecoYuv ) 2825 2825 { 2826 UInt uiDepth = pcCU->getDepth(0);2827 const UIntuiDistortion = 0;2828 UInt uiBits;2826 UInt uiDepth = pcCU->getDepth(0); 2827 const Distortion uiDistortion = 0; 2828 UInt uiBits; 2829 2829 2830 2830 Double dCost; … … 3857 3857 uiCost = m_pcRdCost->getDistPart( pcCU->getSlice()->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA), pcTemplateCand->getAddr(COMPONENT_Y, uiPartAddr), pcTemplateCand->getStride(COMPONENT_Y), pcOrgYuv->getAddr(COMPONENT_Y, uiPartAddr), pcOrgYuv->getStride(COMPONENT_Y), iSizeX, iSizeY, COMPONENT_Y, DF_SAD ); 3858 3858 #endif 3859 uiCost = (UInt) m_pcRdCost->calcRdCost( m_auiMVPIdxCost[iMVPIdx][iMVPNum], uiCost, false,DF_SAD );3859 uiCost = (UInt) m_pcRdCost->calcRdCost( m_auiMVPIdxCost[iMVPIdx][iMVPNum], uiCost, DF_SAD ); 3860 3860 return uiCost; 3861 3861 } -
branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.cpp
r1369 r1389 688 688 689 689 // compute RD cost and choose the best 690 Double dPicRdCost = m_pcRdCost->calcRdCost 64( m_uiPicTotalBits, uiPicDist, true, DF_SSE_FRAME); // NOTE: Is the 'true' parameter really necessary?690 Double dPicRdCost = m_pcRdCost->calcRdCost( (Double)m_uiPicTotalBits, (Double)uiPicDist, DF_SSE_FRAME); 691 691 692 692 if ( dPicRdCost < dPicRdCostBest ) … … 1376 1376 #if SVC_EXTENSION 1377 1377 #if JCTVC_M0259_LAMBDAREFINEMENT 1378 Double TEncSlice::xCalEnhLambdaFactor( Double deltaQP 1379 { 1380 double tmp = beta * pow( 2.0 , deltaQP / 6 );1381 double gamma = tmp / ( tmp + 1 );1382 return ( gamma );1378 Double TEncSlice::xCalEnhLambdaFactor( Double deltaQP, Double beta ) 1379 { 1380 Double tmp = beta * pow( 2.0 , deltaQP / 6 ); 1381 Double gamma = tmp / ( tmp + 1 ); 1382 return gamma; 1383 1383 } 1384 1384 #endif -
branches/SHM-dev/source/Lib/TLibEncoder/TEncSlice.h
r1369 r1389 147 147 148 148 #if SVC_EXTENSION && JCTVC_M0259_LAMBDAREFINEMENT 149 Double xCalEnhLambdaFactor( Double deltaQP 149 Double xCalEnhLambdaFactor( Double deltaQP, Double beta ); 150 150 #endif 151 151 };
Note: See TracChangeset for help on using the changeset viewer.