1*77c1e3ccSAndroid Build Coastguard Worker /* 2*77c1e3ccSAndroid Build Coastguard Worker * Copyright (c) 2016, Alliance for Open Media. All rights reserved. 3*77c1e3ccSAndroid Build Coastguard Worker * 4*77c1e3ccSAndroid Build Coastguard Worker * This source code is subject to the terms of the BSD 2 Clause License and 5*77c1e3ccSAndroid Build Coastguard Worker * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License 6*77c1e3ccSAndroid Build Coastguard Worker * was not distributed with this source code in the LICENSE file, you can 7*77c1e3ccSAndroid Build Coastguard Worker * obtain it at www.aomedia.org/license/software. If the Alliance for Open 8*77c1e3ccSAndroid Build Coastguard Worker * Media Patent License 1.0 was not distributed with this source code in the 9*77c1e3ccSAndroid Build Coastguard Worker * PATENTS file, you can obtain it at www.aomedia.org/license/patent. 10*77c1e3ccSAndroid Build Coastguard Worker */ 11*77c1e3ccSAndroid Build Coastguard Worker 12*77c1e3ccSAndroid Build Coastguard Worker #ifndef AOM_AV1_COMMON_COMMON_DATA_H_ 13*77c1e3ccSAndroid Build Coastguard Worker #define AOM_AV1_COMMON_COMMON_DATA_H_ 14*77c1e3ccSAndroid Build Coastguard Worker 15*77c1e3ccSAndroid Build Coastguard Worker #include "av1/common/enums.h" 16*77c1e3ccSAndroid Build Coastguard Worker #include "aom/aom_integer.h" 17*77c1e3ccSAndroid Build Coastguard Worker #include "aom_dsp/aom_dsp_common.h" 18*77c1e3ccSAndroid Build Coastguard Worker 19*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus 20*77c1e3ccSAndroid Build Coastguard Worker extern "C" { 21*77c1e3ccSAndroid Build Coastguard Worker #endif 22*77c1e3ccSAndroid Build Coastguard Worker 23*77c1e3ccSAndroid Build Coastguard Worker // Log 2 conversion lookup tables in units of mode info (4x4). 24*77c1e3ccSAndroid Build Coastguard Worker // The Mi_Width_Log2 table in the spec (Section 9.3. Conversion tables). 25*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t mi_size_wide_log2[BLOCK_SIZES_ALL] = { 26*77c1e3ccSAndroid Build Coastguard Worker 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 0, 2, 1, 3, 2, 4 27*77c1e3ccSAndroid Build Coastguard Worker }; 28*77c1e3ccSAndroid Build Coastguard Worker // The Mi_Height_Log2 table in the spec (Section 9.3. Conversion tables). 29*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t mi_size_high_log2[BLOCK_SIZES_ALL] = { 30*77c1e3ccSAndroid Build Coastguard Worker 0, 1, 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 2, 0, 3, 1, 4, 2 31*77c1e3ccSAndroid Build Coastguard Worker }; 32*77c1e3ccSAndroid Build Coastguard Worker 33*77c1e3ccSAndroid Build Coastguard Worker // Width/height lookup tables in units of mode info (4x4). 34*77c1e3ccSAndroid Build Coastguard Worker // The Num_4x4_Blocks_Wide table in the spec (Section 9.3. Conversion tables). 35*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t mi_size_wide[BLOCK_SIZES_ALL] = { 36*77c1e3ccSAndroid Build Coastguard Worker 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 1, 4, 2, 8, 4, 16 37*77c1e3ccSAndroid Build Coastguard Worker }; 38*77c1e3ccSAndroid Build Coastguard Worker 39*77c1e3ccSAndroid Build Coastguard Worker // The Num_4x4_Blocks_High table in the spec (Section 9.3. Conversion tables). 40*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t mi_size_high[BLOCK_SIZES_ALL] = { 41*77c1e3ccSAndroid Build Coastguard Worker 1, 2, 1, 2, 4, 2, 4, 8, 4, 8, 16, 8, 16, 32, 16, 32, 4, 1, 8, 2, 16, 4 42*77c1e3ccSAndroid Build Coastguard Worker }; 43*77c1e3ccSAndroid Build Coastguard Worker 44*77c1e3ccSAndroid Build Coastguard Worker // Width/height lookup tables in units of samples. 45*77c1e3ccSAndroid Build Coastguard Worker // The Block_Width table in the spec (Section 9.3. Conversion tables). 46*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t block_size_wide[BLOCK_SIZES_ALL] = { 47*77c1e3ccSAndroid Build Coastguard Worker 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 48*77c1e3ccSAndroid Build Coastguard Worker 64, 64, 64, 128, 128, 4, 16, 8, 32, 16, 64 49*77c1e3ccSAndroid Build Coastguard Worker }; 50*77c1e3ccSAndroid Build Coastguard Worker 51*77c1e3ccSAndroid Build Coastguard Worker // The Block_Height table in the spec (Section 9.3. Conversion tables). 52*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t block_size_high[BLOCK_SIZES_ALL] = { 53*77c1e3ccSAndroid Build Coastguard Worker 4, 8, 4, 8, 16, 8, 16, 32, 16, 32, 64, 54*77c1e3ccSAndroid Build Coastguard Worker 32, 64, 128, 64, 128, 16, 4, 32, 8, 64, 16 55*77c1e3ccSAndroid Build Coastguard Worker }; 56*77c1e3ccSAndroid Build Coastguard Worker 57*77c1e3ccSAndroid Build Coastguard Worker // Maps a block size to a context. 58*77c1e3ccSAndroid Build Coastguard Worker // The Size_Group table in the spec (Section 9.3. Conversion tables). 59*77c1e3ccSAndroid Build Coastguard Worker // AOMMIN(3, AOMMIN(mi_size_wide_log2(bsize), mi_size_high_log2(bsize))) 60*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t size_group_lookup[BLOCK_SIZES_ALL] = { 61*77c1e3ccSAndroid Build Coastguard Worker 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 0, 0, 1, 1, 2, 2 62*77c1e3ccSAndroid Build Coastguard Worker }; 63*77c1e3ccSAndroid Build Coastguard Worker 64*77c1e3ccSAndroid Build Coastguard Worker static const uint8_t num_pels_log2_lookup[BLOCK_SIZES_ALL] = { 65*77c1e3ccSAndroid Build Coastguard Worker 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 11, 12, 13, 13, 14, 6, 6, 8, 8, 10, 10 66*77c1e3ccSAndroid Build Coastguard Worker }; 67*77c1e3ccSAndroid Build Coastguard Worker 68*77c1e3ccSAndroid Build Coastguard Worker // A compressed version of the Partition_Subsize table in the spec (9.3. 69*77c1e3ccSAndroid Build Coastguard Worker // Conversion tables), for square block sizes only. 70*77c1e3ccSAndroid Build Coastguard Worker /* clang-format off */ 71*77c1e3ccSAndroid Build Coastguard Worker static const BLOCK_SIZE subsize_lookup[EXT_PARTITION_TYPES][SQR_BLOCK_SIZES] = { 72*77c1e3ccSAndroid Build Coastguard Worker { // PARTITION_NONE 73*77c1e3ccSAndroid Build Coastguard Worker BLOCK_4X4, BLOCK_8X8, BLOCK_16X16, 74*77c1e3ccSAndroid Build Coastguard Worker BLOCK_32X32, BLOCK_64X64, BLOCK_128X128 75*77c1e3ccSAndroid Build Coastguard Worker }, { // PARTITION_HORZ 76*77c1e3ccSAndroid Build Coastguard Worker BLOCK_INVALID, BLOCK_8X4, BLOCK_16X8, 77*77c1e3ccSAndroid Build Coastguard Worker BLOCK_32X16, BLOCK_64X32, BLOCK_128X64 78*77c1e3ccSAndroid Build Coastguard Worker }, { // PARTITION_VERT 79*77c1e3ccSAndroid Build Coastguard Worker BLOCK_INVALID, BLOCK_4X8, BLOCK_8X16, 80*77c1e3ccSAndroid Build Coastguard Worker BLOCK_16X32, BLOCK_32X64, BLOCK_64X128 81*77c1e3ccSAndroid Build Coastguard Worker }, { // PARTITION_SPLIT 82*77c1e3ccSAndroid Build Coastguard Worker BLOCK_INVALID, BLOCK_4X4, BLOCK_8X8, 83*77c1e3ccSAndroid Build Coastguard Worker BLOCK_16X16, BLOCK_32X32, BLOCK_64X64 84*77c1e3ccSAndroid Build Coastguard Worker }, { // PARTITION_HORZ_A 85*77c1e3ccSAndroid Build Coastguard Worker BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X8, 86*77c1e3ccSAndroid Build Coastguard Worker BLOCK_32X16, BLOCK_64X32, BLOCK_128X64 87*77c1e3ccSAndroid Build Coastguard Worker }, { // PARTITION_HORZ_B 88*77c1e3ccSAndroid Build Coastguard Worker BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X8, 89*77c1e3ccSAndroid Build Coastguard Worker BLOCK_32X16, BLOCK_64X32, BLOCK_128X64 90*77c1e3ccSAndroid Build Coastguard Worker }, { // PARTITION_VERT_A 91*77c1e3ccSAndroid Build Coastguard Worker BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X16, 92*77c1e3ccSAndroid Build Coastguard Worker BLOCK_16X32, BLOCK_32X64, BLOCK_64X128 93*77c1e3ccSAndroid Build Coastguard Worker }, { // PARTITION_VERT_B 94*77c1e3ccSAndroid Build Coastguard Worker BLOCK_INVALID, BLOCK_INVALID, BLOCK_8X16, 95*77c1e3ccSAndroid Build Coastguard Worker BLOCK_16X32, BLOCK_32X64, BLOCK_64X128 96*77c1e3ccSAndroid Build Coastguard Worker }, { // PARTITION_HORZ_4 97*77c1e3ccSAndroid Build Coastguard Worker BLOCK_INVALID, BLOCK_INVALID, BLOCK_16X4, 98*77c1e3ccSAndroid Build Coastguard Worker BLOCK_32X8, BLOCK_64X16, BLOCK_INVALID 99*77c1e3ccSAndroid Build Coastguard Worker }, { // PARTITION_VERT_4 100*77c1e3ccSAndroid Build Coastguard Worker BLOCK_INVALID, BLOCK_INVALID, BLOCK_4X16, 101*77c1e3ccSAndroid Build Coastguard Worker BLOCK_8X32, BLOCK_16X64, BLOCK_INVALID 102*77c1e3ccSAndroid Build Coastguard Worker } 103*77c1e3ccSAndroid Build Coastguard Worker }; 104*77c1e3ccSAndroid Build Coastguard Worker 105*77c1e3ccSAndroid Build Coastguard Worker static const TX_SIZE max_txsize_lookup[BLOCK_SIZES_ALL] = { 106*77c1e3ccSAndroid Build Coastguard Worker // 4X4 107*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, 108*77c1e3ccSAndroid Build Coastguard Worker // 4X8, 8X4, 8X8 109*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, TX_4X4, TX_8X8, 110*77c1e3ccSAndroid Build Coastguard Worker // 8X16, 16X8, 16X16 111*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, TX_8X8, TX_16X16, 112*77c1e3ccSAndroid Build Coastguard Worker // 16X32, 32X16, 32X32 113*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, TX_16X16, TX_32X32, 114*77c1e3ccSAndroid Build Coastguard Worker // 32X64, 64X32, 115*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, TX_32X32, 116*77c1e3ccSAndroid Build Coastguard Worker // 64X64 117*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, 118*77c1e3ccSAndroid Build Coastguard Worker // 64x128, 128x64, 128x128 119*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, TX_64X64, TX_64X64, 120*77c1e3ccSAndroid Build Coastguard Worker // 4x16, 16x4, 8x32 121*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, TX_4X4, TX_8X8, 122*77c1e3ccSAndroid Build Coastguard Worker // 32x8, 16x64 64x16 123*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, TX_16X16, TX_16X16 124*77c1e3ccSAndroid Build Coastguard Worker }; 125*77c1e3ccSAndroid Build Coastguard Worker 126*77c1e3ccSAndroid Build Coastguard Worker static const TX_SIZE max_txsize_rect_lookup[BLOCK_SIZES_ALL] = { 127*77c1e3ccSAndroid Build Coastguard Worker // 4X4 128*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, 129*77c1e3ccSAndroid Build Coastguard Worker // 4X8, 8X4, 8X8 130*77c1e3ccSAndroid Build Coastguard Worker TX_4X8, TX_8X4, TX_8X8, 131*77c1e3ccSAndroid Build Coastguard Worker // 8X16, 16X8, 16X16 132*77c1e3ccSAndroid Build Coastguard Worker TX_8X16, TX_16X8, TX_16X16, 133*77c1e3ccSAndroid Build Coastguard Worker // 16X32, 32X16, 32X32 134*77c1e3ccSAndroid Build Coastguard Worker TX_16X32, TX_32X16, TX_32X32, 135*77c1e3ccSAndroid Build Coastguard Worker // 32X64, 64X32, 136*77c1e3ccSAndroid Build Coastguard Worker TX_32X64, TX_64X32, 137*77c1e3ccSAndroid Build Coastguard Worker // 64X64 138*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, 139*77c1e3ccSAndroid Build Coastguard Worker // 64x128, 128x64, 128x128 140*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, TX_64X64, TX_64X64, 141*77c1e3ccSAndroid Build Coastguard Worker // 4x16, 16x4, 142*77c1e3ccSAndroid Build Coastguard Worker TX_4X16, TX_16X4, 143*77c1e3ccSAndroid Build Coastguard Worker // 8x32, 32x8 144*77c1e3ccSAndroid Build Coastguard Worker TX_8X32, TX_32X8, 145*77c1e3ccSAndroid Build Coastguard Worker // 16x64, 64x16 146*77c1e3ccSAndroid Build Coastguard Worker TX_16X64, TX_64X16 147*77c1e3ccSAndroid Build Coastguard Worker }; 148*77c1e3ccSAndroid Build Coastguard Worker 149*77c1e3ccSAndroid Build Coastguard Worker static const TX_TYPE_1D vtx_tab[TX_TYPES] = { 150*77c1e3ccSAndroid Build Coastguard Worker DCT_1D, ADST_1D, DCT_1D, ADST_1D, 151*77c1e3ccSAndroid Build Coastguard Worker FLIPADST_1D, DCT_1D, FLIPADST_1D, ADST_1D, FLIPADST_1D, IDTX_1D, 152*77c1e3ccSAndroid Build Coastguard Worker DCT_1D, IDTX_1D, ADST_1D, IDTX_1D, FLIPADST_1D, IDTX_1D, 153*77c1e3ccSAndroid Build Coastguard Worker }; 154*77c1e3ccSAndroid Build Coastguard Worker 155*77c1e3ccSAndroid Build Coastguard Worker static const TX_TYPE_1D htx_tab[TX_TYPES] = { 156*77c1e3ccSAndroid Build Coastguard Worker DCT_1D, DCT_1D, ADST_1D, ADST_1D, 157*77c1e3ccSAndroid Build Coastguard Worker DCT_1D, FLIPADST_1D, FLIPADST_1D, FLIPADST_1D, ADST_1D, IDTX_1D, 158*77c1e3ccSAndroid Build Coastguard Worker IDTX_1D, DCT_1D, IDTX_1D, ADST_1D, IDTX_1D, FLIPADST_1D, 159*77c1e3ccSAndroid Build Coastguard Worker }; 160*77c1e3ccSAndroid Build Coastguard Worker 161*77c1e3ccSAndroid Build Coastguard Worker #define TXSIZE_CAT_INVALID (-1) 162*77c1e3ccSAndroid Build Coastguard Worker 163*77c1e3ccSAndroid Build Coastguard Worker /* clang-format on */ 164*77c1e3ccSAndroid Build Coastguard Worker 165*77c1e3ccSAndroid Build Coastguard Worker static const TX_SIZE sub_tx_size_map[TX_SIZES_ALL] = { 166*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // TX_4X4 167*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // TX_8X8 168*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_16X16 169*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_32X32 170*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_64X64 171*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // TX_4X8 172*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // TX_8X4 173*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_8X16 174*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_16X8 175*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_16X32 176*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_32X16 177*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_32X64 178*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_64X32 179*77c1e3ccSAndroid Build Coastguard Worker TX_4X8, // TX_4X16 180*77c1e3ccSAndroid Build Coastguard Worker TX_8X4, // TX_16X4 181*77c1e3ccSAndroid Build Coastguard Worker TX_8X16, // TX_8X32 182*77c1e3ccSAndroid Build Coastguard Worker TX_16X8, // TX_32X8 183*77c1e3ccSAndroid Build Coastguard Worker TX_16X32, // TX_16X64 184*77c1e3ccSAndroid Build Coastguard Worker TX_32X16, // TX_64X16 185*77c1e3ccSAndroid Build Coastguard Worker }; 186*77c1e3ccSAndroid Build Coastguard Worker 187*77c1e3ccSAndroid Build Coastguard Worker static const TX_SIZE txsize_horz_map[TX_SIZES_ALL] = { 188*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // TX_4X4 189*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_8X8 190*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_16X16 191*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_32X32 192*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, // TX_64X64 193*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // TX_4X8 194*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_8X4 195*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_8X16 196*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_16X8 197*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_16X32 198*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_32X16 199*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_32X64 200*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, // TX_64X32 201*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // TX_4X16 202*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_16X4 203*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_8X32 204*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_32X8 205*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_16X64 206*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, // TX_64X16 207*77c1e3ccSAndroid Build Coastguard Worker }; 208*77c1e3ccSAndroid Build Coastguard Worker 209*77c1e3ccSAndroid Build Coastguard Worker static const TX_SIZE txsize_vert_map[TX_SIZES_ALL] = { 210*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // TX_4X4 211*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_8X8 212*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_16X16 213*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_32X32 214*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, // TX_64X64 215*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_4X8 216*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // TX_8X4 217*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_8X16 218*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_16X8 219*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_16X32 220*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_32X16 221*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, // TX_32X64 222*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_64X32 223*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_4X16 224*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // TX_16X4 225*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_8X32 226*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_32X8 227*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, // TX_16X64 228*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_64X16 229*77c1e3ccSAndroid Build Coastguard Worker }; 230*77c1e3ccSAndroid Build Coastguard Worker 231*77c1e3ccSAndroid Build Coastguard Worker #define TX_SIZE_W_MIN 4 232*77c1e3ccSAndroid Build Coastguard Worker 233*77c1e3ccSAndroid Build Coastguard Worker // Transform block width in pixels 234*77c1e3ccSAndroid Build Coastguard Worker static const int tx_size_wide[TX_SIZES_ALL] = { 235*77c1e3ccSAndroid Build Coastguard Worker 4, 8, 16, 32, 64, 4, 8, 8, 16, 16, 32, 32, 64, 4, 16, 8, 32, 16, 64, 236*77c1e3ccSAndroid Build Coastguard Worker }; 237*77c1e3ccSAndroid Build Coastguard Worker 238*77c1e3ccSAndroid Build Coastguard Worker #define TX_SIZE_H_MIN 4 239*77c1e3ccSAndroid Build Coastguard Worker 240*77c1e3ccSAndroid Build Coastguard Worker // Transform block height in pixels 241*77c1e3ccSAndroid Build Coastguard Worker static const int tx_size_high[TX_SIZES_ALL] = { 242*77c1e3ccSAndroid Build Coastguard Worker 4, 8, 16, 32, 64, 8, 4, 16, 8, 32, 16, 64, 32, 16, 4, 32, 8, 64, 16, 243*77c1e3ccSAndroid Build Coastguard Worker }; 244*77c1e3ccSAndroid Build Coastguard Worker 245*77c1e3ccSAndroid Build Coastguard Worker // Transform block width in unit 246*77c1e3ccSAndroid Build Coastguard Worker static const int tx_size_wide_unit[TX_SIZES_ALL] = { 247*77c1e3ccSAndroid Build Coastguard Worker 1, 2, 4, 8, 16, 1, 2, 2, 4, 4, 8, 8, 16, 1, 4, 2, 8, 4, 16, 248*77c1e3ccSAndroid Build Coastguard Worker }; 249*77c1e3ccSAndroid Build Coastguard Worker 250*77c1e3ccSAndroid Build Coastguard Worker // Transform block height in unit 251*77c1e3ccSAndroid Build Coastguard Worker static const int tx_size_high_unit[TX_SIZES_ALL] = { 252*77c1e3ccSAndroid Build Coastguard Worker 1, 2, 4, 8, 16, 2, 1, 4, 2, 8, 4, 16, 8, 4, 1, 8, 2, 16, 4, 253*77c1e3ccSAndroid Build Coastguard Worker }; 254*77c1e3ccSAndroid Build Coastguard Worker 255*77c1e3ccSAndroid Build Coastguard Worker // Transform block width in log2 256*77c1e3ccSAndroid Build Coastguard Worker static const int tx_size_wide_log2[TX_SIZES_ALL] = { 257*77c1e3ccSAndroid Build Coastguard Worker 2, 3, 4, 5, 6, 2, 3, 3, 4, 4, 5, 5, 6, 2, 4, 3, 5, 4, 6, 258*77c1e3ccSAndroid Build Coastguard Worker }; 259*77c1e3ccSAndroid Build Coastguard Worker 260*77c1e3ccSAndroid Build Coastguard Worker // Transform block width in log2 unit 261*77c1e3ccSAndroid Build Coastguard Worker static const int tx_size_wide_unit_log2[TX_SIZES_ALL] = { 262*77c1e3ccSAndroid Build Coastguard Worker 0, 1, 2, 3, 4, 0, 1, 1, 2, 2, 3, 3, 4, 0, 2, 1, 3, 2, 4, 263*77c1e3ccSAndroid Build Coastguard Worker }; 264*77c1e3ccSAndroid Build Coastguard Worker 265*77c1e3ccSAndroid Build Coastguard Worker // Transform block height in log2 266*77c1e3ccSAndroid Build Coastguard Worker static const int tx_size_high_log2[TX_SIZES_ALL] = { 267*77c1e3ccSAndroid Build Coastguard Worker 2, 3, 4, 5, 6, 3, 2, 4, 3, 5, 4, 6, 5, 4, 2, 5, 3, 6, 4, 268*77c1e3ccSAndroid Build Coastguard Worker }; 269*77c1e3ccSAndroid Build Coastguard Worker 270*77c1e3ccSAndroid Build Coastguard Worker // Transform block height in log2 unit 271*77c1e3ccSAndroid Build Coastguard Worker static const int tx_size_high_unit_log2[TX_SIZES_ALL] = { 272*77c1e3ccSAndroid Build Coastguard Worker 0, 1, 2, 3, 4, 1, 0, 2, 1, 3, 2, 4, 3, 2, 0, 3, 1, 4, 2, 273*77c1e3ccSAndroid Build Coastguard Worker }; 274*77c1e3ccSAndroid Build Coastguard Worker 275*77c1e3ccSAndroid Build Coastguard Worker static const int tx_size_2d[TX_SIZES_ALL + 1] = { 276*77c1e3ccSAndroid Build Coastguard Worker 16, 64, 256, 1024, 4096, 32, 32, 128, 128, 512, 277*77c1e3ccSAndroid Build Coastguard Worker 512, 2048, 2048, 64, 64, 256, 256, 1024, 1024, 278*77c1e3ccSAndroid Build Coastguard Worker }; 279*77c1e3ccSAndroid Build Coastguard Worker 280*77c1e3ccSAndroid Build Coastguard Worker static const BLOCK_SIZE txsize_to_bsize[TX_SIZES_ALL] = { 281*77c1e3ccSAndroid Build Coastguard Worker BLOCK_4X4, // TX_4X4 282*77c1e3ccSAndroid Build Coastguard Worker BLOCK_8X8, // TX_8X8 283*77c1e3ccSAndroid Build Coastguard Worker BLOCK_16X16, // TX_16X16 284*77c1e3ccSAndroid Build Coastguard Worker BLOCK_32X32, // TX_32X32 285*77c1e3ccSAndroid Build Coastguard Worker BLOCK_64X64, // TX_64X64 286*77c1e3ccSAndroid Build Coastguard Worker BLOCK_4X8, // TX_4X8 287*77c1e3ccSAndroid Build Coastguard Worker BLOCK_8X4, // TX_8X4 288*77c1e3ccSAndroid Build Coastguard Worker BLOCK_8X16, // TX_8X16 289*77c1e3ccSAndroid Build Coastguard Worker BLOCK_16X8, // TX_16X8 290*77c1e3ccSAndroid Build Coastguard Worker BLOCK_16X32, // TX_16X32 291*77c1e3ccSAndroid Build Coastguard Worker BLOCK_32X16, // TX_32X16 292*77c1e3ccSAndroid Build Coastguard Worker BLOCK_32X64, // TX_32X64 293*77c1e3ccSAndroid Build Coastguard Worker BLOCK_64X32, // TX_64X32 294*77c1e3ccSAndroid Build Coastguard Worker BLOCK_4X16, // TX_4X16 295*77c1e3ccSAndroid Build Coastguard Worker BLOCK_16X4, // TX_16X4 296*77c1e3ccSAndroid Build Coastguard Worker BLOCK_8X32, // TX_8X32 297*77c1e3ccSAndroid Build Coastguard Worker BLOCK_32X8, // TX_32X8 298*77c1e3ccSAndroid Build Coastguard Worker BLOCK_16X64, // TX_16X64 299*77c1e3ccSAndroid Build Coastguard Worker BLOCK_64X16, // TX_64X16 300*77c1e3ccSAndroid Build Coastguard Worker }; 301*77c1e3ccSAndroid Build Coastguard Worker 302*77c1e3ccSAndroid Build Coastguard Worker static const TX_SIZE txsize_sqr_map[TX_SIZES_ALL] = { 303*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // TX_4X4 304*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_8X8 305*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_16X16 306*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_32X32 307*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, // TX_64X64 308*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // TX_4X8 309*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // TX_8X4 310*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_8X16 311*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_16X8 312*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_16X32 313*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_32X16 314*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_32X64 315*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_64X32 316*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // TX_4X16 317*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // TX_16X4 318*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_8X32 319*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_32X8 320*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_16X64 321*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_64X16 322*77c1e3ccSAndroid Build Coastguard Worker }; 323*77c1e3ccSAndroid Build Coastguard Worker 324*77c1e3ccSAndroid Build Coastguard Worker static const TX_SIZE txsize_sqr_up_map[TX_SIZES_ALL] = { 325*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // TX_4X4 326*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_8X8 327*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_16X16 328*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_32X32 329*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, // TX_64X64 330*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_4X8 331*77c1e3ccSAndroid Build Coastguard Worker TX_8X8, // TX_8X4 332*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_8X16 333*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_16X8 334*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_16X32 335*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_32X16 336*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, // TX_32X64 337*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, // TX_64X32 338*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_4X16 339*77c1e3ccSAndroid Build Coastguard Worker TX_16X16, // TX_16X4 340*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_8X32 341*77c1e3ccSAndroid Build Coastguard Worker TX_32X32, // TX_32X8 342*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, // TX_16X64 343*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, // TX_64X16 344*77c1e3ccSAndroid Build Coastguard Worker }; 345*77c1e3ccSAndroid Build Coastguard Worker 346*77c1e3ccSAndroid Build Coastguard Worker static const int8_t txsize_log2_minus4[TX_SIZES_ALL] = { 347*77c1e3ccSAndroid Build Coastguard Worker 0, // TX_4X4 348*77c1e3ccSAndroid Build Coastguard Worker 2, // TX_8X8 349*77c1e3ccSAndroid Build Coastguard Worker 4, // TX_16X16 350*77c1e3ccSAndroid Build Coastguard Worker 6, // TX_32X32 351*77c1e3ccSAndroid Build Coastguard Worker 6, // TX_64X64 352*77c1e3ccSAndroid Build Coastguard Worker 1, // TX_4X8 353*77c1e3ccSAndroid Build Coastguard Worker 1, // TX_8X4 354*77c1e3ccSAndroid Build Coastguard Worker 3, // TX_8X16 355*77c1e3ccSAndroid Build Coastguard Worker 3, // TX_16X8 356*77c1e3ccSAndroid Build Coastguard Worker 5, // TX_16X32 357*77c1e3ccSAndroid Build Coastguard Worker 5, // TX_32X16 358*77c1e3ccSAndroid Build Coastguard Worker 6, // TX_32X64 359*77c1e3ccSAndroid Build Coastguard Worker 6, // TX_64X32 360*77c1e3ccSAndroid Build Coastguard Worker 2, // TX_4X16 361*77c1e3ccSAndroid Build Coastguard Worker 2, // TX_16X4 362*77c1e3ccSAndroid Build Coastguard Worker 4, // TX_8X32 363*77c1e3ccSAndroid Build Coastguard Worker 4, // TX_32X8 364*77c1e3ccSAndroid Build Coastguard Worker 5, // TX_16X64 365*77c1e3ccSAndroid Build Coastguard Worker 5, // TX_64X16 366*77c1e3ccSAndroid Build Coastguard Worker }; 367*77c1e3ccSAndroid Build Coastguard Worker 368*77c1e3ccSAndroid Build Coastguard Worker static const TX_SIZE tx_mode_to_biggest_tx_size[TX_MODES] = { 369*77c1e3ccSAndroid Build Coastguard Worker TX_4X4, // ONLY_4X4 370*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, // TX_MODE_LARGEST 371*77c1e3ccSAndroid Build Coastguard Worker TX_64X64, // TX_MODE_SELECT 372*77c1e3ccSAndroid Build Coastguard Worker }; 373*77c1e3ccSAndroid Build Coastguard Worker 374*77c1e3ccSAndroid Build Coastguard Worker // The Subsampled_Size table in the spec (Section 5.11.38. Get plane residual 375*77c1e3ccSAndroid Build Coastguard Worker // size function). 376*77c1e3ccSAndroid Build Coastguard Worker extern const BLOCK_SIZE av1_ss_size_lookup[BLOCK_SIZES_ALL][2][2]; 377*77c1e3ccSAndroid Build Coastguard Worker 378*77c1e3ccSAndroid Build Coastguard Worker // Generates 5 bit field in which each bit set to 1 represents 379*77c1e3ccSAndroid Build Coastguard Worker // a blocksize partition 11111 means we split 128x128, 64x64, 32x32, 16x16 380*77c1e3ccSAndroid Build Coastguard Worker // and 8x8. 10000 means we just split the 128x128 to 64x64 381*77c1e3ccSAndroid Build Coastguard Worker /* clang-format off */ 382*77c1e3ccSAndroid Build Coastguard Worker static const struct { 383*77c1e3ccSAndroid Build Coastguard Worker PARTITION_CONTEXT above; 384*77c1e3ccSAndroid Build Coastguard Worker PARTITION_CONTEXT left; 385*77c1e3ccSAndroid Build Coastguard Worker } partition_context_lookup[BLOCK_SIZES_ALL] = { 386*77c1e3ccSAndroid Build Coastguard Worker { 31, 31 }, // 4X4 - {0b11111, 0b11111} 387*77c1e3ccSAndroid Build Coastguard Worker { 31, 30 }, // 4X8 - {0b11111, 0b11110} 388*77c1e3ccSAndroid Build Coastguard Worker { 30, 31 }, // 8X4 - {0b11110, 0b11111} 389*77c1e3ccSAndroid Build Coastguard Worker { 30, 30 }, // 8X8 - {0b11110, 0b11110} 390*77c1e3ccSAndroid Build Coastguard Worker { 30, 28 }, // 8X16 - {0b11110, 0b11100} 391*77c1e3ccSAndroid Build Coastguard Worker { 28, 30 }, // 16X8 - {0b11100, 0b11110} 392*77c1e3ccSAndroid Build Coastguard Worker { 28, 28 }, // 16X16 - {0b11100, 0b11100} 393*77c1e3ccSAndroid Build Coastguard Worker { 28, 24 }, // 16X32 - {0b11100, 0b11000} 394*77c1e3ccSAndroid Build Coastguard Worker { 24, 28 }, // 32X16 - {0b11000, 0b11100} 395*77c1e3ccSAndroid Build Coastguard Worker { 24, 24 }, // 32X32 - {0b11000, 0b11000} 396*77c1e3ccSAndroid Build Coastguard Worker { 24, 16 }, // 32X64 - {0b11000, 0b10000} 397*77c1e3ccSAndroid Build Coastguard Worker { 16, 24 }, // 64X32 - {0b10000, 0b11000} 398*77c1e3ccSAndroid Build Coastguard Worker { 16, 16 }, // 64X64 - {0b10000, 0b10000} 399*77c1e3ccSAndroid Build Coastguard Worker { 16, 0 }, // 64X128- {0b10000, 0b00000} 400*77c1e3ccSAndroid Build Coastguard Worker { 0, 16 }, // 128X64- {0b00000, 0b10000} 401*77c1e3ccSAndroid Build Coastguard Worker { 0, 0 }, // 128X128-{0b00000, 0b00000} 402*77c1e3ccSAndroid Build Coastguard Worker { 31, 28 }, // 4X16 - {0b11111, 0b11100} 403*77c1e3ccSAndroid Build Coastguard Worker { 28, 31 }, // 16X4 - {0b11100, 0b11111} 404*77c1e3ccSAndroid Build Coastguard Worker { 30, 24 }, // 8X32 - {0b11110, 0b11000} 405*77c1e3ccSAndroid Build Coastguard Worker { 24, 30 }, // 32X8 - {0b11000, 0b11110} 406*77c1e3ccSAndroid Build Coastguard Worker { 28, 16 }, // 16X64 - {0b11100, 0b10000} 407*77c1e3ccSAndroid Build Coastguard Worker { 16, 28 }, // 64X16 - {0b10000, 0b11100} 408*77c1e3ccSAndroid Build Coastguard Worker }; 409*77c1e3ccSAndroid Build Coastguard Worker /* clang-format on */ 410*77c1e3ccSAndroid Build Coastguard Worker 411*77c1e3ccSAndroid Build Coastguard Worker static const int intra_mode_context[INTRA_MODES] = { 412*77c1e3ccSAndroid Build Coastguard Worker 0, 1, 2, 3, 4, 4, 4, 4, 3, 0, 1, 2, 0, 413*77c1e3ccSAndroid Build Coastguard Worker }; 414*77c1e3ccSAndroid Build Coastguard Worker 415*77c1e3ccSAndroid Build Coastguard Worker // Note: this is also used in unit tests. So whenever one changes the table, 416*77c1e3ccSAndroid Build Coastguard Worker // the unit tests need to be changed accordingly. 417*77c1e3ccSAndroid Build Coastguard Worker static const int quant_dist_weight[4][2] = { 418*77c1e3ccSAndroid Build Coastguard Worker { 2, 3 }, { 2, 5 }, { 2, 7 }, { 1, MAX_FRAME_DISTANCE } 419*77c1e3ccSAndroid Build Coastguard Worker }; 420*77c1e3ccSAndroid Build Coastguard Worker 421*77c1e3ccSAndroid Build Coastguard Worker static const int quant_dist_lookup_table[4][2] = { 422*77c1e3ccSAndroid Build Coastguard Worker { 9, 7 }, 423*77c1e3ccSAndroid Build Coastguard Worker { 11, 5 }, 424*77c1e3ccSAndroid Build Coastguard Worker { 12, 4 }, 425*77c1e3ccSAndroid Build Coastguard Worker { 13, 3 }, 426*77c1e3ccSAndroid Build Coastguard Worker }; 427*77c1e3ccSAndroid Build Coastguard Worker 428*77c1e3ccSAndroid Build Coastguard Worker #ifdef __cplusplus 429*77c1e3ccSAndroid Build Coastguard Worker } // extern "C" 430*77c1e3ccSAndroid Build Coastguard Worker #endif 431*77c1e3ccSAndroid Build Coastguard Worker 432*77c1e3ccSAndroid Build Coastguard Worker #endif // AOM_AV1_COMMON_COMMON_DATA_H_ 433