source: 3DVCSoftware/branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/TComRom.h @ 521

Last change on this file since 521 was 521, checked in by tech, 11 years ago

Integrated following changes:

  • H_MV_FIX1071, fix of encoder side reference list construction on IRAP pictures, same as in HM11.
  • H_3D_VSO_FIX_BORDRE_EXTENSION, fixed uninitialized borders for org-yuvs in VSO
  • H_MV_ENC_DEC_TRAC, added cu/pu level trace ( only enabled when ENC_DEC_TRACE is enabled)
  • Property svn:eol-style set to native
File size: 12.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-2013, 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#include "TypeDef.h"
43
44#include<stdio.h>
45#include<iostream>
46
47//! \ingroup TLibCommon
48//! \{
49
50// ====================================================================================================================
51// Macros
52// ====================================================================================================================
53
54#define     MAX_CU_DEPTH            7                           // log2(LCUSize)
55#define     MAX_CU_SIZE             (1<<(MAX_CU_DEPTH))         // maximum allowable size of CU
56#define     MIN_PU_SIZE             4
57#define     MAX_NUM_SPU_W           (MAX_CU_SIZE/MIN_PU_SIZE)   // maximum number of SPU in horizontal line
58
59// ====================================================================================================================
60// Initialize / destroy functions
61// ====================================================================================================================
62
63Void         initROM();
64Void         destroyROM();
65Void         initSigLastScan(UInt* pBuffD, UInt* pBuffH, UInt* pBuffV, Int iWidth, Int iHeight);
66// ====================================================================================================================
67// Data structure related table & variable
68// ====================================================================================================================
69
70// flexible conversion from relative to absolute index
71extern       UInt   g_auiZscanToRaster[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
72extern       UInt   g_auiRasterToZscan[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
73
74Void         initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx );
75Void         initRasterToZscan ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth         );
76
77// conversion of partition index to picture pel position
78extern       UInt   g_auiRasterToPelX[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
79extern       UInt   g_auiRasterToPelY[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
80
81Void         initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth );
82
83// global variable (LCU width/height, max. CU depth)
84extern       UInt g_uiMaxCUWidth;
85extern       UInt g_uiMaxCUHeight;
86extern       UInt g_uiMaxCUDepth;
87extern       UInt g_uiAddCUDepth;
88
89#define MAX_TS_WIDTH  4
90#define MAX_TS_HEIGHT 4
91
92extern       UInt g_auiPUOffset[8];
93
94#define QUANT_IQUANT_SHIFT    20 // Q(QP%6) * IQ(QP%6) = 2^20
95#define QUANT_SHIFT           14 // Q(4) = 2^14
96#define SCALE_BITS            15 // Inherited from TMuC, pressumably for fractional bit estimates in RDOQ
97#define MAX_TR_DYNAMIC_RANGE  15 // Maximum transform dynamic range (excluding sign bit)
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 Int g_quantScales[6];             // Q(QP%6) 
103extern Int g_invQuantScales[6];          // IQ(QP%6)
104extern const Short g_aiT4[4][4];
105extern const Short g_aiT8[8][8];
106extern const Short g_aiT16[16][16];
107extern const Short g_aiT32[32][32];
108
109// ====================================================================================================================
110// Luma QP to Chroma QP mapping
111// ====================================================================================================================
112
113extern const UChar  g_aucChromaScale      [58];
114
115// ====================================================================================================================
116// Scanning order & context mapping table
117// ====================================================================================================================
118
119extern       UInt*  g_auiSigLastScan[ 3 ][ MAX_CU_DEPTH ];  // raster index from scanning index (diag, hor, ver)
120
121extern const UInt   g_uiGroupIdx[ 32 ];
122extern const UInt   g_uiMinInGroup[ 10 ];
123
124extern const UInt   g_auiGoRiceRange[5];                  //!< maximum value coded with Rice codes
125extern const UInt   g_auiGoRicePrefixLen[5];              //!< prefix length for each maximum value
126 
127extern const UInt   g_sigLastScan8x8[ 3 ][ 4 ];           //!< coefficient group scan order for 8x8 TUs
128extern       UInt   g_sigLastScanCG32x32[ 64 ];
129
130// ====================================================================================================================
131// ADI table
132// ====================================================================================================================
133
134extern const UChar  g_aucIntraModeNumFast[7];
135
136// ====================================================================================================================
137// Bit-depth
138// ====================================================================================================================
139
140extern        Int g_bitDepthY;
141extern        Int g_bitDepthC;
142extern       UInt g_uiPCMBitDepthLuma;
143extern       UInt g_uiPCMBitDepthChroma;
144
145// ====================================================================================================================
146// Texture type to integer mapping
147// ====================================================================================================================
148
149extern const UChar g_aucConvertTxtTypeToIdx[4];
150
151// ==========================================
152// Mode-Dependent DST Matrices
153extern const Short g_as_DST_MAT_4 [4][4];
154extern const UChar g_aucDCTDSTMode_Vert[NUM_INTRA_MODE];
155extern const UChar g_aucDCTDSTMode_Hor[NUM_INTRA_MODE];
156// ==========================================
157
158// ====================================================================================================================
159// Misc.
160// ====================================================================================================================
161
162extern       Char   g_aucConvertToBit  [ MAX_CU_SIZE+1 ];   // from width to log2(width)-2
163
164#ifndef ENC_DEC_TRACE
165# define ENC_DEC_TRACE 0
166#endif
167
168#if ENC_DEC_TRACE
169extern FILE*  g_hTrace;
170extern Bool   g_bJustDoIt;
171extern const Bool g_bEncDecTraceEnable;
172extern const Bool g_bEncDecTraceDisable;
173extern Bool   g_HLSTraceEnable;
174extern UInt64 g_nSymbolCounter;
175
176#define COUNTER_START    1
177#define COUNTER_END      0 //( UInt64(1) << 63 )
178
179#define DTRACE_CABAC_F(x)     if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%f", x );
180#define DTRACE_CABAC_V(x)     if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%d", x );
181#define DTRACE_CABAC_VL(x)    if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%lld", x );
182#define DTRACE_CABAC_T(x)     if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%s", x );
183#define DTRACE_CABAC_X(x)     if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%x", x );
184#define DTRACE_CABAC_R( x,y ) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, x,    y );
185#define DTRACE_CABAC_N        if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "\n"    );
186
187#if H_MV_ENC_DEC_TRAC
188 extern Bool   g_traceCU; 
189 extern Bool   g_tracePU; 
190 extern Bool   g_traceTU; 
191 extern Bool   g_disableHLSTrace; 
192 extern UInt64 g_stopAtCounter; 
193
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
201
202 Void           writeToTraceFile( Char* symbolName, Int val, Bool doIt );
203 Void           writeToTraceFile( Char* symbolName, Bool doIt );
204#endif
205#else
206
207#define DTRACE_CABAC_F(x)
208#define DTRACE_CABAC_V(x)
209#define DTRACE_CABAC_VL(x)
210#define DTRACE_CABAC_T(x)
211#define DTRACE_CABAC_X(x)
212#define DTRACE_CABAC_R( x,y )
213#define DTRACE_CABAC_N
214
215#if H_MV_ENC_DEC_TRAC
216#define DTRACE_CU(x,y)             
217#define DTRACE_PU(x,y)             
218#define DTRACE_TU(x,y)             
219
220#define DTRACE_CU_S(x)             
221#define DTRACE_PU_S(x)             
222#define DTRACE_TU_S(x)             
223
224#endif
225#endif
226
227
228#define SCALING_LIST_NUM 6         ///< list number for quantization matrix
229#define SCALING_LIST_NUM_32x32 2   ///< list number for quantization matrix 32x32
230#define SCALING_LIST_REM_NUM 6     ///< remainder of QP/6
231#define SCALING_LIST_START_VALUE 8 ///< start value for dpcm mode
232#define MAX_MATRIX_COEF_NUM 64     ///< max coefficient number for quantization matrix
233#define MAX_MATRIX_SIZE_NUM 8      ///< max size number for quantization matrix
234#define SCALING_LIST_DC 16         ///< default DC value
235enum ScalingListSize
236{
237  SCALING_LIST_4x4 = 0,
238  SCALING_LIST_8x8,
239  SCALING_LIST_16x16,
240  SCALING_LIST_32x32,
241  SCALING_LIST_SIZE_NUM
242};
243static const Char MatrixType[4][6][20] =
244{
245  {
246  "INTRA4X4_LUMA",
247  "INTRA4X4_CHROMAU",
248  "INTRA4X4_CHROMAV",
249  "INTER4X4_LUMA",
250  "INTER4X4_CHROMAU",
251  "INTER4X4_CHROMAV"
252  },
253  {
254  "INTRA8X8_LUMA",
255  "INTRA8X8_CHROMAU", 
256  "INTRA8X8_CHROMAV", 
257  "INTER8X8_LUMA",
258  "INTER8X8_CHROMAU", 
259  "INTER8X8_CHROMAV" 
260  },
261  {
262  "INTRA16X16_LUMA",
263  "INTRA16X16_CHROMAU", 
264  "INTRA16X16_CHROMAV", 
265  "INTER16X16_LUMA",
266  "INTER16X16_CHROMAU", 
267  "INTER16X16_CHROMAV" 
268  },
269  {
270  "INTRA32X32_LUMA",
271  "INTER32X32_LUMA",
272  },
273};
274static const Char MatrixType_DC[4][12][22] =
275{
276  {
277  },
278  {
279  },
280  {
281  "INTRA16X16_LUMA_DC",
282  "INTRA16X16_CHROMAU_DC", 
283  "INTRA16X16_CHROMAV_DC", 
284  "INTER16X16_LUMA_DC",
285  "INTER16X16_CHROMAU_DC", 
286  "INTER16X16_CHROMAV_DC" 
287  },
288  {
289  "INTRA32X32_LUMA_DC",
290  "INTER32X32_LUMA_DC",
291  },
292};
293extern Int g_quantIntraDefault8x8[64];
294extern Int g_quantIntraDefault16x16[256];
295extern Int g_quantIntraDefault32x32[1024];
296extern Int g_quantInterDefault8x8[64];
297extern Int g_quantInterDefault16x16[256];
298extern Int g_quantInterDefault32x32[1024];
299extern Int g_quantTSDefault4x4[16];
300extern UInt g_scalingListSize [SCALING_LIST_SIZE_NUM];
301extern UInt g_scalingListSizeX[SCALING_LIST_SIZE_NUM];
302extern UInt g_scalingListNum  [SCALING_LIST_SIZE_NUM];
303extern Int  g_eTTable[4];
304//! \}
305
306#endif  //__TCOMROM__
307
Note: See TracBrowser for help on using the repository browser.