source: SHVCSoftware/branches/SHM-2.1-multilayers-dev/source/Lib/TLibCommon/TComRom.cpp @ 579

Last change on this file since 579 was 212, checked in by canon, 12 years ago

integration M0115 - Fast Intra Decision - cfg parameter: FIS (off by default)
edouard.francois@…

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