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" |
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 | uint8_t *txb_entropy_ctx; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 39 | struct buf_2d src; |
| 40 | |
| 41 | // Quantizer setings |
Monty Montgomery | 125c0fc | 2017-10-26 00:44:35 -0400 | [diff] [blame] | 42 | // These are used/accessed only in the quantization process |
| 43 | // RDO does not / must not depend on any of these values |
| 44 | // All values below share the coefficient scale/shift used in TX |
| 45 | const int16_t *quant_fp_QTX; |
| 46 | const int16_t *round_fp_QTX; |
| 47 | const int16_t *quant_QTX; |
| 48 | const int16_t *quant_shift_QTX; |
| 49 | const int16_t *zbin_QTX; |
| 50 | const int16_t *round_QTX; |
| 51 | const int16_t *dequant_QTX; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 52 | } MACROBLOCK_PLANE; |
| 53 | |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 54 | typedef struct { |
| 55 | int txb_skip_cost[TXB_SKIP_CONTEXTS][2]; |
Dake He | 3fe369c | 2017-11-16 17:56:44 -0800 | [diff] [blame] | 56 | int base_eob_cost[SIG_COEF_CONTEXTS_EOB][3]; |
Wenyao Liu | f7e5375 | 2019-01-22 17:34:44 +0800 | [diff] [blame] | 57 | int base_cost[SIG_COEF_CONTEXTS][8]; |
Angie Chiang | 7ab884e | 2017-10-18 15:57:12 -0700 | [diff] [blame] | 58 | int eob_extra_cost[EOB_COEF_CONTEXTS][2]; |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 59 | int dc_sign_cost[DC_SIGN_CONTEXTS][2]; |
Wenyao Liu | f7e5375 | 2019-01-22 17:34:44 +0800 | [diff] [blame] | 60 | 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] | 61 | } LV_MAP_COEFF_COST; |
Jingning Han | f5a4d3b | 2017-08-27 23:01:19 -0700 | [diff] [blame] | 62 | |
Johann | b0ef6ff | 2018-02-08 14:32:21 -0800 | [diff] [blame] | 63 | typedef struct { |
| 64 | int eob_cost[2][11]; |
| 65 | } LV_MAP_EOB_COST; |
Dake He | 0db7d0e | 2017-12-21 15:23:20 -0800 | [diff] [blame] | 66 | |
Jingning Han | f5a4d3b | 2017-08-27 23:01:19 -0700 | [diff] [blame] | 67 | typedef struct { |
| 68 | tran_low_t tcoeff[MAX_MB_PLANE][MAX_SB_SQUARE]; |
| 69 | uint16_t eobs[MAX_MB_PLANE][MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN)]; |
| 70 | uint8_t txb_skip_ctx[MAX_MB_PLANE] |
| 71 | [MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN)]; |
| 72 | int dc_sign_ctx[MAX_MB_PLANE] |
| 73 | [MAX_SB_SQUARE / (TX_SIZE_W_MIN * TX_SIZE_H_MIN)]; |
| 74 | } CB_COEFF_BUFFER; |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 75 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 76 | typedef struct { |
Angie Chiang | c484abe | 2017-03-20 15:43:11 -0700 | [diff] [blame] | 77 | // TODO(angiebird): Reduce the buffer size according to sb_type |
Satish Kumar Suman | e40c226 | 2019-03-13 14:59:39 +0530 | [diff] [blame] | 78 | CB_COEFF_BUFFER *cb_coef_buff; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 79 | CANDIDATE_MV ref_mv_stack[MODE_CTX_REF_FRAMES][MAX_REF_MV_STACK_SIZE]; |
Remya | 628055b | 2019-04-12 19:44:38 +0530 | [diff] [blame] | 80 | uint16_t weight[MODE_CTX_REF_FRAMES][MAX_REF_MV_STACK_SIZE]; |
Angie Chiang | 4c9b602 | 2018-04-10 16:16:45 -0700 | [diff] [blame] | 81 | int_mv global_mvs[REF_FRAMES]; |
Satish Kumar Suman | e40c226 | 2019-03-13 14:59:39 +0530 | [diff] [blame] | 82 | int cb_offset; |
Satish Kumar Suman | 69e9329 | 2018-11-28 16:05:33 +0530 | [diff] [blame] | 83 | int16_t mode_context[MODE_CTX_REF_FRAMES]; |
| 84 | uint8_t ref_mv_count[MODE_CTX_REF_FRAMES]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 85 | } MB_MODE_INFO_EXT; |
| 86 | |
Alex Converse | 0fa0f42 | 2017-04-24 12:51:14 -0700 | [diff] [blame] | 87 | typedef struct { |
| 88 | int col_min; |
| 89 | int col_max; |
| 90 | int row_min; |
| 91 | int row_max; |
| 92 | } MvLimits; |
| 93 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 94 | typedef struct { |
Hui Su | 473cf89 | 2017-11-08 18:14:31 -0800 | [diff] [blame] | 95 | uint8_t best_palette_color_map[MAX_PALETTE_SQUARE]; |
Hui Su | 5891f98 | 2017-12-18 16:18:23 -0800 | [diff] [blame] | 96 | int kmeans_data_buf[2 * MAX_PALETTE_SQUARE]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 97 | } PALETTE_BUFFER; |
| 98 | |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 99 | typedef struct { |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 100 | TX_SIZE tx_size; |
Hui Su | 7167d95 | 2018-02-01 16:33:12 -0800 | [diff] [blame] | 101 | TX_SIZE inter_tx_size[INTER_TX_SIZE_BUF_LEN]; |
Hui Su | f4b79c7 | 2018-03-22 13:14:36 -0700 | [diff] [blame] | 102 | uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE]; |
Hui Su | de1a5db | 2018-02-22 15:44:49 -0800 | [diff] [blame] | 103 | TX_TYPE txk_type[TXK_TYPE_BUF_LEN]; |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 104 | RD_STATS rd_stats; |
| 105 | uint32_t hash_value; |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 106 | } MB_RD_INFO; |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 107 | |
| 108 | #define RD_RECORD_BUFFER_LEN 8 |
| 109 | typedef struct { |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 110 | MB_RD_INFO tx_rd_info[RD_RECORD_BUFFER_LEN]; // Circular buffer. |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 111 | int index_start; |
| 112 | int num; |
Peng Bin | 8a204cd | 2018-04-08 13:07:35 +0800 | [diff] [blame] | 113 | CRC32C crc_calculator; // Hash function. |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 114 | } MB_RD_RECORD; |
Hui Su | 1ddf231 | 2017-08-19 15:21:34 -0700 | [diff] [blame] | 115 | |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 116 | typedef struct { |
| 117 | int64_t dist; |
Jingning Han | 73bc2aa | 2018-02-02 14:31:39 -0800 | [diff] [blame] | 118 | int64_t sse; |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 119 | int rate; |
Hui Su | 8c2b913 | 2017-12-09 10:40:15 -0800 | [diff] [blame] | 120 | uint16_t eob; |
Jingning Han | 73bc2aa | 2018-02-02 14:31:39 -0800 | [diff] [blame] | 121 | TX_TYPE tx_type; |
Jingning Han | 45027c6 | 2017-12-11 11:47:15 -0800 | [diff] [blame] | 122 | uint16_t entropy_context; |
Jingning Han | d7e9911 | 2017-12-13 09:47:45 -0800 | [diff] [blame] | 123 | uint8_t txb_entropy_ctx; |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 124 | uint8_t valid; |
Hui Su | 950b912 | 2018-02-03 10:21:40 -0800 | [diff] [blame] | 125 | uint8_t fast; // This is not being used now. |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 126 | } TXB_RD_INFO; |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 127 | |
| 128 | #define TX_SIZE_RD_RECORD_BUFFER_LEN 256 |
| 129 | typedef struct { |
| 130 | uint32_t hash_vals[TX_SIZE_RD_RECORD_BUFFER_LEN]; |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 131 | TXB_RD_INFO tx_rd_info[TX_SIZE_RD_RECORD_BUFFER_LEN]; |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 132 | int index_start; |
| 133 | int num; |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 134 | } TXB_RD_RECORD; |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 135 | |
| 136 | typedef struct tx_size_rd_info_node { |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 137 | 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] | 138 | struct tx_size_rd_info_node *children[4]; |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 139 | } TXB_RD_INFO_NODE; |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 140 | |
Peng Bin | 525e2da | 2018-09-06 11:32:58 +0800 | [diff] [blame] | 141 | // Simple translation rd state for prune_comp_search_by_single_result |
| 142 | typedef struct { |
| 143 | RD_STATS rd_stats; |
| 144 | RD_STATS rd_stats_y; |
| 145 | RD_STATS rd_stats_uv; |
| 146 | uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE]; |
| 147 | uint8_t skip; |
| 148 | uint8_t disable_skip; |
| 149 | uint8_t early_skipped; |
| 150 | } SimpleRDState; |
| 151 | |
| 152 | // 4: NEAREST, NEW, NEAR, GLOBAL |
| 153 | #define SINGLE_REF_MODES ((REF_FRAMES - 1) * 4) |
| 154 | |
Hui Su | aaf5a61 | 2018-04-12 15:33:42 -0700 | [diff] [blame] | 155 | // Region size for mode decision sampling in the first pass of partition |
| 156 | // search(two_pass_partition_search speed feature), in units of mi size(4). |
Yunqing Wang | 8025b88 | 2019-03-01 10:53:27 -0800 | [diff] [blame] | 157 | // Used by the mode pruning in two_pass_partition_search feature. |
Hui Su | aaf5a61 | 2018-04-12 15:33:42 -0700 | [diff] [blame] | 158 | #define FIRST_PARTITION_PASS_SAMPLE_REGION 8 |
| 159 | #define FIRST_PARTITION_PASS_SAMPLE_REGION_LOG2 3 |
| 160 | #define FIRST_PARTITION_PASS_STATS_TABLES \ |
| 161 | (MAX_MIB_SIZE >> FIRST_PARTITION_PASS_SAMPLE_REGION_LOG2) * \ |
| 162 | (MAX_MIB_SIZE >> FIRST_PARTITION_PASS_SAMPLE_REGION_LOG2) |
| 163 | #define FIRST_PARTITION_PASS_STATS_STRIDE \ |
| 164 | (MAX_MIB_SIZE_LOG2 - FIRST_PARTITION_PASS_SAMPLE_REGION_LOG2) |
| 165 | |
| 166 | static INLINE int av1_first_partition_pass_stats_index(int mi_row, int mi_col) { |
| 167 | const int row = |
| 168 | (mi_row & MAX_MIB_MASK) >> FIRST_PARTITION_PASS_SAMPLE_REGION_LOG2; |
| 169 | const int col = |
| 170 | (mi_col & MAX_MIB_MASK) >> FIRST_PARTITION_PASS_SAMPLE_REGION_LOG2; |
| 171 | return (row << FIRST_PARTITION_PASS_STATS_STRIDE) + col; |
| 172 | } |
| 173 | |
| 174 | typedef struct { |
| 175 | uint8_t ref0_counts[REF_FRAMES]; // Counters for ref_frame[0]. |
| 176 | uint8_t ref1_counts[REF_FRAMES]; // Counters for ref_frame[1]. |
| 177 | int sample_counts; // Number of samples collected. |
Remya | 08f6d83 | 2019-02-25 14:44:07 +0530 | [diff] [blame] | 178 | uint8_t interintra_motion_mode_count[REF_FRAMES]; // Counter for interintra |
| 179 | // motion mode |
Hui Su | aaf5a61 | 2018-04-12 15:33:42 -0700 | [diff] [blame] | 180 | } FIRST_PARTITION_PASS_STATS; |
| 181 | |
Peng Bin | 706a3b2 | 2018-05-30 19:42:05 +0800 | [diff] [blame] | 182 | #define MAX_INTERP_FILTER_STATS 64 |
| 183 | typedef struct { |
| 184 | InterpFilters filters; |
Peng Bin | d482d17 | 2018-06-14 15:55:51 +0800 | [diff] [blame] | 185 | int_mv mv[2]; |
Peng Bin | 706a3b2 | 2018-05-30 19:42:05 +0800 | [diff] [blame] | 186 | int8_t ref_frames[2]; |
Grant Hsu | 97202d0 | 2018-06-28 12:51:49 +0800 | [diff] [blame] | 187 | COMPOUND_TYPE comp_type; |
Sachin Kumar Garg | fe27126 | 2019-02-12 11:17:48 +0530 | [diff] [blame] | 188 | int64_t rd; |
| 189 | int skip_txfm_sb; |
| 190 | int64_t skip_sse_sb; |
| 191 | unsigned int pred_sse; |
Peng Bin | 706a3b2 | 2018-05-30 19:42:05 +0800 | [diff] [blame] | 192 | } INTERPOLATION_FILTER_STATS; |
| 193 | |
Ranjit Kumar Tulabandu | a1ebb57 | 2018-12-24 12:13:54 +0530 | [diff] [blame] | 194 | #define MAX_COMP_RD_STATS 64 |
| 195 | typedef struct { |
| 196 | int32_t rate[COMPOUND_TYPES]; |
| 197 | int64_t dist[COMPOUND_TYPES]; |
Venkat | 9b20f23 | 2019-01-24 18:08:06 +0530 | [diff] [blame] | 198 | int64_t comp_model_rd[COMPOUND_TYPES]; |
Ranjit Kumar Tulabandu | a1ebb57 | 2018-12-24 12:13:54 +0530 | [diff] [blame] | 199 | int_mv mv[2]; |
Hui Su | d06ff66 | 2019-01-23 16:53:05 -0800 | [diff] [blame] | 200 | MV_REFERENCE_FRAME ref_frames[2]; |
Ranjit Kumar Tulabandu | a1ebb57 | 2018-12-24 12:13:54 +0530 | [diff] [blame] | 201 | PREDICTION_MODE mode; |
| 202 | InterpFilters filter; |
| 203 | int ref_mv_idx; |
| 204 | int is_global[2]; |
| 205 | } COMP_RD_STATS; |
| 206 | |
Ravi Chaudhary | 5d970f4 | 2018-09-25 11:25:32 +0530 | [diff] [blame] | 207 | struct inter_modes_info; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 208 | typedef struct macroblock MACROBLOCK; |
| 209 | struct macroblock { |
| 210 | struct macroblock_plane plane[MAX_MB_PLANE]; |
| 211 | |
Jingning Han | 66965a2 | 2018-01-25 09:53:41 -0800 | [diff] [blame] | 212 | // Determine if one would go with reduced complexity transform block |
| 213 | // search model to select prediction modes, or full complexity model |
| 214 | // to select transform kernel. |
Jingning Han | dd8600f | 2018-01-23 09:06:32 -0800 | [diff] [blame] | 215 | int rd_model; |
| 216 | |
Jingning Han | 4489c26 | 2018-01-26 16:43:59 -0800 | [diff] [blame] | 217 | // Indicate if the encoder is running in the first pass partition search. |
| 218 | // In that case, apply certain speed features therein to reduce the overhead |
| 219 | // cost in the first pass search. |
Jingning Han | c58ccc3 | 2018-01-26 07:46:38 -0800 | [diff] [blame] | 220 | int cb_partition_scan; |
| 221 | |
Hui Su | aaf5a61 | 2018-04-12 15:33:42 -0700 | [diff] [blame] | 222 | FIRST_PARTITION_PASS_STATS |
| 223 | first_partition_pass_stats[FIRST_PARTITION_PASS_STATS_TABLES]; |
Hui Su | bb628a7 | 2018-04-05 19:48:23 -0700 | [diff] [blame] | 224 | |
Peng Bin | 706a3b2 | 2018-05-30 19:42:05 +0800 | [diff] [blame] | 225 | // [comp_idx][saved stat_idx] |
| 226 | INTERPOLATION_FILTER_STATS interp_filter_stats[2][MAX_INTERP_FILTER_STATS]; |
| 227 | int interp_filter_stats_idx[2]; |
| 228 | |
Peng Bin | 525e2da | 2018-09-06 11:32:58 +0800 | [diff] [blame] | 229 | // prune_comp_search_by_single_result (3:MAX_REF_MV_SERCH) |
| 230 | SimpleRDState simple_rd_state[SINGLE_REF_MODES][3]; |
| 231 | |
Jingning Han | 4489c26 | 2018-01-26 16:43:59 -0800 | [diff] [blame] | 232 | // Activate constrained coding block partition search range. |
| 233 | int use_cb_search_range; |
| 234 | |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 235 | // Inter macroblock RD search info. |
| 236 | MB_RD_RECORD mb_rd_record; |
Alexander Bokov | c5ddf06 | 2017-10-17 16:41:46 -0700 | [diff] [blame] | 237 | |
Hui Su | 6cb17c1 | 2018-03-09 12:56:20 -0800 | [diff] [blame] | 238 | // Inter transform block RD search info. for square TX sizes. |
| 239 | TXB_RD_RECORD txb_rd_record_8X8[(MAX_MIB_SIZE >> 1) * (MAX_MIB_SIZE >> 1)]; |
| 240 | TXB_RD_RECORD txb_rd_record_16X16[(MAX_MIB_SIZE >> 2) * (MAX_MIB_SIZE >> 2)]; |
| 241 | TXB_RD_RECORD txb_rd_record_32X32[(MAX_MIB_SIZE >> 3) * (MAX_MIB_SIZE >> 3)]; |
| 242 | TXB_RD_RECORD txb_rd_record_64X64[(MAX_MIB_SIZE >> 4) * (MAX_MIB_SIZE >> 4)]; |
| 243 | |
| 244 | // Intra transform block RD search info. for square TX sizes. |
| 245 | TXB_RD_RECORD txb_rd_record_intra; |
Hui Su | ec5a1ab | 2018-03-08 15:09:12 -0800 | [diff] [blame] | 246 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 247 | MACROBLOCKD e_mbd; |
| 248 | MB_MODE_INFO_EXT *mbmi_ext; |
| 249 | int skip_block; |
David Barker | d7d78c8 | 2016-10-24 10:55:35 +0100 | [diff] [blame] | 250 | int qindex; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 251 | |
| 252 | // The equivalent error at the current rdmult of one whole bit (not one |
| 253 | // bitcost unit). |
| 254 | int errorperbit; |
| 255 | // The equivalend SAD error of one (whole) bit at the current quantizer |
| 256 | // for large blocks. |
| 257 | int sadperbit16; |
| 258 | // The equivalend SAD error of one (whole) bit at the current quantizer |
| 259 | // for sub-8x8 blocks. |
| 260 | int sadperbit4; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 261 | int rdmult; |
Yue Chen | 7cae98f | 2018-08-24 10:43:16 -0700 | [diff] [blame] | 262 | int cb_rdmult; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 263 | int mb_energy; |
Yue Chen | de73047 | 2018-06-20 10:13:15 -0700 | [diff] [blame] | 264 | int sb_energy_level; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 265 | int *m_search_count_ptr; |
| 266 | int *ex_search_count_ptr; |
| 267 | |
Jingning Han | 9777afc | 2016-10-20 15:17:43 -0700 | [diff] [blame] | 268 | unsigned int txb_split_count; |
Debargha Mukherjee | 0857e66 | 2019-01-04 16:22:09 -0800 | [diff] [blame] | 269 | #if CONFIG_SPEED_STATS |
| 270 | unsigned int tx_search_count; |
| 271 | #endif // CONFIG_SPEED_STATS |
Jingning Han | 9777afc | 2016-10-20 15:17:43 -0700 | [diff] [blame] | 272 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 273 | // These are set to their default values at the beginning, and then adjusted |
| 274 | // further in the encoding process. |
| 275 | BLOCK_SIZE min_partition_size; |
| 276 | BLOCK_SIZE max_partition_size; |
| 277 | |
Zoe Liu | 27deb38 | 2018-03-27 15:13:56 -0700 | [diff] [blame] | 278 | unsigned int max_mv_context[REF_FRAMES]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 279 | unsigned int source_variance; |
Yue Chen | 4f719c2 | 2019-02-15 15:13:27 -0800 | [diff] [blame] | 280 | unsigned int simple_motion_pred_sse; |
Zoe Liu | 27deb38 | 2018-03-27 15:13:56 -0700 | [diff] [blame] | 281 | unsigned int pred_sse[REF_FRAMES]; |
| 282 | int pred_mv_sad[REF_FRAMES]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 283 | |
Jingning Han | f050fc1 | 2018-03-09 14:53:33 -0800 | [diff] [blame] | 284 | int nmv_vec_cost[MV_JOINTS]; |
| 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; |
| 295 | |
Urvang Joshi | 0a4cfad | 2018-09-07 11:10:39 -0700 | [diff] [blame] | 296 | CONV_BUF_TYPE *tmp_conv_dst; |
| 297 | uint8_t *tmp_obmc_bufs[2]; |
| 298 | |
Ravi Chaudhary | e521517 | 2018-12-21 18:47:25 +0530 | [diff] [blame] | 299 | FRAME_CONTEXT *row_ctx; |
Ravi Chaudhary | 982ac04 | 2018-11-02 14:30:29 +0530 | [diff] [blame] | 300 | // This context will be used to update color_map_cdf pointer which would be |
| 301 | // used during pack bitstream. For single thread and tile-multithreading case |
| 302 | // this ponter will be same as xd->tile_ctx, but for the case of row-mt: |
| 303 | // xd->tile_ctx will point to a temporary context while tile_pb_ctx will point |
| 304 | // to the accurate tile context. |
| 305 | FRAME_CONTEXT *tile_pb_ctx; |
Ravi Chaudhary | 84a280a | 2018-09-24 16:09:48 +0530 | [diff] [blame] | 306 | |
Ravi Chaudhary | 5d970f4 | 2018-09-25 11:25:32 +0530 | [diff] [blame] | 307 | struct inter_modes_info *inter_modes_info; |
Ravi Chaudhary | 5d970f4 | 2018-09-25 11:25:32 +0530 | [diff] [blame] | 308 | |
Ravi Chaudhary | 783d6a3 | 2018-08-28 18:21:02 +0530 | [diff] [blame] | 309 | // buffer for hash value calculation of a block |
| 310 | // used only in av1_get_block_hash_value() |
| 311 | // [first hash/second hash] |
| 312 | // [two buffers used ping-pong] |
| 313 | uint32_t *hash_value_buffer[2][2]; |
| 314 | |
| 315 | CRC_CALCULATOR crc_calculator1; |
| 316 | CRC_CALCULATOR crc_calculator2; |
| 317 | int g_crc_initialized; |
| 318 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 319 | // These define limits to motion vector components to prevent them |
| 320 | // from extending outside the UMV borders |
Alex Converse | 0fa0f42 | 2017-04-24 12:51:14 -0700 | [diff] [blame] | 321 | MvLimits mv_limits; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 322 | |
Hui Su | f4b79c7 | 2018-03-22 13:14:36 -0700 | [diff] [blame] | 323 | uint8_t blk_skip[MAX_MIB_SIZE * MAX_MIB_SIZE]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 324 | |
| 325 | int skip; |
Jingning Han | 8efdbc8 | 2017-02-19 14:40:03 -0800 | [diff] [blame] | 326 | int skip_chroma_rd; |
Zoe Liu | 1eed2df | 2017-10-16 17:13:15 -0700 | [diff] [blame] | 327 | int skip_cost[SKIP_CONTEXTS][2]; |
| 328 | |
Zoe Liu | f40a957 | 2017-10-13 12:37:19 -0700 | [diff] [blame] | 329 | int skip_mode; // 0: off; 1: on |
| 330 | int skip_mode_cost[SKIP_CONTEXTS][2]; |
| 331 | |
Zoe Liu | 104d62e | 2017-12-07 12:44:45 -0800 | [diff] [blame] | 332 | int compound_idx; |
Zoe Liu | f40a957 | 2017-10-13 12:37:19 -0700 | [diff] [blame] | 333 | |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 334 | LV_MAP_COEFF_COST coeff_costs[TX_SIZES][PLANE_TYPES]; |
Dake He | 0db7d0e | 2017-12-21 15:23:20 -0800 | [diff] [blame] | 335 | LV_MAP_EOB_COST eob_costs[7][2]; |
Jingning Han | f5a4d3b | 2017-08-27 23:01:19 -0700 | [diff] [blame] | 336 | uint16_t cb_offset; |
Jingning Han | dfd7232 | 2017-08-09 14:04:12 -0700 | [diff] [blame] | 337 | |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 338 | // mode costs |
Yue Chen | 170678a | 2017-10-17 13:43:10 -0700 | [diff] [blame] | 339 | int intra_inter_cost[INTRA_INTER_CONTEXTS][2]; |
| 340 | |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 341 | int mbmode_cost[BLOCK_SIZE_GROUPS][INTRA_MODES]; |
| 342 | int newmv_mode_cost[NEWMV_MODE_CONTEXTS][2]; |
Sarah Parker | 2b9ec2e | 2017-10-30 17:34:08 -0700 | [diff] [blame] | 343 | int zeromv_mode_cost[GLOBALMV_MODE_CONTEXTS][2]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 344 | int refmv_mode_cost[REFMV_MODE_CONTEXTS][2]; |
| 345 | int drl_mode_cost0[DRL_MODE_CONTEXTS][2]; |
| 346 | |
Hui Su | 9d0c03d | 2017-12-27 16:05:23 -0800 | [diff] [blame] | 347 | int comp_inter_cost[COMP_INTER_CONTEXTS][2]; |
Hui Su | 3d30b4b | 2017-12-27 16:47:59 -0800 | [diff] [blame] | 348 | int single_ref_cost[REF_CONTEXTS][SINGLE_REFS - 1][2]; |
Hui Su | 6b3d1e3 | 2018-01-05 11:25:40 -0800 | [diff] [blame] | 349 | int comp_ref_type_cost[COMP_REF_TYPE_CONTEXTS] |
| 350 | [CDF_SIZE(COMP_REFERENCE_TYPES)]; |
Hui Su | a7e3bfe | 2018-01-05 12:14:48 -0800 | [diff] [blame] | 351 | int uni_comp_ref_cost[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1] |
| 352 | [CDF_SIZE(2)]; |
Hui Su | 0bdf5f5 | 2018-01-05 14:54:32 -0800 | [diff] [blame] | 353 | // Cost for signaling ref_frame[0] (LAST_FRAME, LAST2_FRAME, LAST3_FRAME or |
| 354 | // GOLDEN_FRAME) in bidir-comp mode. |
Zoe Liu | 3b35347 | 2018-02-12 13:58:22 -0800 | [diff] [blame] | 355 | int comp_ref_cost[REF_CONTEXTS][FWD_REFS - 1][2]; |
Hui Su | 0bdf5f5 | 2018-01-05 14:54:32 -0800 | [diff] [blame] | 356 | // Cost for signaling ref_frame[1] (ALTREF_FRAME, ALTREF2_FRAME, or |
| 357 | // BWDREF_FRAME) in bidir-comp mode. |
Zoe Liu | 3b35347 | 2018-02-12 13:58:22 -0800 | [diff] [blame] | 358 | int comp_bwdref_cost[REF_CONTEXTS][BWD_REFS - 1][2]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 359 | int inter_compound_mode_cost[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES]; |
Debargha Mukherjee | 54eabb5 | 2019-02-01 16:54:33 -0800 | [diff] [blame] | 360 | int compound_type_cost[BLOCK_SIZES_ALL][MASKED_COMPOUND_TYPES]; |
Yue Chen | 73335fa | 2017-12-20 23:33:41 -0800 | [diff] [blame] | 361 | int wedge_idx_cost[BLOCK_SIZES_ALL][16]; |
Yue Chen | eaf128a | 2017-10-16 17:01:36 -0700 | [diff] [blame] | 362 | int interintra_cost[BLOCK_SIZE_GROUPS][2]; |
| 363 | int wedge_interintra_cost[BLOCK_SIZES_ALL][2]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 364 | int interintra_mode_cost[BLOCK_SIZE_GROUPS][INTERINTRA_MODES]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 365 | int motion_mode_cost[BLOCK_SIZES_ALL][MOTION_MODES]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 366 | int motion_mode_cost1[BLOCK_SIZES_ALL][2]; |
David Michael Barr | cb3a8ef | 2018-01-06 15:48:49 +0900 | [diff] [blame] | 367 | 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] | 368 | int y_mode_costs[INTRA_MODES][INTRA_MODES][INTRA_MODES]; |
Yue Chen | 45dfb79 | 2018-03-01 13:02:40 -0800 | [diff] [blame] | 369 | int filter_intra_cost[BLOCK_SIZES_ALL][2]; |
Yue Chen | 994dba2 | 2017-12-19 15:27:26 -0800 | [diff] [blame] | 370 | int filter_intra_mode_cost[FILTER_INTRA_MODES]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 371 | int switchable_interp_costs[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS]; |
Sebastien Alaiwan | a6a486c | 2017-11-07 17:04:27 +0100 | [diff] [blame] | 372 | int partition_cost[PARTITION_CONTEXTS][EXT_PARTITION_TYPES]; |
Hui Su | c1f411b | 2017-12-19 15:58:28 -0800 | [diff] [blame] | 373 | int palette_y_size_cost[PALATTE_BSIZE_CTXS][PALETTE_SIZES]; |
| 374 | int palette_uv_size_cost[PALATTE_BSIZE_CTXS][PALETTE_SIZES]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 375 | int palette_y_color_cost[PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS] |
| 376 | [PALETTE_COLORS]; |
| 377 | int palette_uv_color_cost[PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS] |
| 378 | [PALETTE_COLORS]; |
Hui Su | c1f411b | 2017-12-19 15:58:28 -0800 | [diff] [blame] | 379 | 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] | 380 | int palette_uv_mode_cost[PALETTE_UV_MODE_CONTEXTS][2]; |
David Michael Barr | 38e560c | 2017-08-16 21:46:37 +0900 | [diff] [blame] | 381 | // The rate associated with each alpha codeword |
| 382 | int cfl_cost[CFL_JOINT_SIGNS][CFL_PRED_PLANES][CFL_ALPHABET_SIZE]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 383 | int tx_size_cost[TX_SIZES - 1][TX_SIZE_CONTEXTS][TX_SIZES]; |
Yue Chen | 171c17d | 2017-10-16 18:08:22 -0700 | [diff] [blame] | 384 | int txfm_partition_cost[TXFM_PARTITION_CONTEXTS][2]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 385 | int inter_tx_type_costs[EXT_TX_SETS_INTER][EXT_TX_SIZES][TX_TYPES]; |
| 386 | int intra_tx_type_costs[EXT_TX_SETS_INTRA][EXT_TX_SIZES][INTRA_MODES] |
| 387 | [TX_TYPES]; |
Joe Young | 3ca43bf | 2017-10-06 15:12:46 -0700 | [diff] [blame] | 388 | int angle_delta_cost[DIRECTIONAL_MODES][2 * MAX_ANGLE_DELTA + 1]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 389 | int switchable_restore_cost[RESTORE_SWITCHABLE_TYPES]; |
Debargha Mukherjee | bc732ef | 2017-10-12 12:40:25 -0700 | [diff] [blame] | 390 | int wiener_restore_cost[2]; |
| 391 | int sgrproj_restore_cost[2]; |
Hui Su | 6c8584f | 2017-09-14 15:37:02 -0700 | [diff] [blame] | 392 | int intrabc_cost[2]; |
Yue Chen | b23d00a | 2017-07-28 17:01:21 -0700 | [diff] [blame] | 393 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 394 | // Used to store sub partition's choices. |
Zoe Liu | 27deb38 | 2018-03-27 15:13:56 -0700 | [diff] [blame] | 395 | MV pred_mv[REF_FRAMES]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 396 | |
| 397 | // Store the best motion vector during motion search |
| 398 | int_mv best_mv; |
| 399 | // Store the second best motion vector during full-pixel motion search |
| 400 | int_mv second_best_mv; |
| 401 | |
Venkat | e846e2b | 2018-09-21 07:31:14 +0530 | [diff] [blame] | 402 | // Store the fractional best motion vector during sub/Qpel-pixel motion search |
| 403 | int_mv fractional_best_mv[3]; |
| 404 | |
Hui Su | 835bbd5 | 2019-03-05 23:18:15 -0800 | [diff] [blame] | 405 | // Ref frames that are selected by square partition blocks within a super- |
| 406 | // block, in MI resolution. They can be used to prune ref frames for |
| 407 | // rectangular blocks. |
| 408 | int picked_ref_frames_mask[32 * 32]; |
| 409 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 410 | // use default transform and skip transform type search for intra modes |
| 411 | int use_default_intra_tx_type; |
| 412 | // use default transform and skip transform type search for inter modes |
| 413 | int use_default_inter_tx_type; |
Yushin Cho | b7b60c5 | 2017-07-14 16:18:52 -0700 | [diff] [blame] | 414 | #if CONFIG_DIST_8X8 |
Yushin Cho | 5510433 | 2017-08-14 16:15:43 -0700 | [diff] [blame] | 415 | int using_dist_8x8; |
| 416 | aom_tune_metric tune_metric; |
Yushin Cho | b7b60c5 | 2017-07-14 16:18:52 -0700 | [diff] [blame] | 417 | #endif // CONFIG_DIST_8X8 |
Cheng Chen | 4697061 | 2017-10-24 14:53:36 -0700 | [diff] [blame] | 418 | int comp_idx_cost[COMP_INDEX_CONTEXTS][2]; |
Cheng Chen | 2ef24ea | 2017-11-29 12:22:24 -0800 | [diff] [blame] | 419 | int comp_group_idx_cost[COMP_GROUP_IDX_CONTEXTS][2]; |
Hui Su | 6bbd932 | 2018-01-26 11:04:13 -0800 | [diff] [blame] | 420 | // Bit flags for pruning tx type search, tx split, etc. |
| 421 | int tx_search_prune[EXT_TX_SET_TYPES]; |
Hui Su | 845a741 | 2018-03-08 12:21:00 -0800 | [diff] [blame] | 422 | int must_find_valid_partition; |
Hui Su | 7b67ff3 | 2018-03-07 11:52:04 -0800 | [diff] [blame] | 423 | int tx_split_prune_flag; // Flag to skip tx split RD search. |
Ranjit Kumar Tulabandu | 8105bf4 | 2018-07-27 14:16:55 +0530 | [diff] [blame] | 424 | int recalc_luma_mc_data; // Flag to indicate recalculation of MC data during |
| 425 | // interpolation filter search |
elliottk | 1dbb8c1 | 2018-11-06 22:28:59 -0800 | [diff] [blame] | 426 | // The likelihood of an edge existing in the block (using partial Canny edge |
| 427 | // detection). For reference, 556 is the value returned for a solid |
| 428 | // vertical black/white edge. |
| 429 | uint16_t edge_strength; |
elliottk | 17dd3ea | 2019-02-01 11:59:57 -0800 | [diff] [blame] | 430 | // The strongest edge strength seen along the x/y axis. |
| 431 | uint16_t edge_strength_x; |
| 432 | uint16_t edge_strength_y; |
Ranjit Kumar Tulabandu | a1ebb57 | 2018-12-24 12:13:54 +0530 | [diff] [blame] | 433 | |
| 434 | // [Saved stat index] |
| 435 | COMP_RD_STATS comp_rd_stats[MAX_COMP_RD_STATS]; |
| 436 | int comp_rd_stats_idx; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 437 | }; |
| 438 | |
Frederic Barbier | 0f191da | 2018-01-03 17:29:26 +0100 | [diff] [blame] | 439 | static INLINE int is_rect_tx_allowed_bsize(BLOCK_SIZE bsize) { |
| 440 | static const char LUT[BLOCK_SIZES_ALL] = { |
| 441 | 0, // BLOCK_4X4 |
| 442 | 1, // BLOCK_4X8 |
| 443 | 1, // BLOCK_8X4 |
| 444 | 0, // BLOCK_8X8 |
| 445 | 1, // BLOCK_8X16 |
| 446 | 1, // BLOCK_16X8 |
| 447 | 0, // BLOCK_16X16 |
| 448 | 1, // BLOCK_16X32 |
| 449 | 1, // BLOCK_32X16 |
| 450 | 0, // BLOCK_32X32 |
| 451 | 1, // BLOCK_32X64 |
| 452 | 1, // BLOCK_64X32 |
| 453 | 0, // BLOCK_64X64 |
Frederic Barbier | 0f191da | 2018-01-03 17:29:26 +0100 | [diff] [blame] | 454 | 0, // BLOCK_64X128 |
| 455 | 0, // BLOCK_128X64 |
| 456 | 0, // BLOCK_128X128 |
Frederic Barbier | 0f191da | 2018-01-03 17:29:26 +0100 | [diff] [blame] | 457 | 1, // BLOCK_4X16 |
| 458 | 1, // BLOCK_16X4 |
| 459 | 1, // BLOCK_8X32 |
| 460 | 1, // BLOCK_32X8 |
| 461 | 1, // BLOCK_16X64 |
| 462 | 1, // BLOCK_64X16 |
Frederic Barbier | 0f191da | 2018-01-03 17:29:26 +0100 | [diff] [blame] | 463 | }; |
| 464 | |
| 465 | return LUT[bsize]; |
| 466 | } |
| 467 | |
| 468 | static INLINE int is_rect_tx_allowed(const MACROBLOCKD *xd, |
| 469 | const MB_MODE_INFO *mbmi) { |
| 470 | return is_rect_tx_allowed_bsize(mbmi->sb_type) && |
| 471 | !xd->lossless[mbmi->segment_id]; |
| 472 | } |
| 473 | |
Frederic Barbier | 4b56b10 | 2018-03-30 16:09:34 +0200 | [diff] [blame] | 474 | 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] | 475 | TX_SIZE ctx_size = max_txsize_rect_lookup[bsize]; |
Frederic Barbier | 0f191da | 2018-01-03 17:29:26 +0100 | [diff] [blame] | 476 | int depth = 0; |
| 477 | while (tx_size != ctx_size) { |
| 478 | depth++; |
Frederic Barbier | 4b56b10 | 2018-03-30 16:09:34 +0200 | [diff] [blame] | 479 | ctx_size = sub_tx_size_map[ctx_size]; |
Frederic Barbier | 0f191da | 2018-01-03 17:29:26 +0100 | [diff] [blame] | 480 | assert(depth <= MAX_TX_DEPTH); |
| 481 | } |
| 482 | return depth; |
| 483 | } |
| 484 | |
Grant Hsu | 39248c3 | 2018-09-18 10:38:44 +0800 | [diff] [blame] | 485 | static INLINE void set_blk_skip(MACROBLOCK *x, int plane, int blk_idx, |
| 486 | int skip) { |
| 487 | if (skip) |
| 488 | x->blk_skip[blk_idx] |= 1UL << plane; |
| 489 | else |
| 490 | x->blk_skip[blk_idx] &= ~(1UL << plane); |
| 491 | #ifndef NDEBUG |
| 492 | // Set chroma planes to uninitialized states when luma is set to check if |
| 493 | // it will be set later |
| 494 | if (plane == 0) { |
| 495 | x->blk_skip[blk_idx] |= 1UL << (1 + 4); |
| 496 | x->blk_skip[blk_idx] |= 1UL << (2 + 4); |
| 497 | } |
| 498 | |
| 499 | // Clear the initialization checking bit |
| 500 | x->blk_skip[blk_idx] &= ~(1UL << (plane + 4)); |
| 501 | #endif |
| 502 | } |
| 503 | |
| 504 | static INLINE int is_blk_skip(MACROBLOCK *x, int plane, int blk_idx) { |
| 505 | #ifndef NDEBUG |
| 506 | // Check if this is initialized |
| 507 | assert(!(x->blk_skip[blk_idx] & (1UL << (plane + 4)))); |
| 508 | |
| 509 | // The magic number is 0x77, this is to test if there is garbage data |
| 510 | assert((x->blk_skip[blk_idx] & 0x88) == 0); |
| 511 | #endif |
| 512 | return (x->blk_skip[blk_idx] >> plane) & 1; |
| 513 | } |
| 514 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 515 | #ifdef __cplusplus |
| 516 | } // extern "C" |
| 517 | #endif |
| 518 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 519 | #endif // AOM_AV1_ENCODER_BLOCK_H_ |