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

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

Merged 9.3-dev0@831.

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