source: 3DVCSoftware/branches/HTM-5.1-dev1-LG/source/Lib/TLibCommon/TComRom.cpp @ 394

Last change on this file since 394 was 251, checked in by lg, 12 years ago

Integration of JCT3V-C0044

  • Property svn:eol-style set to native
File size: 46.9 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-2012, 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_auiFrameScanXY[ i ] = new UInt[ c*c ];
69    g_auiFrameScanX [ i ] = new UInt[ c*c ];
70    g_auiFrameScanY [ i ] = new UInt[ c*c ];
71    initFrameScanXY( g_auiFrameScanXY[i], g_auiFrameScanX[i], g_auiFrameScanY[i], c, c );
72    g_auiSigLastScan[0][i] = new UInt[ c*c ];
73    g_auiSigLastScan[1][i] = new UInt[ c*c ];
74    g_auiSigLastScan[2][i] = new UInt[ c*c ];
75    g_auiSigLastScan[3][i] = new UInt[ c*c ];
76    initSigLastScan( g_auiSigLastScan[0][i], g_auiSigLastScan[1][i], g_auiSigLastScan[2][i], g_auiSigLastScan[3][i], c, c, i);
77
78    c <<= 1;
79  } 
80
81  g_sigScanNSQT[0] = new UInt[ 64 ];  // 4x16
82  g_sigScanNSQT[1] = new UInt[ 256 ]; // 8x32
83  g_sigScanNSQT[2] = new UInt[ 64 ];  // 16x4
84  g_sigScanNSQT[3] = new UInt[ 256 ]; // 32x8
85 
86  static int diagScanX[ 16 ] =
87  {
88    0, 0, 1, 0, 1, 2, 0, 1, 2, 3, 1, 2, 3, 2, 3, 3
89  };
90  static int diagScanY[ 16 ] =
91  {
92    0, 1, 0, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 3, 2, 3
93  };
94 
95  Int j;
96  // 4x16 scan
97  for (i = 0; i < 4; i++)
98  {
99    for (j = 0; j < 16; j++)
100    {
101      g_sigScanNSQT[ 0 ][ 16 * i + j ] = 16 * i + 4 * diagScanY[ j ] + diagScanX[ j ];
102    }
103  }
104 
105  // 8x32 scan
106  for (i = 0; i < 16; i++)
107  {
108    Int x = g_sigCGScanNSQT[ 1 ][ i ] & 1;
109    Int y = g_sigCGScanNSQT[ 1 ][ i ] >> 1;
110   
111    for (j = 0; j < 16; j++)
112    {
113      g_sigScanNSQT[ 1 ][ 16 * i + j ] = 32 * y + 4 * x + 8 * diagScanY[ j ] + diagScanX[ j ];
114    }
115  }
116 
117  // 16x4 scan
118  for (i = 0; i < 4; i++)
119  {
120    for (j = 0; j < 16; j++)
121    {
122      g_sigScanNSQT[ 2 ][ 16 * i + j ] = 4 * i + 16 * diagScanY[ j ] + diagScanX[ j ];
123    }
124  }
125 
126  // 32x8 scan
127  for (i = 0; i < 16; i++)
128  {
129    Int x = g_sigCGScanNSQT[ 3 ][ i ] & 7;
130    Int y = g_sigCGScanNSQT[ 3 ][ i ] >> 3;
131   
132    for (j = 0; j < 16; j++)
133    {
134      g_sigScanNSQT[ 3 ][ 16 * i + j ] = 128 * y + 4 * x + 32 * diagScanY[ j ] + diagScanX[ j ];
135    }
136  }
137}
138
139Void destroyROM()
140{
141  Int i;
142 
143  for ( i=0; i<MAX_CU_DEPTH; i++ )
144  {
145    delete[] g_auiFrameScanXY[i];
146    delete[] g_auiFrameScanX [i];
147    delete[] g_auiFrameScanY [i];
148    delete[] g_auiSigLastScan[0][i];
149    delete[] g_auiSigLastScan[1][i];
150    delete[] g_auiSigLastScan[2][i];
151    delete[] g_auiSigLastScan[3][i];
152  }
153  for (i = 0; i < 4; i++)
154  {
155    delete[] g_sigScanNSQT[ i ];   
156  }
157
158#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
159  if ( !g_aacWedgeLists.empty() )
160  {
161    for ( UInt ui = 0; ui < g_aacWedgeLists.size(); ui++ )
162    {
163      g_aacWedgeLists[ui].clear();
164    }
165    g_aacWedgeLists.clear();
166  }
167
168  if ( !g_aacWedgeRefLists.empty() )
169  {
170    for ( UInt ui = 0; ui < g_aacWedgeRefLists.size(); ui++ )
171    {
172      g_aacWedgeRefLists[ui].clear();
173    }
174    g_aacWedgeRefLists.clear();
175  }
176#if HHIQC_DMMFASTSEARCH_B0039
177  if ( !g_aacWedgeNodeLists.empty() )
178  {
179    for ( UInt ui = 0; ui < g_aacWedgeNodeLists.size(); ui++ )
180    {
181      g_aacWedgeNodeLists[ui].clear();
182    }
183    g_aacWedgeNodeLists.clear();
184  }
185#endif
186#endif
187}
188
189// ====================================================================================================================
190// Data structure related table & variable
191// ====================================================================================================================
192
193UInt g_uiMaxCUWidth  = MAX_CU_SIZE;
194UInt g_uiMaxCUHeight = MAX_CU_SIZE;
195UInt g_uiMaxCUDepth  = MAX_CU_DEPTH;
196UInt g_uiAddCUDepth  = 0;
197
198UInt g_auiZscanToRaster [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, };
199UInt g_auiRasterToZscan [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, };
200UInt g_auiRasterToPelX  [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, };
201UInt g_auiRasterToPelY  [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, };
202UInt g_motionRefer   [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; 
203
204UInt g_auiPUOffset[8] = { 0, 8, 4, 4, 2, 10, 1, 5};
205
206Void initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx )
207{
208  Int iStride = 1 << ( iMaxDepth - 1 );
209 
210  if ( iDepth == iMaxDepth )
211  {
212    rpuiCurrIdx[0] = uiStartVal;
213    rpuiCurrIdx++;
214  }
215  else
216  {
217    Int iStep = iStride >> iDepth;
218    initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal,                     rpuiCurrIdx );
219    initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep,               rpuiCurrIdx );
220    initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride,       rpuiCurrIdx );
221    initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride+iStep, rpuiCurrIdx );
222  }
223}
224
225Void initRasterToZscan ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth )
226{
227  UInt  uiMinCUWidth  = uiMaxCUWidth  >> ( uiMaxDepth - 1 );
228  UInt  uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 );
229 
230  UInt  uiNumPartInWidth  = (UInt)uiMaxCUWidth  / uiMinCUWidth;
231  UInt  uiNumPartInHeight = (UInt)uiMaxCUHeight / uiMinCUHeight;
232 
233  for ( UInt i = 0; i < uiNumPartInWidth*uiNumPartInHeight; i++ )
234  {
235    g_auiRasterToZscan[ g_auiZscanToRaster[i] ] = i;
236  }
237}
238
239/** generate motion data compression mapping table
240* \param uiMaxCUWidth, width of LCU
241* \param uiMaxCUHeight, hight of LCU
242* \param uiMaxDepth, max depth of LCU
243* \returns Void
244*/
245Void initMotionReferIdx ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth )
246{
247  Int  minCUWidth  = (Int)uiMaxCUWidth  >> ( (Int)uiMaxDepth - 1 );
248  Int  minCUHeight = (Int)uiMaxCUHeight >> ( (Int)uiMaxDepth - 1 );
249
250  Int  numPartInWidth  = (Int)uiMaxCUWidth  / (Int)minCUWidth;
251  Int  numPartInHeight = (Int)uiMaxCUHeight / (Int)minCUHeight;
252
253  for ( Int i = 0; i < numPartInWidth*numPartInHeight; i++ )
254  {
255    g_motionRefer[i] = i;
256  }
257
258  Int compressionNum = 2;
259
260  for ( Int i = numPartInWidth*(numPartInHeight-1); i < numPartInWidth*numPartInHeight; i += compressionNum*2)
261  {
262    for ( Int j = 1; j < compressionNum; j++ )
263    {
264      g_motionRefer[g_auiRasterToZscan[i+j]] = g_auiRasterToZscan[i];
265    }
266  }
267
268  for ( Int i = numPartInWidth*(numPartInHeight-1)+compressionNum*2-1; i < numPartInWidth*numPartInHeight; i += compressionNum*2)
269  {
270    for ( Int j = 1; j < compressionNum; j++ )
271    {
272      g_motionRefer[g_auiRasterToZscan[i-j]] = g_auiRasterToZscan[i];
273    }
274  }
275}
276
277Void initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth )
278{
279  UInt    i;
280 
281  UInt* uiTempX = &g_auiRasterToPelX[0];
282  UInt* uiTempY = &g_auiRasterToPelY[0];
283 
284  UInt  uiMinCUWidth  = uiMaxCUWidth  >> ( uiMaxDepth - 1 );
285  UInt  uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 );
286 
287  UInt  uiNumPartInWidth  = uiMaxCUWidth  / uiMinCUWidth;
288  UInt  uiNumPartInHeight = uiMaxCUHeight / uiMinCUHeight;
289 
290  uiTempX[0] = 0; uiTempX++;
291  for ( i = 1; i < uiNumPartInWidth; i++ )
292  {
293    uiTempX[0] = uiTempX[-1] + uiMinCUWidth; uiTempX++;
294  }
295  for ( i = 1; i < uiNumPartInHeight; i++ )
296  {
297    memcpy(uiTempX, uiTempX-uiNumPartInWidth, sizeof(UInt)*uiNumPartInWidth);
298    uiTempX += uiNumPartInWidth;
299  }
300 
301  for ( i = 1; i < uiNumPartInWidth*uiNumPartInHeight; i++ )
302  {
303    uiTempY[i] = ( i / uiNumPartInWidth ) * uiMinCUWidth;
304  }
305};
306
307#if RWTH_SDC_DLT_B0036
308UInt g_auiSDCPredModes[RWTH_SDC_NUM_PRED_MODES] = { DC_IDX, DMM_WEDGE_FULL_IDX, DMM_WEDGE_PREDDIR_IDX, PLANAR_IDX };
309#endif
310
311Int g_quantScales[6] =
312{
313  26214,23302,20560,18396,16384,14564
314};   
315
316Int g_invQuantScales[6] =
317{
318  40,45,51,57,64,72
319};
320
321const short g_aiT4[4][4] =
322{
323  { 64, 64, 64, 64},
324  { 83, 36,-36,-83},
325  { 64,-64,-64, 64},
326  { 36,-83, 83,-36}
327};
328
329const short g_aiT8[8][8] =
330{
331  { 64, 64, 64, 64, 64, 64, 64, 64},
332  { 89, 75, 50, 18,-18,-50,-75,-89},
333  { 83, 36,-36,-83,-83,-36, 36, 83},
334  { 75,-18,-89,-50, 50, 89, 18,-75},
335  { 64,-64,-64, 64, 64,-64,-64, 64},
336  { 50,-89, 18, 75,-75,-18, 89,-50},
337  { 36,-83, 83,-36,-36, 83,-83, 36},
338  { 18,-50, 75,-89, 89,-75, 50,-18}
339};
340
341const short g_aiT16[16][16] =
342{
343  { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64},
344  { 90, 87, 80, 70, 57, 43, 25,  9, -9,-25,-43,-57,-70,-80,-87,-90},
345  { 89, 75, 50, 18,-18,-50,-75,-89,-89,-75,-50,-18, 18, 50, 75, 89},
346  { 87, 57,  9,-43,-80,-90,-70,-25, 25, 70, 90, 80, 43, -9,-57,-87},
347  { 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83},
348  { 80,  9,-70,-87,-25, 57, 90, 43,-43,-90,-57, 25, 87, 70, -9,-80},
349  { 75,-18,-89,-50, 50, 89, 18,-75,-75, 18, 89, 50,-50,-89,-18, 75},
350  { 70,-43,-87,  9, 90, 25,-80,-57, 57, 80,-25,-90, -9, 87, 43,-70},
351  { 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64},
352  { 57,-80,-25, 90, -9,-87, 43, 70,-70,-43, 87,  9,-90, 25, 80,-57},
353  { 50,-89, 18, 75,-75,-18, 89,-50,-50, 89,-18,-75, 75, 18,-89, 50},
354  { 43,-90, 57, 25,-87, 70,  9,-80, 80, -9,-70, 87,-25,-57, 90,-43},
355  { 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36},
356  { 25,-70, 90,-80, 43,  9,-57, 87,-87, 57, -9,-43, 80,-90, 70,-25},
357  { 18,-50, 75,-89, 89,-75, 50,-18,-18, 50,-75, 89,-89, 75,-50, 18},
358  {  9,-25, 43,-57, 70,-80, 87,-90, 90,-87, 80,-70, 57,-43, 25, -9}
359};
360
361const short g_aiT32[32][32] =
362{
363  { 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},
364  { 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},
365  { 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},
366  { 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},
367  { 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},
368  { 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},
369  { 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},
370  { 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},
371  { 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},
372  { 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},
373  { 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},
374  { 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},
375  { 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},
376  { 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},
377  { 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},
378  { 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},
379  { 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},
380  { 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},
381  { 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},
382  { 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},
383  { 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},
384  { 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},
385  { 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},
386  { 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},
387  { 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},
388  { 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},
389  { 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},
390  { 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},
391  { 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},
392  { 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},
393  {  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},
394  {  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}
395};
396
397const UChar g_aucChromaScale[52]=
398{
399  0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,
400  12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,
401  28,29,29,30,31,32,32,33,34,34,35,35,36,36,37,37,
402  37,38,38,38,39,39,39,39
403};
404
405
406// Mode-Dependent DCT/DST
407const short g_as_DST_MAT_4 [4][4]=
408{
409  {29,   55,    74,   84},
410  {74,   74,    0 ,  -74},
411  {84,  -29,   -74,   55},
412  {55,  -84,    74,  -29},
413};
414
415#if !LOGI_INTRA_NAME_3MPM
416// Mapping each Unified Directional Intra prediction direction to DCT/DST transform
417// 0 implies use DCT, 1 implies DST
418
419#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
420const UChar g_aucDCTDSTMode_Vert[NUM_INTRA_MODE+NUM_DMM_MODE] =
421#else
422const UChar g_aucDCTDSTMode_Vert[NUM_INTRA_MODE] =
423#endif
424{ //0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
425  1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0
426#if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX
427  , 0, 0, 0, 0, 0, 0, 0, 0
428#elif HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
429  , 0, 0, 0, 0
430#endif
431};
432#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
433const UChar g_aucDCTDSTMode_Hor[NUM_INTRA_MODE+NUM_DMM_MODE] =
434#else
435const UChar g_aucDCTDSTMode_Hor[NUM_INTRA_MODE] =
436#endif
437{ //0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
438  1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0
439#if HHI_DMM_WEDGE_INTRA && HHI_DMM_PRED_TEX
440  , 0, 0, 0, 0, 0, 0, 0, 0
441#elif HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
442  , 0, 0, 0, 0
443#endif
444};
445#endif
446
447
448// ====================================================================================================================
449// ADI
450// ====================================================================================================================
451
452#if FAST_UDI_USE_MPM
453const UChar g_aucIntraModeNumFast[7] =
454{
455  3,  //   2x2
456  8,  //   4x4
457  8,  //   8x8
458  3,  //  16x16   
459  3,  //  32x32   
460  3,  //  64x64   
461  3   // 128x128 
462};
463#else // FAST_UDI_USE_MPM
464const UChar g_aucIntraModeNumFast[7] =
465{
466  3,  //   2x2
467  9,  //   4x4
468  9,  //   8x8
469  4,  //  16x16   33
470  4,  //  32x32   33
471  5,  //  64x64   33
472  4   // 128x128  33
473};
474#endif // FAST_UDI_USE_MPM
475
476// chroma
477
478const UChar g_aucConvertTxtTypeToIdx[4] = { 0, 1, 1, 2 };
479
480#if !LOGI_INTRA_NAME_3MPM
481// ====================================================================================================================
482// Angular Intra prediction
483// ====================================================================================================================
484
485// g_aucAngIntraModeOrder
486//   Indexing this array with the mode indicated in the bitstream
487//   gives a logical index used in the prediction functions.
488const UChar g_aucAngIntraModeOrder[NUM_INTRA_MODE] =
489{     //  ModeOrder LogicalOrderInPredFunctions
490  34, //  PLANAR_IDX PLANAR PLANAR
491  9,  //  0 VER     DC
492  25, //  1 HOR     VER-8 (diagonal from top-left to bottom-right = HOR-8)
493  0,  //  2 DC      VER-7
494  1,  //  4 VER-8   VER-6
495  5,  //  5 VER-4   VER-5
496  13, //  6 VER+4   VER-4
497  17, //  7 VER+8   VER-3
498  21, //  8 HOR-4   VER-2
499  29, //  9 HOR+4   VER-1
500  33, // 10 HOR+8   VER
501  3,  // 11 VER-6   VER+1
502  7,  // 12 VER-2   VER+2
503  11, // 13 VER+2   VER+3
504  15, // 14 VER+6   VER+4
505  19, // 15 HOR-6   VER+5
506  23, // 16 HOR-2   VER+6
507  27, // 17 HOR+2   VER+7
508  31, // 18 HOR+6   VER+8
509  2,  // 19 VER-7   HOR-7
510  4,  // 20 VER-5   HOR-6
511  6,  // 21 VER-3   HOR-5
512  8,  // 22 VER-1   HOR-4
513  10, // 23 VER+1   HOR-3
514  12, // 24 VER+3   HOR-2
515  14, // 25 VER+5   HOR-1
516  16, // 26 VER+7   HOR
517  18, // 27 HOR-7   HOR+1
518  20, // 28 HOR-5   HOR+2
519  22, // 29 HOR-3   HOR+3
520  24, // 30 HOR-1   HOR+4
521  26, // 31 HOR+1   HOR+5
522  28, // 32 HOR+3   HOR+6
523  30, // 33 HOR+5   HOR+7
524  32, // 34 HOR+7   HOR+8
525  0, // LM_CHROMA_IDX
526};
527
528const UChar g_aucIntraModeNumAng[7] =
529{
530  4,  //   2x2
531  18,  //   4x4
532  35,  //   8x8
533  35,  //  16x16
534  35,  //  32x32
535  35,  //  64x64
536  6   // 128x128
537};
538
539const UChar g_aucIntraModeBitsAng[7] =
540{
541  2,  //   2x2     3   1+1
542  5,  //   4x4    17   4+1
543  6,  //   8x8    34   5+esc
544  6,  //  16x16   34   5+esc
545  6,  //  32x32   34   5+esc
546  6,  //  64x64   34   5+esc
547  3   // 128x128   5   2+1
548};
549#endif
550
551// ====================================================================================================================
552// Bit-depth
553// ====================================================================================================================
554
555UInt g_uiBitDepth     = 8;    // base bit-depth
556UInt g_uiBitIncrement = 0;    // increments
557UInt g_uiIBDI_MAX     = 255;  // max. value after  IBDI
558UInt g_uiBASE_MAX     = 255;  // max. value before IBDI
559
560UInt g_uiPCMBitDepthLuma     = 8;    // PCM bit-depth
561UInt g_uiPCMBitDepthChroma   = 8;    // PCM bit-depth
562
563// ====================================================================================================================
564// Depth model modes
565// ====================================================================================================================
566#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
567Int g_iDeltaDCsQuantOffset = 0;
568
569const WedgeResolution g_aeWedgeResolutionList[5] = 
570{
571  HALF_PEL,    //  4x4
572  HALF_PEL,    //  8x8
573  FULL_PEL,    // 16x16
574  DOUBLE_PEL,  // 32x32
575  DOUBLE_PEL   // 64x64
576};
577
578const UChar g_aucWedgeFullBitsListIdx[7] =
579{
580  0,   //   2x2
581  7,   //   4x4    WedgeListSize[  HALF_PEL]   86
582  10,  //   8x8    WedgeListSize[  HALF_PEL]  782
583  11,  //  16x16   WedgeListSize[  FULL_PEL] 1394
584  11,  //  32x32   WedgeListSize[DOUBLE_PEL] 1503
585  13,  //  64x64   WedgeListSize[DOUBLE_PEL] 6079
586  0    // 128x128 
587};
588
589#if LGE_DMM3_SIMP_C0044
590const UChar g_aucWedgeTexPredBitsListIdx[7] =
591{
592  0,   //   2x2
593  6,   //   4x4   
594  9,  //   8x8   
595  9,  //  16x16   
596  9,  //  32x32   
597  0,  //  64x64   
598  0    // 128x128 
599};
600#endif
601
602const UChar g_aucIntraSizeIdxToWedgeSize[7] =
603{
604  2,
605  4,
606  8,
607  16,
608  32,
609  64,
610  128
611};
612#endif
613
614// ====================================================================================================================
615// Misc.
616// ====================================================================================================================
617
618Char  g_aucConvertToBit  [ MAX_CU_SIZE+1 ];
619
620#if ENC_DEC_TRACE
621FILE*  g_hTrace = NULL;
622const Bool g_bEncDecTraceEnable  = true;
623const Bool g_bEncDecTraceDisable = false;
624Bool   g_bJustDoIt = false;
625UInt64 g_nSymbolCounter = 0;
626#endif
627// ====================================================================================================================
628// Scanning order & context model mapping
629// ====================================================================================================================
630
631// scanning order table
632UInt* g_auiFrameScanXY[ MAX_CU_DEPTH  ];
633UInt* g_auiFrameScanX [ MAX_CU_DEPTH  ];
634UInt* g_auiFrameScanY [ MAX_CU_DEPTH  ];
635UInt* g_auiSigLastScan[4][ MAX_CU_DEPTH ];
636UInt *g_sigScanNSQT[ 4 ]; // scan for non-square partitions
637UInt g_sigCGScanNSQT[ 4 ][ 16 ] =
638{
639  { 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
640  { 0, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15 },
641  { 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
642  { 0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15 }
643};
644
645#if MULTILEVEL_SIGMAP_EXT
646const UInt g_sigLastScan8x8[ 4 ][ 4 ] =
647{
648  {0, 1, 2, 3},
649  {0, 1, 2, 3},
650  {0, 1, 2, 3},
651  {0, 2, 1, 3}
652};
653UInt g_sigLastScanCG32x32[ 64 ];
654#endif
655
656UInt* g_auiNonSquareSigLastScan[ 4 ];
657
658const UInt g_uiMinInGroup[ 10 ] = {0,1,2,3,4,6,8,12,16,24};
659const 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};
660#if LAST_CTX_REDUCTION
661const UInt g_uiLastCtx[ 28 ]    = 
662{
663  0,   1,  2,  2,                         // 4x4    4
664  3,   4,  5,  5, 2,  2,                  // 8x8    6 
665  6,   7,  8,  8, 9,  9, 2, 2,            // 16x16  8
666  10, 11, 12, 12, 13, 13, 14, 14, 2, 2    // 32x32  10
667};
668#else
669const UInt g_uiLastCtx[ 28 ]    = 
670{
671  0,   1,  2,  2,                         // 4x4    4
672  3,   4,  5,  5, 6,  6,                  // 8x8    6 
673  7,   8,  9,  9, 10, 10, 11, 11,         // 16x16  8
674  12, 13, 14, 14, 15, 15, 16, 16, 17, 17  // 32x32  10
675};
676#endif
677
678// Rice parameters for absolute transform levels
679#if EIGHT_BITS_RICE_CODE
680const UInt g_auiGoRiceRange[5] =
681{
682  7, 14, 26, 46, 78
683};
684
685const UInt g_auiGoRicePrefixLen[5] =
686{
687  8, 7, 6, 5, 4
688};
689#else
690const UInt g_auiGoRiceRange[4] =
691{
692  7, 20, 42, 70
693};
694
695const UInt g_auiGoRicePrefixLen[4] =
696{
697  8, 10, 10, 8
698};
699#endif
700
701#if EIGHT_BITS_RICE_CODE
702const UInt g_aauiGoRiceUpdate[5][24] =
703{
704#if RESTRICT_GR1GR2FLAG_NUMBER
705  {
706    0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4
707  },
708  {
709    1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4
710  },
711  {
712    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4
713  },
714  {
715    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4
716  },
717  {
718    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
719  }
720#else
721  {
722    0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4
723  },
724  {
725    1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4
726  },
727  {
728    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4
729  },
730  {
731    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4
732  },
733  {
734    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
735  }
736#endif
737};
738#else
739const UInt g_aauiGoRiceUpdate[4][16] =
740{
741#if RESTRICT_GR1GR2FLAG_NUMBER
742  {
743    0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3,
744  },
745  { 
746    1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3,
747  },
748  { 
749    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3,
750  },
751  { 
752    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
753  }
754#else 
755  {
756    0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3
757  },
758  {
759    1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3
760  },
761  {
762    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3
763  },
764  {
765    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
766  }
767#endif
768};
769#endif
770
771// initialize g_auiFrameScanXY
772Void initFrameScanXY( UInt* pBuff, UInt* pBuffX, UInt* pBuffY, Int iWidth, Int iHeight )
773{
774  Int x, y, c = 0;
775 
776  // starting point
777  pBuffX[ c ] = 0;
778  pBuffY[ c ] = 0;
779  pBuff[ c++ ] = 0;
780 
781  // loop
782  x=1; y=0;
783  while (1)
784  {
785    // decrease loop
786    while ( x>=0 )
787    {
788      if ( x >= 0 && x < iWidth && y >= 0 && y < iHeight )
789      {
790        pBuffX[ c ] = x;
791        pBuffY[ c ] = y;
792        pBuff[ c++ ] = x+y*iWidth;
793      }
794      x--; y++;
795    }
796    x=0;
797   
798    // increase loop
799    while ( y>=0 )
800    {
801      if ( x >= 0 && x < iWidth && y >= 0 && y < iHeight )
802      {
803        pBuffX[ c ] = x;
804        pBuffY[ c ] = y;
805        pBuff[ c++ ] = x+y*iWidth;
806      }
807      x++; y--;
808    }
809    y=0;
810   
811    // termination condition
812    if ( c >= iWidth*iHeight ) break;
813  } 
814}
815
816Void initSigLastScan(UInt* pBuffZ, UInt* pBuffH, UInt* pBuffV, UInt* pBuffD, Int iWidth, Int iHeight, Int iDepth)
817{
818  const UInt  uiNumScanPos  = UInt( iWidth * iWidth );
819  UInt        uiNextScanPos = 0;
820
821  if( iWidth < 16 )
822  {
823#if MULTILEVEL_SIGMAP_EXT
824  UInt* pBuffTemp = pBuffD;
825  if( iWidth == 8 )
826  {
827    pBuffTemp = g_sigLastScanCG32x32;
828  }
829#endif
830  for( UInt uiScanLine = 0; uiNextScanPos < uiNumScanPos; uiScanLine++ )
831  {
832    int    iPrimDim  = int( uiScanLine );
833    int    iScndDim  = 0;
834    while( iPrimDim >= iWidth )
835    {
836      iScndDim++;
837      iPrimDim--;
838    }
839    while( iPrimDim >= 0 && iScndDim < iWidth )
840    {
841#if MULTILEVEL_SIGMAP_EXT
842      pBuffTemp[ uiNextScanPos ] = iPrimDim * iWidth + iScndDim ;
843#else
844      pBuffD[ uiNextScanPos ] = iPrimDim * iWidth + iScndDim ;
845#endif
846      uiNextScanPos++;
847      iScndDim++;
848      iPrimDim--;
849    }
850  }
851  }
852#if MULTILEVEL_SIGMAP_EXT
853  if( iWidth > 4 )
854#else
855  else
856#endif
857  {
858    UInt uiNumBlkSide = iWidth >> 2;
859    UInt uiNumBlks    = uiNumBlkSide * uiNumBlkSide;
860    UInt log2Blk      = g_aucConvertToBit[ uiNumBlkSide ] + 1;
861
862    for( UInt uiBlk = 0; uiBlk < uiNumBlks; uiBlk++ )
863    {
864      uiNextScanPos   = 0;
865      UInt initBlkPos = g_auiSigLastScan[ SCAN_DIAG ][ log2Blk ][ uiBlk ];
866#if MULTILEVEL_SIGMAP_EXT
867      if( iWidth == 32 )
868      {
869        initBlkPos = g_sigLastScanCG32x32[ uiBlk ];
870      }
871#endif
872      UInt offsetY    = initBlkPos / uiNumBlkSide;
873      UInt offsetX    = initBlkPos - offsetY * uiNumBlkSide;
874      UInt offsetD    = 4 * ( offsetX + offsetY * iWidth );
875      UInt offsetScan = 16 * uiBlk;
876      for( UInt uiScanLine = 0; uiNextScanPos < 16; uiScanLine++ )
877      {
878        int    iPrimDim  = int( uiScanLine );
879        int    iScndDim  = 0;
880        while( iPrimDim >= 4 )
881        {
882          iScndDim++;
883          iPrimDim--;
884        }
885        while( iPrimDim >= 0 && iScndDim < 4 )
886        {
887          pBuffD[ uiNextScanPos + offsetScan ] = iPrimDim * iWidth + iScndDim + offsetD;
888          uiNextScanPos++;
889          iScndDim++;
890          iPrimDim--;
891        }
892      }
893    }
894  }
895 
896  memcpy(pBuffZ, g_auiFrameScanXY[iDepth], sizeof(UInt)*iWidth*iHeight);
897
898  UInt uiCnt = 0;
899  for(Int iY=0; iY < iHeight; iY++)
900  {
901    for(Int iX=0; iX < iWidth; iX++)
902    {
903      pBuffH[uiCnt] = iY*iWidth + iX;
904      uiCnt ++;
905    }
906  }
907
908  uiCnt = 0;
909  for(Int iX=0; iX < iWidth; iX++)
910  {
911    for(Int iY=0; iY < iHeight; iY++)
912    {
913      pBuffV[uiCnt] = iY*iWidth + iX;
914      uiCnt ++;
915    }
916  }   
917}
918
919Void initNonSquareSigLastScan(UInt* pBuffZ, UInt uiWidth, UInt uiHeight)
920{
921
922  Int x, y, c = 0;
923
924  // starting point
925  pBuffZ[ c++ ] = 0;
926
927  // loop
928  if ( uiWidth > uiHeight )
929  {
930    x=0; y=1;
931    while (1)
932    {
933      // increase loop
934      while ( y>=0 )
935      {
936        if ( x >= 0 && x < uiWidth && y >= 0 && y < uiHeight )
937        {
938          pBuffZ[ c++ ] = x + y * uiWidth;
939        }
940        x++;
941        y--;
942      }
943      y=0;
944
945      // decrease loop
946      while ( x>=0 )
947      {
948        if ( x >= 0 && x < uiWidth && y >= 0 && y < uiHeight )
949        {
950          pBuffZ[ c++ ] = x + y * uiWidth;
951        }
952        x--;
953        y++;
954      }
955      x=0;
956
957      // termination condition
958      if ( c >= uiWidth * uiHeight ) 
959        break;
960    }
961  }
962  else
963  {
964    x=1; y=0;
965    while (1)
966    {
967      // increase loop
968      while ( x>=0 )
969      {
970        if ( x >= 0 && x < uiWidth && y >= 0 && y < uiHeight )
971        {
972          pBuffZ[ c++ ] = x + y * uiWidth;
973        }
974        x--;
975        y++;
976      }
977      x=0;
978
979      // decrease loop
980      while ( y>=0 )
981      {
982        if ( x >= 0 && x < uiWidth && y >= 0 && y < uiHeight )
983        {
984          pBuffZ[ c++ ] = x + y * uiWidth;
985        }
986        x++;
987        y--;
988      }
989      y=0;
990
991      // termination condition
992      if ( c >= uiWidth * uiHeight ) 
993        break;
994    }
995  }
996}
997
998#if SCALING_LIST
999Int g_quantIntraDefault4x4[16] =
1000{
1001  16,16,17,21,
1002  16,17,20,25,
1003  17,20,30,41,
1004  21,25,41,70
1005};
1006Int g_quantInterDefault4x4[16] =
1007{
1008  16,16,17,21,
1009  16,17,21,24,
1010  17,21,24,36,
1011  21,24,36,57
1012};
1013
1014Int g_quantIntraDefault8x8[64] =
1015{
1016  16,16,16,16,17,18,21,24,
1017  16,16,16,16,17,19,22,25,
1018  16,16,17,18,20,22,25,29,
1019  16,16,18,21,24,27,31,36,
1020  17,17,20,24,30,35,41,47,
1021  18,19,22,27,35,44,54,65,
1022  21,22,25,31,41,54,70,88,
1023  24,25,29,36,47,65,88,115
1024};
1025
1026Int g_quantInterDefault8x8[64] =
1027{
1028  16,16,16,16,17,18,20,24,
1029  16,16,16,17,18,20,24,25,
1030  16,16,17,18,20,24,25,28,
1031  16,17,18,20,24,25,28,33,
1032  17,18,20,24,25,28,33,41,
1033  18,20,24,25,28,33,41,54,
1034  20,24,25,28,33,41,54,71,
1035  24,25,28,33,41,54,71,91
1036};
1037#else
1038Int g_quantIntraDefault4x4[16] =
1039{
1040   6,13,20,28,
1041  13,20,28,32,
1042  20,28,32,37,
1043  28,32,37,42
1044};
1045Int g_quantInterDefault4x4[16] =
1046{
1047  10,14,20,24,
1048  14,20,24,27,
1049  20,24,27,30,
1050  24,27,30,34
1051};
1052
1053Int g_quantIntraDefault8x8[64] =
1054{
1055   6,10,13,16,18,23,25,27,
1056  10,11,16,18,23,25,27,29,
1057  13,16,18,23,25,27,29,31,
1058  16,18,23,25,27,29,31,33,
1059  18,23,25,27,29,31,33,36,
1060  23,25,27,29,31,33,36,38,
1061  25,27,29,31,33,36,38,40,
1062  27,29,31,33,36,38,40,42
1063};
1064
1065Int g_quantInterDefault8x8[64] =
1066{
1067   9,13,15,17,19,21,22,24,
1068  13,13,17,19,21,22,24,25,
1069  15,17,19,21,22,24,25,27,
1070  17,19,21,22,24,25,27,28,
1071  19,21,22,24,25,27,28,30,
1072  21,22,24,25,27,28,30,32,
1073  22,24,25,27,28,30,32,33,
1074  24,25,27,28,30,32,33,35
1075};
1076
1077Int g_quantIntraDefault16x16[256] =
1078{
1079  16,16,16,16,16,16,16,16,17,17,18,19,21,22,24,27,
1080  16,16,16,16,16,16,16,16,17,18,18,20,21,23,25,27,
1081  16,16,16,16,16,16,16,17,17,18,19,20,22,23,25,28,
1082  16,16,16,16,16,16,17,17,18,19,20,21,23,25,27,29,
1083  16,16,16,16,17,17,18,19,20,21,22,23,25,27,29,31,
1084  16,16,16,16,17,18,19,20,22,23,24,26,27,29,32,34,
1085  16,16,16,17,18,19,21,23,24,25,27,29,31,33,36,39,
1086  16,16,17,17,19,20,23,25,27,29,31,33,35,38,41,44,
1087  17,17,17,18,20,22,24,27,30,32,35,38,41,44,47,51,
1088  17,18,18,19,21,23,25,29,32,36,40,43,47,51,55,60,
1089  18,18,19,20,22,24,27,31,35,40,44,49,54,59,65,70,
1090  19,20,20,21,23,26,29,33,38,43,49,56,62,69,75,82,
1091  21,21,22,23,25,27,31,35,41,47,54,62,70,79,88,97,
1092  22,23,23,25,27,29,33,38,44,51,59,69,79,90,101,113,
1093  24,25,25,27,29,32,36,41,47,55,65,75,88,101,115,130,
1094  27,27,28,29,31,34,39,44,51,60,70,82,97,113,130,149
1095};
1096
1097Int g_quantInterDefault16x16[256] =
1098{
1099  16,16,16,16,16,16,16,16,17,17,18,19,20,21,22,27,
1100  16,16,16,16,16,16,16,17,17,18,19,20,21,22,27,27,
1101  16,16,16,16,16,16,17,17,18,19,20,21,22,27,27,28,
1102  16,16,16,16,16,17,17,18,19,20,21,22,27,27,28,29,
1103  16,16,16,16,17,17,18,19,20,21,22,27,27,28,29,30,
1104  16,16,16,17,17,18,19,20,21,22,27,27,28,29,30,32,
1105  16,16,17,17,18,19,20,21,22,27,27,28,29,30,32,36,
1106  16,17,17,18,19,20,21,22,27,27,28,29,30,32,36,40,
1107  17,17,18,19,20,21,22,27,27,28,29,30,32,36,40,45,
1108  17,18,19,20,21,22,27,27,28,29,30,32,36,40,45,52,
1109  18,19,20,21,22,27,27,28,29,30,32,36,40,45,52,59,
1110  19,20,21,22,27,27,28,29,30,32,36,40,45,52,59,68,
1111  20,21,22,27,27,28,29,30,32,36,40,45,52,59,68,79,
1112  21,22,27,27,28,29,30,32,36,40,45,52,59,68,79,91,
1113  22,27,27,28,29,30,32,36,40,45,52,59,68,79,91,103,
1114  27,27,28,29,30,32,36,40,45,52,59,68,79,91,103,117
1115};
1116
1117Int g_quantIntraDefault32x32[1024] =
1118{
1119  16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,27,28,
1120  16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,23,23,24,25,27,28,
1121  16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,18,19,20,20,21,22,23,24,25,26,27,28,
1122  16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,21,22,23,24,25,26,27,28,
1123  16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,20,21,22,23,23,24,25,26,28,29,
1124  16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,18,19,19,20,21,21,22,23,24,25,26,27,28,30,
1125  16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,18,18,19,19,20,20,21,21,22,23,24,25,26,27,28,29,30,
1126  16,16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,19,19,20,20,21,21,22,23,24,25,26,27,28,29,30,31,
1127  16,16,16,16,16,16,16,16,17,17,17,18,18,18,19,19,20,20,21,21,22,22,23,24,25,26,27,28,29,30,31,33,
1128  16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,20,20,21,22,22,23,23,24,25,26,27,28,29,30,31,33,34,
1129  16,16,16,16,16,16,16,17,17,18,18,19,19,20,20,21,22,22,23,23,24,25,26,26,27,28,29,30,32,33,34,36,
1130  16,16,16,16,16,16,17,17,18,18,19,20,20,21,21,22,23,23,24,25,25,26,27,28,29,30,31,32,33,35,36,38,
1131  16,16,16,16,16,16,17,17,18,19,19,20,21,22,23,23,24,25,25,26,27,28,29,30,31,32,33,34,36,37,39,40,
1132  16,16,16,16,16,17,17,18,18,19,20,21,22,23,24,24,25,26,27,28,29,30,31,32,33,34,35,37,38,39,41,43,
1133  16,16,16,16,17,17,17,18,19,20,20,21,23,24,25,26,27,28,29,30,31,32,33,34,35,36,38,39,41,42,44,46,
1134  16,16,17,17,17,17,18,18,19,20,21,22,23,24,26,27,28,29,31,32,33,34,35,37,38,39,41,42,44,45,47,49,
1135  17,17,17,17,17,18,18,19,20,20,22,23,24,25,27,28,30,31,32,34,35,36,38,39,41,42,44,45,47,49,51,53,
1136  17,17,17,17,18,18,19,19,20,21,22,23,25,26,28,29,31,33,34,36,37,39,41,42,44,45,47,49,51,53,55,57,
1137  17,17,18,18,18,18,19,20,21,22,23,24,25,27,29,31,32,34,36,38,40,42,43,45,47,49,51,53,55,57,60,62,
1138  18,18,18,18,19,19,20,20,21,22,23,25,26,28,30,32,34,36,38,40,42,44,46,48,51,53,55,57,60,62,65,67,
1139  18,18,18,19,19,19,20,21,22,23,24,25,27,29,31,33,35,37,40,42,44,47,49,52,54,57,59,62,65,67,70,73,
1140  19,19,19,19,20,20,21,21,22,23,25,26,28,30,32,34,36,39,42,44,47,50,52,55,58,61,64,67,70,73,76,79,
1141  19,19,20,20,20,21,21,22,23,24,26,27,29,31,33,35,38,41,43,46,49,52,56,59,62,65,69,72,75,79,82,86,
1142  20,20,20,21,21,21,22,23,24,25,26,28,30,32,34,37,39,42,45,48,52,55,59,62,66,70,74,77,81,85,89,93,
1143  21,21,21,21,22,22,23,24,25,26,27,29,31,33,35,38,41,44,47,51,54,58,62,66,70,74,79,83,88,92,97,101,
1144  22,22,22,22,23,23,24,25,26,27,28,30,32,34,36,39,42,45,49,53,57,61,65,70,74,79,84,89,94,99,104,110,
1145  22,23,23,23,23,24,25,26,27,28,29,31,33,35,38,41,44,47,51,55,59,64,69,74,79,84,90,95,101,107,113,119,
1146  23,23,24,24,24,25,26,27,28,29,30,32,34,37,39,42,45,49,53,57,62,67,72,77,83,89,95,101,108,114,121,128,
1147  24,24,25,25,25,26,27,28,29,30,32,33,36,38,41,44,47,51,55,60,65,70,75,81,88,94,101,108,115,122,130,138,
1148  25,25,26,26,26,27,28,29,30,31,33,35,37,39,42,45,49,53,57,62,67,73,79,85,92,99,107,114,122,131,139,148,
1149  27,27,27,27,28,28,29,30,31,33,34,36,39,41,44,47,51,55,60,65,70,76,82,89,97,104,113,121,130,139,149,159,
1150  28,28,28,28,29,30,30,31,33,34,36,38,40,43,46,49,53,57,62,67,73,79,86,93,101,110,119,128,138,148,159,170
1151};
1152
1153Int g_quantInterDefault32x32[1024] =
1154{
1155  16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,
1156  16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,
1157  16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,
1158  16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,
1159  16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,
1160  16,16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,
1161  16,16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,
1162  16,16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,
1163  16,16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,
1164  16,16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,
1165  16,16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,
1166  16,16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,
1167  16,16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,
1168  16,16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,
1169  16,16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,
1170  16,17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,
1171  17,17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,
1172  17,17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,
1173  17,18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,
1174  18,18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,
1175  18,19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,
1176  19,19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,
1177  19,20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,
1178  20,21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,
1179  21,22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,
1180  22,22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,
1181  22,23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94,
1182  23,24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94,101,
1183  24,25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94,101,108,
1184  25,26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94,101,108,115,
1185  26,28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94,101,108,115,123,
1186  28,28,28,28,29,30,30,31,32,33,34,35,36,38,40,42,45,48,52,56,60,64,69,74,80,87,94,101,108,115,123,131
1187};
1188#endif
1189UInt g_scalingListSize   [4] = {16,64,256,1024}; 
1190UInt g_scalingListSizeX  [4] = { 4, 8, 16,  32};
1191UInt g_scalingListNum[SCALING_LIST_SIZE_NUM]={6,6,6,2};
1192Int  g_eTTable[4] = {0,3,1,2};
1193
1194#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
1195std::vector< std::vector<TComWedgelet> > g_aacWedgeLists;
1196std::vector< std::vector<TComWedgeRef> > g_aacWedgeRefLists;
1197
1198#if HHIQC_DMMFASTSEARCH_B0039
1199std::vector< std::vector< std::vector<UInt> > > g_aauiWdgLstM3;
1200std::vector< std::vector< TComWedgeNode> >      g_aacWedgeNodeLists;
1201#endif
1202
1203Void initWedgeLists()
1204{
1205  for( UInt ui = g_aucConvertToBit[DMM_WEDGEMODEL_MIN_SIZE]; ui < (g_aucConvertToBit[DMM_WEDGEMODEL_MAX_SIZE]+1); ui++ )
1206  {
1207    UInt uiWedgeBlockSize = ((UInt)DMM_WEDGEMODEL_MIN_SIZE)<<ui;
1208    std::vector<TComWedgelet> acWedgeList;
1209    std::vector<TComWedgeRef> acWedgeRefList;
1210    createWedgeList( uiWedgeBlockSize, uiWedgeBlockSize, acWedgeList, acWedgeRefList, g_aeWedgeResolutionList[ui] );
1211    g_aacWedgeLists.push_back( acWedgeList );
1212    g_aacWedgeRefLists.push_back( acWedgeRefList );
1213
1214#if HHIQC_DMMFASTSEARCH_B0039
1215    // create WedgeNodeList
1216    std::vector<TComWedgeNode> acWedgeNodeList;
1217    for( UInt uiPos = 0; uiPos < acWedgeList.size(); uiPos++ )
1218    {
1219      if( acWedgeList[uiPos].getIsCoarse() )
1220      {
1221        TComWedgeNode cWedgeNode;
1222        cWedgeNode.setPatternIdx( uiPos );
1223
1224        // set refinement idxs
1225        UInt uiRefPos = 0;
1226        for( Int iOffS = -1; iOffS <= 1; iOffS++ )
1227        {
1228          for( Int iOffE = -1; iOffE <= 1; iOffE++ )
1229          {
1230            if( iOffS == 0 && iOffE == 0 ) { continue; }
1231
1232            Int iSx = (Int)acWedgeList[uiPos].getStartX();
1233            Int iSy = (Int)acWedgeList[uiPos].getStartY();
1234            Int iEx = (Int)acWedgeList[uiPos].getEndX();
1235            Int iEy = (Int)acWedgeList[uiPos].getEndY();
1236
1237            switch( acWedgeList[uiPos].getOri() )
1238            {
1239            case( 0 ): { iSx += iOffS; iEy += iOffE; } break;
1240            case( 1 ): { iSy += iOffS; iEx -= iOffE; } break;
1241            case( 2 ): { iSx -= iOffS; iEy -= iOffE; } break;
1242            case( 3 ): { iSy -= iOffS; iEx += iOffE; } break;
1243            case( 4 ): { iSx += iOffS; iEx += iOffE; } break;
1244            case( 5 ): { iSy += iOffS; iEy += iOffE; } break;
1245            default: assert( 0 );
1246            }
1247
1248            for( UInt k = 0; k < acWedgeRefList.size(); k++ )
1249            {
1250              if( iSx == (Int)acWedgeRefList[k].getStartX() && 
1251                iSy == (Int)acWedgeRefList[k].getStartY() && 
1252                iEx == (Int)acWedgeRefList[k].getEndX() && 
1253                iEy == (Int)acWedgeRefList[k].getEndY()    )
1254              {
1255                if( acWedgeRefList[k].getRefIdx() != cWedgeNode.getPatternIdx() )
1256                {
1257                  Bool bNew = true;
1258                  for( UInt m = 0; m < uiRefPos; m++ ) { if( acWedgeRefList[k].getRefIdx() == cWedgeNode.getRefineIdx( m ) ) { bNew = false; break; } }
1259
1260                  if( bNew ) 
1261                  {
1262                    cWedgeNode.setRefineIdx( acWedgeRefList[k].getRefIdx(), uiRefPos );
1263                    uiRefPos++;
1264                    break;
1265                  }
1266                }
1267              }
1268            }
1269          }
1270        }
1271        acWedgeNodeList.push_back( cWedgeNode );
1272      }
1273    }
1274    g_aacWedgeNodeLists.push_back( acWedgeNodeList );
1275#endif
1276  }
1277  return;
1278}
1279
1280Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes )
1281{
1282  assert( uiWidth == uiHeight );
1283
1284  UChar    uhStartX = 0,    uhStartY = 0,    uhEndX = 0,    uhEndY = 0;
1285  Int   iStepStartX = 0, iStepStartY = 0, iStepEndX = 0, iStepEndY = 0;
1286
1287  UInt uiBlockSize = 0;
1288  switch( eWedgeRes )
1289  {
1290  case( DOUBLE_PEL ): { uiBlockSize = (uiWidth>>1); break; }
1291  case(   FULL_PEL ): { uiBlockSize =  uiWidth;     break; }
1292  case(   HALF_PEL ): { uiBlockSize = (uiWidth<<1); break; }
1293  }
1294
1295  TComWedgelet cTempWedgelet( uiWidth, uiHeight );
1296  for( UInt uiOri = 0; uiOri < 6; uiOri++ )
1297  {
1298    // init the edge line parameters for each of the 6 wedgelet types
1299    switch( uiOri )
1300    {
1301    case( 0 ): {  uhStartX = 0;               uhStartY = 0;               uhEndX = 0;               uhEndY = 0;               iStepStartX = +1; iStepStartY =  0; iStepEndX =  0; iStepEndY = +1; break; }
1302    case( 1 ): {  uhStartX = (uiBlockSize-1); uhStartY = 0;               uhEndX = (uiBlockSize-1); uhEndY = 0;               iStepStartX =  0; iStepStartY = +1; iStepEndX = -1; iStepEndY =  0; break; }
1303    case( 2 ): {  uhStartX = (uiBlockSize-1); uhStartY = (uiBlockSize-1); uhEndX = (uiBlockSize-1); uhEndY = (uiBlockSize-1); iStepStartX = -1; iStepStartY =  0; iStepEndX =  0; iStepEndY = -1; break; }
1304    case( 3 ): {  uhStartX = 0;               uhStartY = (uiBlockSize-1); uhEndX = 0;               uhEndY = (uiBlockSize-1); iStepStartX =  0; iStepStartY = -1; iStepEndX = +1; iStepEndY =  0; break; }
1305    case( 4 ): {  uhStartX = 0;               uhStartY = 0;               uhEndX = 0;               uhEndY = (uiBlockSize-1); iStepStartX = +1; iStepStartY =  0; iStepEndX = +1; iStepEndY =  0; break; }
1306    case( 5 ): {  uhStartX = (uiBlockSize-1); uhStartY = 0;               uhEndX = 0;               uhEndY = 0;               iStepStartX =  0; iStepStartY = +1; iStepEndX =  0; iStepEndY = +1; break; }
1307    }
1308
1309    for( Int iK = 0; iK < uiBlockSize; iK++ )
1310    {
1311      for( Int iL = 0; iL < uiBlockSize; iL++ )
1312      {
1313#if HHIQC_DMMFASTSEARCH_B0039
1314        cTempWedgelet.setWedgelet( uhStartX + (iK*iStepStartX) , uhStartY + (iK*iStepStartY), uhEndX + (iL*iStepEndX), uhEndY + (iL*iStepEndY), (UChar)uiOri, eWedgeRes, ((iL%2)==0 && (iK%2)==0) );
1315#else
1316        cTempWedgelet.setWedgelet( uhStartX + (iK*iStepStartX) , uhStartY + (iK*iStepStartY), uhEndX + (iL*iStepEndX), uhEndY + (iL*iStepEndY), (UChar)uiOri, eWedgeRes );
1317#endif
1318        addWedgeletToList( cTempWedgelet, racWedgeList, racWedgeRefList );
1319      }
1320    }
1321  }
1322#if HHIQC_DMMFASTSEARCH_B0039
1323  UInt uiThrSz = DMM3_SIMPLIFY_TR;
1324
1325  std::vector< std::vector<UInt> > auiWdgListSz;
1326  for( Int idxM=2; idxM<=34 ; idxM++)
1327  {
1328    std::vector<UInt> auiWdgList;
1329    for( Int idxW=0; idxW<racWedgeList.size(); idxW++)
1330    {
1331      UInt uiAbsDiff = abs(idxM-(Int)racWedgeList[idxW].getAng());
1332      if( uiAbsDiff <= uiThrSz )
1333      {
1334        auiWdgList.push_back(idxW);
1335      }
1336    }
1337    auiWdgListSz.push_back(auiWdgList);
1338  }
1339  g_aauiWdgLstM3.push_back(auiWdgListSz);
1340#endif
1341}
1342
1343Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList )
1344{
1345  Bool bValid = cWedgelet.checkNotPlain();
1346  if( bValid )
1347  {
1348    for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ )
1349    {
1350      if( cWedgelet.checkIdentical( racWedgeList[uiPos].getPattern() ) )
1351      {
1352        TComWedgeRef cWedgeRef;
1353        cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos );
1354        racWedgeRefList.push_back( cWedgeRef );
1355        bValid = false;
1356        return;
1357      }
1358    }
1359  }
1360  if( bValid )
1361  {
1362    for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ )
1363    {
1364      if( cWedgelet.checkInvIdentical( racWedgeList[uiPos].getPattern() ) )
1365      {
1366        TComWedgeRef cWedgeRef;
1367        cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos );
1368        racWedgeRefList.push_back( cWedgeRef );
1369        bValid = false;
1370        return;
1371      }
1372    }
1373  }
1374  if( bValid )
1375  {
1376#if HHIQC_DMMFASTSEARCH_B0039
1377  cWedgelet.findClosetAngle();
1378#endif
1379    racWedgeList.push_back( cWedgelet );
1380    TComWedgeRef cWedgeRef;
1381    cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), (UInt)(racWedgeList.size()-1) );
1382    racWedgeRefList.push_back( cWedgeRef );
1383  }
1384}
1385#endif
1386
1387//! \}
Note: See TracBrowser for help on using the repository browser.