1// Copyright (c) 2018-2022, The rav1e contributors. All rights reserved
2//
3// This source code is subject to the terms of the BSD 2 Clause License and
4// the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
5// was not distributed with this source code in the LICENSE file, you can
6// obtain it at www.aomedia.org/license/software. If the Alliance for Open
7// Media Patent License 1.0 was not distributed with this source code in the
8// PATENTS file, you can obtain it at www.aomedia.org/license/patent.
9
10#![allow(non_upper_case_globals)]
11
12use crate::context::*;
13use crate::partition::*;
14use crate::predict::*;
15use crate::transform::*;
16use crate::util::*;
17
18pub const PALETTE_BSIZE_CTXS: usize = 7;
19pub const PALETTE_Y_MODE_CONTEXTS: usize = 3;
20pub const PALETTE_UV_MODE_CONTEXTS: usize = 2;
21const PALETTE_COLOR_INDEX_CONTEXTS: usize = 5;
22const RESTORE_SWITCHABLE_TYPES: usize = 3;
23pub const TX_SIZE_CONTEXTS: usize = 3;
24
25// from seg_common.h
26const MAX_SEGMENTS: usize = 8;
27const SPATIAL_PREDICTION_PROBS: usize = 3;
28const SEG_TEMPORAL_PRED_CTXS: usize = 3;
29
30// enums.h
31const TX_SIZE_LUMA_MIN: usize = TxSize::TX_4X4 as usize;
32const TX_SIZE_CTX_MIN: usize = TX_SIZE_LUMA_MIN + 1;
33pub const MAX_TX_CATS: usize = TxSize::TX_SIZES - TX_SIZE_CTX_MIN;
34pub const BIG_TX_CATS: usize = MAX_TX_CATS - 1; // All except 8x8, which has lower max depth.
35pub const MAX_TX_DEPTH: usize = 2;
36
37// LUTS ---------------------
38
39pub static default_kf_y_mode_cdf: [[[u16; INTRA_MODES]; KF_MODE_CONTEXTS];
40 KF_MODE_CONTEXTS] = cdf_3d([
41 [
42 [
43 15588, 17027, 19338, 20218, 20682, 21110, 21825, 23244, 24189, 28165,
44 29093, 30466,
45 ],
46 [
47 12016, 18066, 19516, 20303, 20719, 21444, 21888, 23032, 24434, 28658,
48 30172, 31409,
49 ],
50 [
51 10052, 10771, 22296, 22788, 23055, 23239, 24133, 25620, 26160, 29336,
52 29929, 31567,
53 ],
54 [
55 14091, 15406, 16442, 18808, 19136, 19546, 19998, 22096, 24746, 29585,
56 30958, 32462,
57 ],
58 [
59 12122, 13265, 15603, 16501, 18609, 20033, 22391, 25583, 26437, 30261,
60 31073, 32475,
61 ],
62 ],
63 [
64 [
65 10023, 19585, 20848, 21440, 21832, 22760, 23089, 24023, 25381, 29014,
66 30482, 31436,
67 ],
68 [
69 5983, 24099, 24560, 24886, 25066, 25795, 25913, 26423, 27610, 29905,
70 31276, 31794,
71 ],
72 [
73 7444, 12781, 20177, 20728, 21077, 21607, 22170, 23405, 24469, 27915,
74 29090, 30492,
75 ],
76 [
77 8537, 14689, 15432, 17087, 17408, 18172, 18408, 19825, 24649, 29153,
78 31096, 32210,
79 ],
80 [
81 7543, 14231, 15496, 16195, 17905, 20717, 21984, 24516, 26001, 29675,
82 30981, 31994,
83 ],
84 ],
85 [
86 [
87 12613, 13591, 21383, 22004, 22312, 22577, 23401, 25055, 25729, 29538,
88 30305, 32077,
89 ],
90 [
91 9687, 13470, 18506, 19230, 19604, 20147, 20695, 22062, 23219, 27743,
92 29211, 30907,
93 ],
94 [
95 6183, 6505, 26024, 26252, 26366, 26434, 27082, 28354, 28555, 30467,
96 30794, 32086,
97 ],
98 [
99 10718, 11734, 14954, 17224, 17565, 17924, 18561, 21523, 23878, 28975,
100 30287, 32252,
101 ],
102 [
103 9194, 9858, 16501, 17263, 18424, 19171, 21563, 25961, 26561, 30072,
104 30737, 32463,
105 ],
106 ],
107 [
108 [
109 12602, 14399, 15488, 18381, 18778, 19315, 19724, 21419, 25060, 29696,
110 30917, 32409,
111 ],
112 [
113 8203, 13821, 14524, 17105, 17439, 18131, 18404, 19468, 25225, 29485,
114 31158, 32342,
115 ],
116 [
117 8451, 9731, 15004, 17643, 18012, 18425, 19070, 21538, 24605, 29118,
118 30078, 32018,
119 ],
120 [
121 7714, 9048, 9516, 16667, 16817, 16994, 17153, 18767, 26743, 30389,
122 31536, 32528,
123 ],
124 [
125 8843, 10280, 11496, 15317, 16652, 17943, 19108, 22718, 25769, 29953,
126 30983, 32485,
127 ],
128 ],
129 [
130 [
131 12578, 13671, 15979, 16834, 19075, 20913, 22989, 25449, 26219, 30214,
132 31150, 32477,
133 ],
134 [
135 9563, 13626, 15080, 15892, 17756, 20863, 22207, 24236, 25380, 29653,
136 31143, 32277,
137 ],
138 [
139 8356, 8901, 17616, 18256, 19350, 20106, 22598, 25947, 26466, 29900,
140 30523, 32261,
141 ],
142 [
143 10835, 11815, 13124, 16042, 17018, 18039, 18947, 22753, 24615, 29489,
144 30883, 32482,
145 ],
146 [
147 7618, 8288, 9859, 10509, 15386, 18657, 22903, 28776, 29180, 31355,
148 31802, 32593,
149 ],
150 ],
151]);
152
153pub static default_angle_delta_cdf: [[u16; 2 * MAX_ANGLE_DELTA + 1];
154 DIRECTIONAL_MODES] = cdf_2d([
155 [2180, 5032, 7567, 22776, 26989, 30217],
156 [2301, 5608, 8801, 23487, 26974, 30330],
157 [3780, 11018, 13699, 19354, 23083, 31286],
158 [4581, 11226, 15147, 17138, 21834, 28397],
159 [1737, 10927, 14509, 19588, 22745, 28823],
160 [2664, 10176, 12485, 17650, 21600, 30495],
161 [2240, 11096, 15453, 20341, 22561, 28917],
162 [3605, 10428, 12459, 17676, 21244, 30655],
163]);
164
165pub static default_if_y_mode_cdf: [[u16; INTRA_MODES]; BLOCK_SIZE_GROUPS] =
166 cdf_2d([
167 [
168 22801, 23489, 24293, 24756, 25601, 26123, 26606, 27418, 27945, 29228,
169 29685, 30349,
170 ],
171 [
172 18673, 19845, 22631, 23318, 23950, 24649, 25527, 27364, 28152, 29701,
173 29984, 30852,
174 ],
175 [
176 19770, 20979, 23396, 23939, 24241, 24654, 25136, 27073, 27830, 29360,
177 29730, 30659,
178 ],
179 [
180 20155, 21301, 22838, 23178, 23261, 23533, 23703, 24804, 25352, 26575,
181 27016, 28049,
182 ],
183 ]);
184
185pub static default_uv_mode_cdf: [[u16; INTRA_MODES]; INTRA_MODES] = cdf_2d([
186 [
187 22631, 24152, 25378, 25661, 25986, 26520, 27055, 27923, 28244, 30059,
188 30941, 31961,
189 ],
190 [
191 9513, 26881, 26973, 27046, 27118, 27664, 27739, 27824, 28359, 29505,
192 29800, 31796,
193 ],
194 [
195 9845, 9915, 28663, 28704, 28757, 28780, 29198, 29822, 29854, 30764, 31777,
196 32029,
197 ],
198 [
199 13639, 13897, 14171, 25331, 25606, 25727, 25953, 27148, 28577, 30612,
200 31355, 32493,
201 ],
202 [
203 9764, 9835, 9930, 9954, 25386, 27053, 27958, 28148, 28243, 31101, 31744,
204 32363,
205 ],
206 [
207 11825, 13589, 13677, 13720, 15048, 29213, 29301, 29458, 29711, 31161,
208 31441, 32550,
209 ],
210 [
211 14175, 14399, 16608, 16821, 17718, 17775, 28551, 30200, 30245, 31837,
212 32342, 32667,
213 ],
214 [
215 12885, 13038, 14978, 15590, 15673, 15748, 16176, 29128, 29267, 30643,
216 31961, 32461,
217 ],
218 [
219 12026, 13661, 13874, 15305, 15490, 15726, 15995, 16273, 28443, 30388,
220 30767, 32416,
221 ],
222 [
223 19052, 19840, 20579, 20916, 21150, 21467, 21885, 22719, 23174, 28861,
224 30379, 32175,
225 ],
226 [
227 18627, 19649, 20974, 21219, 21492, 21816, 22199, 23119, 23527, 27053,
228 31397, 32148,
229 ],
230 [
231 17026, 19004, 19997, 20339, 20586, 21103, 21349, 21907, 22482, 25896,
232 26541, 31819,
233 ],
234 [
235 12124, 13759, 14959, 14992, 15007, 15051, 15078, 15166, 15255, 15753,
236 16039, 16606,
237 ],
238]);
239
240pub static default_uv_mode_cfl_cdf: [[u16; UV_INTRA_MODES]; INTRA_MODES] =
241 cdf_2d([
242 [
243 10407, 11208, 12900, 13181, 13823, 14175, 14899, 15656, 15986, 20086,
244 20995, 22455, 24212,
245 ],
246 [
247 4532, 19780, 20057, 20215, 20428, 21071, 21199, 21451, 22099, 24228,
248 24693, 27032, 29472,
249 ],
250 [
251 5273, 5379, 20177, 20270, 20385, 20439, 20949, 21695, 21774, 23138,
252 24256, 24703, 26679,
253 ],
254 [
255 6740, 7167, 7662, 14152, 14536, 14785, 15034, 16741, 18371, 21520,
256 22206, 23389, 24182,
257 ],
258 [
259 4987, 5368, 5928, 6068, 19114, 20315, 21857, 22253, 22411, 24911, 25380,
260 26027, 26376,
261 ],
262 [
263 5370, 6889, 7247, 7393, 9498, 21114, 21402, 21753, 21981, 24780, 25386,
264 26517, 27176,
265 ],
266 [
267 4816, 4961, 7204, 7326, 8765, 8930, 20169, 20682, 20803, 23188, 23763,
268 24455, 24940,
269 ],
270 [
271 6608, 6740, 8529, 9049, 9257, 9356, 9735, 18827, 19059, 22336, 23204,
272 23964, 24793,
273 ],
274 [
275 5998, 7419, 7781, 8933, 9255, 9549, 9753, 10417, 18898, 22494, 23139,
276 24764, 25989,
277 ],
278 [
279 10660, 11298, 12550, 12957, 13322, 13624, 14040, 15004, 15534, 20714,
280 21789, 23443, 24861,
281 ],
282 [
283 10522, 11530, 12552, 12963, 13378, 13779, 14245, 15235, 15902, 20102,
284 22696, 23774, 25838,
285 ],
286 [
287 10099, 10691, 12639, 13049, 13386, 13665, 14125, 15163, 15636, 19676,
288 20474, 23519, 25208,
289 ],
290 [
291 3144, 5087, 7382, 7504, 7593, 7690, 7801, 8064, 8232, 9248, 9875, 10521,
292 29048,
293 ],
294 ]);
295
296pub const default_partition_w8_cdf: [[u16; 4]; PARTITION_TYPES] = cdf_2d([
297 [19132, 25510, 30392],
298 [13928, 19855, 28540],
299 [12522, 23679, 28629],
300 [9896, 18783, 25853],
301]);
302
303pub const default_partition_cdf: [[u16; EXT_PARTITION_TYPES];
304 3 * PARTITION_TYPES] = cdf_2d([
305 [15597, 20929, 24571, 26706, 27664, 28821, 29601, 30571, 31902],
306 [7925, 11043, 16785, 22470, 23971, 25043, 26651, 28701, 29834],
307 [5414, 13269, 15111, 20488, 22360, 24500, 25537, 26336, 32117],
308 [2662, 6362, 8614, 20860, 23053, 24778, 26436, 27829, 31171],
309 [18462, 20920, 23124, 27647, 28227, 29049, 29519, 30178, 31544],
310 [7689, 9060, 12056, 24992, 25660, 26182, 26951, 28041, 29052],
311 [6015, 9009, 10062, 24544, 25409, 26545, 27071, 27526, 32047],
312 [1394, 2208, 2796, 28614, 29061, 29466, 29840, 30185, 31899],
313 [20137, 21547, 23078, 29566, 29837, 30261, 30524, 30892, 31724],
314 [6732, 7490, 9497, 27944, 28250, 28515, 28969, 29630, 30104],
315 [5945, 7663, 8348, 28683, 29117, 29749, 30064, 30298, 32238],
316 [870, 1212, 1487, 31198, 31394, 31574, 31743, 31881, 32332],
317]);
318
319pub const default_partition_w128_cdf: [[u16; 8]; PARTITION_TYPES] = cdf_2d([
320 [27899, 28219, 28529, 32484, 32539, 32619, 32639],
321 [6607, 6990, 8268, 32060, 32219, 32338, 32371],
322 [5429, 6676, 7122, 32027, 32227, 32531, 32582],
323 [711, 966, 1172, 32448, 32538, 32617, 32664],
324]);
325
326pub static default_intra_tx_1_cdf: [[[u16; 7]; INTRA_MODES];
327 TX_SIZE_SQR_CONTEXTS] = cdf_3d([
328 [
329 [1535, 8035, 9461, 12751, 23467, 27825],
330 [564, 3335, 9709, 10870, 18143, 28094],
331 [672, 3247, 3676, 11982, 19415, 23127],
332 [5279, 13885, 15487, 18044, 23527, 30252],
333 [4423, 6074, 7985, 10416, 25693, 29298],
334 [1486, 4241, 9460, 10662, 16456, 27694],
335 [439, 2838, 3522, 6737, 18058, 23754],
336 [1190, 4233, 4855, 11670, 20281, 24377],
337 [1045, 4312, 8647, 10159, 18644, 29335],
338 [202, 3734, 4747, 7298, 17127, 24016],
339 [447, 4312, 6819, 8884, 16010, 23858],
340 [277, 4369, 5255, 8905, 16465, 22271],
341 [3409, 5436, 10599, 15599, 19687, 24040],
342 ],
343 [
344 [1870, 13742, 14530, 16498, 23770, 27698],
345 [326, 8796, 14632, 15079, 19272, 27486],
346 [484, 7576, 7712, 14443, 19159, 22591],
347 [1126, 15340, 15895, 17023, 20896, 30279],
348 [655, 4854, 5249, 5913, 22099, 27138],
349 [1299, 6458, 8885, 9290, 14851, 25497],
350 [311, 5295, 5552, 6885, 16107, 22672],
351 [883, 8059, 8270, 11258, 17289, 21549],
352 [741, 7580, 9318, 10345, 16688, 29046],
353 [110, 7406, 7915, 9195, 16041, 23329],
354 [363, 7974, 9357, 10673, 15629, 24474],
355 [153, 7647, 8112, 9936, 15307, 19996],
356 [3511, 6332, 11165, 15335, 19323, 23594],
357 ],
358 [
359 [4681, 9362, 14043, 18725, 23406, 28087],
360 [4681, 9362, 14043, 18725, 23406, 28087],
361 [4681, 9362, 14043, 18725, 23406, 28087],
362 [4681, 9362, 14043, 18725, 23406, 28087],
363 [4681, 9362, 14043, 18725, 23406, 28087],
364 [4681, 9362, 14043, 18725, 23406, 28087],
365 [4681, 9362, 14043, 18725, 23406, 28087],
366 [4681, 9362, 14043, 18725, 23406, 28087],
367 [4681, 9362, 14043, 18725, 23406, 28087],
368 [4681, 9362, 14043, 18725, 23406, 28087],
369 [4681, 9362, 14043, 18725, 23406, 28087],
370 [4681, 9362, 14043, 18725, 23406, 28087],
371 [4681, 9362, 14043, 18725, 23406, 28087],
372 ],
373 [
374 [4681, 9362, 14043, 18725, 23406, 28087],
375 [4681, 9362, 14043, 18725, 23406, 28087],
376 [4681, 9362, 14043, 18725, 23406, 28087],
377 [4681, 9362, 14043, 18725, 23406, 28087],
378 [4681, 9362, 14043, 18725, 23406, 28087],
379 [4681, 9362, 14043, 18725, 23406, 28087],
380 [4681, 9362, 14043, 18725, 23406, 28087],
381 [4681, 9362, 14043, 18725, 23406, 28087],
382 [4681, 9362, 14043, 18725, 23406, 28087],
383 [4681, 9362, 14043, 18725, 23406, 28087],
384 [4681, 9362, 14043, 18725, 23406, 28087],
385 [4681, 9362, 14043, 18725, 23406, 28087],
386 [4681, 9362, 14043, 18725, 23406, 28087],
387 ],
388]);
389
390pub static default_intra_tx_2_cdf: [[[u16; 5]; INTRA_MODES];
391 TX_SIZE_SQR_CONTEXTS] = cdf_3d([
392 [
393 [6554, 13107, 19661, 26214],
394 [6554, 13107, 19661, 26214],
395 [6554, 13107, 19661, 26214],
396 [6554, 13107, 19661, 26214],
397 [6554, 13107, 19661, 26214],
398 [6554, 13107, 19661, 26214],
399 [6554, 13107, 19661, 26214],
400 [6554, 13107, 19661, 26214],
401 [6554, 13107, 19661, 26214],
402 [6554, 13107, 19661, 26214],
403 [6554, 13107, 19661, 26214],
404 [6554, 13107, 19661, 26214],
405 [6554, 13107, 19661, 26214],
406 ],
407 [
408 [6554, 13107, 19661, 26214],
409 [6554, 13107, 19661, 26214],
410 [6554, 13107, 19661, 26214],
411 [6554, 13107, 19661, 26214],
412 [6554, 13107, 19661, 26214],
413 [6554, 13107, 19661, 26214],
414 [6554, 13107, 19661, 26214],
415 [6554, 13107, 19661, 26214],
416 [6554, 13107, 19661, 26214],
417 [6554, 13107, 19661, 26214],
418 [6554, 13107, 19661, 26214],
419 [6554, 13107, 19661, 26214],
420 [6554, 13107, 19661, 26214],
421 ],
422 [
423 [1127, 12814, 22772, 27483],
424 [145, 6761, 11980, 26667],
425 [362, 5887, 11678, 16725],
426 [385, 15213, 18587, 30693],
427 [25, 2914, 23134, 27903],
428 [60, 4470, 11749, 23991],
429 [37, 3332, 14511, 21448],
430 [157, 6320, 13036, 17439],
431 [119, 6719, 12906, 29396],
432 [47, 5537, 12576, 21499],
433 [269, 6076, 11258, 23115],
434 [83, 5615, 12001, 17228],
435 [1968, 5556, 12023, 18547],
436 ],
437 [
438 [6554, 13107, 19661, 26214],
439 [6554, 13107, 19661, 26214],
440 [6554, 13107, 19661, 26214],
441 [6554, 13107, 19661, 26214],
442 [6554, 13107, 19661, 26214],
443 [6554, 13107, 19661, 26214],
444 [6554, 13107, 19661, 26214],
445 [6554, 13107, 19661, 26214],
446 [6554, 13107, 19661, 26214],
447 [6554, 13107, 19661, 26214],
448 [6554, 13107, 19661, 26214],
449 [6554, 13107, 19661, 26214],
450 [6554, 13107, 19661, 26214],
451 ],
452]);
453
454pub static default_inter_tx_1_cdf: [[u16; TX_TYPES]; TX_SIZE_SQR_CONTEXTS] =
455 cdf_2d([
456 [
457 4458, 5560, 7695, 9709, 13330, 14789, 17537, 20266, 21504, 22848, 23934,
458 25474, 27727, 28915, 30631,
459 ],
460 [
461 1645, 2573, 4778, 5711, 7807, 8622, 10522, 15357, 17674, 20408, 22517,
462 25010, 27116, 28856, 30749,
463 ],
464 [
465 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528,
466 24576, 26624, 28672, 30720,
467 ],
468 [
469 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528,
470 24576, 26624, 28672, 30720,
471 ],
472 ]);
473
474pub static default_inter_tx_2_cdf: [[u16; 12]; TX_SIZE_SQR_CONTEXTS] =
475 cdf_2d([
476 [2731, 5461, 8192, 10923, 13653, 16384, 19115, 21845, 24576, 27307, 30037],
477 [2731, 5461, 8192, 10923, 13653, 16384, 19115, 21845, 24576, 27307, 30037],
478 [770, 2421, 5225, 12907, 15819, 18927, 21561, 24089, 26595, 28526, 30529],
479 [2731, 5461, 8192, 10923, 13653, 16384, 19115, 21845, 24576, 27307, 30037],
480 ]);
481
482pub static default_inter_tx_3_cdf: [[u16; 2]; TX_SIZE_SQR_CONTEXTS] =
483 cdf_2d([[16384], [4167], [1998], [748]]);
484
485pub static default_cfl_sign_cdf: [u16; CFL_JOINT_SIGNS] =
486 cdf([1418, 2123, 13340, 18405, 26972, 28343, 32294]);
487
488pub static default_cfl_alpha_cdf: [[u16; CFL_ALPHABET_SIZE];
489 CFL_ALPHA_CONTEXTS] = cdf_2d([
490 [
491 7637, 20719, 31401, 32481, 32657, 32688, 32692, 32696, 32700, 32704,
492 32708, 32712, 32716, 32720, 32724,
493 ],
494 [
495 14365, 23603, 28135, 31168, 32167, 32395, 32487, 32573, 32620, 32647,
496 32668, 32672, 32676, 32680, 32684,
497 ],
498 [
499 11532, 22380, 28445, 31360, 32349, 32523, 32584, 32649, 32673, 32677,
500 32681, 32685, 32689, 32693, 32697,
501 ],
502 [
503 26990, 31402, 32282, 32571, 32692, 32696, 32700, 32704, 32708, 32712,
504 32716, 32720, 32724, 32728, 32732,
505 ],
506 [
507 17248, 26058, 28904, 30608, 31305, 31877, 32126, 32321, 32394, 32464,
508 32516, 32560, 32576, 32593, 32622,
509 ],
510 [
511 14738, 21678, 25779, 27901, 29024, 30302, 30980, 31843, 32144, 32413,
512 32520, 32594, 32622, 32656, 32660,
513 ],
514]);
515
516// This does not appear to be used in the rust project currently
517const SWITCHABLE_FILTERS: usize = 3;
518const SWITCHABLE_FILTER_CONTEXTS: usize = (SWITCHABLE_FILTERS + 1) * 4;
519
520#[allow(unused)]
521pub static default_switchable_interp_cdf: [[u16; SWITCHABLE_FILTERS];
522 SWITCHABLE_FILTER_CONTEXTS] = cdf_2d([
523 [31935, 32720],
524 [5568, 32719],
525 [422, 2938],
526 [28244, 32608],
527 [31206, 31953],
528 [4862, 32121],
529 [770, 1152],
530 [20889, 25637],
531 [31910, 32724],
532 [4120, 32712],
533 [305, 2247],
534 [27403, 32636],
535 [31022, 32009],
536 [2963, 32093],
537 [601, 943],
538 [14969, 21398],
539]);
540
541pub static default_newmv_cdf: [[u16; 2]; NEWMV_MODE_CONTEXTS] = [
542 cdf([24035]),
543 cdf([16630]),
544 cdf([15339]),
545 cdf([8386]),
546 cdf([12222]),
547 cdf([4676]),
548 [0; 2],
549];
550
551pub static default_zeromv_cdf: [[u16; 2]; GLOBALMV_MODE_CONTEXTS] =
552 cdf_2d([[2175], [1054]]);
553
554pub static default_refmv_cdf: [[u16; 2]; REFMV_MODE_CONTEXTS] =
555 cdf_2d([[23974], [24188], [17848], [28622], [24312], [19923]]);
556
557pub static default_drl_cdf: [[u16; 2]; DRL_MODE_CONTEXTS] =
558 cdf_2d([[13104], [24560], [18945]]);
559
560pub static default_compound_mode_cdf: [[u16; INTER_COMPOUND_MODES];
561 INTER_MODE_CONTEXTS] = cdf_2d([
562 [7760, 13823, 15808, 17641, 19156, 20666, 26891],
563 [10730, 19452, 21145, 22749, 24039, 25131, 28724],
564 [10664, 20221, 21588, 22906, 24295, 25387, 28436],
565 [13298, 16984, 20471, 24182, 25067, 25736, 26422],
566 [18904, 23325, 25242, 27432, 27898, 28258, 30758],
567 [10725, 17454, 20124, 22820, 24195, 25168, 26046],
568 [17125, 24273, 25814, 27492, 28214, 28704, 30592],
569 [13046, 23214, 24505, 25942, 27435, 28442, 29330],
570]);
571
572#[allow(unused)]
573pub static default_interintra_cdf: [[u16; 2]; BLOCK_SIZE_GROUPS] =
574 cdf_2d([[16384], [26887], [27597], [30237]]);
575
576#[allow(unused)]
577pub static default_interintra_mode_cdf: [[u16;
578 InterIntraMode::INTERINTRA_MODES as usize];
579 BLOCK_SIZE_GROUPS] = cdf_2d([
580 [8192, 16384, 24576],
581 [1875, 11082, 27332],
582 [2473, 9996, 26388],
583 [4238, 11537, 25926],
584]);
585
586#[allow(unused)]
587pub static default_wedge_interintra_cdf: [[u16; 2];
588 BlockSize::BLOCK_SIZES_ALL] = cdf_2d([
589 [16384],
590 [16384],
591 [16384],
592 [20036],
593 [24957],
594 [26704],
595 [27530],
596 [29564],
597 [29444],
598 [26872],
599 [16384],
600 [16384],
601 [16384],
602 [16384],
603 [16384],
604 [16384],
605 [16384],
606 [16384],
607 [16384],
608 [16384],
609 [16384],
610 [16384],
611]);
612
613#[allow(unused)]
614pub static default_compound_type_cdf: [[u16;
615 CompoundType::COMPOUND_TYPES as usize - 1];
616 BlockSize::BLOCK_SIZES_ALL] = cdf_2d([
617 [16384],
618 [16384],
619 [16384],
620 [23431],
621 [13171],
622 [11470],
623 [9770],
624 [9100],
625 [8233],
626 [6172],
627 [16384],
628 [16384],
629 [16384],
630 [16384],
631 [16384],
632 [16384],
633 [16384],
634 [16384],
635 [11820],
636 [7701],
637 [16384],
638 [16384],
639]);
640
641#[allow(unused)]
642pub static default_wedge_idx_cdf: [[u16; 16]; BlockSize::BLOCK_SIZES_ALL] =
643 cdf_2d([
644 [
645 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528,
646 24576, 26624, 28672, 30720,
647 ],
648 [
649 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528,
650 24576, 26624, 28672, 30720,
651 ],
652 [
653 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528,
654 24576, 26624, 28672, 30720,
655 ],
656 [
657 2438, 4440, 6599, 8663, 11005, 12874, 15751, 18094, 20359, 22362, 24127,
658 25702, 27752, 29450, 31171,
659 ],
660 [
661 806, 3266, 6005, 6738, 7218, 7367, 7771, 14588, 16323, 17367, 18452,
662 19422, 22839, 26127, 29629,
663 ],
664 [
665 2779, 3738, 4683, 7213, 7775, 8017, 8655, 14357, 17939, 21332, 24520,
666 27470, 29456, 30529, 31656,
667 ],
668 [
669 1684, 3625, 5675, 7108, 9302, 11274, 14429, 17144, 19163, 20961, 22884,
670 24471, 26719, 28714, 30877,
671 ],
672 [
673 1142, 3491, 6277, 7314, 8089, 8355, 9023, 13624, 15369, 16730, 18114,
674 19313, 22521, 26012, 29550,
675 ],
676 [
677 2742, 4195, 5727, 8035, 8980, 9336, 10146, 14124, 17270, 20533, 23434,
678 25972, 27944, 29570, 31416,
679 ],
680 [
681 1727, 3948, 6101, 7796, 9841, 12344, 15766, 18944, 20638, 22038, 23963,
682 25311, 26988, 28766, 31012,
683 ],
684 [
685 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528,
686 24576, 26624, 28672, 30720,
687 ],
688 [
689 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528,
690 24576, 26624, 28672, 30720,
691 ],
692 [
693 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528,
694 24576, 26624, 28672, 30720,
695 ],
696 [
697 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528,
698 24576, 26624, 28672, 30720,
699 ],
700 [
701 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528,
702 24576, 26624, 28672, 30720,
703 ],
704 [
705 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528,
706 24576, 26624, 28672, 30720,
707 ],
708 [
709 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528,
710 24576, 26624, 28672, 30720,
711 ],
712 [
713 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528,
714 24576, 26624, 28672, 30720,
715 ],
716 [
717 154, 987, 1925, 2051, 2088, 2111, 2151, 23033, 23703, 24284, 24985,
718 25684, 27259, 28883, 30911,
719 ],
720 [
721 1135, 1322, 1493, 2635, 2696, 2737, 2770, 21016, 22935, 25057, 27251,
722 29173, 30089, 30960, 31933,
723 ],
724 [
725 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528,
726 24576, 26624, 28672, 30720,
727 ],
728 [
729 2048, 4096, 6144, 8192, 10240, 12288, 14336, 16384, 18432, 20480, 22528,
730 24576, 26624, 28672, 30720,
731 ],
732 ]);
733
734#[allow(unused)]
735pub static default_motion_mode_cdf: [[u16;
736 MotionMode::MOTION_MODES as usize];
737 BlockSize::BLOCK_SIZES_ALL] = cdf_2d([
738 [10923, 21845],
739 [10923, 21845],
740 [10923, 21845],
741 [7651, 24760],
742 [4738, 24765],
743 [5391, 25528],
744 [19419, 26810],
745 [5123, 23606],
746 [11606, 24308],
747 [26260, 29116],
748 [20360, 28062],
749 [21679, 26830],
750 [29516, 30701],
751 [28898, 30397],
752 [30878, 31335],
753 [32507, 32558],
754 [10923, 21845],
755 [10923, 21845],
756 [28799, 31390],
757 [26431, 30774],
758 [28973, 31594],
759 [29742, 31203],
760]);
761
762#[allow(unused)]
763pub static default_obmc_cdf: [[u16; 2]; BlockSize::BLOCK_SIZES_ALL] =
764 cdf_2d([
765 [16384],
766 [16384],
767 [16384],
768 [10437],
769 [9371],
770 [9301],
771 [17432],
772 [14423],
773 [15142],
774 [25817],
775 [22823],
776 [22083],
777 [30128],
778 [31014],
779 [31560],
780 [32638],
781 [16384],
782 [16384],
783 [23664],
784 [20901],
785 [24008],
786 [26879],
787 ]);
788
789pub static default_intra_inter_cdf: [[u16; 2]; INTRA_INTER_CONTEXTS] =
790 cdf_2d([[806], [16662], [20186], [26538]]);
791
792pub static default_comp_mode_cdf: [[u16; 2]; COMP_INTER_CONTEXTS] =
793 cdf_2d([[26828], [24035], [12031], [10640], [2901]]);
794
795pub static default_comp_ref_type_cdf: [[u16; 2]; COMP_REF_TYPE_CONTEXTS] =
796 cdf_2d([[1198], [2070], [9166], [7499], [22475]]);
797
798#[allow(unused)]
799pub static default_uni_comp_ref_cdf: [[[u16; 2]; UNIDIR_COMP_REFS - 1];
800 UNI_COMP_REF_CONTEXTS] = cdf_3d([
801 [[5284], [3865], [3128]],
802 [[23152], [14173], [15270]],
803 [[31774], [25120], [26710]],
804]);
805
806pub static default_single_ref_cdf: [[[u16; 2]; SINGLE_REFS - 1];
807 REF_CONTEXTS] = cdf_3d([
808 [[4897], [1555], [4236], [8650], [904], [1444]],
809 [[16973], [16751], [19647], [24773], [11014], [15087]],
810 [[29744], [30279], [31194], [31895], [26875], [30304]],
811]);
812
813pub static default_comp_ref_cdf: [[[u16; 2]; FWD_REFS - 1]; REF_CONTEXTS] =
814 cdf_3d([
815 [[4946], [9468], [1503]],
816 [[19891], [22441], [15160]],
817 [[30731], [31059], [27544]],
818 ]);
819
820pub static default_comp_bwdref_cdf: [[[u16; 2]; BWD_REFS - 1]; REF_CONTEXTS] =
821 cdf_3d([[[2235], [1423]], [[17182], [15175]], [[30606], [30489]]]);
822
823#[allow(unused)]
824pub static default_palette_y_size_cdf: [[u16;
825 PaletteSize::PALETTE_SIZES as usize];
826 PALETTE_BSIZE_CTXS] = cdf_2d([
827 [7952, 13000, 18149, 21478, 25527, 29241],
828 [7139, 11421, 16195, 19544, 23666, 28073],
829 [7788, 12741, 17325, 20500, 24315, 28530],
830 [8271, 14064, 18246, 21564, 25071, 28533],
831 [12725, 19180, 21863, 24839, 27535, 30120],
832 [9711, 14888, 16923, 21052, 25661, 27875],
833 [14940, 20797, 21678, 24186, 27033, 28999],
834]);
835
836#[allow(unused)]
837pub static default_palette_uv_size_cdf: [[u16;
838 PaletteSize::PALETTE_SIZES as usize];
839 PALETTE_BSIZE_CTXS] = cdf_2d([
840 [8713, 19979, 27128, 29609, 31331, 32272],
841 [5839, 15573, 23581, 26947, 29848, 31700],
842 [4426, 11260, 17999, 21483, 25863, 29430],
843 [3228, 9464, 14993, 18089, 22523, 27420],
844 [3768, 8886, 13091, 17852, 22495, 27207],
845 [2464, 8451, 12861, 21632, 25525, 28555],
846 [1269, 5435, 10433, 18963, 21700, 25865],
847]);
848
849pub static default_palette_y_mode_cdfs: [[[u16; 2]; PALETTE_Y_MODE_CONTEXTS];
850 PALETTE_BSIZE_CTXS] = cdf_3d([
851 [[31676], [3419], [1261]],
852 [[31912], [2859], [980]],
853 [[31823], [3400], [781]],
854 [[32030], [3561], [904]],
855 [[32309], [7337], [1462]],
856 [[32265], [4015], [1521]],
857 [[32450], [7946], [129]],
858]);
859
860pub static default_palette_uv_mode_cdfs: [[u16; 2]; PALETTE_UV_MODE_CONTEXTS] =
861 cdf_2d([[32461], [21488]]);
862
863#[allow(unused)]
864pub static default_palette_y_color_index_cdf: [[[u16;
865 PaletteColor::PALETTE_COLORS as usize];
866 PALETTE_COLOR_INDEX_CONTEXTS];
867 PaletteSize::PALETTE_SIZES as usize] = [
868 cdf_2d([[28710], [16384], [10553], [27036], [31603]]),
869 cdf_2d([
870 [27877, 30490],
871 [11532, 25697],
872 [6544, 30234],
873 [23018, 28072],
874 [31915, 32385],
875 ]),
876 cdf_2d([
877 [25572, 28046, 30045],
878 [9478, 21590, 27256],
879 [7248, 26837, 29824],
880 [19167, 24486, 28349],
881 [31400, 31825, 32250],
882 ]),
883 cdf_2d([
884 [24779, 26955, 28576, 30282],
885 [8669, 20364, 24073, 28093],
886 [4255, 27565, 29377, 31067],
887 [19864, 23674, 26716, 29530],
888 [31646, 31893, 32147, 32426],
889 ]),
890 cdf_2d([
891 [23132, 25407, 26970, 28435, 30073],
892 [7443, 17242, 20717, 24762, 27982],
893 [6300, 24862, 26944, 28784, 30671],
894 [18916, 22895, 25267, 27435, 29652],
895 [31270, 31550, 31808, 32059, 32353],
896 ]),
897 cdf_2d([
898 [23105, 25199, 26464, 27684, 28931, 30318],
899 [6950, 15447, 18952, 22681, 25567, 28563],
900 [7560, 23474, 25490, 27203, 28921, 30708],
901 [18544, 22373, 24457, 26195, 28119, 30045],
902 [31198, 31451, 31670, 31882, 32123, 32391],
903 ]),
904 cdf_2d([
905 [21689, 23883, 25163, 26352, 27506, 28827, 30195],
906 [6892, 15385, 17840, 21606, 24287, 26753, 29204],
907 [5651, 23182, 25042, 26518, 27982, 29392, 30900],
908 [19349, 22578, 24418, 25994, 27524, 29031, 30448],
909 [31028, 31270, 31504, 31705, 31927, 32153, 32392],
910 ]),
911];
912
913#[allow(unused)]
914pub static default_palette_uv_color_index_cdf: [[[u16;
915 PaletteColor::PALETTE_COLORS as usize];
916 PALETTE_COLOR_INDEX_CONTEXTS];
917 PaletteSize::PALETTE_SIZES as usize] = [
918 cdf_2d([[29089], [16384], [8713], [29257], [31610]]),
919 cdf_2d([
920 [25257, 29145],
921 [12287, 27293],
922 [7033, 27960],
923 [20145, 25405],
924 [30608, 31639],
925 ]),
926 cdf_2d([
927 [24210, 27175, 29903],
928 [9888, 22386, 27214],
929 [5901, 26053, 29293],
930 [18318, 22152, 28333],
931 [30459, 31136, 31926],
932 ]),
933 cdf_2d([
934 [22980, 25479, 27781, 29986],
935 [8413, 21408, 24859, 28874],
936 [2257, 29449, 30594, 31598],
937 [19189, 21202, 25915, 28620],
938 [31844, 32044, 32281, 32518],
939 ]),
940 cdf_2d([
941 [22217, 24567, 26637, 28683, 30548],
942 [7307, 16406, 19636, 24632, 28424],
943 [4441, 25064, 26879, 28942, 30919],
944 [17210, 20528, 23319, 26750, 29582],
945 [30674, 30953, 31396, 31735, 32207],
946 ]),
947 cdf_2d([
948 [21239, 23168, 25044, 26962, 28705, 30506],
949 [6545, 15012, 18004, 21817, 25503, 28701],
950 [3448, 26295, 27437, 28704, 30126, 31442],
951 [15889, 18323, 21704, 24698, 26976, 29690],
952 [30988, 31204, 31479, 31734, 31983, 32325],
953 ]),
954 cdf_2d([
955 [21442, 23288, 24758, 26246, 27649, 28980, 30563],
956 [5863, 14933, 17552, 20668, 23683, 26411, 29273],
957 [3415, 25810, 26877, 27990, 29223, 30394, 31618],
958 [17965, 20084, 22232, 23974, 26274, 28402, 30390],
959 [31190, 31329, 31516, 31679, 31825, 32026, 32322],
960 ]),
961];
962
963pub static default_txfm_partition_cdf: [[u16; 2]; TXFM_PARTITION_CONTEXTS] =
964 cdf_2d([
965 [28581],
966 [23846],
967 [20847],
968 [24315],
969 [18196],
970 [12133],
971 [18791],
972 [10887],
973 [11005],
974 [27179],
975 [20004],
976 [11281],
977 [26549],
978 [19308],
979 [14224],
980 [28015],
981 [21546],
982 [14400],
983 [28165],
984 [22401],
985 [16088],
986 ]);
987
988pub static default_skip_cdfs: [[u16; 2]; SKIP_CONTEXTS] =
989 cdf_2d([[31671], [16515], [4576]]);
990
991#[allow(unused)]
992pub static default_skip_mode_cdfs: [[u16; 2]; SKIP_MODE_CONTEXTS] =
993 cdf_2d([[32621], [20708], [8127]]);
994
995#[allow(unused)]
996pub static default_compound_idx_cdfs: [[u16; 2]; COMP_INDEX_CONTEXTS] =
997 cdf_2d([[18244], [12865], [7053], [13259], [9334], [4644]]);
998
999#[allow(unused)]
1000pub static default_comp_group_idx_cdfs: [[u16; 2]; COMP_GROUP_IDX_CONTEXTS] =
1001 cdf_2d([[26607], [22891], [18840], [24594], [19934], [22674]]);
1002
1003#[allow(unused)]
1004pub static default_intrabc_cdf: [u16; 2] = cdf([30531]);
1005
1006#[allow(unused)]
1007pub static default_filter_intra_mode_cdf: [u16;
1008 FilterIntraMode::FILTER_INTRA_MODES as usize] =
1009 cdf([8949, 12776, 17211, 29558]);
1010
1011pub static default_filter_intra_cdfs: [[u16; 2]; BlockSize::BLOCK_SIZES_ALL] =
1012 cdf_2d([
1013 [4621],
1014 [6743],
1015 [5893],
1016 [7866],
1017 [12551],
1018 [9394],
1019 [12408],
1020 [14301],
1021 [12756],
1022 [22343],
1023 [16384],
1024 [16384],
1025 [16384],
1026 [16384],
1027 [16384],
1028 [16384],
1029 [12770],
1030 [10368],
1031 [20229],
1032 [18101],
1033 [16384],
1034 [16384],
1035 ]);
1036
1037pub static default_switchable_restore_cdf: [u16; RESTORE_SWITCHABLE_TYPES] =
1038 cdf([9413, 22581]);
1039
1040pub static default_wiener_restore_cdf: [u16; 2] = cdf([11570]);
1041
1042pub static default_sgrproj_restore_cdf: [u16; 2] = cdf([16855]);
1043
1044#[allow(unused)]
1045pub static default_delta_q_cdf: [u16; DELTA_Q_PROBS + 1] =
1046 cdf([28160, 32120, 32677]);
1047
1048pub static default_delta_lf_multi_cdf: [[u16; DELTA_LF_PROBS + 1];
1049 FRAME_LF_COUNT] = cdf_2d([
1050 [28160, 32120, 32677],
1051 [28160, 32120, 32677],
1052 [28160, 32120, 32677],
1053 [28160, 32120, 32677],
1054]);
1055
1056pub static default_delta_lf_cdf: [u16; DELTA_LF_PROBS + 1] =
1057 cdf([28160, 32120, 32677]);
1058
1059// FIXME(someone) need real defaults here
1060#[allow(unused)]
1061pub static default_seg_tree_cdf: [u16; MAX_SEGMENTS] =
1062 cdf([4096, 8192, 12288, 16384, 20480, 24576, 28672]);
1063
1064#[allow(unused)]
1065pub static default_segment_pred_cdf: [[u16; 2]; SEG_TEMPORAL_PRED_CTXS] =
1066 cdf_2d([[128 * 128], [128 * 128], [128 * 128]]);
1067
1068pub static default_spatial_pred_seg_tree_cdf: [[u16; MAX_SEGMENTS];
1069 SPATIAL_PREDICTION_PROBS] = cdf_2d([
1070 [5622, 7893, 16093, 18233, 27809, 28373, 32533],
1071 [14274, 18230, 22557, 24935, 29980, 30851, 32344],
1072 [27527, 28487, 28723, 28890, 32397, 32647, 32679],
1073]);
1074
1075pub static default_tx_size_8x8_cdf: [[u16; MAX_TX_DEPTH]; TX_SIZE_CONTEXTS] =
1076 cdf_2d([[19968], [19968], [24320]]);
1077
1078pub static default_tx_size_cdf: [[[u16; MAX_TX_DEPTH + 1]; TX_SIZE_CONTEXTS];
1079 BIG_TX_CATS] = cdf_3d([
1080 [[12272, 30172], [12272, 30172], [18677, 30848]],
1081 [[12986, 15180], [12986, 15180], [24302, 25602]],
1082 [[5782, 11475], [5782, 11475], [16803, 22759]],
1083]);
1084