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-2012, ITU/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 ITU/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 | /** \file TComRom.cpp |
---|
35 | \brief global variables & functions |
---|
36 | */ |
---|
37 | |
---|
38 | #include "TComRom.h" |
---|
39 | #include <memory.h> |
---|
40 | #include <stdlib.h> |
---|
41 | #include <stdio.h> |
---|
42 | // ==================================================================================================================== |
---|
43 | // Initialize / destroy functions |
---|
44 | // ==================================================================================================================== |
---|
45 | |
---|
46 | //! \ingroup TLibCommon |
---|
47 | //! \{ |
---|
48 | |
---|
49 | // initialize ROM variables |
---|
50 | Void initROM() |
---|
51 | { |
---|
52 | Int i, c; |
---|
53 | |
---|
54 | // g_aucConvertToBit[ x ]: log2(x/4), if x=4 -> 0, x=8 -> 1, x=16 -> 2, ... |
---|
55 | ::memset( g_aucConvertToBit, -1, sizeof( g_aucConvertToBit ) ); |
---|
56 | c=0; |
---|
57 | for ( i=4; i<MAX_CU_SIZE; i*=2 ) |
---|
58 | { |
---|
59 | g_aucConvertToBit[ i ] = c; |
---|
60 | c++; |
---|
61 | } |
---|
62 | g_aucConvertToBit[ i ] = c; |
---|
63 | |
---|
64 | // g_auiFrameScanXY[ g_aucConvertToBit[ transformSize ] ]: zigzag scan array for transformSize |
---|
65 | c=2; |
---|
66 | for ( i=0; i<MAX_CU_DEPTH; i++ ) |
---|
67 | { |
---|
68 | g_auiFrameScanXY[ i ] = new UInt[ c*c ]; |
---|
69 | g_auiFrameScanX [ i ] = new UInt[ c*c ]; |
---|
70 | g_auiFrameScanY [ i ] = new UInt[ c*c ]; |
---|
71 | initFrameScanXY( g_auiFrameScanXY[i], g_auiFrameScanX[i], g_auiFrameScanY[i], c, c ); |
---|
72 | g_auiSigLastScan[0][i] = new UInt[ c*c ]; |
---|
73 | g_auiSigLastScan[1][i] = new UInt[ c*c ]; |
---|
74 | g_auiSigLastScan[2][i] = new UInt[ c*c ]; |
---|
75 | g_auiSigLastScan[3][i] = new UInt[ c*c ]; |
---|
76 | initSigLastScan( g_auiSigLastScan[0][i], g_auiSigLastScan[1][i], g_auiSigLastScan[2][i], g_auiSigLastScan[3][i], c, c, i); |
---|
77 | |
---|
78 | c <<= 1; |
---|
79 | } |
---|
80 | |
---|
81 | g_sigScanNSQT[0] = new UInt[ 64 ]; // 4x16 |
---|
82 | g_sigScanNSQT[1] = new UInt[ 256 ]; // 8x32 |
---|
83 | g_sigScanNSQT[2] = new UInt[ 64 ]; // 16x4 |
---|
84 | g_sigScanNSQT[3] = new UInt[ 256 ]; // 32x8 |
---|
85 | |
---|
86 | static int diagScanX[ 16 ] = |
---|
87 | { |
---|
88 | 0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 1, 2, 3, 2, 3, 3 |
---|
89 | }; |
---|
90 | static int diagScanY[ 16 ] = |
---|
91 | { |
---|
92 | 0, 1, 0, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 3, 2, 3 |
---|
93 | }; |
---|
94 | |
---|
95 | Int j; |
---|
96 | // 4x16 scan |
---|
97 | for (i = 0; i < 4; i++) |
---|
98 | { |
---|
99 | for (j = 0; j < 16; j++) |
---|
100 | { |
---|
101 | g_sigScanNSQT[ 0 ][ 16 * i + j ] = 16 * i + 4 * diagScanY[ j ] + diagScanX[ j ]; |
---|
102 | } |
---|
103 | } |
---|
104 | |
---|
105 | // 8x32 scan |
---|
106 | for (i = 0; i < 16; i++) |
---|
107 | { |
---|
108 | Int x = g_sigCGScanNSQT[ 1 ][ i ] & 1; |
---|
109 | Int y = g_sigCGScanNSQT[ 1 ][ i ] >> 1; |
---|
110 | |
---|
111 | for (j = 0; j < 16; j++) |
---|
112 | { |
---|
113 | g_sigScanNSQT[ 1 ][ 16 * i + j ] = 32 * y + 4 * x + 8 * diagScanY[ j ] + diagScanX[ j ]; |
---|
114 | } |
---|
115 | } |
---|
116 | |
---|
117 | // 16x4 scan |
---|
118 | for (i = 0; i < 4; i++) |
---|
119 | { |
---|
120 | for (j = 0; j < 16; j++) |
---|
121 | { |
---|
122 | g_sigScanNSQT[ 2 ][ 16 * i + j ] = 4 * i + 16 * diagScanY[ j ] + diagScanX[ j ]; |
---|
123 | } |
---|
124 | } |
---|
125 | |
---|
126 | // 32x8 scan |
---|
127 | for (i = 0; i < 16; i++) |
---|
128 | { |
---|
129 | Int x = g_sigCGScanNSQT[ 3 ][ i ] & 7; |
---|
130 | Int y = g_sigCGScanNSQT[ 3 ][ i ] >> 3; |
---|
131 | |
---|
132 | for (j = 0; j < 16; j++) |
---|
133 | { |
---|
134 | g_sigScanNSQT[ 3 ][ 16 * i + j ] = 128 * y + 4 * x + 32 * diagScanY[ j ] + diagScanX[ j ]; |
---|
135 | } |
---|
136 | } |
---|
137 | } |
---|
138 | |
---|
139 | Void destroyROM() |
---|
140 | { |
---|
141 | Int i; |
---|
142 | |
---|
143 | for ( i=0; i<MAX_CU_DEPTH; i++ ) |
---|
144 | { |
---|
145 | delete[] g_auiFrameScanXY[i]; |
---|
146 | delete[] g_auiFrameScanX [i]; |
---|
147 | delete[] g_auiFrameScanY [i]; |
---|
148 | delete[] g_auiSigLastScan[0][i]; |
---|
149 | delete[] g_auiSigLastScan[1][i]; |
---|
150 | delete[] g_auiSigLastScan[2][i]; |
---|
151 | delete[] g_auiSigLastScan[3][i]; |
---|
152 | } |
---|
153 | for (i = 0; i < 4; i++) |
---|
154 | { |
---|
155 | delete[] g_sigScanNSQT[ i ]; |
---|
156 | } |
---|
157 | |
---|
158 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
159 | if ( !g_aacWedgeLists.empty() ) |
---|
160 | { |
---|
161 | for ( UInt ui = 0; ui < g_aacWedgeLists.size(); ui++ ) |
---|
162 | { |
---|
163 | g_aacWedgeLists[ui].clear(); |
---|
164 | } |
---|
165 | g_aacWedgeLists.clear(); |
---|
166 | } |
---|
167 | |
---|
168 | if ( !g_aacWedgeRefLists.empty() ) |
---|
169 | { |
---|
170 | for ( UInt ui = 0; ui < g_aacWedgeRefLists.size(); ui++ ) |
---|
171 | { |
---|
172 | g_aacWedgeRefLists[ui].clear(); |
---|
173 | } |
---|
174 | g_aacWedgeRefLists.clear(); |
---|
175 | } |
---|
176 | #if HHIQC_DMMFASTSEARCH_B0039 |
---|
177 | if ( !g_aacWedgeNodeLists.empty() ) |
---|
178 | { |
---|
179 | for ( UInt ui = 0; ui < g_aacWedgeNodeLists.size(); ui++ ) |
---|
180 | { |
---|
181 | g_aacWedgeNodeLists[ui].clear(); |
---|
182 | } |
---|
183 | g_aacWedgeNodeLists.clear(); |
---|
184 | } |
---|
185 | #endif |
---|
186 | #endif |
---|
187 | } |
---|
188 | |
---|
189 | // ==================================================================================================================== |
---|
190 | // Data structure related table & variable |
---|
191 | // ==================================================================================================================== |
---|
192 | |
---|
193 | UInt g_uiMaxCUWidth = MAX_CU_SIZE; |
---|
194 | UInt g_uiMaxCUHeight = MAX_CU_SIZE; |
---|
195 | UInt g_uiMaxCUDepth = MAX_CU_DEPTH; |
---|
196 | UInt g_uiAddCUDepth = 0; |
---|
197 | |
---|
198 | UInt g_auiZscanToRaster [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
199 | UInt g_auiRasterToZscan [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
200 | UInt g_auiRasterToPelX [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
201 | UInt g_auiRasterToPelY [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
202 | UInt g_motionRefer [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
203 | |
---|
204 | UInt g_auiPUOffset[8] = { 0, 8, 4, 4, 2, 10, 1, 5}; |
---|
205 | |
---|
206 | Void initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx ) |
---|
207 | { |
---|
208 | Int iStride = 1 << ( iMaxDepth - 1 ); |
---|
209 | |
---|
210 | if ( iDepth == iMaxDepth ) |
---|
211 | { |
---|
212 | rpuiCurrIdx[0] = uiStartVal; |
---|
213 | rpuiCurrIdx++; |
---|
214 | } |
---|
215 | else |
---|
216 | { |
---|
217 | Int iStep = iStride >> iDepth; |
---|
218 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal, rpuiCurrIdx ); |
---|
219 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep, rpuiCurrIdx ); |
---|
220 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride, rpuiCurrIdx ); |
---|
221 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride+iStep, rpuiCurrIdx ); |
---|
222 | } |
---|
223 | } |
---|
224 | |
---|
225 | Void initRasterToZscan ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
226 | { |
---|
227 | UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 ); |
---|
228 | UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 ); |
---|
229 | |
---|
230 | UInt uiNumPartInWidth = (UInt)uiMaxCUWidth / uiMinCUWidth; |
---|
231 | UInt uiNumPartInHeight = (UInt)uiMaxCUHeight / uiMinCUHeight; |
---|
232 | |
---|
233 | for ( UInt i = 0; i < uiNumPartInWidth*uiNumPartInHeight; i++ ) |
---|
234 | { |
---|
235 | g_auiRasterToZscan[ g_auiZscanToRaster[i] ] = i; |
---|
236 | } |
---|
237 | } |
---|
238 | |
---|
239 | /** generate motion data compression mapping table |
---|
240 | * \param uiMaxCUWidth, width of LCU |
---|
241 | * \param uiMaxCUHeight, hight of LCU |
---|
242 | * \param uiMaxDepth, max depth of LCU |
---|
243 | * \returns Void |
---|
244 | */ |
---|
245 | Void initMotionReferIdx ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
246 | { |
---|
247 | Int minCUWidth = (Int)uiMaxCUWidth >> ( (Int)uiMaxDepth - 1 ); |
---|
248 | Int minCUHeight = (Int)uiMaxCUHeight >> ( (Int)uiMaxDepth - 1 ); |
---|
249 | |
---|
250 | Int numPartInWidth = (Int)uiMaxCUWidth / (Int)minCUWidth; |
---|
251 | Int numPartInHeight = (Int)uiMaxCUHeight / (Int)minCUHeight; |
---|
252 | |
---|
253 | for ( Int i = 0; i < numPartInWidth*numPartInHeight; i++ ) |
---|
254 | { |
---|
255 | g_motionRefer[i] = i; |
---|
256 | } |
---|
257 | |
---|
258 | Int compressionNum = 2; |
---|
259 | |
---|
260 | for ( Int i = numPartInWidth*(numPartInHeight-1); i < numPartInWidth*numPartInHeight; i += compressionNum*2) |
---|
261 | { |
---|
262 | for ( Int j = 1; j < compressionNum; j++ ) |
---|
263 | { |
---|
264 | g_motionRefer[g_auiRasterToZscan[i+j]] = g_auiRasterToZscan[i]; |
---|
265 | } |
---|
266 | } |
---|
267 | |
---|
268 | for ( Int i = numPartInWidth*(numPartInHeight-1)+compressionNum*2-1; i < numPartInWidth*numPartInHeight; i += compressionNum*2) |
---|
269 | { |
---|
270 | for ( Int j = 1; j < compressionNum; j++ ) |
---|
271 | { |
---|
272 | g_motionRefer[g_auiRasterToZscan[i-j]] = g_auiRasterToZscan[i]; |
---|
273 | } |
---|
274 | } |
---|
275 | } |
---|
276 | |
---|
277 | Void initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
278 | { |
---|
279 | UInt i; |
---|
280 | |
---|
281 | UInt* uiTempX = &g_auiRasterToPelX[0]; |
---|
282 | UInt* uiTempY = &g_auiRasterToPelY[0]; |
---|
283 | |
---|
284 | UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 ); |
---|
285 | UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 ); |
---|
286 | |
---|
287 | UInt uiNumPartInWidth = uiMaxCUWidth / uiMinCUWidth; |
---|
288 | UInt uiNumPartInHeight = uiMaxCUHeight / uiMinCUHeight; |
---|
289 | |
---|
290 | uiTempX[0] = 0; uiTempX++; |
---|
291 | for ( i = 1; i < uiNumPartInWidth; i++ ) |
---|
292 | { |
---|
293 | uiTempX[0] = uiTempX[-1] + uiMinCUWidth; uiTempX++; |
---|
294 | } |
---|
295 | for ( i = 1; i < uiNumPartInHeight; i++ ) |
---|
296 | { |
---|
297 | memcpy(uiTempX, uiTempX-uiNumPartInWidth, sizeof(UInt)*uiNumPartInWidth); |
---|
298 | uiTempX += uiNumPartInWidth; |
---|
299 | } |
---|
300 | |
---|
301 | for ( i = 1; i < uiNumPartInWidth*uiNumPartInHeight; i++ ) |
---|
302 | { |
---|
303 | uiTempY[i] = ( i / uiNumPartInWidth ) * uiMinCUWidth; |
---|
304 | } |
---|
305 | }; |
---|
306 | |
---|
307 | #if RWTH_SDC_DLT_B0036 |
---|
308 | #if SAIT_SDC_C0096 |
---|
309 | UInt g_auiSDCPredModes[RWTH_SDC_NUM_PRED_MODES] = { DC_IDX, DMM_WEDGE_FULL_IDX, PLANAR_IDX }; |
---|
310 | #else |
---|
311 | UInt g_auiSDCPredModes[RWTH_SDC_NUM_PRED_MODES] = { DC_IDX, DMM_WEDGE_FULL_IDX, DMM_WEDGE_PREDDIR_IDX, PLANAR_IDX }; |
---|
312 | #endif |
---|
313 | #endif |
---|
314 | |
---|
315 | Int g_quantScales[6] = |
---|
316 | { |
---|
317 | 26214,23302,20560,18396,16384,14564 |
---|
318 | }; |
---|
319 | |
---|
320 | Int g_invQuantScales[6] = |
---|
321 | { |
---|
322 | 40,45,51,57,64,72 |
---|
323 | }; |
---|
324 | |
---|
325 | const short g_aiT4[4][4] = |
---|
326 | { |
---|
327 | { 64, 64, 64, 64}, |
---|
328 | { 83, 36,-36,-83}, |
---|
329 | { 64,-64,-64, 64}, |
---|
330 | { 36,-83, 83,-36} |
---|
331 | }; |
---|
332 | |
---|
333 | const short g_aiT8[8][8] = |
---|
334 | { |
---|
335 | { 64, 64, 64, 64, 64, 64, 64, 64}, |
---|
336 | { 89, 75, 50, 18,-18,-50,-75,-89}, |
---|
337 | { 83, 36,-36,-83,-83,-36, 36, 83}, |
---|
338 | { 75,-18,-89,-50, 50, 89, 18,-75}, |
---|
339 | { 64,-64,-64, 64, 64,-64,-64, 64}, |
---|
340 | { 50,-89, 18, 75,-75,-18, 89,-50}, |
---|
341 | { 36,-83, 83,-36,-36, 83,-83, 36}, |
---|
342 | { 18,-50, 75,-89, 89,-75, 50,-18} |
---|
343 | }; |
---|
344 | |
---|
345 | const short g_aiT16[16][16] = |
---|
346 | { |
---|
347 | { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}, |
---|
348 | { 90, 87, 80, 70, 57, 43, 25, 9, -9,-25,-43,-57,-70,-80,-87,-90}, |
---|
349 | { 89, 75, 50, 18,-18,-50,-75,-89,-89,-75,-50,-18, 18, 50, 75, 89}, |
---|
350 | { 87, 57, 9,-43,-80,-90,-70,-25, 25, 70, 90, 80, 43, -9,-57,-87}, |
---|
351 | { 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83}, |
---|
352 | { 80, 9,-70,-87,-25, 57, 90, 43,-43,-90,-57, 25, 87, 70, -9,-80}, |
---|
353 | { 75,-18,-89,-50, 50, 89, 18,-75,-75, 18, 89, 50,-50,-89,-18, 75}, |
---|
354 | { 70,-43,-87, 9, 90, 25,-80,-57, 57, 80,-25,-90, -9, 87, 43,-70}, |
---|
355 | { 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64}, |
---|
356 | { 57,-80,-25, 90, -9,-87, 43, 70,-70,-43, 87, 9,-90, 25, 80,-57}, |
---|
357 | { 50,-89, 18, 75,-75,-18, 89,-50,-50, 89,-18,-75, 75, 18,-89, 50}, |
---|
358 | { 43,-90, 57, 25,-87, 70, 9,-80, 80, -9,-70, 87,-25,-57, 90,-43}, |
---|
359 | { 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36}, |
---|
360 | { 25,-70, 90,-80, 43, 9,-57, 87,-87, 57, -9,-43, 80,-90, 70,-25}, |
---|
361 | { 18,-50, 75,-89, 89,-75, 50,-18,-18, 50,-75, 89,-89, 75,-50, 18}, |
---|
362 | { 9,-25, 43,-57, 70,-80, 87,-90, 90,-87, 80,-70, 57,-43, 25, -9} |
---|
363 | }; |
---|
364 | |
---|
365 | const short g_aiT32[32][32] = |
---|
366 | { |
---|
367 | { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}, |
---|
368 | { 90, 90, 88, 85, 82, 78, 73, 67, 61, 54, 46, 38, 31, 22, 13, 4, -4,-13,-22,-31,-38,-46,-54,-61,-67,-73,-78,-82,-85,-88,-90,-90}, |
---|
369 | { 90, 87, 80, 70, 57, 43, 25, 9, -9,-25,-43,-57,-70,-80,-87,-90,-90,-87,-80,-70,-57,-43,-25, -9, 9, 25, 43, 57, 70, 80, 87, 90}, |
---|
370 | { 90, 82, 67, 46, 22, -4,-31,-54,-73,-85,-90,-88,-78,-61,-38,-13, 13, 38, 61, 78, 88, 90, 85, 73, 54, 31, 4,-22,-46,-67,-82,-90}, |
---|
371 | { 89, 75, 50, 18,-18,-50,-75,-89,-89,-75,-50,-18, 18, 50, 75, 89, 89, 75, 50, 18,-18,-50,-75,-89,-89,-75,-50,-18, 18, 50, 75, 89}, |
---|
372 | { 88, 67, 31,-13,-54,-82,-90,-78,-46, -4, 38, 73, 90, 85, 61, 22,-22,-61,-85,-90,-73,-38, 4, 46, 78, 90, 82, 54, 13,-31,-67,-88}, |
---|
373 | { 87, 57, 9,-43,-80,-90,-70,-25, 25, 70, 90, 80, 43, -9,-57,-87,-87,-57, -9, 43, 80, 90, 70, 25,-25,-70,-90,-80,-43, 9, 57, 87}, |
---|
374 | { 85, 46,-13,-67,-90,-73,-22, 38, 82, 88, 54, -4,-61,-90,-78,-31, 31, 78, 90, 61, 4,-54,-88,-82,-38, 22, 73, 90, 67, 13,-46,-85}, |
---|
375 | { 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83}, |
---|
376 | { 82, 22,-54,-90,-61, 13, 78, 85, 31,-46,-90,-67, 4, 73, 88, 38,-38,-88,-73, -4, 67, 90, 46,-31,-85,-78,-13, 61, 90, 54,-22,-82}, |
---|
377 | { 80, 9,-70,-87,-25, 57, 90, 43,-43,-90,-57, 25, 87, 70, -9,-80,-80, -9, 70, 87, 25,-57,-90,-43, 43, 90, 57,-25,-87,-70, 9, 80}, |
---|
378 | { 78, -4,-82,-73, 13, 85, 67,-22,-88,-61, 31, 90, 54,-38,-90,-46, 46, 90, 38,-54,-90,-31, 61, 88, 22,-67,-85,-13, 73, 82, 4,-78}, |
---|
379 | { 75,-18,-89,-50, 50, 89, 18,-75,-75, 18, 89, 50,-50,-89,-18, 75, 75,-18,-89,-50, 50, 89, 18,-75,-75, 18, 89, 50,-50,-89,-18, 75}, |
---|
380 | { 73,-31,-90,-22, 78, 67,-38,-90,-13, 82, 61,-46,-88, -4, 85, 54,-54,-85, 4, 88, 46,-61,-82, 13, 90, 38,-67,-78, 22, 90, 31,-73}, |
---|
381 | { 70,-43,-87, 9, 90, 25,-80,-57, 57, 80,-25,-90, -9, 87, 43,-70,-70, 43, 87, -9,-90,-25, 80, 57,-57,-80, 25, 90, 9,-87,-43, 70}, |
---|
382 | { 67,-54,-78, 38, 85,-22,-90, 4, 90, 13,-88,-31, 82, 46,-73,-61, 61, 73,-46,-82, 31, 88,-13,-90, -4, 90, 22,-85,-38, 78, 54,-67}, |
---|
383 | { 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64}, |
---|
384 | { 61,-73,-46, 82, 31,-88,-13, 90, -4,-90, 22, 85,-38,-78, 54, 67,-67,-54, 78, 38,-85,-22, 90, 4,-90, 13, 88,-31,-82, 46, 73,-61}, |
---|
385 | { 57,-80,-25, 90, -9,-87, 43, 70,-70,-43, 87, 9,-90, 25, 80,-57,-57, 80, 25,-90, 9, 87,-43,-70, 70, 43,-87, -9, 90,-25,-80, 57}, |
---|
386 | { 54,-85, -4, 88,-46,-61, 82, 13,-90, 38, 67,-78,-22, 90,-31,-73, 73, 31,-90, 22, 78,-67,-38, 90,-13,-82, 61, 46,-88, 4, 85,-54}, |
---|
387 | { 50,-89, 18, 75,-75,-18, 89,-50,-50, 89,-18,-75, 75, 18,-89, 50, 50,-89, 18, 75,-75,-18, 89,-50,-50, 89,-18,-75, 75, 18,-89, 50}, |
---|
388 | { 46,-90, 38, 54,-90, 31, 61,-88, 22, 67,-85, 13, 73,-82, 4, 78,-78, -4, 82,-73,-13, 85,-67,-22, 88,-61,-31, 90,-54,-38, 90,-46}, |
---|
389 | { 43,-90, 57, 25,-87, 70, 9,-80, 80, -9,-70, 87,-25,-57, 90,-43,-43, 90,-57,-25, 87,-70, -9, 80,-80, 9, 70,-87, 25, 57,-90, 43}, |
---|
390 | { 38,-88, 73, -4,-67, 90,-46,-31, 85,-78, 13, 61,-90, 54, 22,-82, 82,-22,-54, 90,-61,-13, 78,-85, 31, 46,-90, 67, 4,-73, 88,-38}, |
---|
391 | { 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36}, |
---|
392 | { 31,-78, 90,-61, 4, 54,-88, 82,-38,-22, 73,-90, 67,-13,-46, 85,-85, 46, 13,-67, 90,-73, 22, 38,-82, 88,-54, -4, 61,-90, 78,-31}, |
---|
393 | { 25,-70, 90,-80, 43, 9,-57, 87,-87, 57, -9,-43, 80,-90, 70,-25,-25, 70,-90, 80,-43, -9, 57,-87, 87,-57, 9, 43,-80, 90,-70, 25}, |
---|
394 | { 22,-61, 85,-90, 73,-38, -4, 46,-78, 90,-82, 54,-13,-31, 67,-88, 88,-67, 31, 13,-54, 82,-90, 78,-46, 4, 38,-73, 90,-85, 61,-22}, |
---|
395 | { 18,-50, 75,-89, 89,-75, 50,-18,-18, 50,-75, 89,-89, 75,-50, 18, 18,-50, 75,-89, 89,-75, 50,-18,-18, 50,-75, 89,-89, 75,-50, 18}, |
---|
396 | { 13,-38, 61,-78, 88,-90, 85,-73, 54,-31, 4, 22,-46, 67,-82, 90,-90, 82,-67, 46,-22, -4, 31,-54, 73,-85, 90,-88, 78,-61, 38,-13}, |
---|
397 | { 9,-25, 43,-57, 70,-80, 87,-90, 90,-87, 80,-70, 57,-43, 25, -9, -9, 25,-43, 57,-70, 80,-87, 90,-90, 87,-80, 70,-57, 43,-25, 9}, |
---|
398 | { 4,-13, 22,-31, 38,-46, 54,-61, 67,-73, 78,-82, 85,-88, 90,-90, 90,-90, 88,-85, 82,-78, 73,-67, 61,-54, 46,-38, 31,-22, 13, -4} |
---|
399 | }; |
---|
400 | |
---|
401 | const UChar g_aucChromaScale[52]= |
---|
402 | { |
---|
403 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11, |
---|
404 | 12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27, |
---|
405 | 28,29,29,30,31,32,32,33,34,34,35,35,36,36,37,37, |
---|
406 | 37,38,38,38,39,39,39,39 |
---|
407 | }; |
---|
408 | |
---|
409 | |
---|
410 | // Mode-Dependent DCT/DST |
---|
411 | const short g_as_DST_MAT_4 [4][4]= |
---|
412 | { |
---|
413 | {29, 55, 74, 84}, |
---|
414 | {74, 74, 0 , -74}, |
---|
415 | {84, -29, -74, 55}, |
---|
416 | {55, -84, 74, -29}, |
---|
417 | }; |
---|
418 | |
---|
419 | #if !LOGI_INTRA_NAME_3MPM |
---|
420 | // Mapping each Unified Directional Intra prediction direction to DCT/DST transform |
---|
421 | // 0 implies use DCT, 1 implies DST |
---|
422 | |
---|
423 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
424 | const UChar g_aucDCTDSTMode_Vert[NUM_INTRA_MODE+NUM_DMM_MODE] = |
---|
425 | #else |
---|
426 | const UChar g_aucDCTDSTMode_Vert[NUM_INTRA_MODE] = |
---|
427 | #endif |
---|
428 | { //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
---|
429 | 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 |
---|
430 | #if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX |
---|
431 | , 0, 0, 0, 0, 0, 0, 0, 0 |
---|
432 | #elif HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
433 | , 0, 0, 0, 0 |
---|
434 | #endif |
---|
435 | }; |
---|
436 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
437 | const UChar g_aucDCTDSTMode_Hor[NUM_INTRA_MODE+NUM_DMM_MODE] = |
---|
438 | #else |
---|
439 | const UChar g_aucDCTDSTMode_Hor[NUM_INTRA_MODE] = |
---|
440 | #endif |
---|
441 | { //0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
---|
442 | 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0 |
---|
443 | #if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX |
---|
444 | , 0, 0, 0, 0, 0, 0, 0, 0 |
---|
445 | #elif HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
446 | , 0, 0, 0, 0 |
---|
447 | #endif |
---|
448 | }; |
---|
449 | #endif |
---|
450 | |
---|
451 | |
---|
452 | // ==================================================================================================================== |
---|
453 | // ADI |
---|
454 | // ==================================================================================================================== |
---|
455 | |
---|
456 | #if FAST_UDI_USE_MPM |
---|
457 | const UChar g_aucIntraModeNumFast[7] = |
---|
458 | { |
---|
459 | 3, // 2x2 |
---|
460 | 8, // 4x4 |
---|
461 | 8, // 8x8 |
---|
462 | 3, // 16x16 |
---|
463 | 3, // 32x32 |
---|
464 | 3, // 64x64 |
---|
465 | 3 // 128x128 |
---|
466 | }; |
---|
467 | #else // FAST_UDI_USE_MPM |
---|
468 | const UChar g_aucIntraModeNumFast[7] = |
---|
469 | { |
---|
470 | 3, // 2x2 |
---|
471 | 9, // 4x4 |
---|
472 | 9, // 8x8 |
---|
473 | 4, // 16x16 33 |
---|
474 | 4, // 32x32 33 |
---|
475 | 5, // 64x64 33 |
---|
476 | 4 // 128x128 33 |
---|
477 | }; |
---|
478 | #endif // FAST_UDI_USE_MPM |
---|
479 | |
---|
480 | // chroma |
---|
481 | |
---|
482 | const UChar g_aucConvertTxtTypeToIdx[4] = { 0, 1, 1, 2 }; |
---|
483 | |
---|
484 | #if !LOGI_INTRA_NAME_3MPM |
---|
485 | // ==================================================================================================================== |
---|
486 | // Angular Intra prediction |
---|
487 | // ==================================================================================================================== |
---|
488 | |
---|
489 | // g_aucAngIntraModeOrder |
---|
490 | // Indexing this array with the mode indicated in the bitstream |
---|
491 | // gives a logical index used in the prediction functions. |
---|
492 | const UChar g_aucAngIntraModeOrder[NUM_INTRA_MODE] = |
---|
493 | { // ModeOrder LogicalOrderInPredFunctions |
---|
494 | 34, // PLANAR_IDX PLANAR PLANAR |
---|
495 | 9, // 0 VER DC |
---|
496 | 25, // 1 HOR VER-8 (diagonal from top-left to bottom-right = HOR-8) |
---|
497 | 0, // 2 DC VER-7 |
---|
498 | 1, // 4 VER-8 VER-6 |
---|
499 | 5, // 5 VER-4 VER-5 |
---|
500 | 13, // 6 VER+4 VER-4 |
---|
501 | 17, // 7 VER+8 VER-3 |
---|
502 | 21, // 8 HOR-4 VER-2 |
---|
503 | 29, // 9 HOR+4 VER-1 |
---|
504 | 33, // 10 HOR+8 VER |
---|
505 | 3, // 11 VER-6 VER+1 |
---|
506 | 7, // 12 VER-2 VER+2 |
---|
507 | 11, // 13 VER+2 VER+3 |
---|
508 | 15, // 14 VER+6 VER+4 |
---|
509 | 19, // 15 HOR-6 VER+5 |
---|
510 | 23, // 16 HOR-2 VER+6 |
---|
511 | 27, // 17 HOR+2 VER+7 |
---|
512 | 31, // 18 HOR+6 VER+8 |
---|
513 | 2, // 19 VER-7 HOR-7 |
---|
514 | 4, // 20 VER-5 HOR-6 |
---|
515 | 6, // 21 VER-3 HOR-5 |
---|
516 | 8, // 22 VER-1 HOR-4 |
---|
517 | 10, // 23 VER+1 HOR-3 |
---|
518 | 12, // 24 VER+3 HOR-2 |
---|
519 | 14, // 25 VER+5 HOR-1 |
---|
520 | 16, // 26 VER+7 HOR |
---|
521 | 18, // 27 HOR-7 HOR+1 |
---|
522 | 20, // 28 HOR-5 HOR+2 |
---|
523 | 22, // 29 HOR-3 HOR+3 |
---|
524 | 24, // 30 HOR-1 HOR+4 |
---|
525 | 26, // 31 HOR+1 HOR+5 |
---|
526 | 28, // 32 HOR+3 HOR+6 |
---|
527 | 30, // 33 HOR+5 HOR+7 |
---|
528 | 32, // 34 HOR+7 HOR+8 |
---|
529 | 0, // LM_CHROMA_IDX |
---|
530 | }; |
---|
531 | |
---|
532 | const UChar g_aucIntraModeNumAng[7] = |
---|
533 | { |
---|
534 | 4, // 2x2 |
---|
535 | 18, // 4x4 |
---|
536 | 35, // 8x8 |
---|
537 | 35, // 16x16 |
---|
538 | 35, // 32x32 |
---|
539 | 35, // 64x64 |
---|
540 | 6 // 128x128 |
---|
541 | }; |
---|
542 | |
---|
543 | const UChar g_aucIntraModeBitsAng[7] = |
---|
544 | { |
---|
545 | 2, // 2x2 3 1+1 |
---|
546 | 5, // 4x4 17 4+1 |
---|
547 | 6, // 8x8 34 5+esc |
---|
548 | 6, // 16x16 34 5+esc |
---|
549 | 6, // 32x32 34 5+esc |
---|
550 | 6, // 64x64 34 5+esc |
---|
551 | 3 // 128x128 5 2+1 |
---|
552 | }; |
---|
553 | #endif |
---|
554 | |
---|
555 | // ==================================================================================================================== |
---|
556 | // Bit-depth |
---|
557 | // ==================================================================================================================== |
---|
558 | |
---|
559 | UInt g_uiBitDepth = 8; // base bit-depth |
---|
560 | UInt g_uiBitIncrement = 0; // increments |
---|
561 | UInt g_uiIBDI_MAX = 255; // max. value after IBDI |
---|
562 | UInt g_uiBASE_MAX = 255; // max. value before IBDI |
---|
563 | |
---|
564 | UInt g_uiPCMBitDepthLuma = 8; // PCM bit-depth |
---|
565 | UInt g_uiPCMBitDepthChroma = 8; // PCM bit-depth |
---|
566 | |
---|
567 | // ==================================================================================================================== |
---|
568 | // Depth model modes |
---|
569 | // ==================================================================================================================== |
---|
570 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
571 | Int g_iDeltaDCsQuantOffset = 0; |
---|
572 | |
---|
573 | const WedgeResolution g_aeWedgeResolutionList[5] = |
---|
574 | { |
---|
575 | HALF_PEL, // 4x4 |
---|
576 | HALF_PEL, // 8x8 |
---|
577 | FULL_PEL, // 16x16 |
---|
578 | DOUBLE_PEL, // 32x32 |
---|
579 | DOUBLE_PEL // 64x64 |
---|
580 | }; |
---|
581 | |
---|
582 | const UChar g_aucWedgeFullBitsListIdx[7] = |
---|
583 | { |
---|
584 | 0, // 2x2 |
---|
585 | 7, // 4x4 WedgeListSize[ HALF_PEL] 86 |
---|
586 | 10, // 8x8 WedgeListSize[ HALF_PEL] 782 |
---|
587 | 11, // 16x16 WedgeListSize[ FULL_PEL] 1394 |
---|
588 | 11, // 32x32 WedgeListSize[DOUBLE_PEL] 1503 |
---|
589 | 13, // 64x64 WedgeListSize[DOUBLE_PEL] 6079 |
---|
590 | 0 // 128x128 |
---|
591 | }; |
---|
592 | |
---|
593 | #if LGE_DMM3_SIMP_C0044 |
---|
594 | const UChar g_aucWedgeTexPredBitsListIdx[7] = |
---|
595 | { |
---|
596 | 0, // 2x2 |
---|
597 | 6, // 4x4 |
---|
598 | 9, // 8x8 |
---|
599 | 9, // 16x16 |
---|
600 | 9, // 32x32 |
---|
601 | 0, // 64x64 |
---|
602 | 0 // 128x128 |
---|
603 | }; |
---|
604 | #endif |
---|
605 | |
---|
606 | const UChar g_aucIntraSizeIdxToWedgeSize[7] = |
---|
607 | { |
---|
608 | 2, |
---|
609 | 4, |
---|
610 | 8, |
---|
611 | 16, |
---|
612 | 32, |
---|
613 | 64, |
---|
614 | 128 |
---|
615 | }; |
---|
616 | #endif |
---|
617 | |
---|
618 | // ==================================================================================================================== |
---|
619 | // Misc. |
---|
620 | // ==================================================================================================================== |
---|
621 | |
---|
622 | Char g_aucConvertToBit [ MAX_CU_SIZE+1 ]; |
---|
623 | |
---|
624 | #if ENC_DEC_TRACE |
---|
625 | FILE* g_hTrace = NULL; |
---|
626 | const Bool g_bEncDecTraceEnable = true; |
---|
627 | const Bool g_bEncDecTraceDisable = false; |
---|
628 | Bool g_bJustDoIt = false; |
---|
629 | UInt64 g_nSymbolCounter = 0; |
---|
630 | #endif |
---|
631 | // ==================================================================================================================== |
---|
632 | // Scanning order & context model mapping |
---|
633 | // ==================================================================================================================== |
---|
634 | |
---|
635 | // scanning order table |
---|
636 | UInt* g_auiFrameScanXY[ MAX_CU_DEPTH ]; |
---|
637 | UInt* g_auiFrameScanX [ MAX_CU_DEPTH ]; |
---|
638 | UInt* g_auiFrameScanY [ MAX_CU_DEPTH ]; |
---|
639 | UInt* g_auiSigLastScan[4][ MAX_CU_DEPTH ]; |
---|
640 | UInt *g_sigScanNSQT[ 4 ]; // scan for non-square partitions |
---|
641 | UInt g_sigCGScanNSQT[ 4 ][ 16 ] = |
---|
642 | { |
---|
643 | { 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
---|
644 | { 0, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15 }, |
---|
645 | { 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, |
---|
646 | { 0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15 } |
---|
647 | }; |
---|
648 | |
---|
649 | #if MULTILEVEL_SIGMAP_EXT |
---|
650 | const UInt g_sigLastScan8x8[ 4 ][ 4 ] = |
---|
651 | { |
---|
652 | {0, 1, 2, 3}, |
---|
653 | {0, 1, 2, 3}, |
---|
654 | {0, 1, 2, 3}, |
---|
655 | {0, 2, 1, 3} |
---|
656 | }; |
---|
657 | UInt g_sigLastScanCG32x32[ 64 ]; |
---|
658 | #endif |
---|
659 | |
---|
660 | UInt* g_auiNonSquareSigLastScan[ 4 ]; |
---|
661 | |
---|
662 | const UInt g_uiMinInGroup[ 10 ] = {0,1,2,3,4,6,8,12,16,24}; |
---|
663 | const UInt g_uiGroupIdx[ 32 ] = {0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9}; |
---|
664 | #if LAST_CTX_REDUCTION |
---|
665 | const UInt g_uiLastCtx[ 28 ] = |
---|
666 | { |
---|
667 | 0, 1, 2, 2, // 4x4 4 |
---|
668 | 3, 4, 5, 5, 2, 2, // 8x8 6 |
---|
669 | 6, 7, 8, 8, 9, 9, 2, 2, // 16x16 8 |
---|
670 | 10, 11, 12, 12, 13, 13, 14, 14, 2, 2 // 32x32 10 |
---|
671 | }; |
---|
672 | #else |
---|
673 | const UInt g_uiLastCtx[ 28 ] = |
---|
674 | { |
---|
675 | 0, 1, 2, 2, // 4x4 4 |
---|
676 | 3, 4, 5, 5, 6, 6, // 8x8 6 |
---|
677 | 7, 8, 9, 9, 10, 10, 11, 11, // 16x16 8 |
---|
678 | 12, 13, 14, 14, 15, 15, 16, 16, 17, 17 // 32x32 10 |
---|
679 | }; |
---|
680 | #endif |
---|
681 | |
---|
682 | // Rice parameters for absolute transform levels |
---|
683 | #if EIGHT_BITS_RICE_CODE |
---|
684 | const UInt g_auiGoRiceRange[5] = |
---|
685 | { |
---|
686 | 7, 14, 26, 46, 78 |
---|
687 | }; |
---|
688 | |
---|
689 | const UInt g_auiGoRicePrefixLen[5] = |
---|
690 | { |
---|
691 | 8, 7, 6, 5, 4 |
---|
692 | }; |
---|
693 | #else |
---|
694 | const UInt g_auiGoRiceRange[4] = |
---|
695 | { |
---|
696 | 7, 20, 42, 70 |
---|
697 | }; |
---|
698 | |
---|
699 | const UInt g_auiGoRicePrefixLen[4] = |
---|
700 | { |
---|
701 | 8, 10, 10, 8 |
---|
702 | }; |
---|
703 | #endif |
---|
704 | |
---|
705 | #if EIGHT_BITS_RICE_CODE |
---|
706 | const UInt g_aauiGoRiceUpdate[5][24] = |
---|
707 | { |
---|
708 | #if RESTRICT_GR1GR2FLAG_NUMBER |
---|
709 | { |
---|
710 | 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 |
---|
711 | }, |
---|
712 | { |
---|
713 | 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 |
---|
714 | }, |
---|
715 | { |
---|
716 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 |
---|
717 | }, |
---|
718 | { |
---|
719 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 |
---|
720 | }, |
---|
721 | { |
---|
722 | 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 |
---|
723 | } |
---|
724 | #else |
---|
725 | { |
---|
726 | 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 |
---|
727 | }, |
---|
728 | { |
---|
729 | 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 |
---|
730 | }, |
---|
731 | { |
---|
732 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 |
---|
733 | }, |
---|
734 | { |
---|
735 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4 |
---|
736 | }, |
---|
737 | { |
---|
738 | 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 |
---|
739 | } |
---|
740 | #endif |
---|
741 | }; |
---|
742 | #else |
---|
743 | const UInt g_aauiGoRiceUpdate[4][16] = |
---|
744 | { |
---|
745 | #if RESTRICT_GR1GR2FLAG_NUMBER |
---|
746 | { |
---|
747 | 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, |
---|
748 | }, |
---|
749 | { |
---|
750 | 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, |
---|
751 | }, |
---|
752 | { |
---|
753 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, |
---|
754 | }, |
---|
755 | { |
---|
756 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, |
---|
757 | } |
---|
758 | #else |
---|
759 | { |
---|
760 | 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 |
---|
761 | }, |
---|
762 | { |
---|
763 | 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 |
---|
764 | }, |
---|
765 | { |
---|
766 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 |
---|
767 | }, |
---|
768 | { |
---|
769 | 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 |
---|
770 | } |
---|
771 | #endif |
---|
772 | }; |
---|
773 | #endif |
---|
774 | |
---|
775 | // initialize g_auiFrameScanXY |
---|
776 | Void initFrameScanXY( UInt* pBuff, UInt* pBuffX, UInt* pBuffY, Int iWidth, Int iHeight ) |
---|
777 | { |
---|
778 | Int x, y, c = 0; |
---|
779 | |
---|
780 | // starting point |
---|
781 | pBuffX[ c ] = 0; |
---|
782 | pBuffY[ c ] = 0; |
---|
783 | pBuff[ c++ ] = 0; |
---|
784 | |
---|
785 | // loop |
---|
786 | x=1; y=0; |
---|
787 | while (1) |
---|
788 | { |
---|
789 | // decrease loop |
---|
790 | while ( x>=0 ) |
---|
791 | { |
---|
792 | if ( x >= 0 && x < iWidth && y >= 0 && y < iHeight ) |
---|
793 | { |
---|
794 | pBuffX[ c ] = x; |
---|
795 | pBuffY[ c ] = y; |
---|
796 | pBuff[ c++ ] = x+y*iWidth; |
---|
797 | } |
---|
798 | x--; y++; |
---|
799 | } |
---|
800 | x=0; |
---|
801 | |
---|
802 | // increase loop |
---|
803 | while ( y>=0 ) |
---|
804 | { |
---|
805 | if ( x >= 0 && x < iWidth && y >= 0 && y < iHeight ) |
---|
806 | { |
---|
807 | pBuffX[ c ] = x; |
---|
808 | pBuffY[ c ] = y; |
---|
809 | pBuff[ c++ ] = x+y*iWidth; |
---|
810 | } |
---|
811 | x++; y--; |
---|
812 | } |
---|
813 | y=0; |
---|
814 | |
---|
815 | // termination condition |
---|
816 | if ( c >= iWidth*iHeight ) break; |
---|
817 | } |
---|
818 | } |
---|
819 | |
---|
820 | Void initSigLastScan(UInt* pBuffZ, UInt* pBuffH, UInt* pBuffV, UInt* pBuffD, Int iWidth, Int iHeight, Int iDepth) |
---|
821 | { |
---|
822 | const UInt uiNumScanPos = UInt( iWidth * iWidth ); |
---|
823 | UInt uiNextScanPos = 0; |
---|
824 | |
---|
825 | if( iWidth < 16 ) |
---|
826 | { |
---|
827 | #if MULTILEVEL_SIGMAP_EXT |
---|
828 | UInt* pBuffTemp = pBuffD; |
---|
829 | if( iWidth == 8 ) |
---|
830 | { |
---|
831 | pBuffTemp = g_sigLastScanCG32x32; |
---|
832 | } |
---|
833 | #endif |
---|
834 | for( UInt uiScanLine = 0; uiNextScanPos < uiNumScanPos; uiScanLine++ ) |
---|
835 | { |
---|
836 | int iPrimDim = int( uiScanLine ); |
---|
837 | int iScndDim = 0; |
---|
838 | while( iPrimDim >= iWidth ) |
---|
839 | { |
---|
840 | iScndDim++; |
---|
841 | iPrimDim--; |
---|
842 | } |
---|
843 | while( iPrimDim >= 0 && iScndDim < iWidth ) |
---|
844 | { |
---|
845 | #if MULTILEVEL_SIGMAP_EXT |
---|
846 | pBuffTemp[ uiNextScanPos ] = iPrimDim * iWidth + iScndDim ; |
---|
847 | #else |
---|
848 | pBuffD[ uiNextScanPos ] = iPrimDim * iWidth + iScndDim ; |
---|
849 | #endif |
---|
850 | uiNextScanPos++; |
---|
851 | iScndDim++; |
---|
852 | iPrimDim--; |
---|
853 | } |
---|
854 | } |
---|
855 | } |
---|
856 | #if MULTILEVEL_SIGMAP_EXT |
---|
857 | if( iWidth > 4 ) |
---|
858 | #else |
---|
859 | else |
---|
860 | #endif |
---|
861 | { |
---|
862 | UInt uiNumBlkSide = iWidth >> 2; |
---|
863 | UInt uiNumBlks = uiNumBlkSide * uiNumBlkSide; |
---|
864 | UInt log2Blk = g_aucConvertToBit[ uiNumBlkSide ] + 1; |
---|
865 | |
---|
866 | for( UInt uiBlk = 0; uiBlk < uiNumBlks; uiBlk++ ) |
---|
867 | { |
---|
868 | uiNextScanPos = 0; |
---|
869 | UInt initBlkPos = g_auiSigLastScan[ SCAN_DIAG ][ log2Blk ][ uiBlk ]; |
---|
870 | #if MULTILEVEL_SIGMAP_EXT |
---|
871 | if( iWidth == 32 ) |
---|
872 | { |
---|
873 | initBlkPos = g_sigLastScanCG32x32[ uiBlk ]; |
---|
874 | } |
---|
875 | #endif |
---|
876 | UInt offsetY = initBlkPos / uiNumBlkSide; |
---|
877 | UInt offsetX = initBlkPos - offsetY * uiNumBlkSide; |
---|
878 | UInt offsetD = 4 * ( offsetX + offsetY * iWidth ); |
---|
879 | UInt offsetScan = 16 * uiBlk; |
---|
880 | for( UInt uiScanLine = 0; uiNextScanPos < 16; uiScanLine++ ) |
---|
881 | { |
---|
882 | int iPrimDim = int( uiScanLine ); |
---|
883 | int iScndDim = 0; |
---|
884 | while( iPrimDim >= 4 ) |
---|
885 | { |
---|
886 | iScndDim++; |
---|
887 | iPrimDim--; |
---|
888 | } |
---|
889 | while( iPrimDim >= 0 && iScndDim < 4 ) |
---|
890 | { |
---|
891 | pBuffD[ uiNextScanPos + offsetScan ] = iPrimDim * iWidth + iScndDim + offsetD; |
---|
892 | uiNextScanPos++; |
---|
893 | iScndDim++; |
---|
894 | iPrimDim--; |
---|
895 | } |
---|
896 | } |
---|
897 | } |
---|
898 | } |
---|
899 | |
---|
900 | memcpy(pBuffZ, g_auiFrameScanXY[iDepth], sizeof(UInt)*iWidth*iHeight); |
---|
901 | |
---|
902 | UInt uiCnt = 0; |
---|
903 | for(Int iY=0; iY < iHeight; iY++) |
---|
904 | { |
---|
905 | for(Int iX=0; iX < iWidth; iX++) |
---|
906 | { |
---|
907 | pBuffH[uiCnt] = iY*iWidth + iX; |
---|
908 | uiCnt ++; |
---|
909 | } |
---|
910 | } |
---|
911 | |
---|
912 | uiCnt = 0; |
---|
913 | for(Int iX=0; iX < iWidth; iX++) |
---|
914 | { |
---|
915 | for(Int iY=0; iY < iHeight; iY++) |
---|
916 | { |
---|
917 | pBuffV[uiCnt] = iY*iWidth + iX; |
---|
918 | uiCnt ++; |
---|
919 | } |
---|
920 | } |
---|
921 | } |
---|
922 | |
---|
923 | Void initNonSquareSigLastScan(UInt* pBuffZ, UInt uiWidth, UInt uiHeight) |
---|
924 | { |
---|
925 | |
---|
926 | Int x, y, c = 0; |
---|
927 | |
---|
928 | // starting point |
---|
929 | pBuffZ[ c++ ] = 0; |
---|
930 | |
---|
931 | // loop |
---|
932 | if ( uiWidth > uiHeight ) |
---|
933 | { |
---|
934 | x=0; y=1; |
---|
935 | while (1) |
---|
936 | { |
---|
937 | // increase loop |
---|
938 | while ( y>=0 ) |
---|
939 | { |
---|
940 | if ( x >= 0 && x < uiWidth && y >= 0 && y < uiHeight ) |
---|
941 | { |
---|
942 | pBuffZ[ c++ ] = x + y * uiWidth; |
---|
943 | } |
---|
944 | x++; |
---|
945 | y--; |
---|
946 | } |
---|
947 | y=0; |
---|
948 | |
---|
949 | // decrease loop |
---|
950 | while ( x>=0 ) |
---|
951 | { |
---|
952 | if ( x >= 0 && x < uiWidth && y >= 0 && y < uiHeight ) |
---|
953 | { |
---|
954 | pBuffZ[ c++ ] = x + y * uiWidth; |
---|
955 | } |
---|
956 | x--; |
---|
957 | y++; |
---|
958 | } |
---|
959 | x=0; |
---|
960 | |
---|
961 | // termination condition |
---|
962 | if ( c >= uiWidth * uiHeight ) |
---|
963 | break; |
---|
964 | } |
---|
965 | } |
---|
966 | else |
---|
967 | { |
---|
968 | x=1; y=0; |
---|
969 | while (1) |
---|
970 | { |
---|
971 | // increase loop |
---|
972 | while ( x>=0 ) |
---|
973 | { |
---|
974 | if ( x >= 0 && x < uiWidth && y >= 0 && y < uiHeight ) |
---|
975 | { |
---|
976 | pBuffZ[ c++ ] = x + y * uiWidth; |
---|
977 | } |
---|
978 | x--; |
---|
979 | y++; |
---|
980 | } |
---|
981 | x=0; |
---|
982 | |
---|
983 | // decrease loop |
---|
984 | while ( y>=0 ) |
---|
985 | { |
---|
986 | if ( x >= 0 && x < uiWidth && y >= 0 && y < uiHeight ) |
---|
987 | { |
---|
988 | pBuffZ[ c++ ] = x + y * uiWidth; |
---|
989 | } |
---|
990 | x++; |
---|
991 | y--; |
---|
992 | } |
---|
993 | y=0; |
---|
994 | |
---|
995 | // termination condition |
---|
996 | if ( c >= uiWidth * uiHeight ) |
---|
997 | break; |
---|
998 | } |
---|
999 | } |
---|
1000 | } |
---|
1001 | |
---|
1002 | #if SCALING_LIST |
---|
1003 | Int g_quantIntraDefault4x4[16] = |
---|
1004 | { |
---|
1005 | 16,16,17,21, |
---|
1006 | 16,17,20,25, |
---|
1007 | 17,20,30,41, |
---|
1008 | 21,25,41,70 |
---|
1009 | }; |
---|
1010 | Int g_quantInterDefault4x4[16] = |
---|
1011 | { |
---|
1012 | 16,16,17,21, |
---|
1013 | 16,17,21,24, |
---|
1014 | 17,21,24,36, |
---|
1015 | 21,24,36,57 |
---|
1016 | }; |
---|
1017 | |
---|
1018 | Int g_quantIntraDefault8x8[64] = |
---|
1019 | { |
---|
1020 | 16,16,16,16,17,18,21,24, |
---|
1021 | 16,16,16,16,17,19,22,25, |
---|
1022 | 16,16,17,18,20,22,25,29, |
---|
1023 | 16,16,18,21,24,27,31,36, |
---|
1024 | 17,17,20,24,30,35,41,47, |
---|
1025 | 18,19,22,27,35,44,54,65, |
---|
1026 | 21,22,25,31,41,54,70,88, |
---|
1027 | 24,25,29,36,47,65,88,115 |
---|
1028 | }; |
---|
1029 | |
---|
1030 | Int g_quantInterDefault8x8[64] = |
---|
1031 | { |
---|
1032 | 16,16,16,16,17,18,20,24, |
---|
1033 | 16,16,16,17,18,20,24,25, |
---|
1034 | 16,16,17,18,20,24,25,28, |
---|
1035 | 16,17,18,20,24,25,28,33, |
---|
1036 | 17,18,20,24,25,28,33,41, |
---|
1037 | 18,20,24,25,28,33,41,54, |
---|
1038 | 20,24,25,28,33,41,54,71, |
---|
1039 | 24,25,28,33,41,54,71,91 |
---|
1040 | }; |
---|
1041 | #else |
---|
1042 | Int g_quantIntraDefault4x4[16] = |
---|
1043 | { |
---|
1044 | 6,13,20,28, |
---|
1045 | 13,20,28,32, |
---|
1046 | 20,28,32,37, |
---|
1047 | 28,32,37,42 |
---|
1048 | }; |
---|
1049 | Int g_quantInterDefault4x4[16] = |
---|
1050 | { |
---|
1051 | 10,14,20,24, |
---|
1052 | 14,20,24,27, |
---|
1053 | 20,24,27,30, |
---|
1054 | 24,27,30,34 |
---|
1055 | }; |
---|
1056 | |
---|
1057 | Int g_quantIntraDefault8x8[64] = |
---|
1058 | { |
---|
1059 | 6,10,13,16,18,23,25,27, |
---|
1060 | 10,11,16,18,23,25,27,29, |
---|
1061 | 13,16,18,23,25,27,29,31, |
---|
1062 | 16,18,23,25,27,29,31,33, |
---|
1063 | 18,23,25,27,29,31,33,36, |
---|
1064 | 23,25,27,29,31,33,36,38, |
---|
1065 | 25,27,29,31,33,36,38,40, |
---|
1066 | 27,29,31,33,36,38,40,42 |
---|
1067 | }; |
---|
1068 | |
---|
1069 | Int g_quantInterDefault8x8[64] = |
---|
1070 | { |
---|
1071 | 9,13,15,17,19,21,22,24, |
---|
1072 | 13,13,17,19,21,22,24,25, |
---|
1073 | 15,17,19,21,22,24,25,27, |
---|
1074 | 17,19,21,22,24,25,27,28, |
---|
1075 | 19,21,22,24,25,27,28,30, |
---|
1076 | 21,22,24,25,27,28,30,32, |
---|
1077 | 22,24,25,27,28,30,32,33, |
---|
1078 | 24,25,27,28,30,32,33,35 |
---|
1079 | }; |
---|
1080 | |
---|
1081 | Int g_quantIntraDefault16x16[256] = |
---|
1082 | { |
---|
1083 | 16,16,16,16,16,16,16,16,17,17,18,19,21,22,24,27, |
---|
1084 | 16,16,16,16,16,16,16,16,17,18,18,20,21,23,25,27, |
---|
1085 | 16,16,16,16,16,16,16,17,17,18,19,20,22,23,25,28, |
---|
1086 | 16,16,16,16,16,16,17,17,18,19,20,21,23,25,27,29, |
---|
1087 | 16,16,16,16,17,17,18,19,20,21,22,23,25,27,29,31, |
---|
1088 | 16,16,16,16,17,18,19,20,22,23,24,26,27,29,32,34, |
---|
1089 | 16,16,16,17,18,19,21,23,24,25,27,29,31,33,36,39, |
---|
1090 | 16,16,17,17,19,20,23,25,27,29,31,33,35,38,41,44, |
---|
1091 | 17,17,17,18,20,22,24,27,30,32,35,38,41,44,47,51, |
---|
1092 | 17,18,18,19,21,23,25,29,32,36,40,43,47,51,55,60, |
---|
1093 | 18,18,19,20,22,24,27,31,35,40,44,49,54,59,65,70, |
---|
1094 | 19,20,20,21,23,26,29,33,38,43,49,56,62,69,75,82, |
---|
1095 | 21,21,22,23,25,27,31,35,41,47,54,62,70,79,88,97, |
---|
1096 | 22,23,23,25,27,29,33,38,44,51,59,69,79,90,101,113, |
---|
1097 | 24,25,25,27,29,32,36,41,47,55,65,75,88,101,115,130, |
---|
1098 | 27,27,28,29,31,34,39,44,51,60,70,82,97,113,130,149 |
---|
1099 | }; |
---|
1100 | |
---|
1101 | Int g_quantInterDefault16x16[256] = |
---|
1102 | { |
---|
1103 | 16,16,16,16,16,16,16,16,17,17,18,19,20,21,22,27, |
---|
1104 | 16,16,16,16,16,16,16,17,17,18,19,20,21,22,27,27, |
---|
1105 | 16,16,16,16,16,16,17,17,18,19,20,21,22,27,27,28, |
---|
1106 | 16,16,16,16,16,17,17,18,19,20,21,22,27,27,28,29, |
---|
1107 | 16,16,16,16,17,17,18,19,20,21,22,27,27,28,29,30, |
---|
1108 | 16,16,16,17,17,18,19,20,21,22,27,27,28,29,30,32, |
---|
1109 | 16,16,17,17,18,19,20,21,22,27,27,28,29,30,32,36, |
---|
1110 | 16,17,17,18,19,20,21,22,27,27,28,29,30,32,36,40, |
---|
1111 | 17,17,18,19,20,21,22,27,27,28,29,30,32,36,40,45, |
---|
1112 | 17,18,19,20,21,22,27,27,28,29,30,32,36,40,45,52, |
---|
1113 | 18,19,20,21,22,27,27,28,29,30,32,36,40,45,52,59, |
---|
1114 | 19,20,21,22,27,27,28,29,30,32,36,40,45,52,59,68, |
---|
1115 | 20,21,22,27,27,28,29,30,32,36,40,45,52,59,68,79, |
---|
1116 | 21,22,27,27,28,29,30,32,36,40,45,52,59,68,79,91, |
---|
1117 | 22,27,27,28,29,30,32,36,40,45,52,59,68,79,91,103, |
---|
1118 | 27,27,28,29,30,32,36,40,45,52,59,68,79,91,103,117 |
---|
1119 | }; |
---|
1120 | |
---|
1121 | Int g_quantIntraDefault32x32[1024] = |
---|
1122 | { |
---|
1123 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,27,28, |
---|
1124 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,23,23,24,25,27,28, |
---|
1125 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,18,19,20,20,21,22,23,24,25,26,27,28, |
---|
1126 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,21,22,23,24,25,26,27,28, |
---|
1127 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,20,21,22,23,23,24,25,26,28,29, |
---|
1128 | 16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,18,19,19,20,21,21,22,23,24,25,26,27,28,30, |
---|
1129 | 16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,18,18,19,19,20,20,21,21,22,23,24,25,26,27,28,29,30, |
---|
1130 | 16,16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,19,19,20,20,21,21,22,23,24,25,26,27,28,29,30,31, |
---|
1131 | 16,16,16,16,16,16,16,16,17,17,17,18,18,18,19,19,20,20,21,21,22,22,23,24,25,26,27,28,29,30,31,33, |
---|
1132 | 16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,20,20,21,22,22,23,23,24,25,26,27,28,29,30,31,33,34, |
---|
1133 | 16,16,16,16,16,16,16,17,17,18,18,19,19,20,20,21,22,22,23,23,24,25,26,26,27,28,29,30,32,33,34,36, |
---|
1134 | 16,16,16,16,16,16,17,17,18,18,19,20,20,21,21,22,23,23,24,25,25,26,27,28,29,30,31,32,33,35,36,38, |
---|
1135 | 16,16,16,16,16,16,17,17,18,19,19,20,21,22,23,23,24,25,25,26,27,28,29,30,31,32,33,34,36,37,39,40, |
---|
1136 | 16,16,16,16,16,17,17,18,18,19,20,21,22,23,24,24,25,26,27,28,29,30,31,32,33,34,35,37,38,39,41,43, |
---|
1137 | 16,16,16,16,17,17,17,18,19,20,20,21,23,24,25,26,27,28,29,30,31,32,33,34,35,36,38,39,41,42,44,46, |
---|
1138 | 16,16,17,17,17,17,18,18,19,20,21,22,23,24,26,27,28,29,31,32,33,34,35,37,38,39,41,42,44,45,47,49, |
---|
1139 | 17,17,17,17,17,18,18,19,20,20,22,23,24,25,27,28,30,31,32,34,35,36,38,39,41,42,44,45,47,49,51,53, |
---|
1140 | 17,17,17,17,18,18,19,19,20,21,22,23,25,26,28,29,31,33,34,36,37,39,41,42,44,45,47,49,51,53,55,57, |
---|
1141 | 17,17,18,18,18,18,19,20,21,22,23,24,25,27,29,31,32,34,36,38,40,42,43,45,47,49,51,53,55,57,60,62, |
---|
1142 | 18,18,18,18,19,19,20,20,21,22,23,25,26,28,30,32,34,36,38,40,42,44,46,48,51,53,55,57,60,62,65,67, |
---|
1143 | 18,18,18,19,19,19,20,21,22,23,24,25,27,29,31,33,35,37,40,42,44,47,49,52,54,57,59,62,65,67,70,73, |
---|
1144 | 19,19,19,19,20,20,21,21,22,23,25,26,28,30,32,34,36,39,42,44,47,50,52,55,58,61,64,67,70,73,76,79, |
---|
1145 | 19,19,20,20,20,21,21,22,23,24,26,27,29,31,33,35,38,41,43,46,49,52,56,59,62,65,69,72,75,79,82,86, |
---|
1146 | 20,20,20,21,21,21,22,23,24,25,26,28,30,32,34,37,39,42,45,48,52,55,59,62,66,70,74,77,81,85,89,93, |
---|
1147 | 21,21,21,21,22,22,23,24,25,26,27,29,31,33,35,38,41,44,47,51,54,58,62,66,70,74,79,83,88,92,97,101, |
---|
1148 | 22,22,22,22,23,23,24,25,26,27,28,30,32,34,36,39,42,45,49,53,57,61,65,70,74,79,84,89,94,99,104,110, |
---|
1149 | 22,23,23,23,23,24,25,26,27,28,29,31,33,35,38,41,44,47,51,55,59,64,69,74,79,84,90,95,101,107,113,119, |
---|
1150 | 23,23,24,24,24,25,26,27,28,29,30,32,34,37,39,42,45,49,53,57,62,67,72,77,83,89,95,101,108,114,121,128, |
---|
1151 | 24,24,25,25,25,26,27,28,29,30,32,33,36,38,41,44,47,51,55,60,65,70,75,81,88,94,101,108,115,122,130,138, |
---|
1152 | 25,25,26,26,26,27,28,29,30,31,33,35,37,39,42,45,49,53,57,62,67,73,79,85,92,99,107,114,122,131,139,148, |
---|
1153 | 27,27,27,27,28,28,29,30,31,33,34,36,39,41,44,47,51,55,60,65,70,76,82,89,97,104,113,121,130,139,149,159, |
---|
1154 | 28,28,28,28,29,30,30,31,33,34,36,38,40,43,46,49,53,57,62,67,73,79,86,93,101,110,119,128,138,148,159,170 |
---|
1155 | }; |
---|
1156 | |
---|
1157 | Int g_quantInterDefault32x32[1024] = |
---|
1158 | { |
---|
1159 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28, |
---|
1160 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28, |
---|
1161 | 16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28, |
---|
1162 | 16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28, |
---|
1163 | 16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29, |
---|
1164 | 16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30, |
---|
1165 | 16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30, |
---|
1166 | 16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31, |
---|
1167 | 16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32, |
---|
1168 | 16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33, |
---|
1169 | 16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34, |
---|
1170 | 16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35, |
---|
1171 | 16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36, |
---|
1172 | 16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38, |
---|
1173 | 16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40, |
---|
1174 | 16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42, |
---|
1175 | 17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45, |
---|
1176 | 17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48, |
---|
1177 | 17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52, |
---|
1178 | 18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56, |
---|
1179 | 18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60, |
---|
1180 | 19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64, |
---|
1181 | 19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69, |
---|
1182 | 20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74, |
---|
1183 | 21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80, |
---|
1184 | 22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87, |
---|
1185 | 22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94, |
---|
1186 | 23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94,101, |
---|
1187 | 24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94,101,108, |
---|
1188 | 25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94,101,108,115, |
---|
1189 | 26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94,101,108,115,123, |
---|
1190 | 28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94,101,108,115,123,131 |
---|
1191 | }; |
---|
1192 | #endif |
---|
1193 | UInt g_scalingListSize [4] = {16,64,256,1024}; |
---|
1194 | UInt g_scalingListSizeX [4] = { 4, 8, 16, 32}; |
---|
1195 | UInt g_scalingListNum[SCALING_LIST_SIZE_NUM]={6,6,6,2}; |
---|
1196 | Int g_eTTable[4] = {0,3,1,2}; |
---|
1197 | |
---|
1198 | #if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX |
---|
1199 | std::vector< std::vector<TComWedgelet> > g_aacWedgeLists; |
---|
1200 | std::vector< std::vector<TComWedgeRef> > g_aacWedgeRefLists; |
---|
1201 | |
---|
1202 | #if HHIQC_DMMFASTSEARCH_B0039 |
---|
1203 | std::vector< std::vector< std::vector<UInt> > > g_aauiWdgLstM3; |
---|
1204 | std::vector< std::vector< TComWedgeNode> > g_aacWedgeNodeLists; |
---|
1205 | #endif |
---|
1206 | |
---|
1207 | Void initWedgeLists() |
---|
1208 | { |
---|
1209 | for( UInt ui = g_aucConvertToBit[DMM_WEDGEMODEL_MIN_SIZE]; ui < (g_aucConvertToBit[DMM_WEDGEMODEL_MAX_SIZE]+1); ui++ ) |
---|
1210 | { |
---|
1211 | UInt uiWedgeBlockSize = ((UInt)DMM_WEDGEMODEL_MIN_SIZE)<<ui; |
---|
1212 | std::vector<TComWedgelet> acWedgeList; |
---|
1213 | std::vector<TComWedgeRef> acWedgeRefList; |
---|
1214 | createWedgeList( uiWedgeBlockSize, uiWedgeBlockSize, acWedgeList, acWedgeRefList, g_aeWedgeResolutionList[ui] ); |
---|
1215 | g_aacWedgeLists.push_back( acWedgeList ); |
---|
1216 | g_aacWedgeRefLists.push_back( acWedgeRefList ); |
---|
1217 | |
---|
1218 | #if HHIQC_DMMFASTSEARCH_B0039 |
---|
1219 | // create WedgeNodeList |
---|
1220 | std::vector<TComWedgeNode> acWedgeNodeList; |
---|
1221 | for( UInt uiPos = 0; uiPos < acWedgeList.size(); uiPos++ ) |
---|
1222 | { |
---|
1223 | if( acWedgeList[uiPos].getIsCoarse() ) |
---|
1224 | { |
---|
1225 | TComWedgeNode cWedgeNode; |
---|
1226 | cWedgeNode.setPatternIdx( uiPos ); |
---|
1227 | |
---|
1228 | // set refinement idxs |
---|
1229 | UInt uiRefPos = 0; |
---|
1230 | for( Int iOffS = -1; iOffS <= 1; iOffS++ ) |
---|
1231 | { |
---|
1232 | for( Int iOffE = -1; iOffE <= 1; iOffE++ ) |
---|
1233 | { |
---|
1234 | if( iOffS == 0 && iOffE == 0 ) { continue; } |
---|
1235 | |
---|
1236 | Int iSx = (Int)acWedgeList[uiPos].getStartX(); |
---|
1237 | Int iSy = (Int)acWedgeList[uiPos].getStartY(); |
---|
1238 | Int iEx = (Int)acWedgeList[uiPos].getEndX(); |
---|
1239 | Int iEy = (Int)acWedgeList[uiPos].getEndY(); |
---|
1240 | |
---|
1241 | switch( acWedgeList[uiPos].getOri() ) |
---|
1242 | { |
---|
1243 | case( 0 ): { iSx += iOffS; iEy += iOffE; } break; |
---|
1244 | case( 1 ): { iSy += iOffS; iEx -= iOffE; } break; |
---|
1245 | case( 2 ): { iSx -= iOffS; iEy -= iOffE; } break; |
---|
1246 | case( 3 ): { iSy -= iOffS; iEx += iOffE; } break; |
---|
1247 | case( 4 ): { iSx += iOffS; iEx += iOffE; } break; |
---|
1248 | case( 5 ): { iSy += iOffS; iEy += iOffE; } break; |
---|
1249 | default: assert( 0 ); |
---|
1250 | } |
---|
1251 | |
---|
1252 | for( UInt k = 0; k < acWedgeRefList.size(); k++ ) |
---|
1253 | { |
---|
1254 | if( iSx == (Int)acWedgeRefList[k].getStartX() && |
---|
1255 | iSy == (Int)acWedgeRefList[k].getStartY() && |
---|
1256 | iEx == (Int)acWedgeRefList[k].getEndX() && |
---|
1257 | iEy == (Int)acWedgeRefList[k].getEndY() ) |
---|
1258 | { |
---|
1259 | if( acWedgeRefList[k].getRefIdx() != cWedgeNode.getPatternIdx() ) |
---|
1260 | { |
---|
1261 | Bool bNew = true; |
---|
1262 | for( UInt m = 0; m < uiRefPos; m++ ) { if( acWedgeRefList[k].getRefIdx() == cWedgeNode.getRefineIdx( m ) ) { bNew = false; break; } } |
---|
1263 | |
---|
1264 | if( bNew ) |
---|
1265 | { |
---|
1266 | cWedgeNode.setRefineIdx( acWedgeRefList[k].getRefIdx(), uiRefPos ); |
---|
1267 | uiRefPos++; |
---|
1268 | break; |
---|
1269 | } |
---|
1270 | } |
---|
1271 | } |
---|
1272 | } |
---|
1273 | } |
---|
1274 | } |
---|
1275 | acWedgeNodeList.push_back( cWedgeNode ); |
---|
1276 | } |
---|
1277 | } |
---|
1278 | g_aacWedgeNodeLists.push_back( acWedgeNodeList ); |
---|
1279 | #endif |
---|
1280 | } |
---|
1281 | return; |
---|
1282 | } |
---|
1283 | |
---|
1284 | Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes ) |
---|
1285 | { |
---|
1286 | assert( uiWidth == uiHeight ); |
---|
1287 | |
---|
1288 | UChar uhStartX = 0, uhStartY = 0, uhEndX = 0, uhEndY = 0; |
---|
1289 | Int iStepStartX = 0, iStepStartY = 0, iStepEndX = 0, iStepEndY = 0; |
---|
1290 | |
---|
1291 | UInt uiBlockSize = 0; |
---|
1292 | switch( eWedgeRes ) |
---|
1293 | { |
---|
1294 | case( DOUBLE_PEL ): { uiBlockSize = (uiWidth>>1); break; } |
---|
1295 | case( FULL_PEL ): { uiBlockSize = uiWidth; break; } |
---|
1296 | case( HALF_PEL ): { uiBlockSize = (uiWidth<<1); break; } |
---|
1297 | } |
---|
1298 | |
---|
1299 | TComWedgelet cTempWedgelet( uiWidth, uiHeight ); |
---|
1300 | for( UInt uiOri = 0; uiOri < 6; uiOri++ ) |
---|
1301 | { |
---|
1302 | // init the edge line parameters for each of the 6 wedgelet types |
---|
1303 | switch( uiOri ) |
---|
1304 | { |
---|
1305 | case( 0 ): { uhStartX = 0; uhStartY = 0; uhEndX = 0; uhEndY = 0; iStepStartX = +1; iStepStartY = 0; iStepEndX = 0; iStepEndY = +1; break; } |
---|
1306 | case( 1 ): { uhStartX = (uiBlockSize-1); uhStartY = 0; uhEndX = (uiBlockSize-1); uhEndY = 0; iStepStartX = 0; iStepStartY = +1; iStepEndX = -1; iStepEndY = 0; break; } |
---|
1307 | case( 2 ): { uhStartX = (uiBlockSize-1); uhStartY = (uiBlockSize-1); uhEndX = (uiBlockSize-1); uhEndY = (uiBlockSize-1); iStepStartX = -1; iStepStartY = 0; iStepEndX = 0; iStepEndY = -1; break; } |
---|
1308 | case( 3 ): { uhStartX = 0; uhStartY = (uiBlockSize-1); uhEndX = 0; uhEndY = (uiBlockSize-1); iStepStartX = 0; iStepStartY = -1; iStepEndX = +1; iStepEndY = 0; break; } |
---|
1309 | case( 4 ): { uhStartX = 0; uhStartY = 0; uhEndX = 0; uhEndY = (uiBlockSize-1); iStepStartX = +1; iStepStartY = 0; iStepEndX = +1; iStepEndY = 0; break; } |
---|
1310 | case( 5 ): { uhStartX = (uiBlockSize-1); uhStartY = 0; uhEndX = 0; uhEndY = 0; iStepStartX = 0; iStepStartY = +1; iStepEndX = 0; iStepEndY = +1; break; } |
---|
1311 | } |
---|
1312 | |
---|
1313 | for( Int iK = 0; iK < uiBlockSize; iK++ ) |
---|
1314 | { |
---|
1315 | for( Int iL = 0; iL < uiBlockSize; iL++ ) |
---|
1316 | { |
---|
1317 | #if HHIQC_DMMFASTSEARCH_B0039 |
---|
1318 | cTempWedgelet.setWedgelet( uhStartX + (iK*iStepStartX) , uhStartY + (iK*iStepStartY), uhEndX + (iL*iStepEndX), uhEndY + (iL*iStepEndY), (UChar)uiOri, eWedgeRes, ((iL%2)==0 && (iK%2)==0) ); |
---|
1319 | #else |
---|
1320 | cTempWedgelet.setWedgelet( uhStartX + (iK*iStepStartX) , uhStartY + (iK*iStepStartY), uhEndX + (iL*iStepEndX), uhEndY + (iL*iStepEndY), (UChar)uiOri, eWedgeRes ); |
---|
1321 | #endif |
---|
1322 | addWedgeletToList( cTempWedgelet, racWedgeList, racWedgeRefList ); |
---|
1323 | } |
---|
1324 | } |
---|
1325 | } |
---|
1326 | #if HHIQC_DMMFASTSEARCH_B0039 |
---|
1327 | UInt uiThrSz = DMM3_SIMPLIFY_TR; |
---|
1328 | |
---|
1329 | std::vector< std::vector<UInt> > auiWdgListSz; |
---|
1330 | for( Int idxM=2; idxM<=34 ; idxM++) |
---|
1331 | { |
---|
1332 | std::vector<UInt> auiWdgList; |
---|
1333 | for( Int idxW=0; idxW<racWedgeList.size(); idxW++) |
---|
1334 | { |
---|
1335 | UInt uiAbsDiff = abs(idxM-(Int)racWedgeList[idxW].getAng()); |
---|
1336 | if( uiAbsDiff <= uiThrSz ) |
---|
1337 | { |
---|
1338 | auiWdgList.push_back(idxW); |
---|
1339 | } |
---|
1340 | } |
---|
1341 | auiWdgListSz.push_back(auiWdgList); |
---|
1342 | } |
---|
1343 | g_aauiWdgLstM3.push_back(auiWdgListSz); |
---|
1344 | #endif |
---|
1345 | } |
---|
1346 | |
---|
1347 | Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList ) |
---|
1348 | { |
---|
1349 | Bool bValid = cWedgelet.checkNotPlain(); |
---|
1350 | if( bValid ) |
---|
1351 | { |
---|
1352 | for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ ) |
---|
1353 | { |
---|
1354 | if( cWedgelet.checkIdentical( racWedgeList[uiPos].getPattern() ) ) |
---|
1355 | { |
---|
1356 | TComWedgeRef cWedgeRef; |
---|
1357 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos ); |
---|
1358 | racWedgeRefList.push_back( cWedgeRef ); |
---|
1359 | bValid = false; |
---|
1360 | return; |
---|
1361 | } |
---|
1362 | } |
---|
1363 | } |
---|
1364 | if( bValid ) |
---|
1365 | { |
---|
1366 | for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ ) |
---|
1367 | { |
---|
1368 | if( cWedgelet.checkInvIdentical( racWedgeList[uiPos].getPattern() ) ) |
---|
1369 | { |
---|
1370 | TComWedgeRef cWedgeRef; |
---|
1371 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos ); |
---|
1372 | racWedgeRefList.push_back( cWedgeRef ); |
---|
1373 | bValid = false; |
---|
1374 | return; |
---|
1375 | } |
---|
1376 | } |
---|
1377 | } |
---|
1378 | if( bValid ) |
---|
1379 | { |
---|
1380 | #if HHIQC_DMMFASTSEARCH_B0039 |
---|
1381 | cWedgelet.findClosetAngle(); |
---|
1382 | #endif |
---|
1383 | racWedgeList.push_back( cWedgelet ); |
---|
1384 | TComWedgeRef cWedgeRef; |
---|
1385 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), (UInt)(racWedgeList.size()-1) ); |
---|
1386 | racWedgeRefList.push_back( cWedgeRef ); |
---|
1387 | } |
---|
1388 | } |
---|
1389 | #endif |
---|
1390 | |
---|
1391 | //! \} |
---|