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-2013, 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 | |
---|
63 | c=2; |
---|
64 | for ( i=0; i<MAX_CU_DEPTH; i++ ) |
---|
65 | { |
---|
66 | g_auiSigLastScan[0][i] = new UInt[ c*c ]; |
---|
67 | g_auiSigLastScan[1][i] = new UInt[ c*c ]; |
---|
68 | g_auiSigLastScan[2][i] = new UInt[ c*c ]; |
---|
69 | initSigLastScan( g_auiSigLastScan[0][i], g_auiSigLastScan[1][i], g_auiSigLastScan[2][i], c, c); |
---|
70 | |
---|
71 | c <<= 1; |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | Void destroyROM() |
---|
76 | { |
---|
77 | for (Int i=0; i<MAX_CU_DEPTH; i++ ) |
---|
78 | { |
---|
79 | delete[] g_auiSigLastScan[0][i]; |
---|
80 | delete[] g_auiSigLastScan[1][i]; |
---|
81 | delete[] g_auiSigLastScan[2][i]; |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | // ==================================================================================================================== |
---|
86 | // Data structure related table & variable |
---|
87 | // ==================================================================================================================== |
---|
88 | |
---|
89 | UInt g_uiMaxCUWidth = MAX_CU_SIZE; |
---|
90 | UInt g_uiMaxCUHeight = MAX_CU_SIZE; |
---|
91 | UInt g_uiMaxCUDepth = MAX_CU_DEPTH; |
---|
92 | UInt g_uiAddCUDepth = 0; |
---|
93 | UInt g_auiZscanToRaster [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
94 | UInt g_auiRasterToZscan [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
95 | UInt g_auiRasterToPelX [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
96 | UInt g_auiRasterToPelY [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
97 | |
---|
98 | UInt g_auiPUOffset[8] = { 0, 8, 4, 4, 2, 10, 1, 5}; |
---|
99 | |
---|
100 | #if FAST_INTRA_SHVC |
---|
101 | UInt g_reducedSetIntraModes[NUM_INTRA_MODE-1] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; |
---|
102 | UInt g_predefSetIntraModes[NUM_INTRA_MODE-1] = {26,10,18,34,2,22,14,30,6,24,12,28,8,20,16,32,4,17,19,15,21,13,23,11,25,9,27,7,29,5,31,3,33,0,2}; |
---|
103 | #endif |
---|
104 | |
---|
105 | Void initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx ) |
---|
106 | { |
---|
107 | Int iStride = 1 << ( iMaxDepth - 1 ); |
---|
108 | |
---|
109 | if ( iDepth == iMaxDepth ) |
---|
110 | { |
---|
111 | rpuiCurrIdx[0] = uiStartVal; |
---|
112 | rpuiCurrIdx++; |
---|
113 | } |
---|
114 | else |
---|
115 | { |
---|
116 | Int iStep = iStride >> iDepth; |
---|
117 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal, rpuiCurrIdx ); |
---|
118 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep, rpuiCurrIdx ); |
---|
119 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride, rpuiCurrIdx ); |
---|
120 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride+iStep, rpuiCurrIdx ); |
---|
121 | } |
---|
122 | } |
---|
123 | |
---|
124 | Void initRasterToZscan ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
125 | { |
---|
126 | UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 ); |
---|
127 | UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 ); |
---|
128 | |
---|
129 | UInt uiNumPartInWidth = (UInt)uiMaxCUWidth / uiMinCUWidth; |
---|
130 | UInt uiNumPartInHeight = (UInt)uiMaxCUHeight / uiMinCUHeight; |
---|
131 | |
---|
132 | for ( UInt i = 0; i < uiNumPartInWidth*uiNumPartInHeight; i++ ) |
---|
133 | { |
---|
134 | g_auiRasterToZscan[ g_auiZscanToRaster[i] ] = i; |
---|
135 | } |
---|
136 | } |
---|
137 | |
---|
138 | Void initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
139 | { |
---|
140 | UInt i; |
---|
141 | |
---|
142 | UInt* uiTempX = &g_auiRasterToPelX[0]; |
---|
143 | UInt* uiTempY = &g_auiRasterToPelY[0]; |
---|
144 | |
---|
145 | UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 ); |
---|
146 | UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 ); |
---|
147 | |
---|
148 | UInt uiNumPartInWidth = uiMaxCUWidth / uiMinCUWidth; |
---|
149 | UInt uiNumPartInHeight = uiMaxCUHeight / uiMinCUHeight; |
---|
150 | |
---|
151 | uiTempX[0] = 0; uiTempX++; |
---|
152 | for ( i = 1; i < uiNumPartInWidth; i++ ) |
---|
153 | { |
---|
154 | uiTempX[0] = uiTempX[-1] + uiMinCUWidth; uiTempX++; |
---|
155 | } |
---|
156 | for ( i = 1; i < uiNumPartInHeight; i++ ) |
---|
157 | { |
---|
158 | memcpy(uiTempX, uiTempX-uiNumPartInWidth, sizeof(UInt)*uiNumPartInWidth); |
---|
159 | uiTempX += uiNumPartInWidth; |
---|
160 | } |
---|
161 | |
---|
162 | for ( i = 1; i < uiNumPartInWidth*uiNumPartInHeight; i++ ) |
---|
163 | { |
---|
164 | uiTempY[i] = ( i / uiNumPartInWidth ) * uiMinCUWidth; |
---|
165 | } |
---|
166 | }; |
---|
167 | |
---|
168 | |
---|
169 | Int g_quantScales[6] = |
---|
170 | { |
---|
171 | 26214,23302,20560,18396,16384,14564 |
---|
172 | }; |
---|
173 | |
---|
174 | Int g_invQuantScales[6] = |
---|
175 | { |
---|
176 | 40,45,51,57,64,72 |
---|
177 | }; |
---|
178 | |
---|
179 | const Short g_aiT4[4][4] = |
---|
180 | { |
---|
181 | { 64, 64, 64, 64}, |
---|
182 | { 83, 36,-36,-83}, |
---|
183 | { 64,-64,-64, 64}, |
---|
184 | { 36,-83, 83,-36} |
---|
185 | }; |
---|
186 | |
---|
187 | const Short g_aiT8[8][8] = |
---|
188 | { |
---|
189 | { 64, 64, 64, 64, 64, 64, 64, 64}, |
---|
190 | { 89, 75, 50, 18,-18,-50,-75,-89}, |
---|
191 | { 83, 36,-36,-83,-83,-36, 36, 83}, |
---|
192 | { 75,-18,-89,-50, 50, 89, 18,-75}, |
---|
193 | { 64,-64,-64, 64, 64,-64,-64, 64}, |
---|
194 | { 50,-89, 18, 75,-75,-18, 89,-50}, |
---|
195 | { 36,-83, 83,-36,-36, 83,-83, 36}, |
---|
196 | { 18,-50, 75,-89, 89,-75, 50,-18} |
---|
197 | }; |
---|
198 | |
---|
199 | const Short g_aiT16[16][16] = |
---|
200 | { |
---|
201 | { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}, |
---|
202 | { 90, 87, 80, 70, 57, 43, 25, 9, -9,-25,-43,-57,-70,-80,-87,-90}, |
---|
203 | { 89, 75, 50, 18,-18,-50,-75,-89,-89,-75,-50,-18, 18, 50, 75, 89}, |
---|
204 | { 87, 57, 9,-43,-80,-90,-70,-25, 25, 70, 90, 80, 43, -9,-57,-87}, |
---|
205 | { 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83}, |
---|
206 | { 80, 9,-70,-87,-25, 57, 90, 43,-43,-90,-57, 25, 87, 70, -9,-80}, |
---|
207 | { 75,-18,-89,-50, 50, 89, 18,-75,-75, 18, 89, 50,-50,-89,-18, 75}, |
---|
208 | { 70,-43,-87, 9, 90, 25,-80,-57, 57, 80,-25,-90, -9, 87, 43,-70}, |
---|
209 | { 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64}, |
---|
210 | { 57,-80,-25, 90, -9,-87, 43, 70,-70,-43, 87, 9,-90, 25, 80,-57}, |
---|
211 | { 50,-89, 18, 75,-75,-18, 89,-50,-50, 89,-18,-75, 75, 18,-89, 50}, |
---|
212 | { 43,-90, 57, 25,-87, 70, 9,-80, 80, -9,-70, 87,-25,-57, 90,-43}, |
---|
213 | { 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36}, |
---|
214 | { 25,-70, 90,-80, 43, 9,-57, 87,-87, 57, -9,-43, 80,-90, 70,-25}, |
---|
215 | { 18,-50, 75,-89, 89,-75, 50,-18,-18, 50,-75, 89,-89, 75,-50, 18}, |
---|
216 | { 9,-25, 43,-57, 70,-80, 87,-90, 90,-87, 80,-70, 57,-43, 25, -9} |
---|
217 | }; |
---|
218 | |
---|
219 | const Short g_aiT32[32][32] = |
---|
220 | { |
---|
221 | { 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}, |
---|
222 | { 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}, |
---|
223 | { 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}, |
---|
224 | { 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}, |
---|
225 | { 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}, |
---|
226 | { 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}, |
---|
227 | { 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}, |
---|
228 | { 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}, |
---|
229 | { 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}, |
---|
230 | { 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}, |
---|
231 | { 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}, |
---|
232 | { 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}, |
---|
233 | { 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}, |
---|
234 | { 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}, |
---|
235 | { 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}, |
---|
236 | { 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}, |
---|
237 | { 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}, |
---|
238 | { 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}, |
---|
239 | { 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}, |
---|
240 | { 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}, |
---|
241 | { 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}, |
---|
242 | { 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}, |
---|
243 | { 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}, |
---|
244 | { 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}, |
---|
245 | { 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}, |
---|
246 | { 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}, |
---|
247 | { 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}, |
---|
248 | { 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}, |
---|
249 | { 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}, |
---|
250 | { 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}, |
---|
251 | { 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}, |
---|
252 | { 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} |
---|
253 | }; |
---|
254 | |
---|
255 | const UChar g_aucChromaScale[58]= |
---|
256 | { |
---|
257 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16, |
---|
258 | 17,18,19,20,21,22,23,24,25,26,27,28,29,29,30,31,32, |
---|
259 | 33,33,34,34,35,35,36,36,37,37,38,39,40,41,42,43,44, |
---|
260 | 45,46,47,48,49,50,51 |
---|
261 | }; |
---|
262 | |
---|
263 | |
---|
264 | // Mode-Dependent DCT/DST |
---|
265 | const Short g_as_DST_MAT_4 [4][4]= |
---|
266 | { |
---|
267 | {29, 55, 74, 84}, |
---|
268 | {74, 74, 0 , -74}, |
---|
269 | {84, -29, -74, 55}, |
---|
270 | {55, -84, 74, -29}, |
---|
271 | }; |
---|
272 | |
---|
273 | |
---|
274 | // ==================================================================================================================== |
---|
275 | // ADI |
---|
276 | // ==================================================================================================================== |
---|
277 | |
---|
278 | #if FAST_UDI_USE_MPM |
---|
279 | const UChar g_aucIntraModeNumFast[MAX_CU_DEPTH] = |
---|
280 | { |
---|
281 | 3, // 2x2 |
---|
282 | 8, // 4x4 |
---|
283 | 8, // 8x8 |
---|
284 | 3, // 16x16 |
---|
285 | 3, // 32x32 |
---|
286 | 3 // 64x64 |
---|
287 | }; |
---|
288 | #else // FAST_UDI_USE_MPM |
---|
289 | const UChar g_aucIntraModeNumFast[MAX_CU_DEPTH] = |
---|
290 | { |
---|
291 | 3, // 2x2 |
---|
292 | 9, // 4x4 |
---|
293 | 9, // 8x8 |
---|
294 | 4, // 16x16 33 |
---|
295 | 4, // 32x32 33 |
---|
296 | 5 // 64x64 33 |
---|
297 | }; |
---|
298 | #endif // FAST_UDI_USE_MPM |
---|
299 | |
---|
300 | // chroma |
---|
301 | |
---|
302 | const UChar g_aucConvertTxtTypeToIdx[4] = { 0, 1, 1, 2 }; |
---|
303 | |
---|
304 | |
---|
305 | // ==================================================================================================================== |
---|
306 | // Bit-depth |
---|
307 | // ==================================================================================================================== |
---|
308 | |
---|
309 | Int g_bitDepthY = 8; |
---|
310 | Int g_bitDepthC = 8; |
---|
311 | |
---|
312 | UInt g_uiPCMBitDepthLuma = 8; // PCM bit-depth |
---|
313 | UInt g_uiPCMBitDepthChroma = 8; // PCM bit-depth |
---|
314 | |
---|
315 | // ==================================================================================================================== |
---|
316 | // Misc. |
---|
317 | // ==================================================================================================================== |
---|
318 | |
---|
319 | Char g_aucConvertToBit [ MAX_CU_SIZE+1 ]; |
---|
320 | |
---|
321 | #if ENC_DEC_TRACE |
---|
322 | FILE* g_hTrace = NULL; |
---|
323 | const Bool g_bEncDecTraceEnable = true; |
---|
324 | const Bool g_bEncDecTraceDisable = false; |
---|
325 | Bool g_HLSTraceEnable = true; |
---|
326 | Bool g_bJustDoIt = false; |
---|
327 | UInt64 g_nSymbolCounter = 0; |
---|
328 | #endif |
---|
329 | // ==================================================================================================================== |
---|
330 | // Scanning order & context model mapping |
---|
331 | // ==================================================================================================================== |
---|
332 | |
---|
333 | // scanning order table |
---|
334 | UInt* g_auiSigLastScan[ 3 ][ MAX_CU_DEPTH ]; |
---|
335 | |
---|
336 | const UInt g_sigLastScan8x8[ 3 ][ 4 ] = |
---|
337 | { |
---|
338 | {0, 2, 1, 3}, |
---|
339 | {0, 1, 2, 3}, |
---|
340 | {0, 2, 1, 3} |
---|
341 | }; |
---|
342 | UInt g_sigLastScanCG32x32[ 64 ]; |
---|
343 | |
---|
344 | const UInt g_uiMinInGroup[ 10 ] = {0,1,2,3,4,6,8,12,16,24}; |
---|
345 | 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}; |
---|
346 | |
---|
347 | // Rice parameters for absolute transform levels |
---|
348 | const UInt g_auiGoRiceRange[5] = |
---|
349 | { |
---|
350 | 7, 14, 26, 46, 78 |
---|
351 | }; |
---|
352 | |
---|
353 | const UInt g_auiGoRicePrefixLen[5] = |
---|
354 | { |
---|
355 | 8, 7, 6, 5, 4 |
---|
356 | }; |
---|
357 | |
---|
358 | Void initSigLastScan(UInt* pBuffD, UInt* pBuffH, UInt* pBuffV, Int iWidth, Int iHeight) |
---|
359 | { |
---|
360 | const UInt uiNumScanPos = UInt( iWidth * iWidth ); |
---|
361 | UInt uiNextScanPos = 0; |
---|
362 | |
---|
363 | if( iWidth < 16 ) |
---|
364 | { |
---|
365 | UInt* pBuffTemp = pBuffD; |
---|
366 | if( iWidth == 8 ) |
---|
367 | { |
---|
368 | pBuffTemp = g_sigLastScanCG32x32; |
---|
369 | } |
---|
370 | for( UInt uiScanLine = 0; uiNextScanPos < uiNumScanPos; uiScanLine++ ) |
---|
371 | { |
---|
372 | Int iPrimDim = Int( uiScanLine ); |
---|
373 | Int iScndDim = 0; |
---|
374 | while( iPrimDim >= iWidth ) |
---|
375 | { |
---|
376 | iScndDim++; |
---|
377 | iPrimDim--; |
---|
378 | } |
---|
379 | while( iPrimDim >= 0 && iScndDim < iWidth ) |
---|
380 | { |
---|
381 | pBuffTemp[ uiNextScanPos ] = iPrimDim * iWidth + iScndDim ; |
---|
382 | uiNextScanPos++; |
---|
383 | iScndDim++; |
---|
384 | iPrimDim--; |
---|
385 | } |
---|
386 | } |
---|
387 | } |
---|
388 | if( iWidth > 4 ) |
---|
389 | { |
---|
390 | UInt uiNumBlkSide = iWidth >> 2; |
---|
391 | UInt uiNumBlks = uiNumBlkSide * uiNumBlkSide; |
---|
392 | UInt log2Blk = g_aucConvertToBit[ uiNumBlkSide ] + 1; |
---|
393 | |
---|
394 | for( UInt uiBlk = 0; uiBlk < uiNumBlks; uiBlk++ ) |
---|
395 | { |
---|
396 | uiNextScanPos = 0; |
---|
397 | UInt initBlkPos = g_auiSigLastScan[ SCAN_DIAG ][ log2Blk ][ uiBlk ]; |
---|
398 | if( iWidth == 32 ) |
---|
399 | { |
---|
400 | initBlkPos = g_sigLastScanCG32x32[ uiBlk ]; |
---|
401 | } |
---|
402 | UInt offsetY = initBlkPos / uiNumBlkSide; |
---|
403 | UInt offsetX = initBlkPos - offsetY * uiNumBlkSide; |
---|
404 | UInt offsetD = 4 * ( offsetX + offsetY * iWidth ); |
---|
405 | UInt offsetScan = 16 * uiBlk; |
---|
406 | for( UInt uiScanLine = 0; uiNextScanPos < 16; uiScanLine++ ) |
---|
407 | { |
---|
408 | Int iPrimDim = Int( uiScanLine ); |
---|
409 | Int iScndDim = 0; |
---|
410 | while( iPrimDim >= 4 ) |
---|
411 | { |
---|
412 | iScndDim++; |
---|
413 | iPrimDim--; |
---|
414 | } |
---|
415 | while( iPrimDim >= 0 && iScndDim < 4 ) |
---|
416 | { |
---|
417 | pBuffD[ uiNextScanPos + offsetScan ] = iPrimDim * iWidth + iScndDim + offsetD; |
---|
418 | uiNextScanPos++; |
---|
419 | iScndDim++; |
---|
420 | iPrimDim--; |
---|
421 | } |
---|
422 | } |
---|
423 | } |
---|
424 | } |
---|
425 | |
---|
426 | UInt uiCnt = 0; |
---|
427 | if( iWidth > 2 ) |
---|
428 | { |
---|
429 | UInt numBlkSide = iWidth >> 2; |
---|
430 | for(Int blkY=0; blkY < numBlkSide; blkY++) |
---|
431 | { |
---|
432 | for(Int blkX=0; blkX < numBlkSide; blkX++) |
---|
433 | { |
---|
434 | UInt offset = blkY * 4 * iWidth + blkX * 4; |
---|
435 | for(Int y=0; y < 4; y++) |
---|
436 | { |
---|
437 | for(Int x=0; x < 4; x++) |
---|
438 | { |
---|
439 | pBuffH[uiCnt] = y*iWidth + x + offset; |
---|
440 | uiCnt ++; |
---|
441 | } |
---|
442 | } |
---|
443 | } |
---|
444 | } |
---|
445 | |
---|
446 | uiCnt = 0; |
---|
447 | for(Int blkX=0; blkX < numBlkSide; blkX++) |
---|
448 | { |
---|
449 | for(Int blkY=0; blkY < numBlkSide; blkY++) |
---|
450 | { |
---|
451 | UInt offset = blkY * 4 * iWidth + blkX * 4; |
---|
452 | for(Int x=0; x < 4; x++) |
---|
453 | { |
---|
454 | for(Int y=0; y < 4; y++) |
---|
455 | { |
---|
456 | pBuffV[uiCnt] = y*iWidth + x + offset; |
---|
457 | uiCnt ++; |
---|
458 | } |
---|
459 | } |
---|
460 | } |
---|
461 | } |
---|
462 | } |
---|
463 | else |
---|
464 | { |
---|
465 | for(Int iY=0; iY < iHeight; iY++) |
---|
466 | { |
---|
467 | for(Int iX=0; iX < iWidth; iX++) |
---|
468 | { |
---|
469 | pBuffH[uiCnt] = iY*iWidth + iX; |
---|
470 | uiCnt ++; |
---|
471 | } |
---|
472 | } |
---|
473 | |
---|
474 | uiCnt = 0; |
---|
475 | for(Int iX=0; iX < iWidth; iX++) |
---|
476 | { |
---|
477 | for(Int iY=0; iY < iHeight; iY++) |
---|
478 | { |
---|
479 | pBuffV[uiCnt] = iY*iWidth + iX; |
---|
480 | uiCnt ++; |
---|
481 | } |
---|
482 | } |
---|
483 | } |
---|
484 | } |
---|
485 | |
---|
486 | Int g_quantTSDefault4x4[16] = |
---|
487 | { |
---|
488 | 16,16,16,16, |
---|
489 | 16,16,16,16, |
---|
490 | 16,16,16,16, |
---|
491 | 16,16,16,16 |
---|
492 | }; |
---|
493 | |
---|
494 | Int g_quantIntraDefault8x8[64] = |
---|
495 | { |
---|
496 | 16,16,16,16,17,18,21,24, |
---|
497 | 16,16,16,16,17,19,22,25, |
---|
498 | 16,16,17,18,20,22,25,29, |
---|
499 | 16,16,18,21,24,27,31,36, |
---|
500 | 17,17,20,24,30,35,41,47, |
---|
501 | 18,19,22,27,35,44,54,65, |
---|
502 | 21,22,25,31,41,54,70,88, |
---|
503 | 24,25,29,36,47,65,88,115 |
---|
504 | }; |
---|
505 | |
---|
506 | Int g_quantInterDefault8x8[64] = |
---|
507 | { |
---|
508 | 16,16,16,16,17,18,20,24, |
---|
509 | 16,16,16,17,18,20,24,25, |
---|
510 | 16,16,17,18,20,24,25,28, |
---|
511 | 16,17,18,20,24,25,28,33, |
---|
512 | 17,18,20,24,25,28,33,41, |
---|
513 | 18,20,24,25,28,33,41,54, |
---|
514 | 20,24,25,28,33,41,54,71, |
---|
515 | 24,25,28,33,41,54,71,91 |
---|
516 | }; |
---|
517 | UInt g_scalingListSize [4] = {16,64,256,1024}; |
---|
518 | UInt g_scalingListSizeX [4] = { 4, 8, 16, 32}; |
---|
519 | UInt g_scalingListNum[SCALING_LIST_SIZE_NUM]={6,6,6,2}; |
---|
520 | Int g_eTTable[4] = {0,3,1,2}; |
---|
521 | |
---|
522 | #if SVC_EXTENSION |
---|
523 | Int g_mvScalingFactor [MAX_LAYERS][2] = {{0,0}, {0,0}}; |
---|
524 | Int g_posScalingFactor [MAX_LAYERS][2] = {{0,0}, {0,0}}; |
---|
525 | |
---|
526 | #if IL_SL_SIGNALLING_N0371 |
---|
527 | Int ref_scalingListDC [MAX_LAYERS][SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; |
---|
528 | Int ref_scalingListCoef [MAX_LAYERS][SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM][MAX_MATRIX_COEF_NUM]; |
---|
529 | Int activeRefPPSId [MAX_LAYERS]; |
---|
530 | Int activeRefSPSId [MAX_LAYERS]; |
---|
531 | #endif |
---|
532 | #endif |
---|
533 | |
---|
534 | //! \} |
---|