source: 3DVCSoftware/branches/HTM-DEV-0.3-dev2a/source/Lib/TLibCommon/ContextTables.h @ 468

Last change on this file since 468 was 468, checked in by lg, 11 years ago

1.IC and full pel depth coding are integrated and is guarded by Macro H_3D_IC.

  • Property svn:eol-style set to native
File size: 11.8 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// ====================================================================================================================
109// Tables
110// ====================================================================================================================
111
112// initial probability for cu_transquant_bypass flag
113static const UChar
114INIT_CU_TRANSQUANT_BYPASS_FLAG[3][NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX] =
115{
116  { 154 }, 
117  { 154 }, 
118  { 154 }, 
119};
120
121// initial probability for split flag
122static const UChar
123INIT_SPLIT_FLAG[3][NUM_SPLIT_FLAG_CTX] = 
124{
125  { 107,  139,  126, },
126  { 107,  139,  126, }, 
127  { 139,  141,  157, }, 
128};
129
130static const UChar
131INIT_SKIP_FLAG[3][NUM_SKIP_FLAG_CTX] = 
132{
133  { 197,  185,  201, }, 
134  { 197,  185,  201, }, 
135  { CNU,  CNU,  CNU, }, 
136};
137
138static const UChar
139INIT_MERGE_FLAG_EXT[3][NUM_MERGE_FLAG_EXT_CTX] = 
140{
141  { 154, }, 
142  { 110, }, 
143  { CNU, }, 
144};
145
146static const UChar
147INIT_MERGE_IDX_EXT[3][NUM_MERGE_IDX_EXT_CTX] = 
148{
149  { 137, }, 
150  { 122, }, 
151  { CNU, }, 
152};
153
154static const UChar
155INIT_PART_SIZE[3][NUM_PART_SIZE_CTX] = 
156{
157  { 154,  139,  CNU,  CNU, }, 
158  { 154,  139,  CNU,  CNU, }, 
159  { 184,  CNU,  CNU,  CNU, }, 
160};
161
162static const UChar
163INIT_CU_AMP_POS[3][NUM_CU_AMP_CTX] = 
164{
165  { 154, }, 
166  { 154, }, 
167  { CNU, }, 
168};
169
170static const UChar
171INIT_PRED_MODE[3][NUM_PRED_MODE_CTX] = 
172{
173  { 134, }, 
174  { 149, }, 
175  { CNU, }, 
176};
177
178static const UChar
179INIT_INTRA_PRED_MODE[3][NUM_ADI_CTX] = 
180{
181  { 183, }, 
182  { 154, }, 
183  { 184, }, 
184};
185
186static const UChar
187INIT_CHROMA_PRED_MODE[3][NUM_CHROMA_PRED_CTX] = 
188{
189  { 152,  139, }, 
190  { 152,  139, }, 
191  {  63,  139, }, 
192};
193
194static const UChar
195INIT_INTER_DIR[3][NUM_INTER_DIR_CTX] = 
196{
197  {  95,   79,   63,   31,  31, }, 
198  {  95,   79,   63,   31,  31, }, 
199  { CNU,  CNU,  CNU,  CNU, CNU, }, 
200};
201
202static const UChar
203INIT_MVD[3][NUM_MV_RES_CTX] = 
204{
205  { 169,  198, }, 
206  { 140,  198, }, 
207  { CNU,  CNU, }, 
208};
209
210static const UChar
211INIT_REF_PIC[3][NUM_REF_NO_CTX] = 
212{
213  { 153,  153 }, 
214  { 153,  153 }, 
215  { CNU,  CNU }, 
216};
217
218static const UChar
219INIT_DQP[3][NUM_DELTA_QP_CTX] = 
220{
221  { 154,  154,  154, }, 
222  { 154,  154,  154, }, 
223  { 154,  154,  154, }, 
224};
225
226static const UChar
227INIT_QT_CBF[3][2*NUM_QT_CBF_CTX] = 
228{
229  { 153,  111,  CNU,  CNU,  CNU,  149,   92,  167,  CNU,  CNU, }, 
230  { 153,  111,  CNU,  CNU,  CNU,  149,  107,  167,  CNU,  CNU, }, 
231  { 111,  141,  CNU,  CNU,  CNU,   94,  138,  182,  CNU,  CNU, }, 
232};
233
234static const UChar
235INIT_QT_ROOT_CBF[3][NUM_QT_ROOT_CBF_CTX] = 
236{
237  {  79, }, 
238  {  79, }, 
239  { CNU, }, 
240};
241
242static const UChar
243INIT_LAST[3][2*NUM_CTX_LAST_FLAG_XY] = 
244{
245  { 125,  110,  124,  110,   95,   94,  125,  111,  111,   79,  125,  126,  111,  111,   79,
246    108,  123,   93,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU, 
247  }, 
248  { 125,  110,   94,  110,   95,   79,  125,  111,  110,   78,  110,  111,  111,   95,   94,
249    108,  123,  108,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,
250  }, 
251  { 110,  110,  124,  125,  140,  153,  125,  127,  140,  109,  111,  143,  127,  111,   79, 
252    108,  123,   63,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU,  CNU, 
253  }, 
254};
255
256static const UChar
257INIT_SIG_CG_FLAG[3][2 * NUM_SIG_CG_FLAG_CTX] = 
258{
259  { 121,  140, 
260    61,  154, 
261  }, 
262  { 121,  140, 
263    61,  154, 
264  }, 
265  {  91,  171, 
266    134,  141, 
267  }, 
268};
269
270static const UChar
271INIT_SIG_FLAG[3][NUM_SIG_FLAG_CTX] = 
272{
273  { 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,  }, 
274  { 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,  }, 
275  { 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,  }, 
276};
277
278static const UChar
279INIT_ONE_FLAG[3][NUM_ONE_FLAG_CTX] = 
280{
281  { 154,  196,  167,  167,  154,  152,  167,  182,  182,  134,  149,  136,  153,  121,  136,  122,  169,  208,  166,  167,  154,  152,  167,  182, }, 
282  { 154,  196,  196,  167,  154,  152,  167,  182,  182,  134,  149,  136,  153,  121,  136,  137,  169,  194,  166,  167,  154,  167,  137,  182, }, 
283  { 140,   92,  137,  138,  140,  152,  138,  139,  153,   74,  149,   92,  139,  107,  122,  152,  140,  179,  166,  182,  140,  227,  122,  197, }, 
284};
285
286static const UChar
287INIT_ABS_FLAG[3][NUM_ABS_FLAG_CTX] = 
288{
289  { 107,  167,   91,  107,  107,  167, }, 
290  { 107,  167,   91,  122,  107,  167, }, 
291  { 138,  153,  136,  167,  152,  152, }, 
292};
293
294static const UChar
295INIT_MVP_IDX[3][NUM_MVP_IDX_CTX] = 
296{
297  { 168,  CNU, }, 
298  { 168,  CNU, }, 
299  { CNU,  CNU, }, 
300};
301
302static const UChar
303INIT_SAO_MERGE_FLAG[3][NUM_SAO_MERGE_FLAG_CTX] = 
304{
305  { 153,  }, 
306  { 153,  }, 
307  { 153,  }, 
308};
309
310static const UChar
311INIT_SAO_TYPE_IDX[3][NUM_SAO_TYPE_IDX_CTX] = 
312{
313#if FIX827
314  { 160, },
315  { 185, },
316  { 200, },
317#else
318  { 200, },
319  { 185, }, 
320  { 160, },
321#endif
322};
323
324static const UChar
325INIT_TRANS_SUBDIV_FLAG[3][NUM_TRANS_SUBDIV_FLAG_CTX] =
326{
327#if FIX712
328  { 224,  167,  122, },
329  { 124,  138,   94, },
330  { 153,  138,  138, },
331#else
332  { 153,  138,  138, },
333  { 124,  138,   94, },
334  { 224,  167,  122, },
335#endif
336};
337
338static const UChar
339INIT_TRANSFORMSKIP_FLAG[3][2*NUM_TRANSFORMSKIP_FLAG_CTX] = 
340{
341  { 139,  139}, 
342  { 139,  139}, 
343  { 139,  139}, 
344};
345
346#if H_3D_ARP
347static const UChar
348INIT_ARPW[3][NUM_ARPW_CTX] = 
349{
350  { 154, 154, 154, 154 }, 
351  { 154, 154, 154, 154 }, 
352  { 154, 154, 154, 154 }, 
353};
354#endif
355
356#if H_3D_IC
357static const UChar
358INIT_IC_FLAG[3][NUM_IC_FLAG_CTX] = 
359{
360  { CNU,  CNU,  CNU, }, 
361  { 197,  185,  201, }, 
362  { 197,  185,  201, }, 
363};
364#endif
365
366//! \}
367
368
369#endif
Note: See TracBrowser for help on using the repository browser.