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 TComAdaptiveLoopFilter.h |
---|
37 | \brief adaptive loop filter class (header) |
---|
38 | */ |
---|
39 | |
---|
40 | #ifndef __TCOMADAPTIVELOOPFILTER__ |
---|
41 | #define __TCOMADAPTIVELOOPFILTER__ |
---|
42 | |
---|
43 | #include "TComPic.h" |
---|
44 | |
---|
45 | // ==================================================================================================================== |
---|
46 | // Constants |
---|
47 | // ==================================================================================================================== |
---|
48 | |
---|
49 | #define ALF_MAX_NUM_TAP 9 ///< maximum number of filter taps (9x9) |
---|
50 | #define ALF_MIN_NUM_TAP 5 ///< minimum number of filter taps (5x5) |
---|
51 | #define ALF_MAX_NUM_TAP_C 5 ///< number of filter taps for chroma (5x5) |
---|
52 | #define ALF_MAX_NUM_COEF 42 ///< maximum number of filter coefficients |
---|
53 | #define ALF_MIN_NUM_COEF 14 ///< minimum number of filter coefficients |
---|
54 | #define ALF_MAX_NUM_COEF_C 14 ///< number of filter taps for chroma |
---|
55 | #define ALF_NUM_BIT_SHIFT 8 ///< bit shift parameter for quantization of ALF param. |
---|
56 | #define ALF_ROUND_OFFSET ( 1 << ( ALF_NUM_BIT_SHIFT - 1 ) ) ///< rounding offset for ALF quantization |
---|
57 | |
---|
58 | #include "../TLibCommon/CommonDef.h" |
---|
59 | |
---|
60 | #define NUM_BITS 9 |
---|
61 | #define NO_TEST_FILT 3 // Filter supports (5/7/9) |
---|
62 | #define NO_VAR_BINS 16 |
---|
63 | #define NO_FILTERS 16 |
---|
64 | |
---|
65 | #if MQT_BA_RA |
---|
66 | #define VAR_SIZE 1 // JCTVC-E323+E046 |
---|
67 | #else |
---|
68 | #define VAR_SIZE 3 |
---|
69 | #endif |
---|
70 | |
---|
71 | #define FILTER_LENGTH 9 |
---|
72 | |
---|
73 | #define MAX_SQR_FILT_LENGTH ((FILTER_LENGTH*FILTER_LENGTH) / 2 + 2) |
---|
74 | #if TI_ALF_MAX_VSIZE_7 |
---|
75 | #define SQR_FILT_LENGTH_9SYM ((9*9) / 4 + 2 - 1) |
---|
76 | #else |
---|
77 | #define SQR_FILT_LENGTH_9SYM ((9*9) / 4 + 2) |
---|
78 | #endif |
---|
79 | #define SQR_FILT_LENGTH_7SYM ((7*7) / 4 + 2) |
---|
80 | #define SQR_FILT_LENGTH_5SYM ((5*5) / 4 + 2) |
---|
81 | #define MAX_SCAN_VAL 11 |
---|
82 | #define MAX_EXP_GOLOMB 16 |
---|
83 | |
---|
84 | #define min(a, b) (((a) < (b)) ? (a) : (b)) |
---|
85 | #define max(a, b) (((a) > (b)) ? (a) : (b)) |
---|
86 | #define imgpel unsigned short |
---|
87 | |
---|
88 | #if TI_ALF_MAX_VSIZE_7 |
---|
89 | extern Int depthInt9x9Sym[21]; |
---|
90 | #else |
---|
91 | extern Int depthInt9x9Sym[22]; |
---|
92 | #endif |
---|
93 | extern Int depthInt7x7Sym[14]; |
---|
94 | extern Int depthInt5x5Sym[8]; |
---|
95 | extern Int *pDepthIntTab[NO_TEST_FILT]; |
---|
96 | void destroyMatrix_int(int **m2D); |
---|
97 | void initMatrix_int(int ***m2D, int d1, int d2); |
---|
98 | |
---|
99 | #if MTK_NONCROSS_INLOOP_FILTER |
---|
100 | #define EXTEND_NUM_PEL (UInt)(ALF_MAX_NUM_TAP/2) |
---|
101 | #define EXTEND_NUM_PEL_C (UInt)(ALF_MAX_NUM_TAP_C/2) |
---|
102 | enum PaddingRegionPosition |
---|
103 | { |
---|
104 | PRP_L = 0, |
---|
105 | PRP_R, |
---|
106 | PRP_T, |
---|
107 | PRP_B, |
---|
108 | NUM_PADDING_TILE, |
---|
109 | PRP_LT = NUM_PADDING_TILE, |
---|
110 | PRP_RT, |
---|
111 | PRP_LB, |
---|
112 | PRP_RB, |
---|
113 | NUM_PADDING_REGION |
---|
114 | }; |
---|
115 | enum AlfChromaID |
---|
116 | { |
---|
117 | ALF_Cb = 0, |
---|
118 | ALF_Cr = 1 |
---|
119 | }; |
---|
120 | #endif |
---|
121 | |
---|
122 | #if MQT_BA_RA |
---|
123 | enum ALFClassficationMethod |
---|
124 | { |
---|
125 | ALF_BA =0, |
---|
126 | ALF_RA, |
---|
127 | NUM_ALF_CLASS_METHOD |
---|
128 | }; |
---|
129 | #endif |
---|
130 | // ==================================================================================================================== |
---|
131 | // Class definition |
---|
132 | // ==================================================================================================================== |
---|
133 | |
---|
134 | #if MTK_SAO |
---|
135 | |
---|
136 | #define CRANGE_EXT 512 |
---|
137 | #define CRANGE 4096 |
---|
138 | #define CRANGE_ALL (CRANGE + (CRANGE_EXT*2)) |
---|
139 | #define AO_MAX_DEPTH 4 |
---|
140 | #define MAX_NUM_QAO_PART 341 |
---|
141 | #define MTK_QAO_BO_BITS 5 |
---|
142 | #define LUMA_GROUP_NUM (1<<MTK_QAO_BO_BITS) |
---|
143 | #define MAX_NUM_QAO_CLASS 32 |
---|
144 | #define SAO_RDCO 0 |
---|
145 | |
---|
146 | class TComSampleAdaptiveOffset |
---|
147 | { |
---|
148 | protected: |
---|
149 | TComPic* m_pcPic; |
---|
150 | |
---|
151 | |
---|
152 | static UInt m_uiMaxDepth; |
---|
153 | static const Int m_aiNumPartsInRow[5]; |
---|
154 | static const Int m_aiNumPartsLevel[5]; |
---|
155 | static const Int m_aiNumCulPartsLevel[5]; |
---|
156 | static const UInt m_auiEoTable[9]; |
---|
157 | static const UInt m_auiEoTable2D[9]; |
---|
158 | static const UInt m_iWeightAO[MAX_NUM_SAO_TYPE]; |
---|
159 | Int m_iOffsetBo[4096]; |
---|
160 | Int m_iOffsetEo[LUMA_GROUP_NUM]; |
---|
161 | |
---|
162 | Int m_iPicWidth; |
---|
163 | Int m_iPicHeight; |
---|
164 | UInt m_uiMaxSplitLevel; |
---|
165 | UInt m_uiMaxCUWidth; |
---|
166 | UInt m_uiMaxCUHeight; |
---|
167 | Int m_iNumCuInWidth; |
---|
168 | Int m_iNumCuInHeight; |
---|
169 | Int m_iNumTotalParts; |
---|
170 | static Int m_iNumClass[MAX_NUM_SAO_TYPE]; |
---|
171 | |
---|
172 | Bool m_bSaoFlag; |
---|
173 | SAOQTPart *m_psQAOPart; |
---|
174 | |
---|
175 | SliceType m_eSliceType; |
---|
176 | Int m_iPicNalReferenceIdc; |
---|
177 | |
---|
178 | UInt m_uiAoBitDepth; |
---|
179 | UInt m_uiQP; |
---|
180 | |
---|
181 | Bool m_bBcEnable; |
---|
182 | Int m_iMinY; |
---|
183 | Int m_iMaxY; |
---|
184 | Int m_iMinCb; |
---|
185 | Int m_iMaxCb; |
---|
186 | Int m_iMinCr; |
---|
187 | Int m_iMaxCr; |
---|
188 | Pel *m_pClipTable; |
---|
189 | Pel m_pClipTableBase[CRANGE_ALL]; |
---|
190 | Pel *m_ppLumaTableBo0; |
---|
191 | Pel *m_ppLumaTableBo1; |
---|
192 | |
---|
193 | Int *m_iUpBuff1; |
---|
194 | Int *m_iUpBuff2; |
---|
195 | Int *m_iUpBufft; |
---|
196 | Int *ipSwap; |
---|
197 | |
---|
198 | public: |
---|
199 | Void create( UInt uiSourceWidth, UInt uiSourceHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth ); |
---|
200 | Void destroy (); |
---|
201 | Void xCreateQAOParts(); |
---|
202 | Void xDestroyQAOParts(); |
---|
203 | Void xInitALfOnePart(Int part_level, Int part_row, Int part_col, Int parent_part_idx, Int StartCUX, Int EndCUX, Int StartCUY, Int EndCUY); |
---|
204 | Void xMakeSubPartList(Int part_level, Int part_row, Int part_col, Int* pList, Int& rListLength, Int NumPartInRow); |
---|
205 | Void xSetQTPartCUInfo(); |
---|
206 | |
---|
207 | Bool getQAOFlag () {return m_bSaoFlag;} |
---|
208 | Int getMaxSplitLevel() {return (Int)m_uiMaxSplitLevel;} |
---|
209 | SAOQTPart * getQTPart() {return m_psQAOPart;} |
---|
210 | |
---|
211 | Void SAOProcess(TComPic* pcPic, SAOParam* pcQaoParam); |
---|
212 | Void resetQTPart(); |
---|
213 | Void xAoOnePart(UInt uiPartIdx, TComPicYuv* pcPicYuvRec, TComPicYuv* pcPicYuvExt); |
---|
214 | Void xProcessQuadTreeAo(UInt uiPartIdx, TComPicYuv* pcPicYuvRec, TComPicYuv* pcPicYuvExt); |
---|
215 | Void copyQaoData(SAOParam* pcQaoParam); |
---|
216 | |
---|
217 | Void InitSao(SAOParam* pSaoParam); |
---|
218 | Void AoProcessCu(Int iAddr, Int iPartIdx); |
---|
219 | }; |
---|
220 | #endif |
---|
221 | |
---|
222 | |
---|
223 | #if MTK_NONCROSS_INLOOP_FILTER |
---|
224 | |
---|
225 | class CAlfCU |
---|
226 | { |
---|
227 | public: |
---|
228 | CAlfCU() {} |
---|
229 | ~CAlfCU() {} |
---|
230 | public: |
---|
231 | // Void init(TComDataCU* pcCU, UInt uiCUAddr, UInt uiStartCU, UInt uiEndCU, UInt uiNumCUWidth, UInt uiNumCUHeight); |
---|
232 | Void init(TComPic* pcPic, UInt uiCUAddr, UInt uiStartCU, UInt uiEndCU, UInt uiNumCUWidth, UInt uiNumCUHeight); |
---|
233 | TComDataCU* getCU() {return m_pcCU;} |
---|
234 | UInt getWidth() {return m_uiWidth;} |
---|
235 | UInt getHeight() {return m_uiHeight;} |
---|
236 | Int* getCUBorderFlag() {return m_aiCUBorderFlag;} |
---|
237 | Void extendCUBorder(Pel* pCUPel, UInt uiCUWidth, UInt uiCUHeight, Int iStride, UInt uiExtSize); |
---|
238 | private: |
---|
239 | Void assignBorderStatus(UInt uiStartCU, UInt uiEndCU, UInt uiNumCUWidth, UInt uiNumCUHeight); |
---|
240 | |
---|
241 | private: |
---|
242 | TComDataCU* m_pcCU; |
---|
243 | |
---|
244 | UInt m_uiCUAddr; |
---|
245 | Int m_aiCUBorderFlag[NUM_PADDING_REGION]; |
---|
246 | UInt m_uiWidth; |
---|
247 | UInt m_uiHeight; |
---|
248 | }; |
---|
249 | |
---|
250 | class CAlfSlice |
---|
251 | { |
---|
252 | public: |
---|
253 | CAlfSlice() |
---|
254 | { |
---|
255 | m_pcAlfCU= NULL; |
---|
256 | } |
---|
257 | ~CAlfSlice() |
---|
258 | { |
---|
259 | destroy(); |
---|
260 | } |
---|
261 | public: //operator to access CAlfCU |
---|
262 | CAlfCU& operator[] (Int idx) |
---|
263 | { |
---|
264 | assert(idx < m_uiNumLCUs); |
---|
265 | return m_pcAlfCU[idx]; |
---|
266 | } |
---|
267 | |
---|
268 | public: |
---|
269 | Void init(UInt uiNumLCUsInPicWidth, UInt uiNumLCUsInPicHeight); |
---|
270 | Void create(TComPic* pcPic, Int iSliceID, UInt uiStartLCU, UInt uiEndLCU); |
---|
271 | Void destroy(); |
---|
272 | |
---|
273 | UInt getNumLCUs () {return m_uiNumLCUs;} |
---|
274 | |
---|
275 | Void extendSliceBorderLuma(Pel* pPelSrc, Int iStride, UInt uiExtSize); |
---|
276 | Void extendSliceBorderChroma(Pel* pPelSrc, Int iStride, UInt uiExtSize); |
---|
277 | Void copySliceLuma(Pel* pPicDst, Pel* pPicSrc, Int iStride); |
---|
278 | Void copySliceChroma(Pel* pPicDst, Pel* pPicSrc, Int iStride ); |
---|
279 | |
---|
280 | private: |
---|
281 | |
---|
282 | Int m_iSliceID; |
---|
283 | UInt m_uiStartLCU; |
---|
284 | UInt m_uiEndLCU; |
---|
285 | UInt m_uiNumLCUs; |
---|
286 | |
---|
287 | CAlfCU* m_pcAlfCU; |
---|
288 | |
---|
289 | //----------------------------------------// |
---|
290 | UInt m_uiNumLCUsInPicWidth; |
---|
291 | UInt m_uiNumLCUsInPicHeight; |
---|
292 | }; |
---|
293 | |
---|
294 | #endif |
---|
295 | |
---|
296 | |
---|
297 | /// adaptive loop filter class |
---|
298 | class TComAdaptiveLoopFilter |
---|
299 | { |
---|
300 | protected: |
---|
301 | // quantized filter coefficients |
---|
302 | static const Int m_aiSymmetricMag9x9[41]; ///< quantization scaling factor for 9x9 filter |
---|
303 | static const Int m_aiSymmetricMag7x7[25]; ///< quantization scaling factor for 7x7 filter |
---|
304 | static const Int m_aiSymmetricMag5x5[13]; ///< quantization scaling factor for 5x5 filter |
---|
305 | #if TI_ALF_MAX_VSIZE_7 |
---|
306 | static const Int m_aiSymmetricMag9x7[32]; ///< quantization scaling factor for 9x7 filter |
---|
307 | #endif |
---|
308 | |
---|
309 | // temporary picture buffer |
---|
310 | TComPicYuv* m_pcTempPicYuv; ///< temporary picture buffer for ALF processing |
---|
311 | |
---|
312 | // ------------------------------------------------------------------------------------------------------------------ |
---|
313 | // For luma component |
---|
314 | // ------------------------------------------------------------------------------------------------------------------ |
---|
315 | #if TI_ALF_MAX_VSIZE_7 |
---|
316 | static Int m_pattern9x9Sym[39]; |
---|
317 | static Int m_weights9x9Sym[21]; |
---|
318 | #else |
---|
319 | static Int m_pattern9x9Sym[41]; |
---|
320 | static Int m_weights9x9Sym[22]; |
---|
321 | #endif |
---|
322 | static Int m_pattern9x9Sym_Quart[42]; |
---|
323 | static Int m_pattern7x7Sym[25]; |
---|
324 | static Int m_weights7x7Sym[14]; |
---|
325 | static Int m_pattern7x7Sym_Quart[42]; |
---|
326 | static Int m_pattern5x5Sym[13]; |
---|
327 | static Int m_weights5x5Sym[8]; |
---|
328 | static Int m_pattern5x5Sym_Quart[45]; |
---|
329 | #if TI_ALF_MAX_VSIZE_7 |
---|
330 | static Int m_pattern9x9Sym_9[39]; |
---|
331 | #else |
---|
332 | static Int m_pattern9x9Sym_9[41]; |
---|
333 | #endif |
---|
334 | static Int m_pattern9x9Sym_7[25]; |
---|
335 | static Int m_pattern9x9Sym_5[13]; |
---|
336 | |
---|
337 | static Int *m_patternTab_filt[NO_TEST_FILT]; |
---|
338 | static Int m_flTab[NO_TEST_FILT]; |
---|
339 | static Int *m_patternTab[NO_TEST_FILT]; |
---|
340 | static Int *m_patternMapTab[NO_TEST_FILT]; |
---|
341 | static Int *m_weightsTab[NO_TEST_FILT]; |
---|
342 | static Int m_sqrFiltLengthTab[NO_TEST_FILT]; |
---|
343 | |
---|
344 | Int m_img_height,m_img_width; |
---|
345 | |
---|
346 | imgpel **m_imgY_pad; |
---|
347 | imgpel **m_imgY_var; |
---|
348 | Int **m_imgY_temp; |
---|
349 | |
---|
350 | #if MQT_BA_RA |
---|
351 | Int** m_imgY_ver; |
---|
352 | Int** m_imgY_hor; |
---|
353 | UInt m_uiVarGenMethod; |
---|
354 | imgpel** m_varImgMethods[NUM_ALF_CLASS_METHOD]; |
---|
355 | #endif |
---|
356 | |
---|
357 | Int **m_filterCoeffSym; |
---|
358 | Int **m_filterCoeffPrevSelected; |
---|
359 | Int **m_filterCoeffTmp; |
---|
360 | Int **m_filterCoeffSymTmp; |
---|
361 | |
---|
362 | |
---|
363 | #if MTK_NONCROSS_INLOOP_FILTER |
---|
364 | Bool m_bUseNonCrossALF; |
---|
365 | UInt m_uiNumLCUsInWidth; |
---|
366 | UInt m_uiNumLCUsInHeight; |
---|
367 | UInt m_uiNumSlicesInPic; |
---|
368 | CAlfSlice* m_pSlice; |
---|
369 | Bool m_bIsFirstDecodedSlice; |
---|
370 | |
---|
371 | Bool m_bIsCreated; |
---|
372 | Void xFilterOneSlice (CAlfSlice* pSlice, imgpel* pDec, imgpel* pRest, Int iStride, ALFParam* pcAlfParam); |
---|
373 | Void calcVarforOneSlice (CAlfSlice* pSlice, imgpel **imgY_var, imgpel *imgY_pad, Int pad_size, Int fl, Int img_stride); |
---|
374 | Void xFrameChromaforOneSlice (CAlfSlice* pSlice, Int ComponentID, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, Int *qh, Int iTap); |
---|
375 | //for decoder CU on/off control |
---|
376 | Void setAlfCtrlFlagsforSlices (ALFParam *pcAlfParam, UInt &idx); |
---|
377 | Void setAlfCtrlFlagsforOneSlice (CAlfSlice* pSlice, ALFParam *pcAlfParam, UInt &idx); |
---|
378 | #endif |
---|
379 | |
---|
380 | #if MQT_BA_RA |
---|
381 | Void createRegionIndexMap(imgpel **imgY_var, Int img_width, Int img_height); |
---|
382 | #endif |
---|
383 | |
---|
384 | /// ALF for luma component |
---|
385 | Void xALFLuma_qc( TComPic* pcPic, ALFParam* pcAlfParam, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest ); |
---|
386 | |
---|
387 | Void reconstructFilterCoeffs(ALFParam* pcAlfParam,int **pfilterCoeffSym, int bit_depth); |
---|
388 | Void getCurrentFilter(int **filterCoeffSym,ALFParam* pcAlfParam); |
---|
389 | // memory allocation |
---|
390 | Void destroyMatrix_imgpel(imgpel **m2D); |
---|
391 | Void destroyMatrix_int(int **m2D); |
---|
392 | Void initMatrix_int(int ***m2D, int d1, int d2); |
---|
393 | Void initMatrix_imgpel(imgpel ***m2D, int d1, int d2); |
---|
394 | Void destroyMatrix4D_double(double ****m4D, int d1, int d2); |
---|
395 | Void destroyMatrix3D_double(double ***m3D, int d1); |
---|
396 | Void destroyMatrix_double(double **m2D); |
---|
397 | Void initMatrix4D_double(double *****m4D, int d1, int d2, int d3, int d4); |
---|
398 | Void initMatrix3D_double(double ****m3D, int d1, int d2, int d3); |
---|
399 | Void initMatrix_double(double ***m2D, int d1, int d2); |
---|
400 | Void free_mem2Dpel(imgpel **array2D); |
---|
401 | Void get_mem2Dpel(imgpel ***array2D, int rows, int columns); |
---|
402 | Void no_mem_exit(const char *where); |
---|
403 | Void xError(const char *text, int code); |
---|
404 | #if MTK_NONCROSS_INLOOP_FILTER |
---|
405 | Void calcVar(int ypos, int xpos, imgpel **imgY_var, imgpel *imgY_pad, int pad_size, int fl, int img_height, int img_width, int img_stride); |
---|
406 | #else |
---|
407 | Void calcVar(imgpel **imgY_var, imgpel *imgY_pad, int pad_size, int fl, int img_height, int img_width, int img_stride); |
---|
408 | #endif |
---|
409 | Void DecFilter_qc(imgpel* imgY_rec,ALFParam* pcAlfParam, int Stride); |
---|
410 | Void xSubCUAdaptive_qc(TComDataCU* pcCU, ALFParam* pcAlfParam, imgpel *imgY_rec_post, imgpel *imgY_rec, UInt uiAbsPartIdx, UInt uiDepth, Int Stride); |
---|
411 | Void xCUAdaptive_qc(TComPic* pcPic, ALFParam* pcAlfParam, imgpel *imgY_rec_post, imgpel *imgY_rec, Int Stride); |
---|
412 | Void subfilterFrame(imgpel *imgY_rec_post, imgpel *imgY_rec, int filtNo, int start_height, int end_height, int start_width, int end_width, int Stride); |
---|
413 | Void filterFrame(imgpel *imgY_rec_post, imgpel *imgY_rec, int filtNo, int Stride); |
---|
414 | #if TSB_ALF_HEADER |
---|
415 | UInt m_uiNumCUsInFrame; |
---|
416 | Void setAlfCtrlFlags (ALFParam *pAlfParam, TComDataCU *pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt &idx); |
---|
417 | #endif |
---|
418 | |
---|
419 | // ------------------------------------------------------------------------------------------------------------------ |
---|
420 | // For chroma component |
---|
421 | // ------------------------------------------------------------------------------------------------------------------ |
---|
422 | |
---|
423 | /// ALF for chroma component |
---|
424 | Void xALFChroma ( ALFParam* pcAlfParam, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest ); |
---|
425 | |
---|
426 | /// sub function: non-adaptive ALF process for chroma |
---|
427 | #if MTK_NONCROSS_INLOOP_FILTER |
---|
428 | Void xFrameChroma ( Int ypos, Int xpos, Int iHeight, Int iWidth, TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, Int *qh, Int iTap, Int iColor ); |
---|
429 | #else |
---|
430 | Void xFrameChroma ( TComPicYuv* pcPicDec, TComPicYuv* pcPicRest, Int *qh, Int iTap, Int iColor ); |
---|
431 | #endif |
---|
432 | |
---|
433 | public: |
---|
434 | TComAdaptiveLoopFilter(); |
---|
435 | virtual ~TComAdaptiveLoopFilter() {} |
---|
436 | |
---|
437 | // initialize & destory temporary buffer |
---|
438 | Void create ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth ); |
---|
439 | Void destroy (); |
---|
440 | |
---|
441 | Bool isCreated() { return m_bIsCreated;} |
---|
442 | // alloc & free & set functions |
---|
443 | Void allocALFParam ( ALFParam* pAlfParam ); |
---|
444 | Void freeALFParam ( ALFParam* pAlfParam ); |
---|
445 | Void copyALFParam ( ALFParam* pDesAlfParam, ALFParam* pSrcAlfParam ); |
---|
446 | #if TSB_ALF_HEADER |
---|
447 | Void setNumCUsInFrame (TComPic *pcPic); |
---|
448 | #endif |
---|
449 | |
---|
450 | // predict filter coefficients |
---|
451 | Void predictALFCoeff ( ALFParam* pAlfParam ); ///< prediction of luma ALF coefficients |
---|
452 | Void predictALFCoeffChroma ( ALFParam* pAlfParam ); ///< prediction of chroma ALF coefficients |
---|
453 | |
---|
454 | // interface function |
---|
455 | Void ALFProcess ( TComPic* pcPic, ALFParam* pcAlfParam ); ///< interface function for ALF process |
---|
456 | |
---|
457 | #if TI_ALF_MAX_VSIZE_7 |
---|
458 | static Int ALFTapHToTapV(Int tapH); |
---|
459 | static Int ALFTapHToNumCoeff(Int tapH); |
---|
460 | static Int ALFFlHToFlV(Int flH); |
---|
461 | #endif |
---|
462 | |
---|
463 | |
---|
464 | #if MTK_NONCROSS_INLOOP_FILTER |
---|
465 | public: |
---|
466 | Void setNumSlicesInPic(UInt uiNum) {m_uiNumSlicesInPic = uiNum;} |
---|
467 | UInt getNumSlicesInPic() {return m_uiNumSlicesInPic;} |
---|
468 | Void setUseNonCrossAlf(Bool bVal) {m_bUseNonCrossALF = bVal;} |
---|
469 | Bool getUseNonCrossAlf() {return m_bUseNonCrossALF;} |
---|
470 | Void createSlice (); |
---|
471 | Void destroySlice (); |
---|
472 | |
---|
473 | public: //operator to access Alf slice |
---|
474 | CAlfSlice& operator[] (UInt i) |
---|
475 | { |
---|
476 | assert(i < m_uiNumSlicesInPic); |
---|
477 | return m_pSlice[i]; |
---|
478 | } |
---|
479 | #endif |
---|
480 | |
---|
481 | |
---|
482 | }; |
---|
483 | #endif |
---|