source: 3DVCSoftware/branches/HTM-10.2-dev0/source/Lib/TLibCommon/ContextTables.h @ 939

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

Merged 10.2-dev3-HiSilicon@928.

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