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

Last change on this file since 372 was 370, checked in by seregin, 11 years ago

remove SIMPLIFIED_MV_POS_SCALING macro

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