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

Last change on this file since 464 was 464, checked in by zhang, 11 years ago

Implementation of ARP from QC

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