source: SHVCSoftware/branches/SHM-dev/source/Lib/TLibCommon/TComRom.h @ 1302

Last change on this file since 1302 was 1292, checked in by seregin, 9 years ago

port rev 4326

  • Property svn:eol-style set to native
File size: 11.1 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-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
34/** \file     TComRom.h
35    \brief    global variables & functions (header)
36*/
37
38#ifndef __TCOMROM__
39#define __TCOMROM__
40
41#include "CommonDef.h"
42
43#include<stdio.h>
44#include<iostream>
45
46//! \ingroup TLibCommon
47//! \{
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
66Void         initROM();
67Void         destroyROM();
68
69// ====================================================================================================================
70// Data structure related table & variable
71// ====================================================================================================================
72
73// flexible conversion from relative to absolute index
74extern       UInt   g_auiZscanToRaster[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
75extern       UInt   g_auiRasterToZscan[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
76extern       UInt*  g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][ MAX_CU_DEPTH ][ MAX_CU_DEPTH ];
77
78Void         initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx );
79Void         initRasterToZscan ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth         );
80
81// conversion of partition index to picture pel position
82extern       UInt   g_auiRasterToPelX[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
83extern       UInt   g_auiRasterToPelY[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
84
85Void         initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth );
86
87extern const UInt g_auiPUOffset[NUMBER_OF_PART_SIZES];
88
89#define QUANT_SHIFT                14 // Q(4) = 2^14
90#define IQUANT_SHIFT                6
91#define SCALE_BITS                 15 // Inherited from TMuC, pressumably for fractional bit estimates in RDOQ
92
93#define SQRT2                      11585
94#define SQRT2_SHIFT                13
95#define INVSQRT2                   11585
96#define INVSQRT2_SHIFT             14
97#define ADDITIONAL_MULTIPLIER_BITS 14
98
99#define SHIFT_INV_1ST               7 // Shift after first inverse transform stage
100#define SHIFT_INV_2ND              12 // Shift after second inverse transform stage
101
102extern const Int g_quantScales[SCALING_LIST_REM_NUM];             // Q(QP%6)
103extern const Int g_invQuantScales[SCALING_LIST_REM_NUM];          // IQ(QP%6)
104
105#if RExt__HIGH_PRECISION_FORWARD_TRANSFORM
106static const Int g_transformMatrixShift[TRANSFORM_NUMBER_OF_DIRECTIONS] = { 14, 6 };
107#else
108static const Int g_transformMatrixShift[TRANSFORM_NUMBER_OF_DIRECTIONS] = {  6, 6 };
109#endif
110
111extern const TMatrixCoeff g_aiT4 [TRANSFORM_NUMBER_OF_DIRECTIONS][4][4];
112extern const TMatrixCoeff g_aiT8 [TRANSFORM_NUMBER_OF_DIRECTIONS][8][8];
113extern const TMatrixCoeff g_aiT16[TRANSFORM_NUMBER_OF_DIRECTIONS][16][16];
114extern const TMatrixCoeff g_aiT32[TRANSFORM_NUMBER_OF_DIRECTIONS][32][32];
115
116// ====================================================================================================================
117// Luma QP to Chroma QP mapping
118// ====================================================================================================================
119
120static const Int chromaQPMappingTableSize = 58;
121
122extern const UChar  g_aucChromaScale[NUM_CHROMA_FORMAT][chromaQPMappingTableSize];
123
124// ====================================================================================================================
125// Entropy Coding
126// ====================================================================================================================
127
128#define CONTEXT_STATE_BITS             6
129#define LAST_SIGNIFICANT_GROUPS       10
130
131// ====================================================================================================================
132// Scanning order & context mapping table
133// ====================================================================================================================
134
135extern const UInt   ctxIndMap4x4[4*4];
136
137extern const UInt   g_uiGroupIdx[ MAX_TU_SIZE ];
138extern const UInt   g_uiMinInGroup[ LAST_SIGNIFICANT_GROUPS ];
139
140// ====================================================================================================================
141// ADI table
142// ====================================================================================================================
143
144extern const UChar  g_aucIntraModeNumFast[MAX_CU_DEPTH];
145
146extern const UChar  g_chroma422IntraAngleMappingTable[NUM_INTRA_MODE];
147
148// ====================================================================================================================
149// Mode-Dependent DST Matrices
150// ====================================================================================================================
151
152extern const TMatrixCoeff g_as_DST_MAT_4 [TRANSFORM_NUMBER_OF_DIRECTIONS][4][4];
153
154// ====================================================================================================================
155// Misc.
156// ====================================================================================================================
157
158extern       Char   g_aucConvertToBit  [ MAX_CU_SIZE+1 ];   // from width to log2(width)-2
159
160#ifndef ENC_DEC_TRACE
161#define ENC_DEC_TRACE 0
162#endif
163
164
165#if ENC_DEC_TRACE
166extern FILE*  g_hTrace;
167extern Bool   g_bJustDoIt;
168extern const Bool g_bEncDecTraceEnable;
169extern const Bool g_bEncDecTraceDisable;
170extern Bool   g_HLSTraceEnable;
171extern UInt64 g_nSymbolCounter;
172
173#define COUNTER_START    1
174#define COUNTER_END      0 //( UInt64(1) << 63 )
175
176#define DTRACE_CABAC_F(x)     if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%f", x );
177#define DTRACE_CABAC_V(x)     if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%d", x );
178#define DTRACE_CABAC_VL(x)    if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%lld", x );
179#define DTRACE_CABAC_T(x)     if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%s", x );
180#define DTRACE_CABAC_X(x)     if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%x", x );
181#define DTRACE_CABAC_R( x,y ) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, x,    y );
182#define DTRACE_CABAC_N        if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "\n"    );
183
184#else
185
186#define DTRACE_CABAC_F(x)
187#define DTRACE_CABAC_V(x)
188#define DTRACE_CABAC_VL(x)
189#define DTRACE_CABAC_T(x)
190#define DTRACE_CABAC_X(x)
191#define DTRACE_CABAC_R( x,y )
192#define DTRACE_CABAC_N
193
194#endif
195
196
197#define SCALING_LIST_NUM (MAX_NUM_COMPONENT * NUMBER_OF_PREDICTION_MODES) ///< list number for quantization matrix
198
199#define SCALING_LIST_START_VALUE 8                                        ///< start value for dpcm mode
200#define MAX_MATRIX_COEF_NUM 64                                            ///< max coefficient number for quantization matrix
201#define MAX_MATRIX_SIZE_NUM 8                                             ///< max size number for quantization matrix
202#define SCALING_LIST_BITS 8                                               ///< bit depth of scaling list entries
203#define LOG2_SCALING_LIST_NEUTRAL_VALUE 4                                 ///< log2 of the value that, when used in a scaling list, has no effect on quantisation
204#define SCALING_LIST_DC 16                                                ///< default DC value
205
206extern const Char *MatrixType[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM];
207extern const Char *MatrixType_DC[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM];
208
209extern const Int g_quantTSDefault4x4[4*4];
210extern const Int g_quantIntraDefault8x8[8*8];
211extern const Int g_quantInterDefault8x8[8*8];
212
213extern const UInt g_scalingListSize [SCALING_LIST_SIZE_NUM];
214extern const UInt g_scalingListSizeX[SCALING_LIST_SIZE_NUM];
215extern const UInt g_scalingListNum  [SCALING_LIST_SIZE_NUM];
216
217#if SVC_EXTENSION
218#if FAST_INTRA_SHVC
219extern UInt g_reducedSetIntraModes[NUM_INTRA_MODE-1];
220extern UInt g_predefSetIntraModes[NUM_INTRA_MODE-1];
221#endif
222extern Int g_mvScalingFactor  [MAX_LAYERS][2];
223extern Int g_posScalingFactor [MAX_LAYERS][2];
224std::string NaluToStr( NalUnitType nalu );
225#if LAYER_CTB
226extern       UInt g_auiLayerZscanToRaster[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
227extern       UInt g_auiLayerRasterToZscan[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
228extern       UInt g_auiLayerRasterToPelX[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
229extern       UInt g_auiLayerRasterToPelY[MAX_LAYERS][ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
230#endif
231#endif //SVC_EXTENSION
232
233//! \}
234
235#endif  //__TCOMROM__
236
Note: See TracBrowser for help on using the repository browser.