source: 3DVCSoftware/branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComRom.cpp @ 521

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

Integrated following changes:

  • H_MV_FIX1071, fix of encoder side reference list construction on IRAP pictures, same as in HM11.
  • H_3D_VSO_FIX_BORDRE_EXTENSION, fixed uninitialized borders for org-yuvs in VSO
  • H_MV_ENC_DEC_TRAC, added cu/pu level trace ( only enabled when ENC_DEC_TRACE is enabled)
  • Property svn:eol-style set to native
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
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#if H_MV_ENC_DEC_TRAC
327Bool g_traceCU = true; 
328Bool g_tracePU = true; 
329Bool g_traceTU = true; 
330Bool g_disableHLSTrace = false; 
331UInt64 g_stopAtCounter   = 10803; 
332#endif
333#endif
334// ====================================================================================================================
335// Scanning order & context model mapping
336// ====================================================================================================================
337
338// scanning order table
339UInt* g_auiSigLastScan[ 3 ][ MAX_CU_DEPTH ];
340
341const UInt g_sigLastScan8x8[ 3 ][ 4 ] =
342{
343  {0, 2, 1, 3},
344  {0, 1, 2, 3},
345  {0, 2, 1, 3}
346};
347UInt g_sigLastScanCG32x32[ 64 ];
348
349const UInt g_uiMinInGroup[ 10 ] = {0,1,2,3,4,6,8,12,16,24};
350const 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};
351
352// Rice parameters for absolute transform levels
353const UInt g_auiGoRiceRange[5] =
354{
355  7, 14, 26, 46, 78
356};
357
358const UInt g_auiGoRicePrefixLen[5] =
359{
360  8, 7, 6, 5, 4
361};
362
363Void initSigLastScan(UInt* pBuffD, UInt* pBuffH, UInt* pBuffV, Int iWidth, Int iHeight)
364{
365  const UInt  uiNumScanPos  = UInt( iWidth * iWidth );
366  UInt        uiNextScanPos = 0;
367
368  if( iWidth < 16 )
369  {
370  UInt* pBuffTemp = pBuffD;
371  if( iWidth == 8 )
372  {
373    pBuffTemp = g_sigLastScanCG32x32;
374  }
375  for( UInt uiScanLine = 0; uiNextScanPos < uiNumScanPos; uiScanLine++ )
376  {
377    Int    iPrimDim  = Int( uiScanLine );
378    Int    iScndDim  = 0;
379    while( iPrimDim >= iWidth )
380    {
381      iScndDim++;
382      iPrimDim--;
383    }
384    while( iPrimDim >= 0 && iScndDim < iWidth )
385    {
386      pBuffTemp[ uiNextScanPos ] = iPrimDim * iWidth + iScndDim ;
387      uiNextScanPos++;
388      iScndDim++;
389      iPrimDim--;
390    }
391  }
392  }
393  if( iWidth > 4 )
394  {
395    UInt uiNumBlkSide = iWidth >> 2;
396    UInt uiNumBlks    = uiNumBlkSide * uiNumBlkSide;
397    UInt log2Blk      = g_aucConvertToBit[ uiNumBlkSide ] + 1;
398
399    for( UInt uiBlk = 0; uiBlk < uiNumBlks; uiBlk++ )
400    {
401      uiNextScanPos   = 0;
402      UInt initBlkPos = g_auiSigLastScan[ SCAN_DIAG ][ log2Blk ][ uiBlk ];
403      if( iWidth == 32 )
404      {
405        initBlkPos = g_sigLastScanCG32x32[ uiBlk ];
406      }
407      UInt offsetY    = initBlkPos / uiNumBlkSide;
408      UInt offsetX    = initBlkPos - offsetY * uiNumBlkSide;
409      UInt offsetD    = 4 * ( offsetX + offsetY * iWidth );
410      UInt offsetScan = 16 * uiBlk;
411      for( UInt uiScanLine = 0; uiNextScanPos < 16; uiScanLine++ )
412      {
413        Int    iPrimDim  = Int( uiScanLine );
414        Int    iScndDim  = 0;
415        while( iPrimDim >= 4 )
416        {
417          iScndDim++;
418          iPrimDim--;
419        }
420        while( iPrimDim >= 0 && iScndDim < 4 )
421        {
422          pBuffD[ uiNextScanPos + offsetScan ] = iPrimDim * iWidth + iScndDim + offsetD;
423          uiNextScanPos++;
424          iScndDim++;
425          iPrimDim--;
426        }
427      }
428    }
429  }
430 
431  UInt uiCnt = 0;
432  if( iWidth > 2 )
433  {
434    UInt numBlkSide = iWidth >> 2;
435    for(Int blkY=0; blkY < numBlkSide; blkY++)
436    {
437      for(Int blkX=0; blkX < numBlkSide; blkX++)
438      {
439        UInt offset    = blkY * 4 * iWidth + blkX * 4;
440        for(Int y=0; y < 4; y++)
441        {
442          for(Int x=0; x < 4; x++)
443          {
444            pBuffH[uiCnt] = y*iWidth + x + offset;
445            uiCnt ++;
446          }
447        }
448      }
449    }
450
451    uiCnt = 0;
452    for(Int blkX=0; blkX < numBlkSide; blkX++)
453    {
454      for(Int blkY=0; blkY < numBlkSide; blkY++)
455      {
456        UInt offset    = blkY * 4 * iWidth + blkX * 4;
457        for(Int x=0; x < 4; x++)
458        {
459          for(Int y=0; y < 4; y++)
460          {
461            pBuffV[uiCnt] = y*iWidth + x + offset;
462            uiCnt ++;
463          }
464        }
465      }
466    }
467  }
468  else
469  {
470  for(Int iY=0; iY < iHeight; iY++)
471  {
472    for(Int iX=0; iX < iWidth; iX++)
473    {
474      pBuffH[uiCnt] = iY*iWidth + iX;
475      uiCnt ++;
476    }
477  }
478
479  uiCnt = 0;
480  for(Int iX=0; iX < iWidth; iX++)
481  {
482    for(Int iY=0; iY < iHeight; iY++)
483    {
484      pBuffV[uiCnt] = iY*iWidth + iX;
485      uiCnt ++;
486    }
487  }   
488  }
489}
490
491Int g_quantTSDefault4x4[16] =
492{
493  16,16,16,16,
494  16,16,16,16,
495  16,16,16,16,
496  16,16,16,16
497};
498
499Int g_quantIntraDefault8x8[64] =
500{
501  16,16,16,16,17,18,21,24,
502  16,16,16,16,17,19,22,25,
503  16,16,17,18,20,22,25,29,
504  16,16,18,21,24,27,31,36,
505  17,17,20,24,30,35,41,47,
506  18,19,22,27,35,44,54,65,
507  21,22,25,31,41,54,70,88,
508  24,25,29,36,47,65,88,115
509};
510
511Int g_quantInterDefault8x8[64] =
512{
513  16,16,16,16,17,18,20,24,
514  16,16,16,17,18,20,24,25,
515  16,16,17,18,20,24,25,28,
516  16,17,18,20,24,25,28,33,
517  17,18,20,24,25,28,33,41,
518  18,20,24,25,28,33,41,54,
519  20,24,25,28,33,41,54,71,
520  24,25,28,33,41,54,71,91
521};
522UInt g_scalingListSize   [4] = {16,64,256,1024}; 
523UInt g_scalingListSizeX  [4] = { 4, 8, 16,  32};
524UInt g_scalingListNum[SCALING_LIST_SIZE_NUM]={6,6,6,2};
525Int  g_eTTable[4] = {0,3,1,2};
526
527#if H_MV_ENC_DEC_TRAC
528#if ENC_DEC_TRACE
529Void writeToTraceFile( Char* symbolName, Int val, Bool doIt )
530{
531  if ( ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) && doIt  ) 
532  {
533    if ( g_stopAtCounter == g_nSymbolCounter )
534    {
535      std::cout << "Break point here." << std::endl; 
536    }
537    fprintf( g_hTrace, "%8lld  ", g_nSymbolCounter++ );
538    fprintf( g_hTrace, "%-50s       : %d\n", symbolName, val );     
539    fflush ( g_hTrace );
540    g_nSymbolCounter++; 
541  }
542}
543
544Void writeToTraceFile( Char* symbolName, Bool doIt )
545{
546  if ( ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) && doIt  ) 
547  {
548    fprintf( g_hTrace, "%s", symbolName );   
549    fflush ( g_hTrace );
550    g_nSymbolCounter++; 
551  }
552}
553
554#endif
555#endif
556//! \}
Note: See TracBrowser for help on using the repository browser.