| 1 | /* The copyright in this software is being made available under the BSD |
|---|
| 2 | * License, included below. This software may be subject to other third party |
|---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
|---|
| 4 | * granted under this license. |
|---|
| 5 | * |
|---|
| 6 | * Copyright (c) 2010-2011, ISO/IEC |
|---|
| 7 | * All rights reserved. |
|---|
| 8 | * |
|---|
| 9 | * Redistribution and use in source and binary forms, with or without |
|---|
| 10 | * modification, are permitted provided that the following conditions are met: |
|---|
| 11 | * |
|---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
|---|
| 13 | * this list of conditions and the following disclaimer. |
|---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
|---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
|---|
| 16 | * and/or other materials provided with the distribution. |
|---|
| 17 | * * Neither the name of the ISO/IEC nor the names of its contributors may |
|---|
| 18 | * be used to endorse or promote products derived from this software without |
|---|
| 19 | * specific prior written permission. |
|---|
| 20 | * |
|---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
|---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
|---|
| 32 | */ |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | /** \file TEncAdaptiveLoopFilter.h |
|---|
| 37 | \brief estimation part of adaptive loop filter class (header) |
|---|
| 38 | */ |
|---|
| 39 | |
|---|
| 40 | #ifndef __TENCADAPTIVELOOPFILTER__ |
|---|
| 41 | #define __TENCADAPTIVELOOPFILTER__ |
|---|
| 42 | |
|---|
| 43 | #include "../TLibCommon/TComAdaptiveLoopFilter.h" |
|---|
| 44 | #include "../TLibCommon/TComPic.h" |
|---|
| 45 | |
|---|
| 46 | #include "TEncEntropy.h" |
|---|
| 47 | #include "TEncSbac.h" |
|---|
| 48 | #include "../TLibCommon/TComBitCounter.h" |
|---|
| 49 | |
|---|
| 50 | // ==================================================================================================================== |
|---|
| 51 | // Class definition |
|---|
| 52 | // ==================================================================================================================== |
|---|
| 53 | #if MTK_SAO |
|---|
| 54 | |
|---|
| 55 | class TEncSampleAdaptiveOffset : public TComSampleAdaptiveOffset |
|---|
| 56 | { |
|---|
| 57 | private: |
|---|
| 58 | Double m_dLambdaLuma; |
|---|
| 59 | Double m_dLambdaChroma; |
|---|
| 60 | |
|---|
| 61 | TEncEntropy* m_pcEntropyCoder; |
|---|
| 62 | TEncSbac*** m_pppcRDSbacCoder; |
|---|
| 63 | TEncSbac* m_pcRDGoOnSbacCoder; |
|---|
| 64 | |
|---|
| 65 | Int64 ***m_iCount ; //[MAX_NUM_QAO_PART][MAX_NUM_QAO_TYPE][MAX_NUM_QAO_CLASS]; |
|---|
| 66 | Int64 ***m_iOffset; //[MAX_NUM_QAO_PART][MAX_NUM_QAO_TYPE][MAX_NUM_QAO_CLASS]; |
|---|
| 67 | Int64 ***m_iOffsetOrg ; //[MAX_NUM_QAO_PART][MAX_NUM_QAO_TYPE]; |
|---|
| 68 | Int64 **m_iRate ; //[MAX_NUM_QAO_PART][MAX_NUM_QAO_TYPE]; |
|---|
| 69 | Int64 **m_iDist ; //[MAX_NUM_QAO_PART][MAX_NUM_QAO_TYPE]; |
|---|
| 70 | Double **m_dCost ; //[MAX_NUM_QAO_PART][MAX_NUM_QAO_TYPE]; |
|---|
| 71 | Double *m_dCostPartBest ;//[MAX_NUM_QAO_PART]; |
|---|
| 72 | Int64 *m_iDistOrg; //[MAX_NUM_QAO_PART]; |
|---|
| 73 | Int *m_iTypePartBest ;//[MAX_NUM_QAO_PART]; |
|---|
| 74 | |
|---|
| 75 | Bool m_bUseSBACRD; |
|---|
| 76 | |
|---|
| 77 | public: |
|---|
| 78 | Void startSaoEnc( TComPic* pcPic, TEncEntropy* pcEntropyCoder, TEncSbac*** pppcRDSbacCoder, TEncSbac* pcRDGoOnSbacCoder); |
|---|
| 79 | Void endSaoEnc(); |
|---|
| 80 | Void SAOProcess(Double dLambda); |
|---|
| 81 | Void xQuadTreeDecisionFunc(Int iPartIdx, TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, Double &dCostFinal); |
|---|
| 82 | Void xQAOOnePart(SAOQTPart* pQAOOnePart, Int iPartIdx); |
|---|
| 83 | Void xPartTreeDisable(Int iPartIdx); |
|---|
| 84 | Void xGetQAOStats(TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest); |
|---|
| 85 | Void calcAoStatsCu(Int iAddr, Int iPartIdx); |
|---|
| 86 | Void destoryEncBuffer(); |
|---|
| 87 | Void createEncBuffer(); |
|---|
| 88 | }; |
|---|
| 89 | #endif |
|---|
| 90 | |
|---|
| 91 | /// estimation part of adaptive loop filter class |
|---|
| 92 | class TEncAdaptiveLoopFilter : public TComAdaptiveLoopFilter |
|---|
| 93 | { |
|---|
| 94 | private: |
|---|
| 95 | static const Int m_aiSymmetricArray9x9[81]; ///< scan index for 9x9 filter |
|---|
| 96 | static const Int m_aiSymmetricArray7x7[49]; ///< scan index for 7x7 filter |
|---|
| 97 | static const Int m_aiSymmetricArray5x5[25]; ///< scan index for 5x5 filter |
|---|
| 98 | #if TI_ALF_MAX_VSIZE_7 |
|---|
| 99 | static const Int m_aiSymmetricArray9x7[63]; ///< scan index for 9x7 filter |
|---|
| 100 | #endif |
|---|
| 101 | |
|---|
| 102 | Double** m_ppdAlfCorr; |
|---|
| 103 | Double* m_pdDoubleAlfCoeff; |
|---|
| 104 | |
|---|
| 105 | SliceType m_eSliceType; |
|---|
| 106 | Int m_iPicNalReferenceIdc; |
|---|
| 107 | |
|---|
| 108 | Double m_dLambdaLuma; |
|---|
| 109 | Double m_dLambdaChroma; |
|---|
| 110 | |
|---|
| 111 | TEncEntropy* m_pcEntropyCoder; |
|---|
| 112 | |
|---|
| 113 | TComPic* m_pcPic; |
|---|
| 114 | ALFParam* m_pcBestAlfParam; |
|---|
| 115 | ALFParam* m_pcTempAlfParam; |
|---|
| 116 | |
|---|
| 117 | TComPicYuv* m_pcPicYuvBest; |
|---|
| 118 | TComPicYuv* m_pcPicYuvTmp; |
|---|
| 119 | |
|---|
| 120 | UInt m_uiNumSCUInCU; |
|---|
| 121 | |
|---|
| 122 | Int m_varIndTab[NO_VAR_BINS]; |
|---|
| 123 | double ***m_yGlobalSym; |
|---|
| 124 | double ****m_EGlobalSym; |
|---|
| 125 | double *m_pixAcc; |
|---|
| 126 | Int **m_filterCoeffSymQuant; |
|---|
| 127 | imgpel **m_varImg; |
|---|
| 128 | imgpel **m_maskImg; |
|---|
| 129 | Int m_im_width; |
|---|
| 130 | Int m_im_height; |
|---|
| 131 | ALFParam *m_tempALFp; |
|---|
| 132 | TEncEntropy* m_pcDummyEntropyCoder; |
|---|
| 133 | |
|---|
| 134 | double **m_y_merged; |
|---|
| 135 | double ***m_E_merged; |
|---|
| 136 | double *m_pixAcc_merged; |
|---|
| 137 | double *m_y_temp; |
|---|
| 138 | double **m_E_temp; |
|---|
| 139 | |
|---|
| 140 | Int *m_filterCoeffQuantMod; |
|---|
| 141 | double *m_filterCoeff; |
|---|
| 142 | Int *m_filterCoeffQuant; |
|---|
| 143 | Int **m_diffFilterCoeffQuant; |
|---|
| 144 | Int **m_FilterCoeffQuantTemp; |
|---|
| 145 | |
|---|
| 146 | #if MQT_ALF_NPASS |
|---|
| 147 | Int m_iUsePreviousFilter; |
|---|
| 148 | Int m_iDesignCurrentFilter; |
|---|
| 149 | Int m_iFilterIdx; |
|---|
| 150 | #if MQT_BA_RA |
|---|
| 151 | Int*** m_aiFilterCoeffSavedMethods[NUM_ALF_CLASS_METHOD]; |
|---|
| 152 | Int*** m_aiFilterCoeffSaved; |
|---|
| 153 | #else |
|---|
| 154 | Int m_aiFilterCoeffSaved[9][NO_VAR_BINS][MAX_SQR_FILT_LENGTH]; |
|---|
| 155 | #endif |
|---|
| 156 | Int m_iGOPSize; |
|---|
| 157 | Int m_iCurrentPOC; |
|---|
| 158 | Int m_iALFEncodePassReduction; |
|---|
| 159 | Int m_iALFNumOfRedesign; |
|---|
| 160 | Int m_iMatrixBaseFiltNo; |
|---|
| 161 | |
|---|
| 162 | #if TI_ALF_MAX_VSIZE_7 |
|---|
| 163 | static Int m_aiTapPos9x9_In9x9Sym[21]; |
|---|
| 164 | #else |
|---|
| 165 | static Int m_aiTapPos9x9_In9x9Sym[22]; |
|---|
| 166 | #endif |
|---|
| 167 | static Int m_aiTapPos7x7_In9x9Sym[14]; |
|---|
| 168 | static Int m_aiTapPos5x5_In9x9Sym[8]; |
|---|
| 169 | static Int* m_iTapPosTabIn9x9Sym[NO_TEST_FILT]; |
|---|
| 170 | #endif |
|---|
| 171 | |
|---|
| 172 | #if MTK_NONCROSS_INLOOP_FILTER |
|---|
| 173 | TComPicYuv* m_pcSliceYuvTmp; |
|---|
| 174 | #endif |
|---|
| 175 | |
|---|
| 176 | private: |
|---|
| 177 | // init / uninit internal variables |
|---|
| 178 | Void xInitParam (); |
|---|
| 179 | Void xUninitParam (); |
|---|
| 180 | |
|---|
| 181 | // create/destroy/copy/set functions of ALF control flags |
|---|
| 182 | Void xCreateTmpAlfCtrlFlags (); |
|---|
| 183 | Void xDestroyTmpAlfCtrlFlags (); |
|---|
| 184 | Void xCopyTmpAlfCtrlFlagsTo (); |
|---|
| 185 | Void xCopyTmpAlfCtrlFlagsFrom (); |
|---|
| 186 | |
|---|
| 187 | // encoder ALF control flags |
|---|
| 188 | Void xEncodeCUAlfCtrlFlags (); |
|---|
| 189 | Void xEncodeCUAlfCtrlFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth); |
|---|
| 190 | |
|---|
| 191 | // functions related to correlation computation |
|---|
| 192 | #if MTK_NONCROSS_INLOOP_FILTER |
|---|
| 193 | Void xCalcCorrelationFunc ( Int ypos, Int xpos, Pel* pOrg, Pel* pCmp, Int iTap, Int iWidth, Int iHeight, Int iOrgStride, Int iCmpStride, Bool bSymmCopyBlockMatrix); |
|---|
| 194 | #else |
|---|
| 195 | Void xCalcCorrelationFunc ( Pel* pOrg, Pel* pCmp, Int iTap, Int iWidth, Int iHeight, Int iOrgStride, Int iCmpStride); |
|---|
| 196 | #endif |
|---|
| 197 | |
|---|
| 198 | // functions related to filtering |
|---|
| 199 | Void xFilterCoefQuickSort ( Double *coef_data, Int *coef_num, Int upper, Int lower ); |
|---|
| 200 | Void xQuantFilterCoef ( Double* h, Int* qh, Int tap, int bit_depth ); |
|---|
| 201 | Void xClearFilterCoefInt ( Int* qh, Int N ); |
|---|
| 202 | Void xCopyDecToRestCUs ( TComPicYuv* pcPicDec, TComPicYuv* pcPicRest ); |
|---|
| 203 | Void xCopyDecToRestCU ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest ); |
|---|
| 204 | Void xFilteringFrameChroma ( TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest ); |
|---|
| 205 | |
|---|
| 206 | // distortion / misc functions |
|---|
| 207 | UInt64 xCalcSSD ( Pel* pOrg, Pel* pCmp, Int iWidth, Int iHeight, Int iStride ); |
|---|
| 208 | Void xCalcRDCost ( TComPicYuv* pcPicOrg, TComPicYuv* pcPicCmp, ALFParam* pAlfParam, UInt64& ruiRate, UInt64& ruiDist, Double& rdCost ); |
|---|
| 209 | Void xCalcRDCostChroma ( TComPicYuv* pcPicOrg, TComPicYuv* pcPicCmp, ALFParam* pAlfParam, UInt64& ruiRate, UInt64& ruiDist, Double& rdCost ); |
|---|
| 210 | Void xCalcRDCost ( ALFParam* pAlfParam, UInt64& ruiRate, UInt64 uiDist, Double& rdCost ); |
|---|
| 211 | Int xGauss ( Double **a, Int N ); |
|---|
| 212 | |
|---|
| 213 | #if MQT_ALF_NPASS |
|---|
| 214 | Void xretriveBlockMatrix (Int iNumTaps, Int* piTapPosInMaxFilter, Double*** pppdEBase, Double*** pppdETarget, Double** ppdyBase, Double** ppdyTarget ); |
|---|
| 215 | Void xcalcPredFilterCoeffPrev(Int filtNo); |
|---|
| 216 | Void setALFEncodingParam(TComPic *pcPic); |
|---|
| 217 | Void setFilterIdx(Int index); |
|---|
| 218 | Void setInitialMask(TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec); |
|---|
| 219 | #if MQT_BA_RA |
|---|
| 220 | Void xFirstEstimateFilteringFrameLumaAllTap(imgpel* ImgOrg, imgpel* ImgDec, Int Stride, ALFParam* pcAlfSaved,Int* aiVarIndTabBest,Int** ppiBestCoeffSet, Int& ibestfiltNo,Int& ibestfilters_per_fr, Double** ppdBesty,Double*** pppdBestE,Double* pdBestpixAcc,UInt64& ruiRate,Int64& riDist,Double& rdCost); |
|---|
| 221 | #else |
|---|
| 222 | Void xFirstFilteringFrameLumaAllTap(imgpel* ImgOrg, imgpel* ImgDec, imgpel* ImgRest, Int Stride); |
|---|
| 223 | #endif |
|---|
| 224 | Int64 xFastFiltDistEstimation(Double** ppdE, Double* pdy, Int* piCoeff, Int iFiltLength); |
|---|
| 225 | Int64 xEstimateFiltDist (Int filters_per_fr, Int* VarIndTab, Double*** pppdE, Double** ppdy, Int** ppiCoeffSet, Int iFiltLength); |
|---|
| 226 | #endif |
|---|
| 227 | |
|---|
| 228 | |
|---|
| 229 | #if MTK_NONCROSS_INLOOP_FILTER |
|---|
| 230 | Void xstoreInBlockMatrixforSlices (imgpel* ImgOrg, imgpel* ImgDec, Int tap, Int iStride); |
|---|
| 231 | Void xstoreInBlockMatrixforOneSlice(CAlfSlice* pSlice, imgpel* ImgOrg, imgpel* ImgDec, Int tap, Int iStride, Bool bFirstSlice, Bool bLastSlice); |
|---|
| 232 | Void xfilterSlices_en (imgpel* ImgDec, imgpel* ImgRest,int filtNo, int Stride); |
|---|
| 233 | Void xfilterOneSlice_en (CAlfSlice* pSlice, imgpel* ImgDec, imgpel* ImgRest,int filtNo, int iStride); |
|---|
| 234 | Void calcVarforSlices (imgpel **varmap, imgpel *imgY_pad, Int pad_size, Int fl, Int img_stride); |
|---|
| 235 | |
|---|
| 236 | //only for chroma |
|---|
| 237 | Void xCalcCorrelationFuncforChromaSlices (Int ComponentID, Pel* pOrg, Pel* pCmp, Int iTap, Int iOrgStride, Int iCmpStride); |
|---|
| 238 | Void xCalcCorrelationFuncforChromaOneSlice(CAlfSlice* pSlice, Pel* pOrg, Pel* pCmp, Int iTap, Int iStride, Bool bLastSlice); |
|---|
| 239 | Void xFrameChromaforSlices (Int ComponentID, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, Int *qh, Int iTap); |
|---|
| 240 | #endif |
|---|
| 241 | |
|---|
| 242 | |
|---|
| 243 | protected: |
|---|
| 244 | /// do ALF for chroma |
|---|
| 245 | Void xEncALFChroma ( UInt64 uiLumaRate, TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiDist, UInt64& ruiBits ); |
|---|
| 246 | public: |
|---|
| 247 | TEncAdaptiveLoopFilter (); |
|---|
| 248 | virtual ~TEncAdaptiveLoopFilter () {} |
|---|
| 249 | |
|---|
| 250 | /// allocate temporal memory |
|---|
| 251 | Void startALFEnc(TComPic* pcPic, TEncEntropy* pcEntropyCoder); |
|---|
| 252 | |
|---|
| 253 | /// destroy temporal memory |
|---|
| 254 | Void endALFEnc(); |
|---|
| 255 | |
|---|
| 256 | /// estimate ALF parameters |
|---|
| 257 | Void ALFProcess(ALFParam* pcAlfParam, Double dLambda, UInt64& ruiDist, UInt64& ruiBits, UInt& ruiMaxAlfCtrlDepth ); |
|---|
| 258 | /// test ALF for luma |
|---|
| 259 | Void xEncALFLuma_qc ( TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiMinRate, |
|---|
| 260 | UInt64& ruiMinDist, Double& rdMinCost ); |
|---|
| 261 | Void xCUAdaptiveControl_qc ( TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiMinRate, |
|---|
| 262 | UInt64& ruiMinDist, Double& rdMinCost ); |
|---|
| 263 | #if TSB_ALF_HEADER |
|---|
| 264 | Void xSetCUAlfCtrlFlags_qc (UInt uiAlfCtrlDepth, TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, |
|---|
| 265 | UInt64& ruiDist, ALFParam *pAlfParam); |
|---|
| 266 | Void xSetCUAlfCtrlFlag_qc (TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiAlfCtrlDepth, TComPicYuv* pcPicOrg, |
|---|
| 267 | TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiDist, ALFParam *pAlfParam); |
|---|
| 268 | #else |
|---|
| 269 | Void xSetCUAlfCtrlFlags_qc (UInt uiAlfCtrlDepth, TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, |
|---|
| 270 | UInt64& ruiDist); |
|---|
| 271 | Void xSetCUAlfCtrlFlag_qc (TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiAlfCtrlDepth, TComPicYuv* pcPicOrg, |
|---|
| 272 | TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiDist); |
|---|
| 273 | #endif |
|---|
| 274 | Void xReDesignFilterCoeff_qc (TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, Bool bReadCorr); |
|---|
| 275 | Void xFilterTapDecision_qc (TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, UInt64& ruiMinRate, |
|---|
| 276 | UInt64& ruiMinDist, Double& rdMinCost); |
|---|
| 277 | Void xFirstFilteringFrameLuma (imgpel* ImgOrg, imgpel* ImgDec, imgpel* ImgRest, ALFParam* ALFp, Int tap, Int Stride); |
|---|
| 278 | #if MTK_NONCROSS_INLOOP_FILTER |
|---|
| 279 | Void xstoreInBlockMatrix(Int ypos, Int xpos, Int iheight, Int iwidth, Bool bResetBlockMatrix, Bool bSymmCopyBlockMatrix, imgpel* ImgOrg, imgpel* ImgDec, Int tap, Int Stride); |
|---|
| 280 | #else |
|---|
| 281 | Void xstoreInBlockMatrix(imgpel* ImgOrg, imgpel* ImgDec, Int tap, Int Stride); |
|---|
| 282 | #endif |
|---|
| 283 | Void xFilteringFrameLuma_qc(imgpel* ImgOrg, imgpel* imgY_pad, imgpel* ImgFilt, ALFParam* ALFp, Int tap, Int Stride); |
|---|
| 284 | #if MTK_NONCROSS_INLOOP_FILTER |
|---|
| 285 | Void xfilterFrame_en(int ypos, int xpos, int iheight, int iwidth, imgpel* ImgDec, imgpel* ImgRest,int filtNo, int Stride); |
|---|
| 286 | #else |
|---|
| 287 | Void xfilterFrame_en(imgpel* ImgDec, imgpel* ImgRest,int filtNo, int Stride); |
|---|
| 288 | #endif |
|---|
| 289 | Void xcalcPredFilterCoeff(Int filtNo); |
|---|
| 290 | #if MQT_ALF_NPASS |
|---|
| 291 | UInt xcodeFiltCoeff(Int **filterCoeffSymQuant, Int filtNo, Int varIndTab[], Int filters_per_fr_best, Int frNo, ALFParam* ALFp); |
|---|
| 292 | #else |
|---|
| 293 | Void xcodeFiltCoeff(Int **filterCoeffSymQuant, Int filtNo, Int varIndTab[], Int filters_per_fr_best, Int frNo, ALFParam* ALFp); |
|---|
| 294 | #endif |
|---|
| 295 | Void xfindBestFilterVarPred(double **ySym, double ***ESym, double *pixAcc, Int **filterCoeffSym, Int **filterCoeffSymQuant, |
|---|
| 296 | Int filtNo, Int *filters_per_fr_best, Int varIndTab[], imgpel **imgY_rec, imgpel **varImg, |
|---|
| 297 | imgpel **maskImg, imgpel **imgY_pad, double lambda_val); |
|---|
| 298 | double xfindBestCoeffCodMethod(int codedVarBins[NO_VAR_BINS], int *forceCoeff0, |
|---|
| 299 | int **filterCoeffSymQuant, int fl, int sqrFiltLength, |
|---|
| 300 | int filters_per_fr, double errorForce0CoeffTab[NO_VAR_BINS][2], |
|---|
| 301 | double *errorQuant, double lambda); |
|---|
| 302 | Void xcollectStatCodeFilterCoeffForce0(int **pDiffQFilterCoeffIntPP, int fl, int sqrFiltLength, int filters_per_group, |
|---|
| 303 | int bitsVarBin[]); |
|---|
| 304 | Void xdecideCoeffForce0(int codedVarBins[NO_VAR_BINS], double errorForce0Coeff[], double errorForce0CoeffTab[NO_VAR_BINS][2], |
|---|
| 305 | int bitsVarBin[NO_VAR_BINS], double lambda, int filters_per_fr); |
|---|
| 306 | Int xsendAllFiltersPPPredForce0(int **FilterCoeffQuant, int fl, int sqrFiltLength, int filters_per_group, |
|---|
| 307 | int codedVarBins[NO_VAR_BINS], int createBistream, ALFParam* ALFp); |
|---|
| 308 | Int xsendAllFiltersPPPred(int **FilterCoeffQuant, int fl, int sqrFiltLength, |
|---|
| 309 | int filters_per_group, int createBistream, ALFParam* ALFp); |
|---|
| 310 | Int xcodeAuxInfo(int filtNo, int noFilters, int varIndTab[NO_VAR_BINS], int frNo, int createBitstream,int realfiltNo, ALFParam* ALFp); |
|---|
| 311 | Int xcodeFilterCoeff(int **pDiffQFilterCoeffIntPP, int fl, int sqrFiltLength, int filters_per_group, int createBitstream); |
|---|
| 312 | Int lengthGolomb(int coeffVal, int k); |
|---|
| 313 | Int lengthPredFlags(int force0, int predMethod, int codedVarBins[NO_VAR_BINS], |
|---|
| 314 | int filters_per_group, int createBitstream); |
|---|
| 315 | Int lengthFilterCoeffs(int sqrFiltLength, int filters_per_group, int pDepthInt[], |
|---|
| 316 | int **FilterCoeff, int kMinTab[], int createBitstream); |
|---|
| 317 | //cholesky related |
|---|
| 318 | Double findFilterCoeff(double ***EGlobalSeq, double **yGlobalSeq, double *pixAccGlobalSeq, int **filterCoeffSeq, |
|---|
| 319 | int **filterCoeffQuantSeq, int intervalBest[NO_VAR_BINS][2], int varIndTab[NO_VAR_BINS], int sqrFiltLength, |
|---|
| 320 | int filters_per_fr, int *weights, int bit_depth, double errorTabForce0Coeff[NO_VAR_BINS][2]); |
|---|
| 321 | Double QuantizeIntegerFilterPP(double *filterCoeff, int *filterCoeffQuant, double **E, double *y, |
|---|
| 322 | int sqrFiltLength, int *weights, int bit_depth); |
|---|
| 323 | Void roundFiltCoeff(int *FilterCoeffQuan, double *FilterCoeff, int sqrFiltLength, int factor); |
|---|
| 324 | double findFilterGroupingError(double ***EGlobalSeq, double **yGlobalSeq, double *pixAccGlobalSeq, |
|---|
| 325 | int intervalBest[NO_VAR_BINS][2], int sqrFiltLength, int filters_per_fr); |
|---|
| 326 | double mergeFiltersGreedy(double **yGlobalSeq, double ***EGlobalSeq, double *pixAccGlobalSeq, |
|---|
| 327 | int intervalBest[NO_VAR_BINS][2], int sqrFiltLength, int noIntervals); |
|---|
| 328 | double calculateErrorAbs(double **A, double *b, double y, int size); |
|---|
| 329 | double calculateErrorCoeffProvided(double **A, double *b, double *c, int size); |
|---|
| 330 | Void add_b(double *bmerged, double **b, int start, int stop, int size); |
|---|
| 331 | Void add_A(double **Amerged, double ***A, int start, int stop, int size); |
|---|
| 332 | Int gnsSolveByChol(double **LHS, double *rhs, double *x, int noEq); |
|---|
| 333 | Void gnsBacksubstitution(double R[MAX_SQR_FILT_LENGTH][MAX_SQR_FILT_LENGTH], double z[MAX_SQR_FILT_LENGTH], |
|---|
| 334 | int R_size, double A[MAX_SQR_FILT_LENGTH]); |
|---|
| 335 | Void gnsTransposeBacksubstitution(double U[MAX_SQR_FILT_LENGTH][MAX_SQR_FILT_LENGTH], double rhs[], double x[], |
|---|
| 336 | int order); |
|---|
| 337 | Int gnsCholeskyDec(double **inpMatr, double outMatr[MAX_SQR_FILT_LENGTH][MAX_SQR_FILT_LENGTH], int noEq); |
|---|
| 338 | #if MQT_ALF_NPASS |
|---|
| 339 | Void setGOPSize(Int val) { m_iGOPSize = val; } |
|---|
| 340 | Void setALFEncodePassReduction (Int iVal) {m_iALFEncodePassReduction = iVal;} |
|---|
| 341 | |
|---|
| 342 | #if MQT_BA_RA |
|---|
| 343 | Void createAlfGlobalBuffers(Int iALFEncodePassReduction); |
|---|
| 344 | Void destroyAlfGlobalBuffers(); |
|---|
| 345 | #endif |
|---|
| 346 | #endif |
|---|
| 347 | }; |
|---|
| 348 | #endif |
|---|