source: 3DVCSoftware/branches/HTM-15.0-dev0/source/Lib/TLibCommon/TComRom.h @ 1317

Last change on this file since 1317 was 1317, checked in by tech, 9 years ago

Clean-ups. HLS.

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