Changeset 837 in 3DVCSoftware for branches/HTM-10.0rc1-dev0/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h
- Timestamp:
- 8 Feb 2014, 00:23:11 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HTM-10.0rc1-dev0/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.h
r608 r837 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 3, ITU/ISO/IEC6 * Copyright (c) 2010-2014, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 54 54 // ==================================================================================================================== 55 55 56 enum SAOCabacStateLablesRDO //CABAC state labels 57 { 58 SAO_CABACSTATE_PIC_INIT =0, 59 SAO_CABACSTATE_BLK_CUR, 60 SAO_CABACSTATE_BLK_NEXT, 61 SAO_CABACSTATE_BLK_MID, 62 SAO_CABACSTATE_BLK_TEMP, 63 NUM_SAO_CABACSTATE_LABELS 64 }; 65 66 struct SAOStatData //data structure for SAO statistics 67 { 68 Int64 diff[MAX_NUM_SAO_CLASSES]; 69 Int64 count[MAX_NUM_SAO_CLASSES]; 70 71 SAOStatData(){} 72 ~SAOStatData(){} 73 Void reset() 74 { 75 ::memset(diff, 0, sizeof(Int64)*MAX_NUM_SAO_CLASSES); 76 ::memset(count, 0, sizeof(Int64)*MAX_NUM_SAO_CLASSES); 77 } 78 const SAOStatData& operator=(const SAOStatData& src) 79 { 80 ::memcpy(diff, src.diff, sizeof(Int64)*MAX_NUM_SAO_CLASSES); 81 ::memcpy(count, src.count, sizeof(Int64)*MAX_NUM_SAO_CLASSES); 82 return *this; 83 } 84 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 85 const SAOStatData& operator+= (const SAOStatData& src) 86 { 87 for(Int i=0; i< MAX_NUM_SAO_CLASSES; i++) 88 { 89 diff[i] += src.diff[i]; 90 count[i] += src.count[i]; 91 } 92 return *this; 93 } 94 #endif 95 }; 96 56 97 class TEncSampleAdaptiveOffset : public TComSampleAdaptiveOffset 57 98 { 58 private:59 TEncEntropy* m_pcEntropyCoder;60 TEncSbac*** m_pppcRDSbacCoder; ///< for CABAC61 TEncSbac* m_pcRDGoOnSbacCoder;62 #if FAST_BIT_EST63 TEncBinCABACCounter*** m_pppcBinCoderCABAC; ///< temporal CABAC state storage for RD computation64 #else65 TEncBinCABAC*** m_pppcBinCoderCABAC; ///< temporal CABAC state storage for RD computation66 #endif67 68 Int64 ***m_iCount; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];69 Int64 ***m_iOffset; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];70 Int64 ***m_iOffsetOrg; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];71 Int64 ****m_count_PreDblk; //[LCU][YCbCr][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];72 Int64 ****m_offsetOrg_PreDblk; //[LCU][YCbCr][MAX_NUM_SAO_TYPE][MAX_NUM_SAO_CLASS];73 Int64 **m_iRate; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];74 Int64 **m_iDist; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];75 Double **m_dCost; //[MAX_NUM_SAO_PART][MAX_NUM_SAO_TYPE];76 Double *m_dCostPartBest; //[MAX_NUM_SAO_PART];77 Int64 *m_iDistOrg; //[MAX_NUM_SAO_PART];78 Int *m_iTypePartBest; //[MAX_NUM_SAO_PART];79 Int m_iOffsetThY;80 Int m_iOffsetThC;81 Bool m_bUseSBACRD;82 #if SAO_ENCODING_CHOICE83 #if SAO_ENCODING_CHOICE_CHROMA84 Double m_depthSaoRate[2][4];85 #else86 Double m_depth0SaoRate;87 #endif88 #endif89 90 99 public: 91 TEncSampleAdaptiveOffset 100 TEncSampleAdaptiveOffset(); 92 101 virtual ~TEncSampleAdaptiveOffset(); 93 102 94 Void startSaoEnc( TComPic* pcPic, TEncEntropy* pcEntropyCoder, TEncSbac*** pppcRDSbacCoder, TEncSbac* pcRDGoOnSbacCoder); 95 Void endSaoEnc(); 96 Void resetStats(); 97 #if SAO_CHROMA_LAMBDA 103 //interface 104 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 105 Void createEncData(Bool isPreDBFSamplesUsed); 106 #else 107 Void createEncData(); 108 #endif 109 Void destroyEncData(); 110 Void initRDOCabacCoder(TEncSbac* pcRDGoOnSbacCoder, TComSlice* pcSlice) ; 111 Void SAOProcess(TComPic* pPic, Bool* sliceEnabled, const Double *lambdas 112 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 113 , Bool isPreDBFSamplesUsed 114 #endif 115 ); 116 public: //methods 117 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 118 Void getPreDBFStatistics(TComPic* pPic); 119 #endif 120 private: //methods 121 Void getStatistics(SAOStatData*** blkStats, TComPicYuv* orgYuv, TComPicYuv* srcYuv,TComPic* pPic 122 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 123 , Bool isCalculatePreDeblockSamples = false 124 #endif 125 ); 126 Void decidePicParams(Bool* sliceEnabled, Int picTempLayer); 127 Void decideBlkParams(TComPic* pic, Bool* sliceEnabled, SAOStatData*** blkStats, TComPicYuv* srcYuv, TComPicYuv* resYuv, SAOBlkParam* reconParams, SAOBlkParam* codedParams); 128 Void getBlkStats(Int compIdx, SAOStatData* statsDataTypes, Pel* srcBlk, Pel* orgBlk, Int srcStride, Int orgStride, Int width, Int height, Bool isLeftAvail, Bool isRightAvail, Bool isAboveAvail, Bool isBelowAvail, Bool isAboveLeftAvail, Bool isAboveRightAvail, Bool isBelowLeftAvail, Bool isBelowRightAvail 129 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 130 , Bool isCalculatePreDeblockSamples 131 #endif 132 ); 133 Void deriveModeNewRDO(Int ctu, std::vector<SAOBlkParam*>& mergeList, Bool* sliceEnabled, SAOStatData*** blkStats, SAOBlkParam& modeParam, Double& modeNormCost, TEncSbac** cabacCoderRDO, Int inCabacLabel); 134 Void deriveModeMergeRDO(Int ctu, std::vector<SAOBlkParam*>& mergeList, Bool* sliceEnabled, SAOStatData*** blkStats, SAOBlkParam& modeParam, Double& modeNormCost, TEncSbac** cabacCoderRDO, Int inCabacLabel); 135 Int64 getDistortion(Int ctu, Int compIdx, Int typeIdc, Int typeAuxInfo, Int* offsetVal, SAOStatData& statData); 136 Void deriveOffsets(Int ctu, Int compIdx, Int typeIdc, SAOStatData& statData, Int* quantOffsets, Int& typeAuxInfo); 137 inline Int64 estSaoDist(Int64 count, Int64 offset, Int64 diffSum, Int shift); 138 inline Int estIterOffset(Int typeIdx, Int classIdx, Double lambda, Int offsetInput, Int64 count, Int64 diffSum, Int shift, Int bitIncrease, Int64& bestDist, Double& bestCost, Int offsetTh ); 139 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 140 Void addPreDBFStatistics(SAOStatData*** blkStats); 141 #endif 142 private: //members 143 //for RDO 144 TEncSbac** m_pppcRDSbacCoder; 145 TEncSbac* m_pcRDGoOnSbacCoder; 146 TEncBinCABACCounter** m_pppcBinCoderCABAC; 147 Double m_lambda[NUM_SAO_COMPONENTS]; 148 149 //statistics 150 SAOStatData*** m_statData; //[ctu][comp][classes] 151 #if SAO_ENCODE_ALLOW_USE_PREDEBLOCK 152 SAOStatData*** m_preDBFstatData; 153 #endif 98 154 #if SAO_ENCODING_CHOICE 99 Void SAOProcess(SAOParam *pcSaoParam, Double dLambda, Double dLambdaChroma, Int depth); 100 #else 101 Void SAOProcess(SAOParam *pcSaoParam, Double dLambda, Double dLambdaChroma); 155 Double m_saoDisabledRate[NUM_SAO_COMPONENTS][MAX_TLAYER]; 102 156 #endif 103 #else 104 Void SAOProcess(SAOParam *pcSaoParam, Double dLambda); 105 #endif 106 107 Void runQuadTreeDecision(SAOQTPart *psQTPart, Int iPartIdx, Double &dCostFinal, Int iMaxLevel, Double dLambda, Int yCbCr); 108 Void rdoSaoOnePart(SAOQTPart *psQTPart, Int iPartIdx, Double dLambda, Int yCbCr); 109 110 Void disablePartTree(SAOQTPart *psQTPart, Int iPartIdx); 111 Void getSaoStats(SAOQTPart *psQTPart, Int iYCbCr); 112 Void calcSaoStatsCu(Int iAddr, Int iPartIdx, Int iYCbCr); 113 Void calcSaoStatsBlock( Pel* pRecStart, Pel* pOrgStart, Int stride, Int64** ppStats, Int64** ppCount, UInt width, UInt height, Bool* pbBorderAvail, Int iYCbCr); 114 Void calcSaoStatsCuOrg(Int iAddr, Int iPartIdx, Int iYCbCr); 115 Void calcSaoStatsCu_BeforeDblk( TComPic* pcPic ); 116 Void destroyEncBuffer(); 117 Void createEncBuffer(); 118 Void assignSaoUnitSyntax(SaoLcuParam* saoLcuParam, SAOQTPart* saoPart, Bool &oneUnitFlag, Int yCbCr); 119 Void checkMerge(SaoLcuParam * lcuParamCurr,SaoLcuParam * lcuParamCheck, Int dir); 120 #if SAO_ENCODING_CHOICE 121 Void rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma, Int depth); 122 #else 123 Void rdoSaoUnitAll(SAOParam *saoParam, Double lambda, Double lambdaChroma); 124 #endif 125 Void saoComponentParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Int yCbCr, Double lambda, SaoLcuParam *compSaoParam, Double *distortion); 126 Void sao2ChromaParamDist(Int allowMergeLeft, Int allowMergeUp, SAOParam *saoParam, Int addr, Int addrUp, Int addrLeft, Double lambda, SaoLcuParam *crSaoParam, SaoLcuParam *cbSaoParam, Double *distortion); 127 inline Int64 estSaoDist(Int64 count, Int64 offset, Int64 offsetOrg, Int shift); 128 inline Int64 estIterOffset(Int typeIdx, Int classIdx, Double lambda, Int64 offsetInput, Int64 count, Int64 offsetOrg, Int shift, Int bitIncrease, Int *currentDistortionTableBo, Double *currentRdCostTableBo, Int offsetTh ); 129 inline Int64 estSaoTypeDist(Int compIdx, Int typeIdx, Int shift, Double lambda, Int *currentDistortionTableBo, Double *currentRdCostTableBo); 130 Void setMaxNumOffsetsPerPic(Int iVal) {m_maxNumOffsetsPerPic = iVal; } 131 Int getMaxNumOffsetsPerPic() {return m_maxNumOffsetsPerPic; } 157 Int m_skipLinesR[NUM_SAO_COMPONENTS][NUM_SAO_NEW_TYPES]; 158 Int m_skipLinesB[NUM_SAO_COMPONENTS][NUM_SAO_NEW_TYPES]; 132 159 }; 133 134 160 //! \} 135 161
Note: See TracChangeset for help on using the changeset viewer.