source: 3DVCSoftware/branches/HTM-5.0-dev0/source/Lib/TLibCommon/TComRom.h @ 206

Last change on this file since 206 was 189, checked in by tech, 12 years ago

Reintegrated branch 4.1-dev0 Rev. 188.

  • Property svn:eol-style set to native
File size: 15.5 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-2012, 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#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
47#include "TComWedgelet.h"
48#endif
49
50//! \ingroup TLibCommon
51//! \{
52
53// ====================================================================================================================
54// Macros
55// ====================================================================================================================
56
57#define     MAX_CU_DEPTH            7                           // log2(LCUSize)
58#define     MAX_CU_SIZE             (1<<(MAX_CU_DEPTH))         // maximum allowable size of CU
59#define     MIN_PU_SIZE             4
60#define     MAX_NUM_SPU_W           (MAX_CU_SIZE/MIN_PU_SIZE)   // maximum number of SPU in horizontal line
61
62// ====================================================================================================================
63// Initialize / destroy functions
64// ====================================================================================================================
65
66Void         initROM();
67Void         destroyROM();
68Void         initFrameScanXY( UInt* pBuff, UInt* pBuffX, UInt* pBuffY, Int iWidth, Int iHeight );
69Void         initSigLastScan(UInt* pBuffZ, UInt* pBuffH, UInt* pBuffV, UInt* pBuffD, Int iWidth, Int iHeight, Int iDepth);
70Void         initNonSquareSigLastScan(UInt* pBuffZ, UInt uiWidth, UInt uiHeight);
71// ====================================================================================================================
72// Data structure related table & variable
73// ====================================================================================================================
74
75// flexible conversion from relative to absolute index
76extern       UInt   g_auiZscanToRaster[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
77extern       UInt   g_auiRasterToZscan[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
78extern       UInt   g_motionRefer[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
79
80Void         initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx );
81Void         initRasterToZscan ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth         );
82
83Void          initMotionReferIdx ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth );
84
85// conversion of partition index to picture pel position
86extern       UInt   g_auiRasterToPelX[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
87extern       UInt   g_auiRasterToPelY[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
88
89Void         initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth );
90
91// global variable (LCU width/height, max. CU depth)
92extern       UInt g_uiMaxCUWidth;
93extern       UInt g_uiMaxCUHeight;
94extern       UInt g_uiMaxCUDepth;
95extern       UInt g_uiAddCUDepth;
96
97extern       UInt g_auiPUOffset[8];
98
99#define QUANT_IQUANT_SHIFT    20 // Q(QP%6) * IQ(QP%6) = 2^20
100#define QUANT_SHIFT           14 // Q(4) = 2^14
101#define SCALE_BITS            15 // Inherited from TMuC, pressumably for fractional bit estimates in RDOQ
102#define MAX_TR_DYNAMIC_RANGE  15 // Maximum transform dynamic range (excluding sign bit)
103
104#define SHIFT_INV_1ST          7 // Shift after first inverse transform stage
105#define SHIFT_INV_2ND         12 // Shift after second inverse transform stage
106
107extern Int g_quantScales[6];             // Q(QP%6) 
108extern Int g_invQuantScales[6];          // IQ(QP%6)
109extern const short g_aiT4[4][4];
110extern const short g_aiT8[8][8];
111extern const short g_aiT16[16][16];
112extern const short g_aiT32[32][32];
113
114// ====================================================================================================================
115// Luma QP to Chroma QP mapping
116// ====================================================================================================================
117
118extern const UChar  g_aucChromaScale      [52];
119
120// ====================================================================================================================
121// Scanning order & context mapping table
122// ====================================================================================================================
123
124extern       UInt*  g_auiFrameScanXY[ MAX_CU_DEPTH  ];    // raster index     from scanning index
125extern       UInt*  g_auiFrameScanX [ MAX_CU_DEPTH  ];    // raster index (x) from scanning index
126extern       UInt*  g_auiFrameScanY [ MAX_CU_DEPTH  ];    // raster index (y) from scanning index
127extern       UInt*  g_auiSigLastScan[4][ MAX_CU_DEPTH ];  // raster index from scanning index (zigzag, hor, ver, diag)
128extern UInt *g_sigScanNSQT[ 4 ]; // scan for non-square partitions
129extern UInt g_sigCGScanNSQT[ 4 ][ 16 ]; // coarse-grain scan for non-square partitions
130
131extern       UInt*  g_auiNonSquareSigLastScan[ 4 ];      // raster index from scanning index (zigzag)
132
133extern const UInt   g_uiGroupIdx[ 32 ];
134extern const UInt   g_uiMinInGroup[ 10 ];
135extern const UInt   g_uiLastCtx[ 28 ];
136
137#if EIGHT_BITS_RICE_CODE
138extern const UInt   g_auiGoRiceRange[5];                  //!< maximum value coded with Rice codes
139extern const UInt   g_auiGoRicePrefixLen[5];              //!< prefix length for each maximum value
140extern const UInt   g_aauiGoRiceUpdate[5][24];            //!< parameter update rules for Rice codes
141#else
142extern const UInt   g_auiGoRiceRange[4];                  //!< maximum value coded with Rice codes
143extern const UInt   g_auiGoRicePrefixLen[4];              //!< prefix length for each maximum value
144extern const UInt   g_aauiGoRiceUpdate[4][16];            //!< parameter update rules for Rice codes
145#endif
146 
147#if MULTILEVEL_SIGMAP_EXT
148extern const UInt   g_sigLastScan8x8[ 4 ][ 4 ];           //!< coefficient group scan order for 8x8 TUs
149extern       UInt   g_sigLastScanCG32x32[ 64 ];
150#endif
151
152// ====================================================================================================================
153// ADI table
154// ====================================================================================================================
155
156extern const UChar  g_aucIntraModeNumFast[7];
157
158// ====================================================================================================================
159// Angular Intra table
160// ====================================================================================================================
161
162extern const UChar g_aucIntraModeNumAng[7];
163extern const UChar g_aucIntraModeBitsAng[7];
164extern const UChar g_aucAngIntraModeOrder[NUM_INTRA_MODE];
165
166// ====================================================================================================================
167// Bit-depth
168// ====================================================================================================================
169
170extern       UInt g_uiBitDepth;
171extern       UInt g_uiBitIncrement;
172extern       UInt g_uiIBDI_MAX;
173extern       UInt g_uiBASE_MAX;
174extern       UInt g_uiPCMBitDepthLuma;
175extern       UInt g_uiPCMBitDepthChroma;
176
177// ====================================================================================================================
178// Texture type to integer mapping
179// ====================================================================================================================
180
181extern const UChar g_aucConvertTxtTypeToIdx[4];
182
183// ====================================================================================================================
184// Depth model modes
185// ====================================================================================================================
186#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
187extern       Int             g_iDeltaDCsQuantOffset;
188extern const WedgeResolution g_aeWedgeResolutionList[5];
189extern const UChar           g_aucWedgeFullBitsListIdx[7];
190extern const UChar           g_aucIntraSizeIdxToWedgeSize[7];
191
192extern       std::vector< std::vector<TComWedgelet> >  g_aacWedgeLists;
193extern       std::vector< std::vector<TComWedgeRef> >  g_aacWedgeRefLists;
194
195#if HHIQC_DMMFASTSEARCH_B0039
196extern       std::vector< std::vector< std::vector<UInt> > > g_aauiWdgLstM3;
197extern       std::vector< std::vector<TComWedgeNode> >       g_aacWedgeNodeLists;
198#endif
199
200#if RWTH_SDC_DLT_B0036
201#define RWTH_SDC_NUM_PRED_MODES 4
202extern      UInt g_auiSDCPredModes[RWTH_SDC_NUM_PRED_MODES];
203#endif
204
205Void initWedgeLists();
206Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes );
207Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList );
208
209#if DEFAULT_DC
210__inline Void mapDMMtoIntraMode(  UInt& dirMode ) { dirMode = (dirMode >= NUM_INTRA_MODE) ? DC_IDX : dirMode; }
211__inline Void mapDMMtoIntraMode(   Int& dirMode ) { dirMode = (dirMode >= NUM_INTRA_MODE) ? DC_IDX : dirMode; }
212#else
213__inline Void mapDMMtoIntraMode(  UInt& dirMode ) { dirMode = (dirMode >= NUM_INTRA_MODE) ? PLANAR_IDX : dirMode; }
214__inline Void mapDMMtoIntraMode(   Int& dirMode ) { dirMode = (dirMode >= NUM_INTRA_MODE) ? PLANAR_IDX : dirMode; }
215#endif
216#endif
217
218#if LGE_EDGE_INTRA_A0070
219__inline Void mapEdgeIntratoDC( UChar& curDir ) { curDir = (curDir >= EDGE_INTRA_IDX) ? DC_IDX : curDir; }
220__inline Void mapEdgeIntratoDC(  UInt& curDir ) { curDir = (curDir >= EDGE_INTRA_IDX) ? DC_IDX : curDir; }
221__inline Void mapEdgeIntratoDC(   Int& curDir ) { curDir = (curDir >= EDGE_INTRA_IDX) ? DC_IDX : curDir; }
222#endif
223
224// ==========================================
225// Mode-Dependent DST Matrices
226extern const short g_as_DST_MAT_4 [4][4];
227#if HHI_DMM_WEDGE_INTRA || HHI_DMM_PRED_TEX
228extern const UChar g_aucDCTDSTMode_Vert[NUM_INTRA_MODE+NUM_DMM_MODE];
229extern const UChar g_aucDCTDSTMode_Hor [NUM_INTRA_MODE+NUM_DMM_MODE];
230#else
231extern const UChar g_aucDCTDSTMode_Vert[NUM_INTRA_MODE];
232extern const UChar g_aucDCTDSTMode_Hor[NUM_INTRA_MODE];
233#endif
234// ==========================================
235
236// ====================================================================================================================
237// Misc.
238// ====================================================================================================================
239
240extern       Char   g_aucConvertToBit  [ MAX_CU_SIZE+1 ];   // from width to log2(width)-2
241
242#define ENC_DEC_TRACE 0
243
244
245#if ENC_DEC_TRACE
246extern FILE*  g_hTrace;
247extern Bool   g_bJustDoIt;
248extern const Bool g_bEncDecTraceEnable;
249extern const Bool g_bEncDecTraceDisable;
250extern UInt64 g_nSymbolCounter;
251
252#define COUNTER_START    1
253#define COUNTER_END      0 //( UInt64(1) << 63 )
254
255#define DTRACE_CABAC_F(x)     if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%f", x );
256#define DTRACE_CABAC_V(x)     if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%d", x );
257#define DTRACE_CABAC_VL(x)    if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%lld", x );
258#define DTRACE_CABAC_T(x)     if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%s", x );
259#define DTRACE_CABAC_X(x)     if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "%x", x );
260#define DTRACE_CABAC_R( x,y ) if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, x,    y );
261#define DTRACE_CABAC_N        if ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) fprintf( g_hTrace, "\n"    );
262
263#else
264
265#define DTRACE_CABAC_F(x)
266#define DTRACE_CABAC_V(x)
267#define DTRACE_CABAC_VL(x)
268#define DTRACE_CABAC_T(x)
269#define DTRACE_CABAC_X(x)
270#define DTRACE_CABAC_R( x,y )
271#define DTRACE_CABAC_N
272
273#endif
274
275
276#define SCALING_LIST_NUM 6         ///< list number for quantization matrix
277#define SCALING_LIST_NUM_32x32 2   ///< list number for quantization matrix 32x32
278#define SCALING_LIST_REM_NUM 6     ///< remainder of QP/6
279#define SCALING_LIST_START_VALUE 8 ///< start value for dpcm mode
280#define MAX_MATRIX_COEF_NUM 64     ///< max coefficient number for quantization matrix
281#define MAX_MATRIX_SIZE_NUM 8      ///< max size number for quantization matrix
282#if SCALING_LIST
283#define SCALING_LIST_DC 16         ///< default DC value
284#endif
285enum ScalingListDIR
286{
287  SCALING_LIST_SQT = 0,
288  SCALING_LIST_VER,
289  SCALING_LIST_HOR,
290  SCALING_LIST_DIR_NUM
291};
292enum ScalingListSize
293{
294  SCALING_LIST_4x4 = 0,
295  SCALING_LIST_8x8,
296  SCALING_LIST_16x16,
297  SCALING_LIST_32x32,
298  SCALING_LIST_SIZE_NUM
299};
300static const char MatrixType[4][6][20] =
301{
302  {
303  "INTRA4X4_LUMA",
304  "INTRA4X4_CHROMAU",
305  "INTRA4X4_CHROMAV",
306  "INTER4X4_LUMA",
307  "INTER4X4_CHROMAU",
308  "INTER4X4_CHROMAV"
309  },
310  {
311  "INTRA8X8_LUMA",
312  "INTRA8X8_CHROMAU", 
313  "INTRA8X8_CHROMAV", 
314  "INTER8X8_LUMA",
315  "INTER8X8_CHROMAU", 
316  "INTER8X8_CHROMAV" 
317  },
318  {
319  "INTRA16X16_LUMA",
320  "INTRA16X16_CHROMAU", 
321  "INTRA16X16_CHROMAV", 
322  "INTER16X16_LUMA",
323  "INTER16X16_CHROMAU", 
324  "INTER16X16_CHROMAV" 
325  },
326  {
327  "INTRA32X32_LUMA",
328  "INTER32X32_LUMA",
329  },
330};
331#if SCALING_LIST
332static const char MatrixType_DC[4][12][22] =
333{
334  {
335  },
336  {
337  },
338  {
339  "INTRA16X16_LUMA_DC",
340  "INTRA16X16_CHROMAU_DC", 
341  "INTRA16X16_CHROMAV_DC", 
342  "INTER16X16_LUMA_DC",
343  "INTER16X16_CHROMAU_DC", 
344  "INTER16X16_CHROMAV_DC" 
345  },
346  {
347  "INTRA32X32_LUMA_DC",
348  "INTER32X32_LUMA_DC",
349  },
350};
351#endif
352extern Int g_quantIntraDefault4x4[16];
353extern Int g_quantIntraDefault8x8[64];
354extern Int g_quantIntraDefault16x16[256];
355extern Int g_quantIntraDefault32x32[1024];
356extern Int g_quantInterDefault4x4[16];
357extern Int g_quantInterDefault8x8[64];
358extern Int g_quantInterDefault16x16[256];
359extern Int g_quantInterDefault32x32[1024];
360extern UInt g_scalingListSize [SCALING_LIST_SIZE_NUM];
361extern UInt g_scalingListSizeX[SCALING_LIST_SIZE_NUM];
362extern UInt g_scalingListNum  [SCALING_LIST_SIZE_NUM];
363extern Int  g_eTTable[4];
364//! \}
365
366#endif  //__TCOMROM__
367
Note: See TracBrowser for help on using the repository browser.