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 | #define CNU 154 ///< dummy initialization value for unused context models 'Context model Not Used' |
---|
98 | |
---|
99 | #if H_3D_DIM |
---|
100 | #define NUM_DEPTH_INTRA_MODE_CTX 8 ///< number of context models for depth intra modes |
---|
101 | #define NUM_DDC_FLAG_CTX 2 ///< number of context models for deltaDC flag (DMM or RBC) |
---|
102 | #define NUM_DDC_DATA_CTX 2 ///< number of context models for deltaDC data (DMM or RBC) |
---|
103 | #if H_3D_DIM_DMM |
---|
104 | #define NUM_DMM1_DATA_CTX 1 ///< number of context models for DMM1 data |
---|
105 | #define NUM_DMM2_DATA_CTX 1 ///< number of context models for DMM2 data |
---|
106 | #define NUM_DMM3_DATA_CTX 1 ///< number of context models for DMM3 data |
---|
107 | #endif |
---|
108 | #if H_3D_DIM_RBC |
---|
109 | #define NUM_RBC_DATA_CTX 1 ///< number of context models for RBC data |
---|
110 | #endif |
---|
111 | #endif |
---|
112 | |
---|
113 | // ==================================================================================================================== |
---|
114 | // Tables |
---|
115 | // ==================================================================================================================== |
---|
116 | |
---|
117 | // initial probability for cu_transquant_bypass flag |
---|
118 | static const UChar |
---|
119 | INIT_CU_TRANSQUANT_BYPASS_FLAG[3][NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX] = |
---|
120 | { |
---|
121 | { 154 }, |
---|
122 | { 154 }, |
---|
123 | { 154 }, |
---|
124 | }; |
---|
125 | |
---|
126 | // initial probability for split flag |
---|
127 | static const UChar |
---|
128 | INIT_SPLIT_FLAG[3][NUM_SPLIT_FLAG_CTX] = |
---|
129 | { |
---|
130 | { 107, 139, 126, }, |
---|
131 | { 107, 139, 126, }, |
---|
132 | { 139, 141, 157, }, |
---|
133 | }; |
---|
134 | |
---|
135 | static const UChar |
---|
136 | INIT_SKIP_FLAG[3][NUM_SKIP_FLAG_CTX] = |
---|
137 | { |
---|
138 | { 197, 185, 201, }, |
---|
139 | { 197, 185, 201, }, |
---|
140 | { CNU, CNU, CNU, }, |
---|
141 | }; |
---|
142 | |
---|
143 | static const UChar |
---|
144 | INIT_MERGE_FLAG_EXT[3][NUM_MERGE_FLAG_EXT_CTX] = |
---|
145 | { |
---|
146 | { 154, }, |
---|
147 | { 110, }, |
---|
148 | { CNU, }, |
---|
149 | }; |
---|
150 | |
---|
151 | static const UChar |
---|
152 | INIT_MERGE_IDX_EXT[3][NUM_MERGE_IDX_EXT_CTX] = |
---|
153 | { |
---|
154 | { 137, }, |
---|
155 | { 122, }, |
---|
156 | { CNU, }, |
---|
157 | }; |
---|
158 | |
---|
159 | static const UChar |
---|
160 | INIT_PART_SIZE[3][NUM_PART_SIZE_CTX] = |
---|
161 | { |
---|
162 | { 154, 139, CNU, CNU, }, |
---|
163 | { 154, 139, CNU, CNU, }, |
---|
164 | { 184, CNU, CNU, CNU, }, |
---|
165 | }; |
---|
166 | |
---|
167 | static const UChar |
---|
168 | INIT_CU_AMP_POS[3][NUM_CU_AMP_CTX] = |
---|
169 | { |
---|
170 | { 154, }, |
---|
171 | { 154, }, |
---|
172 | { CNU, }, |
---|
173 | }; |
---|
174 | |
---|
175 | static const UChar |
---|
176 | INIT_PRED_MODE[3][NUM_PRED_MODE_CTX] = |
---|
177 | { |
---|
178 | { 134, }, |
---|
179 | { 149, }, |
---|
180 | { CNU, }, |
---|
181 | }; |
---|
182 | |
---|
183 | static const UChar |
---|
184 | INIT_INTRA_PRED_MODE[3][NUM_ADI_CTX] = |
---|
185 | { |
---|
186 | { 183, }, |
---|
187 | { 154, }, |
---|
188 | { 184, }, |
---|
189 | }; |
---|
190 | |
---|
191 | static const UChar |
---|
192 | INIT_CHROMA_PRED_MODE[3][NUM_CHROMA_PRED_CTX] = |
---|
193 | { |
---|
194 | { 152, 139, }, |
---|
195 | { 152, 139, }, |
---|
196 | { 63, 139, }, |
---|
197 | }; |
---|
198 | |
---|
199 | static const UChar |
---|
200 | INIT_INTER_DIR[3][NUM_INTER_DIR_CTX] = |
---|
201 | { |
---|
202 | { 95, 79, 63, 31, 31, }, |
---|
203 | { 95, 79, 63, 31, 31, }, |
---|
204 | { CNU, CNU, CNU, CNU, CNU, }, |
---|
205 | }; |
---|
206 | |
---|
207 | static const UChar |
---|
208 | INIT_MVD[3][NUM_MV_RES_CTX] = |
---|
209 | { |
---|
210 | { 169, 198, }, |
---|
211 | { 140, 198, }, |
---|
212 | { CNU, CNU, }, |
---|
213 | }; |
---|
214 | |
---|
215 | static const UChar |
---|
216 | INIT_REF_PIC[3][NUM_REF_NO_CTX] = |
---|
217 | { |
---|
218 | { 153, 153 }, |
---|
219 | { 153, 153 }, |
---|
220 | { CNU, CNU }, |
---|
221 | }; |
---|
222 | |
---|
223 | static const UChar |
---|
224 | INIT_DQP[3][NUM_DELTA_QP_CTX] = |
---|
225 | { |
---|
226 | { 154, 154, 154, }, |
---|
227 | { 154, 154, 154, }, |
---|
228 | { 154, 154, 154, }, |
---|
229 | }; |
---|
230 | |
---|
231 | static const UChar |
---|
232 | INIT_QT_CBF[3][2*NUM_QT_CBF_CTX] = |
---|
233 | { |
---|
234 | { 153, 111, CNU, CNU, CNU, 149, 92, 167, CNU, CNU, }, |
---|
235 | { 153, 111, CNU, CNU, CNU, 149, 107, 167, CNU, CNU, }, |
---|
236 | { 111, 141, CNU, CNU, CNU, 94, 138, 182, CNU, CNU, }, |
---|
237 | }; |
---|
238 | |
---|
239 | static const UChar |
---|
240 | INIT_QT_ROOT_CBF[3][NUM_QT_ROOT_CBF_CTX] = |
---|
241 | { |
---|
242 | { 79, }, |
---|
243 | { 79, }, |
---|
244 | { CNU, }, |
---|
245 | }; |
---|
246 | |
---|
247 | static const UChar |
---|
248 | INIT_LAST[3][2*NUM_CTX_LAST_FLAG_XY] = |
---|
249 | { |
---|
250 | { 125, 110, 124, 110, 95, 94, 125, 111, 111, 79, 125, 126, 111, 111, 79, |
---|
251 | 108, 123, 93, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, |
---|
252 | }, |
---|
253 | { 125, 110, 94, 110, 95, 79, 125, 111, 110, 78, 110, 111, 111, 95, 94, |
---|
254 | 108, 123, 108, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, |
---|
255 | }, |
---|
256 | { 110, 110, 124, 125, 140, 153, 125, 127, 140, 109, 111, 143, 127, 111, 79, |
---|
257 | 108, 123, 63, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, |
---|
258 | }, |
---|
259 | }; |
---|
260 | |
---|
261 | static const UChar |
---|
262 | INIT_SIG_CG_FLAG[3][2 * NUM_SIG_CG_FLAG_CTX] = |
---|
263 | { |
---|
264 | { 121, 140, |
---|
265 | 61, 154, |
---|
266 | }, |
---|
267 | { 121, 140, |
---|
268 | 61, 154, |
---|
269 | }, |
---|
270 | { 91, 171, |
---|
271 | 134, 141, |
---|
272 | }, |
---|
273 | }; |
---|
274 | |
---|
275 | static const UChar |
---|
276 | INIT_SIG_FLAG[3][NUM_SIG_FLAG_CTX] = |
---|
277 | { |
---|
278 | { 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, }, |
---|
279 | { 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, }, |
---|
280 | { 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, }, |
---|
281 | }; |
---|
282 | |
---|
283 | static const UChar |
---|
284 | INIT_ONE_FLAG[3][NUM_ONE_FLAG_CTX] = |
---|
285 | { |
---|
286 | { 154, 196, 167, 167, 154, 152, 167, 182, 182, 134, 149, 136, 153, 121, 136, 122, 169, 208, 166, 167, 154, 152, 167, 182, }, |
---|
287 | { 154, 196, 196, 167, 154, 152, 167, 182, 182, 134, 149, 136, 153, 121, 136, 137, 169, 194, 166, 167, 154, 167, 137, 182, }, |
---|
288 | { 140, 92, 137, 138, 140, 152, 138, 139, 153, 74, 149, 92, 139, 107, 122, 152, 140, 179, 166, 182, 140, 227, 122, 197, }, |
---|
289 | }; |
---|
290 | |
---|
291 | static const UChar |
---|
292 | INIT_ABS_FLAG[3][NUM_ABS_FLAG_CTX] = |
---|
293 | { |
---|
294 | { 107, 167, 91, 107, 107, 167, }, |
---|
295 | { 107, 167, 91, 122, 107, 167, }, |
---|
296 | { 138, 153, 136, 167, 152, 152, }, |
---|
297 | }; |
---|
298 | |
---|
299 | static const UChar |
---|
300 | INIT_MVP_IDX[3][NUM_MVP_IDX_CTX] = |
---|
301 | { |
---|
302 | { 168, CNU, }, |
---|
303 | { 168, CNU, }, |
---|
304 | { CNU, CNU, }, |
---|
305 | }; |
---|
306 | |
---|
307 | static const UChar |
---|
308 | INIT_SAO_MERGE_FLAG[3][NUM_SAO_MERGE_FLAG_CTX] = |
---|
309 | { |
---|
310 | { 153, }, |
---|
311 | { 153, }, |
---|
312 | { 153, }, |
---|
313 | }; |
---|
314 | |
---|
315 | static const UChar |
---|
316 | INIT_SAO_TYPE_IDX[3][NUM_SAO_TYPE_IDX_CTX] = |
---|
317 | { |
---|
318 | #if FIX827 |
---|
319 | { 160, }, |
---|
320 | { 185, }, |
---|
321 | { 200, }, |
---|
322 | #else |
---|
323 | { 200, }, |
---|
324 | { 185, }, |
---|
325 | { 160, }, |
---|
326 | #endif |
---|
327 | }; |
---|
328 | |
---|
329 | static const UChar |
---|
330 | INIT_TRANS_SUBDIV_FLAG[3][NUM_TRANS_SUBDIV_FLAG_CTX] = |
---|
331 | { |
---|
332 | #if FIX712 |
---|
333 | { 224, 167, 122, }, |
---|
334 | { 124, 138, 94, }, |
---|
335 | { 153, 138, 138, }, |
---|
336 | #else |
---|
337 | { 153, 138, 138, }, |
---|
338 | { 124, 138, 94, }, |
---|
339 | { 224, 167, 122, }, |
---|
340 | #endif |
---|
341 | }; |
---|
342 | |
---|
343 | static const UChar |
---|
344 | INIT_TRANSFORMSKIP_FLAG[3][2*NUM_TRANSFORMSKIP_FLAG_CTX] = |
---|
345 | { |
---|
346 | { 139, 139}, |
---|
347 | { 139, 139}, |
---|
348 | { 139, 139}, |
---|
349 | }; |
---|
350 | |
---|
351 | #if H_3D_DIM |
---|
352 | static const UChar |
---|
353 | INIT_DEPTH_INTRA_MODE[3][NUM_DEPTH_INTRA_MODE_CTX] = |
---|
354 | { |
---|
355 | {0, 0, 64, 0, CNU, 0, CNU, 0}, |
---|
356 | {0, 64, 0, CNU, 0, CNU, 0, 0}, |
---|
357 | {64, 0, CNU, 0, CNU, 0, 0, 0} |
---|
358 | }; |
---|
359 | static const UChar |
---|
360 | INIT_DDC_FLAG[3][NUM_DDC_FLAG_CTX] = |
---|
361 | { |
---|
362 | {0 , CNU}, |
---|
363 | {0 , CNU}, |
---|
364 | {64, CNU} |
---|
365 | }; |
---|
366 | static const UChar |
---|
367 | INIT_DDC_DATA[3][NUM_DDC_DATA_CTX] = |
---|
368 | { |
---|
369 | { CNU, CNU }, |
---|
370 | { CNU, CNU }, |
---|
371 | { CNU, CNU }, |
---|
372 | }; |
---|
373 | #if H_3D_DIM_DMM |
---|
374 | static const UChar |
---|
375 | INIT_DMM1_DATA[3][NUM_DMM1_DATA_CTX] = |
---|
376 | { |
---|
377 | { CNU }, |
---|
378 | { CNU }, |
---|
379 | { CNU }, |
---|
380 | }; |
---|
381 | static const UChar |
---|
382 | INIT_DMM2_DATA[3][NUM_DMM2_DATA_CTX] = |
---|
383 | { |
---|
384 | { CNU }, |
---|
385 | { CNU }, |
---|
386 | { CNU }, |
---|
387 | }; |
---|
388 | static const UChar |
---|
389 | INIT_DMM3_DATA[3][NUM_DMM3_DATA_CTX] = |
---|
390 | { |
---|
391 | { CNU }, |
---|
392 | { CNU }, |
---|
393 | { CNU }, |
---|
394 | }; |
---|
395 | #endif |
---|
396 | #if H_3D_DIM_RBC |
---|
397 | static const UChar |
---|
398 | INIT_RBC_DATA[3][NUM_RBC_DATA_CTX] = |
---|
399 | { |
---|
400 | { CNU }, |
---|
401 | { CNU }, |
---|
402 | { CNU }, |
---|
403 | }; |
---|
404 | #endif |
---|
405 | #endif |
---|
406 | //! \} |
---|
407 | |
---|
408 | |
---|
409 | #endif |
---|