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 | #define NUM_MERGE_FLAG_EXT_CTX 1 ///< number of context models for merge flag of merge extended |
---|
54 | #define NUM_MERGE_IDX_EXT_CTX 1 ///< number of context models for merge index of merge extended |
---|
55 | |
---|
56 | #define NUM_PART_SIZE_CTX 4 ///< number of context models for partition size |
---|
57 | #define NUM_PRED_MODE_CTX 1 ///< number of context models for prediction mode |
---|
58 | |
---|
59 | #define NUM_ADI_CTX 1 ///< number of context models for intra prediction |
---|
60 | |
---|
61 | #define NUM_CHROMA_PRED_CTX 2 ///< number of context models for intra prediction (chroma) |
---|
62 | #define NUM_INTER_DIR_CTX 5 ///< number of context models for inter prediction direction |
---|
63 | #define NUM_MV_RES_CTX 2 ///< number of context models for motion vector difference |
---|
64 | |
---|
65 | #define NUM_REF_NO_CTX 2 ///< number of context models for reference index |
---|
66 | #define NUM_TRANS_SUBDIV_FLAG_CTX 3 ///< number of context models for transform subdivision flags |
---|
67 | #define NUM_QT_CBF_CTX 4 ///< number of context models for QT CBF |
---|
68 | #define NUM_QT_ROOT_CBF_CTX 1 ///< number of context models for QT ROOT CBF |
---|
69 | #define NUM_DELTA_QP_CTX 3 ///< number of context models for dQP |
---|
70 | |
---|
71 | #define NUM_SIG_CG_FLAG_CTX 2 ///< number of context models for MULTI_LEVEL_SIGNIFICANCE |
---|
72 | |
---|
73 | #define NUM_SIG_FLAG_CTX 42 ///< number of context models for sig flag |
---|
74 | #define NUM_SIG_FLAG_CTX_LUMA 27 ///< number of context models for luma sig flag |
---|
75 | #define NUM_SIG_FLAG_CTX_CHROMA 15 ///< number of context models for chroma sig flag |
---|
76 | |
---|
77 | #define NUM_CTX_LAST_FLAG_XY 15 ///< number of context models for last coefficient position |
---|
78 | |
---|
79 | #define NUM_ONE_FLAG_CTX 24 ///< number of context models for greater than 1 flag |
---|
80 | #define NUM_ONE_FLAG_CTX_LUMA 16 ///< number of context models for greater than 1 flag of luma |
---|
81 | #define NUM_ONE_FLAG_CTX_CHROMA 8 ///< number of context models for greater than 1 flag of chroma |
---|
82 | #define NUM_ABS_FLAG_CTX 6 ///< number of context models for greater than 2 flag |
---|
83 | #define NUM_ABS_FLAG_CTX_LUMA 4 ///< number of context models for greater than 2 flag of luma |
---|
84 | #define NUM_ABS_FLAG_CTX_CHROMA 2 ///< number of context models for greater than 2 flag of chroma |
---|
85 | |
---|
86 | #define NUM_MVP_IDX_CTX 1 ///< number of context models for MVP index |
---|
87 | |
---|
88 | #define NUM_SAO_MERGE_FLAG_CTX 1 ///< number of context models for SAO merge flags |
---|
89 | #define NUM_SAO_TYPE_IDX_CTX 1 ///< number of context models for SAO type index |
---|
90 | |
---|
91 | #define NUM_TRANSFORMSKIP_FLAG_CTX 1 ///< number of context models for transform skipping |
---|
92 | #define NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX 1 |
---|
93 | |
---|
94 | |
---|
95 | |
---|
96 | #define CNU 154 ///< dummy initialization value for unused context models 'Context model Not Used' |
---|
97 | |
---|
98 | |
---|
99 | // ==================================================================================================================== |
---|
100 | // Tables |
---|
101 | // ==================================================================================================================== |
---|
102 | |
---|
103 | // initial probability for cu_transquant_bypass flag |
---|
104 | static const UChar |
---|
105 | INIT_CU_TRANSQUANT_BYPASS_FLAG[3][NUM_CU_TRANSQUANT_BYPASS_FLAG_CTX] = |
---|
106 | { |
---|
107 | { 154 }, |
---|
108 | { 154 }, |
---|
109 | { 154 }, |
---|
110 | }; |
---|
111 | |
---|
112 | // initial probability for split flag |
---|
113 | static const UChar |
---|
114 | INIT_SPLIT_FLAG[3][NUM_SPLIT_FLAG_CTX] = |
---|
115 | { |
---|
116 | { 107, 139, 126, }, |
---|
117 | { 107, 139, 126, }, |
---|
118 | { 139, 141, 157, }, |
---|
119 | }; |
---|
120 | |
---|
121 | static const UChar |
---|
122 | INIT_SKIP_FLAG[3][NUM_SKIP_FLAG_CTX] = |
---|
123 | { |
---|
124 | { 197, 185, 201, }, |
---|
125 | { 197, 185, 201, }, |
---|
126 | { CNU, CNU, CNU, }, |
---|
127 | }; |
---|
128 | static const UChar |
---|
129 | INIT_MERGE_FLAG_EXT[3][NUM_MERGE_FLAG_EXT_CTX] = |
---|
130 | { |
---|
131 | { 154, }, |
---|
132 | { 110, }, |
---|
133 | { CNU, }, |
---|
134 | }; |
---|
135 | |
---|
136 | static const UChar |
---|
137 | INIT_MERGE_IDX_EXT[3][NUM_MERGE_IDX_EXT_CTX] = |
---|
138 | { |
---|
139 | { 137, }, |
---|
140 | { 122, }, |
---|
141 | { CNU, }, |
---|
142 | }; |
---|
143 | |
---|
144 | static const UChar |
---|
145 | INIT_PART_SIZE[3][NUM_PART_SIZE_CTX] = |
---|
146 | { |
---|
147 | { 154, 139, 154, 154 }, |
---|
148 | { 154, 139, 154, 154 }, |
---|
149 | { 184, CNU, CNU, CNU }, |
---|
150 | }; |
---|
151 | |
---|
152 | static const UChar |
---|
153 | INIT_PRED_MODE[3][NUM_PRED_MODE_CTX] = |
---|
154 | { |
---|
155 | { 134, }, |
---|
156 | { 149, }, |
---|
157 | { CNU, }, |
---|
158 | }; |
---|
159 | |
---|
160 | static const UChar |
---|
161 | INIT_INTRA_PRED_MODE[3][NUM_ADI_CTX] = |
---|
162 | { |
---|
163 | { 183, }, |
---|
164 | { 154, }, |
---|
165 | { 184, }, |
---|
166 | }; |
---|
167 | |
---|
168 | static const UChar |
---|
169 | INIT_CHROMA_PRED_MODE[3][NUM_CHROMA_PRED_CTX] = |
---|
170 | { |
---|
171 | { 152, 139, }, |
---|
172 | { 152, 139, }, |
---|
173 | { 63, 139, }, |
---|
174 | }; |
---|
175 | |
---|
176 | static const UChar |
---|
177 | INIT_INTER_DIR[3][NUM_INTER_DIR_CTX] = |
---|
178 | { |
---|
179 | { 95, 79, 63, 31, 31, }, |
---|
180 | { 95, 79, 63, 31, 31, }, |
---|
181 | { CNU, CNU, CNU, CNU, CNU, }, |
---|
182 | }; |
---|
183 | |
---|
184 | static const UChar |
---|
185 | INIT_MVD[3][NUM_MV_RES_CTX] = |
---|
186 | { |
---|
187 | { 169, 198, }, |
---|
188 | { 140, 198, }, |
---|
189 | { CNU, CNU, }, |
---|
190 | }; |
---|
191 | |
---|
192 | static const UChar |
---|
193 | INIT_REF_PIC[3][NUM_REF_NO_CTX] = |
---|
194 | { |
---|
195 | { 153, 153 }, |
---|
196 | { 153, 153 }, |
---|
197 | { CNU, CNU }, |
---|
198 | }; |
---|
199 | |
---|
200 | static const UChar |
---|
201 | INIT_DQP[3][NUM_DELTA_QP_CTX] = |
---|
202 | { |
---|
203 | { 154, 154, 154, }, |
---|
204 | { 154, 154, 154, }, |
---|
205 | { 154, 154, 154, }, |
---|
206 | }; |
---|
207 | |
---|
208 | static const UChar |
---|
209 | INIT_QT_CBF[3][2*NUM_QT_CBF_CTX] = |
---|
210 | { |
---|
211 | { 153, 111, CNU, CNU, 149, 92, 167, 154 }, |
---|
212 | { 153, 111, CNU, CNU, 149, 107, 167, 154 }, |
---|
213 | { 111, 141, CNU, CNU, 94, 138, 182, 154 }, |
---|
214 | }; |
---|
215 | |
---|
216 | static const UChar |
---|
217 | INIT_QT_ROOT_CBF[3][NUM_QT_ROOT_CBF_CTX] = |
---|
218 | { |
---|
219 | { 79, }, |
---|
220 | { 79, }, |
---|
221 | { CNU, }, |
---|
222 | }; |
---|
223 | |
---|
224 | static const UChar |
---|
225 | INIT_LAST[3][2*NUM_CTX_LAST_FLAG_XY] = |
---|
226 | { |
---|
227 | { 125, 110, 124, 110, 95, 94, 125, 111, 111, 79, 125, 126, 111, 111, 79, |
---|
228 | 108, 123, 93, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, |
---|
229 | }, |
---|
230 | { 125, 110, 94, 110, 95, 79, 125, 111, 110, 78, 110, 111, 111, 95, 94, |
---|
231 | 108, 123, 108, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, |
---|
232 | }, |
---|
233 | { 110, 110, 124, 125, 140, 153, 125, 127, 140, 109, 111, 143, 127, 111, 79, |
---|
234 | 108, 123, 63, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, |
---|
235 | }, |
---|
236 | }; |
---|
237 | |
---|
238 | static const UChar |
---|
239 | INIT_SIG_CG_FLAG[3][2 * NUM_SIG_CG_FLAG_CTX] = |
---|
240 | { |
---|
241 | { 121, 140, |
---|
242 | 61, 154, |
---|
243 | }, |
---|
244 | { 121, 140, |
---|
245 | 61, 154, |
---|
246 | }, |
---|
247 | { 91, 171, |
---|
248 | 134, 141, |
---|
249 | }, |
---|
250 | }; |
---|
251 | |
---|
252 | static const UChar |
---|
253 | INIT_SIG_FLAG[3][NUM_SIG_FLAG_CTX] = |
---|
254 | { |
---|
255 | { 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, }, |
---|
256 | { 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, }, |
---|
257 | { 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, }, |
---|
258 | }; |
---|
259 | |
---|
260 | static const UChar |
---|
261 | INIT_ONE_FLAG[3][NUM_ONE_FLAG_CTX] = |
---|
262 | { |
---|
263 | { 154, 196, 167, 167, 154, 152, 167, 182, 182, 134, 149, 136, 153, 121, 136, 122, 169, 208, 166, 167, 154, 152, 167, 182, }, |
---|
264 | { 154, 196, 196, 167, 154, 152, 167, 182, 182, 134, 149, 136, 153, 121, 136, 137, 169, 194, 166, 167, 154, 167, 137, 182, }, |
---|
265 | { 140, 92, 137, 138, 140, 152, 138, 139, 153, 74, 149, 92, 139, 107, 122, 152, 140, 179, 166, 182, 140, 227, 122, 197, }, |
---|
266 | }; |
---|
267 | |
---|
268 | static const UChar |
---|
269 | INIT_ABS_FLAG[3][NUM_ABS_FLAG_CTX] = |
---|
270 | { |
---|
271 | { 107, 167, 91, 107, 107, 167, }, |
---|
272 | { 107, 167, 91, 122, 107, 167, }, |
---|
273 | { 138, 153, 136, 167, 152, 152, }, |
---|
274 | }; |
---|
275 | |
---|
276 | static const UChar |
---|
277 | INIT_MVP_IDX[3][NUM_MVP_IDX_CTX] = |
---|
278 | { |
---|
279 | { 168 }, |
---|
280 | { 168 }, |
---|
281 | { CNU }, |
---|
282 | }; |
---|
283 | |
---|
284 | static const UChar |
---|
285 | INIT_SAO_MERGE_FLAG[3][NUM_SAO_MERGE_FLAG_CTX] = |
---|
286 | { |
---|
287 | { 153, }, |
---|
288 | { 153, }, |
---|
289 | { 153, }, |
---|
290 | }; |
---|
291 | |
---|
292 | static const UChar |
---|
293 | INIT_SAO_TYPE_IDX[3][NUM_SAO_TYPE_IDX_CTX] = |
---|
294 | { |
---|
295 | { 160, }, |
---|
296 | { 185, }, |
---|
297 | { 200, }, |
---|
298 | }; |
---|
299 | |
---|
300 | static const UChar |
---|
301 | INIT_TRANS_SUBDIV_FLAG[3][NUM_TRANS_SUBDIV_FLAG_CTX] = |
---|
302 | { |
---|
303 | { 224, 167, 122, }, |
---|
304 | { 124, 138, 94, }, |
---|
305 | { 153, 138, 138, }, |
---|
306 | }; |
---|
307 | |
---|
308 | static const UChar |
---|
309 | INIT_TRANSFORMSKIP_FLAG[3][2*NUM_TRANSFORMSKIP_FLAG_CTX] = |
---|
310 | { |
---|
311 | { 139, 139}, |
---|
312 | { 139, 139}, |
---|
313 | { 139, 139}, |
---|
314 | }; |
---|
315 | |
---|
316 | |
---|
317 | |
---|
318 | //! \} |
---|
319 | |
---|
320 | |
---|
321 | #endif |
---|