source: SHVCSoftware/branches/SHM-4.0-dev/source/Lib/TLibCommon/TComRom.cpp @ 918

Last change on this file since 918 was 467, checked in by seregin, 11 years ago

undelete the code from the previous revision

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