source: 3DVCSoftware/trunk/source/Lib/TLibCommon/ContextTables.h @ 773

Last change on this file since 773 was 773, checked in by tech, 10 years ago

Merged branch/9.2-dev0@722.

  • Property svn:eol-style set to native
File size: 13.8 KB
RevLine 
[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
[56]4 * granted under this license. 
[5]5 *
[608]6 * Copyright (c) 2010-2013, 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
34/** \file     ContextTables.h
35    \brief    Defines constants and tables for SBAC
36    \todo     number of context models is not matched to actual use, should be fixed
37*/
38
39#ifndef __CONTEXTTABLES__
40#define __CONTEXTTABLES__
41
[56]42//! \ingroup TLibCommon
43//! \{
[608]44#define FIX827 1 ///< Fix for issue #827: CABAC init tables
45#define FIX712 1 ///< Fix for issue #712: CABAC init tables
[56]46
[2]47// ====================================================================================================================
48// Constants
49// ====================================================================================================================
50
[56]51#define MAX_NUM_CTX_MOD             512       ///< maximum number of supported contexts
52
[2]53#define NUM_SPLIT_FLAG_CTX            3       ///< number of context models for split flag
54#define NUM_SKIP_FLAG_CTX             3       ///< number of context models for skip flag
55
[56]56#define NUM_MERGE_FLAG_EXT_CTX        1       ///< number of context models for merge flag of merge extended
57#define NUM_MERGE_IDX_EXT_CTX         1       ///< number of context models for merge index of merge extended
[2]58
[56]59#define NUM_PART_SIZE_CTX             4       ///< number of context models for partition size
60#define NUM_CU_AMP_CTX                1       ///< number of context models for partition size (AMP)
61#define NUM_PRED_MODE_CTX             1       ///< number of context models for prediction mode
[2]62
[56]63#define NUM_ADI_CTX                   1       ///< number of context models for intra prediction
64
65#define NUM_CHROMA_PRED_CTX           2       ///< number of context models for intra prediction (chroma)
[608]66#define NUM_INTER_DIR_CTX             5       ///< number of context models for inter prediction direction
[56]67#define NUM_MV_RES_CTX                2       ///< number of context models for motion vector difference
[2]68
[608]69#define NUM_REF_NO_CTX                2       ///< number of context models for reference index
70#define NUM_TRANS_SUBDIV_FLAG_CTX     3       ///< number of context models for transform subdivision flags
[56]71#define NUM_QT_CBF_CTX                5       ///< number of context models for QT CBF
72#define NUM_QT_ROOT_CBF_CTX           1       ///< number of context models for QT ROOT CBF
73#define NUM_DELTA_QP_CTX              3       ///< number of context models for dQP
[2]74
[56]75#define NUM_SIG_CG_FLAG_CTX           2       ///< number of context models for MULTI_LEVEL_SIGNIFICANCE
76
[608]77#define NUM_SIG_FLAG_CTX              42      ///< number of context models for sig flag
78#define NUM_SIG_FLAG_CTX_LUMA         27      ///< number of context models for luma sig flag
79#define NUM_SIG_FLAG_CTX_CHROMA       15      ///< number of context models for chroma sig flag
[56]80
81#define NUM_CTX_LAST_FLAG_XY          15      ///< number of context models for last coefficient position
[2]82
[56]83#define NUM_ONE_FLAG_CTX              24      ///< number of context models for greater than 1 flag
84#define NUM_ONE_FLAG_CTX_LUMA         16      ///< number of context models for greater than 1 flag of luma
85#define NUM_ONE_FLAG_CTX_CHROMA        8      ///< number of context models for greater than 1 flag of chroma
86#define NUM_ABS_FLAG_CTX               6      ///< number of context models for greater than 2 flag
87#define NUM_ABS_FLAG_CTX_LUMA          4      ///< number of context models for greater than 2 flag of luma
88#define NUM_ABS_FLAG_CTX_CHROMA        2      ///< number of context models for greater than 2 flag of chroma
89
[2]90#define NUM_MVP_IDX_CTX               2       ///< number of context models for MVP index
91
[443]92#define NUM_SAO_MERGE_FLAG_CTX        1       ///< number of context models for SAO merge flags
93#define NUM_SAO_TYPE_IDX_CTX          1       ///< number of context models for SAO type index
[608]94
95#define NUM_TRANSFORMSKIP_FLAG_CTX    1       ///< number of context models for transform skipping
96#define NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX  1
97
98#if H_3D_ARP
99#define NUM_ARPW_CTX                  4       ///< number of context models for weighting factor index used by advanced residual prediction
[443]100#endif
[608]101
102#if H_3D_IC
103#define NUM_IC_FLAG_CTX               3       ///< number of context models for illumination compensation flag
104#endif
105
[56]106#define CNU                          154      ///< dummy initialization value for unused context models 'Context model Not Used'
[2]107
[608]108#if H_3D_DIM
109#define NUM_DEPTH_INTRA_MODE_CTX      8       ///< number of context models for depth intra modes
110#define NUM_DDC_FLAG_CTX              2       ///< number of context models for deltaDC flag (DMM or RBC)
[724]111#define NUM_DDC_DATA_CTX              1       ///< number of context models for deltaDC data (DMM or RBC)
[608]112#if H_3D_DIM_DMM
113#define NUM_DMM1_DATA_CTX             1       ///< number of context models for DMM1 data
[296]114#endif
[724]115#endif
[100]116
[608]117#if H_3D_DIM_SDC
[189]118#define SDC_NUM_RESIDUAL_FLAG_CTX        1
[443]119#define SDC_NUM_RESIDUAL_CTX             1
120#endif
[189]121
[655]122#if H_3D_INTER_SDC
[608]123#define NUM_INTER_SDC_FLAG_CTX        1      ///< number of context models for inter SDC flag
124#define NUM_INTER_SDC_SIGN_FLAG_CTX   1      ///< number of context models for sign of inter SDC residual
125#define NUM_INTER_SDC_RESIDUAL_CTX    1      ///< number of context models for abs of inter SDC residual
[189]126#endif
[2]127// ====================================================================================================================
128// Tables
129// ====================================================================================================================
130
[608]131// initial probability for cu_transquant_bypass flag
132static const UChar
133INIT_CU_TRANSQUANT_BYPASS_FLAG[3][NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX] =
134{
135  { 154 }, 
136  { 154 }, 
137  { 154 }, 
138};
139
[56]140// initial probability for split flag
141static const UChar
142INIT_SPLIT_FLAG[3][NUM_SPLIT_FLAG_CTX] = 
[2]143{
[608]144  { 107,  139,  126, },
145  { 107,  139,  126, }, 
[56]146  { 139,  141,  157, }, 
[2]147};
148
[56]149static const UChar
150INIT_SKIP_FLAG[3][NUM_SKIP_FLAG_CTX] = 
[2]151{
[56]152  { 197,  185,  201, }, 
153  { 197,  185,  201, }, 
[189]154  { CNU,  CNU,  CNU, }, 
155};
156
[608]157static const UChar
[56]158INIT_MERGE_FLAG_EXT[3][NUM_MERGE_FLAG_EXT_CTX] = 
159{
[608]160  { 154, }, 
161  { 110, }, 
[56]162  { CNU, }, 
163};
[2]164
[56]165static const UChar
166INIT_MERGE_IDX_EXT[3][NUM_MERGE_IDX_EXT_CTX] = 
[2]167{
[608]168  { 137, }, 
169  { 122, }, 
[56]170  { CNU, }, 
171};
172
173static const UChar
174INIT_PART_SIZE[3][NUM_PART_SIZE_CTX] = 
175{
176  { 154,  139,  CNU,  CNU, }, 
177  { 154,  139,  CNU,  CNU, }, 
[608]178  { 184,  CNU,  CNU,  CNU, }, 
[56]179};
180
181static const UChar
182INIT_CU_AMP_POS[3][NUM_CU_AMP_CTX] = 
183{
184  { 154, }, 
185  { 154, }, 
[608]186  { CNU, }, 
[56]187};
188
189static const UChar
190INIT_PRED_MODE[3][NUM_PRED_MODE_CTX] = 
191{
[608]192  { 134, }, 
193  { 149, }, 
[56]194  { CNU, }, 
195};
196
197static const UChar
198INIT_INTRA_PRED_MODE[3][NUM_ADI_CTX] = 
199{
[608]200  { 183, }, 
201  { 154, }, 
[56]202  { 184, }, 
203};
204
205static const UChar
206INIT_CHROMA_PRED_MODE[3][NUM_CHROMA_PRED_CTX] = 
207{
208  { 152,  139, }, 
209  { 152,  139, }, 
[608]210  {  63,  139, }, 
[56]211};
212
213static const UChar
214INIT_INTER_DIR[3][NUM_INTER_DIR_CTX] = 
215{
[608]216  {  95,   79,   63,   31,  31, }, 
217  {  95,   79,   63,   31,  31, }, 
218  { CNU,  CNU,  CNU,  CNU, CNU, }, 
[56]219};
220
221static const UChar
222INIT_MVD[3][NUM_MV_RES_CTX] = 
223{
[608]224  { 169,  198, }, 
225  { 140,  198, }, 
[56]226  { CNU,  CNU, }, 
227};
228
229static const UChar
230INIT_REF_PIC[3][NUM_REF_NO_CTX] = 
231{
[608]232  { 153,  153 }, 
233  { 153,  153 }, 
234  { CNU,  CNU }, 
[56]235};
236
237static const UChar
238INIT_DQP[3][NUM_DELTA_QP_CTX] = 
239{
240  { 154,  154,  154, }, 
241  { 154,  154,  154, }, 
242  { 154,  154,  154, }, 
243};
244
245static const UChar
246INIT_QT_CBF[3][2*NUM_QT_CBF_CTX] = 
247{
[608]248  { 153,  111,  CNU,  CNU,  CNU,  149,   92,  167,  CNU,  CNU, }, 
249  { 153,  111,  CNU,  CNU,  CNU,  149,  107,  167,  CNU,  CNU, }, 
[56]250  { 111,  141,  CNU,  CNU,  CNU,   94,  138,  182,  CNU,  CNU, }, 
251};
252
253static const UChar
254INIT_QT_ROOT_CBF[3][NUM_QT_ROOT_CBF_CTX] = 
255{
256  {  79, }, 
257  {  79, }, 
[608]258  { CNU, }, 
[56]259};
260
261static const UChar
262INIT_LAST[3][2*NUM_CTX_LAST_FLAG_XY] = 
263{
[608]264  { 125,  110,  124,  110,   95,   94,  125,  111,  111,   79,  125,  126,  111,  111,   79,
265    108,  123,   93,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU, 
[56]266  }, 
[608]267  { 125,  110,   94,  110,   95,   79,  125,  111,  110,   78,  110,  111,  111,   95,   94,
[56]268    108,  123,  108,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,
269  }, 
[608]270  { 110,  110,  124,  125,  140,  153,  125,  127,  140,  109,  111,  143,  127,  111,   79, 
271    108,  123,   63,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU, 
[56]272  }, 
273};
274
275static const UChar
276INIT_SIG_CG_FLAG[3][2 * NUM_SIG_CG_FLAG_CTX] = 
277{
[608]278  { 121,  140, 
279    61,  154, 
[56]280  }, 
281  { 121,  140, 
282    61,  154, 
283  }, 
[608]284  {  91,  171, 
285    134,  141, 
[56]286  }, 
287};
288
289static const UChar
290INIT_SIG_FLAG[3][NUM_SIG_FLAG_CTX] = 
291{
[608]292  { 170,  154,  139,  153,  139,  123,  123,   63,  124,  166,  183,  140,  136,  153,  154,  166,  183,  140,  136,  153,  154,  166,  183,  140,  136,  153,  154,  170,  153,  138,  138,  122,  121,  122,  121,  167,  151,  183,  140,  151,  183,  140,  }, 
293  { 155,  154,  139,  153,  139,  123,  123,   63,  153,  166,  183,  140,  136,  153,  154,  166,  183,  140,  136,  153,  154,  166,  183,  140,  136,  153,  154,  170,  153,  123,  123,  107,  121,  107,  121,  167,  151,  183,  140,  151,  183,  140,  }, 
294  { 111,  111,  125,  110,  110,   94,  124,  108,  124,  107,  125,  141,  179,  153,  125,  107,  125,  141,  179,  153,  125,  107,  125,  141,  179,  153,  125,  140,  139,  182,  182,  152,  136,  152,  136,  153,  136,  139,  111,  136,  139,  111,  }, 
[56]295};
296
297static const UChar
298INIT_ONE_FLAG[3][NUM_ONE_FLAG_CTX] = 
299{
[608]300  { 154,  196,  167,  167,  154,  152,  167,  182,  182,  134,  149,  136,  153,  121,  136,  122,  169,  208,  166,  167,  154,  152,  167,  182, }, 
301  { 154,  196,  196,  167,  154,  152,  167,  182,  182,  134,  149,  136,  153,  121,  136,  137,  169,  194,  166,  167,  154,  167,  137,  182, }, 
[56]302  { 140,   92,  137,  138,  140,  152,  138,  139,  153,   74,  149,   92,  139,  107,  122,  152,  140,  179,  166,  182,  140,  227,  122,  197, }, 
303};
304
305static const UChar
306INIT_ABS_FLAG[3][NUM_ABS_FLAG_CTX] = 
307{
[608]308  { 107,  167,   91,  107,  107,  167, }, 
309  { 107,  167,   91,  122,  107,  167, }, 
[56]310  { 138,  153,  136,  167,  152,  152, }, 
311};
312
313static const UChar
314INIT_MVP_IDX[3][NUM_MVP_IDX_CTX] = 
315{
316  { 168,  CNU, }, 
317  { 168,  CNU, }, 
[608]318  { CNU,  CNU, }, 
[56]319};
320
321static const UChar
[608]322INIT_SAO_MERGE_FLAG[3][NUM_SAO_MERGE_FLAG_CTX] = 
[56]323{
[608]324  { 153,  }, 
325  { 153,  }, 
326  { 153,  }, 
[56]327};
328
329static const UChar
[608]330INIT_SAO_TYPE_IDX[3][NUM_SAO_TYPE_IDX_CTX] = 
[56]331{
[608]332#if FIX827
333  { 160, },
334  { 185, },
335  { 200, },
336#else
337  { 200, },
338  { 185, }, 
339  { 160, },
340#endif
[56]341};
342
[443]343static const UChar
[608]344INIT_TRANS_SUBDIV_FLAG[3][NUM_TRANS_SUBDIV_FLAG_CTX] =
[443]345{
[608]346#if FIX712
347  { 224,  167,  122, },
348  { 124,  138,   94, },
349  { 153,  138,  138, },
[443]350#else
[608]351  { 153,  138,  138, },
352  { 124,  138,   94, },
353  { 224,  167,  122, },
354#endif
[56]355};
356
[608]357static const UChar
358INIT_TRANSFORMSKIP_FLAG[3][2*NUM_TRANSFORMSKIP_FLAG_CTX] = 
[56]359{
[608]360  { 139,  139}, 
361  { 139,  139}, 
362  { 139,  139}, 
[56]363};
364
[608]365#if H_3D_ARP
[56]366static const UChar
[608]367INIT_ARPW[3][NUM_ARPW_CTX] = 
[56]368{
[724]369    { 162, 153, 154, 162 },
370    { 162, 153, 154, 162 },
371    { 162, 153, 154, 162 },
[56]372};
[608]373#endif
[56]374
[608]375#if H_3D_IC
[56]376static const UChar
[608]377INIT_IC_FLAG[3][NUM_IC_FLAG_CTX] = 
[56]378{
[724]379    { 154,  154,  154, },
380    { 154,  154,  154, },
381    { 154,  154,  154, },
[56]382};
[608]383#endif
384#if H_3D_DIM
385static const UChar
386INIT_DEPTH_INTRA_MODE[3][NUM_DEPTH_INTRA_MODE_CTX] =
[56]387{
[608]388    {0,  0,  64, 168, 168, 124, CNU, 0},
389    {0, 64,   0, 183, CNU, 108,   0, 0},
390    {64, 0, CNU, CNU, 168, 109,   0, 0}
[56]391};
[655]392
[56]393static const UChar
[608]394INIT_DDC_FLAG[3][NUM_DDC_FLAG_CTX] =
[56]395{
[608]396  {0 , CNU},
397  {0 , CNU},
398  {64, CNU}
[56]399};
400static const UChar
[608]401INIT_DDC_DATA[3][NUM_DDC_DATA_CTX] = 
[2]402{
[724]403  { 154 }, 
404  { 154 }, 
405  { 154 }, 
[2]406};
[608]407#if H_3D_DIM_DMM
[56]408static const UChar
[608]409INIT_DMM1_DATA[3][NUM_DMM1_DATA_CTX] = 
[56]410{
[608]411  { CNU }, 
412  { CNU }, 
413  { CNU }, 
[2]414};
415#endif
[608]416#if H_3D_DIM_SDC
417static const UChar
418INIT_SDC_RESIDUAL_FLAG[3][SDC_NUM_RESIDUAL_FLAG_CTX] =
[443]419{
[608]420  { CNU },
421  { CNU },
422  { CNU },
[443]423};
[608]424static const UChar
425INIT_SDC_RESIDUAL[3][SDC_NUM_RESIDUAL_CTX] =
[443]426{
[608]427  { 155 },
428  { 155 },
429  { 155 },
[443]430};
431#endif
[608]432#endif
[443]433
[655]434#if H_3D_INTER_SDC
[608]435static const UChar
436INIT_INTER_SDC_FLAG[3][NUM_INTER_SDC_FLAG_CTX] =
[443]437{
[608]438  { CNU }, 
439  { 154 },
440  { 154 },
[443]441};
[189]442
[608]443static const UChar
444INIT_INTER_SDC_SIGN_FLAG[3][NUM_INTER_SDC_SIGN_FLAG_CTX] =
[189]445{
[608]446  { CNU }, 
447  { 154 },
448  { 154 },
[189]449};
450
[608]451static const UChar
452INIT_INTER_SDC_RESIDUAL[3][NUM_INTER_SDC_RESIDUAL_CTX] =
[189]453{
[608]454  { CNU }, 
455  { 154 },
456  { 154 },
[189]457};
458#endif
[56]459//! \}
460
[608]461
[2]462#endif
Note: See TracBrowser for help on using the repository browser.