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_SPEED_FEATURES_H_ |
| 13 | #define AV1_ENCODER_SPEED_FEATURES_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 14 | |
| 15 | #include "av1/common/enums.h" |
| 16 | |
| 17 | #ifdef __cplusplus |
| 18 | extern "C" { |
| 19 | #endif |
| 20 | |
| 21 | enum { |
| 22 | INTRA_ALL = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED) | (1 << D45_PRED) | |
Hui Su | 69ae7b8 | 2018-02-20 20:10:51 -0800 | [diff] [blame] | 23 | (1 << D135_PRED) | (1 << D113_PRED) | (1 << D157_PRED) | |
| 24 | (1 << D203_PRED) | (1 << D67_PRED) | (1 << SMOOTH_PRED) | |
Urvang Joshi | b7301cd | 2017-11-09 15:08:56 -0800 | [diff] [blame] | 25 | (1 << SMOOTH_V_PRED) | (1 << SMOOTH_H_PRED) | (1 << PAETH_PRED), |
Urvang Joshi | b7301cd | 2017-11-09 15:08:56 -0800 | [diff] [blame] | 26 | UV_INTRA_ALL = |
| 27 | (1 << UV_DC_PRED) | (1 << UV_V_PRED) | (1 << UV_H_PRED) | |
Hui Su | 69ae7b8 | 2018-02-20 20:10:51 -0800 | [diff] [blame] | 28 | (1 << UV_D45_PRED) | (1 << UV_D135_PRED) | (1 << UV_D113_PRED) | |
| 29 | (1 << UV_D157_PRED) | (1 << UV_D203_PRED) | (1 << UV_D67_PRED) | |
Urvang Joshi | b7301cd | 2017-11-09 15:08:56 -0800 | [diff] [blame] | 30 | (1 << UV_SMOOTH_PRED) | (1 << UV_SMOOTH_V_PRED) | |
| 31 | (1 << UV_SMOOTH_H_PRED) | (1 << UV_PAETH_PRED) | (1 << UV_CFL_PRED), |
Luc Trudeau | d6d9eee | 2017-07-12 12:36:50 -0400 | [diff] [blame] | 32 | UV_INTRA_DC = (1 << UV_DC_PRED), |
Luc Trudeau | 6e1cd78 | 2017-06-21 13:52:36 -0400 | [diff] [blame] | 33 | UV_INTRA_DC_CFL = (1 << UV_DC_PRED) | (1 << UV_CFL_PRED), |
Urvang Joshi | 96d1c0a | 2017-10-10 13:15:32 -0700 | [diff] [blame] | 34 | UV_INTRA_DC_TM = (1 << UV_DC_PRED) | (1 << UV_PAETH_PRED), |
| 35 | UV_INTRA_DC_PAETH_CFL = |
| 36 | (1 << UV_DC_PRED) | (1 << UV_PAETH_PRED) | (1 << UV_CFL_PRED), |
Luc Trudeau | d6d9eee | 2017-07-12 12:36:50 -0400 | [diff] [blame] | 37 | UV_INTRA_DC_H_V = (1 << UV_DC_PRED) | (1 << UV_V_PRED) | (1 << UV_H_PRED), |
Luc Trudeau | 6e1cd78 | 2017-06-21 13:52:36 -0400 | [diff] [blame] | 38 | UV_INTRA_DC_H_V_CFL = (1 << UV_DC_PRED) | (1 << UV_V_PRED) | |
| 39 | (1 << UV_H_PRED) | (1 << UV_CFL_PRED), |
Urvang Joshi | 96d1c0a | 2017-10-10 13:15:32 -0700 | [diff] [blame] | 40 | UV_INTRA_DC_PAETH_H_V = (1 << UV_DC_PRED) | (1 << UV_PAETH_PRED) | |
| 41 | (1 << UV_V_PRED) | (1 << UV_H_PRED), |
| 42 | UV_INTRA_DC_PAETH_H_V_CFL = (1 << UV_DC_PRED) | (1 << UV_PAETH_PRED) | |
| 43 | (1 << UV_V_PRED) | (1 << UV_H_PRED) | |
| 44 | (1 << UV_CFL_PRED), |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 45 | INTRA_DC = (1 << DC_PRED), |
Urvang Joshi | 96d1c0a | 2017-10-10 13:15:32 -0700 | [diff] [blame] | 46 | INTRA_DC_TM = (1 << DC_PRED) | (1 << PAETH_PRED), |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 47 | INTRA_DC_H_V = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED), |
Urvang Joshi | 96d1c0a | 2017-10-10 13:15:32 -0700 | [diff] [blame] | 48 | INTRA_DC_PAETH_H_V = |
| 49 | (1 << DC_PRED) | (1 << PAETH_PRED) | (1 << V_PRED) | (1 << H_PRED) |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 52 | enum { |
Sarah Parker | 2b9ec2e | 2017-10-30 17:34:08 -0700 | [diff] [blame] | 53 | INTER_ALL = (1 << NEARESTMV) | (1 << NEARMV) | (1 << GLOBALMV) | |
| 54 | (1 << NEWMV) | (1 << NEAREST_NEARESTMV) | (1 << NEAR_NEARMV) | |
| 55 | (1 << NEW_NEWMV) | (1 << NEAREST_NEWMV) | (1 << NEAR_NEWMV) | |
| 56 | (1 << NEW_NEARMV) | (1 << NEW_NEARESTMV) | (1 << GLOBAL_GLOBALMV), |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 57 | INTER_NEAREST = (1 << NEARESTMV) | (1 << NEAREST_NEARESTMV) | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 58 | (1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV), |
Zoe Liu | 7f24e1b | 2017-03-17 17:42:05 -0700 | [diff] [blame] | 59 | INTER_NEAREST_NEW = (1 << NEARESTMV) | (1 << NEWMV) | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 60 | (1 << NEAREST_NEARESTMV) | (1 << NEW_NEWMV) | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 61 | (1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV) | |
| 62 | (1 << NEW_NEARMV) | (1 << NEAR_NEWMV), |
Sarah Parker | 2b9ec2e | 2017-10-30 17:34:08 -0700 | [diff] [blame] | 63 | INTER_NEAREST_ZERO = (1 << NEARESTMV) | (1 << GLOBALMV) | |
| 64 | (1 << NEAREST_NEARESTMV) | (1 << GLOBAL_GLOBALMV) | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 65 | (1 << NEAREST_NEWMV) | (1 << NEW_NEARESTMV), |
Sarah Parker | 2b9ec2e | 2017-10-30 17:34:08 -0700 | [diff] [blame] | 66 | INTER_NEAREST_NEW_ZERO = (1 << NEARESTMV) | (1 << GLOBALMV) | (1 << NEWMV) | |
| 67 | (1 << NEAREST_NEARESTMV) | (1 << GLOBAL_GLOBALMV) | |
Debargha Mukherjee | bb6e134 | 2017-04-17 16:05:04 -0700 | [diff] [blame] | 68 | (1 << NEW_NEWMV) | (1 << NEW_NEARESTMV) | |
| 69 | (1 << NEAREST_NEWMV) | (1 << NEW_NEARMV) | |
| 70 | (1 << NEAR_NEWMV), |
| 71 | INTER_NEAREST_NEAR_NEW = (1 << NEARESTMV) | (1 << NEARMV) | (1 << NEWMV) | |
| 72 | (1 << NEAREST_NEARESTMV) | (1 << NEW_NEWMV) | |
| 73 | (1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV) | |
| 74 | (1 << NEW_NEARMV) | (1 << NEAR_NEWMV) | |
| 75 | (1 << NEAR_NEARMV), |
Sarah Parker | 2b9ec2e | 2017-10-30 17:34:08 -0700 | [diff] [blame] | 76 | INTER_NEAREST_NEAR_ZERO = (1 << NEARESTMV) | (1 << NEARMV) | (1 << GLOBALMV) | |
| 77 | (1 << NEAREST_NEARESTMV) | (1 << GLOBAL_GLOBALMV) | |
Debargha Mukherjee | bb6e134 | 2017-04-17 16:05:04 -0700 | [diff] [blame] | 78 | (1 << NEAREST_NEWMV) | (1 << NEW_NEARESTMV) | |
| 79 | (1 << NEW_NEARMV) | (1 << NEAR_NEWMV) | |
| 80 | (1 << NEAR_NEARMV), |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 81 | }; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 82 | |
| 83 | enum { |
| 84 | DISABLE_ALL_INTER_SPLIT = (1 << THR_COMP_GA) | (1 << THR_COMP_LA) | |
| 85 | (1 << THR_ALTR) | (1 << THR_GOLD) | (1 << THR_LAST), |
| 86 | |
| 87 | DISABLE_ALL_SPLIT = (1 << THR_INTRA) | DISABLE_ALL_INTER_SPLIT, |
| 88 | |
| 89 | DISABLE_COMPOUND_SPLIT = (1 << THR_COMP_GA) | (1 << THR_COMP_LA), |
| 90 | |
| 91 | LAST_AND_INTRA_SPLIT_ONLY = (1 << THR_COMP_GA) | (1 << THR_COMP_LA) | |
| 92 | (1 << THR_ALTR) | (1 << THR_GOLD) |
| 93 | }; |
| 94 | |
| 95 | typedef enum { |
Jingning Han | b49c6ae | 2017-11-27 18:14:05 -0800 | [diff] [blame] | 96 | TXFM_CODING_SF = 1, |
| 97 | INTER_PRED_SF = 2, |
| 98 | INTRA_PRED_SF = 4, |
| 99 | PARTITION_SF = 8, |
| 100 | LOOP_FILTER_SF = 16, |
| 101 | RD_SKIP_SF = 32, |
| 102 | RESERVE_2_SF = 64, |
| 103 | RESERVE_3_SF = 128, |
| 104 | } DEV_SPEED_FEATURES; |
| 105 | |
| 106 | typedef enum { |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 107 | DIAMOND = 0, |
| 108 | NSTEP = 1, |
| 109 | HEX = 2, |
| 110 | BIGDIA = 3, |
| 111 | SQUARE = 4, |
| 112 | FAST_HEX = 5, |
| 113 | FAST_DIAMOND = 6 |
| 114 | } SEARCH_METHODS; |
| 115 | |
| 116 | typedef enum { |
| 117 | // No recode. |
| 118 | DISALLOW_RECODE = 0, |
| 119 | // Allow recode for KF and exceeding maximum frame bandwidth. |
| 120 | ALLOW_RECODE_KFMAXBW = 1, |
| 121 | // Allow recode only for KF/ARF/GF frames. |
| 122 | ALLOW_RECODE_KFARFGF = 2, |
| 123 | // Allow recode for all frames based on bitrate constraints. |
| 124 | ALLOW_RECODE = 3, |
| 125 | } RECODE_LOOP_TYPE; |
| 126 | |
| 127 | typedef enum { |
| 128 | SUBPEL_TREE = 0, |
| 129 | SUBPEL_TREE_PRUNED = 1, // Prunes 1/2-pel searches |
| 130 | SUBPEL_TREE_PRUNED_MORE = 2, // Prunes 1/2-pel searches more aggressively |
| 131 | SUBPEL_TREE_PRUNED_EVENMORE = 3, // Prunes 1/2- and 1/4-pel searches |
| 132 | // Other methods to come |
| 133 | } SUBPEL_SEARCH_METHODS; |
| 134 | |
| 135 | typedef enum { |
| 136 | NO_MOTION_THRESHOLD = 0, |
| 137 | LOW_MOTION_THRESHOLD = 7 |
| 138 | } MOTION_THRESHOLD; |
| 139 | |
| 140 | typedef enum { |
| 141 | USE_FULL_RD = 0, |
Debargha Mukherjee | 5166686 | 2017-10-24 14:29:13 -0700 | [diff] [blame] | 142 | USE_FAST_RD, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 143 | USE_LARGESTALL, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 144 | } TX_SIZE_SEARCH_METHOD; |
| 145 | |
| 146 | typedef enum { |
| 147 | NOT_IN_USE = 0, |
Thomas Daede | 8082614 | 2017-03-20 15:44:24 -0700 | [diff] [blame] | 148 | RELAXED_NEIGHBORING_MIN_MAX = 1 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 149 | } AUTO_MIN_MAX_MODE; |
| 150 | |
| 151 | typedef enum { |
| 152 | // Try the full image with different values. |
| 153 | LPF_PICK_FROM_FULL_IMAGE, |
| 154 | // Try a small portion of the image with different values. |
| 155 | LPF_PICK_FROM_SUBIMAGE, |
| 156 | // Estimate the level based on quantizer and frame type |
| 157 | LPF_PICK_FROM_Q, |
| 158 | // Pick 0 to disable LPF if LPF was enabled last frame |
| 159 | LPF_PICK_MINIMAL_LPF |
| 160 | } LPF_PICK_METHOD; |
| 161 | |
| 162 | typedef enum { |
| 163 | // Terminate search early based on distortion so far compared to |
| 164 | // qp step, distortion in the neighborhood of the frame, etc. |
| 165 | FLAG_EARLY_TERMINATE = 1 << 0, |
| 166 | |
| 167 | // Skips comp inter modes if the best so far is an intra mode. |
| 168 | FLAG_SKIP_COMP_BESTINTRA = 1 << 1, |
| 169 | |
| 170 | // Skips oblique intra modes if the best so far is an inter mode. |
| 171 | FLAG_SKIP_INTRA_BESTINTER = 1 << 3, |
| 172 | |
| 173 | // Skips oblique intra modes at angles 27, 63, 117, 153 if the best |
| 174 | // intra so far is not one of the neighboring directions. |
| 175 | FLAG_SKIP_INTRA_DIRMISMATCH = 1 << 4, |
| 176 | |
| 177 | // Skips intra modes other than DC_PRED if the source variance is small |
| 178 | FLAG_SKIP_INTRA_LOWVAR = 1 << 5, |
| 179 | } MODE_SEARCH_SKIP_LOGIC; |
| 180 | |
| 181 | typedef enum { |
| 182 | FLAG_SKIP_EIGHTTAP_REGULAR = 1 << EIGHTTAP_REGULAR, |
| 183 | FLAG_SKIP_EIGHTTAP_SMOOTH = 1 << EIGHTTAP_SMOOTH, |
| 184 | FLAG_SKIP_MULTITAP_SHARP = 1 << MULTITAP_SHARP, |
| 185 | } INTERP_FILTER_MASK; |
| 186 | |
| 187 | typedef enum { |
| 188 | NO_PRUNE = 0, |
| 189 | // eliminates one tx type in vertical and horizontal direction |
| 190 | PRUNE_ONE = 1, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 191 | // eliminates two tx types in each direction |
| 192 | PRUNE_TWO = 2, |
Alexander Bokov | 0c7eb10 | 2017-09-07 18:49:00 -0700 | [diff] [blame] | 193 | // adaptively prunes the least perspective tx types out of all 16 |
| 194 | // (tuned to provide negligible quality loss) |
| 195 | PRUNE_2D_ACCURATE = 3, |
| 196 | // similar, but applies much more aggressive pruning to get better speed-up |
| 197 | PRUNE_2D_FAST = 4, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 198 | } TX_TYPE_PRUNE_MODE; |
| 199 | |
| 200 | typedef struct { |
| 201 | TX_TYPE_PRUNE_MODE prune_mode; |
| 202 | int fast_intra_tx_type_search; |
| 203 | int fast_inter_tx_type_search; |
Alexander Bokov | 8829a24 | 2017-08-31 18:07:05 -0700 | [diff] [blame] | 204 | |
| 205 | // Use a skip flag prediction model to detect blocks with skip = 1 early |
| 206 | // and avoid doing full TX type search for such blocks. |
| 207 | int use_skip_flag_prediction; |
Alexander Bokov | 79a3724 | 2017-09-29 11:25:55 -0700 | [diff] [blame] | 208 | |
| 209 | // Use a model to predict TX block split decisions on the highest level |
| 210 | // of TX partition tree and apply adaptive pruning based on that to speed up |
| 211 | // RD search (currently works only when prune_mode equals to PRUNE_2D_ACCURATE |
| 212 | // or PRUNE_2D_FAST). |
| 213 | int use_tx_size_pruning; |
Cheng Chen | 3c22260 | 2018-01-22 19:34:18 -0800 | [diff] [blame] | 214 | |
| 215 | // skip remaining transform type search when we found the rdcost of skip is |
| 216 | // better than applying transform |
| 217 | int skip_tx_search; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 218 | } TX_TYPE_SEARCH; |
| 219 | |
| 220 | typedef enum { |
| 221 | // Search partitions using RD criterion |
| 222 | SEARCH_PARTITION, |
| 223 | |
| 224 | // Always use a fixed size partition |
| 225 | FIXED_PARTITION, |
| 226 | |
Thomas Daede | 8ea3319 | 2017-05-10 15:40:06 -0700 | [diff] [blame] | 227 | REFERENCE_PARTITION |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 228 | } PARTITION_SEARCH_TYPE; |
| 229 | |
| 230 | typedef enum { |
| 231 | // Does a dry run to see if any of the contexts need to be updated or not, |
| 232 | // before the final run. |
| 233 | TWO_LOOP = 0, |
| 234 | |
| 235 | // No dry run, also only half the coef contexts and bands are updated. |
| 236 | // The rest are not updated at all. |
| 237 | ONE_LOOP_REDUCED = 1 |
| 238 | } FAST_COEFF_UPDATE; |
| 239 | |
| 240 | typedef struct MV_SPEED_FEATURES { |
| 241 | // Motion search method (Diamond, NSTEP, Hex, Big Diamond, Square, etc). |
| 242 | SEARCH_METHODS search_method; |
| 243 | |
| 244 | // This parameter controls which step in the n-step process we start at. |
| 245 | // It's changed adaptively based on circumstances. |
| 246 | int reduce_first_step_size; |
| 247 | |
| 248 | // If this is set to 1, we limit the motion search range to 2 times the |
| 249 | // largest motion vector found in the last frame. |
| 250 | int auto_mv_step_size; |
| 251 | |
| 252 | // Subpel_search_method can only be subpel_tree which does a subpixel |
| 253 | // logarithmic search that keeps stepping at 1/2 pixel units until |
| 254 | // you stop getting a gain, and then goes on to 1/4 and repeats |
| 255 | // the same process. Along the way it skips many diagonals. |
| 256 | SUBPEL_SEARCH_METHODS subpel_search_method; |
| 257 | |
| 258 | // Maximum number of steps in logarithmic subpel search before giving up. |
| 259 | int subpel_iters_per_step; |
| 260 | |
| 261 | // Control when to stop subpel search |
| 262 | int subpel_force_stop; |
| 263 | |
| 264 | // This variable sets the step_param used in full pel motion search. |
| 265 | int fullpel_search_step_param; |
| 266 | } MV_SPEED_FEATURES; |
| 267 | |
| 268 | #define MAX_MESH_STEP 4 |
| 269 | |
| 270 | typedef struct MESH_PATTERN { |
| 271 | int range; |
| 272 | int interval; |
| 273 | } MESH_PATTERN; |
| 274 | |
Debargha Mukherjee | 2a9d746 | 2017-05-04 17:37:52 -0700 | [diff] [blame] | 275 | typedef enum { |
| 276 | GM_FULL_SEARCH, |
| 277 | GM_REDUCED_REF_SEARCH, |
| 278 | GM_DISABLE_SEARCH |
| 279 | } GM_SEARCH_TYPE; |
Debargha Mukherjee | 2a9d746 | 2017-05-04 17:37:52 -0700 | [diff] [blame] | 280 | |
Sarah Parker | 251c9dc | 2017-12-13 15:34:36 -0800 | [diff] [blame] | 281 | typedef enum { |
Sarah Parker | 07a28bc | 2018-03-16 14:29:58 -0700 | [diff] [blame] | 282 | GM_ERRORADV_TR_0, |
| 283 | GM_ERRORADV_TR_1, |
| 284 | GM_ERRORADV_TR_2, |
| 285 | } GM_ERRORADV_TYPE; |
| 286 | |
| 287 | typedef enum { |
Sarah Parker | 251c9dc | 2017-12-13 15:34:36 -0800 | [diff] [blame] | 288 | NO_TRELLIS_OPT, // No trellis optimization |
| 289 | FULL_TRELLIS_OPT, // Trellis optimization in all stages |
| 290 | FINAL_PASS_TRELLIS_OPT // Trellis optimization in only the final encode pass |
| 291 | } TRELLIS_OPT_TYPE; |
| 292 | |
Jingning Han | 66965a2 | 2018-01-25 09:53:41 -0800 | [diff] [blame] | 293 | typedef enum { |
| 294 | FULL_TXFM_RD, |
| 295 | LOW_TXFM_RD, |
| 296 | } TXFM_RD_MODEL; |
| 297 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 298 | typedef struct SPEED_FEATURES { |
| 299 | MV_SPEED_FEATURES mv; |
| 300 | |
| 301 | // Frame level coding parameter update |
| 302 | int frame_parameter_update; |
| 303 | |
| 304 | RECODE_LOOP_TYPE recode_loop; |
| 305 | |
Sarah Parker | 251c9dc | 2017-12-13 15:34:36 -0800 | [diff] [blame] | 306 | // Trellis (dynamic programming) optimization of quantized values |
| 307 | TRELLIS_OPT_TYPE optimize_coefficients; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 308 | |
Sarah Parker | 07a28bc | 2018-03-16 14:29:58 -0700 | [diff] [blame] | 309 | // Global motion warp error threshold |
| 310 | GM_ERRORADV_TYPE gm_erroradv_type; |
| 311 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 312 | // Always set to 0. If on it enables 0 cost background transmission |
| 313 | // (except for the initial transmission of the segmentation). The feature is |
| 314 | // disabled because the addition of very large block sizes make the |
| 315 | // backgrounds very to cheap to encode, and the segmentation we have |
| 316 | // adds overhead. |
| 317 | int static_segmentation; |
| 318 | |
Jingning Han | 8db5f17 | 2018-01-23 15:15:51 -0800 | [diff] [blame] | 319 | // Limit the inter mode tested in the RD loop |
| 320 | int reduce_inter_modes; |
| 321 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 322 | // If 1 we iterate finding a best reference for 2 ref frames together - via |
| 323 | // a log search that iterates 4 times (check around mv for last for best |
| 324 | // error of combined predictor then check around mv for alt). If 0 we |
| 325 | // we just use the best motion vector found for each frame by itself. |
| 326 | BLOCK_SIZE comp_inter_joint_search_thresh; |
| 327 | |
| 328 | // This variable is used to cap the maximum number of times we skip testing a |
| 329 | // mode to be evaluated. A high value means we will be faster. |
| 330 | int adaptive_rd_thresh; |
| 331 | |
| 332 | // Coefficient probability model approximation step size |
| 333 | int coeff_prob_appx_step; |
| 334 | |
| 335 | // The threshold is to determine how slow the motino is, it is used when |
| 336 | // use_lastframe_partitioning is set to LAST_FRAME_PARTITION_LOW_MOTION |
| 337 | MOTION_THRESHOLD lf_motion_threshold; |
| 338 | |
| 339 | // Determine which method we use to determine transform size. We can choose |
| 340 | // between options like full rd, largest for prediction size, largest |
| 341 | // for intra and model coefs for the rest. |
| 342 | TX_SIZE_SEARCH_METHOD tx_size_search_method; |
| 343 | |
Debargha Mukherjee | edc7346 | 2017-10-31 15:13:32 -0700 | [diff] [blame] | 344 | // Init search depth for square and rectangular transform partitions. |
| 345 | // Values: |
| 346 | // 0 - search full tree, 1: search 1 level, 2: search the highest level only |
| 347 | int tx_size_search_init_depth_sqr; |
| 348 | int tx_size_search_init_depth_rect; |
Jingning Han | 45738ed | 2018-03-18 17:34:16 -0700 | [diff] [blame] | 349 | // If any dimension of a coding block size above 64, always search the |
| 350 | // largest transform only, since the largest transform block size is 64x64. |
| 351 | int tx_size_search_lgr_block; |
Debargha Mukherjee | edc7346 | 2017-10-31 15:13:32 -0700 | [diff] [blame] | 352 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 353 | // After looking at the first set of modes (set by index here), skip |
| 354 | // checking modes for reference frames that don't match the reference frame |
| 355 | // of the best so far. |
| 356 | int mode_skip_start; |
| 357 | |
| 358 | PARTITION_SEARCH_TYPE partition_search_type; |
| 359 | |
| 360 | TX_TYPE_SEARCH tx_type_search; |
| 361 | |
Jingning Han | eb8f5e8 | 2018-01-30 17:01:54 -0800 | [diff] [blame] | 362 | // Skip split transform block partition when the collocated bigger block |
| 363 | // is selected as all zero coefficients. |
| 364 | int txb_split_cap; |
| 365 | |
Jingning Han | b91a0e7 | 2018-02-28 10:43:44 -0800 | [diff] [blame] | 366 | // Shortcut the transform block partition and type search when the target |
| 367 | // rdcost is relatively lower. |
| 368 | int adaptive_txb_search; |
| 369 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 370 | // Used if partition_search_type = FIXED_SIZE_PARTITION |
| 371 | BLOCK_SIZE always_this_block_size; |
| 372 | |
Jingning Han | cf842ad | 2017-10-25 12:02:30 -0700 | [diff] [blame] | 373 | // Drop less likely picked reference frames in the RD search |
Zoe Liu | 451672e | 2017-11-08 11:11:37 -0800 | [diff] [blame] | 374 | // Has three levels for now: 1, 2 and 3, where higher levels are more |
| 375 | // aggressive than lower ones. |
Jingning Han | cf842ad | 2017-10-25 12:02:30 -0700 | [diff] [blame] | 376 | int selective_ref_frame; |
| 377 | |
Debargha Mukherjee | c4b6764 | 2017-11-01 22:57:28 -0700 | [diff] [blame] | 378 | // Conditionally prune extended partition types search |
| 379 | int prune_ext_partition_types_search; |
Debargha Mukherjee | c4b6764 | 2017-11-01 22:57:28 -0700 | [diff] [blame] | 380 | |
Debargha Mukherjee | d7338aa | 2017-11-04 07:34:50 -0700 | [diff] [blame] | 381 | int fast_cdef_search; |
Debargha Mukherjee | d7338aa | 2017-11-04 07:34:50 -0700 | [diff] [blame] | 382 | |
Jingning Han | a5847e8 | 2018-01-23 16:52:05 -0800 | [diff] [blame] | 383 | // 2-pass coding block partition search |
| 384 | int two_pass_partition_search; |
| 385 | |
Hui Su | bb628a7 | 2018-04-05 19:48:23 -0700 | [diff] [blame^] | 386 | // Use the mode decisions made in the initial partition search to prune mode |
| 387 | // candidates, e.g. ref frames. |
| 388 | int mode_pruning_based_on_two_pass_partition_search; |
| 389 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 390 | // Skip rectangular partition test when partition type none gives better |
| 391 | // rd than partition type split. |
| 392 | int less_rectangular_check; |
| 393 | |
| 394 | // Disable testing non square partitions. (eg 16x32) |
| 395 | int use_square_partition_only; |
| 396 | |
| 397 | // Sets min and max partition sizes for this superblock based on the |
| 398 | // same superblock in last encoded frame, and the left and above neighbor. |
| 399 | AUTO_MIN_MAX_MODE auto_min_max_partition_size; |
| 400 | // Ensures the rd based auto partition search will always |
| 401 | // go down at least to the specified level. |
| 402 | BLOCK_SIZE rd_auto_partition_min_limit; |
| 403 | |
| 404 | // Min and max partition size we enable (block_size) as per auto |
| 405 | // min max, but also used by adjust partitioning, and pick_partitioning. |
| 406 | BLOCK_SIZE default_min_partition_size; |
| 407 | BLOCK_SIZE default_max_partition_size; |
| 408 | |
| 409 | // Whether or not we allow partitions one smaller or one greater than the last |
| 410 | // frame's partitioning. Only used if use_lastframe_partitioning is set. |
| 411 | int adjust_partitioning_from_last_frame; |
| 412 | |
| 413 | // How frequently we re do the partitioning from scratch. Only used if |
| 414 | // use_lastframe_partitioning is set. |
| 415 | int last_partitioning_redo_frequency; |
| 416 | |
| 417 | // Disables sub 8x8 blocksizes in different scenarios: Choices are to disable |
| 418 | // it always, to allow it for only Last frame and Intra, disable it for all |
| 419 | // inter modes or to enable it always. |
| 420 | int disable_split_mask; |
| 421 | |
| 422 | // TODO(jingning): combine the related motion search speed features |
| 423 | // This allows us to use motion search at other sizes as a starting |
| 424 | // point for this motion search and limits the search range around it. |
| 425 | int adaptive_motion_search; |
| 426 | |
| 427 | // Flag for allowing some use of exhaustive searches; |
| 428 | int allow_exhaustive_searches; |
| 429 | |
| 430 | // Threshold for allowing exhaistive motion search. |
| 431 | int exhaustive_searches_thresh; |
| 432 | |
| 433 | // Maximum number of exhaustive searches for a frame. |
| 434 | int max_exaustive_pct; |
| 435 | |
| 436 | // Pattern to be used for any exhaustive mesh searches. |
| 437 | MESH_PATTERN mesh_patterns[MAX_MESH_STEP]; |
| 438 | |
| 439 | int schedule_mode_search; |
| 440 | |
| 441 | // Allows sub 8x8 modes to use the prediction filter that was determined |
| 442 | // best for 8x8 mode. If set to 0 we always re check all the filters for |
| 443 | // sizes less than 8x8, 1 means we check all filter modes if no 8x8 filter |
| 444 | // was selected, and 2 means we use 8 tap if no 8x8 filter mode was selected. |
| 445 | int adaptive_pred_interp_filter; |
| 446 | |
| 447 | // Adaptive prediction mode search |
| 448 | int adaptive_mode_search; |
| 449 | |
| 450 | // Chessboard pattern prediction filter type search |
| 451 | int cb_pred_filter_search; |
| 452 | |
| 453 | int cb_partition_search; |
| 454 | |
| 455 | int alt_ref_search_fp; |
| 456 | |
| 457 | // Use finer quantizer in every other few frames that run variable block |
| 458 | // partition type search. |
| 459 | int force_frame_boost; |
| 460 | |
| 461 | // Maximally allowed base quantization index fluctuation. |
| 462 | int max_delta_qindex; |
| 463 | |
| 464 | // Implements various heuristics to skip searching modes |
| 465 | // The heuristics selected are based on flags |
| 466 | // defined in the MODE_SEARCH_SKIP_HEURISTICS enum |
| 467 | unsigned int mode_search_skip_flags; |
| 468 | |
| 469 | // A source variance threshold below which filter search is disabled |
| 470 | // Choose a very large value (UINT_MAX) to use 8-tap always |
| 471 | unsigned int disable_filter_search_var_thresh; |
| 472 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 473 | // A source variance threshold below which wedge search is disabled |
| 474 | unsigned int disable_wedge_search_var_thresh; |
| 475 | |
| 476 | // Whether fast wedge sign estimate is used |
| 477 | int fast_wedge_sign_estimate; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 478 | |
| 479 | // These bit masks allow you to enable or disable intra modes for each |
| 480 | // transform size separately. |
| 481 | int intra_y_mode_mask[TX_SIZES]; |
| 482 | int intra_uv_mode_mask[TX_SIZES]; |
| 483 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 484 | // This variable enables an early break out of mode testing if the model for |
| 485 | // rd built from the prediction signal indicates a value that's much |
| 486 | // higher than the best rd we've seen so far. |
| 487 | int use_rd_breakout; |
| 488 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 489 | // This feature controls how the loop filter level is determined. |
| 490 | LPF_PICK_METHOD lpf_pick; |
| 491 | |
| 492 | // This feature limits the number of coefficients updates we actually do |
| 493 | // by only looking at counts from 1/2 the bands. |
| 494 | FAST_COEFF_UPDATE use_fast_coef_updates; |
| 495 | |
Sarah Parker | 2b9ec2e | 2017-10-30 17:34:08 -0700 | [diff] [blame] | 496 | // A binary mask indicating if NEARESTMV, NEARMV, GLOBALMV, NEWMV |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 497 | // modes are used in order from LSB to MSB for each BLOCK_SIZE. |
Rupert Swarbrick | 93c39e9 | 2017-07-12 11:11:02 +0100 | [diff] [blame] | 498 | int inter_mode_mask[BLOCK_SIZES_ALL]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 499 | |
| 500 | // This feature controls whether we do the expensive context update and |
| 501 | // calculation in the rd coefficient costing loop. |
| 502 | int use_fast_coef_costing; |
| 503 | |
| 504 | // This feature controls the tolerence vs target used in deciding whether to |
| 505 | // recode a frame. It has no meaning if recode is disabled. |
| 506 | int recode_tolerance; |
| 507 | |
| 508 | // This variable controls the maximum block size where intra blocks can be |
| 509 | // used in inter frames. |
| 510 | // TODO(aconverse): Fold this into one of the other many mode skips |
| 511 | BLOCK_SIZE max_intra_bsize; |
| 512 | |
Thomas Daede | 2e30063 | 2017-05-10 15:25:26 -0700 | [diff] [blame] | 513 | // The frequency that we check if |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 514 | // FIXED_PARTITION search type should be used. |
| 515 | int search_type_check_frequency; |
| 516 | |
| 517 | // When partition is pre-set, the inter prediction result from pick_inter_mode |
| 518 | // can be reused in final block encoding process. It is enabled only for real- |
| 519 | // time mode speed 6. |
| 520 | int reuse_inter_pred_sby; |
| 521 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 522 | // default interp filter choice |
James Zern | 7b9407a | 2016-05-18 23:48:05 -0700 | [diff] [blame] | 523 | InterpFilter default_interp_filter; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 524 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 525 | // adaptive interp_filter search to allow skip of certain filter types. |
| 526 | int adaptive_interp_filter_search; |
| 527 | |
| 528 | // mask for skip evaluation of certain interp_filter type. |
| 529 | INTERP_FILTER_MASK interp_filter_search_mask; |
| 530 | |
| 531 | // Partition search early breakout thresholds. |
| 532 | int64_t partition_search_breakout_dist_thr; |
| 533 | int partition_search_breakout_rate_thr; |
| 534 | |
| 535 | // Allow skipping partition search for still image frame |
| 536 | int allow_partition_search_skip; |
| 537 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 538 | // Fast approximation of av1_model_rd_from_var_lapndz |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 539 | int simple_model_rd_from_var; |
| 540 | |
Urvang Joshi | d2159ea | 2018-01-18 11:47:47 -0800 | [diff] [blame] | 541 | // If true, sub-pixel search uses the exact convolve function used for final |
| 542 | // encoding and decoding; otherwise, it uses bilinear interpolation. |
| 543 | int use_accurate_subpel_search; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 544 | |
| 545 | // Whether to compute distortion in the image domain (slower but |
| 546 | // more accurate), or in the transform domain (faster but less acurate). |
| 547 | int use_transform_domain_distortion; |
Debargha Mukherjee | 2a9d746 | 2017-05-04 17:37:52 -0700 | [diff] [blame] | 548 | |
Debargha Mukherjee | 2a9d746 | 2017-05-04 17:37:52 -0700 | [diff] [blame] | 549 | GM_SEARCH_TYPE gm_search_type; |
Michelle Findlay-Olynyk | a3eb912 | 2017-11-27 10:46:45 -0800 | [diff] [blame] | 550 | |
| 551 | // Do limited interpolation filter search for dual filters, since best choice |
| 552 | // usually includes EIGHTTAP_REGULAR. |
| 553 | int use_fast_interpolation_filter_search; |
Cheng Chen | c683bf9 | 2017-12-13 09:21:40 -0800 | [diff] [blame] | 554 | |
Michelle Findlay-Olynyk | fbab062 | 2017-12-13 14:10:56 -0800 | [diff] [blame] | 555 | // Use a hash table to store previously computed optimized qcoeffs from |
| 556 | // expensive calls to optimize_txb. |
| 557 | int use_hash_based_trellis; |
| 558 | |
Cheng Chen | c683bf9 | 2017-12-13 09:21:40 -0800 | [diff] [blame] | 559 | // flag to drop some ref frames in compound motion search |
| 560 | int drop_ref; |
Cheng Chen | c30c18f | 2018-01-26 16:58:31 -0800 | [diff] [blame] | 561 | |
| 562 | // flag to allow skipping intra mode for inter frame prediction |
| 563 | int skip_intra_in_interframe; |
Hui Su | ec5a1ab | 2018-03-08 15:09:12 -0800 | [diff] [blame] | 564 | |
| 565 | // Use hash table to store intra(keyframe only) txb transform search results |
| 566 | // to avoid repeated search on the same residue signal. |
| 567 | int use_intra_txb_hash; |
Hui Su | 9021ec9 | 2018-03-09 15:20:21 -0800 | [diff] [blame] | 568 | |
| 569 | // Use hash table to store inter txb transform search results |
| 570 | // to avoid repeated search on the same residue signal. |
| 571 | int use_inter_txb_hash; |
| 572 | |
| 573 | // Use hash table to store macroblock RD search results |
| 574 | // to avoid repeated search on the same residue signal. |
| 575 | int use_mb_rd_hash; |
Hui Su | 00dd499 | 2018-03-22 15:54:04 -0700 | [diff] [blame] | 576 | |
| 577 | // Calculate RD cost before doing optimize_b, and skip if the cost is large. |
| 578 | int optimize_b_precheck; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 579 | } SPEED_FEATURES; |
| 580 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 581 | struct AV1_COMP; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 582 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 583 | void av1_set_speed_features_framesize_independent(struct AV1_COMP *cpi); |
| 584 | void av1_set_speed_features_framesize_dependent(struct AV1_COMP *cpi); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 585 | |
| 586 | #ifdef __cplusplus |
| 587 | } // extern "C" |
| 588 | #endif |
| 589 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 590 | #endif // AV1_ENCODER_SPEED_FEATURES_H_ |