source: SHVCSoftware/branches/SHM-2.0-dev/source/Lib/TLibCommon/TComRom.cpp @ 444

Last change on this file since 444 was 137, checked in by mediatek, 12 years ago

M0133/M0449: inter-layer MV scaling and pixel mapping position calculation
Author: Peter Chuang <peter.chuang@…>

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