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