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