source: 3DVCSoftware/branches/HTM-10.1-dev0/source/Lib/TLibCommon/ContextTables.h @ 876

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

Cleanups part 1.

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