source: 3DVCSoftware/tags/HTM-DEV-0.1/source/Lib/TLibCommon/TComRom.cpp @ 324

Last change on this file since 324 was 324, checked in by tech, 11 years ago

Initial development version for update to latest HM version.
Includes MV-HEVC and basic extensions for 3D-HEVC.

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