HEVC Test Model (HM)  HM-16.3
TComRom.h
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 #ifndef __TCOMROM__
39 #define __TCOMROM__
40 
41 #include "CommonDef.h"
42 
43 #include<stdio.h>
44 #include<iostream>
45 
48 
49 // ====================================================================================================================
50 // Macros
51 // ====================================================================================================================
52 
53 #define MAX_CU_DEPTH 6 // log2(CTUSize)
54 #define MAX_CU_SIZE (1<<(MAX_CU_DEPTH)) // maximum allowable size of CU, surely 64? (not 1<<7 = 128)
55 #define MIN_PU_SIZE 4
56 #define MIN_TU_SIZE 4
57 #define MAX_TU_SIZE 32
58 #define MAX_NUM_SPU_W (MAX_CU_SIZE/MIN_PU_SIZE) // maximum number of SPU in horizontal line
59 
60 #define SCALING_LIST_REM_NUM 6
61 
62 // ====================================================================================================================
63 // Initialize / destroy functions
64 // ====================================================================================================================
65 
66 Void initROM();
68 
69 // ====================================================================================================================
70 // Data structure related table & variable
71 // ====================================================================================================================
72 
73 // flexible conversion from relative to absolute index
77 
78 Void initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx );
79 Void initRasterToZscan ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth );
80 
81 // conversion of partition index to picture pel position
84 
85 Void initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth );
86 
87 // global variable (CTU width/height, max. CU depth)
88 extern UInt g_uiMaxCUWidth;
89 extern UInt g_uiMaxCUHeight;
90 extern UInt g_uiMaxCUDepth;
91 extern UInt g_uiAddCUDepth;
92 
94 
95 #define QUANT_SHIFT 14 // Q(4) = 2^14
96 #define IQUANT_SHIFT 6
97 #define SCALE_BITS 15 // Inherited from TMuC, pressumably for fractional bit estimates in RDOQ
98 
100 
101 #define SQRT2 11585
102 #define SQRT2_SHIFT 13
103 #define INVSQRT2 11585
104 #define INVSQRT2_SHIFT 14
105 #define ADDITIONAL_MULTIPLIER_BITS 14
106 
107 #define SHIFT_INV_1ST 7 // Shift after first inverse transform stage
108 #define SHIFT_INV_2ND 12 // Shift after second inverse transform stage
109 
110 extern Int g_quantScales[SCALING_LIST_REM_NUM]; // Q(QP%6)
111 extern Int g_invQuantScales[SCALING_LIST_REM_NUM]; // IQ(QP%6)
112 
113 #if RExt__HIGH_PRECISION_FORWARD_TRANSFORM
115 #else
117 #endif
118 
123 
124 // ====================================================================================================================
125 // Luma QP to Chroma QP mapping
126 // ====================================================================================================================
127 
128 static const Int chromaQPMappingTableSize = 58;
129 
131 
132 // ====================================================================================================================
133 // Entropy Coding
134 // ====================================================================================================================
135 
136 #define CONTEXT_STATE_BITS 6
137 #define LAST_SIGNIFICANT_GROUPS 10
138 
139 // ====================================================================================================================
140 // Scanning order & context mapping table
141 // ====================================================================================================================
142 
143 extern const UInt ctxIndMap4x4[4*4];
144 
145 extern const UInt g_uiGroupIdx[ MAX_TU_SIZE ];
147 
148 // ====================================================================================================================
149 // ADI table
150 // ====================================================================================================================
151 
153 
155 
156 // ====================================================================================================================
157 // Bit-depth
158 // ====================================================================================================================
159 
162 #if O0043_BEST_EFFORT_DECODING
163 extern Int g_bitDepthInStream [MAX_NUM_CHANNEL_TYPE]; // 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.
164 #endif
165 
166 // ====================================================================================================================
167 // Mode-Dependent DST Matrices
168 // ====================================================================================================================
169 
171 
172 // ====================================================================================================================
173 // Misc.
174 // ====================================================================================================================
175 
176 extern Char g_aucConvertToBit [ MAX_CU_SIZE+1 ]; // from width to log2(width)-2
177 
178 #ifndef ENC_DEC_TRACE
179 #define ENC_DEC_TRACE 1
180 #endif
181 
182 
183 #if ENC_DEC_TRACE
184 extern FILE* g_hTrace;
185 extern Bool g_bJustDoIt;
186 extern const Bool g_bEncDecTraceEnable;
187 extern const Bool g_bEncDecTraceDisable;
188 extern Bool g_HLSTraceEnable;
189 extern UInt64 g_nSymbolCounter;
190 
191 #define COUNTER_START 1
192 #define COUNTER_END 0 //( UInt64(1) << 63 )
193 
194 #define DTRACE_CABAC_F(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%f", x );
195 #define DTRACE_CABAC_V(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%d", x );
196 #define DTRACE_CABAC_VL(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%lld", x );
197 #define DTRACE_CABAC_T(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%s", x );
198 #define DTRACE_CABAC_X(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%x", x );
199 #define DTRACE_CABAC_R( x,y ) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, x, y );
200 #define DTRACE_CABAC_N if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "\n" );
201 
202 #else
203 
204 #define DTRACE_CABAC_F(x)
205 #define DTRACE_CABAC_V(x)
206 #define DTRACE_CABAC_VL(x)
207 #define DTRACE_CABAC_T(x)
208 #define DTRACE_CABAC_X(x)
209 #define DTRACE_CABAC_R( x,y )
210 #define DTRACE_CABAC_N
211 
212 #endif
213 
214 
215 #define SCALING_LIST_NUM (MAX_NUM_COMPONENT * NUMBER_OF_PREDICTION_MODES)
216 
217 #define SCALING_LIST_START_VALUE 8
218 #define MAX_MATRIX_COEF_NUM 64
219 #define MAX_MATRIX_SIZE_NUM 8
220 #define SCALING_LIST_BITS 8
221 #define LOG2_SCALING_LIST_NEUTRAL_VALUE 4
222 #define SCALING_LIST_DC 16
223 
226 
227 extern Int g_quantTSDefault4x4[4*4];
228 extern Int g_quantIntraDefault8x8[8*8];
229 extern Int g_quantInterDefault8x8[8*8];
230 
235 
236 #endif //__TCOMROM__
237 
#define MAX_CU_SIZE
Definition: TComRom.h:54
UInt g_auiRasterToPelY[((1<<(6))/4)*((1<<(6))/4)]
Definition: TComRom.cpp:258
UInt64 g_nSymbolCounter
Definition: TComRom.cpp:566
UInt g_scalingListNum[SCALING_LIST_SIZE_NUM]
const UInt ctxIndMap4x4[4 *4]
Definition: TComRom.cpp:575
Void initROM()
Definition: TComRom.cpp:146
const TMatrixCoeff g_aiT4[TRANSFORM_NUMBER_OF_DIRECTIONS][4][4]
Definition: TComRom.cpp:462
UInt g_scalingListSizeX[SCALING_LIST_SIZE_NUM]
Definition: TComRom.cpp:679
Defines constants, macros and tool parameters.
void Void
Definition: TypeDef.h:285
const UChar g_aucChromaScale[NUM_CHROMA_FORMAT][chromaQPMappingTableSize]
Definition: TComRom.cpp:505
const TMatrixCoeff g_aiT32[TRANSFORM_NUMBER_OF_DIRECTIONS][32][32]
Definition: TComRom.cpp:480
const TMatrixCoeff g_as_DST_MAT_4[TRANSFORM_NUMBER_OF_DIRECTIONS][4][4]
Definition: TComRom.cpp:486
const UChar g_chroma422IntraAngleMappingTable[36]
Definition: TComRom.cpp:540
UInt g_auiPUOffset[NUMBER_OF_PART_SIZES]
Definition: TComRom.cpp:260
char Char
Definition: TypeDef.h:291
FILE * g_hTrace
Definition: TComRom.cpp:561
unsigned int UInt
Definition: TypeDef.h:297
UInt g_auiZscanToRaster[((1<<(6))/4)*((1<<(6))/4)]
Definition: TComRom.cpp:255
Int g_PCMBitDepth[MAX_NUM_CHANNEL_TYPE]
Definition: TComRom.cpp:552
#define NUM_INTRA_MODE
Definition: TypeDef.h:170
static const Int chromaQPMappingTableSize
Definition: TComRom.h:128
Bool g_bJustDoIt
Definition: TComRom.cpp:565
Void initZscanToRaster(Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt *&rpuiCurrIdx)
Definition: TComRom.cpp:262
const TMatrixCoeff g_aiT16[TRANSFORM_NUMBER_OF_DIRECTIONS][16][16]
Definition: TComRom.cpp:474
Short TMatrixCoeff
transform matrix coefficient
Definition: TypeDef.h:694
#define SCALING_LIST_NUM
list number for quantization matrix
Definition: TComRom.h:215
const Bool g_bEncDecTraceEnable
Definition: TComRom.cpp:562
Void initRasterToZscan(UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth)
Definition: TComRom.cpp:281
Bool g_HLSTraceEnable
Definition: TComRom.cpp:564
UInt * g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][6][6]
Definition: TComRom.cpp:573
UInt g_auiRasterToPelX[((1<<(6))/4)*((1<<(6))/4)]
Definition: TComRom.cpp:257
#define MAX_NUM_SPU_W
Definition: TComRom.h:58
bool Bool
Definition: TypeDef.h:286
Int g_invQuantScales[6]
Definition: TComRom.cpp:332
UInt g_uiMaxCUHeight
Definition: TComRom.cpp:252
UInt g_auiRasterToZscan[((1<<(6))/4)*((1<<(6))/4)]
Definition: TComRom.cpp:256
Int g_quantIntraDefault8x8[8 *8]
Definition: TComRom.cpp:654
#define LAST_SIGNIFICANT_GROUPS
Definition: TComRom.h:137
UInt g_uiMaxCUDepth
Definition: TComRom.cpp:253
Int g_quantTSDefault4x4[4 *4]
Definition: TComRom.cpp:646
Int g_quantInterDefault8x8[8 *8]
Definition: TComRom.cpp:666
UInt g_scalingListSize[SCALING_LIST_SIZE_NUM]
Definition: TComRom.cpp:678
static const Int g_transformMatrixShift[TRANSFORM_NUMBER_OF_DIRECTIONS]
Definition: TComRom.h:116
unsigned char UChar
Definition: TypeDef.h:293
const Bool g_bEncDecTraceDisable
Definition: TComRom.cpp:563
Int g_quantScales[6]
Definition: TComRom.cpp:327
const Char * MatrixType_DC[SCALING_LIST_SIZE_NUM][(MAX_NUM_COMPONENT *NUMBER_OF_PREDICTION_MODES)]
Definition: TComRom.cpp:622
const UInt g_uiGroupIdx[32]
Definition: TComRom.cpp:584
unsigned long long UInt64
Definition: TypeDef.h:318
#define MAX_CU_DEPTH
Definition: TComRom.h:53
Int g_bitDepth[MAX_NUM_CHANNEL_TYPE]
Definition: TComRom.cpp:548
const UInt g_uiMinInGroup[10]
Definition: TComRom.cpp:583
Void initRasterToPelXY(UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth)
Definition: TComRom.cpp:295
Void destroyROM()
Definition: TComRom.cpp:230
UInt g_uiAddCUDepth
Definition: TComRom.cpp:254
Char g_aucConvertToBit[(1<<(6))+1]
Definition: TComRom.cpp:558
const Char * MatrixType[SCALING_LIST_SIZE_NUM][(MAX_NUM_COMPONENT *NUMBER_OF_PREDICTION_MODES)]
Definition: TComRom.cpp:586
int Int
Definition: TypeDef.h:296
Int g_maxTrDynamicRange[MAX_NUM_CHANNEL_TYPE]
Definition: TComRom.cpp:325
const TMatrixCoeff g_aiT8[TRANSFORM_NUMBER_OF_DIRECTIONS][8][8]
Definition: TComRom.cpp:468
#define SCALING_LIST_REM_NUM
Definition: TComRom.h:60
const UChar g_aucIntraModeNumFast[6]
Definition: TComRom.cpp:519
#define MAX_TU_SIZE
Definition: TComRom.h:57
UInt g_uiMaxCUWidth
Definition: TComRom.cpp:251