AOMedia AV1 Codec: av1/common/enums.h Source File

| AOMedia AV1 Codec

enums.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
11
12 #ifndef AOM_AV1_COMMON_ENUMS_H_
13 #define AOM_AV1_COMMON_ENUMS_H_
14
15 #include "config/aom_config.h"
16
17 #include "aom/aom_codec.h"
18 #include "aom/aom_integer.h"
19 #include "aom_ports/mem.h"
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
29 #undef MAX_SB_SIZE
30
31 // Max superblock size
32 #define MAX_SB_SIZE_LOG2 7
33 #define MAX_SB_SIZE (1 << MAX_SB_SIZE_LOG2)
34 #define MAX_SB_SQUARE (MAX_SB_SIZE * MAX_SB_SIZE)
35
36 // Min superblock size
37 #define MIN_SB_SIZE_LOG2 6
38
39 // Pixels per Mode Info (MI) unit
40 #define MI_SIZE_LOG2 2
41 #define MI_SIZE (1 << MI_SIZE_LOG2)
42
43 // MI-units per max superblock (MI Block - MIB)
44 #define MAX_MIB_SIZE_LOG2 (MAX_SB_SIZE_LOG2 - MI_SIZE_LOG2)
45 #define MAX_MIB_SIZE (1 << MAX_MIB_SIZE_LOG2)
46
47 // MI-units per min superblock
48 #define MIN_MIB_SIZE_LOG2 (MIN_SB_SIZE_LOG2 - MI_SIZE_LOG2)
49
50 // Mask to extract MI offset within max MIB
51 #define MAX_MIB_MASK (MAX_MIB_SIZE - 1)
52
53 // Maximum number of tile rows and tile columns
54 #define MAX_TILE_ROWS 64
55 #define MAX_TILE_COLS 64
56
57 #define MAX_VARTX_DEPTH 2
58
59 #define MI_SIZE_64X64 (64 >> MI_SIZE_LOG2)
60 #define MI_SIZE_128X128 (128 >> MI_SIZE_LOG2)
61
62 #define MAX_PALETTE_SQUARE (64 * 64)
63 // Maximum number of colors in a palette.
64 #define PALETTE_MAX_SIZE 8
65 // Minimum number of colors in a palette.
66 #define PALETTE_MIN_SIZE 2
67
68 #define FRAME_OFFSET_BITS 5
69 #define MAX_FRAME_DISTANCE ((1 << FRAME_OFFSET_BITS) - 1)
70
71 // 4 frame filter levels: y plane vertical, y plane horizontal,
72 // u plane, and v plane
73 #define FRAME_LF_COUNT 4
74 #define DEFAULT_DELTA_LF_MULTI 0
75 #define MAX_MODE_LF_DELTAS 2
76
77 #define DIST_PRECISION_BITS 4
78 #define DIST_PRECISION (1 << DIST_PRECISION_BITS) // 16
79
80 #define PROFILE_BITS 3
81 // The following three profiles are currently defined.
82 // Profile 0. 8-bit and 10-bit 4:2:0 and 4:0:0 only.
83 // Profile 1. 8-bit and 10-bit 4:4:4
84 // Profile 2. 8-bit and 10-bit 4:2:2
85 // 12-bit 4:0:0, 4:2:2 and 4:4:4
86 // Since we have three bits for the profiles, it can be extended later.
87 enum {
88 PROFILE_0,
89 PROFILE_1,
90 PROFILE_2,
91 MAX_PROFILES,
92 } SENUM1BYTE(BITSTREAM_PROFILE);
93
94 #define OP_POINTS_CNT_MINUS_1_BITS 5
95 #define OP_POINTS_IDC_BITS 12
96
97 // Note: Some enums use the attribute 'packed' to use smallest possible integer
98 // type, so that we can save memory when they are used in structs/arrays.
99
100 typedef enum ATTRIBUTE_PACKED {
101 BLOCK_4X4,
102 BLOCK_4X8,
103 BLOCK_8X4,
104 BLOCK_8X8,
105 BLOCK_8X16,
106 BLOCK_16X8,
107 BLOCK_16X16,
108 BLOCK_16X32,
109 BLOCK_32X16,
110 BLOCK_32X32,
111 BLOCK_32X64,
112 BLOCK_64X32,
113 BLOCK_64X64,
114 BLOCK_64X128,
115 BLOCK_128X64,
116 BLOCK_128X128,
117 BLOCK_4X16,
118 BLOCK_16X4,
119 BLOCK_8X32,
120 BLOCK_32X8,
121 BLOCK_16X64,
122 BLOCK_64X16,
123 BLOCK_SIZES_ALL,
124 BLOCK_SIZES = BLOCK_4X16,
125 BLOCK_INVALID = 255,
126 BLOCK_LARGEST = (BLOCK_SIZES - 1)
127 } BLOCK_SIZE;
128
129 // 4X4, 8X8, 16X16, 32X32, 64X64, 128X128
130 #define SQR_BLOCK_SIZES 6
131
132 // Partition types. R: Recursive
133 //
134 // NONE HORZ VERT SPLIT
135 // +-------+ +-------+ +---+---+ +---+---+
136 // | | | | | | | | R | R |
137 // | | +-------+ | | | +---+---+
138 // | | | | | | | | R | R |
139 // +-------+ +-------+ +---+---+ +---+---+
140 //
141 // HORZ_A HORZ_B VERT_A VERT_B
142 // +---+---+ +-------+ +---+---+ +---+---+
143 // | | | | | | | | | | |
144 // +---+---+ +---+---+ +---+ | | +---+
145 // | | | | | | | | | | |
146 // +-------+ +---+---+ +---+---+ +---+---+
147 //
148 // HORZ_4 VERT_4
149 // +-----+ +-+-+-+
150 // +-----+ | | | |
151 // +-----+ | | | |
152 // +-----+ +-+-+-+
153 enum {
154 PARTITION_NONE,
155 PARTITION_HORZ,
156 PARTITION_VERT,
157 PARTITION_SPLIT,
158 PARTITION_HORZ_A, // HORZ split and the top partition is split again
159 PARTITION_HORZ_B, // HORZ split and the bottom partition is split again
160 PARTITION_VERT_A, // VERT split and the left partition is split again
161 PARTITION_VERT_B, // VERT split and the right partition is split again
162 PARTITION_HORZ_4, // 4:1 horizontal partition
163 PARTITION_VERT_4, // 4:1 vertical partition
164 EXT_PARTITION_TYPES,
165 PARTITION_TYPES = PARTITION_SPLIT + 1,
166 PARTITION_INVALID = 255
167 } UENUM1BYTE(PARTITION_TYPE);
168
169 typedef char PARTITION_CONTEXT;
170 #define PARTITION_PLOFFSET 4 // number of probability models per block size
171 #define PARTITION_BLOCK_SIZES 5
172 #define PARTITION_CONTEXTS (PARTITION_BLOCK_SIZES * PARTITION_PLOFFSET)
173
174 // block transform size
175 enum {
176 TX_4X4, // 4x4 transform
177 TX_8X8, // 8x8 transform
178 TX_16X16, // 16x16 transform
179 TX_32X32, // 32x32 transform
180 TX_64X64, // 64x64 transform
181 TX_4X8, // 4x8 transform
182 TX_8X4, // 8x4 transform
183 TX_8X16, // 8x16 transform
184 TX_16X8, // 16x8 transform
185 TX_16X32, // 16x32 transform
186 TX_32X16, // 32x16 transform
187 TX_32X64, // 32x64 transform
188 TX_64X32, // 64x32 transform
189 TX_4X16, // 4x16 transform
190 TX_16X4, // 16x4 transform
191 TX_8X32, // 8x32 transform
192 TX_32X8, // 32x8 transform
193 TX_16X64, // 16x64 transform
194 TX_64X16, // 64x16 transform
195 TX_SIZES_ALL, // Includes rectangular transforms
196 TX_SIZES = TX_4X8, // Does NOT include rectangular transforms
197 TX_SIZES_LARGEST = TX_64X64,
198 TX_INVALID = 255 // Invalid transform size
199 } UENUM1BYTE(TX_SIZE);
200
201 #define TX_SIZE_LUMA_MIN (TX_4X4)
202 /* We don't need to code a transform size unless the allowed size is at least
203 one more than the minimum. */
204 #define TX_SIZE_CTX_MIN (TX_SIZE_LUMA_MIN + 1)
205
206 // Maximum tx_size categories
207 #define MAX_TX_CATS (TX_SIZES - TX_SIZE_CTX_MIN)
208 #define MAX_TX_DEPTH 2
209
210 #define MAX_TX_SIZE_LOG2 (6)
211 #define MAX_TX_SIZE (1 << MAX_TX_SIZE_LOG2)
212 #define MIN_TX_SIZE_LOG2 2
213 #define MIN_TX_SIZE (1 << MIN_TX_SIZE_LOG2)
214 #define MAX_TX_SQUARE (MAX_TX_SIZE * MAX_TX_SIZE)
215
216 // Pad 4 extra columns to remove horizontal availability check.
217 #define TX_PAD_HOR_LOG2 2
218 #define TX_PAD_HOR 4
219 // Pad 6 extra rows (2 on top and 4 on bottom) to remove vertical availability
220 // check.
221 #define TX_PAD_TOP 0
222 #define TX_PAD_BOTTOM 4
223 #define TX_PAD_VER (TX_PAD_TOP + TX_PAD_BOTTOM)
224 // Pad 16 extra bytes to avoid reading overflow in SIMD optimization.
225 #define TX_PAD_END 16
226 #define TX_PAD_2D ((32 + TX_PAD_HOR) * (32 + TX_PAD_VER) + TX_PAD_END)
227
228 // Number of maxium size transform blocks in the maximum size superblock
229 #define MAX_TX_BLOCKS_IN_MAX_SB_LOG2 ((MAX_SB_SIZE_LOG2 - MAX_TX_SIZE_LOG2) * 2)
230 #define MAX_TX_BLOCKS_IN_MAX_SB (1 << MAX_TX_BLOCKS_IN_MAX_SB_LOG2)
231
232 // frame transform mode
233 enum {
234 ONLY_4X4, // use only 4x4 transform
235 TX_MODE_LARGEST, // transform size is the largest possible for pu size
236 TX_MODE_SELECT, // transform specified for each block
237 TX_MODES,
238 } UENUM1BYTE(TX_MODE);
239
240 // 1D tx types
241 enum {
242 DCT_1D,
243 ADST_1D,
244 FLIPADST_1D,
245 IDTX_1D,
246 TX_TYPES_1D,
247 } UENUM1BYTE(TX_TYPE_1D);
248
249 enum {
250 DCT_DCT, // DCT in both horizontal and vertical
251 ADST_DCT, // ADST in vertical, DCT in horizontal
252 DCT_ADST, // DCT in vertical, ADST in horizontal
253 ADST_ADST, // ADST in both directions
254 FLIPADST_DCT, // FLIPADST in vertical, DCT in horizontal
255 DCT_FLIPADST, // DCT in vertical, FLIPADST in horizontal
256 FLIPADST_FLIPADST, // FLIPADST in both directions
257 ADST_FLIPADST, // ADST in vertical, FLIPADST in horizontal
258 FLIPADST_ADST, // FLIPADST in vertical, ADST in horizontal
259 IDTX, // Identity in both directions
260 V_DCT, // DCT in vertical, identity in horizontal
261 H_DCT, // Identity in vertical, DCT in horizontal
262 V_ADST, // ADST in vertical, identity in horizontal
263 H_ADST, // Identity in vertical, ADST in horizontal
264 V_FLIPADST, // FLIPADST in vertical, identity in horizontal
265 H_FLIPADST, // Identity in vertical, FLIPADST in horizontal
266 TX_TYPES,
267 DCT_ADST_TX_MASK = 0x000F, // Either DCT or ADST in each direction
268 } UENUM1BYTE(TX_TYPE);
269
270 enum {
271 REG_REG,
272 REG_SMOOTH,
273 REG_SHARP,
274 SMOOTH_REG,
275 SMOOTH_SMOOTH,
276 SMOOTH_SHARP,
277 SHARP_REG,
278 SHARP_SMOOTH,
279 SHARP_SHARP,
280 } UENUM1BYTE(DUAL_FILTER_TYPE);
281
282 enum {
283 // DCT only
284 EXT_TX_SET_DCTONLY,
285 // DCT + Identity only
286 EXT_TX_SET_DCT_IDTX,
287 // Discrete Trig transforms w/o flip (4) + Identity (1)
288 EXT_TX_SET_DTT4_IDTX,
289 // Discrete Trig transforms w/o flip (4) + Identity (1) + 1D Hor/vert DCT (2)
290 EXT_TX_SET_DTT4_IDTX_1DDCT,
291 // Discrete Trig transforms w/ flip (9) + Identity (1) + 1D Hor/Ver DCT (2)
292 EXT_TX_SET_DTT9_IDTX_1DDCT,
293 // Discrete Trig transforms w/ flip (9) + Identity (1) + 1D Hor/Ver (6)
294 EXT_TX_SET_ALL16,
295 EXT_TX_SET_TYPES
296 } UENUM1BYTE(TxSetType);
297
298 #define EXT_TX_SIZES 4 // number of sizes that use extended transforms
299 #define EXT_TX_SETS_INTER 4 // Sets of transform selections for INTER
300 #define EXT_TX_SETS_INTRA 3 // Sets of transform selections for INTRA
301
302 enum {
303 AOM_LAST_FLAG = 1 << 0,
304 AOM_LAST2_FLAG = 1 << 1,
305 AOM_LAST3_FLAG = 1 << 2,
306 AOM_GOLD_FLAG = 1 << 3,
307 AOM_BWD_FLAG = 1 << 4,
308 AOM_ALT2_FLAG = 1 << 5,
309 AOM_ALT_FLAG = 1 << 6,
310 AOM_REFFRAME_ALL = (1 << 7) - 1
311 } UENUM1BYTE(AOM_REFFRAME);
312
313 enum {
314 UNIDIR_COMP_REFERENCE,
315 BIDIR_COMP_REFERENCE,
316 COMP_REFERENCE_TYPES,
317 } UENUM1BYTE(COMP_REFERENCE_TYPE);
318
319 enum { PLANE_TYPE_Y, PLANE_TYPE_UV, PLANE_TYPES } UENUM1BYTE(PLANE_TYPE);
320
321 #define CFL_ALPHABET_SIZE_LOG2 4
322 #define CFL_ALPHABET_SIZE (1 << CFL_ALPHABET_SIZE_LOG2)
323 #define CFL_MAGS_SIZE ((2 << CFL_ALPHABET_SIZE_LOG2) + 1)
324 #define CFL_INDEX_ZERO CFL_ALPHABET_SIZE
325 #define CFL_IDX_U(idx) (idx >> CFL_ALPHABET_SIZE_LOG2)
326 #define CFL_IDX_V(idx) (idx & (CFL_ALPHABET_SIZE - 1))
327
328 enum { CFL_PRED_U, CFL_PRED_V, CFL_PRED_PLANES } UENUM1BYTE(CFL_PRED_TYPE);
329
330 enum {
331 CFL_SIGN_ZERO,
332 CFL_SIGN_NEG,
333 CFL_SIGN_POS,
334 CFL_SIGNS
335 } UENUM1BYTE(CFL_SIGN_TYPE);
336
337 enum {
338 CFL_DISALLOWED,
339 CFL_ALLOWED,
340 CFL_ALLOWED_TYPES
341 } UENUM1BYTE(CFL_ALLOWED_TYPE);
342
343 // CFL_SIGN_ZERO,CFL_SIGN_ZERO is invalid
344 #define CFL_JOINT_SIGNS (CFL_SIGNS * CFL_SIGNS - 1)
345 // CFL_SIGN_U is equivalent to (js + 1) / 3 for js in 0 to 8
346 #define CFL_SIGN_U(js) (((js + 1) * 11) >> 5)
347 // CFL_SIGN_V is equivalent to (js + 1) % 3 for js in 0 to 8
348 #define CFL_SIGN_V(js) ((js + 1) - CFL_SIGNS * CFL_SIGN_U(js))
349
350 // There is no context when the alpha for a given plane is zero.
351 // So there are 2 fewer contexts than joint signs.
352 #define CFL_ALPHA_CONTEXTS (CFL_JOINT_SIGNS + 1 - CFL_SIGNS)
353 #define CFL_CONTEXT_U(js) (js + 1 - CFL_SIGNS)
354 // Also, the contexts are symmetric under swapping the planes.
355 #define CFL_CONTEXT_V(js) \
356 (CFL_SIGN_V(js) * CFL_SIGNS + CFL_SIGN_U(js) - CFL_SIGNS)
357
358 enum {
359 PALETTE_MAP,
360 COLOR_MAP_TYPES,
361 } UENUM1BYTE(COLOR_MAP_TYPE);
362
363 enum {
364 TWO_COLORS,
365 THREE_COLORS,
366 FOUR_COLORS,
367 FIVE_COLORS,
368 SIX_COLORS,
369 SEVEN_COLORS,
370 EIGHT_COLORS,
371 PALETTE_SIZES
372 } UENUM1BYTE(PALETTE_SIZE);
373
374 enum {
375 PALETTE_COLOR_ONE,
376 PALETTE_COLOR_TWO,
377 PALETTE_COLOR_THREE,
378 PALETTE_COLOR_FOUR,
379 PALETTE_COLOR_FIVE,
380 PALETTE_COLOR_SIX,
381 PALETTE_COLOR_SEVEN,
382 PALETTE_COLOR_EIGHT,
383 PALETTE_COLORS
384 } UENUM1BYTE(PALETTE_COLOR);
385
386 // Note: All directional predictors must be between V_PRED and D67_PRED (both
387 // inclusive).
388 enum {
389 DC_PRED, // Average of above and left pixels
390 V_PRED, // Vertical
391 H_PRED, // Horizontal
392 D45_PRED, // Directional 45 degree
393 D135_PRED, // Directional 135 degree
394 D113_PRED, // Directional 113 degree
395 D157_PRED, // Directional 157 degree
396 D203_PRED, // Directional 203 degree
397 D67_PRED, // Directional 67 degree
398 SMOOTH_PRED, // Combination of horizontal and vertical interpolation
399 SMOOTH_V_PRED, // Vertical interpolation
400 SMOOTH_H_PRED, // Horizontal interpolation
401 PAETH_PRED, // Predict from the direction of smallest gradient
402 NEARESTMV,
403 NEARMV,
404 GLOBALMV,
405 NEWMV,
406 // Compound ref compound modes
407 NEAREST_NEARESTMV,
408 NEAR_NEARMV,
409 NEAREST_NEWMV,
410 NEW_NEARESTMV,
411 NEAR_NEWMV,
412 NEW_NEARMV,
413 GLOBAL_GLOBALMV,
414 NEW_NEWMV,
415 MB_MODE_COUNT,
416 PRED_MODE_INVALID = MB_MODE_COUNT,
417 INTRA_MODE_START = DC_PRED,
418 INTRA_MODE_END = NEARESTMV,
419 DIR_MODE_START = V_PRED,
420 DIR_MODE_END = D67_PRED + 1,
421 INTRA_MODE_NUM = INTRA_MODE_END - INTRA_MODE_START,
422 SINGLE_INTER_MODE_START = NEARESTMV,
423 SINGLE_INTER_MODE_END = NEAREST_NEARESTMV,
424 SINGLE_INTER_MODE_NUM = SINGLE_INTER_MODE_END - SINGLE_INTER_MODE_START,
425 COMP_INTER_MODE_START = NEAREST_NEARESTMV,
426 COMP_INTER_MODE_END = MB_MODE_COUNT,
427 COMP_INTER_MODE_NUM = COMP_INTER_MODE_END - COMP_INTER_MODE_START,
428 INTER_MODE_START = NEARESTMV,
429 INTER_MODE_END = MB_MODE_COUNT,
430 INTRA_MODES = PAETH_PRED + 1, // PAETH_PRED has to be the last intra mode.
431 INTRA_INVALID = MB_MODE_COUNT // For uv_mode in inter blocks
432 } UENUM1BYTE(PREDICTION_MODE);
433
434 // TODO(ltrudeau) Do we really want to pack this?
435 // TODO(ltrudeau) Do we match with PREDICTION_MODE?
436 enum {
437 UV_DC_PRED, // Average of above and left pixels
438 UV_V_PRED, // Vertical
439 UV_H_PRED, // Horizontal
440 UV_D45_PRED, // Directional 45 degree
441 UV_D135_PRED, // Directional 135 degree
442 UV_D113_PRED, // Directional 113 degree
443 UV_D157_PRED, // Directional 157 degree
444 UV_D203_PRED, // Directional 203 degree
445 UV_D67_PRED, // Directional 67 degree
446 UV_SMOOTH_PRED, // Combination of horizontal and vertical interpolation
447 UV_SMOOTH_V_PRED, // Vertical interpolation
448 UV_SMOOTH_H_PRED, // Horizontal interpolation
449 UV_PAETH_PRED, // Predict from the direction of smallest gradient
450 UV_CFL_PRED, // Chroma-from-Luma
451 UV_INTRA_MODES,
452 UV_MODE_INVALID, // For uv_mode in inter blocks
453 } UENUM1BYTE(UV_PREDICTION_MODE);
454
455 enum {
456 SIMPLE_TRANSLATION,
457 OBMC_CAUSAL, // 2-sided OBMC
458 WARPED_CAUSAL, // 2-sided WARPED
459 MOTION_MODES
460 } UENUM1BYTE(MOTION_MODE);
461
462 enum {
463 II_DC_PRED,
464 II_V_PRED,
465 II_H_PRED,
466 II_SMOOTH_PRED,
467 INTERINTRA_MODES
468 } UENUM1BYTE(INTERINTRA_MODE);
469
470 enum {
471 COMPOUND_AVERAGE,
472 COMPOUND_DISTWTD,
473 COMPOUND_WEDGE,
474 COMPOUND_DIFFWTD,
475 COMPOUND_TYPES,
476 MASKED_COMPOUND_TYPES = 2,
477 } UENUM1BYTE(COMPOUND_TYPE);
478
479 enum {
480 FILTER_DC_PRED,
481 FILTER_V_PRED,
482 FILTER_H_PRED,
483 FILTER_D157_PRED,
484 FILTER_PAETH_PRED,
485 FILTER_INTRA_MODES,
486 } UENUM1BYTE(FILTER_INTRA_MODE);
487
488 enum {
489 SEQ_LEVEL_2_0,
490 SEQ_LEVEL_2_1,
491 SEQ_LEVEL_2_2,
492 SEQ_LEVEL_2_3,
493 SEQ_LEVEL_3_0,
494 SEQ_LEVEL_3_1,
495 SEQ_LEVEL_3_2,
496 SEQ_LEVEL_3_3,
497 SEQ_LEVEL_4_0,
498 SEQ_LEVEL_4_1,
499 SEQ_LEVEL_4_2,
500 SEQ_LEVEL_4_3,
501 SEQ_LEVEL_5_0,
502 SEQ_LEVEL_5_1,
503 SEQ_LEVEL_5_2,
504 SEQ_LEVEL_5_3,
505 SEQ_LEVEL_6_0,
506 SEQ_LEVEL_6_1,
507 SEQ_LEVEL_6_2,
508 SEQ_LEVEL_6_3,
509 SEQ_LEVEL_7_0,
510 SEQ_LEVEL_7_1,
511 SEQ_LEVEL_7_2,
512 SEQ_LEVEL_7_3,
513 SEQ_LEVELS,
514 SEQ_LEVEL_MAX = 31
515 } UENUM1BYTE(AV1_LEVEL);
516
517 #define LEVEL_BITS 5
518
519 #define DIRECTIONAL_MODES 8
520 #define MAX_ANGLE_DELTA 3
521 #define ANGLE_STEP 3
522
523 #define INTER_MODES (1 + NEWMV - NEARESTMV)
524
525 #define INTER_COMPOUND_MODES (1 + NEW_NEWMV - NEAREST_NEARESTMV)
526
527 #define SKIP_CONTEXTS 3
528 #define SKIP_MODE_CONTEXTS 3
529
530 #define COMP_INDEX_CONTEXTS 6
531 #define COMP_GROUP_IDX_CONTEXTS 6
532
533 #define NMV_CONTEXTS 3
534
535 #define NEWMV_MODE_CONTEXTS 6
536 #define GLOBALMV_MODE_CONTEXTS 2
537 #define REFMV_MODE_CONTEXTS 6
538 #define DRL_MODE_CONTEXTS 3
539
540 #define GLOBALMV_OFFSET 3
541 #define REFMV_OFFSET 4
542
543 #define NEWMV_CTX_MASK ((1 << GLOBALMV_OFFSET) - 1)
544 #define GLOBALMV_CTX_MASK ((1 << (REFMV_OFFSET - GLOBALMV_OFFSET)) - 1)
545 #define REFMV_CTX_MASK ((1 << (8 - REFMV_OFFSET)) - 1)
546
547 #define COMP_NEWMV_CTXS 5
548 #define INTER_MODE_CONTEXTS 8
549
550 #define DELTA_Q_SMALL 3
551 #define DELTA_Q_PROBS (DELTA_Q_SMALL)
552 #define DEFAULT_DELTA_Q_RES_PERCEPTUAL 4
553 #define DEFAULT_DELTA_Q_RES_OBJECTIVE 4
554
555 #define DELTA_LF_SMALL 3
556 #define DELTA_LF_PROBS (DELTA_LF_SMALL)
557 #define DEFAULT_DELTA_LF_RES 2
558
559 /* Segment Feature Masks */
560 #define MAX_MV_REF_CANDIDATES 2
561
562 #define MAX_REF_MV_STACK_SIZE 8
563 #define USABLE_REF_MV_STACK_SIZE 4
564 #define REF_CAT_LEVEL 640
565
566 #define INTRA_INTER_CONTEXTS 4
567 #define COMP_INTER_CONTEXTS 5
568 #define REF_CONTEXTS 3
569
570 #define COMP_REF_TYPE_CONTEXTS 5
571 #define UNI_COMP_REF_CONTEXTS 3
572
573 #define TXFM_PARTITION_CONTEXTS ((TX_SIZES - TX_8X8) * 6 - 3)
574 typedef uint8_t TXFM_CONTEXT;
575
576 // An enum for single reference types (and some derived values).
577 enum {
578 NONE_FRAME = -1,
579 INTRA_FRAME,
580 LAST_FRAME,
581 LAST2_FRAME,
582 LAST3_FRAME,
583 GOLDEN_FRAME,
584 BWDREF_FRAME,
585 ALTREF2_FRAME,
586 ALTREF_FRAME,
587 REF_FRAMES,
588
589 // Extra/scratch reference frame. It may be:
590 // - used to update the ALTREF2_FRAME ref (see lshift_bwd_ref_frames()), or
591 // - updated from ALTREF2_FRAME ref (see rshift_bwd_ref_frames()).
592 EXTREF_FRAME = REF_FRAMES,
593
594 // Number of inter (non-intra) reference types.
595 INTER_REFS_PER_FRAME = ALTREF_FRAME - LAST_FRAME + 1,
596
597 // Number of forward (aka past) reference types.
598 FWD_REFS = GOLDEN_FRAME - LAST_FRAME + 1,
599
600 // Number of backward (aka future) reference types.
601 BWD_REFS = ALTREF_FRAME - BWDREF_FRAME + 1,
602
603 SINGLE_REFS = FWD_REFS + BWD_REFS,
604 };
605
606 #define REF_FRAMES_LOG2 3
607
608 // REF_FRAMES for the cm->ref_frame_map array, 1 scratch frame for the new
609 // frame in cm->cur_frame, INTER_REFS_PER_FRAME for scaled references on the
610 // encoder in the cpi->scaled_ref_buf array.
611 #define FRAME_BUFFERS (REF_FRAMES + 1 + INTER_REFS_PER_FRAME)
612
613 #define FWD_RF_OFFSET(ref) (ref - LAST_FRAME)
614 #define BWD_RF_OFFSET(ref) (ref - BWDREF_FRAME)
615
616 enum {
617 LAST_LAST2_FRAMES, // { LAST_FRAME, LAST2_FRAME }
618 LAST_LAST3_FRAMES, // { LAST_FRAME, LAST3_FRAME }
619 LAST_GOLDEN_FRAMES, // { LAST_FRAME, GOLDEN_FRAME }
620 BWDREF_ALTREF_FRAMES, // { BWDREF_FRAME, ALTREF_FRAME }
621 LAST2_LAST3_FRAMES, // { LAST2_FRAME, LAST3_FRAME }
622 LAST2_GOLDEN_FRAMES, // { LAST2_FRAME, GOLDEN_FRAME }
623 LAST3_GOLDEN_FRAMES, // { LAST3_FRAME, GOLDEN_FRAME }
624 BWDREF_ALTREF2_FRAMES, // { BWDREF_FRAME, ALTREF2_FRAME }
625 ALTREF2_ALTREF_FRAMES, // { ALTREF2_FRAME, ALTREF_FRAME }
626 TOTAL_UNIDIR_COMP_REFS,
627 // NOTE: UNIDIR_COMP_REFS is the number of uni-directional reference pairs
628 // that are explicitly signaled.
629 UNIDIR_COMP_REFS = BWDREF_ALTREF_FRAMES + 1,
630 } UENUM1BYTE(UNIDIR_COMP_REF);
631
632 #define TOTAL_COMP_REFS (FWD_REFS * BWD_REFS + TOTAL_UNIDIR_COMP_REFS)
633
634 #define COMP_REFS (FWD_REFS * BWD_REFS + UNIDIR_COMP_REFS)
635
636 // NOTE: A limited number of unidirectional reference pairs can be signalled for
637 // compound prediction. The use of skip mode, on the other hand, makes it
638 // possible to have a reference pair not listed for explicit signaling.
639 #define MODE_CTX_REF_FRAMES (REF_FRAMES + TOTAL_COMP_REFS)
640
641 // Note: It includes single and compound references. So, it can take values from
642 // NONE_FRAME to (MODE_CTX_REF_FRAMES - 1). Hence, it is not defined as an enum.
643 typedef int8_t MV_REFERENCE_FRAME;
644
650 typedef enum {
651 RESTORE_NONE,
652 RESTORE_WIENER,
653 RESTORE_SGRPROJ,
654 RESTORE_SWITCHABLE,
655 RESTORE_SWITCHABLE_TYPES = RESTORE_SWITCHABLE,
656 RESTORE_TYPES = 4,
657 } RestorationType;
658
660 // Picture prediction structures (0-12 are predefined) in scalability metadata.
661 enum {
662 SCALABILITY_L1T2 = 0,
663 SCALABILITY_L1T3 = 1,
664 SCALABILITY_L2T1 = 2,
665 SCALABILITY_L2T2 = 3,
666 SCALABILITY_L2T3 = 4,
667 SCALABILITY_S2T1 = 5,
668 SCALABILITY_S2T2 = 6,
669 SCALABILITY_S2T3 = 7,
670 SCALABILITY_L2T1h = 8,
671 SCALABILITY_L2T2h = 9,
672 SCALABILITY_L2T3h = 10,
673 SCALABILITY_S2T1h = 11,
674 SCALABILITY_S2T2h = 12,
675 SCALABILITY_S2T3h = 13,
676 SCALABILITY_SS = 14
677 } UENUM1BYTE(SCALABILITY_STRUCTURES);
678
679 #define SUPERRES_SCALE_BITS 3
680 #define SUPERRES_SCALE_DENOMINATOR_MIN (SCALE_NUMERATOR + 1)
681
682 // In large_scale_tile coding, external references are used.
683 #define MAX_EXTERNAL_REFERENCES 128
684 #define MAX_TILES 512
685
688 #ifdef __cplusplus
689 } // extern "C"
690 #endif
691
692 #endif // AOM_AV1_COMMON_ENUMS_H_
aom_codec.h
Describes the codec algorithm interface to applications.
RestorationType
RestorationType
This enumeration defines various restoration types supported.
Definition: enums.h:650
RESTORE_NONE
@ RESTORE_NONE
Definition: enums.h:651
RESTORE_SWITCHABLE_TYPES
@ RESTORE_SWITCHABLE_TYPES
Definition: enums.h:655
RESTORE_SWITCHABLE
@ RESTORE_SWITCHABLE
Definition: enums.h:654
RESTORE_TYPES
@ RESTORE_TYPES
Definition: enums.h:656
RESTORE_SGRPROJ
@ RESTORE_SGRPROJ
Definition: enums.h:653
RESTORE_WIENER
@ RESTORE_WIENER
Definition: enums.h:652
ATTRIBUTE_PACKED
#define ATTRIBUTE_PACKED
Decorator indicating that given struct/union/enum is packed.
Definition: aom_codec.h:140