blob: 4e38709495d96b3868314b953220116e98ca3547 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07004 * 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 Xuc27fc142016-08-22 16:08:15 -070010 */
11
Yaowu Xuf883b422016-08-30 14:01:10 -070012#ifndef AV1_ENCODER_SPEED_FEATURES_H_
13#define AV1_ENCODER_SPEED_FEATURES_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
15#include "av1/common/enums.h"
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21enum {
22 INTRA_ALL = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED) | (1 << D45_PRED) |
Hui Su69ae7b82018-02-20 20:10:51 -080023 (1 << D135_PRED) | (1 << D113_PRED) | (1 << D157_PRED) |
24 (1 << D203_PRED) | (1 << D67_PRED) | (1 << SMOOTH_PRED) |
Urvang Joshib7301cd2017-11-09 15:08:56 -080025 (1 << SMOOTH_V_PRED) | (1 << SMOOTH_H_PRED) | (1 << PAETH_PRED),
Urvang Joshib7301cd2017-11-09 15:08:56 -080026 UV_INTRA_ALL =
27 (1 << UV_DC_PRED) | (1 << UV_V_PRED) | (1 << UV_H_PRED) |
Hui Su69ae7b82018-02-20 20:10:51 -080028 (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 Joshib7301cd2017-11-09 15:08:56 -080030 (1 << UV_SMOOTH_PRED) | (1 << UV_SMOOTH_V_PRED) |
31 (1 << UV_SMOOTH_H_PRED) | (1 << UV_PAETH_PRED) | (1 << UV_CFL_PRED),
Luc Trudeaud6d9eee2017-07-12 12:36:50 -040032 UV_INTRA_DC = (1 << UV_DC_PRED),
Luc Trudeau6e1cd782017-06-21 13:52:36 -040033 UV_INTRA_DC_CFL = (1 << UV_DC_PRED) | (1 << UV_CFL_PRED),
Urvang Joshi96d1c0a2017-10-10 13:15:32 -070034 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 Trudeaud6d9eee2017-07-12 12:36:50 -040037 UV_INTRA_DC_H_V = (1 << UV_DC_PRED) | (1 << UV_V_PRED) | (1 << UV_H_PRED),
Luc Trudeau6e1cd782017-06-21 13:52:36 -040038 UV_INTRA_DC_H_V_CFL = (1 << UV_DC_PRED) | (1 << UV_V_PRED) |
39 (1 << UV_H_PRED) | (1 << UV_CFL_PRED),
Urvang Joshi96d1c0a2017-10-10 13:15:32 -070040 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 Xuc27fc142016-08-22 16:08:15 -070045 INTRA_DC = (1 << DC_PRED),
Urvang Joshi96d1c0a2017-10-10 13:15:32 -070046 INTRA_DC_TM = (1 << DC_PRED) | (1 << PAETH_PRED),
Yaowu Xuc27fc142016-08-22 16:08:15 -070047 INTRA_DC_H_V = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED),
Urvang Joshi96d1c0a2017-10-10 13:15:32 -070048 INTRA_DC_PAETH_H_V =
49 (1 << DC_PRED) | (1 << PAETH_PRED) | (1 << V_PRED) | (1 << H_PRED)
Yaowu Xuc27fc142016-08-22 16:08:15 -070050};
51
Yaowu Xuc27fc142016-08-22 16:08:15 -070052enum {
Sarah Parker2b9ec2e2017-10-30 17:34:08 -070053 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 Xuc27fc142016-08-22 16:08:15 -070057 INTER_NEAREST = (1 << NEARESTMV) | (1 << NEAREST_NEARESTMV) |
Yaowu Xuc27fc142016-08-22 16:08:15 -070058 (1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV),
Zoe Liu7f24e1b2017-03-17 17:42:05 -070059 INTER_NEAREST_NEW = (1 << NEARESTMV) | (1 << NEWMV) |
Yaowu Xuc27fc142016-08-22 16:08:15 -070060 (1 << NEAREST_NEARESTMV) | (1 << NEW_NEWMV) |
Yaowu Xuc27fc142016-08-22 16:08:15 -070061 (1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV) |
62 (1 << NEW_NEARMV) | (1 << NEAR_NEWMV),
Sarah Parker2b9ec2e2017-10-30 17:34:08 -070063 INTER_NEAREST_ZERO = (1 << NEARESTMV) | (1 << GLOBALMV) |
64 (1 << NEAREST_NEARESTMV) | (1 << GLOBAL_GLOBALMV) |
Yaowu Xuc27fc142016-08-22 16:08:15 -070065 (1 << NEAREST_NEWMV) | (1 << NEW_NEARESTMV),
Sarah Parker2b9ec2e2017-10-30 17:34:08 -070066 INTER_NEAREST_NEW_ZERO = (1 << NEARESTMV) | (1 << GLOBALMV) | (1 << NEWMV) |
67 (1 << NEAREST_NEARESTMV) | (1 << GLOBAL_GLOBALMV) |
Debargha Mukherjeebb6e1342017-04-17 16:05:04 -070068 (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 Parker2b9ec2e2017-10-30 17:34:08 -070076 INTER_NEAREST_NEAR_ZERO = (1 << NEARESTMV) | (1 << NEARMV) | (1 << GLOBALMV) |
77 (1 << NEAREST_NEARESTMV) | (1 << GLOBAL_GLOBALMV) |
Debargha Mukherjeebb6e1342017-04-17 16:05:04 -070078 (1 << NEAREST_NEWMV) | (1 << NEW_NEARESTMV) |
79 (1 << NEW_NEARMV) | (1 << NEAR_NEWMV) |
80 (1 << NEAR_NEARMV),
Yaowu Xuc27fc142016-08-22 16:08:15 -070081};
Yaowu Xuc27fc142016-08-22 16:08:15 -070082
83enum {
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
95typedef enum {
Jingning Hanb49c6ae2017-11-27 18:14:05 -080096 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
106typedef enum {
Yaowu Xuc27fc142016-08-22 16:08:15 -0700107 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
116typedef 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
127typedef 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
135typedef enum {
136 NO_MOTION_THRESHOLD = 0,
137 LOW_MOTION_THRESHOLD = 7
138} MOTION_THRESHOLD;
139
140typedef enum {
141 USE_FULL_RD = 0,
Debargha Mukherjee51666862017-10-24 14:29:13 -0700142 USE_FAST_RD,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700143 USE_LARGESTALL,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700144} TX_SIZE_SEARCH_METHOD;
145
146typedef enum {
147 NOT_IN_USE = 0,
Thomas Daede80826142017-03-20 15:44:24 -0700148 RELAXED_NEIGHBORING_MIN_MAX = 1
Yaowu Xuc27fc142016-08-22 16:08:15 -0700149} AUTO_MIN_MAX_MODE;
150
151typedef 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
162typedef 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
181typedef 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
187typedef enum {
188 NO_PRUNE = 0,
189 // eliminates one tx type in vertical and horizontal direction
190 PRUNE_ONE = 1,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700191 // eliminates two tx types in each direction
192 PRUNE_TWO = 2,
Alexander Bokov0c7eb102017-09-07 18:49:00 -0700193 // 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 Xuc27fc142016-08-22 16:08:15 -0700198} TX_TYPE_PRUNE_MODE;
199
200typedef struct {
201 TX_TYPE_PRUNE_MODE prune_mode;
202 int fast_intra_tx_type_search;
203 int fast_inter_tx_type_search;
Alexander Bokov8829a242017-08-31 18:07:05 -0700204
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 Bokov79a37242017-09-29 11:25:55 -0700208
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 Chen3c222602018-01-22 19:34:18 -0800214
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 Xuc27fc142016-08-22 16:08:15 -0700218} TX_TYPE_SEARCH;
219
220typedef enum {
221 // Search partitions using RD criterion
222 SEARCH_PARTITION,
223
224 // Always use a fixed size partition
225 FIXED_PARTITION,
226
Thomas Daede8ea33192017-05-10 15:40:06 -0700227 REFERENCE_PARTITION
Yaowu Xuc27fc142016-08-22 16:08:15 -0700228} PARTITION_SEARCH_TYPE;
229
230typedef 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
240typedef 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
270typedef struct MESH_PATTERN {
271 int range;
272 int interval;
273} MESH_PATTERN;
274
Debargha Mukherjee2a9d7462017-05-04 17:37:52 -0700275typedef enum {
276 GM_FULL_SEARCH,
277 GM_REDUCED_REF_SEARCH,
278 GM_DISABLE_SEARCH
279} GM_SEARCH_TYPE;
Debargha Mukherjee2a9d7462017-05-04 17:37:52 -0700280
Sarah Parker251c9dc2017-12-13 15:34:36 -0800281typedef enum {
Sarah Parker07a28bc2018-03-16 14:29:58 -0700282 GM_ERRORADV_TR_0,
283 GM_ERRORADV_TR_1,
284 GM_ERRORADV_TR_2,
285} GM_ERRORADV_TYPE;
286
287typedef enum {
Sarah Parker251c9dc2017-12-13 15:34:36 -0800288 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 Han66965a22018-01-25 09:53:41 -0800293typedef enum {
294 FULL_TXFM_RD,
295 LOW_TXFM_RD,
296} TXFM_RD_MODEL;
297
Yaowu Xuc27fc142016-08-22 16:08:15 -0700298typedef 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 Parker251c9dc2017-12-13 15:34:36 -0800306 // Trellis (dynamic programming) optimization of quantized values
307 TRELLIS_OPT_TYPE optimize_coefficients;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700308
Sarah Parker07a28bc2018-03-16 14:29:58 -0700309 // Global motion warp error threshold
310 GM_ERRORADV_TYPE gm_erroradv_type;
311
Yaowu Xuc27fc142016-08-22 16:08:15 -0700312 // 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 Han8db5f172018-01-23 15:15:51 -0800319 // Limit the inter mode tested in the RD loop
320 int reduce_inter_modes;
321
Yaowu Xuc27fc142016-08-22 16:08:15 -0700322 // 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 Mukherjeeedc73462017-10-31 15:13:32 -0700344 // 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 Han45738ed2018-03-18 17:34:16 -0700349 // 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 Mukherjeeedc73462017-10-31 15:13:32 -0700352
Yaowu Xuc27fc142016-08-22 16:08:15 -0700353 // 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 Haneb8f5e82018-01-30 17:01:54 -0800362 // Skip split transform block partition when the collocated bigger block
363 // is selected as all zero coefficients.
364 int txb_split_cap;
365
Jingning Hanb91a0e72018-02-28 10:43:44 -0800366 // Shortcut the transform block partition and type search when the target
367 // rdcost is relatively lower.
368 int adaptive_txb_search;
369
Yaowu Xuc27fc142016-08-22 16:08:15 -0700370 // Used if partition_search_type = FIXED_SIZE_PARTITION
371 BLOCK_SIZE always_this_block_size;
372
Jingning Hancf842ad2017-10-25 12:02:30 -0700373 // Drop less likely picked reference frames in the RD search
Zoe Liu451672e2017-11-08 11:11:37 -0800374 // Has three levels for now: 1, 2 and 3, where higher levels are more
375 // aggressive than lower ones.
Jingning Hancf842ad2017-10-25 12:02:30 -0700376 int selective_ref_frame;
377
Debargha Mukherjeec4b67642017-11-01 22:57:28 -0700378 // Conditionally prune extended partition types search
379 int prune_ext_partition_types_search;
Debargha Mukherjeec4b67642017-11-01 22:57:28 -0700380
Debargha Mukherjeed7338aa2017-11-04 07:34:50 -0700381 int fast_cdef_search;
Debargha Mukherjeed7338aa2017-11-04 07:34:50 -0700382
Jingning Hana5847e82018-01-23 16:52:05 -0800383 // 2-pass coding block partition search
384 int two_pass_partition_search;
385
Hui Subb628a72018-04-05 19:48:23 -0700386 // 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 Xuc27fc142016-08-22 16:08:15 -0700390 // 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 Xuc27fc142016-08-22 16:08:15 -0700473 // 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 Xuc27fc142016-08-22 16:08:15 -0700478
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 Xuc27fc142016-08-22 16:08:15 -0700484 // 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 Xuc27fc142016-08-22 16:08:15 -0700489 // 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 Parker2b9ec2e2017-10-30 17:34:08 -0700496 // A binary mask indicating if NEARESTMV, NEARMV, GLOBALMV, NEWMV
Yaowu Xuc27fc142016-08-22 16:08:15 -0700497 // modes are used in order from LSB to MSB for each BLOCK_SIZE.
Rupert Swarbrick93c39e92017-07-12 11:11:02 +0100498 int inter_mode_mask[BLOCK_SIZES_ALL];
Yaowu Xuc27fc142016-08-22 16:08:15 -0700499
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 Daede2e300632017-05-10 15:25:26 -0700513 // The frequency that we check if
Yaowu Xuc27fc142016-08-22 16:08:15 -0700514 // 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 Xuc27fc142016-08-22 16:08:15 -0700522 // default interp filter choice
James Zern7b9407a2016-05-18 23:48:05 -0700523 InterpFilter default_interp_filter;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700524
Yaowu Xuc27fc142016-08-22 16:08:15 -0700525 // 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 Xuf883b422016-08-30 14:01:10 -0700538 // Fast approximation of av1_model_rd_from_var_lapndz
Yaowu Xuc27fc142016-08-22 16:08:15 -0700539 int simple_model_rd_from_var;
540
Urvang Joshid2159ea2018-01-18 11:47:47 -0800541 // 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 Xuc27fc142016-08-22 16:08:15 -0700544
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 Mukherjee2a9d7462017-05-04 17:37:52 -0700548
Debargha Mukherjee2a9d7462017-05-04 17:37:52 -0700549 GM_SEARCH_TYPE gm_search_type;
Michelle Findlay-Olynyka3eb9122017-11-27 10:46:45 -0800550
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 Chenc683bf92017-12-13 09:21:40 -0800554
Michelle Findlay-Olynykfbab0622017-12-13 14:10:56 -0800555 // 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 Chenc683bf92017-12-13 09:21:40 -0800559 // flag to drop some ref frames in compound motion search
560 int drop_ref;
Cheng Chenc30c18f2018-01-26 16:58:31 -0800561
562 // flag to allow skipping intra mode for inter frame prediction
563 int skip_intra_in_interframe;
Hui Suec5a1ab2018-03-08 15:09:12 -0800564
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 Su9021ec92018-03-09 15:20:21 -0800568
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 Su00dd4992018-03-22 15:54:04 -0700576
577 // Calculate RD cost before doing optimize_b, and skip if the cost is large.
578 int optimize_b_precheck;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700579} SPEED_FEATURES;
580
Yaowu Xuf883b422016-08-30 14:01:10 -0700581struct AV1_COMP;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700582
Yaowu Xuf883b422016-08-30 14:01:10 -0700583void av1_set_speed_features_framesize_independent(struct AV1_COMP *cpi);
584void av1_set_speed_features_framesize_dependent(struct AV1_COMP *cpi);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700585
586#ifdef __cplusplus
587} // extern "C"
588#endif
589
Yaowu Xuf883b422016-08-30 14:01:10 -0700590#endif // AV1_ENCODER_SPEED_FEATURES_H_