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 | /** \file TComRom.h |
---|
34 | \brief global variables & functions (header) |
---|
35 | */ |
---|
36 | #ifndef __TCOMROM__ |
---|
37 | #define __TCOMROM__ |
---|
38 | #include "CommonDef.h" |
---|
39 | #include<stdio.h> |
---|
40 | #include<iostream> |
---|
41 | #if H_3D_DIM |
---|
42 | #include "TComWedgelet.h" |
---|
43 | #endif |
---|
44 | //! \ingroup TLibCommon |
---|
45 | //! \{ |
---|
46 | // ==================================================================================================================== |
---|
47 | // Initialize / destroy functions |
---|
48 | // ==================================================================================================================== |
---|
49 | Void initROM(); |
---|
50 | Void destroyROM(); |
---|
51 | // ==================================================================================================================== |
---|
52 | // Data structure related table & variable |
---|
53 | // ==================================================================================================================== |
---|
54 | // flexible conversion from relative to absolute index |
---|
55 | extern UInt g_auiZscanToRaster[ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ]; |
---|
56 | extern UInt g_auiRasterToZscan[ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ]; |
---|
57 | extern UInt* g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][ MAX_CU_DEPTH ][ MAX_CU_DEPTH ]; |
---|
58 | Void initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx ); |
---|
59 | Void initRasterToZscan ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ); |
---|
60 | // conversion of partition index to picture pel position |
---|
61 | extern UInt g_auiRasterToPelX[ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ]; |
---|
62 | extern UInt g_auiRasterToPelY[ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ]; |
---|
63 | Void initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ); |
---|
64 | extern const UInt g_auiPUOffset[NUMBER_OF_PART_SIZES]; |
---|
65 | extern const Int g_quantScales[SCALING_LIST_REM_NUM]; // Q(QP%6) |
---|
66 | extern const Int g_invQuantScales[SCALING_LIST_REM_NUM]; // IQ(QP%6) |
---|
67 | #if RExt__HIGH_PRECISION_FORWARD_TRANSFORM |
---|
68 | static const Int g_transformMatrixShift[TRANSFORM_NUMBER_OF_DIRECTIONS] = { 14, 6 }; |
---|
69 | #else |
---|
70 | static const Int g_transformMatrixShift[TRANSFORM_NUMBER_OF_DIRECTIONS] = { 6, 6 }; |
---|
71 | #endif |
---|
72 | extern const TMatrixCoeff g_aiT4 [TRANSFORM_NUMBER_OF_DIRECTIONS][4][4]; |
---|
73 | extern const TMatrixCoeff g_aiT8 [TRANSFORM_NUMBER_OF_DIRECTIONS][8][8]; |
---|
74 | extern const TMatrixCoeff g_aiT16[TRANSFORM_NUMBER_OF_DIRECTIONS][16][16]; |
---|
75 | extern const TMatrixCoeff g_aiT32[TRANSFORM_NUMBER_OF_DIRECTIONS][32][32]; |
---|
76 | // ==================================================================================================================== |
---|
77 | // Luma QP to Chroma QP mapping |
---|
78 | // ==================================================================================================================== |
---|
79 | static const Int chromaQPMappingTableSize = 58; |
---|
80 | extern const UChar g_aucChromaScale[NUM_CHROMA_FORMAT][chromaQPMappingTableSize]; |
---|
81 | // ==================================================================================================================== |
---|
82 | // Scanning order & context mapping table |
---|
83 | // ==================================================================================================================== |
---|
84 | extern const UInt ctxIndMap4x4[4*4]; |
---|
85 | extern const UInt g_uiGroupIdx[ MAX_TU_SIZE ]; |
---|
86 | extern const UInt g_uiMinInGroup[ LAST_SIGNIFICANT_GROUPS ]; |
---|
87 | // ==================================================================================================================== |
---|
88 | // Intra prediction table |
---|
89 | // ==================================================================================================================== |
---|
90 | extern const UChar g_aucIntraModeNumFast_UseMPM[MAX_CU_DEPTH]; |
---|
91 | extern const UChar g_aucIntraModeNumFast_NotUseMPM[MAX_CU_DEPTH]; |
---|
92 | extern const UChar g_chroma422IntraAngleMappingTable[NUM_INTRA_MODE]; |
---|
93 | #if H_3D_DIM |
---|
94 | // ==================================================================================================================== |
---|
95 | // Depth coding modes |
---|
96 | // ==================================================================================================================== |
---|
97 | __inline Void mapDepthModeToIntraDir( UInt& intraMode ) { if( isDimMode( intraMode ) ) intraMode = DC_IDX; } |
---|
98 | __inline Void mapDepthModeToIntraDir( Int& intraMode ) { if( isDimMode( intraMode ) ) intraMode = DC_IDX; } |
---|
99 | #if H_3D_DIM_SDC || H_3D_DIM_DLT |
---|
100 | __inline UInt numBitsForValue( UInt value ) { UInt bits = 0; while (value != 0) { value >>= 1; bits++; } return bits; }; |
---|
101 | #endif |
---|
102 | #if H_3D_DIM_DMM |
---|
103 | extern const WedgeResolution g_dmmWedgeResolution [6]; |
---|
104 | extern const UChar g_dmm1TabIdxBits [6]; |
---|
105 | extern const UChar g_dmm3IntraTabIdxBits[6]; |
---|
106 | extern Bool g_wedgePattern[32*32]; |
---|
107 | extern std::vector< std::vector<TComWedgelet> > g_dmmWedgeLists; |
---|
108 | extern std::vector< std::vector<TComWedgeRef> > g_dmmWedgeRefLists; |
---|
109 | extern std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists; |
---|
110 | Void initWedgeLists( Bool initNodeList = false ); |
---|
111 | Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes ); |
---|
112 | Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList ); |
---|
113 | #endif |
---|
114 | #endif |
---|
115 | // ==================================================================================================================== |
---|
116 | // Mode-Dependent DST Matrices |
---|
117 | // ==================================================================================================================== |
---|
118 | extern const TMatrixCoeff g_as_DST_MAT_4 [TRANSFORM_NUMBER_OF_DIRECTIONS][4][4]; |
---|
119 | #if H_MV_HLS_PTL_LIMITS |
---|
120 | class TComGeneralTierAndLevelLimits |
---|
121 | { |
---|
122 | public: |
---|
123 | TComGeneralTierAndLevelLimits::TComGeneralTierAndLevelLimits |
---|
124 | ( Int maxLumaPs, |
---|
125 | Int maxCPBMainTier, |
---|
126 | Int maxCPBHighTier, |
---|
127 | Int maxSliceSegmentsPerPicture, |
---|
128 | Int maxTileRows, |
---|
129 | Int maxTileCols ) |
---|
130 | : m_maxLumaPs ( maxLumaPs ), |
---|
131 | m_maxCPBMainTier ( maxCPBMainTier ), |
---|
132 | m_maxCPBHighTier ( maxCPBHighTier ), |
---|
133 | m_maxSliceSegmentsPerPicture( maxSliceSegmentsPerPicture ), |
---|
134 | m_maxTileRows ( maxTileRows ), |
---|
135 | m_maxTileCols ( maxTileCols ); |
---|
136 | {}; |
---|
137 | Int getMaxLumaPs ( ) { return m_maxLumaPs ; }; |
---|
138 | Int getMaxCPBMainTier ( ) { return m_maxCPBMainTier ; }; |
---|
139 | Int getMaxCPBHighTier ( ) { return m_maxCPBHighTier ; }; |
---|
140 | Int getMaxSliceSegmentsPerPicture( ) { return m_maxSliceSegmentsPerPicture; }; |
---|
141 | Int getMaxTileRows ( ) { return m_maxTileRows ; }; |
---|
142 | Int getMaxTileCols ( ) { return m_maxTileCols ; }; |
---|
143 | private: |
---|
144 | const Int m_maxLumaPs; |
---|
145 | const Int m_maxCPBMainTier; |
---|
146 | const Int m_maxCPBHighTier; |
---|
147 | const Int m_maxSliceSegmentsPerPicture; |
---|
148 | const Int m_maxTileRows; |
---|
149 | const Int m_maxTileCols; |
---|
150 | }; |
---|
151 | extern std::map< Level::Name, TComGeneralTierAndLevelLimits > g_generalTierAndLevelLimits; |
---|
152 | #endif |
---|
153 | // ==================================================================================================================== |
---|
154 | // Misc. |
---|
155 | // ==================================================================================================================== |
---|
156 | extern Char g_aucConvertToBit [ MAX_CU_SIZE+1 ]; // from width to log2(width)-2 |
---|
157 | #if NH_MV |
---|
158 | // Change later |
---|
159 | #ifndef ENC_DEC_TRACE |
---|
160 | #define ENC_DEC_TRACE 0 |
---|
161 | #endif |
---|
162 | #endif |
---|
163 | #if ENC_DEC_TRACE |
---|
164 | extern FILE* g_hTrace; |
---|
165 | extern Bool g_bJustDoIt; |
---|
166 | extern const Bool g_bEncDecTraceEnable; |
---|
167 | extern const Bool g_bEncDecTraceDisable; |
---|
168 | extern Bool g_HLSTraceEnable; |
---|
169 | extern UInt64 g_nSymbolCounter; |
---|
170 | #define COUNTER_START 1 |
---|
171 | #define COUNTER_END 0 //( UInt64(1) << 63 ) |
---|
172 | #define DTRACE_CABAC_F(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%f", x ); |
---|
173 | #define DTRACE_CABAC_V(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%d", x ); |
---|
174 | #define DTRACE_CABAC_VL(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%lld", x ); |
---|
175 | #define DTRACE_CABAC_T(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%s", x ); |
---|
176 | #define DTRACE_CABAC_X(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%x", x ); |
---|
177 | #define DTRACE_CABAC_R( x,y ) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, x, y ); |
---|
178 | #define DTRACE_CABAC_N if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "\n" ); |
---|
179 | #if H_MV_ENC_DEC_TRAC |
---|
180 | extern Bool g_traceCU; |
---|
181 | extern Bool g_tracePU ; |
---|
182 | extern Bool g_traceTU; |
---|
183 | extern Bool g_disableHLSTrace; // USE g_HLSTraceEnable to toggle HLS trace. Not this one! |
---|
184 | extern Bool g_disableNumbering; // Don't print numbers to trace file |
---|
185 | extern UInt64 g_stopAtCounter; // Counter to set breakpoint. |
---|
186 | extern Bool g_traceCopyBack; // Output samples on copy back |
---|
187 | extern Bool g_decTraceDispDer; // Trace derived disparity vectors (decoder only) |
---|
188 | extern Bool g_decTraceMvFromMerge; // Trace motion vectors obtained from merge (decoder only) |
---|
189 | extern Bool g_decTracePicOutput; // Trace output of pictures |
---|
190 | extern Bool g_stopAtPos; // Stop at position |
---|
191 | extern Bool g_outputPos; // Output position |
---|
192 | extern Bool g_traceCameraParameters; // Trace camera parameters |
---|
193 | extern Bool g_encNumberOfWrittenBits;// Trace number of written bits |
---|
194 | #define DTRACE_CU(x,y) writeToTraceFile( x,y, g_traceCU ); |
---|
195 | #define DTRACE_PU(x,y) writeToTraceFile( x,y, g_tracePU ); |
---|
196 | #define DTRACE_TU(x,y) writeToTraceFile( x,y, g_traceTU ); |
---|
197 | #define DTRACE_CU_S(x) writeToTraceFile( x, g_traceCU ); |
---|
198 | #define DTRACE_PU_S(x) writeToTraceFile( x, g_tracePU ); |
---|
199 | #define DTRACE_TU_S(x) writeToTraceFile( x, g_traceTU ); |
---|
200 | Void tracePSHeader ( const Char* psName, Int layerId ); |
---|
201 | Void writeToTraceFile( const Char* symbolName, Int val, Bool doIt ); |
---|
202 | Void writeToTraceFile( const Char* symbolName, Bool doIt ); |
---|
203 | Void stopAtPos ( Int poc, Int layerId, Int cuPelX, Int cuPelY, Int cuWidth, Int cuHeight ); |
---|
204 | #endif |
---|
205 | #else |
---|
206 | #define DTRACE_CABAC_F(x) |
---|
207 | #define DTRACE_CABAC_V(x) |
---|
208 | #define DTRACE_CABAC_VL(x) |
---|
209 | #define DTRACE_CABAC_T(x) |
---|
210 | #define DTRACE_CABAC_X(x) |
---|
211 | #define DTRACE_CABAC_R( x,y ) |
---|
212 | #define DTRACE_CABAC_N |
---|
213 | #if H_MV_ENC_DEC_TRAC |
---|
214 | #define DTRACE_CU(x,y) ; |
---|
215 | #define DTRACE_PU(x,y) ; |
---|
216 | #define DTRACE_TU(x,y) ; |
---|
217 | #define DTRACE_CU_S(x) ; |
---|
218 | #define DTRACE_PU_S(x) ; |
---|
219 | #define DTRACE_TU_S(x) ; |
---|
220 | #endif |
---|
221 | #endif |
---|
222 | const Char* nalUnitTypeToString(NalUnitType type); |
---|
223 | extern const Char *MatrixType[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; |
---|
224 | extern const Char *MatrixType_DC[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; |
---|
225 | extern const Int g_quantTSDefault4x4[4*4]; |
---|
226 | extern const Int g_quantIntraDefault8x8[8*8]; |
---|
227 | extern const Int g_quantInterDefault8x8[8*8]; |
---|
228 | extern const UInt g_scalingListSize [SCALING_LIST_SIZE_NUM]; |
---|
229 | extern const UInt g_scalingListSizeX[SCALING_LIST_SIZE_NUM]; |
---|
230 | //! \} |
---|
231 | #endif //__TCOMROM__ |
---|