Changeset 916 in SHVCSoftware for branches/SHM-upgrade/source/Lib/TLibCommon/TComTrQuant.h
- Timestamp:
- 12 Nov 2014, 08:09:17 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-upgrade/source/Lib/TLibCommon/TComTrQuant.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 … … 42 42 #include "TComYuv.h" 43 43 #include "TComDataCU.h" 44 #include "TComChromaFormat.h" 44 45 #include "ContextTables.h" 45 46 … … 59 60 typedef struct 60 61 { 61 Int significantCoeffGroupBits[NUM_SIG_CG_FLAG_CTX][2]; 62 Int significantBits[NUM_SIG_FLAG_CTX][2]; 63 Int lastXBits[32]; 64 Int lastYBits[32]; 65 Int m_greaterOneBits[NUM_ONE_FLAG_CTX][2]; 66 Int m_levelAbsBits[NUM_ABS_FLAG_CTX][2]; 67 68 Int blockCbpBits[3*NUM_QT_CBF_CTX][2]; 69 Int blockRootCbpBits[4][2]; 62 Int significantCoeffGroupBits[NUM_SIG_CG_FLAG_CTX][2 /*Flag = [0|1]*/]; 63 Int significantBits[NUM_SIG_FLAG_CTX][2 /*Flag = [0|1]*/]; 64 Int lastXBits[MAX_NUM_CHANNEL_TYPE][LAST_SIGNIFICANT_GROUPS]; 65 Int lastYBits[MAX_NUM_CHANNEL_TYPE][LAST_SIGNIFICANT_GROUPS]; 66 Int m_greaterOneBits[NUM_ONE_FLAG_CTX][2 /*Flag = [0|1]*/]; 67 Int m_levelAbsBits[NUM_ABS_FLAG_CTX][2 /*Flag = [0|1]*/]; 68 69 Int blockCbpBits[NUM_QT_CBF_CTX_SETS * NUM_QT_CBF_CTX_PER_SET][2 /*Flag = [0|1]*/]; 70 Int blockRootCbpBits[4][2 /*Flag = [0|1]*/]; 71 72 Int golombRiceAdaptationStatistics[RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS]; 70 73 } estBitsSbacStruct; 71 74 … … 74 77 // ==================================================================================================================== 75 78 76 /// QP class77 classQpParam79 /// QP struct 80 struct QpParam 78 81 { 79 public: 80 QpParam(); 81 82 Int m_iQP; 83 Int m_iPer; 84 Int m_iRem; 85 86 public: 87 Int m_iBits; 88 89 Void setQpParam( Int qpScaled ) 90 { 91 m_iQP = qpScaled; 92 m_iPer = qpScaled / 6; 93 m_iRem = qpScaled % 6; 94 m_iBits = QP_BITS + m_iPer; 95 } 96 97 Void clear() 98 { 99 m_iQP = 0; 100 m_iPer = 0; 101 m_iRem = 0; 102 m_iBits = 0; 103 } 104 105 106 Int per() const { return m_iPer; } 107 Int rem() const { return m_iRem; } 108 Int bits() const { return m_iBits; } 109 110 Int qp() {return m_iQP;} 111 }; // END CLASS DEFINITION QpParam 82 Int Qp; 83 Int per; 84 Int rem; 85 86 QpParam(const Int qpy, 87 const ChannelType chType, 88 const Int qpBdOffset, 89 const Int chromaQPOffset, 90 const ChromaFormat chFmt ); 91 92 QpParam(const TComDataCU &cu, const ComponentID compID); 93 94 }; // END STRUCT DEFINITION QpParam 95 112 96 113 97 /// transform and quantization class … … 117 101 TComTrQuant(); 118 102 ~TComTrQuant(); 119 103 120 104 // initialize class 121 Void init ( UInt uiMaxTrSize, Bool useRDOQ = false, 122 Bool useRDOQTS = false, 123 Bool bEnc = false, Bool useTransformSkipFast = false 124 #if ADAPTIVE_QP_SELECTION 125 , Bool bUseAdaptQpSelect = false 126 #endif 127 ); 128 105 Void init ( UInt uiMaxTrSize, 106 Bool useRDOQ = false, 107 Bool useRDOQTS = false, 108 Bool bEnc = false, 109 Bool useTransformSkipFast = false 110 #if ADAPTIVE_QP_SELECTION 111 , Bool bUseAdaptQpSelect = false 112 #endif 113 ); 114 129 115 // transform & inverse transform functions 130 Void transformNxN( TComDataCU* pcCU, 131 Pel* pcResidual, 132 UInt uiStride, 133 TCoeff* rpcCoeff, 134 #if ADAPTIVE_QP_SELECTION 135 Int*& rpcArlCoeff, 136 #endif 137 UInt uiWidth, 138 UInt uiHeight, 139 UInt& uiAbsSum, 140 TextType eTType, 141 UInt uiAbsPartIdx, 142 Bool useTransformSkip = false ); 143 144 Void invtransformNxN( Bool transQuantBypass, TextType eText, UInt uiMode,Pel* rpcResidual, UInt uiStride, TCoeff* pcCoeff, UInt uiWidth, UInt uiHeight, Int scalingListType, Bool useTransformSkip = false ); 145 Void invRecurTransformNxN ( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eTxt, Pel* rpcResidual, UInt uiAddr, UInt uiStride, UInt uiWidth, UInt uiHeight, 146 UInt uiMaxTrMode, UInt uiTrMode, TCoeff* rpcCoeff ); 147 116 Void transformNxN( TComTU & rTu, 117 const ComponentID compID, 118 Pel * pcResidual, 119 const UInt uiStride, 120 TCoeff * rpcCoeff, 121 #if ADAPTIVE_QP_SELECTION 122 TCoeff * rpcArlCoeff, 123 #endif 124 TCoeff & uiAbsSum, 125 const QpParam & cQP 126 ); 127 128 129 Void invTransformNxN( TComTU & rTu, 130 const ComponentID compID, 131 Pel *pcResidual, 132 const UInt uiStride, 133 TCoeff * pcCoeff, 134 const QpParam & cQP 135 DEBUG_STRING_FN_DECLAREP(psDebug)); 136 137 Void invRecurTransformNxN ( const ComponentID compID, TComYuv *pResidual, TComTU &rTu ); 138 139 Void rdpcmNxN ( TComTU& rTu, const ComponentID compID, Pel* pcResidual, const UInt uiStride, const QpParam& cQP, TCoeff* pcCoeff, TCoeff &uiAbsSum, RDPCMMode& rdpcmMode ); 140 Void invRdpcmNxN( TComTU& rTu, const ComponentID compID, Pel* pcResidual, const UInt uiStride ); 141 142 Void applyForwardRDPCM( TComTU& rTu, const ComponentID compID, Pel* pcResidual, const UInt uiStride, const QpParam& cQP, TCoeff* pcCoeff, TCoeff &uiAbsSum, const RDPCMMode mode ); 143 148 144 // Misc functions 149 Void setQPforQuant( Int qpy, TextType eTxtType, Int qpBdOffset, Int chromaQPOffset); 150 151 #if RDOQ_CHROMA_LAMBDA 152 Void setLambdas ( const Double lambdas[3] ) { for (Int component = 0; component < 3; component++) m_lambdas[component] = lambdas[component]; } 153 Void selectLambda(TextType eTType) { m_dLambda = (eTType == TEXT_LUMA) ? m_lambdas[0] : ((eTType == TEXT_CHROMA_U) ? m_lambdas[1] : m_lambdas[2]); } 145 146 #if RDOQ_CHROMA_LAMBDA 147 Void setLambdas(const Double lambdas[MAX_NUM_COMPONENT]) { for (UInt component = 0; component < MAX_NUM_COMPONENT; component++) m_lambdas[component] = lambdas[component]; } 148 Void selectLambda(const ComponentID compIdx) { m_dLambda = m_lambdas[compIdx]; } 154 149 #else 155 150 Void setLambda(Double dLambda) { m_dLambda = dLambda;} 156 151 #endif 157 152 Void setRDOQOffset( UInt uiRDOQOffset ) { m_uiRDOQOffset = uiRDOQOffset; } 158 153 159 154 estBitsSbacStruct* m_pcEstBitsSbac; 160 161 static Int calcPatternSigCtx( const UInt* sigCoeffGroupFlag, UInt posXCG, UInt posYCG, Int width, Int height ); 162 163 static Int getSigCtxInc ( 164 Int patternSigCtx, 165 UInt scanIdx, 166 Int posX, 167 Int posY, 168 Int log2BlkSize, 169 TextType textureType 155 156 static Int calcPatternSigCtx( const UInt* sigCoeffGroupFlag, UInt uiCGPosX, UInt uiCGPosY, UInt widthInGroups, UInt heightInGroups ); 157 158 static Int getSigCtxInc ( Int patternSigCtx, 159 const TUEntropyCodingParameters &codingParameters, 160 const Int scanPosition, 161 const Int log2BlockWidth, 162 const Int log2BlockHeight, 163 const ChannelType chanType 170 164 ); 171 static UInt getSigCoeffGroupCtxInc ( const UInt* uiSigCoeffGroupFlag, 172 const UInt uiCGPosX, 173 const UInt uiCGPosY, 174 Int width, Int height); 165 166 static UInt getSigCoeffGroupCtxInc (const UInt* uiSigCoeffGroupFlag, 167 const UInt uiCGPosX, 168 const UInt uiCGPosY, 169 const UInt widthInGroups, 170 const UInt heightInGroups); 171 175 172 Void initScalingList (); 176 173 Void destroyScalingList (); 177 Void setErrScaleCoeff ( UInt list, UInt size, UInt qp); 178 Double* getErrScaleCoeff ( UInt list, UInt size, UInt qp) {return m_errScale[size][list][qp];}; //!< get Error Scale Coefficent 179 Int* getQuantCoeff ( UInt list, UInt qp, UInt size) {return m_quantCoef[size][list][qp];}; //!< get Quant Coefficent 180 Int* getDequantCoeff ( UInt list, UInt qp, UInt size) {return m_dequantCoef[size][list][qp];}; //!< get DeQuant Coefficent 174 Void setErrScaleCoeff ( UInt list, UInt size, Int qp ); 175 Double* getErrScaleCoeff ( UInt list, UInt size, Int qp ) { return m_errScale [size][list][qp]; }; //!< get Error Scale Coefficent 176 Double& getErrScaleCoeffNoScalingList ( UInt list, UInt size, Int qp ) { return m_errScaleNoScalingList[size][list][qp]; }; //!< get Error Scale Coefficent 177 Int* getQuantCoeff ( UInt list, Int qp, UInt size ) { return m_quantCoef [size][list][qp]; }; //!< get Quant Coefficent 178 Int* getDequantCoeff ( UInt list, Int qp, UInt size ) { return m_dequantCoef [size][list][qp]; }; //!< get DeQuant Coefficent 181 179 Void setUseScalingList ( Bool bUseScalingList){ m_scalingListEnabledFlag = bUseScalingList; }; 182 Bool getUseScalingList ( ){ return m_scalingListEnabledFlag; };183 Void setFlatScalingList ( );184 Void xsetFlatScalingList ( UInt list, UInt size, UInt qp);185 Void xSetScalingListEnc ( TComScalingList *scalingList, UInt list, UInt size, UInt qp);186 Void xSetScalingListDec ( TComScalingList *scalingList, UInt list, UInt size, UInt qp);187 Void setScalingList ( TComScalingList *scalingList );188 Void setScalingListDec ( TComScalingList *scalingList );180 Bool getUseScalingList (const UInt width, const UInt height, const Bool isTransformSkip){ return m_scalingListEnabledFlag && (!isTransformSkip || ((width == 4) && (height == 4))); }; 181 Void setFlatScalingList (const ChromaFormat format); 182 Void xsetFlatScalingList ( UInt list, UInt size, Int qp, const ChromaFormat format); 183 Void xSetScalingListEnc ( TComScalingList *scalingList, UInt list, UInt size, Int qp, const ChromaFormat format); 184 Void xSetScalingListDec ( TComScalingList *scalingList, UInt list, UInt size, Int qp, const ChromaFormat format); 185 Void setScalingList ( TComScalingList *scalingList, const ChromaFormat format); 186 Void setScalingListDec ( TComScalingList *scalingList, const ChromaFormat format); 189 187 Void processScalingListEnc( Int *coeff, Int *quantcoeff, Int quantScales, UInt height, UInt width, UInt ratio, Int sizuNum, UInt dc); 190 188 Void processScalingListDec( Int *coeff, Int *dequantcoeff, Int invQuantScales, UInt height, UInt width, UInt ratio, Int sizuNum, UInt dc); … … 193 191 Void storeSliceQpNext(TComSlice* pcSlice); 194 192 Void clearSliceARLCnt(); 195 Int getQpDelta(Int qp) { return m_qpDelta[qp]; } 196 Int* getSliceNSamples(){ return m_sliceNsamples ;} 193 Int getQpDelta(Int qp) { return m_qpDelta[qp]; } 194 Int* getSliceNSamples(){ return m_sliceNsamples ;} 197 195 Double* getSliceSumC() { return m_sliceSumC; } 198 196 #endif 197 Void transformSkipQuantOneSample(TComTU &rTu, const ComponentID compID, const Pel resiDiff, TCoeff* pcCoeff, const UInt uiPos, const QpParam &cQP, const Bool bUseHalfRoundingPoint); 198 Void invTrSkipDeQuantOneSample(TComTU &rTu, ComponentID compID, TCoeff pcCoeff, Pel &reconSample, const QpParam &cQP, UInt uiPos ); 199 199 200 protected: 200 201 #if ADAPTIVE_QP_SELECTION 201 Int m_qpDelta[MAX_QP+1]; 202 Int m_sliceNsamples[LEVEL_RANGE+1]; 203 Double m_sliceSumC[LEVEL_RANGE+1] ; 204 #endif 205 Int*m_plTempCoeff;206 207 QpParam m_cQP; 202 Int m_qpDelta[MAX_QP+1]; 203 Int m_sliceNsamples[LEVEL_RANGE+1]; 204 Double m_sliceSumC[LEVEL_RANGE+1] ; 205 #endif 206 TCoeff* m_plTempCoeff; 207 208 // QpParam m_cQP; - removed - placed on the stack. 208 209 #if RDOQ_CHROMA_LAMBDA 209 Double m_lambdas[ 3];210 Double m_lambdas[MAX_NUM_COMPONENT]; 210 211 #endif 211 212 Double m_dLambda; … … 219 220 #endif 220 221 Bool m_useTransformSkipFast; 222 221 223 Bool m_scalingListEnabledFlag; 222 Int *m_quantCoef [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM][SCALING_LIST_REM_NUM]; ///< array of quantization matrix coefficient 4x4 223 Int *m_dequantCoef [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM][SCALING_LIST_REM_NUM]; ///< array of dequantization matrix coefficient 4x4 224 Double *m_errScale [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM][SCALING_LIST_REM_NUM]; ///< array of quantization matrix coefficient 4x4 224 225 Int *m_quantCoef [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM][SCALING_LIST_REM_NUM]; ///< array of quantization matrix coefficient 4x4 226 Int *m_dequantCoef [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM][SCALING_LIST_REM_NUM]; ///< array of dequantization matrix coefficient 4x4 227 Double *m_errScale [SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM][SCALING_LIST_REM_NUM]; ///< array of quantization matrix coefficient 4x4 228 Double m_errScaleNoScalingList[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM][SCALING_LIST_REM_NUM]; ///< array of quantization matrix coefficient 4x4 229 225 230 private: 226 231 // forward Transform 227 Void xT ( Int bitDepth, UInt uiMode,Pel* pResidual, UInt uiStride, Int* plCoeff, Int iWidth, Int iHeight );228 232 Void xT ( const ComponentID compID, Bool useDST, Pel* piBlkResi, UInt uiStride, TCoeff* psCoeff, Int iWidth, Int iHeight ); 233 229 234 // skipping Transform 230 Void xTransformSkip ( Int bitDepth, Pel* piBlkResi, UInt uiStride, Int* psCoeff, Int width, Int height );231 232 Void signBitHidingHDQ( TCoeff* pQCoef, TCoeff* pCoef, UInt const *scan, Int* deltaU, Int width, Int height);235 Void xTransformSkip ( Pel* piBlkResi, UInt uiStride, TCoeff* psCoeff, TComTU &rTu, const ComponentID component ); 236 237 Void signBitHidingHDQ( const ComponentID compID, TCoeff* pQCoef, TCoeff* pCoef, TCoeff* deltaU, const TUEntropyCodingParameters &codingParameters ); 233 238 234 239 // quantization 235 Void xQuant( TComDataCU* pcCU, 236 Int* pSrc, 237 TCoeff* pDes, 238 #if ADAPTIVE_QP_SELECTION 239 Int*& pArlDes, 240 #endif 241 Int iWidth, 242 Int iHeight, 243 UInt& uiAcSum, 244 TextType eTType, 245 UInt uiAbsPartIdx ); 240 Void xQuant( TComTU &rTu, 241 TCoeff * pSrc, 242 TCoeff * pDes, 243 #if ADAPTIVE_QP_SELECTION 244 TCoeff *pArlDes, 245 #endif 246 TCoeff &uiAbsSum, 247 const ComponentID compID, 248 const QpParam &cQP ); 246 249 247 250 // RDOQ functions 248 249 Void xRateDistOptQuant ( TComDataCU* pcCU, 250 Int* plSrcCoeff, 251 TCoeff* piDstCoeff, 252 #if ADAPTIVE_QP_SELECTION 253 Int*& piArlDstCoeff, 254 #endif 255 UInt uiWidth, 256 UInt uiHeight, 257 UInt& uiAbsSum, 258 TextType eTType, 259 UInt uiAbsPartIdx ); 260 __inline UInt xGetCodedLevel ( Double& rd64CodedCost, 261 Double& rd64CodedCost0, 262 Double& rd64CodedCostSig, 263 Int lLevelDouble, 264 UInt uiMaxAbsLevel, 265 UShort ui16CtxNumSig, 266 UShort ui16CtxNumOne, 267 UShort ui16CtxNumAbs, 268 UShort ui16AbsGoRice, 269 UInt c1Idx, 270 UInt c2Idx, 271 Int iQBits, 272 Double dTemp, 273 Bool bLast ) const; 274 __inline Int xGetICRate ( UInt uiAbsLevel, 275 UShort ui16CtxNumOne, 276 UShort ui16CtxNumAbs, 277 UShort ui16AbsGoRice 278 , UInt c1Idx, 279 UInt c2Idx 280 ) const; 281 __inline Double xGetRateLast ( const UInt uiPosX, 282 const UInt uiPosY ) const; 283 __inline Double xGetRateSigCoeffGroup ( UShort uiSignificanceCoeffGroup, 284 UShort ui16CtxNumSig ) const; 285 __inline Double xGetRateSigCoef ( UShort uiSignificance, 286 UShort ui16CtxNumSig ) const; 287 __inline Double xGetICost ( Double dRate ) const; 288 __inline Double xGetIEPRate ( ) const; 289 290 251 252 Void xRateDistOptQuant ( TComTU &rTu, 253 TCoeff * plSrcCoeff, 254 TCoeff * piDstCoeff, 255 #if ADAPTIVE_QP_SELECTION 256 TCoeff *piArlDstCoeff, 257 #endif 258 TCoeff &uiAbsSum, 259 const ComponentID compID, 260 const QpParam &cQP ); 261 262 __inline UInt xGetCodedLevel ( Double& rd64CodedCost, 263 Double& rd64CodedCost0, 264 Double& rd64CodedCostSig, 265 Intermediate_Int lLevelDouble, 266 UInt uiMaxAbsLevel, 267 UShort ui16CtxNumSig, 268 UShort ui16CtxNumOne, 269 UShort ui16CtxNumAbs, 270 UShort ui16AbsGoRice, 271 UInt c1Idx, 272 UInt c2Idx, 273 Int iQBits, 274 Double errorScale, 275 Bool bLast, 276 Bool useLimitedPrefixLength, 277 ChannelType channelType 278 ) const; 279 280 281 __inline Int xGetICRate ( UInt uiAbsLevel, 282 UShort ui16CtxNumOne, 283 UShort ui16CtxNumAbs, 284 UShort ui16AbsGoRice, 285 UInt c1Idx, 286 UInt c2Idx, 287 Bool useLimitedPrefixLength, 288 ChannelType channelType 289 ) const; 290 291 __inline Double xGetRateLast ( const UInt uiPosX, const UInt uiPosY, const ComponentID component ) const; 292 __inline Double xGetRateSigCoeffGroup( UShort uiSignificanceCoeffGroup, UShort ui16CtxNumSig ) const; 293 __inline Double xGetRateSigCoef ( UShort uiSignificance, UShort ui16CtxNumSig ) const; 294 __inline Double xGetICost ( Double dRate ) const; 295 __inline Double xGetIEPRate ( ) const; 296 297 291 298 // dequantization 292 Void xDeQuant(Int bitDepth, const TCoeff* pSrc, Int* pDes, Int iWidth, Int iHeight, Int scalingListType ); 293 299 Void xDeQuant( TComTU &rTu, 300 const TCoeff * pSrc, 301 TCoeff * pDes, 302 const ComponentID compID, 303 const QpParam &cQP ); 304 294 305 // inverse transform 295 Void xIT ( Int bitDepth, UInt uiMode, Int* plCoef, Pel* pResidual, UInt uiStride, Int iWidth, Int iHeight );296 306 Void xIT ( const ComponentID compID, Bool useDST, TCoeff* plCoef, Pel* pResidual, UInt uiStride, Int iWidth, Int iHeight ); 307 297 308 // inverse skipping transform 298 Void xITransformSkip (Int bitDepth, Int* plCoef, Pel* pResidual, UInt uiStride, Int width, Int height ); 309 Void xITransformSkip ( TCoeff* plCoef, Pel* pResidual, UInt uiStride, TComTU &rTu, const ComponentID component ); 310 311 public: 312 static Void crossComponentPrediction( TComTU &rTu, 313 const ComponentID compID, 314 const Pel *piResiL, 315 const Pel *piResiC, 316 Pel *piResiT, 317 const Int width, 318 const Int height, 319 const Int strideL, 320 const Int strideC, 321 const Int strideT, 322 const Bool reverse); 323 299 324 };// END CLASS DEFINITION TComTrQuant 300 325
Note: See TracChangeset for help on using the changeset viewer.