source: 3DVCSoftware/branches/HTM-10.0-dev0/source/Lib/TLibCommon/ContextTables.h

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

Update HM-12.0 -> HM-13.0.

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