Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 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. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 12 | #ifndef AV1_ENCODER_BLOCK_H_ |
| 13 | #define AV1_ENCODER_BLOCK_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 14 | |
| 15 | #include "av1/common/entropymv.h" |
| 16 | #include "av1/common/entropy.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 17 | #include "av1/common/mvref_common.h" |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 18 | #include "av1/encoder/hash.h" |
Yushin Cho | 5510433 | 2017-08-14 16:15:43 -0700 | [diff] [blame] | 19 | #if CONFIG_DIST_8X8 |
| 20 | #include "aom/aomcx.h" |
| 21 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 22 | |
| 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
| 27 | typedef struct { |
| 28 | unsigned int sse; |
| 29 | int sum; |
| 30 | unsigned int var; |
Urvang Joshi | 454280d | 2016-10-14 16:51:44 -0700 | [diff] [blame] | 31 | } DIFF; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 32 | |
| 33 | typedef struct macroblock_plane { |
| 34 | DECLARE_ALIGNED(16, int16_t, src_diff[MAX_SB_SQUARE]); |
| 35 | tran_low_t *qcoeff; |
| 36 | tran_low_t *coeff; |
| 37 | uint16_t *eobs; |
Angie Chiang | 74e2307 | 2017-03-24 14:54:23 -0700 | [diff] [blame] | 38 | #if CONFIG_LV_MAP |
| 39 | uint8_t *txb_entropy_ctx; |
| 40 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 41 | struct buf_2d src; |
| 42 | |
| 43 | // Quantizer setings |
Monty Montgomery | 125c0fc | 2017-10-26 00:44:35 -0400 | [diff] [blame] | 44 | // These are used/accessed only in the quantization process |
| 45 | // RDO does not / must not depend on any of these values |
| 46 | // All values below share the coefficient scale/shift used in TX |
| 47 | const int16_t *quant_fp_QTX; |
| 48 | const int16_t *round_fp_QTX; |
| 49 | const int16_t *quant_QTX; |
| 50 | const int16_t *quant_shift_QTX; |
| 51 | const int16_t *zbin_QTX; |
| 52 | const int16_t *round_QTX; |
| 53 | const int16_t *dequant_QTX; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 54 | #if CONFIG_NEW_QUANT |
| 55 | const cuml_bins_type_nuq *cuml_bins_nuq[QUANT_PROFILES]; |
Monty Montgomery | 125c0fc | 2017-10-26 00:44:35 -0400 | [diff] [blame] | 56 | const dequant_val_type_nuq *dequant_val_nuq_QTX[QUANT_PROFILES]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 57 | #endif // CONFIG_NEW_QUANT |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 58 | } MACROBLOCK_PLANE; |
| 59 | |
hui su | c0cf71d | 2017-07-20 16:38:50 -0700 | [diff] [blame] | 60 | typedef int av1_coeff_cost[PLANE_TYPES][REF_TYPES][COEF_BANDS][COEFF_CONTEXTS] |
| 61 | [TAIL_TOKENS]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 62 | |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 63 | #if CONFIG_LV_MAP |
| 64 | typedef struct { |
| 65 | int txb_skip_cost[TXB_SKIP_CONTEXTS][2]; |
Ola Hugosson | 1389210 | 2017-11-06 08:01:44 +0100 | [diff] [blame] | 66 | #if CONFIG_LV_MAP_MULTI |
Dake He | 3fe369c | 2017-11-16 17:56:44 -0800 | [diff] [blame] | 67 | #if USE_BASE_EOB_ALPHABET |
| 68 | int base_eob_cost[SIG_COEF_CONTEXTS_EOB][3]; |
| 69 | #endif |
Ola Hugosson | 1389210 | 2017-11-06 08:01:44 +0100 | [diff] [blame] | 70 | int base_cost[SIG_COEF_CONTEXTS][4]; |
| 71 | #else |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 72 | int nz_map_cost[SIG_COEF_CONTEXTS][2]; |
Ola Hugosson | 1389210 | 2017-11-06 08:01:44 +0100 | [diff] [blame] | 73 | #endif |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 74 | int eob_cost[EOB_COEF_CONTEXTS][2]; |
Angie Chiang | 7ab884e | 2017-10-18 15:57:12 -0700 | [diff] [blame] | 75 | int eob_extra_cost[EOB_COEF_CONTEXTS][2]; |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 76 | int dc_sign_cost[DC_SIGN_CONTEXTS][2]; |
Ola Hugosson | 1389210 | 2017-11-06 08:01:44 +0100 | [diff] [blame] | 77 | #if !CONFIG_LV_MAP_MULTI |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 78 | int base_cost[NUM_BASE_LEVELS][COEFF_BASE_CONTEXTS][2]; |
Ola Hugosson | 1389210 | 2017-11-06 08:01:44 +0100 | [diff] [blame] | 79 | #endif |
Angie Chiang | 26d3e45 | 2017-09-29 17:40:02 -0700 | [diff] [blame] | 80 | int lps_cost[LEVEL_CONTEXTS][COEFF_BASE_RANGE + 1]; |
Ola Hugosson | e72a209 | 2017-11-12 09:11:53 +0100 | [diff] [blame] | 81 | #if !CONFIG_LV_MAP_MULTI |
Jingning Han | 87b01b5 | 2017-08-31 12:07:20 -0700 | [diff] [blame] | 82 | int br_cost[BASE_RANGE_SETS][LEVEL_CONTEXTS][2]; |
Ola Hugosson | e72a209 | 2017-11-12 09:11:53 +0100 | [diff] [blame] | 83 | #endif |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 84 | } LV_MAP_COEFF_COST; |
Jingning Han | f5a4d3b | 2017-08-27 23:01:19 -0700 | [diff] [blame] | 85 | |
| 86 | typedef struct { |
| 87 | tran_low_t tcoeff[MAX_MB_PLANE][MAX_SB_SQUARE]; |
| 88 | uint16_t eobs[MAX_MB_PLANE][MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN)]; |
| 89 | uint8_t txb_skip_ctx[MAX_MB_PLANE] |
| 90 | [MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN)]; |
| 91 | int dc_sign_ctx[MAX_MB_PLANE] |
| 92 | [MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN)]; |
| 93 | } CB_COEFF_BUFFER; |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 94 | #endif |
| 95 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 96 | typedef struct { |
| 97 | int_mv ref_mvs[MODE_CTX_REF_FRAMES][MAX_MV_REF_CANDIDATES]; |
| 98 | int16_t mode_context[MODE_CTX_REF_FRAMES]; |
Angie Chiang | f0fbf9d | 2017-03-15 15:01:22 -0700 | [diff] [blame] | 99 | #if CONFIG_LV_MAP |
Angie Chiang | c484abe | 2017-03-20 15:43:11 -0700 | [diff] [blame] | 100 | // TODO(angiebird): Reduce the buffer size according to sb_type |
Jingning Han | f5a4d3b | 2017-08-27 23:01:19 -0700 | [diff] [blame] | 101 | tran_low_t *tcoeff[MAX_MB_PLANE]; |
| 102 | uint16_t *eobs[MAX_MB_PLANE]; |
| 103 | uint8_t *txb_skip_ctx[MAX_MB_PLANE]; |
| 104 | int *dc_sign_ctx[MAX_MB_PLANE]; |
Angie Chiang | f0fbf9d | 2017-03-15 15:01:22 -0700 | [diff] [blame] | 105 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 106 | uint8_t ref_mv_count[MODE_CTX_REF_FRAMES]; |
| 107 | CANDIDATE_MV ref_mv_stack[MODE_CTX_REF_FRAMES][MAX_REF_MV_STACK_SIZE]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 108 | int16_t compound_mode_context[MODE_CTX_REF_FRAMES]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 109 | } MB_MODE_INFO_EXT; |
| 110 | |
Alex Converse | 0fa0f42 | 2017-04-24 12:51:14 -0700 | [diff] [blame] | 111 | typedef struct { |
| 112 | int col_min; |
| 113 | int col_max; |
| 114 | int row_min; |
| 115 | int row_max; |
| 116 | } MvLimits; |
| 117 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 118 | typedef struct { |
Hui Su | 473cf89 | 2017-11-08 18:14:31 -0800 | [diff] [blame] | 119 | uint8_t best_palette_color_map[MAX_PALETTE_SQUARE]; |
| 120 | float kmeans_data_buf[2 * MAX_PALETTE_SQUARE]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 121 | } PALETTE_BUFFER; |
| 122 | |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 123 | typedef struct { |
| 124 | TX_TYPE tx_type; |
| 125 | TX_SIZE tx_size; |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 126 | TX_SIZE min_tx_size; |
| 127 | TX_SIZE inter_tx_size[MAX_MIB_SIZE][MAX_MIB_SIZE]; |
| 128 | uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE * 8]; |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 129 | #if CONFIG_TXK_SEL |
| 130 | TX_TYPE txk_type[MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN)]; |
| 131 | #endif // CONFIG_TXK_SEL |
| 132 | RD_STATS rd_stats; |
| 133 | uint32_t hash_value; |
| 134 | } TX_RD_INFO; |
| 135 | |
| 136 | #define RD_RECORD_BUFFER_LEN 8 |
| 137 | typedef struct { |
| 138 | TX_RD_INFO tx_rd_info[RD_RECORD_BUFFER_LEN]; // Circular buffer. |
| 139 | int index_start; |
| 140 | int num; |
| 141 | CRC_CALCULATOR crc_calculator; // Hash function. |
| 142 | } TX_RD_RECORD; |
| 143 | |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 144 | typedef struct { |
| 145 | int64_t dist; |
| 146 | int rate; |
Hui Su | 8c2b913 | 2017-12-09 10:40:15 -0800 | [diff] [blame^] | 147 | uint16_t eob; |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 148 | uint8_t entropy_context; |
| 149 | uint8_t valid; |
| 150 | uint8_t fast; |
| 151 | } TX_SIZE_RD_INFO; |
| 152 | |
| 153 | #define TX_SIZE_RD_RECORD_BUFFER_LEN 256 |
| 154 | typedef struct { |
| 155 | uint32_t hash_vals[TX_SIZE_RD_RECORD_BUFFER_LEN]; |
| 156 | TX_SIZE_RD_INFO tx_rd_info[TX_SIZE_RD_RECORD_BUFFER_LEN][TX_TYPES]; |
| 157 | int index_start; |
| 158 | int num; |
| 159 | } TX_SIZE_RD_RECORD; |
| 160 | |
| 161 | typedef struct tx_size_rd_info_node { |
| 162 | TX_SIZE_RD_INFO *rd_info_array; // Points to array of size TX_TYPES. |
| 163 | struct tx_size_rd_info_node *children[4]; |
| 164 | } TX_SIZE_RD_INFO_NODE; |
| 165 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 166 | typedef struct macroblock MACROBLOCK; |
| 167 | struct macroblock { |
| 168 | struct macroblock_plane plane[MAX_MB_PLANE]; |
| 169 | |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 170 | // Save the transform RD search info. |
| 171 | TX_RD_RECORD tx_rd_record; |
| 172 | |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 173 | // Also save RD info on the TX size search level for square TX sizes. |
| 174 | TX_SIZE_RD_RECORD |
| 175 | tx_size_rd_record_8X8[(MAX_MIB_SIZE >> 1) * (MAX_MIB_SIZE >> 1)]; |
| 176 | TX_SIZE_RD_RECORD |
| 177 | tx_size_rd_record_16X16[(MAX_MIB_SIZE >> 2) * (MAX_MIB_SIZE >> 2)]; |
| 178 | TX_SIZE_RD_RECORD |
| 179 | tx_size_rd_record_32X32[(MAX_MIB_SIZE >> 3) * (MAX_MIB_SIZE >> 3)]; |
| 180 | #if CONFIG_TX64X64 |
| 181 | TX_SIZE_RD_RECORD |
| 182 | tx_size_rd_record_64X64[(MAX_MIB_SIZE >> 4) * (MAX_MIB_SIZE >> 4)]; |
| 183 | #endif |
| 184 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 185 | MACROBLOCKD e_mbd; |
| 186 | MB_MODE_INFO_EXT *mbmi_ext; |
| 187 | int skip_block; |
David Barker | d7d78c8 | 2016-10-24 10:55:35 +0100 | [diff] [blame] | 188 | int qindex; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 189 | |
| 190 | // The equivalent error at the current rdmult of one whole bit (not one |
| 191 | // bitcost unit). |
| 192 | int errorperbit; |
| 193 | // The equivalend SAD error of one (whole) bit at the current quantizer |
| 194 | // for large blocks. |
| 195 | int sadperbit16; |
| 196 | // The equivalend SAD error of one (whole) bit at the current quantizer |
| 197 | // for sub-8x8 blocks. |
| 198 | int sadperbit4; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 199 | int rdmult; |
| 200 | int mb_energy; |
| 201 | int *m_search_count_ptr; |
| 202 | int *ex_search_count_ptr; |
| 203 | |
Jingning Han | 9777afc | 2016-10-20 15:17:43 -0700 | [diff] [blame] | 204 | unsigned int txb_split_count; |
Jingning Han | 9777afc | 2016-10-20 15:17:43 -0700 | [diff] [blame] | 205 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 206 | // These are set to their default values at the beginning, and then adjusted |
| 207 | // further in the encoding process. |
| 208 | BLOCK_SIZE min_partition_size; |
| 209 | BLOCK_SIZE max_partition_size; |
| 210 | |
| 211 | int mv_best_ref_index[TOTAL_REFS_PER_FRAME]; |
| 212 | unsigned int max_mv_context[TOTAL_REFS_PER_FRAME]; |
| 213 | unsigned int source_variance; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 214 | unsigned int pred_sse[TOTAL_REFS_PER_FRAME]; |
| 215 | int pred_mv_sad[TOTAL_REFS_PER_FRAME]; |
| 216 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 217 | int *nmvjointcost; |
| 218 | int nmv_vec_cost[NMV_CONTEXTS][MV_JOINTS]; |
| 219 | int *nmvcost[NMV_CONTEXTS][2]; |
| 220 | int *nmvcost_hp[NMV_CONTEXTS][2]; |
| 221 | int **mv_cost_stack[NMV_CONTEXTS]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 222 | int **mvcost; |
Alex Converse | a127a79 | 2017-05-23 15:27:21 -0700 | [diff] [blame] | 223 | |
Yue Chen | e9638cc | 2016-10-10 12:37:54 -0700 | [diff] [blame] | 224 | int32_t *wsrc_buf; |
| 225 | int32_t *mask_buf; |
Jingning Han | d064cf0 | 2017-06-01 10:00:39 -0700 | [diff] [blame] | 226 | uint8_t *above_pred_buf; |
| 227 | uint8_t *left_pred_buf; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 228 | |
| 229 | PALETTE_BUFFER *palette_buffer; |
| 230 | |
| 231 | // These define limits to motion vector components to prevent them |
| 232 | // from extending outside the UMV borders |
Alex Converse | 0fa0f42 | 2017-04-24 12:51:14 -0700 | [diff] [blame] | 233 | MvLimits mv_limits; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 234 | |
Jingning Han | 9ca05b7 | 2017-01-03 14:41:36 -0800 | [diff] [blame] | 235 | uint8_t blk_skip[MAX_MB_PLANE][MAX_MIB_SIZE * MAX_MIB_SIZE * 8]; |
Jingning Han | 9ca05b7 | 2017-01-03 14:41:36 -0800 | [diff] [blame] | 236 | uint8_t blk_skip_drl[MAX_MB_PLANE][MAX_MIB_SIZE * MAX_MIB_SIZE * 8]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 237 | |
| 238 | int skip; |
Jingning Han | 8efdbc8 | 2017-02-19 14:40:03 -0800 | [diff] [blame] | 239 | int skip_chroma_rd; |
Zoe Liu | 1eed2df | 2017-10-16 17:13:15 -0700 | [diff] [blame] | 240 | int skip_cost[SKIP_CONTEXTS][2]; |
| 241 | |
Zoe Liu | f40a957 | 2017-10-13 12:37:19 -0700 | [diff] [blame] | 242 | #if CONFIG_EXT_SKIP |
| 243 | int skip_mode; // 0: off; 1: on |
| 244 | int skip_mode_cost[SKIP_CONTEXTS][2]; |
| 245 | |
| 246 | int64_t skip_mode_rdcost; // -1: Not set |
| 247 | int skip_mode_rate; |
| 248 | int64_t skip_mode_sse; |
| 249 | int64_t skip_mode_dist; |
| 250 | MV_REFERENCE_FRAME skip_mode_ref_frame[2]; |
| 251 | int_mv skip_mode_mv[2]; |
| 252 | int skip_mode_index_candidate; |
| 253 | int skip_mode_index; |
| 254 | #endif // CONFIG_EXT_SKIP |
| 255 | |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 256 | #if CONFIG_LV_MAP |
| 257 | LV_MAP_COEFF_COST coeff_costs[TX_SIZES][PLANE_TYPES]; |
Jingning Han | f5a4d3b | 2017-08-27 23:01:19 -0700 | [diff] [blame] | 258 | uint16_t cb_offset; |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 259 | #endif |
| 260 | |
hui su | c0cf71d | 2017-07-20 16:38:50 -0700 | [diff] [blame] | 261 | av1_coeff_cost token_head_costs[TX_SIZES]; |
| 262 | av1_coeff_cost token_tail_costs[TX_SIZES]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 263 | |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 264 | // mode costs |
Yue Chen | 170678a | 2017-10-17 13:43:10 -0700 | [diff] [blame] | 265 | int intra_inter_cost[INTRA_INTER_CONTEXTS][2]; |
| 266 | |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 267 | int mbmode_cost[BLOCK_SIZE_GROUPS][INTRA_MODES]; |
| 268 | int newmv_mode_cost[NEWMV_MODE_CONTEXTS][2]; |
Sarah Parker | 2b9ec2e | 2017-10-30 17:34:08 -0700 | [diff] [blame] | 269 | int zeromv_mode_cost[GLOBALMV_MODE_CONTEXTS][2]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 270 | int refmv_mode_cost[REFMV_MODE_CONTEXTS][2]; |
| 271 | int drl_mode_cost0[DRL_MODE_CONTEXTS][2]; |
| 272 | |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 273 | int inter_compound_mode_cost[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES]; |
Cheng Chen | 2ef24ea | 2017-11-29 12:22:24 -0800 | [diff] [blame] | 274 | #if CONFIG_JNT_COMP |
| 275 | int compound_type_cost[BLOCK_SIZES_ALL][COMPOUND_TYPES - 1]; |
| 276 | #else |
Yue Chen | a424551 | 2017-08-31 11:58:08 -0700 | [diff] [blame] | 277 | int compound_type_cost[BLOCK_SIZES_ALL][COMPOUND_TYPES]; |
Cheng Chen | 2ef24ea | 2017-11-29 12:22:24 -0800 | [diff] [blame] | 278 | #endif // CONFIG_JNT_COMP |
Yue Chen | eaf128a | 2017-10-16 17:01:36 -0700 | [diff] [blame] | 279 | int interintra_cost[BLOCK_SIZE_GROUPS][2]; |
| 280 | int wedge_interintra_cost[BLOCK_SIZES_ALL][2]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 281 | int interintra_mode_cost[BLOCK_SIZE_GROUPS][INTERINTRA_MODES]; |
Yunqing Wang | 3afbf3f | 2017-11-21 20:16:18 -0800 | [diff] [blame] | 282 | #if CONFIG_EXT_WARPED_MOTION |
| 283 | int motion_mode_cost[MOTION_MODE_CTX][BLOCK_SIZES_ALL][MOTION_MODES]; |
| 284 | #else |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 285 | int motion_mode_cost[BLOCK_SIZES_ALL][MOTION_MODES]; |
Yunqing Wang | 3afbf3f | 2017-11-21 20:16:18 -0800 | [diff] [blame] | 286 | #endif // CONFIG_EXT_WARPED_MOTION |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 287 | int motion_mode_cost1[BLOCK_SIZES_ALL][2]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 288 | int intra_uv_mode_cost[INTRA_MODES][UV_INTRA_MODES]; |
| 289 | int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES]; |
Yue Chen | 63ce36f | 2017-10-10 23:37:31 -0700 | [diff] [blame] | 290 | #if CONFIG_FILTER_INTRA |
Yue Chen | 4eba69b | 2017-11-09 22:37:35 -0800 | [diff] [blame] | 291 | int filter_intra_cost[TX_SIZES_ALL][2]; |
Yue Chen | 63ce36f | 2017-10-10 23:37:31 -0700 | [diff] [blame] | 292 | int filter_intra_mode_cost[PLANE_TYPES][FILTER_INTRA_MODES]; |
| 293 | #endif |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 294 | int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS]; |
| 295 | #if CONFIG_EXT_PARTITION_TYPES |
Sebastien Alaiwan | a6a486c | 2017-11-07 17:04:27 +0100 | [diff] [blame] | 296 | int partition_cost[PARTITION_CONTEXTS][EXT_PARTITION_TYPES]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 297 | #else |
Sebastien Alaiwan | a6a486c | 2017-11-07 17:04:27 +0100 | [diff] [blame] | 298 | int partition_cost[PARTITION_CONTEXTS][PARTITION_TYPES]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 299 | #endif // CONFIG_EXT_PARTITION_TYPES |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 300 | int palette_y_size_cost[PALETTE_BLOCK_SIZES][PALETTE_SIZES]; |
| 301 | int palette_uv_size_cost[PALETTE_BLOCK_SIZES][PALETTE_SIZES]; |
| 302 | int palette_y_color_cost[PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS] |
| 303 | [PALETTE_COLORS]; |
| 304 | int palette_uv_color_cost[PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS] |
| 305 | [PALETTE_COLORS]; |
Yue Chen | dab2ca9 | 2017-10-16 17:48:48 -0700 | [diff] [blame] | 306 | int palette_y_mode_cost[PALETTE_BLOCK_SIZES][PALETTE_Y_MODE_CONTEXTS][2]; |
| 307 | int palette_uv_mode_cost[PALETTE_UV_MODE_CONTEXTS][2]; |
David Michael Barr | 38e560c | 2017-08-16 21:46:37 +0900 | [diff] [blame] | 308 | #if CONFIG_CFL |
| 309 | // The rate associated with each alpha codeword |
| 310 | int cfl_cost[CFL_JOINT_SIGNS][CFL_PRED_PLANES][CFL_ALPHABET_SIZE]; |
| 311 | #endif // CONFIG_CFL |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 312 | int tx_size_cost[TX_SIZES - 1][TX_SIZE_CONTEXTS][TX_SIZES]; |
Yue Chen | 171c17d | 2017-10-16 18:08:22 -0700 | [diff] [blame] | 313 | int txfm_partition_cost[TXFM_PARTITION_CONTEXTS][2]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 314 | int inter_tx_type_costs[EXT_TX_SETS_INTER][EXT_TX_SIZES][TX_TYPES]; |
| 315 | int intra_tx_type_costs[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES] |
| 316 | [TX_TYPES]; |
Joe Young | 3ca43bf | 2017-10-06 15:12:46 -0700 | [diff] [blame] | 317 | #if CONFIG_EXT_INTRA && CONFIG_EXT_INTRA_MOD |
| 318 | int angle_delta_cost[DIRECTIONAL_MODES][2 * MAX_ANGLE_DELTA + 1]; |
| 319 | #endif // CONFIG_EXT_INTRA && CONFIG_EXT_INTRA_MOD |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 320 | #if CONFIG_LOOP_RESTORATION |
| 321 | int switchable_restore_cost[RESTORE_SWITCHABLE_TYPES]; |
Debargha Mukherjee | bc732ef | 2017-10-12 12:40:25 -0700 | [diff] [blame] | 322 | int wiener_restore_cost[2]; |
| 323 | int sgrproj_restore_cost[2]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 324 | #endif // CONFIG_LOOP_RESTORATION |
Hui Su | 6c8584f | 2017-09-14 15:37:02 -0700 | [diff] [blame] | 325 | #if CONFIG_INTRABC |
| 326 | int intrabc_cost[2]; |
| 327 | #endif // CONFIG_INTRABC |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 328 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 329 | int optimize; |
| 330 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 331 | // Used to store sub partition's choices. |
| 332 | MV pred_mv[TOTAL_REFS_PER_FRAME]; |
| 333 | |
| 334 | // Store the best motion vector during motion search |
| 335 | int_mv best_mv; |
| 336 | // Store the second best motion vector during full-pixel motion search |
| 337 | int_mv second_best_mv; |
| 338 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 339 | // use default transform and skip transform type search for intra modes |
| 340 | int use_default_intra_tx_type; |
| 341 | // use default transform and skip transform type search for inter modes |
| 342 | int use_default_inter_tx_type; |
Yushin Cho | b7b60c5 | 2017-07-14 16:18:52 -0700 | [diff] [blame] | 343 | #if CONFIG_DIST_8X8 |
Yushin Cho | 5510433 | 2017-08-14 16:15:43 -0700 | [diff] [blame] | 344 | int using_dist_8x8; |
| 345 | aom_tune_metric tune_metric; |
Yushin Cho | 8ab875d | 2017-06-23 14:47:21 -0700 | [diff] [blame] | 346 | #if CONFIG_HIGHBITDEPTH |
| 347 | DECLARE_ALIGNED(16, uint16_t, decoded_8x8[8 * 8]); |
| 348 | #else |
Yushin Cho | 63927c4 | 2017-05-23 15:41:05 -0700 | [diff] [blame] | 349 | DECLARE_ALIGNED(16, uint8_t, decoded_8x8[8 * 8]); |
Yushin Cho | 8ab875d | 2017-06-23 14:47:21 -0700 | [diff] [blame] | 350 | #endif |
Yushin Cho | b7b60c5 | 2017-07-14 16:18:52 -0700 | [diff] [blame] | 351 | #endif // CONFIG_DIST_8X8 |
Cheng Chen | 4697061 | 2017-10-24 14:53:36 -0700 | [diff] [blame] | 352 | #if CONFIG_JNT_COMP |
| 353 | int comp_idx_cost[COMP_INDEX_CONTEXTS][2]; |
Cheng Chen | 2ef24ea | 2017-11-29 12:22:24 -0800 | [diff] [blame] | 354 | int comp_group_idx_cost[COMP_GROUP_IDX_CONTEXTS][2]; |
Cheng Chen | 4697061 | 2017-10-24 14:53:36 -0700 | [diff] [blame] | 355 | #endif // CONFIG_JNT_COMP |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 356 | }; |
| 357 | |
| 358 | #ifdef __cplusplus |
| 359 | } // extern "C" |
| 360 | #endif |
| 361 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 362 | #endif // AV1_ENCODER_BLOCK_H_ |