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 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 12 | #ifndef AOM_AV1_ENCODER_BLOCK_H_ |
| 13 | #define AOM_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" |
chiyotsai | 36035d1 | 2019-06-19 17:39:48 -0700 | [diff] [blame] | 18 | |
Ravi Chaudhary | b61cdea | 2019-07-05 15:01:20 +0530 | [diff] [blame] | 19 | #include "av1/encoder/enc_enums.h" |
chiyotsai | 36035d1 | 2019-06-19 17:39:48 -0700 | [diff] [blame] | 20 | #if !CONFIG_REALTIME_ONLY |
| 21 | #include "av1/encoder/partition_cnn_weights.h" |
| 22 | #endif |
| 23 | |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 24 | #include "av1/encoder/hash.h" |
Yushin Cho | 5510433 | 2017-08-14 16:15:43 -0700 | [diff] [blame] | 25 | #if CONFIG_DIST_8X8 |
| 26 | #include "aom/aomcx.h" |
| 27 | #endif |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 28 | |
| 29 | #ifdef __cplusplus |
| 30 | extern "C" { |
| 31 | #endif |
| 32 | |
Yue Chen | bd93423 | 2019-08-05 14:23:39 -0700 | [diff] [blame] | 33 | // 1: use classic model 0: use count or saving stats |
| 34 | #define USE_TPL_CLASSIC_MODEL 0 |
Yunqing Wang | 61b2eac | 2019-09-24 16:45:16 -0700 | [diff] [blame] | 35 | #define MC_FLOW_BSIZE_1D 16 |
| 36 | #define MC_FLOW_NUM_PELS (MC_FLOW_BSIZE_1D * MC_FLOW_BSIZE_1D) |
| 37 | #define MAX_MC_FLOW_BLK_IN_SB (MAX_SB_SIZE / MC_FLOW_BSIZE_1D) |
Cherma Rajan A | d71ace6 | 2019-11-25 12:58:37 +0530 | [diff] [blame] | 38 | #define MAX_WINNER_MODE_COUNT_INTRA 3 |
| 39 | #define MAX_WINNER_MODE_COUNT_INTER 1 |
Cherma Rajan A | 835f7a6 | 2019-09-25 11:04:39 +0530 | [diff] [blame] | 40 | typedef struct { |
| 41 | MB_MODE_INFO mbmi; |
Cherma Rajan A | d71ace6 | 2019-11-25 12:58:37 +0530 | [diff] [blame] | 42 | RD_STATS rd_cost; |
Cherma Rajan A | 835f7a6 | 2019-09-25 11:04:39 +0530 | [diff] [blame] | 43 | int64_t rd; |
Cherma Rajan A | d71ace6 | 2019-11-25 12:58:37 +0530 | [diff] [blame] | 44 | int rate_y; |
| 45 | int rate_uv; |
Cherma Rajan A | 835f7a6 | 2019-09-25 11:04:39 +0530 | [diff] [blame] | 46 | uint8_t color_index_map[64 * 64]; |
Cherma Rajan A | d71ace6 | 2019-11-25 12:58:37 +0530 | [diff] [blame] | 47 | THR_MODES mode_index; |
Cherma Rajan A | 835f7a6 | 2019-09-25 11:04:39 +0530 | [diff] [blame] | 48 | } WinnerModeStats; |
Yue Chen | bd93423 | 2019-08-05 14:23:39 -0700 | [diff] [blame] | 49 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 50 | typedef struct { |
| 51 | unsigned int sse; |
| 52 | int sum; |
| 53 | unsigned int var; |
Urvang Joshi | 454280d | 2016-10-14 16:51:44 -0700 | [diff] [blame] | 54 | } DIFF; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 55 | |
| 56 | typedef struct macroblock_plane { |
Ravi Chaudhary | d4a5a50 | 2019-06-07 12:13:32 +0530 | [diff] [blame] | 57 | DECLARE_ALIGNED(32, int16_t, src_diff[MAX_SB_SQUARE]); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 58 | tran_low_t *qcoeff; |
| 59 | tran_low_t *coeff; |
| 60 | uint16_t *eobs; |
Angie Chiang | 74e2307 | 2017-03-24 14:54:23 -0700 | [diff] [blame] | 61 | uint8_t *txb_entropy_ctx; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 62 | struct buf_2d src; |
| 63 | |
| 64 | // Quantizer setings |
Monty Montgomery | 125c0fc | 2017-10-26 00:44:35 -0400 | [diff] [blame] | 65 | // These are used/accessed only in the quantization process |
| 66 | // RDO does not / must not depend on any of these values |
| 67 | // All values below share the coefficient scale/shift used in TX |
| 68 | const int16_t *quant_fp_QTX; |
| 69 | const int16_t *round_fp_QTX; |
| 70 | const int16_t *quant_QTX; |
| 71 | const int16_t *quant_shift_QTX; |
| 72 | const int16_t *zbin_QTX; |
| 73 | const int16_t *round_QTX; |
| 74 | const int16_t *dequant_QTX; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 75 | } MACROBLOCK_PLANE; |
| 76 | |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 77 | typedef struct { |
| 78 | int txb_skip_cost[TXB_SKIP_CONTEXTS][2]; |
Dake He | 3fe369c | 2017-11-16 17:56:44 -0800 | [diff] [blame] | 79 | int base_eob_cost[SIG_COEF_CONTEXTS_EOB][3]; |
Wenyao Liu | f7e5375 | 2019-01-22 17:34:44 +0800 | [diff] [blame] | 80 | int base_cost[SIG_COEF_CONTEXTS][8]; |
Angie Chiang | 7ab884e | 2017-10-18 15:57:12 -0700 | [diff] [blame] | 81 | int eob_extra_cost[EOB_COEF_CONTEXTS][2]; |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 82 | int dc_sign_cost[DC_SIGN_CONTEXTS][2]; |
Wenyao Liu | f7e5375 | 2019-01-22 17:34:44 +0800 | [diff] [blame] | 83 | int lps_cost[LEVEL_CONTEXTS][COEFF_BASE_RANGE + 1 + COEFF_BASE_RANGE + 1]; |
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 | |
Johann | b0ef6ff | 2018-02-08 14:32:21 -0800 | [diff] [blame] | 86 | typedef struct { |
| 87 | int eob_cost[2][11]; |
| 88 | } LV_MAP_EOB_COST; |
Dake He | 0db7d0e | 2017-12-21 15:23:20 -0800 | [diff] [blame] | 89 | |
Jingning Han | f5a4d3b | 2017-08-27 23:01:19 -0700 | [diff] [blame] | 90 | typedef struct { |
| 91 | tran_low_t tcoeff[MAX_MB_PLANE][MAX_SB_SQUARE]; |
| 92 | uint16_t eobs[MAX_MB_PLANE][MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN)]; |
Hui Su | c328ea2 | 2019-10-01 15:01:27 -0700 | [diff] [blame] | 93 | // Transform block entropy contexts. |
| 94 | // Bits 0~3: txb_skip_ctx; bits 4~5: dc_sign_ctx. |
| 95 | uint8_t entropy_ctx[MAX_MB_PLANE] |
| 96 | [MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN)]; |
Jingning Han | f5a4d3b | 2017-08-27 23:01:19 -0700 | [diff] [blame] | 97 | } CB_COEFF_BUFFER; |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 98 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 99 | typedef struct { |
Angie Chiang | c484abe | 2017-03-20 15:43:11 -0700 | [diff] [blame] | 100 | // TODO(angiebird): Reduce the buffer size according to sb_type |
Ravi Chaudhary | fa73e20 | 2019-08-19 12:41:26 +0530 | [diff] [blame] | 101 | CANDIDATE_MV ref_mv_stack[MODE_CTX_REF_FRAMES][USABLE_REF_MV_STACK_SIZE]; |
| 102 | uint16_t weight[MODE_CTX_REF_FRAMES][USABLE_REF_MV_STACK_SIZE]; |
Angie Chiang | 4c9b602 | 2018-04-10 16:16:45 -0700 | [diff] [blame] | 103 | int_mv global_mvs[REF_FRAMES]; |
Satish Kumar Suman | 69e9329 | 2018-11-28 16:05:33 +0530 | [diff] [blame] | 104 | int16_t mode_context[MODE_CTX_REF_FRAMES]; |
| 105 | uint8_t ref_mv_count[MODE_CTX_REF_FRAMES]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 106 | } MB_MODE_INFO_EXT; |
| 107 | |
Remya | 0cce44c | 2019-08-16 11:57:24 +0530 | [diff] [blame] | 108 | // Structure to store winner reference mode information at frame level. This |
| 109 | // frame level information will be used during bitstream preparation stage. |
| 110 | typedef struct { |
Ravi Chaudhary | fa73e20 | 2019-08-19 12:41:26 +0530 | [diff] [blame] | 111 | CANDIDATE_MV ref_mv_stack[USABLE_REF_MV_STACK_SIZE]; |
| 112 | uint16_t weight[USABLE_REF_MV_STACK_SIZE]; |
Remya | 0cce44c | 2019-08-16 11:57:24 +0530 | [diff] [blame] | 113 | // TODO(Ravi/Remya): Reduce the buffer size of global_mvs |
| 114 | int_mv global_mvs[REF_FRAMES]; |
| 115 | int cb_offset; |
| 116 | int16_t mode_context; |
| 117 | uint8_t ref_mv_count; |
| 118 | } MB_MODE_INFO_EXT_FRAME; |
| 119 | |
Alex Converse | 0fa0f42 | 2017-04-24 12:51:14 -0700 | [diff] [blame] | 120 | typedef struct { |
| 121 | int col_min; |
| 122 | int col_max; |
| 123 | int row_min; |
| 124 | int row_max; |
| 125 | } MvLimits; |
| 126 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 127 | typedef struct { |
Hui Su | 473cf89 | 2017-11-08 18:14:31 -0800 | [diff] [blame] | 128 | uint8_t best_palette_color_map[MAX_PALETTE_SQUARE]; |
Hui Su | 5891f98 | 2017-12-18 16:18:23 -0800 | [diff] [blame] | 129 | int kmeans_data_buf[2 * MAX_PALETTE_SQUARE]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 130 | } PALETTE_BUFFER; |
| 131 | |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 132 | typedef struct { |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 133 | TX_SIZE tx_size; |
Hui Su | 7167d95 | 2018-02-01 16:33:12 -0800 | [diff] [blame] | 134 | TX_SIZE inter_tx_size[INTER_TX_SIZE_BUF_LEN]; |
Hui Su | f4b79c7 | 2018-03-22 13:14:36 -0700 | [diff] [blame] | 135 | uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE]; |
Hui Su | 52b7ddc | 2019-10-10 16:27:16 -0700 | [diff] [blame] | 136 | uint8_t tx_type_map[MAX_MIB_SIZE * MAX_MIB_SIZE]; |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 137 | RD_STATS rd_stats; |
| 138 | uint32_t hash_value; |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 139 | } MB_RD_INFO; |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 140 | |
| 141 | #define RD_RECORD_BUFFER_LEN 8 |
| 142 | typedef struct { |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 143 | MB_RD_INFO tx_rd_info[RD_RECORD_BUFFER_LEN]; // Circular buffer. |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 144 | int index_start; |
| 145 | int num; |
Peng Bin | 8a204cd | 2018-04-08 13:07:35 +0800 | [diff] [blame] | 146 | CRC32C crc_calculator; // Hash function. |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 147 | } MB_RD_RECORD; |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 148 | |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 149 | typedef struct { |
| 150 | int64_t dist; |
Jingning Han | 73bc2aa | 2018-02-02 14:31:39 -0800 | [diff] [blame] | 151 | int64_t sse; |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 152 | int rate; |
Hui Su | 8c2b913 | 2017-12-09 10:40:15 -0800 | [diff] [blame] | 153 | uint16_t eob; |
Jingning Han | 73bc2aa | 2018-02-02 14:31:39 -0800 | [diff] [blame] | 154 | TX_TYPE tx_type; |
Jingning Han | 45027c6 | 2017-12-11 11:47:15 -0800 | [diff] [blame] | 155 | uint16_t entropy_context; |
Jingning Han | d7e9911 | 2017-12-13 09:47:45 -0800 | [diff] [blame] | 156 | uint8_t txb_entropy_ctx; |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 157 | uint8_t valid; |
Hui Su | 950b912 | 2018-02-03 10:21:40 -0800 | [diff] [blame] | 158 | uint8_t fast; // This is not being used now. |
Sachin Kumar Garg | 4ec28cb | 2019-06-06 19:33:58 +0530 | [diff] [blame] | 159 | uint8_t perform_block_coeff_opt; |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 160 | } TXB_RD_INFO; |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 161 | |
| 162 | #define TX_SIZE_RD_RECORD_BUFFER_LEN 256 |
| 163 | typedef struct { |
| 164 | uint32_t hash_vals[TX_SIZE_RD_RECORD_BUFFER_LEN]; |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 165 | TXB_RD_INFO tx_rd_info[TX_SIZE_RD_RECORD_BUFFER_LEN]; |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 166 | int index_start; |
| 167 | int num; |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 168 | } TXB_RD_RECORD; |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 169 | |
| 170 | typedef struct tx_size_rd_info_node { |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 171 | TXB_RD_INFO *rd_info_array; // Points to array of size TX_TYPES. |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 172 | struct tx_size_rd_info_node *children[4]; |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 173 | } TXB_RD_INFO_NODE; |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 174 | |
Peng Bin | 525e2da | 2018-09-06 11:32:58 +0800 | [diff] [blame] | 175 | // Simple translation rd state for prune_comp_search_by_single_result |
| 176 | typedef struct { |
| 177 | RD_STATS rd_stats; |
| 178 | RD_STATS rd_stats_y; |
| 179 | RD_STATS rd_stats_uv; |
| 180 | uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE]; |
Hui Su | 52b7ddc | 2019-10-10 16:27:16 -0700 | [diff] [blame] | 181 | uint8_t tx_type_map[MAX_MIB_SIZE * MAX_MIB_SIZE]; |
Peng Bin | 525e2da | 2018-09-06 11:32:58 +0800 | [diff] [blame] | 182 | uint8_t skip; |
| 183 | uint8_t disable_skip; |
| 184 | uint8_t early_skipped; |
| 185 | } SimpleRDState; |
| 186 | |
| 187 | // 4: NEAREST, NEW, NEAR, GLOBAL |
| 188 | #define SINGLE_REF_MODES ((REF_FRAMES - 1) * 4) |
| 189 | |
Ranjit Kumar Tulabandu | a1ebb57 | 2018-12-24 12:13:54 +0530 | [diff] [blame] | 190 | #define MAX_COMP_RD_STATS 64 |
| 191 | typedef struct { |
| 192 | int32_t rate[COMPOUND_TYPES]; |
| 193 | int64_t dist[COMPOUND_TYPES]; |
Venkat | 457e32e | 2019-12-19 17:44:05 +0530 | [diff] [blame^] | 194 | int32_t model_rate[COMPOUND_TYPES]; |
| 195 | int64_t model_dist[COMPOUND_TYPES]; |
Ranjit Kumar Tulabandu | a1ebb57 | 2018-12-24 12:13:54 +0530 | [diff] [blame] | 196 | int_mv mv[2]; |
Hui Su | d06ff66 | 2019-01-23 16:53:05 -0800 | [diff] [blame] | 197 | MV_REFERENCE_FRAME ref_frames[2]; |
Ranjit Kumar Tulabandu | a1ebb57 | 2018-12-24 12:13:54 +0530 | [diff] [blame] | 198 | PREDICTION_MODE mode; |
Ravi Chaudhary | 1e4f94b | 2019-06-20 16:19:49 +0530 | [diff] [blame] | 199 | int_interpfilters filter; |
Ranjit Kumar Tulabandu | a1ebb57 | 2018-12-24 12:13:54 +0530 | [diff] [blame] | 200 | int ref_mv_idx; |
| 201 | int is_global[2]; |
| 202 | } COMP_RD_STATS; |
| 203 | |
Hui Su | 38711e7 | 2019-06-11 10:49:47 -0700 | [diff] [blame] | 204 | // Struct for buffers used by compound_type_rd() function. |
| 205 | // For sizes and alignment of these arrays, refer to |
| 206 | // alloc_compound_type_rd_buffers() function. |
| 207 | typedef struct { |
| 208 | uint8_t *pred0; |
| 209 | uint8_t *pred1; |
| 210 | int16_t *residual1; // src - pred1 |
| 211 | int16_t *diff10; // pred1 - pred0 |
| 212 | uint8_t *tmp_best_mask_buf; // backup of the best segmentation mask |
| 213 | } CompoundTypeRdBuffers; |
| 214 | |
Ravi Chaudhary | 5d970f4 | 2018-09-25 11:25:32 +0530 | [diff] [blame] | 215 | struct inter_modes_info; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 216 | typedef struct macroblock MACROBLOCK; |
| 217 | struct macroblock { |
| 218 | struct macroblock_plane plane[MAX_MB_PLANE]; |
| 219 | |
Jingning Han | 66965a2 | 2018-01-25 09:53:41 -0800 | [diff] [blame] | 220 | // Determine if one would go with reduced complexity transform block |
| 221 | // search model to select prediction modes, or full complexity model |
| 222 | // to select transform kernel. |
Jingning Han | dd8600f | 2018-01-23 09:06:32 -0800 | [diff] [blame] | 223 | int rd_model; |
| 224 | |
elliottk | dfc5924 | 2019-04-25 16:38:51 -0700 | [diff] [blame] | 225 | // prune_comp_search_by_single_result (3:MAX_REF_MV_SEARCH) |
Peng Bin | 525e2da | 2018-09-06 11:32:58 +0800 | [diff] [blame] | 226 | SimpleRDState simple_rd_state[SINGLE_REF_MODES][3]; |
| 227 | |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 228 | // Inter macroblock RD search info. |
| 229 | MB_RD_RECORD mb_rd_record; |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 230 | |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 231 | // Inter transform block RD search info. for square TX sizes. |
| 232 | TXB_RD_RECORD txb_rd_record_8X8[(MAX_MIB_SIZE >> 1) * (MAX_MIB_SIZE >> 1)]; |
| 233 | TXB_RD_RECORD txb_rd_record_16X16[(MAX_MIB_SIZE >> 2) * (MAX_MIB_SIZE >> 2)]; |
| 234 | TXB_RD_RECORD txb_rd_record_32X32[(MAX_MIB_SIZE >> 3) * (MAX_MIB_SIZE >> 3)]; |
| 235 | TXB_RD_RECORD txb_rd_record_64X64[(MAX_MIB_SIZE >> 4) * (MAX_MIB_SIZE >> 4)]; |
| 236 | |
| 237 | // Intra transform block RD search info. for square TX sizes. |
| 238 | TXB_RD_RECORD txb_rd_record_intra; |
Hui Su | ec5a1ab | 2018-03-08 15:09:12 -0800 | [diff] [blame] | 239 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 240 | MACROBLOCKD e_mbd; |
| 241 | MB_MODE_INFO_EXT *mbmi_ext; |
Remya | 0cce44c | 2019-08-16 11:57:24 +0530 | [diff] [blame] | 242 | MB_MODE_INFO_EXT_FRAME *mbmi_ext_frame; |
Cherma Rajan A | 835f7a6 | 2019-09-25 11:04:39 +0530 | [diff] [blame] | 243 | // Array of mode stats for winner mode processing |
Cherma Rajan A | d71ace6 | 2019-11-25 12:58:37 +0530 | [diff] [blame] | 244 | WinnerModeStats winner_mode_stats[AOMMAX(MAX_WINNER_MODE_COUNT_INTRA, |
| 245 | MAX_WINNER_MODE_COUNT_INTER)]; |
Cherma Rajan A | 835f7a6 | 2019-09-25 11:04:39 +0530 | [diff] [blame] | 246 | int winner_mode_count; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 247 | int skip_block; |
David Barker | d7d78c8 | 2016-10-24 10:55:35 +0100 | [diff] [blame] | 248 | int qindex; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 249 | |
| 250 | // The equivalent error at the current rdmult of one whole bit (not one |
| 251 | // bitcost unit). |
| 252 | int errorperbit; |
| 253 | // The equivalend SAD error of one (whole) bit at the current quantizer |
| 254 | // for large blocks. |
| 255 | int sadperbit16; |
| 256 | // The equivalend SAD error of one (whole) bit at the current quantizer |
| 257 | // for sub-8x8 blocks. |
| 258 | int sadperbit4; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 259 | int rdmult; |
| 260 | int mb_energy; |
Yue Chen | de73047 | 2018-06-20 10:13:15 -0700 | [diff] [blame] | 261 | int sb_energy_level; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 262 | int *m_search_count_ptr; |
| 263 | int *ex_search_count_ptr; |
| 264 | |
Jingning Han | 9777afc | 2016-10-20 15:17:43 -0700 | [diff] [blame] | 265 | unsigned int txb_split_count; |
Debargha Mukherjee | 0857e66 | 2019-01-04 16:22:09 -0800 | [diff] [blame] | 266 | #if CONFIG_SPEED_STATS |
| 267 | unsigned int tx_search_count; |
| 268 | #endif // CONFIG_SPEED_STATS |
Jingning Han | 9777afc | 2016-10-20 15:17:43 -0700 | [diff] [blame] | 269 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 270 | // These are set to their default values at the beginning, and then adjusted |
| 271 | // further in the encoding process. |
| 272 | BLOCK_SIZE min_partition_size; |
| 273 | BLOCK_SIZE max_partition_size; |
| 274 | |
Zoe Liu | 27deb38 | 2018-03-27 15:13:56 -0700 | [diff] [blame] | 275 | unsigned int max_mv_context[REF_FRAMES]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 276 | unsigned int source_variance; |
Yue Chen | 4f719c2 | 2019-02-15 15:13:27 -0800 | [diff] [blame] | 277 | unsigned int simple_motion_pred_sse; |
Zoe Liu | 27deb38 | 2018-03-27 15:13:56 -0700 | [diff] [blame] | 278 | unsigned int pred_sse[REF_FRAMES]; |
| 279 | int pred_mv_sad[REF_FRAMES]; |
Lokeshwar Reddy B | ce8b759 | 2019-07-09 18:19:55 +0530 | [diff] [blame] | 280 | int best_pred_mv_sad; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 281 | |
Jingning Han | f050fc1 | 2018-03-09 14:53:33 -0800 | [diff] [blame] | 282 | int nmv_vec_cost[MV_JOINTS]; |
Debargha Mukherjee | 8d27341 | 2019-09-11 10:36:50 -0700 | [diff] [blame] | 283 | int nmv_costs[2][MV_VALS]; |
| 284 | int nmv_costs_hp[2][MV_VALS]; |
Jingning Han | f050fc1 | 2018-03-09 14:53:33 -0800 | [diff] [blame] | 285 | int *nmvcost[2]; |
| 286 | int *nmvcost_hp[2]; |
| 287 | int **mv_cost_stack; |
Alex Converse | a127a79 | 2017-05-23 15:27:21 -0700 | [diff] [blame] | 288 | |
Yue Chen | e9638cc | 2016-10-10 12:37:54 -0700 | [diff] [blame] | 289 | int32_t *wsrc_buf; |
| 290 | int32_t *mask_buf; |
Jingning Han | d064cf0 | 2017-06-01 10:00:39 -0700 | [diff] [blame] | 291 | uint8_t *above_pred_buf; |
| 292 | uint8_t *left_pred_buf; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 293 | |
| 294 | PALETTE_BUFFER *palette_buffer; |
Hui Su | 38711e7 | 2019-06-11 10:49:47 -0700 | [diff] [blame] | 295 | CompoundTypeRdBuffers comp_rd_buffer; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 296 | |
Urvang Joshi | 0a4cfad | 2018-09-07 11:10:39 -0700 | [diff] [blame] | 297 | CONV_BUF_TYPE *tmp_conv_dst; |
| 298 | uint8_t *tmp_obmc_bufs[2]; |
| 299 | |
Ravi Chaudhary | e521517 | 2018-12-21 18:47:25 +0530 | [diff] [blame] | 300 | FRAME_CONTEXT *row_ctx; |
Ravi Chaudhary | 982ac04 | 2018-11-02 14:30:29 +0530 | [diff] [blame] | 301 | // This context will be used to update color_map_cdf pointer which would be |
| 302 | // used during pack bitstream. For single thread and tile-multithreading case |
| 303 | // this ponter will be same as xd->tile_ctx, but for the case of row-mt: |
| 304 | // xd->tile_ctx will point to a temporary context while tile_pb_ctx will point |
| 305 | // to the accurate tile context. |
| 306 | FRAME_CONTEXT *tile_pb_ctx; |
Ravi Chaudhary | 84a280a | 2018-09-24 16:09:48 +0530 | [diff] [blame] | 307 | |
Ravi Chaudhary | 5d970f4 | 2018-09-25 11:25:32 +0530 | [diff] [blame] | 308 | struct inter_modes_info *inter_modes_info; |
Ravi Chaudhary | 5d970f4 | 2018-09-25 11:25:32 +0530 | [diff] [blame] | 309 | |
Ravi Chaudhary | 783d6a3 | 2018-08-28 18:21:02 +0530 | [diff] [blame] | 310 | // buffer for hash value calculation of a block |
| 311 | // used only in av1_get_block_hash_value() |
| 312 | // [first hash/second hash] |
| 313 | // [two buffers used ping-pong] |
| 314 | uint32_t *hash_value_buffer[2][2]; |
| 315 | |
| 316 | CRC_CALCULATOR crc_calculator1; |
| 317 | CRC_CALCULATOR crc_calculator2; |
| 318 | int g_crc_initialized; |
| 319 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 320 | // These define limits to motion vector components to prevent them |
| 321 | // from extending outside the UMV borders |
Alex Converse | 0fa0f42 | 2017-04-24 12:51:14 -0700 | [diff] [blame] | 322 | MvLimits mv_limits; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 323 | |
Hui Su | f4b79c7 | 2018-03-22 13:14:36 -0700 | [diff] [blame] | 324 | uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE]; |
Hui Su | 52b7ddc | 2019-10-10 16:27:16 -0700 | [diff] [blame] | 325 | uint8_t tx_type_map[MAX_MIB_SIZE * MAX_MIB_SIZE]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 326 | |
Hui Su | 9349b8f | 2019-12-13 11:56:06 -0800 | [diff] [blame] | 327 | // Force the coding block to skip transform and quantization. |
| 328 | int force_skip; |
Jingning Han | 8efdbc8 | 2017-02-19 14:40:03 -0800 | [diff] [blame] | 329 | int skip_chroma_rd; |
Zoe Liu | 1eed2df | 2017-10-16 17:13:15 -0700 | [diff] [blame] | 330 | int skip_cost[SKIP_CONTEXTS][2]; |
| 331 | |
Zoe Liu | f40a957 | 2017-10-13 12:37:19 -0700 | [diff] [blame] | 332 | int skip_mode; // 0: off; 1: on |
| 333 | int skip_mode_cost[SKIP_CONTEXTS][2]; |
| 334 | |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 335 | LV_MAP_COEFF_COST coeff_costs[TX_SIZES][PLANE_TYPES]; |
Dake He | 0db7d0e | 2017-12-21 15:23:20 -0800 | [diff] [blame] | 336 | LV_MAP_EOB_COST eob_costs[7][2]; |
Jingning Han | f5a4d3b | 2017-08-27 23:01:19 -0700 | [diff] [blame] | 337 | uint16_t cb_offset; |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 338 | |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 339 | // mode costs |
Yue Chen | 170678a | 2017-10-17 13:43:10 -0700 | [diff] [blame] | 340 | int intra_inter_cost[INTRA_INTER_CONTEXTS][2]; |
| 341 | |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 342 | int mbmode_cost[BLOCK_SIZE_GROUPS][INTRA_MODES]; |
| 343 | int newmv_mode_cost[NEWMV_MODE_CONTEXTS][2]; |
Sarah Parker | 2b9ec2e | 2017-10-30 17:34:08 -0700 | [diff] [blame] | 344 | int zeromv_mode_cost[GLOBALMV_MODE_CONTEXTS][2]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 345 | int refmv_mode_cost[REFMV_MODE_CONTEXTS][2]; |
| 346 | int drl_mode_cost0[DRL_MODE_CONTEXTS][2]; |
| 347 | |
Hui Su | 9d0c03d | 2017-12-27 16:05:23 -0800 | [diff] [blame] | 348 | int comp_inter_cost[COMP_INTER_CONTEXTS][2]; |
Hui Su | 3d30b4b | 2017-12-27 16:47:59 -0800 | [diff] [blame] | 349 | int single_ref_cost[REF_CONTEXTS][SINGLE_REFS - 1][2]; |
Hui Su | 6b3d1e3 | 2018-01-05 11:25:40 -0800 | [diff] [blame] | 350 | int comp_ref_type_cost[COMP_REF_TYPE_CONTEXTS] |
| 351 | [CDF_SIZE(COMP_REFERENCE_TYPES)]; |
Hui Su | a7e3bfe | 2018-01-05 12:14:48 -0800 | [diff] [blame] | 352 | int uni_comp_ref_cost[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1] |
| 353 | [CDF_SIZE(2)]; |
Hui Su | 0bdf5f5 | 2018-01-05 14:54:32 -0800 | [diff] [blame] | 354 | // Cost for signaling ref_frame[0] (LAST_FRAME, LAST2_FRAME, LAST3_FRAME or |
| 355 | // GOLDEN_FRAME) in bidir-comp mode. |
Zoe Liu | 3b35347 | 2018-02-12 13:58:22 -0800 | [diff] [blame] | 356 | int comp_ref_cost[REF_CONTEXTS][FWD_REFS - 1][2]; |
Hui Su | 0bdf5f5 | 2018-01-05 14:54:32 -0800 | [diff] [blame] | 357 | // Cost for signaling ref_frame[1] (ALTREF_FRAME, ALTREF2_FRAME, or |
| 358 | // BWDREF_FRAME) in bidir-comp mode. |
Zoe Liu | 3b35347 | 2018-02-12 13:58:22 -0800 | [diff] [blame] | 359 | int comp_bwdref_cost[REF_CONTEXTS][BWD_REFS - 1][2]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 360 | int inter_compound_mode_cost[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES]; |
Debargha Mukherjee | 54eabb5 | 2019-02-01 16:54:33 -0800 | [diff] [blame] | 361 | int compound_type_cost[BLOCK_SIZES_ALL][MASKED_COMPOUND_TYPES]; |
Yue Chen | 73335fa | 2017-12-20 23:33:41 -0800 | [diff] [blame] | 362 | int wedge_idx_cost[BLOCK_SIZES_ALL][16]; |
Yue Chen | eaf128a | 2017-10-16 17:01:36 -0700 | [diff] [blame] | 363 | int interintra_cost[BLOCK_SIZE_GROUPS][2]; |
| 364 | int wedge_interintra_cost[BLOCK_SIZES_ALL][2]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 365 | int interintra_mode_cost[BLOCK_SIZE_GROUPS][INTERINTRA_MODES]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 366 | int motion_mode_cost[BLOCK_SIZES_ALL][MOTION_MODES]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 367 | int motion_mode_cost1[BLOCK_SIZES_ALL][2]; |
David Michael Barr | cb3a8ef | 2018-01-06 15:48:49 +0900 | [diff] [blame] | 368 | int intra_uv_mode_cost[CFL_ALLOWED_TYPES][INTRA_MODES][UV_INTRA_MODES]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 369 | int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES]; |
Yue Chen | 45dfb79 | 2018-03-01 13:02:40 -0800 | [diff] [blame] | 370 | int filter_intra_cost[BLOCK_SIZES_ALL][2]; |
Yue Chen | 994dba2 | 2017-12-19 15:27:26 -0800 | [diff] [blame] | 371 | int filter_intra_mode_cost[FILTER_INTRA_MODES]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 372 | int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS]; |
Sebastien Alaiwan | a6a486c | 2017-11-07 17:04:27 +0100 | [diff] [blame] | 373 | int partition_cost[PARTITION_CONTEXTS][EXT_PARTITION_TYPES]; |
Hui Su | c1f411b | 2017-12-19 15:58:28 -0800 | [diff] [blame] | 374 | int palette_y_size_cost[PALATTE_BSIZE_CTXS][PALETTE_SIZES]; |
| 375 | int palette_uv_size_cost[PALATTE_BSIZE_CTXS][PALETTE_SIZES]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 376 | int palette_y_color_cost[PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS] |
| 377 | [PALETTE_COLORS]; |
| 378 | int palette_uv_color_cost[PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS] |
| 379 | [PALETTE_COLORS]; |
Hui Su | c1f411b | 2017-12-19 15:58:28 -0800 | [diff] [blame] | 380 | int palette_y_mode_cost[PALATTE_BSIZE_CTXS][PALETTE_Y_MODE_CONTEXTS][2]; |
Yue Chen | dab2ca9 | 2017-10-16 17:48:48 -0700 | [diff] [blame] | 381 | int palette_uv_mode_cost[PALETTE_UV_MODE_CONTEXTS][2]; |
David Michael Barr | 38e560c | 2017-08-16 21:46:37 +0900 | [diff] [blame] | 382 | // The rate associated with each alpha codeword |
| 383 | int cfl_cost[CFL_JOINT_SIGNS][CFL_PRED_PLANES][CFL_ALPHABET_SIZE]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 384 | int tx_size_cost[TX_SIZES - 1][TX_SIZE_CONTEXTS][TX_SIZES]; |
Yue Chen | 171c17d | 2017-10-16 18:08:22 -0700 | [diff] [blame] | 385 | int txfm_partition_cost[TXFM_PARTITION_CONTEXTS][2]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 386 | int inter_tx_type_costs[EXT_TX_SETS_INTER][EXT_TX_SIZES][TX_TYPES]; |
| 387 | int intra_tx_type_costs[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES] |
| 388 | [TX_TYPES]; |
Joe Young | 3ca43bf | 2017-10-06 15:12:46 -0700 | [diff] [blame] | 389 | int angle_delta_cost[DIRECTIONAL_MODES][2 * MAX_ANGLE_DELTA + 1]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 390 | int switchable_restore_cost[RESTORE_SWITCHABLE_TYPES]; |
Debargha Mukherjee | bc732ef | 2017-10-12 12:40:25 -0700 | [diff] [blame] | 391 | int wiener_restore_cost[2]; |
| 392 | int sgrproj_restore_cost[2]; |
Hui Su | 6c8584f | 2017-09-14 15:37:02 -0700 | [diff] [blame] | 393 | int intrabc_cost[2]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 394 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 395 | // Used to store sub partition's choices. |
Zoe Liu | 27deb38 | 2018-03-27 15:13:56 -0700 | [diff] [blame] | 396 | MV pred_mv[REF_FRAMES]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 397 | |
| 398 | // Store the best motion vector during motion search |
| 399 | int_mv best_mv; |
| 400 | // Store the second best motion vector during full-pixel motion search |
| 401 | int_mv second_best_mv; |
| 402 | |
Venkat | e846e2b | 2018-09-21 07:31:14 +0530 | [diff] [blame] | 403 | // Store the fractional best motion vector during sub/Qpel-pixel motion search |
| 404 | int_mv fractional_best_mv[3]; |
| 405 | |
Hui Su | 835bbd5 | 2019-03-05 23:18:15 -0800 | [diff] [blame] | 406 | // Ref frames that are selected by square partition blocks within a super- |
| 407 | // block, in MI resolution. They can be used to prune ref frames for |
| 408 | // rectangular blocks. |
| 409 | int picked_ref_frames_mask[32 * 32]; |
| 410 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 411 | // use default transform and skip transform type search for intra modes |
| 412 | int use_default_intra_tx_type; |
| 413 | // use default transform and skip transform type search for inter modes |
| 414 | int use_default_inter_tx_type; |
Yushin Cho | b7b60c5 | 2017-07-14 16:18:52 -0700 | [diff] [blame] | 415 | #if CONFIG_DIST_8X8 |
Yushin Cho | 5510433 | 2017-08-14 16:15:43 -0700 | [diff] [blame] | 416 | int using_dist_8x8; |
| 417 | aom_tune_metric tune_metric; |
Yushin Cho | b7b60c5 | 2017-07-14 16:18:52 -0700 | [diff] [blame] | 418 | #endif // CONFIG_DIST_8X8 |
Cheng Chen | 4697061 | 2017-10-24 14:53:36 -0700 | [diff] [blame] | 419 | int comp_idx_cost[COMP_INDEX_CONTEXTS][2]; |
Cheng Chen | 2ef24ea | 2017-11-29 12:22:24 -0800 | [diff] [blame] | 420 | int comp_group_idx_cost[COMP_GROUP_IDX_CONTEXTS][2]; |
Hui Su | 845a741 | 2018-03-08 12:21:00 -0800 | [diff] [blame] | 421 | int must_find_valid_partition; |
Ranjit Kumar Tulabandu | 8105bf4 | 2018-07-27 14:16:55 +0530 | [diff] [blame] | 422 | int recalc_luma_mc_data; // Flag to indicate recalculation of MC data during |
| 423 | // interpolation filter search |
Cherma Rajan A | 12478f3 | 2019-10-31 10:03:34 +0530 | [diff] [blame] | 424 | int prune_mode; |
Cherma Rajan A | 628efce | 2019-09-18 18:55:12 +0530 | [diff] [blame] | 425 | uint32_t tx_domain_dist_threshold; |
Cherma Rajan A | ba4e156 | 2019-08-29 14:45:22 +0530 | [diff] [blame] | 426 | int use_transform_domain_distortion; |
elliottk | 1dbb8c1 | 2018-11-06 22:28:59 -0800 | [diff] [blame] | 427 | // The likelihood of an edge existing in the block (using partial Canny edge |
| 428 | // detection). For reference, 556 is the value returned for a solid |
| 429 | // vertical black/white edge. |
| 430 | uint16_t edge_strength; |
elliottk | 17dd3ea | 2019-02-01 11:59:57 -0800 | [diff] [blame] | 431 | // The strongest edge strength seen along the x/y axis. |
| 432 | uint16_t edge_strength_x; |
| 433 | uint16_t edge_strength_y; |
Remya | 05be56a | 2019-04-15 19:09:08 +0530 | [diff] [blame] | 434 | uint8_t compound_idx; |
Ranjit Kumar Tulabandu | a1ebb57 | 2018-12-24 12:13:54 +0530 | [diff] [blame] | 435 | |
| 436 | // [Saved stat index] |
| 437 | COMP_RD_STATS comp_rd_stats[MAX_COMP_RD_STATS]; |
| 438 | int comp_rd_stats_idx; |
Hui Su | f1b1106 | 2019-04-17 14:18:26 -0700 | [diff] [blame] | 439 | |
| 440 | CB_COEFF_BUFFER *cb_coef_buff; |
chiyotsai | 36035d1 | 2019-06-19 17:39:48 -0700 | [diff] [blame] | 441 | |
Ranjit Kumar Tulabandu | 824f9db | 2019-07-05 15:16:37 +0530 | [diff] [blame] | 442 | // Threshold used to decide the applicability of R-D optimization of |
| 443 | // quantized coeffs |
| 444 | uint32_t coeff_opt_dist_threshold; |
| 445 | |
chiyotsai | 36035d1 | 2019-06-19 17:39:48 -0700 | [diff] [blame] | 446 | #if !CONFIG_REALTIME_ONLY |
| 447 | int quad_tree_idx; |
chiyotsai | 52ac004 | 2019-07-01 09:48:03 -0700 | [diff] [blame] | 448 | int cnn_output_valid; |
chiyotsai | 36035d1 | 2019-06-19 17:39:48 -0700 | [diff] [blame] | 449 | float cnn_buffer[CNN_OUT_BUF_SIZE]; |
| 450 | float log_q; |
| 451 | #endif |
Ravi Chaudhary | b61cdea | 2019-07-05 15:01:20 +0530 | [diff] [blame] | 452 | int thresh_freq_fact[BLOCK_SIZES_ALL][MAX_MODES]; |
Fyodor Kyslov | 59745d9 | 2019-07-30 18:16:54 -0700 | [diff] [blame] | 453 | uint8_t variance_low[105]; |
Fyodor Kyslov | abef54f | 2019-08-14 14:43:12 -0700 | [diff] [blame] | 454 | // Strong color activity detection. Used in REALTIME coding mode to enhance |
| 455 | // the visual quality at the boundary of moving color objects. |
| 456 | uint8_t color_sensitivity[2]; |
Marco Paniconi | c681cf1 | 2019-11-05 15:24:00 -0800 | [diff] [blame] | 457 | int nonrd_reduce_golden_mode_search; |
Cherma Rajan A | 3ed030f | 2019-08-16 18:56:00 +0530 | [diff] [blame] | 458 | |
| 459 | // Used to control the tx size search evaluation for mode processing |
| 460 | // (normal/winner mode) |
| 461 | int tx_size_search_method; |
chiyotsai | f271f9f | 2019-11-25 16:44:25 -0800 | [diff] [blame] | 462 | // This tx_mode_search_type is used internally by the encoder, and is not |
| 463 | // written to the bitstream. It determines what kind of tx_mode should be |
| 464 | // searched. For example, we might set it to TX_MODE_LARGEST to find a good |
| 465 | // candidate, then use TX_MODE_SELECT on it |
| 466 | TX_MODE tx_mode_search_type; |
Yunqing Wang | 61b2eac | 2019-09-24 16:45:16 -0700 | [diff] [blame] | 467 | |
Nithya V S | d0276ac | 2019-10-24 11:31:06 +0530 | [diff] [blame] | 468 | // Used to control aggressiveness of skip flag prediction for mode processing |
| 469 | // (normal/winner mode) |
| 470 | unsigned int predict_skip_level; |
| 471 | |
Yunqing Wang | 61b2eac | 2019-09-24 16:45:16 -0700 | [diff] [blame] | 472 | // Copy out this SB's TPL block stats. |
| 473 | int valid_cost_b; |
| 474 | int64_t inter_cost_b[MAX_MC_FLOW_BLK_IN_SB * MAX_MC_FLOW_BLK_IN_SB]; |
| 475 | int64_t intra_cost_b[MAX_MC_FLOW_BLK_IN_SB * MAX_MC_FLOW_BLK_IN_SB]; |
| 476 | int cost_stride; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 477 | }; |
| 478 | |
Yunqing Wang | 8317cac | 2019-09-25 10:52:51 -0700 | [diff] [blame] | 479 | // Only consider full SB, MC_FLOW_BSIZE_1D = 16. |
| 480 | static INLINE int tpl_blocks_in_sb(BLOCK_SIZE bsize) { |
| 481 | switch (bsize) { |
| 482 | case BLOCK_64X64: return 16; |
| 483 | case BLOCK_128X128: return 64; |
| 484 | default: assert(0); |
| 485 | } |
| 486 | return -1; |
| 487 | } |
| 488 | |
Frederic Barbier | 0f191da | 2018-01-03 17:29:26 +0100 | [diff] [blame] | 489 | static INLINE int is_rect_tx_allowed_bsize(BLOCK_SIZE bsize) { |
| 490 | static const char LUT[BLOCK_SIZES_ALL] = { |
| 491 | 0, // BLOCK_4X4 |
| 492 | 1, // BLOCK_4X8 |
| 493 | 1, // BLOCK_8X4 |
| 494 | 0, // BLOCK_8X8 |
| 495 | 1, // BLOCK_8X16 |
| 496 | 1, // BLOCK_16X8 |
| 497 | 0, // BLOCK_16X16 |
| 498 | 1, // BLOCK_16X32 |
| 499 | 1, // BLOCK_32X16 |
| 500 | 0, // BLOCK_32X32 |
| 501 | 1, // BLOCK_32X64 |
| 502 | 1, // BLOCK_64X32 |
| 503 | 0, // BLOCK_64X64 |
Frederic Barbier | 0f191da | 2018-01-03 17:29:26 +0100 | [diff] [blame] | 504 | 0, // BLOCK_64X128 |
| 505 | 0, // BLOCK_128X64 |
| 506 | 0, // BLOCK_128X128 |
Frederic Barbier | 0f191da | 2018-01-03 17:29:26 +0100 | [diff] [blame] | 507 | 1, // BLOCK_4X16 |
| 508 | 1, // BLOCK_16X4 |
| 509 | 1, // BLOCK_8X32 |
| 510 | 1, // BLOCK_32X8 |
| 511 | 1, // BLOCK_16X64 |
| 512 | 1, // BLOCK_64X16 |
Frederic Barbier | 0f191da | 2018-01-03 17:29:26 +0100 | [diff] [blame] | 513 | }; |
| 514 | |
| 515 | return LUT[bsize]; |
| 516 | } |
| 517 | |
| 518 | static INLINE int is_rect_tx_allowed(const MACROBLOCKD *xd, |
| 519 | const MB_MODE_INFO *mbmi) { |
| 520 | return is_rect_tx_allowed_bsize(mbmi->sb_type) && |
| 521 | !xd->lossless[mbmi->segment_id]; |
| 522 | } |
| 523 | |
Frederic Barbier | 4b56b10 | 2018-03-30 16:09:34 +0200 | [diff] [blame] | 524 | static INLINE int tx_size_to_depth(TX_SIZE tx_size, BLOCK_SIZE bsize) { |
Urvang Joshi | dd0376f | 2018-05-02 16:37:25 -0700 | [diff] [blame] | 525 | TX_SIZE ctx_size = max_txsize_rect_lookup[bsize]; |
Frederic Barbier | 0f191da | 2018-01-03 17:29:26 +0100 | [diff] [blame] | 526 | int depth = 0; |
| 527 | while (tx_size != ctx_size) { |
| 528 | depth++; |
Frederic Barbier | 4b56b10 | 2018-03-30 16:09:34 +0200 | [diff] [blame] | 529 | ctx_size = sub_tx_size_map[ctx_size]; |
Frederic Barbier | 0f191da | 2018-01-03 17:29:26 +0100 | [diff] [blame] | 530 | assert(depth <= MAX_TX_DEPTH); |
| 531 | } |
| 532 | return depth; |
| 533 | } |
| 534 | |
Grant Hsu | 39248c3 | 2018-09-18 10:38:44 +0800 | [diff] [blame] | 535 | static INLINE void set_blk_skip(MACROBLOCK *x, int plane, int blk_idx, |
| 536 | int skip) { |
| 537 | if (skip) |
| 538 | x->blk_skip[blk_idx] |= 1UL << plane; |
| 539 | else |
| 540 | x->blk_skip[blk_idx] &= ~(1UL << plane); |
| 541 | #ifndef NDEBUG |
| 542 | // Set chroma planes to uninitialized states when luma is set to check if |
| 543 | // it will be set later |
| 544 | if (plane == 0) { |
| 545 | x->blk_skip[blk_idx] |= 1UL << (1 + 4); |
| 546 | x->blk_skip[blk_idx] |= 1UL << (2 + 4); |
| 547 | } |
| 548 | |
| 549 | // Clear the initialization checking bit |
| 550 | x->blk_skip[blk_idx] &= ~(1UL << (plane + 4)); |
| 551 | #endif |
| 552 | } |
| 553 | |
| 554 | static INLINE int is_blk_skip(MACROBLOCK *x, int plane, int blk_idx) { |
| 555 | #ifndef NDEBUG |
| 556 | // Check if this is initialized |
| 557 | assert(!(x->blk_skip[blk_idx] & (1UL << (plane + 4)))); |
| 558 | |
| 559 | // The magic number is 0x77, this is to test if there is garbage data |
| 560 | assert((x->blk_skip[blk_idx] & 0x88) == 0); |
| 561 | #endif |
| 562 | return (x->blk_skip[blk_idx] >> plane) & 1; |
| 563 | } |
| 564 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 565 | #ifdef __cplusplus |
| 566 | } // extern "C" |
| 567 | #endif |
| 568 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 569 | #endif // AOM_AV1_ENCODER_BLOCK_H_ |