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