HEVC Test Model (HM)  HM-16.3
TComRom.cpp
Go to the documentation of this file.
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-2015, 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 
38 #include "TComRom.h"
39 #include <memory.h>
40 #include <stdlib.h>
41 #include <stdio.h>
42 #include <iomanip>
43 #include <assert.h>
44 #include "TComDataCU.h"
45 #include "Debug.h"
46 // ====================================================================================================================
47 // Initialize / destroy functions
48 // ====================================================================================================================
49 
52 
54 {
55 private:
58  const UInt m_stride;
60 
61 public:
62  ScanGenerator(UInt blockWidth, UInt blockHeight, UInt stride, COEFF_SCAN_TYPE scanType)
63  : m_line(0), m_column(0), m_blockWidth(blockWidth), m_blockHeight(blockHeight), m_stride(stride), m_scanType(scanType)
64  { }
65 
66  UInt GetCurrentX() const { return m_column; }
67  UInt GetCurrentY() const { return m_line; }
68 
69  UInt GetNextIndex(UInt blockOffsetX, UInt blockOffsetY)
70  {
71  Int rtn=((m_line + blockOffsetY) * m_stride) + m_column + blockOffsetX;
72 
73  //advance line and column to the next position
74  switch (m_scanType)
75  {
76  //------------------------------------------------
77 
78  case SCAN_DIAG:
79  {
80  if ((m_column == (m_blockWidth - 1)) || (m_line == 0)) //if we reach the end of a rank, go diagonally down to the next one
81  {
82  m_line += m_column + 1;
83  m_column = 0;
84 
85  if (m_line >= m_blockHeight) //if that takes us outside the block, adjust so that we are back on the bottom row
86  {
87  m_column += m_line - (m_blockHeight - 1);
88  m_line = m_blockHeight - 1;
89  }
90  }
91  else
92  {
93  m_column++;
94  m_line--;
95  }
96  }
97  break;
98 
99  //------------------------------------------------
100 
101  case SCAN_HOR:
102  {
103  if (m_column == (m_blockWidth - 1))
104  {
105  m_line++;
106  m_column = 0;
107  }
108  else
109  {
110  m_column++;
111  }
112  }
113  break;
114 
115  //------------------------------------------------
116 
117  case SCAN_VER:
118  {
119  if (m_line == (m_blockHeight - 1))
120  {
121  m_column++;
122  m_line = 0;
123  }
124  else
125  {
126  m_line++;
127  }
128  }
129  break;
130 
131  //------------------------------------------------
132 
133  default:
134  {
135  std::cerr << "ERROR: Unknown scan type \"" << m_scanType << "\"in ScanGenerator::GetNextIndex" << std::endl;
136  exit(1);
137  }
138  break;
139  }
140 
141  return rtn;
142  }
143 };
144 
145 // initialize ROM variables
147 {
148  Int i, c;
149 
150  // g_aucConvertToBit[ x ]: log2(x/4), if x=4 -> 0, x=8 -> 1, x=16 -> 2, ...
151  ::memset( g_aucConvertToBit, -1, sizeof( g_aucConvertToBit ) );
152  c=0;
153  for ( i=4; i<=MAX_CU_SIZE; i*=2 )
154  {
155  g_aucConvertToBit[ i ] = c;
156  c++;
157  }
158 
159  // initialise scan orders
160  for(UInt log2BlockHeight = 0; log2BlockHeight < MAX_CU_DEPTH; log2BlockHeight++)
161  {
162  for(UInt log2BlockWidth = 0; log2BlockWidth < MAX_CU_DEPTH; log2BlockWidth++)
163  {
164  const UInt blockWidth = 1 << log2BlockWidth;
165  const UInt blockHeight = 1 << log2BlockHeight;
166  const UInt totalValues = blockWidth * blockHeight;
167 
168  //--------------------------------------------------------------------------------------------------
169 
170  //non-grouped scan orders
171 
172  for (UInt scanTypeIndex = 0; scanTypeIndex < SCAN_NUMBER_OF_TYPES; scanTypeIndex++)
173  {
174  const COEFF_SCAN_TYPE scanType = COEFF_SCAN_TYPE(scanTypeIndex);
175 
176  g_scanOrder[SCAN_UNGROUPED][scanType][log2BlockWidth][log2BlockHeight] = new UInt[totalValues];
177 
178  ScanGenerator fullBlockScan(blockWidth, blockHeight, blockWidth, scanType);
179 
180  for (UInt scanPosition = 0; scanPosition < totalValues; scanPosition++)
181  {
182  g_scanOrder[SCAN_UNGROUPED][scanType][log2BlockWidth][log2BlockHeight][scanPosition] = fullBlockScan.GetNextIndex(0, 0);
183  }
184  }
185 
186  //--------------------------------------------------------------------------------------------------
187 
188  //grouped scan orders
189 
190  const UInt groupWidth = 1 << MLS_CG_LOG2_WIDTH;
191  const UInt groupHeight = 1 << MLS_CG_LOG2_HEIGHT;
192  const UInt widthInGroups = blockWidth >> MLS_CG_LOG2_WIDTH;
193  const UInt heightInGroups = blockHeight >> MLS_CG_LOG2_HEIGHT;
194 
195  const UInt groupSize = groupWidth * groupHeight;
196  const UInt totalGroups = widthInGroups * heightInGroups;
197 
198  for (UInt scanTypeIndex = 0; scanTypeIndex < SCAN_NUMBER_OF_TYPES; scanTypeIndex++)
199  {
200  const COEFF_SCAN_TYPE scanType = COEFF_SCAN_TYPE(scanTypeIndex);
201 
202  g_scanOrder[SCAN_GROUPED_4x4][scanType][log2BlockWidth][log2BlockHeight] = new UInt[totalValues];
203 
204  ScanGenerator fullBlockScan(widthInGroups, heightInGroups, groupWidth, scanType);
205 
206  for (UInt groupIndex = 0; groupIndex < totalGroups; groupIndex++)
207  {
208  const UInt groupPositionY = fullBlockScan.GetCurrentY();
209  const UInt groupPositionX = fullBlockScan.GetCurrentX();
210  const UInt groupOffsetX = groupPositionX * groupWidth;
211  const UInt groupOffsetY = groupPositionY * groupHeight;
212  const UInt groupOffsetScan = groupIndex * groupSize;
213 
214  ScanGenerator groupScan(groupWidth, groupHeight, blockWidth, scanType);
215 
216  for (UInt scanPosition = 0; scanPosition < groupSize; scanPosition++)
217  {
218  g_scanOrder[SCAN_GROUPED_4x4][scanType][log2BlockWidth][log2BlockHeight][groupOffsetScan + scanPosition] = groupScan.GetNextIndex(groupOffsetX, groupOffsetY);
219  }
220 
221  fullBlockScan.GetNextIndex(0,0);
222  }
223  }
224 
225  //--------------------------------------------------------------------------------------------------
226  }
227  }
228 }
229 
231 {
232  for(UInt groupTypeIndex = 0; groupTypeIndex < SCAN_NUMBER_OF_GROUP_TYPES; groupTypeIndex++)
233  {
234  for (UInt scanOrderIndex = 0; scanOrderIndex < SCAN_NUMBER_OF_TYPES; scanOrderIndex++)
235  {
236  for (UInt log2BlockWidth = 0; log2BlockWidth < MAX_CU_DEPTH; log2BlockWidth++)
237  {
238  for (UInt log2BlockHeight = 0; log2BlockHeight < MAX_CU_DEPTH; log2BlockHeight++)
239  {
240  delete [] g_scanOrder[groupTypeIndex][scanOrderIndex][log2BlockWidth][log2BlockHeight];
241  }
242  }
243  }
244  }
245 }
246 
247 // ====================================================================================================================
248 // Data structure related table & variable
249 // ====================================================================================================================
250 
259 
260 UInt g_auiPUOffset[NUMBER_OF_PART_SIZES] = { 0, 8, 4, 4, 2, 10, 1, 5};
261 
262 Void initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx )
263 {
264  Int iStride = 1 << ( iMaxDepth - 1 );
265 
266  if ( iDepth == iMaxDepth )
267  {
268  rpuiCurrIdx[0] = uiStartVal;
269  rpuiCurrIdx++;
270  }
271  else
272  {
273  Int iStep = iStride >> iDepth;
274  initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal, rpuiCurrIdx );
275  initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep, rpuiCurrIdx );
276  initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride, rpuiCurrIdx );
277  initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride+iStep, rpuiCurrIdx );
278  }
279 }
280 
281 Void initRasterToZscan ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth )
282 {
283  UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 );
284  UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 );
285 
286  UInt uiNumPartInWidth = (UInt)uiMaxCUWidth / uiMinCUWidth;
287  UInt uiNumPartInHeight = (UInt)uiMaxCUHeight / uiMinCUHeight;
288 
289  for ( UInt i = 0; i < uiNumPartInWidth*uiNumPartInHeight; i++ )
290  {
292  }
293 }
294 
295 Void initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth )
296 {
297  UInt i;
298 
299  UInt* uiTempX = &g_auiRasterToPelX[0];
300  UInt* uiTempY = &g_auiRasterToPelY[0];
301 
302  UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 );
303  UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 );
304 
305  UInt uiNumPartInWidth = uiMaxCUWidth / uiMinCUWidth;
306  UInt uiNumPartInHeight = uiMaxCUHeight / uiMinCUHeight;
307 
308  uiTempX[0] = 0; uiTempX++;
309  for ( i = 1; i < uiNumPartInWidth; i++ )
310  {
311  uiTempX[0] = uiTempX[-1] + uiMinCUWidth; uiTempX++;
312  }
313  for ( i = 1; i < uiNumPartInHeight; i++ )
314  {
315  memcpy(uiTempX, uiTempX-uiNumPartInWidth, sizeof(UInt)*uiNumPartInWidth);
316  uiTempX += uiNumPartInWidth;
317  }
318 
319  for ( i = 1; i < uiNumPartInWidth*uiNumPartInHeight; i++ )
320  {
321  uiTempY[i] = ( i / uiNumPartInWidth ) * uiMinCUWidth;
322  }
323 }
324 
326 
328 {
329  26214,23302,20560,18396,16384,14564
330 };
331 
333 {
334  40,45,51,57,64,72
335 };
336 
337 //--------------------------------------------------------------------------------------------------
338 
339 //structures
340 
341 #define DEFINE_DST4x4_MATRIX(a,b,c,d) \
342 { \
343  { a, b, c, d }, \
344  { c, c, 0, -c }, \
345  { d, -a, -c, b }, \
346  { b, -d, c, -a }, \
347 }
348 
349 #define DEFINE_DCT4x4_MATRIX(a,b,c) \
350 { \
351  { a, a, a, a}, \
352  { b, c, -c, -b}, \
353  { a, -a, -a, a}, \
354  { c, -b, b, -c} \
355 }
356 
357 #define DEFINE_DCT8x8_MATRIX(a,b,c,d,e,f,g) \
358 { \
359  { a, a, a, a, a, a, a, a}, \
360  { d, e, f, g, -g, -f, -e, -d}, \
361  { b, c, -c, -b, -b, -c, c, b}, \
362  { e, -g, -d, -f, f, d, g, -e}, \
363  { a, -a, -a, a, a, -a, -a, a}, \
364  { f, -d, g, e, -e, -g, d, -f}, \
365  { c, -b, b, -c, -c, b, -b, c}, \
366  { g, -f, e, -d, d, -e, f, -g} \
367 }
368 
369 #define DEFINE_DCT16x16_MATRIX(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) \
370 { \
371  { a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a}, \
372  { h, i, j, k, l, m, n, o, -o, -n, -m, -l, -k, -j, -i, -h}, \
373  { d, e, f, g, -g, -f, -e, -d, -d, -e, -f, -g, g, f, e, d}, \
374  { i, l, o, -m, -j, -h, -k, -n, n, k, h, j, m, -o, -l, -i}, \
375  { b, c, -c, -b, -b, -c, c, b, b, c, -c, -b, -b, -c, c, b}, \
376  { j, o, -k, -i, -n, l, h, m, -m, -h, -l, n, i, k, -o, -j}, \
377  { e, -g, -d, -f, f, d, g, -e, -e, g, d, f, -f, -d, -g, e}, \
378  { k, -m, -i, o, h, n, -j, -l, l, j, -n, -h, -o, i, m, -k}, \
379  { a, -a, -a, a, a, -a, -a, a, a, -a, -a, a, a, -a, -a, a}, \
380  { l, -j, -n, h, -o, -i, m, k, -k, -m, i, o, -h, n, j, -l}, \
381  { f, -d, g, e, -e, -g, d, -f, -f, d, -g, -e, e, g, -d, f}, \
382  { m, -h, l, n, -i, k, o, -j, j, -o, -k, i, -n, -l, h, -m}, \
383  { c, -b, b, -c, -c, b, -b, c, c, -b, b, -c, -c, b, -b, c}, \
384  { n, -k, h, -j, m, o, -l, i, -i, l, -o, -m, j, -h, k, -n}, \
385  { g, -f, e, -d, d, -e, f, -g, -g, f, -e, d, -d, e, -f, g}, \
386  { o, -n, m, -l, k, -j, i, -h, h, -i, j, -k, l, -m, n, -o} \
387 }
388 
389 #define DEFINE_DCT32x32_MATRIX(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E) \
390 { \
391  { a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a}, \
392  { p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, -E, -D, -C, -B, -A, -z, -y, -x, -w, -v, -u, -t, -s, -r, -q, -p}, \
393  { h, i, j, k, l, m, n, o, -o, -n, -m, -l, -k, -j, -i, -h, -h, -i, -j, -k, -l, -m, -n, -o, o, n, m, l, k, j, i, h}, \
394  { q, t, w, z, C, -E, -B, -y, -v, -s, -p, -r, -u, -x, -A, -D, D, A, x, u, r, p, s, v, y, B, E, -C, -z, -w, -t, -q}, \
395  { d, e, f, g, -g, -f, -e, -d, -d, -e, -f, -g, g, f, e, d, d, e, f, g, -g, -f, -e, -d, -d, -e, -f, -g, g, f, e, d}, \
396  { r, w, B, -D, -y, -t, -p, -u, -z, -E, A, v, q, s, x, C, -C, -x, -s, -q, -v, -A, E, z, u, p, t, y, D, -B, -w, -r}, \
397  { i, l, o, -m, -j, -h, -k, -n, n, k, h, j, m, -o, -l, -i, -i, -l, -o, m, j, h, k, n, -n, -k, -h, -j, -m, o, l, i}, \
398  { s, z, -D, -w, -p, -v, -C, A, t, r, y, -E, -x, -q, -u, -B, B, u, q, x, E, -y, -r, -t, -A, C, v, p, w, D, -z, -s}, \
399  { b, c, -c, -b, -b, -c, c, b, b, c, -c, -b, -b, -c, c, b, b, c, -c, -b, -b, -c, c, b, b, c, -c, -b, -b, -c, c, b}, \
400  { t, C, -y, -p, -x, D, u, s, B, -z, -q, -w, E, v, r, A, -A, -r, -v, -E, w, q, z, -B, -s, -u, -D, x, p, y, -C, -t}, \
401  { j, o, -k, -i, -n, l, h, m, -m, -h, -l, n, i, k, -o, -j, -j, -o, k, i, n, -l, -h, -m, m, h, l, -n, -i, -k, o, j}, \
402  { u, -E, -t, -v, D, s, w, -C, -r, -x, B, q, y, -A, -p, -z, z, p, A, -y, -q, -B, x, r, C, -w, -s, -D, v, t, E, -u}, \
403  { e, -g, -d, -f, f, d, g, -e, -e, g, d, f, -f, -d, -g, e, e, -g, -d, -f, f, d, g, -e, -e, g, d, f, -f, -d, -g, e}, \
404  { v, -B, -p, -C, u, w, -A, -q, -D, t, x, -z, -r, -E, s, y, -y, -s, E, r, z, -x, -t, D, q, A, -w, -u, C, p, B, -v}, \
405  { k, -m, -i, o, h, n, -j, -l, l, j, -n, -h, -o, i, m, -k, -k, m, i, -o, -h, -n, j, l, -l, -j, n, h, o, -i, -m, k}, \
406  { w, -y, -u, A, s, -C, -q, E, p, D, -r, -B, t, z, -v, -x, x, v, -z, -t, B, r, -D, -p, -E, q, C, -s, -A, u, y, -w}, \
407  { a, -a, -a, a, a, -a, -a, a, a, -a, -a, a, a, -a, -a, a, a, -a, -a, a, a, -a, -a, a, a, -a, -a, a, a, -a, -a, a}, \
408  { x, -v, -z, t, B, -r, -D, p, -E, -q, C, s, -A, -u, y, w, -w, -y, u, A, -s, -C, q, E, -p, D, r, -B, -t, z, v, -x}, \
409  { l, -j, -n, h, -o, -i, m, k, -k, -m, i, o, -h, n, j, -l, -l, j, n, -h, o, i, -m, -k, k, m, -i, -o, h, -n, -j, l}, \
410  { y, -s, -E, r, -z, -x, t, D, -q, A, w, -u, -C, p, -B, -v, v, B, -p, C, u, -w, -A, q, -D, -t, x, z, -r, E, s, -y}, \
411  { f, -d, g, e, -e, -g, d, -f, -f, d, -g, -e, e, g, -d, f, f, -d, g, e, -e, -g, d, -f, -f, d, -g, -e, e, g, -d, f}, \
412  { z, -p, A, y, -q, B, x, -r, C, w, -s, D, v, -t, E, u, -u, -E, t, -v, -D, s, -w, -C, r, -x, -B, q, -y, -A, p, -z}, \
413  { m, -h, l, n, -i, k, o, -j, j, -o, -k, i, -n, -l, h, -m, -m, h, -l, -n, i, -k, -o, j, -j, o, k, -i, n, l, -h, m}, \
414  { A, -r, v, -E, -w, q, -z, -B, s, -u, D, x, -p, y, C, -t, t, -C, -y, p, -x, -D, u, -s, B, z, -q, w, E, -v, r, -A}, \
415  { c, -b, b, -c, -c, b, -b, c, c, -b, b, -c, -c, b, -b, c, c, -b, b, -c, -c, b, -b, c, c, -b, b, -c, -c, b, -b, c}, \
416  { B, -u, q, -x, E, y, -r, t, -A, -C, v, -p, w, -D, -z, s, -s, z, D, -w, p, -v, C, A, -t, r, -y, -E, x, -q, u, -B}, \
417  { n, -k, h, -j, m, o, -l, i, -i, l, -o, -m, j, -h, k, -n, -n, k, -h, j, -m, -o, l, -i, i, -l, o, m, -j, h, -k, n}, \
418  { C, -x, s, -q, v, -A, -E, z, -u, p, -t, y, -D, -B, w, -r, r, -w, B, D, -y, t, -p, u, -z, E, A, -v, q, -s, x, -C}, \
419  { g, -f, e, -d, d, -e, f, -g, -g, f, -e, d, -d, e, -f, g, g, -f, e, -d, d, -e, f, -g, -g, f, -e, d, -d, e, -f, g}, \
420  { D, -A, x, -u, r, -p, s, -v, y, -B, E, C, -z, w, -t, q, -q, t, -w, z, -C, -E, B, -y, v, -s, p, -r, u, -x, A, -D}, \
421  { o, -n, m, -l, k, -j, i, -h, h, -i, j, -k, l, -m, n, -o, -o, n, -m, l, -k, j, -i, h, -h, i, -j, k, -l, m, -n, o}, \
422  { E, -D, C, -B, A, -z, y, -x, w, -v, u, -t, s, -r, q, -p, p, -q, r, -s, t, -u, v, -w, x, -y, z, -A, B, -C, D, -E} \
423 }
424 
425 //--------------------------------------------------------------------------------------------------
426 
427 //coefficients
428 
429 #if RExt__HIGH_PRECISION_FORWARD_TRANSFORM
431 {
432  DEFINE_DCT4x4_MATRIX (16384, 21266, 9224),
433  DEFINE_DCT4x4_MATRIX ( 64, 83, 36)
434 };
435 
437 {
438  DEFINE_DCT8x8_MATRIX (16384, 21266, 9224, 22813, 19244, 12769, 4563),
439  DEFINE_DCT8x8_MATRIX ( 64, 83, 36, 89, 75, 50, 18)
440 };
441 
443 {
444  DEFINE_DCT16x16_MATRIX(16384, 21266, 9224, 22813, 19244, 12769, 4563, 23120, 22063, 20450, 17972, 14642, 11109, 6446, 2316),
445  DEFINE_DCT16x16_MATRIX( 64, 83, 36, 89, 75, 50, 18, 90, 87, 80, 70, 57, 43, 25, 9)
446 };
447 
449 {
450  DEFINE_DCT32x32_MATRIX(16384, 21266, 9224, 22813, 19244, 12769, 4563, 23120, 22063, 20450, 17972, 14642, 11109, 6446, 2316, 23106, 22852, 22445, 21848, 20995, 19810, 18601, 17143, 15718, 13853, 11749, 9846, 7908, 5573, 3281, 946),
451  DEFINE_DCT32x32_MATRIX( 64, 83, 36, 89, 75, 50, 18, 90, 87, 80, 70, 57, 43, 25, 9, 90, 90, 88, 85, 82, 78, 73, 67, 61, 54, 46, 38, 31, 22, 13, 4)
452 };
453 
455 {
456  DEFINE_DST4x4_MATRIX( 7424, 14081, 18893, 21505),
457  DEFINE_DST4x4_MATRIX( 29, 55, 74, 84)
458 };
459 
460 #else
461 
463 {
464  DEFINE_DCT4x4_MATRIX ( 64, 83, 36),
465  DEFINE_DCT4x4_MATRIX ( 64, 83, 36)
466 };
467 
469 {
470  DEFINE_DCT8x8_MATRIX ( 64, 83, 36, 89, 75, 50, 18),
471  DEFINE_DCT8x8_MATRIX ( 64, 83, 36, 89, 75, 50, 18)
472 };
473 
475 {
476  DEFINE_DCT16x16_MATRIX( 64, 83, 36, 89, 75, 50, 18, 90, 87, 80, 70, 57, 43, 25, 9),
477  DEFINE_DCT16x16_MATRIX( 64, 83, 36, 89, 75, 50, 18, 90, 87, 80, 70, 57, 43, 25, 9)
478 };
479 
481 {
482  DEFINE_DCT32x32_MATRIX( 64, 83, 36, 89, 75, 50, 18, 90, 87, 80, 70, 57, 43, 25, 9, 90, 90, 88, 85, 82, 78, 73, 67, 61, 54, 46, 38, 31, 22, 13, 4),
483  DEFINE_DCT32x32_MATRIX( 64, 83, 36, 89, 75, 50, 18, 90, 87, 80, 70, 57, 43, 25, 9, 90, 90, 88, 85, 82, 78, 73, 67, 61, 54, 46, 38, 31, 22, 13, 4)
484 };
485 
487 {
488  DEFINE_DST4x4_MATRIX( 29, 55, 74, 84),
489  DEFINE_DST4x4_MATRIX( 29, 55, 74, 84)
490 };
491 #endif
492 
493 
494 //--------------------------------------------------------------------------------------------------
495 
496 #undef DEFINE_DST4x4_MATRIX
497 #undef DEFINE_DCT4x4_MATRIX
498 #undef DEFINE_DCT8x8_MATRIX
499 #undef DEFINE_DCT16x16_MATRIX
500 #undef DEFINE_DCT32x32_MATRIX
501 
502 //--------------------------------------------------------------------------------------------------
503 
504 
506 {
507  //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,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57
508  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
509  { 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,29,30,31,32,33,33,34,34,35,35,36,36,37,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51 },
510  { 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,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,51,51,51,51,51,51 },
511  { 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,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,51,51,51,51,51,51 }
512 };
513 
514 // ====================================================================================================================
515 // ADI
516 // ====================================================================================================================
517 
518 #if FAST_UDI_USE_MPM
520 {
521  3, // 2x2
522  8, // 4x4
523  8, // 8x8
524  3, // 16x16
525  3, // 32x32
526  3 // 64x64
527 };
528 #else // FAST_UDI_USE_MPM
530 {
531  3, // 2x2
532  9, // 4x4
533  9, // 8x8
534  4, // 16x16 33
535  4, // 32x32 33
536  5 // 64x64 33
537 };
538 #endif // FAST_UDI_USE_MPM
539 
541  //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, DM
542  { 0, 1, 2, 2, 2, 2, 3, 5, 7, 8, 10, 12, 13, 15, 17, 18, 19, 20, 21, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 29, 30, 31, DM_CHROMA_IDX};
543 
544 // ====================================================================================================================
545 // Bit-depth
546 // ====================================================================================================================
547 
549 #if O0043_BEST_EFFORT_DECODING
550 Int g_bitDepthInStream [MAX_NUM_CHANNEL_TYPE] = {8, 8}; // In the encoder, this is the same as g_bitDepth. In the decoder, this can vary from g_bitDepth if the decoder is forced to use 'best-effort decoding' at a particular bit-depth.
551 #endif
552 Int g_PCMBitDepth[MAX_NUM_CHANNEL_TYPE] = {8, 8}; // PCM bit-depth
553 
554 // ====================================================================================================================
555 // Misc.
556 // ====================================================================================================================
557 
559 
560 #if ENC_DEC_TRACE
561 FILE* g_hTrace = NULL; // Set to NULL to open up a file. Set to stdout to use the current output
567 #endif
568 // ====================================================================================================================
569 // Scanning order & context model mapping
570 // ====================================================================================================================
571 
572 // scanning order table
574 
575 const UInt ctxIndMap4x4[4*4] =
576 {
577  0, 1, 4, 5,
578  2, 3, 4, 5,
579  6, 6, 8, 8,
580  7, 7, 8, 8
581 };
582 
583 const UInt g_uiMinInGroup[ LAST_SIGNIFICANT_GROUPS ] = {0,1,2,3,4,6,8,12,16,24};
584 const UInt g_uiGroupIdx[ MAX_TU_SIZE ] = {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};
585 
587 {
588  {
589  "INTRA4X4_LUMA",
590  "INTRA4X4_CHROMAU",
591  "INTRA4X4_CHROMAV",
592  "INTER4X4_LUMA",
593  "INTER4X4_CHROMAU",
594  "INTER4X4_CHROMAV"
595  },
596  {
597  "INTRA8X8_LUMA",
598  "INTRA8X8_CHROMAU",
599  "INTRA8X8_CHROMAV",
600  "INTER8X8_LUMA",
601  "INTER8X8_CHROMAU",
602  "INTER8X8_CHROMAV"
603  },
604  {
605  "INTRA16X16_LUMA",
606  "INTRA16X16_CHROMAU",
607  "INTRA16X16_CHROMAV",
608  "INTER16X16_LUMA",
609  "INTER16X16_CHROMAU",
610  "INTER16X16_CHROMAV"
611  },
612  {
613  "INTRA32X32_LUMA",
614  "INTRA32X32_CHROMAU_FROM16x16_CHROMAU",
615  "INTRA32X32_CHROMAV_FROM16x16_CHROMAV",
616  "INTER32X32_LUMA",
617  "INTER32X32_CHROMAU_FROM16x16_CHROMAU",
618  "INTER32X32_CHROMAV_FROM16x16_CHROMAV"
619  },
620 };
621 
623 {
624  {
625  },
626  {
627  },
628  {
629  "INTRA16X16_LUMA_DC",
630  "INTRA16X16_CHROMAU_DC",
631  "INTRA16X16_CHROMAV_DC",
632  "INTER16X16_LUMA_DC",
633  "INTER16X16_CHROMAU_DC",
634  "INTER16X16_CHROMAV_DC"
635  },
636  {
637  "INTRA32X32_LUMA_DC",
638  "INTRA32X32_CHROMAU_DC_FROM16x16_CHROMAU",
639  "INTRA32X32_CHROMAV_DC_FROM16x16_CHROMAV",
640  "INTER32X32_LUMA_DC",
641  "INTER32X32_CHROMAU_DC_FROM16x16_CHROMAU",
642  "INTER32X32_CHROMAV_DC_FROM16x16_CHROMAV"
643  },
644 };
645 
647 {
648  16,16,16,16,
649  16,16,16,16,
650  16,16,16,16,
651  16,16,16,16
652 };
653 
655 {
656  16,16,16,16,17,18,21,24,
657  16,16,16,16,17,19,22,25,
658  16,16,17,18,20,22,25,29,
659  16,16,18,21,24,27,31,36,
660  17,17,20,24,30,35,41,47,
661  18,19,22,27,35,44,54,65,
662  21,22,25,31,41,54,70,88,
663  24,25,29,36,47,65,88,115
664 };
665 
667 {
668  16,16,16,16,17,18,20,24,
669  16,16,16,17,18,20,24,25,
670  16,16,17,18,20,24,25,28,
671  16,17,18,20,24,25,28,33,
672  17,18,20,24,25,28,33,41,
673  18,20,24,25,28,33,41,54,
674  20,24,25,28,33,41,54,71,
675  24,25,28,33,41,54,71,91
676 };
677 
680 
#define MAX_CU_SIZE
Definition: TComRom.h:54
UInt GetNextIndex(UInt blockOffsetX, UInt blockOffsetY)
Definition: TComRom.cpp:69
UInt g_uiMaxCUDepth
Definition: TComRom.cpp:253
const UChar g_aucIntraModeNumFast[6]
Definition: TComRom.cpp:519
UInt * g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][6][6]
Definition: TComRom.cpp:573
const TMatrixCoeff g_aiT16[TRANSFORM_NUMBER_OF_DIRECTIONS][16][16]
Definition: TComRom.cpp:474
void Void
Definition: TypeDef.h:285
const Char * MatrixType[SCALING_LIST_SIZE_NUM][(MAX_NUM_COMPONENT *NUMBER_OF_PREDICTION_MODES)]
Definition: TComRom.cpp:586
UInt g_auiRasterToPelX[((1<<(6))/4)*((1<<(6))/4)]
Definition: TComRom.cpp:257
const TMatrixCoeff g_aiT4[TRANSFORM_NUMBER_OF_DIRECTIONS][4][4]
Definition: TComRom.cpp:462
global variables & functions (header)
#define NULL
Definition: CommonDef.h:100
UInt g_scalingListSizeX[SCALING_LIST_SIZE_NUM]
Definition: TComRom.cpp:679
Void initROM()
Definition: TComRom.cpp:146
char Char
Definition: TypeDef.h:291
Char g_aucConvertToBit[(1<<(6))+1]
Definition: TComRom.cpp:558
unsigned int UInt
Definition: TypeDef.h:297
const UInt m_blockWidth
Definition: TComRom.cpp:57
#define NUM_INTRA_MODE
Definition: TypeDef.h:170
static const Int chromaQPMappingTableSize
Definition: TComRom.h:128
UInt g_uiAddCUDepth
Definition: TComRom.cpp:254
#define DEFINE_DST4x4_MATRIX(a, b, c, d)
Definition: TComRom.cpp:341
UInt g_auiPUOffset[NUMBER_OF_PART_SIZES]
Definition: TComRom.cpp:260
Int g_quantTSDefault4x4[4 *4]
Definition: TComRom.cpp:646
UInt64 g_nSymbolCounter
Definition: TComRom.cpp:566
#define DEFINE_DCT4x4_MATRIX(a, b, c)
Definition: TComRom.cpp:349
const UInt g_uiGroupIdx[32]
Definition: TComRom.cpp:584
Bool g_HLSTraceEnable
Definition: TComRom.cpp:564
horizontal first scan
Definition: TypeDef.h:524
Short TMatrixCoeff
transform matrix coefficient
Definition: TypeDef.h:694
#define SCALING_LIST_NUM
list number for quantization matrix
Definition: TComRom.h:215
UInt g_auiRasterToZscan[((1<<(6))/4)*((1<<(6))/4)]
Definition: TComRom.cpp:256
const UInt m_stride
Definition: TComRom.cpp:58
const UChar g_chroma422IntraAngleMappingTable[36]
Definition: TComRom.cpp:540
UInt m_column
Definition: TComRom.cpp:56
const Bool g_bEncDecTraceEnable
Definition: TComRom.cpp:562
FILE * g_hTrace
Definition: TComRom.cpp:561
const UInt m_blockHeight
Definition: TComRom.cpp:57
#define MAX_NUM_SPU_W
Definition: TComRom.h:58
UInt GetCurrentX() const
Definition: TComRom.cpp:66
bool Bool
Definition: TypeDef.h:286
Int g_maxTrDynamicRange[MAX_NUM_CHANNEL_TYPE]
Definition: TComRom.cpp:325
Int g_bitDepth[MAX_NUM_CHANNEL_TYPE]
Definition: TComRom.cpp:548
Void initRasterToPelXY(UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth)
Definition: TComRom.cpp:295
UInt g_uiMaxCUHeight
Definition: TComRom.cpp:252
#define MLS_CG_LOG2_HEIGHT
Definition: TypeDef.h:145
UInt g_uiMaxCUWidth
Definition: TComRom.cpp:251
Bool g_bJustDoIt
Definition: TComRom.cpp:565
ScanGenerator(UInt blockWidth, UInt blockHeight, UInt stride, COEFF_SCAN_TYPE scanType)
Definition: TComRom.cpp:62
up-right diagonal scan
Definition: TypeDef.h:523
#define LAST_SIGNIFICANT_GROUPS
Definition: TComRom.h:137
Int g_quantIntraDefault8x8[8 *8]
Definition: TComRom.cpp:654
Void initRasterToZscan(UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth)
Definition: TComRom.cpp:281
UInt g_auiZscanToRaster[((1<<(6))/4)*((1<<(6))/4)]
Definition: TComRom.cpp:255
Int g_PCMBitDepth[MAX_NUM_CHANNEL_TYPE]
Definition: TComRom.cpp:552
unsigned char UChar
Definition: TypeDef.h:293
COEFF_SCAN_TYPE
coefficient scanning type used in ACS
Definition: TypeDef.h:521
UInt g_auiRasterToPelY[((1<<(6))/4)*((1<<(6))/4)]
Definition: TComRom.cpp:258
#define DEFINE_DCT8x8_MATRIX(a, b, c, d, e, f, g)
Definition: TComRom.cpp:357
Int g_quantScales[6]
Definition: TComRom.cpp:327
#define DM_CHROMA_IDX
Definition: TypeDef.h:185
const TMatrixCoeff g_aiT32[TRANSFORM_NUMBER_OF_DIRECTIONS][32][32]
Definition: TComRom.cpp:480
const TMatrixCoeff g_aiT8[TRANSFORM_NUMBER_OF_DIRECTIONS][8][8]
Definition: TComRom.cpp:468
unsigned long long UInt64
Definition: TypeDef.h:318
#define DEFINE_DCT16x16_MATRIX(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o)
Definition: TComRom.cpp:369
#define MAX_CU_DEPTH
Definition: TComRom.h:53
const COEFF_SCAN_TYPE m_scanType
Definition: TComRom.cpp:59
Int g_invQuantScales[6]
Definition: TComRom.cpp:332
const UInt ctxIndMap4x4[4 *4]
Definition: TComRom.cpp:575
const TMatrixCoeff g_as_DST_MAT_4[TRANSFORM_NUMBER_OF_DIRECTIONS][4][4]
Definition: TComRom.cpp:486
Void initZscanToRaster(Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt *&rpuiCurrIdx)
Definition: TComRom.cpp:262
UInt g_scalingListSize[SCALING_LIST_SIZE_NUM]
Definition: TComRom.cpp:678
int Int
Definition: TypeDef.h:296
const Bool g_bEncDecTraceDisable
Definition: TComRom.cpp:563
Int g_quantInterDefault8x8[8 *8]
Definition: TComRom.cpp:666
const UInt g_uiMinInGroup[10]
Definition: TComRom.cpp:583
#define SCALING_LIST_REM_NUM
Definition: TComRom.h:60
const UChar g_aucChromaScale[NUM_CHROMA_FORMAT][chromaQPMappingTableSize]
Definition: TComRom.cpp:505
CU data structure (header)
UInt GetCurrentY() const
Definition: TComRom.cpp:67
vertical first scan
Definition: TypeDef.h:525
#define DEFINE_DCT32x32_MATRIX(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E)
Definition: TComRom.cpp:389
#define MAX_TU_SIZE
Definition: TComRom.h:57
const Char * MatrixType_DC[SCALING_LIST_SIZE_NUM][(MAX_NUM_COMPONENT *NUMBER_OF_PREDICTION_MODES)]
Definition: TComRom.cpp:622
Defines types and objects for environment-variable-based debugging and feature control.
Void destroyROM()
Definition: TComRom.cpp:230
#define MLS_CG_LOG2_WIDTH
Definition: TypeDef.h:144