source: 3DVCSoftware/branches/HTM-9.3-dev3-Qualcomm/source/Lib/TLibCommon/ContextTables.h @ 1417

Last change on this file since 1417 was 782, checked in by qualcomm, 11 years ago

integration of JCT3V-G0130 (unify signaling and delta DC coding in intra SDC and inter SDC) by Qualcomm

  • Property svn:eol-style set to native
File size: 14.9 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
[781]109#if QC_GENERIC_SDC_G0122
110#define NUM_DEPTH_INTRA_MODE_CTX      1       ///< number of context models for depth intra modes
111#else
[608]112#define NUM_DEPTH_INTRA_MODE_CTX      8       ///< number of context models for depth intra modes
[781]113#endif
[608]114#define NUM_DDC_FLAG_CTX              2       ///< number of context models for deltaDC flag (DMM or RBC)
[724]115#define NUM_DDC_DATA_CTX              1       ///< number of context models for deltaDC data (DMM or RBC)
[608]116#if H_3D_DIM_DMM
117#define NUM_DMM1_DATA_CTX             1       ///< number of context models for DMM1 data
[296]118#endif
[781]119#if QC_GENERIC_SDC_G0122
120#define NUM_ANGLE_FLAG_CTX            3
[782]121#if !QC_SDC_UNIFY_G0130
[781]122#define NUM_INTRASDC_FLAG_CTX         3
[724]123#endif
[781]124#endif
[782]125#endif
[100]126
[608]127#if H_3D_DIM_SDC
[189]128#define SDC_NUM_RESIDUAL_FLAG_CTX        1
[443]129#define SDC_NUM_RESIDUAL_CTX             1
130#endif
[189]131
[782]132#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
[608]133#define NUM_INTER_SDC_FLAG_CTX        1      ///< number of context models for inter SDC flag
134#define NUM_INTER_SDC_SIGN_FLAG_CTX   1      ///< number of context models for sign of inter SDC residual
135#define NUM_INTER_SDC_RESIDUAL_CTX    1      ///< number of context models for abs of inter SDC residual
[189]136#endif
[782]137#if QC_SDC_UNIFY_G0130
138#define NUM_SDC_FLAG_CTX              1      ///< number of context models for inter SDC flag
139#endif
[2]140// ====================================================================================================================
141// Tables
142// ====================================================================================================================
143
[608]144// initial probability for cu_transquant_bypass flag
145static const UChar
146INIT_CU_TRANSQUANT_BYPASS_FLAG[3][NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX] =
147{
148  { 154 }, 
149  { 154 }, 
150  { 154 }, 
151};
152
[56]153// initial probability for split flag
154static const UChar
155INIT_SPLIT_FLAG[3][NUM_SPLIT_FLAG_CTX] = 
[2]156{
[608]157  { 107,  139,  126, },
158  { 107,  139,  126, }, 
[56]159  { 139,  141,  157, }, 
[2]160};
161
[56]162static const UChar
163INIT_SKIP_FLAG[3][NUM_SKIP_FLAG_CTX] = 
[2]164{
[56]165  { 197,  185,  201, }, 
166  { 197,  185,  201, }, 
[189]167  { CNU,  CNU,  CNU, }, 
168};
169
[608]170static const UChar
[56]171INIT_MERGE_FLAG_EXT[3][NUM_MERGE_FLAG_EXT_CTX] = 
172{
[608]173  { 154, }, 
174  { 110, }, 
[56]175  { CNU, }, 
176};
[2]177
[56]178static const UChar
179INIT_MERGE_IDX_EXT[3][NUM_MERGE_IDX_EXT_CTX] = 
[2]180{
[608]181  { 137, }, 
182  { 122, }, 
[56]183  { CNU, }, 
184};
185
186static const UChar
187INIT_PART_SIZE[3][NUM_PART_SIZE_CTX] = 
188{
189  { 154,  139,  CNU,  CNU, }, 
190  { 154,  139,  CNU,  CNU, }, 
[608]191  { 184,  CNU,  CNU,  CNU, }, 
[56]192};
193
194static const UChar
195INIT_CU_AMP_POS[3][NUM_CU_AMP_CTX] = 
196{
197  { 154, }, 
198  { 154, }, 
[608]199  { CNU, }, 
[56]200};
201
202static const UChar
203INIT_PRED_MODE[3][NUM_PRED_MODE_CTX] = 
204{
[608]205  { 134, }, 
206  { 149, }, 
[56]207  { CNU, }, 
208};
209
210static const UChar
211INIT_INTRA_PRED_MODE[3][NUM_ADI_CTX] = 
212{
[608]213  { 183, }, 
214  { 154, }, 
[56]215  { 184, }, 
216};
217
218static const UChar
219INIT_CHROMA_PRED_MODE[3][NUM_CHROMA_PRED_CTX] = 
220{
221  { 152,  139, }, 
222  { 152,  139, }, 
[608]223  {  63,  139, }, 
[56]224};
225
226static const UChar
227INIT_INTER_DIR[3][NUM_INTER_DIR_CTX] = 
228{
[608]229  {  95,   79,   63,   31,  31, }, 
230  {  95,   79,   63,   31,  31, }, 
231  { CNU,  CNU,  CNU,  CNU, CNU, }, 
[56]232};
233
234static const UChar
235INIT_MVD[3][NUM_MV_RES_CTX] = 
236{
[608]237  { 169,  198, }, 
238  { 140,  198, }, 
[56]239  { CNU,  CNU, }, 
240};
241
242static const UChar
243INIT_REF_PIC[3][NUM_REF_NO_CTX] = 
244{
[608]245  { 153,  153 }, 
246  { 153,  153 }, 
247  { CNU,  CNU }, 
[56]248};
249
250static const UChar
251INIT_DQP[3][NUM_DELTA_QP_CTX] = 
252{
253  { 154,  154,  154, }, 
254  { 154,  154,  154, }, 
255  { 154,  154,  154, }, 
256};
257
258static const UChar
259INIT_QT_CBF[3][2*NUM_QT_CBF_CTX] = 
260{
[608]261  { 153,  111,  CNU,  CNU,  CNU,  149,   92,  167,  CNU,  CNU, }, 
262  { 153,  111,  CNU,  CNU,  CNU,  149,  107,  167,  CNU,  CNU, }, 
[56]263  { 111,  141,  CNU,  CNU,  CNU,   94,  138,  182,  CNU,  CNU, }, 
264};
265
266static const UChar
267INIT_QT_ROOT_CBF[3][NUM_QT_ROOT_CBF_CTX] = 
268{
269  {  79, }, 
270  {  79, }, 
[608]271  { CNU, }, 
[56]272};
273
274static const UChar
275INIT_LAST[3][2*NUM_CTX_LAST_FLAG_XY] = 
276{
[608]277  { 125,  110,  124,  110,   95,   94,  125,  111,  111,   79,  125,  126,  111,  111,   79,
278    108,  123,   93,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU, 
[56]279  }, 
[608]280  { 125,  110,   94,  110,   95,   79,  125,  111,  110,   78,  110,  111,  111,   95,   94,
[56]281    108,  123,  108,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,
282  }, 
[608]283  { 110,  110,  124,  125,  140,  153,  125,  127,  140,  109,  111,  143,  127,  111,   79, 
284    108,  123,   63,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU, 
[56]285  }, 
286};
287
288static const UChar
289INIT_SIG_CG_FLAG[3][2 * NUM_SIG_CG_FLAG_CTX] = 
290{
[608]291  { 121,  140, 
292    61,  154, 
[56]293  }, 
294  { 121,  140, 
295    61,  154, 
296  }, 
[608]297  {  91,  171, 
298    134,  141, 
[56]299  }, 
300};
301
302static const UChar
303INIT_SIG_FLAG[3][NUM_SIG_FLAG_CTX] = 
304{
[608]305  { 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,  }, 
306  { 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,  }, 
307  { 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]308};
309
310static const UChar
311INIT_ONE_FLAG[3][NUM_ONE_FLAG_CTX] = 
312{
[608]313  { 154,  196,  167,  167,  154,  152,  167,  182,  182,  134,  149,  136,  153,  121,  136,  122,  169,  208,  166,  167,  154,  152,  167,  182, }, 
314  { 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]315  { 140,   92,  137,  138,  140,  152,  138,  139,  153,   74,  149,   92,  139,  107,  122,  152,  140,  179,  166,  182,  140,  227,  122,  197, }, 
316};
317
318static const UChar
319INIT_ABS_FLAG[3][NUM_ABS_FLAG_CTX] = 
320{
[608]321  { 107,  167,   91,  107,  107,  167, }, 
322  { 107,  167,   91,  122,  107,  167, }, 
[56]323  { 138,  153,  136,  167,  152,  152, }, 
324};
325
326static const UChar
327INIT_MVP_IDX[3][NUM_MVP_IDX_CTX] = 
328{
329  { 168,  CNU, }, 
330  { 168,  CNU, }, 
[608]331  { CNU,  CNU, }, 
[56]332};
333
334static const UChar
[608]335INIT_SAO_MERGE_FLAG[3][NUM_SAO_MERGE_FLAG_CTX] = 
[56]336{
[608]337  { 153,  }, 
338  { 153,  }, 
339  { 153,  }, 
[56]340};
341
342static const UChar
[608]343INIT_SAO_TYPE_IDX[3][NUM_SAO_TYPE_IDX_CTX] = 
[56]344{
[608]345#if FIX827
346  { 160, },
347  { 185, },
348  { 200, },
349#else
350  { 200, },
351  { 185, }, 
352  { 160, },
353#endif
[56]354};
355
[443]356static const UChar
[608]357INIT_TRANS_SUBDIV_FLAG[3][NUM_TRANS_SUBDIV_FLAG_CTX] =
[443]358{
[608]359#if FIX712
360  { 224,  167,  122, },
361  { 124,  138,   94, },
362  { 153,  138,  138, },
[443]363#else
[608]364  { 153,  138,  138, },
365  { 124,  138,   94, },
366  { 224,  167,  122, },
367#endif
[56]368};
369
[608]370static const UChar
371INIT_TRANSFORMSKIP_FLAG[3][2*NUM_TRANSFORMSKIP_FLAG_CTX] = 
[56]372{
[608]373  { 139,  139}, 
374  { 139,  139}, 
375  { 139,  139}, 
[56]376};
377
[608]378#if H_3D_ARP
[56]379static const UChar
[608]380INIT_ARPW[3][NUM_ARPW_CTX] = 
[56]381{
[724]382    { 162, 153, 154, 162 },
383    { 162, 153, 154, 162 },
384    { 162, 153, 154, 162 },
[56]385};
[608]386#endif
[56]387
[608]388#if H_3D_IC
[56]389static const UChar
[608]390INIT_IC_FLAG[3][NUM_IC_FLAG_CTX] = 
[56]391{
[724]392    { 154,  154,  154, },
393    { 154,  154,  154, },
394    { 154,  154,  154, },
[56]395};
[608]396#endif
397#if H_3D_DIM
[781]398#if QC_GENERIC_SDC_G0122
[608]399static const UChar
400INIT_DEPTH_INTRA_MODE[3][NUM_DEPTH_INTRA_MODE_CTX] =
[56]401{
[781]402  { 154, },
403  { 154, },
404  { 154, }
405};
406#else
407static const UChar
408INIT_DEPTH_INTRA_MODE[3][NUM_DEPTH_INTRA_MODE_CTX] =
409{
[608]410    {0,  0,  64, 168, 168, 124, CNU, 0},
411    {0, 64,   0, 183, CNU, 108,   0, 0},
412    {64, 0, CNU, CNU, 168, 109,   0, 0}
[56]413};
[781]414#endif
[655]415
[781]416#if QC_GENERIC_SDC_G0122
[56]417static const UChar
[781]418INIT_ANGLE_FLAG[3][NUM_ANGLE_FLAG_CTX] =
419{
420  { 154, 155, 156 },
421  { 141, 185, 214 },
422  { 155, 170, 157 },
423};
[782]424#if !QC_SDC_UNIFY_G0130
[781]425static const UChar
426INIT_INTRASDC_FLAG[3][NUM_INTRASDC_FLAG_CTX] =
427{
428  { 214, 229, 230 },
429  { 215, 202, 174 },
430  { 213, 201, 246 },
431};
432#endif
[782]433#endif
[781]434
435static const UChar
[608]436INIT_DDC_FLAG[3][NUM_DDC_FLAG_CTX] =
[56]437{
[608]438  {0 , CNU},
439  {0 , CNU},
440  {64, CNU}
[56]441};
442static const UChar
[608]443INIT_DDC_DATA[3][NUM_DDC_DATA_CTX] = 
[2]444{
[724]445  { 154 }, 
446  { 154 }, 
447  { 154 }, 
[2]448};
[608]449#if H_3D_DIM_DMM
[56]450static const UChar
[608]451INIT_DMM1_DATA[3][NUM_DMM1_DATA_CTX] = 
[56]452{
[608]453  { CNU }, 
454  { CNU }, 
455  { CNU }, 
[2]456};
457#endif
[608]458#if H_3D_DIM_SDC
459static const UChar
460INIT_SDC_RESIDUAL_FLAG[3][SDC_NUM_RESIDUAL_FLAG_CTX] =
[443]461{
[608]462  { CNU },
463  { CNU },
464  { CNU },
[443]465};
[608]466static const UChar
467INIT_SDC_RESIDUAL[3][SDC_NUM_RESIDUAL_CTX] =
[443]468{
[608]469  { 155 },
470  { 155 },
471  { 155 },
[443]472};
473#endif
[608]474#endif
[443]475
[782]476#if H_3D_INTER_SDC && !QC_SDC_UNIFY_G0130
[608]477static const UChar
478INIT_INTER_SDC_FLAG[3][NUM_INTER_SDC_FLAG_CTX] =
[443]479{
[608]480  { CNU }, 
481  { 154 },
482  { 154 },
[443]483};
[189]484
[608]485static const UChar
486INIT_INTER_SDC_SIGN_FLAG[3][NUM_INTER_SDC_SIGN_FLAG_CTX] =
[189]487{
[608]488  { CNU }, 
489  { 154 },
490  { 154 },
[189]491};
492
[608]493static const UChar
494INIT_INTER_SDC_RESIDUAL[3][NUM_INTER_SDC_RESIDUAL_CTX] =
[189]495{
[608]496  { CNU }, 
497  { 154 },
498  { 154 },
[189]499};
500#endif
[56]501//! \}
[782]502#if QC_SDC_UNIFY_G0130
503static const UChar
504INIT_SDC_FLAG[3][NUM_SDC_FLAG_CTX] =
505{
506  { 154 }, 
507  { 154 },
508  { 154 },
509};
510#endif
[56]511
[2]512#endif
Note: See TracBrowser for help on using the repository browser.