[5] | 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 |
---|
[1313] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[1313] | 6 | * Copyright (c) 2010-2015, ITU/ISO/IEC |
---|
[5] | 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. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 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 | */ |
---|
[2] | 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> |
---|
[56] | 41 | //! \ingroup TLibCommon |
---|
| 42 | //! \{ |
---|
[2] | 43 | // ==================================================================================================================== |
---|
| 44 | // Initialize / destroy functions |
---|
| 45 | // ==================================================================================================================== |
---|
| 46 | Void initROM(); |
---|
| 47 | Void destroyROM(); |
---|
| 48 | // ==================================================================================================================== |
---|
| 49 | // Data structure related table & variable |
---|
| 50 | // ==================================================================================================================== |
---|
| 51 | // flexible conversion from relative to absolute index |
---|
[1313] | 52 | extern UInt g_auiZscanToRaster[ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ]; |
---|
| 53 | extern UInt g_auiRasterToZscan[ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ]; |
---|
| 54 | extern UInt* g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][ MAX_CU_DEPTH ][ MAX_CU_DEPTH ]; |
---|
[2] | 55 | Void initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx ); |
---|
| 56 | Void initRasterToZscan ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ); |
---|
| 57 | // conversion of partition index to picture pel position |
---|
[1313] | 58 | extern UInt g_auiRasterToPelX[ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ]; |
---|
| 59 | extern UInt g_auiRasterToPelY[ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ]; |
---|
[2] | 60 | Void initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ); |
---|
[1313] | 61 | extern const UInt g_auiPUOffset[NUMBER_OF_PART_SIZES]; |
---|
| 62 | extern const Int g_quantScales[SCALING_LIST_REM_NUM]; // Q(QP%6) |
---|
| 63 | extern const Int g_invQuantScales[SCALING_LIST_REM_NUM]; // IQ(QP%6) |
---|
| 64 | #if RExt__HIGH_PRECISION_FORWARD_TRANSFORM |
---|
| 65 | static const Int g_transformMatrixShift[TRANSFORM_NUMBER_OF_DIRECTIONS] = { 14, 6 }; |
---|
| 66 | #else |
---|
| 67 | static const Int g_transformMatrixShift[TRANSFORM_NUMBER_OF_DIRECTIONS] = { 6, 6 }; |
---|
| 68 | #endif |
---|
| 69 | extern const TMatrixCoeff g_aiT4 [TRANSFORM_NUMBER_OF_DIRECTIONS][4][4]; |
---|
| 70 | extern const TMatrixCoeff g_aiT8 [TRANSFORM_NUMBER_OF_DIRECTIONS][8][8]; |
---|
| 71 | extern const TMatrixCoeff g_aiT16[TRANSFORM_NUMBER_OF_DIRECTIONS][16][16]; |
---|
| 72 | extern const TMatrixCoeff g_aiT32[TRANSFORM_NUMBER_OF_DIRECTIONS][32][32]; |
---|
[2] | 73 | // ==================================================================================================================== |
---|
| 74 | // Luma QP to Chroma QP mapping |
---|
| 75 | // ==================================================================================================================== |
---|
[1313] | 76 | static const Int chromaQPMappingTableSize = 58; |
---|
| 77 | extern const UChar g_aucChromaScale[NUM_CHROMA_FORMAT][chromaQPMappingTableSize]; |
---|
[2] | 78 | // ==================================================================================================================== |
---|
| 79 | // Scanning order & context mapping table |
---|
| 80 | // ==================================================================================================================== |
---|
[1313] | 81 | extern const UInt ctxIndMap4x4[4*4]; |
---|
| 82 | extern const UInt g_uiGroupIdx[ MAX_TU_SIZE ]; |
---|
| 83 | extern const UInt g_uiMinInGroup[ LAST_SIGNIFICANT_GROUPS ]; |
---|
[2] | 84 | // ==================================================================================================================== |
---|
[1313] | 85 | // Intra prediction table |
---|
[2] | 86 | // ==================================================================================================================== |
---|
[1313] | 87 | extern const UChar g_aucIntraModeNumFast_UseMPM[MAX_CU_DEPTH]; |
---|
| 88 | extern const UChar g_aucIntraModeNumFast_NotUseMPM[MAX_CU_DEPTH]; |
---|
| 89 | extern const UChar g_chroma422IntraAngleMappingTable[NUM_INTRA_MODE]; |
---|
[2] | 90 | // ==================================================================================================================== |
---|
| 91 | // Mode-Dependent DST Matrices |
---|
[1313] | 92 | // ==================================================================================================================== |
---|
| 93 | extern const TMatrixCoeff g_as_DST_MAT_4 [TRANSFORM_NUMBER_OF_DIRECTIONS][4][4]; |
---|
[1066] | 94 | #if H_MV_HLS_PTL_LIMITS |
---|
| 95 | class TComGeneralTierAndLevelLimits |
---|
| 96 | { |
---|
| 97 | public: |
---|
| 98 | TComGeneralTierAndLevelLimits::TComGeneralTierAndLevelLimits |
---|
| 99 | ( Int maxLumaPs, |
---|
| 100 | Int maxCPBMainTier, |
---|
| 101 | Int maxCPBHighTier, |
---|
| 102 | Int maxSliceSegmentsPerPicture, |
---|
| 103 | Int maxTileRows, |
---|
| 104 | Int maxTileCols ) |
---|
| 105 | : m_maxLumaPs ( maxLumaPs ), |
---|
| 106 | m_maxCPBMainTier ( maxCPBMainTier ), |
---|
| 107 | m_maxCPBHighTier ( maxCPBHighTier ), |
---|
| 108 | m_maxSliceSegmentsPerPicture( maxSliceSegmentsPerPicture ), |
---|
| 109 | m_maxTileRows ( maxTileRows ), |
---|
| 110 | m_maxTileCols ( maxTileCols ); |
---|
| 111 | {}; |
---|
| 112 | Int getMaxLumaPs ( ) { return m_maxLumaPs ; }; |
---|
| 113 | Int getMaxCPBMainTier ( ) { return m_maxCPBMainTier ; }; |
---|
| 114 | Int getMaxCPBHighTier ( ) { return m_maxCPBHighTier ; }; |
---|
| 115 | Int getMaxSliceSegmentsPerPicture( ) { return m_maxSliceSegmentsPerPicture; }; |
---|
| 116 | Int getMaxTileRows ( ) { return m_maxTileRows ; }; |
---|
| 117 | Int getMaxTileCols ( ) { return m_maxTileCols ; }; |
---|
| 118 | private: |
---|
| 119 | const Int m_maxLumaPs; |
---|
| 120 | const Int m_maxCPBMainTier; |
---|
| 121 | const Int m_maxCPBHighTier; |
---|
| 122 | const Int m_maxSliceSegmentsPerPicture; |
---|
| 123 | const Int m_maxTileRows; |
---|
| 124 | const Int m_maxTileCols; |
---|
| 125 | }; |
---|
| 126 | extern std::map< Level::Name, TComGeneralTierAndLevelLimits > g_generalTierAndLevelLimits; |
---|
| 127 | #endif |
---|
[2] | 128 | // ==================================================================================================================== |
---|
| 129 | // Misc. |
---|
| 130 | // ==================================================================================================================== |
---|
| 131 | extern Char g_aucConvertToBit [ MAX_CU_SIZE+1 ]; // from width to log2(width)-2 |
---|
[1313] | 132 | #if NH_MV |
---|
| 133 | // Change later |
---|
[608] | 134 | #ifndef ENC_DEC_TRACE |
---|
[1313] | 135 | #define ENC_DEC_TRACE 0 |
---|
[608] | 136 | #endif |
---|
[1313] | 137 | #endif |
---|
[2] | 138 | #if ENC_DEC_TRACE |
---|
| 139 | extern FILE* g_hTrace; |
---|
| 140 | extern Bool g_bJustDoIt; |
---|
| 141 | extern const Bool g_bEncDecTraceEnable; |
---|
| 142 | extern const Bool g_bEncDecTraceDisable; |
---|
[608] | 143 | extern Bool g_HLSTraceEnable; |
---|
[2] | 144 | extern UInt64 g_nSymbolCounter; |
---|
| 145 | #define COUNTER_START 1 |
---|
| 146 | #define COUNTER_END 0 //( UInt64(1) << 63 ) |
---|
| 147 | #define DTRACE_CABAC_F(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%f", x ); |
---|
| 148 | #define DTRACE_CABAC_V(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%d", x ); |
---|
[56] | 149 | #define DTRACE_CABAC_VL(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%lld", x ); |
---|
[2] | 150 | #define DTRACE_CABAC_T(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%s", x ); |
---|
| 151 | #define DTRACE_CABAC_X(x) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%x", x ); |
---|
| 152 | #define DTRACE_CABAC_R( x,y ) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, x, y ); |
---|
| 153 | #define DTRACE_CABAC_N if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "\n" ); |
---|
[608] | 154 | #if H_MV_ENC_DEC_TRAC |
---|
| 155 | extern Bool g_traceCU; |
---|
[1313] | 156 | extern Bool g_tracePU ; |
---|
[608] | 157 | extern Bool g_traceTU; |
---|
[622] | 158 | extern Bool g_disableHLSTrace; // USE g_HLSTraceEnable to toggle HLS trace. Not this one! |
---|
[1179] | 159 | extern Bool g_disableNumbering; // Don't print numbers to trace file |
---|
[622] | 160 | extern UInt64 g_stopAtCounter; // Counter to set breakpoint. |
---|
| 161 | extern Bool g_traceCopyBack; // Output samples on copy back |
---|
[964] | 162 | extern Bool g_decTraceDispDer; // Trace derived disparity vectors (decoder only) |
---|
[622] | 163 | extern Bool g_decTraceMvFromMerge; // Trace motion vectors obtained from merge (decoder only) |
---|
[964] | 164 | extern Bool g_decTracePicOutput; // Trace output of pictures |
---|
[1313] | 165 | extern Bool g_startStopTrace; // Stop at position |
---|
[872] | 166 | extern Bool g_outputPos; // Output position |
---|
[1179] | 167 | extern Bool g_traceCameraParameters; // Trace camera parameters |
---|
| 168 | extern Bool g_encNumberOfWrittenBits;// Trace number of written bits |
---|
[1313] | 169 | extern Bool g_traceEncFracBits; // Trace fractional bits |
---|
| 170 | extern Bool g_traceIntraSearchCost; // Trace intra mode cost |
---|
| 171 | extern Bool g_traceRDCost; |
---|
| 172 | extern Bool g_traceModeCheck; |
---|
| 173 | extern Bool g_traceSAOCost; |
---|
| 174 | extern UInt g_indent; |
---|
[1321] | 175 | extern Bool g_traceMotionInfoBeforUniPred; |
---|
| 176 | extern Bool g_traceMergeCandListConst; |
---|
| 177 | extern Bool g_traceSubPBMotion; |
---|
| 178 | extern Bool g_traceBitsRead; |
---|
[608] | 179 | #define DTRACE_CU(x,y) writeToTraceFile( x,y, g_traceCU ); |
---|
| 180 | #define DTRACE_PU(x,y) writeToTraceFile( x,y, g_tracePU ); |
---|
| 181 | #define DTRACE_TU(x,y) writeToTraceFile( x,y, g_traceTU ); |
---|
| 182 | #define DTRACE_CU_S(x) writeToTraceFile( x, g_traceCU ); |
---|
| 183 | #define DTRACE_PU_S(x) writeToTraceFile( x, g_tracePU ); |
---|
| 184 | #define DTRACE_TU_S(x) writeToTraceFile( x, g_traceTU ); |
---|
[1325] | 185 | |
---|
[1313] | 186 | #define D_DEC_INDENT( b ) decIndent ( b ); |
---|
| 187 | #define D_PRINT_INC_INDENT( b, str ) prinStrIncIndent( b, str ); |
---|
| 188 | #define D_PRINT_INDENT( b, str ) printStrIndent ( b, str); |
---|
[1325] | 189 | |
---|
[1313] | 190 | Void tracePSHeader ( const Char* psName, Int layerId ); |
---|
[738] | 191 | Void writeToTraceFile( const Char* symbolName, Int val, Bool doIt ); |
---|
| 192 | Void writeToTraceFile( const Char* symbolName, Bool doIt ); |
---|
[1313] | 193 | UInt64 incSymbolCounter(); |
---|
| 194 | Void stopAtPos ( Int poc, Int layerId, Int cuPelX, Int cuPelY, Int cuWidth, Int cuHeight ); |
---|
[1325] | 195 | |
---|
[1313] | 196 | Void printStr ( std::string str ); |
---|
| 197 | Void printStrIndent ( Bool b, std::string str ); |
---|
| 198 | Void prinStrIncIndent ( Bool b, std::string str ); |
---|
| 199 | Void decIndent ( Bool b ); |
---|
[1325] | 200 | |
---|
[1313] | 201 | template <typename T> |
---|
| 202 | std::string n2s ( T Number ) |
---|
| 203 | { |
---|
| 204 | std::ostringstream ss; |
---|
| 205 | ss << Number; |
---|
| 206 | return ss.str(); |
---|
| 207 | }; |
---|
[1325] | 208 | |
---|
[608] | 209 | #endif |
---|
[2] | 210 | #else |
---|
| 211 | #define DTRACE_CABAC_F(x) |
---|
| 212 | #define DTRACE_CABAC_V(x) |
---|
[56] | 213 | #define DTRACE_CABAC_VL(x) |
---|
[2] | 214 | #define DTRACE_CABAC_T(x) |
---|
| 215 | #define DTRACE_CABAC_X(x) |
---|
| 216 | #define DTRACE_CABAC_R( x,y ) |
---|
| 217 | #define DTRACE_CABAC_N |
---|
[1321] | 218 | #if NH_MV |
---|
[1196] | 219 | #define DTRACE_CU(x,y) ; |
---|
| 220 | #define DTRACE_PU(x,y) ; |
---|
| 221 | #define DTRACE_TU(x,y) ; |
---|
| 222 | #define DTRACE_CU_S(x) ; |
---|
| 223 | #define DTRACE_PU_S(x) ; |
---|
| 224 | #define DTRACE_TU_S(x) ; |
---|
[1325] | 225 | |
---|
[1313] | 226 | #define D_DEC_INDENT( b ) ; |
---|
| 227 | #define D_PRINT_INC_INDENT( b, str ); |
---|
| 228 | #define D_PRINT_INDENT( b, str ); |
---|
[2] | 229 | #endif |
---|
[1321] | 230 | #endif |
---|
[1313] | 231 | const Char* nalUnitTypeToString(NalUnitType type); |
---|
| 232 | extern const Char *MatrixType[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; |
---|
| 233 | extern const Char *MatrixType_DC[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; |
---|
| 234 | extern const Int g_quantTSDefault4x4[4*4]; |
---|
| 235 | extern const Int g_quantIntraDefault8x8[8*8]; |
---|
| 236 | extern const Int g_quantInterDefault8x8[8*8]; |
---|
| 237 | extern const UInt g_scalingListSize [SCALING_LIST_SIZE_NUM]; |
---|
| 238 | extern const UInt g_scalingListSizeX[SCALING_LIST_SIZE_NUM]; |
---|
[56] | 239 | //! \} |
---|
[2] | 240 | #endif //__TCOMROM__ |
---|