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

Last change on this file since 781 was 781, checked in by qualcomm, 10 years ago

integration of JCT3V-G0122 (generalize SDC to all depth intra modes) by Qualcomm.

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