/src/aom/av1/encoder/speed_features.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2016, Alliance for Open Media. All rights reserved. |
3 | | * |
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. |
10 | | */ |
11 | | |
12 | | #include <limits.h> |
13 | | |
14 | | #include "av1/common/reconintra.h" |
15 | | |
16 | | #include "av1/encoder/encoder.h" |
17 | | #include "av1/encoder/speed_features.h" |
18 | | #include "av1/encoder/rdopt.h" |
19 | | |
20 | | #include "aom_dsp/aom_dsp_common.h" |
21 | | |
22 | | #define MAX_MESH_SPEED 5 // Max speed setting for mesh motion method |
23 | | // Max speed setting for tx domain evaluation |
24 | | #define MAX_TX_DOMAIN_EVAL_SPEED 5 |
25 | | static const MESH_PATTERN |
26 | | good_quality_mesh_patterns[MAX_MESH_SPEED + 1][MAX_MESH_STEP] = { |
27 | | { { 64, 8 }, { 28, 4 }, { 15, 1 }, { 7, 1 } }, |
28 | | { { 64, 8 }, { 28, 4 }, { 15, 1 }, { 7, 1 } }, |
29 | | { { 64, 8 }, { 14, 2 }, { 7, 1 }, { 7, 1 } }, |
30 | | { { 64, 16 }, { 24, 8 }, { 12, 4 }, { 7, 1 } }, |
31 | | { { 64, 16 }, { 24, 8 }, { 12, 4 }, { 7, 1 } }, |
32 | | { { 64, 16 }, { 24, 8 }, { 12, 4 }, { 7, 1 } }, |
33 | | }; |
34 | | |
35 | | // TODO(huisu@google.com): These settings are pretty relaxed, tune them for |
36 | | // each speed setting |
37 | | static const MESH_PATTERN |
38 | | intrabc_mesh_patterns[MAX_MESH_SPEED + 1][MAX_MESH_STEP] = { |
39 | | { { 256, 1 }, { 256, 1 }, { 0, 0 }, { 0, 0 } }, |
40 | | { { 256, 1 }, { 256, 1 }, { 0, 0 }, { 0, 0 } }, |
41 | | { { 64, 1 }, { 64, 1 }, { 0, 0 }, { 0, 0 } }, |
42 | | { { 64, 1 }, { 64, 1 }, { 0, 0 }, { 0, 0 } }, |
43 | | { { 64, 4 }, { 16, 1 }, { 0, 0 }, { 0, 0 } }, |
44 | | { { 64, 4 }, { 16, 1 }, { 0, 0 }, { 0, 0 } }, |
45 | | }; |
46 | | |
47 | | // Threshold values to be used for pruning the txfm_domain_distortion |
48 | | // based on block MSE |
49 | | // Index 0: Default mode evaluation, Winner mode processing is not |
50 | | // applicable (Eg : IntraBc). Index 1: Mode evaluation. |
51 | | // Index 2: Winner mode evaluation. Index 1 and 2 are applicable when |
52 | | // enable_winner_mode_for_use_tx_domain_dist speed feature is ON |
53 | | // TODO(any): Experiment the threshold logic based on variance metric |
54 | | static const unsigned int tx_domain_dist_thresholds[4][MODE_EVAL_TYPES] = { |
55 | | { UINT_MAX, UINT_MAX, UINT_MAX }, |
56 | | { 22026, 22026, 22026 }, |
57 | | { 1377, 1377, 1377 }, |
58 | | { 0, 0, 0 } |
59 | | }; |
60 | | |
61 | | // Number of different levels of aggressiveness in using transform domain |
62 | | // distortion during the R-D evaluation based on the speed feature |
63 | | // tx_domain_dist_level. |
64 | | #define TX_DOMAIN_DIST_LEVELS 4 |
65 | | |
66 | | // Transform domain distortion type to be used for default, mode and winner mode |
67 | | // evaluation Index 0: Default mode evaluation, Winner mode processing is not |
68 | | // applicable (Eg : IntraBc). Index 1: Mode evaluation. Index 2: Winner mode |
69 | | // evaluation. Index 1 and 2 are applicable when |
70 | | // enable_winner_mode_for_use_tx_domain_dist speed feature is ON |
71 | | static const unsigned int |
72 | | tx_domain_dist_types[TX_DOMAIN_DIST_LEVELS][MODE_EVAL_TYPES] = { |
73 | | { 0, 2, 0 }, { 1, 2, 0 }, { 2, 2, 0 }, { 2, 2, 2 } |
74 | | }; |
75 | | |
76 | | // Threshold values to be used for disabling coeff RD-optimization |
77 | | // based on block MSE / qstep^2. |
78 | | // TODO(any): Experiment the threshold logic based on variance metric. |
79 | | // Table has satd and dist threshold value index 0 : dist,index 1: satd |
80 | | // For each row, the indices are as follows. |
81 | | // Index 0: Default mode evaluation, Winner mode processing is not applicable |
82 | | // (Eg : IntraBc) |
83 | | // Index 1: Mode evaluation. |
84 | | // Index 2: Winner mode evaluation. |
85 | | // Index 1 and 2 are applicable when enable_winner_mode_for_coeff_opt speed |
86 | | // feature is ON |
87 | | // There are 7 levels with increasing speed, mapping to vertical indices. |
88 | | static const unsigned int coeff_opt_thresholds[9][MODE_EVAL_TYPES][2] = { |
89 | | { { UINT_MAX, UINT_MAX }, { UINT_MAX, UINT_MAX }, { UINT_MAX, UINT_MAX } }, |
90 | | { { 3200, UINT_MAX }, { 250, UINT_MAX }, { UINT_MAX, UINT_MAX } }, |
91 | | { { 1728, UINT_MAX }, { 142, UINT_MAX }, { UINT_MAX, UINT_MAX } }, |
92 | | { { 864, UINT_MAX }, { 142, UINT_MAX }, { UINT_MAX, UINT_MAX } }, |
93 | | { { 432, UINT_MAX }, { 86, UINT_MAX }, { UINT_MAX, UINT_MAX } }, |
94 | | { { 864, 97 }, { 142, 16 }, { UINT_MAX, UINT_MAX } }, |
95 | | { { 432, 97 }, { 86, 16 }, { UINT_MAX, UINT_MAX } }, |
96 | | { { 216, 25 }, { 86, 10 }, { UINT_MAX, UINT_MAX } }, |
97 | | { { 216, 25 }, { 0, 10 }, { UINT_MAX, UINT_MAX } } |
98 | | }; |
99 | | |
100 | | // Transform size to be used for default, mode and winner mode evaluation |
101 | | // Index 0: Default mode evaluation, Winner mode processing is not applicable |
102 | | // (Eg : IntraBc) Index 1: Mode evaluation. Index 2: Winner mode evaluation. |
103 | | // Index 1 and 2 are applicable when enable_winner_mode_for_tx_size_srch speed |
104 | | // feature is ON |
105 | | static const TX_SIZE_SEARCH_METHOD |
106 | | tx_size_search_methods[4][MODE_EVAL_TYPES] = { |
107 | | { USE_FULL_RD, USE_LARGESTALL, USE_FULL_RD }, |
108 | | { USE_FAST_RD, USE_LARGESTALL, USE_FULL_RD }, |
109 | | { USE_LARGESTALL, USE_LARGESTALL, USE_FULL_RD }, |
110 | | { USE_LARGESTALL, USE_LARGESTALL, USE_LARGESTALL } |
111 | | }; |
112 | | |
113 | | // Predict transform skip levels to be used for default, mode and winner mode |
114 | | // evaluation. Index 0: Default mode evaluation, Winner mode processing is not |
115 | | // applicable. Index 1: Mode evaluation, Index 2: Winner mode evaluation |
116 | | // Values indicate the aggressiveness of skip flag prediction. |
117 | | // 0 : no early skip prediction |
118 | | // 1 : conservative early skip prediction using DCT_DCT |
119 | | // 2 : early skip prediction based on SSE |
120 | | static const unsigned int predict_skip_levels[3][MODE_EVAL_TYPES] = { |
121 | | { 0, 0, 0 }, { 1, 1, 1 }, { 1, 2, 1 } |
122 | | }; |
123 | | |
124 | | // Predict skip or DC block level used during transform type search. It is |
125 | | // indexed using the following: |
126 | | // First index : Speed feature 'dc_blk_pred_level' (0 to 3) |
127 | | // Second index : Mode evaluation type (DEFAULT_EVAL, MODE_EVAL and |
128 | | // WINNER_MODE_EVAL). |
129 | | // |
130 | | // The values of predict_dc_levels[][] indicate the aggressiveness of predicting |
131 | | // a block as transform skip or DC only. |
132 | | // Type 0 : No skip block or DC only block prediction |
133 | | // Type 1 : Prediction of skip block based on residual mean and variance |
134 | | // Type 2 : Prediction of skip block or DC only block based on residual mean and |
135 | | // variance |
136 | | static const unsigned int predict_dc_levels[4][MODE_EVAL_TYPES] = { |
137 | | { 0, 0, 0 }, { 1, 1, 0 }, { 2, 2, 0 }, { 2, 2, 2 } |
138 | | }; |
139 | | |
140 | | #if !CONFIG_FPMT_TEST |
141 | | // This table holds the maximum number of reference frames for global motion. |
142 | | // The table is indexed as per the speed feature 'gm_search_type'. |
143 | | // 0 : All reference frames are allowed. |
144 | | // 1 : All reference frames except L2 and L3 are allowed. |
145 | | // 2 : All reference frames except L2, L3 and ARF2 are allowed. |
146 | | // 3 : No reference frame is allowed. |
147 | | static const int gm_available_reference_frames[GM_DISABLE_SEARCH + 1] = { |
148 | | INTER_REFS_PER_FRAME, INTER_REFS_PER_FRAME - 2, INTER_REFS_PER_FRAME - 3, 0 |
149 | | }; |
150 | | #endif |
151 | | |
152 | | // Qindex threshold levels used for selecting full-pel motion search. |
153 | | // ms_qthresh[i][j][k] indicates the qindex boundary value for 'k'th qindex band |
154 | | // for resolution index 'j' for aggressiveness level 'i'. |
155 | | // Aggressiveness increases from i = 0 to 2. |
156 | | // j = 0: lower than 720p resolution, j = 1: 720p or larger resolution. |
157 | | // Currently invoked only for speed 0, 1 and 2. |
158 | | static const int ms_qindex_thresh[3][2][2] = { { { 200, 70 }, { MAXQ, 200 } }, |
159 | | { { 170, 50 }, { MAXQ, 200 } }, |
160 | | { { 170, 40 }, { 200, 40 } } }; |
161 | | |
162 | | // Full-pel search methods for aggressive search based on qindex. |
163 | | // Index 0 is for resolutions lower than 720p, index 1 for 720p or larger |
164 | | // resolutions. Currently invoked only for speed 1 and 2. |
165 | | static const SEARCH_METHODS motion_search_method[2] = { CLAMPED_DIAMOND, |
166 | | DIAMOND }; |
167 | | |
168 | | // Intra only frames, golden frames (except alt ref overlays) and |
169 | | // alt ref frames tend to be coded at a higher than ambient quality |
170 | 0 | static int frame_is_boosted(const AV1_COMP *cpi) { |
171 | 0 | return frame_is_kf_gf_arf(cpi); |
172 | 0 | } |
173 | | |
174 | | // Set transform rd gate level for all transform search cases. |
175 | | static inline void set_txfm_rd_gate_level( |
176 | 0 | int txfm_rd_gate_level[TX_SEARCH_CASES], int level) { |
177 | 0 | assert(level <= MAX_TX_RD_GATE_LEVEL); |
178 | 0 | for (int idx = 0; idx < TX_SEARCH_CASES; idx++) |
179 | 0 | txfm_rd_gate_level[idx] = level; |
180 | 0 | } |
181 | | |
182 | | static void set_allintra_speed_feature_framesize_dependent( |
183 | 0 | const AV1_COMP *const cpi, SPEED_FEATURES *const sf, int speed) { |
184 | 0 | const AV1_COMMON *const cm = &cpi->common; |
185 | 0 | const int is_480p_or_larger = AOMMIN(cm->width, cm->height) >= 480; |
186 | 0 | const int is_720p_or_larger = AOMMIN(cm->width, cm->height) >= 720; |
187 | 0 | const int is_1080p_or_larger = AOMMIN(cm->width, cm->height) >= 1080; |
188 | 0 | const int is_4k_or_larger = AOMMIN(cm->width, cm->height) >= 2160; |
189 | 0 | const bool use_hbd = cpi->oxcf.use_highbitdepth; |
190 | |
|
191 | 0 | if (is_480p_or_larger) { |
192 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_128X128; |
193 | 0 | if (is_720p_or_larger) |
194 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = ADAPT_PRED; |
195 | 0 | else |
196 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = RELAXED_PRED; |
197 | 0 | } else { |
198 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_64X64; |
199 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = DIRECT_PRED; |
200 | 0 | if (use_hbd) sf->tx_sf.prune_tx_size_level = 1; |
201 | 0 | } |
202 | |
|
203 | 0 | if (is_4k_or_larger) { |
204 | 0 | sf->part_sf.default_min_partition_size = BLOCK_8X8; |
205 | 0 | } |
206 | | |
207 | | // TODO(huisu@google.com): train models for 720P and above. |
208 | 0 | if (!is_720p_or_larger) { |
209 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[0] = 200; // BLOCK_8X8 |
210 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[1] = 250; // BLOCK_16X16 |
211 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[2] = 300; // BLOCK_32X32 |
212 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[3] = 500; // BLOCK_64X64 |
213 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[4] = -1; // BLOCK_128X128 |
214 | 0 | sf->part_sf.ml_early_term_after_part_split_level = 1; |
215 | 0 | } |
216 | |
|
217 | 0 | if (is_720p_or_larger) { |
218 | | // TODO(chiyotsai@google.com): make this speed feature adaptive based on |
219 | | // current block's vertical texture instead of hardcoded with resolution |
220 | 0 | sf->mv_sf.use_downsampled_sad = 2; |
221 | 0 | } |
222 | |
|
223 | 0 | if (speed >= 1) { |
224 | 0 | if (is_720p_or_larger) { |
225 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_128X128; |
226 | 0 | } else if (is_480p_or_larger) { |
227 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_64X64; |
228 | 0 | } else { |
229 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_32X32; |
230 | 0 | } |
231 | |
|
232 | 0 | if (!is_720p_or_larger) { |
233 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[0] = 200; // BLOCK_8X8 |
234 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[1] = 250; // BLOCK_16X16 |
235 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[2] = 300; // BLOCK_32X32 |
236 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[3] = 300; // BLOCK_64X64 |
237 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[4] = -1; // BLOCK_128X128 |
238 | 0 | } |
239 | 0 | sf->part_sf.ml_early_term_after_part_split_level = 2; |
240 | 0 | } |
241 | |
|
242 | 0 | if (speed >= 2) { |
243 | 0 | if (is_720p_or_larger) { |
244 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_64X64; |
245 | 0 | } else if (is_480p_or_larger) { |
246 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_32X32; |
247 | 0 | } else { |
248 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_32X32; |
249 | 0 | } |
250 | |
|
251 | 0 | if (is_720p_or_larger) { |
252 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 24); |
253 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 120; |
254 | 0 | } else { |
255 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 22); |
256 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 100; |
257 | 0 | } |
258 | |
|
259 | 0 | if (is_480p_or_larger) { |
260 | 0 | sf->tx_sf.tx_type_search.prune_tx_type_using_stats = 1; |
261 | 0 | if (use_hbd) sf->tx_sf.prune_tx_size_level = 2; |
262 | 0 | } else { |
263 | 0 | if (use_hbd) sf->tx_sf.prune_tx_size_level = 3; |
264 | 0 | } |
265 | 0 | } |
266 | |
|
267 | 0 | if (speed >= 3) { |
268 | 0 | sf->part_sf.ml_early_term_after_part_split_level = 0; |
269 | |
|
270 | 0 | if (is_720p_or_larger) { |
271 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 25); |
272 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 200; |
273 | 0 | } else { |
274 | 0 | sf->part_sf.max_intra_bsize = BLOCK_32X32; |
275 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 23); |
276 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 120; |
277 | 0 | } |
278 | 0 | if (use_hbd) sf->tx_sf.prune_tx_size_level = 3; |
279 | 0 | } |
280 | |
|
281 | 0 | if (speed >= 4) { |
282 | 0 | if (is_720p_or_larger) { |
283 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 26); |
284 | 0 | } else { |
285 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 24); |
286 | 0 | } |
287 | |
|
288 | 0 | if (is_480p_or_larger) { |
289 | 0 | sf->tx_sf.tx_type_search.prune_tx_type_using_stats = 2; |
290 | 0 | } |
291 | 0 | } |
292 | |
|
293 | 0 | if (speed >= 6) { |
294 | 0 | if (is_720p_or_larger) { |
295 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = NOT_IN_USE; |
296 | 0 | } else if (is_480p_or_larger) { |
297 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = DIRECT_PRED; |
298 | 0 | } |
299 | |
|
300 | 0 | if (is_1080p_or_larger) { |
301 | 0 | sf->part_sf.default_min_partition_size = BLOCK_8X8; |
302 | 0 | } |
303 | |
|
304 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_16X16; |
305 | 0 | } |
306 | |
|
307 | 0 | if (speed >= 7) { |
308 | | // TODO(kyslov): add more speed features to control speed/quality |
309 | 0 | } |
310 | |
|
311 | 0 | if (speed >= 8) { |
312 | 0 | if (!is_480p_or_larger) { |
313 | 0 | sf->rt_sf.nonrd_check_partition_merge_mode = 2; |
314 | 0 | } |
315 | 0 | if (is_720p_or_larger) { |
316 | 0 | sf->rt_sf.force_large_partition_blocks_intra = 1; |
317 | 0 | } |
318 | 0 | } |
319 | |
|
320 | 0 | if (speed >= 9) { |
321 | | // TODO(kyslov): add more speed features to control speed/quality |
322 | 0 | if (!is_4k_or_larger) { |
323 | | // In av1_select_sb_size(), superblock size is set to 64x64 only for |
324 | | // resolutions less than 4k in speed>=9, to improve the multithread |
325 | | // performance. If cost update levels are set to INTERNAL_COST_UPD_OFF |
326 | | // for resolutions >= 4k, the SB size setting can be modified for these |
327 | | // resolutions as well. |
328 | 0 | sf->inter_sf.coeff_cost_upd_level = INTERNAL_COST_UPD_OFF; |
329 | 0 | sf->inter_sf.mode_cost_upd_level = INTERNAL_COST_UPD_OFF; |
330 | 0 | } |
331 | 0 | } |
332 | 0 | } |
333 | | |
334 | | static void set_allintra_speed_features_framesize_independent( |
335 | 0 | const AV1_COMP *const cpi, SPEED_FEATURES *const sf, int speed) { |
336 | 0 | const AV1_COMMON *const cm = &cpi->common; |
337 | 0 | const int allow_screen_content_tools = |
338 | 0 | cm->features.allow_screen_content_tools; |
339 | 0 | const int use_hbd = cpi->oxcf.use_highbitdepth; |
340 | |
|
341 | 0 | sf->part_sf.less_rectangular_check_level = 1; |
342 | 0 | sf->part_sf.ml_prune_partition = 1; |
343 | 0 | sf->part_sf.prune_ext_partition_types_search_level = 1; |
344 | 0 | sf->part_sf.prune_part4_search = 2; |
345 | 0 | sf->part_sf.simple_motion_search_prune_rect = 1; |
346 | 0 | sf->part_sf.ml_predict_breakout_level = use_hbd ? 1 : 3; |
347 | 0 | sf->part_sf.reuse_prev_rd_results_for_part_ab = 1; |
348 | 0 | sf->part_sf.use_best_rd_for_pruning = 1; |
349 | |
|
350 | 0 | sf->intra_sf.intra_pruning_with_hog = 1; |
351 | 0 | sf->intra_sf.prune_luma_palette_size_search_level = 1; |
352 | 0 | sf->intra_sf.dv_cost_upd_level = INTERNAL_COST_UPD_OFF; |
353 | 0 | sf->intra_sf.early_term_chroma_palette_size_search = 1; |
354 | |
|
355 | 0 | sf->tx_sf.adaptive_txb_search_level = 1; |
356 | 0 | sf->tx_sf.intra_tx_size_search_init_depth_sqr = 1; |
357 | 0 | sf->tx_sf.model_based_prune_tx_search_level = 1; |
358 | 0 | sf->tx_sf.tx_type_search.use_reduced_intra_txset = 1; |
359 | |
|
360 | 0 | sf->rt_sf.use_nonrd_pick_mode = 0; |
361 | 0 | sf->rt_sf.use_real_time_ref_set = 0; |
362 | |
|
363 | 0 | if (cpi->twopass_frame.fr_content_type == FC_GRAPHICS_ANIMATION || |
364 | 0 | cpi->use_screen_content_tools) { |
365 | 0 | sf->mv_sf.exhaustive_searches_thresh = (1 << 20); |
366 | 0 | } else { |
367 | 0 | sf->mv_sf.exhaustive_searches_thresh = (1 << 25); |
368 | 0 | } |
369 | |
|
370 | 0 | sf->rd_sf.perform_coeff_opt = 1; |
371 | 0 | sf->hl_sf.superres_auto_search_type = SUPERRES_AUTO_DUAL; |
372 | |
|
373 | 0 | if (speed >= 1) { |
374 | 0 | sf->part_sf.intra_cnn_based_part_prune_level = |
375 | 0 | allow_screen_content_tools ? 0 : 2; |
376 | 0 | sf->part_sf.simple_motion_search_early_term_none = 1; |
377 | | // TODO(Venkat): Clean-up frame type dependency for |
378 | | // simple_motion_search_split in partition search function and set the |
379 | | // speed feature accordingly |
380 | 0 | sf->part_sf.simple_motion_search_split = allow_screen_content_tools ? 1 : 2; |
381 | 0 | sf->part_sf.ml_predict_breakout_level = use_hbd ? 2 : 3; |
382 | 0 | sf->part_sf.reuse_best_prediction_for_part_ab = 1; |
383 | |
|
384 | 0 | sf->mv_sf.exhaustive_searches_thresh <<= 1; |
385 | |
|
386 | 0 | sf->intra_sf.prune_palette_search_level = 1; |
387 | 0 | sf->intra_sf.prune_luma_palette_size_search_level = 2; |
388 | 0 | sf->intra_sf.top_intra_model_count_allowed = 3; |
389 | |
|
390 | 0 | sf->tx_sf.adaptive_txb_search_level = 2; |
391 | 0 | sf->tx_sf.inter_tx_size_search_init_depth_rect = 1; |
392 | 0 | sf->tx_sf.inter_tx_size_search_init_depth_sqr = 1; |
393 | 0 | sf->tx_sf.intra_tx_size_search_init_depth_rect = 1; |
394 | 0 | sf->tx_sf.model_based_prune_tx_search_level = 0; |
395 | 0 | sf->tx_sf.tx_type_search.ml_tx_split_thresh = 4000; |
396 | 0 | sf->tx_sf.tx_type_search.prune_2d_txfm_mode = TX_TYPE_PRUNE_2; |
397 | 0 | sf->tx_sf.tx_type_search.skip_tx_search = 1; |
398 | |
|
399 | 0 | sf->rd_sf.perform_coeff_opt = 2; |
400 | 0 | sf->rd_sf.tx_domain_dist_level = 1; |
401 | 0 | sf->rd_sf.tx_domain_dist_thres_level = 1; |
402 | |
|
403 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL1; |
404 | 0 | sf->lpf_sf.dual_sgr_penalty_level = 1; |
405 | 0 | sf->lpf_sf.enable_sgr_ep_pruning = 1; |
406 | 0 | } |
407 | |
|
408 | 0 | if (speed >= 2) { |
409 | 0 | sf->mv_sf.auto_mv_step_size = 1; |
410 | |
|
411 | 0 | sf->intra_sf.disable_smooth_intra = 1; |
412 | 0 | sf->intra_sf.intra_pruning_with_hog = 2; |
413 | 0 | sf->intra_sf.prune_filter_intra_level = 1; |
414 | |
|
415 | 0 | sf->rd_sf.perform_coeff_opt = 3; |
416 | |
|
417 | 0 | sf->lpf_sf.prune_wiener_based_on_src_var = 1; |
418 | 0 | sf->lpf_sf.prune_sgr_based_on_wiener = 1; |
419 | 0 | } |
420 | |
|
421 | 0 | if (speed >= 3) { |
422 | 0 | sf->hl_sf.high_precision_mv_usage = CURRENT_Q; |
423 | 0 | sf->hl_sf.recode_loop = ALLOW_RECODE_KFARFGF; |
424 | |
|
425 | 0 | sf->part_sf.less_rectangular_check_level = 2; |
426 | 0 | sf->part_sf.simple_motion_search_prune_agg = SIMPLE_AGG_LVL1; |
427 | 0 | sf->part_sf.prune_ext_part_using_split_info = 1; |
428 | |
|
429 | 0 | sf->mv_sf.full_pixel_search_level = 1; |
430 | 0 | sf->mv_sf.search_method = DIAMOND; |
431 | | |
432 | | // TODO(chiyotsai@google.com): the thresholds chosen for intra hog are |
433 | | // inherited directly from luma hog with some minor tweaking. Eventually we |
434 | | // should run this with a bayesian optimizer to find the Pareto frontier. |
435 | 0 | sf->intra_sf.chroma_intra_pruning_with_hog = 2; |
436 | 0 | sf->intra_sf.intra_pruning_with_hog = 3; |
437 | 0 | sf->intra_sf.prune_palette_search_level = 2; |
438 | |
|
439 | 0 | sf->tx_sf.adaptive_txb_search_level = 2; |
440 | 0 | sf->tx_sf.tx_type_search.use_skip_flag_prediction = 2; |
441 | 0 | sf->tx_sf.use_rd_based_breakout_for_intra_tx_search = true; |
442 | | |
443 | | // TODO(any): evaluate if these lpf features can be moved to speed 2. |
444 | | // For screen content, "prune_sgr_based_on_wiener = 2" cause large quality |
445 | | // loss. |
446 | 0 | sf->lpf_sf.prune_sgr_based_on_wiener = allow_screen_content_tools ? 1 : 2; |
447 | 0 | sf->lpf_sf.disable_loop_restoration_chroma = 0; |
448 | 0 | sf->lpf_sf.reduce_wiener_window_size = 1; |
449 | 0 | sf->lpf_sf.prune_wiener_based_on_src_var = 2; |
450 | 0 | } |
451 | |
|
452 | 0 | if (speed >= 4) { |
453 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE; |
454 | |
|
455 | 0 | sf->part_sf.simple_motion_search_prune_agg = SIMPLE_AGG_LVL2; |
456 | 0 | sf->part_sf.simple_motion_search_reduce_search_steps = 4; |
457 | 0 | sf->part_sf.prune_ext_part_using_split_info = 2; |
458 | 0 | sf->part_sf.early_term_after_none_split = 1; |
459 | 0 | sf->part_sf.ml_predict_breakout_level = 3; |
460 | |
|
461 | 0 | sf->intra_sf.prune_chroma_modes_using_luma_winner = 1; |
462 | |
|
463 | 0 | sf->mv_sf.simple_motion_subpel_force_stop = HALF_PEL; |
464 | |
|
465 | 0 | sf->tpl_sf.prune_starting_mv = 2; |
466 | 0 | sf->tpl_sf.subpel_force_stop = HALF_PEL; |
467 | 0 | sf->tpl_sf.search_method = FAST_BIGDIA; |
468 | |
|
469 | 0 | sf->tx_sf.tx_type_search.winner_mode_tx_type_pruning = 2; |
470 | 0 | sf->tx_sf.tx_type_search.fast_intra_tx_type_search = 1; |
471 | 0 | sf->tx_sf.tx_type_search.prune_2d_txfm_mode = TX_TYPE_PRUNE_3; |
472 | 0 | sf->tx_sf.tx_type_search.prune_tx_type_est_rd = 1; |
473 | |
|
474 | 0 | sf->rd_sf.perform_coeff_opt = 5; |
475 | 0 | sf->rd_sf.tx_domain_dist_thres_level = 3; |
476 | |
|
477 | 0 | sf->lpf_sf.lpf_pick = LPF_PICK_FROM_FULL_IMAGE_NON_DUAL; |
478 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL3; |
479 | |
|
480 | 0 | sf->mv_sf.reduce_search_range = 1; |
481 | |
|
482 | 0 | sf->winner_mode_sf.enable_winner_mode_for_coeff_opt = 1; |
483 | 0 | sf->winner_mode_sf.enable_winner_mode_for_use_tx_domain_dist = 1; |
484 | 0 | sf->winner_mode_sf.multi_winner_mode_type = MULTI_WINNER_MODE_DEFAULT; |
485 | 0 | sf->winner_mode_sf.enable_winner_mode_for_tx_size_srch = 1; |
486 | 0 | } |
487 | |
|
488 | 0 | if (speed >= 5) { |
489 | 0 | sf->part_sf.simple_motion_search_prune_agg = SIMPLE_AGG_LVL3; |
490 | 0 | sf->part_sf.ext_partition_eval_thresh = |
491 | 0 | allow_screen_content_tools ? BLOCK_8X8 : BLOCK_16X16; |
492 | 0 | sf->part_sf.intra_cnn_based_part_prune_level = |
493 | 0 | allow_screen_content_tools ? 1 : 2; |
494 | |
|
495 | 0 | sf->intra_sf.chroma_intra_pruning_with_hog = 3; |
496 | |
|
497 | 0 | sf->lpf_sf.use_coarse_filter_level_search = 0; |
498 | | // Disable Wiener and Self-guided Loop restoration filters. |
499 | 0 | sf->lpf_sf.disable_wiener_filter = true; |
500 | 0 | sf->lpf_sf.disable_sgr_filter = true; |
501 | |
|
502 | 0 | sf->mv_sf.prune_mesh_search = PRUNE_MESH_SEARCH_LVL_2; |
503 | |
|
504 | 0 | sf->winner_mode_sf.multi_winner_mode_type = MULTI_WINNER_MODE_FAST; |
505 | 0 | } |
506 | |
|
507 | 0 | if (speed >= 6) { |
508 | 0 | sf->intra_sf.prune_smooth_intra_mode_for_chroma = 1; |
509 | 0 | sf->intra_sf.prune_filter_intra_level = 2; |
510 | 0 | sf->intra_sf.chroma_intra_pruning_with_hog = 4; |
511 | 0 | sf->intra_sf.intra_pruning_with_hog = 4; |
512 | 0 | sf->intra_sf.cfl_search_range = 1; |
513 | 0 | sf->intra_sf.top_intra_model_count_allowed = 2; |
514 | 0 | sf->intra_sf.adapt_top_model_rd_count_using_neighbors = 1; |
515 | 0 | sf->intra_sf.prune_luma_odd_delta_angles_in_intra = 1; |
516 | |
|
517 | 0 | sf->part_sf.prune_rectangular_split_based_on_qidx = |
518 | 0 | allow_screen_content_tools ? 0 : 2; |
519 | 0 | sf->part_sf.prune_rect_part_using_4x4_var_deviation = true; |
520 | 0 | sf->part_sf.prune_rect_part_using_none_pred_mode = true; |
521 | 0 | sf->part_sf.prune_sub_8x8_partition_level = |
522 | 0 | allow_screen_content_tools ? 0 : 1; |
523 | 0 | sf->part_sf.prune_part4_search = 3; |
524 | | // TODO(jingning): This might not be a good trade off if the |
525 | | // target image quality is very low. |
526 | 0 | sf->part_sf.default_max_partition_size = BLOCK_32X32; |
527 | |
|
528 | 0 | sf->mv_sf.use_bsize_dependent_search_method = 1; |
529 | |
|
530 | 0 | sf->tx_sf.tx_type_search.winner_mode_tx_type_pruning = 3; |
531 | 0 | sf->tx_sf.tx_type_search.prune_tx_type_est_rd = 0; |
532 | 0 | sf->tx_sf.prune_intra_tx_depths_using_nn = true; |
533 | |
|
534 | 0 | sf->rd_sf.perform_coeff_opt = 6; |
535 | 0 | sf->rd_sf.tx_domain_dist_level = 3; |
536 | |
|
537 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL4; |
538 | 0 | sf->lpf_sf.lpf_pick = LPF_PICK_FROM_Q; |
539 | |
|
540 | 0 | sf->winner_mode_sf.multi_winner_mode_type = MULTI_WINNER_MODE_OFF; |
541 | 0 | sf->winner_mode_sf.prune_winner_mode_eval_level = 1; |
542 | 0 | sf->winner_mode_sf.dc_blk_pred_level = 1; |
543 | 0 | } |
544 | | // The following should make all-intra mode speed 7 approximately equal |
545 | | // to real-time speed 6, |
546 | | // all-intra speed 8 close to real-time speed 7, and all-intra speed 9 |
547 | | // close to real-time speed 8 |
548 | 0 | if (speed >= 7) { |
549 | 0 | sf->part_sf.default_min_partition_size = BLOCK_8X8; |
550 | 0 | sf->part_sf.partition_search_type = VAR_BASED_PARTITION; |
551 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_PICK_FROM_Q; |
552 | 0 | sf->rt_sf.mode_search_skip_flags |= FLAG_SKIP_INTRA_DIRMISMATCH; |
553 | 0 | sf->rt_sf.var_part_split_threshold_shift = 7; |
554 | 0 | } |
555 | |
|
556 | 0 | if (speed >= 8) { |
557 | 0 | sf->rt_sf.hybrid_intra_pickmode = 1; |
558 | 0 | sf->rt_sf.use_nonrd_pick_mode = 1; |
559 | 0 | sf->rt_sf.nonrd_check_partition_merge_mode = 1; |
560 | 0 | sf->rt_sf.var_part_split_threshold_shift = 8; |
561 | | // Set mask for intra modes. |
562 | 0 | for (int i = 0; i < BLOCK_SIZES; ++i) |
563 | 0 | if (i >= BLOCK_32X32) |
564 | 0 | sf->rt_sf.intra_y_mode_bsize_mask_nrd[i] = INTRA_DC; |
565 | 0 | else |
566 | | // Use DC, H, V intra mode for block sizes < 32X32. |
567 | 0 | sf->rt_sf.intra_y_mode_bsize_mask_nrd[i] = INTRA_DC_H_V; |
568 | 0 | } |
569 | |
|
570 | 0 | if (speed >= 9) { |
571 | 0 | sf->inter_sf.coeff_cost_upd_level = INTERNAL_COST_UPD_SBROW; |
572 | 0 | sf->inter_sf.mode_cost_upd_level = INTERNAL_COST_UPD_SBROW; |
573 | |
|
574 | 0 | sf->rt_sf.nonrd_check_partition_merge_mode = 0; |
575 | 0 | sf->rt_sf.hybrid_intra_pickmode = 0; |
576 | 0 | sf->rt_sf.var_part_split_threshold_shift = 9; |
577 | 0 | sf->rt_sf.vbp_prune_16x16_split_using_min_max_sub_blk_var = true; |
578 | 0 | sf->rt_sf.prune_h_pred_using_best_mode_so_far = true; |
579 | 0 | sf->rt_sf.enable_intra_mode_pruning_using_neighbors = true; |
580 | 0 | sf->rt_sf.prune_intra_mode_using_best_sad_so_far = true; |
581 | 0 | } |
582 | | |
583 | | // As the speed feature prune_chroma_modes_using_luma_winner already |
584 | | // constrains the number of chroma directional mode evaluations to a maximum |
585 | | // of 1, the HOG computation and the associated pruning logic does not seem to |
586 | | // help speed-up the chroma mode evaluations. Hence disable the speed feature |
587 | | // chroma_intra_pruning_with_hog when prune_chroma_modes_using_luma_winner is |
588 | | // enabled. |
589 | 0 | if (sf->intra_sf.prune_chroma_modes_using_luma_winner) |
590 | 0 | sf->intra_sf.chroma_intra_pruning_with_hog = 0; |
591 | 0 | } |
592 | | |
593 | | static void set_good_speed_feature_framesize_dependent( |
594 | 0 | const AV1_COMP *const cpi, SPEED_FEATURES *const sf, int speed) { |
595 | 0 | const AV1_COMMON *const cm = &cpi->common; |
596 | 0 | const int is_480p_or_lesser = AOMMIN(cm->width, cm->height) <= 480; |
597 | 0 | const int is_480p_or_larger = AOMMIN(cm->width, cm->height) >= 480; |
598 | 0 | const int is_720p_or_larger = AOMMIN(cm->width, cm->height) >= 720; |
599 | 0 | const int is_1080p_or_larger = AOMMIN(cm->width, cm->height) >= 1080; |
600 | 0 | const int is_4k_or_larger = AOMMIN(cm->width, cm->height) >= 2160; |
601 | 0 | const bool use_hbd = cpi->oxcf.use_highbitdepth; |
602 | | // Speed features applicable for temporal filtering and tpl modules may be |
603 | | // changed based on frame type at places where the sf is applied (Example : |
604 | | // use_downsampled_sad). This is because temporal filtering and tpl modules |
605 | | // are called before this function (except for the first key frame). |
606 | | // TODO(deepa.kg@ittiam.com): For the speed features applicable to temporal |
607 | | // filtering and tpl modules, modify the sf initialization appropriately |
608 | | // before calling the modules. |
609 | 0 | const int boosted = frame_is_boosted(cpi); |
610 | 0 | const int is_boosted_arf2_bwd_type = |
611 | 0 | boosted || |
612 | 0 | cpi->ppi->gf_group.update_type[cpi->gf_frame_index] == INTNL_ARF_UPDATE; |
613 | 0 | const int is_lf_frame = |
614 | 0 | cpi->ppi->gf_group.update_type[cpi->gf_frame_index] == LF_UPDATE; |
615 | 0 | const int allow_screen_content_tools = |
616 | 0 | cm->features.allow_screen_content_tools; |
617 | |
|
618 | 0 | if (is_480p_or_larger) { |
619 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_128X128; |
620 | 0 | if (is_720p_or_larger) |
621 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = ADAPT_PRED; |
622 | 0 | else |
623 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = RELAXED_PRED; |
624 | 0 | } else { |
625 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_64X64; |
626 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = DIRECT_PRED; |
627 | 0 | if (use_hbd) sf->tx_sf.prune_tx_size_level = 1; |
628 | 0 | } |
629 | |
|
630 | 0 | if (is_4k_or_larger) { |
631 | 0 | sf->part_sf.default_min_partition_size = BLOCK_8X8; |
632 | 0 | } |
633 | | |
634 | | // TODO(huisu@google.com): train models for 720P and above. |
635 | 0 | if (!is_720p_or_larger) { |
636 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[0] = 200; // BLOCK_8X8 |
637 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[1] = 250; // BLOCK_16X16 |
638 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[2] = 300; // BLOCK_32X32 |
639 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[3] = 500; // BLOCK_64X64 |
640 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[4] = -1; // BLOCK_128X128 |
641 | 0 | sf->part_sf.ml_early_term_after_part_split_level = 1; |
642 | 0 | } |
643 | |
|
644 | 0 | if (is_720p_or_larger) { |
645 | | // TODO(chiyotsai@google.com): make this speed feature adaptive based on |
646 | | // current block's vertical texture instead of hardcoded with resolution |
647 | 0 | sf->mv_sf.use_downsampled_sad = 2; |
648 | 0 | } |
649 | |
|
650 | 0 | if (!is_720p_or_larger) { |
651 | 0 | const RateControlCfg *const rc_cfg = &cpi->oxcf.rc_cfg; |
652 | 0 | const int rate_tolerance = |
653 | 0 | AOMMIN(rc_cfg->under_shoot_pct, rc_cfg->over_shoot_pct); |
654 | 0 | sf->hl_sf.recode_tolerance = 25 + (rate_tolerance >> 2); |
655 | 0 | } |
656 | |
|
657 | 0 | if (speed >= 1) { |
658 | 0 | if (is_480p_or_lesser) sf->inter_sf.skip_newmv_in_drl = 1; |
659 | |
|
660 | 0 | if (is_720p_or_larger) { |
661 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_128X128; |
662 | 0 | } else if (is_480p_or_larger) { |
663 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_64X64; |
664 | 0 | } else { |
665 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_32X32; |
666 | 0 | } |
667 | |
|
668 | 0 | if (!is_720p_or_larger) { |
669 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[0] = 200; // BLOCK_8X8 |
670 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[1] = 250; // BLOCK_16X16 |
671 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[2] = 300; // BLOCK_32X32 |
672 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[3] = 300; // BLOCK_64X64 |
673 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[4] = -1; // BLOCK_128X128 |
674 | 0 | } |
675 | 0 | sf->part_sf.ml_early_term_after_part_split_level = 2; |
676 | |
|
677 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL1; |
678 | 0 | } |
679 | |
|
680 | 0 | if (speed >= 2) { |
681 | 0 | if (is_720p_or_larger) { |
682 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_64X64; |
683 | 0 | } else if (is_480p_or_larger) { |
684 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_32X32; |
685 | 0 | } else { |
686 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_32X32; |
687 | 0 | } |
688 | |
|
689 | 0 | if (is_720p_or_larger) { |
690 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 24); |
691 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 120; |
692 | 0 | } else { |
693 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 22); |
694 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 100; |
695 | 0 | } |
696 | |
|
697 | 0 | if (is_720p_or_larger) { |
698 | 0 | sf->inter_sf.prune_obmc_prob_thresh = 16; |
699 | 0 | } else { |
700 | 0 | sf->inter_sf.prune_obmc_prob_thresh = 8; |
701 | 0 | } |
702 | |
|
703 | 0 | if (is_480p_or_larger) { |
704 | 0 | sf->inter_sf.disable_interintra_wedge_var_thresh = 100; |
705 | 0 | } else { |
706 | 0 | sf->inter_sf.disable_interintra_wedge_var_thresh = UINT_MAX; |
707 | 0 | } |
708 | |
|
709 | 0 | if (is_480p_or_lesser) sf->inter_sf.skip_ext_comp_nearmv_mode = 1; |
710 | |
|
711 | 0 | if (is_720p_or_larger) { |
712 | 0 | sf->inter_sf.limit_inter_mode_cands = is_lf_frame ? 1 : 0; |
713 | 0 | } else { |
714 | 0 | sf->inter_sf.limit_inter_mode_cands = is_lf_frame ? 2 : 0; |
715 | 0 | } |
716 | |
|
717 | 0 | if (is_480p_or_larger) { |
718 | 0 | sf->tx_sf.tx_type_search.prune_tx_type_using_stats = 1; |
719 | 0 | if (use_hbd) sf->tx_sf.prune_tx_size_level = 2; |
720 | 0 | } else { |
721 | 0 | if (use_hbd) sf->tx_sf.prune_tx_size_level = 3; |
722 | 0 | sf->tx_sf.tx_type_search.winner_mode_tx_type_pruning = boosted ? 0 : 1; |
723 | 0 | sf->winner_mode_sf.enable_winner_mode_for_tx_size_srch = boosted ? 0 : 1; |
724 | 0 | } |
725 | |
|
726 | 0 | if (!is_720p_or_larger) { |
727 | 0 | sf->mv_sf.disable_second_mv = 1; |
728 | 0 | sf->mv_sf.auto_mv_step_size = 2; |
729 | 0 | } else { |
730 | 0 | sf->mv_sf.disable_second_mv = boosted ? 0 : 2; |
731 | 0 | sf->mv_sf.auto_mv_step_size = 1; |
732 | 0 | } |
733 | |
|
734 | 0 | if (!is_720p_or_larger) { |
735 | 0 | sf->hl_sf.recode_tolerance = 50; |
736 | 0 | sf->inter_sf.disable_interinter_wedge_newmv_search = |
737 | 0 | is_boosted_arf2_bwd_type ? 0 : 1; |
738 | 0 | sf->inter_sf.enable_fast_wedge_mask_search = 1; |
739 | 0 | } |
740 | 0 | } |
741 | |
|
742 | 0 | if (speed >= 3) { |
743 | 0 | sf->inter_sf.enable_fast_wedge_mask_search = 1; |
744 | 0 | sf->inter_sf.skip_newmv_in_drl = 2; |
745 | 0 | sf->inter_sf.skip_ext_comp_nearmv_mode = 1; |
746 | 0 | sf->inter_sf.limit_inter_mode_cands = is_lf_frame ? 3 : 0; |
747 | 0 | sf->inter_sf.disable_interinter_wedge_newmv_search = boosted ? 0 : 1; |
748 | 0 | sf->tx_sf.tx_type_search.winner_mode_tx_type_pruning = 1; |
749 | 0 | sf->winner_mode_sf.enable_winner_mode_for_tx_size_srch = |
750 | 0 | frame_is_intra_only(&cpi->common) ? 0 : 1; |
751 | |
|
752 | 0 | sf->part_sf.ml_early_term_after_part_split_level = 0; |
753 | |
|
754 | 0 | if (is_720p_or_larger) { |
755 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 25); |
756 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 200; |
757 | 0 | sf->part_sf.skip_non_sq_part_based_on_none = is_lf_frame ? 2 : 0; |
758 | 0 | } else { |
759 | 0 | sf->part_sf.max_intra_bsize = BLOCK_32X32; |
760 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 23); |
761 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 120; |
762 | 0 | sf->part_sf.skip_non_sq_part_based_on_none = is_lf_frame ? 1 : 0; |
763 | 0 | } |
764 | 0 | if (use_hbd) sf->tx_sf.prune_tx_size_level = 3; |
765 | |
|
766 | 0 | if (is_480p_or_larger) { |
767 | 0 | sf->part_sf.early_term_after_none_split = 1; |
768 | 0 | } else { |
769 | 0 | sf->part_sf.early_term_after_none_split = 0; |
770 | 0 | } |
771 | 0 | if (is_720p_or_larger) { |
772 | 0 | sf->intra_sf.skip_intra_in_interframe = boosted ? 1 : 2; |
773 | 0 | } else { |
774 | 0 | sf->intra_sf.skip_intra_in_interframe = boosted ? 1 : 3; |
775 | 0 | } |
776 | |
|
777 | 0 | if (is_720p_or_larger) { |
778 | 0 | sf->inter_sf.disable_interinter_wedge_var_thresh = 100; |
779 | 0 | sf->inter_sf.limit_txfm_eval_per_mode = boosted ? 0 : 1; |
780 | 0 | } else { |
781 | 0 | sf->inter_sf.disable_interinter_wedge_var_thresh = UINT_MAX; |
782 | 0 | sf->inter_sf.limit_txfm_eval_per_mode = boosted ? 0 : 2; |
783 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL2; |
784 | 0 | } |
785 | |
|
786 | 0 | sf->inter_sf.disable_interintra_wedge_var_thresh = UINT_MAX; |
787 | 0 | } |
788 | |
|
789 | 0 | if (speed >= 4) { |
790 | 0 | sf->tx_sf.tx_type_search.winner_mode_tx_type_pruning = 2; |
791 | 0 | sf->winner_mode_sf.enable_winner_mode_for_tx_size_srch = 1; |
792 | 0 | if (is_720p_or_larger) { |
793 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 26); |
794 | 0 | } else { |
795 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 24); |
796 | 0 | } |
797 | 0 | sf->part_sf.early_term_after_none_split = 1; |
798 | |
|
799 | 0 | if (is_480p_or_larger) { |
800 | 0 | sf->tx_sf.tx_type_search.prune_tx_type_using_stats = 2; |
801 | 0 | } else { |
802 | 0 | sf->mv_sf.skip_fullpel_search_using_startmv = boosted ? 0 : 1; |
803 | 0 | } |
804 | |
|
805 | 0 | sf->inter_sf.disable_interinter_wedge_var_thresh = UINT_MAX; |
806 | 0 | sf->inter_sf.prune_obmc_prob_thresh = INT_MAX; |
807 | 0 | sf->inter_sf.limit_txfm_eval_per_mode = boosted ? 0 : 2; |
808 | 0 | if (is_480p_or_lesser) sf->inter_sf.skip_newmv_in_drl = 3; |
809 | |
|
810 | 0 | if (is_720p_or_larger) { |
811 | 0 | sf->inter_sf.prune_comp_ref_frames = 1; |
812 | 0 | } else if (is_480p_or_larger) { |
813 | 0 | sf->inter_sf.prune_comp_ref_frames = is_boosted_arf2_bwd_type ? 0 : 1; |
814 | 0 | } |
815 | |
|
816 | 0 | if (is_720p_or_larger) |
817 | 0 | sf->hl_sf.recode_tolerance = 32; |
818 | 0 | else |
819 | 0 | sf->hl_sf.recode_tolerance = 55; |
820 | |
|
821 | 0 | sf->intra_sf.skip_intra_in_interframe = 4; |
822 | |
|
823 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL3; |
824 | 0 | } |
825 | |
|
826 | 0 | if (speed >= 5) { |
827 | 0 | if (is_720p_or_larger) { |
828 | 0 | sf->inter_sf.prune_warped_prob_thresh = 16; |
829 | 0 | } else if (is_480p_or_larger) { |
830 | 0 | sf->inter_sf.prune_warped_prob_thresh = 8; |
831 | 0 | } |
832 | 0 | if (is_720p_or_larger) sf->hl_sf.recode_tolerance = 40; |
833 | |
|
834 | 0 | sf->inter_sf.skip_newmv_in_drl = 4; |
835 | 0 | sf->inter_sf.prune_comp_ref_frames = 1; |
836 | 0 | sf->mv_sf.skip_fullpel_search_using_startmv = boosted ? 0 : 1; |
837 | |
|
838 | 0 | if (!is_720p_or_larger) { |
839 | 0 | sf->inter_sf.mv_cost_upd_level = INTERNAL_COST_UPD_SBROW_SET; |
840 | 0 | sf->inter_sf.prune_nearest_near_mv_using_refmv_weight = |
841 | 0 | (boosted || allow_screen_content_tools) ? 0 : 1; |
842 | 0 | sf->mv_sf.use_downsampled_sad = 1; |
843 | 0 | } |
844 | |
|
845 | 0 | if (!is_480p_or_larger) { |
846 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 26); |
847 | 0 | } |
848 | |
|
849 | 0 | if (is_480p_or_lesser) { |
850 | 0 | sf->inter_sf.prune_nearmv_using_neighbors = PRUNE_NEARMV_LEVEL1; |
851 | 0 | } else { |
852 | 0 | sf->inter_sf.prune_nearmv_using_neighbors = PRUNE_NEARMV_LEVEL2; |
853 | 0 | } |
854 | |
|
855 | 0 | if (is_720p_or_larger) |
856 | 0 | sf->part_sf.ext_part_eval_based_on_cur_best = |
857 | 0 | (allow_screen_content_tools || frame_is_intra_only(cm)) ? 0 : 1; |
858 | |
|
859 | 0 | if (is_480p_or_larger) { |
860 | 0 | sf->tpl_sf.reduce_num_frames = 1; |
861 | 0 | } |
862 | 0 | } |
863 | |
|
864 | 0 | if (speed >= 6) { |
865 | 0 | sf->tx_sf.tx_type_search.winner_mode_tx_type_pruning = 4; |
866 | 0 | sf->inter_sf.prune_nearmv_using_neighbors = PRUNE_NEARMV_LEVEL3; |
867 | 0 | sf->inter_sf.prune_comp_ref_frames = 2; |
868 | 0 | sf->inter_sf.prune_nearest_near_mv_using_refmv_weight = |
869 | 0 | (boosted || allow_screen_content_tools) ? 0 : 1; |
870 | 0 | sf->mv_sf.skip_fullpel_search_using_startmv = boosted ? 0 : 2; |
871 | |
|
872 | 0 | if (is_720p_or_larger) { |
873 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = NOT_IN_USE; |
874 | 0 | } else if (is_480p_or_larger) { |
875 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = DIRECT_PRED; |
876 | 0 | } |
877 | |
|
878 | 0 | if (is_480p_or_larger) { |
879 | 0 | sf->hl_sf.allow_sub_blk_me_in_tf = 1; |
880 | 0 | } |
881 | |
|
882 | 0 | if (is_1080p_or_larger) { |
883 | 0 | sf->part_sf.default_min_partition_size = BLOCK_8X8; |
884 | 0 | } |
885 | |
|
886 | 0 | if (is_720p_or_larger) { |
887 | 0 | sf->inter_sf.disable_masked_comp = 1; |
888 | 0 | } |
889 | |
|
890 | 0 | if (!is_720p_or_larger) { |
891 | 0 | sf->inter_sf.coeff_cost_upd_level = INTERNAL_COST_UPD_SBROW; |
892 | 0 | sf->inter_sf.mode_cost_upd_level = INTERNAL_COST_UPD_SBROW; |
893 | 0 | } |
894 | |
|
895 | 0 | if (is_720p_or_larger) { |
896 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_32X32; |
897 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 28); |
898 | 0 | } else { |
899 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_16X16; |
900 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 26); |
901 | 0 | } |
902 | |
|
903 | 0 | if (is_720p_or_larger) { |
904 | 0 | sf->inter_sf.prune_ref_mv_idx_search = 2; |
905 | 0 | } else { |
906 | 0 | sf->inter_sf.prune_ref_mv_idx_search = 1; |
907 | 0 | } |
908 | |
|
909 | 0 | if (!is_720p_or_larger) { |
910 | 0 | sf->tx_sf.tx_type_search.fast_inter_tx_type_prob_thresh = |
911 | 0 | is_boosted_arf2_bwd_type ? 450 : 150; |
912 | 0 | } |
913 | |
|
914 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL4; |
915 | |
|
916 | 0 | sf->hl_sf.recode_tolerance = 55; |
917 | 0 | } |
918 | 0 | } |
919 | | |
920 | | static void set_good_speed_features_framesize_independent( |
921 | 0 | const AV1_COMP *const cpi, SPEED_FEATURES *const sf, int speed) { |
922 | 0 | const AV1_COMMON *const cm = &cpi->common; |
923 | 0 | const GF_GROUP *const gf_group = &cpi->ppi->gf_group; |
924 | 0 | const int boosted = frame_is_boosted(cpi); |
925 | 0 | const int is_boosted_arf2_bwd_type = |
926 | 0 | boosted || gf_group->update_type[cpi->gf_frame_index] == INTNL_ARF_UPDATE; |
927 | 0 | const int is_inter_frame = |
928 | 0 | gf_group->frame_type[cpi->gf_frame_index] == INTER_FRAME; |
929 | 0 | const int allow_screen_content_tools = |
930 | 0 | cm->features.allow_screen_content_tools; |
931 | 0 | const int use_hbd = cpi->oxcf.use_highbitdepth; |
932 | 0 | if (!cpi->oxcf.tile_cfg.enable_large_scale_tile) { |
933 | 0 | sf->hl_sf.high_precision_mv_usage = LAST_MV_DATA; |
934 | 0 | } |
935 | | |
936 | | // Speed 0 for all speed features that give neutral coding performance change. |
937 | 0 | sf->gm_sf.gm_search_type = boosted ? GM_REDUCED_REF_SEARCH_SKIP_L2_L3_ARF2 |
938 | 0 | : GM_SEARCH_CLOSEST_REFS_ONLY; |
939 | 0 | sf->gm_sf.prune_ref_frame_for_gm_search = boosted ? 0 : 1; |
940 | 0 | sf->gm_sf.disable_gm_search_based_on_stats = 1; |
941 | |
|
942 | 0 | sf->part_sf.less_rectangular_check_level = 1; |
943 | 0 | sf->part_sf.ml_prune_partition = 1; |
944 | 0 | sf->part_sf.prune_ext_partition_types_search_level = 1; |
945 | 0 | sf->part_sf.prune_part4_search = 2; |
946 | 0 | sf->part_sf.simple_motion_search_prune_rect = 1; |
947 | 0 | sf->part_sf.ml_predict_breakout_level = use_hbd ? 1 : 3; |
948 | 0 | sf->part_sf.reuse_prev_rd_results_for_part_ab = 1; |
949 | 0 | sf->part_sf.use_best_rd_for_pruning = 1; |
950 | 0 | sf->part_sf.simple_motion_search_prune_agg = |
951 | 0 | allow_screen_content_tools ? NO_PRUNING : SIMPLE_AGG_LVL0; |
952 | | |
953 | | // TODO(debargha): Test, tweak and turn on either 1 or 2 |
954 | 0 | sf->inter_sf.inter_mode_rd_model_estimation = 1; |
955 | 0 | sf->inter_sf.model_based_post_interp_filter_breakout = 1; |
956 | 0 | sf->inter_sf.prune_compound_using_single_ref = 1; |
957 | 0 | sf->inter_sf.prune_mode_search_simple_translation = 1; |
958 | 0 | sf->inter_sf.prune_ref_frame_for_rect_partitions = |
959 | 0 | (boosted || (allow_screen_content_tools)) |
960 | 0 | ? 0 |
961 | 0 | : (is_boosted_arf2_bwd_type ? 1 : 2); |
962 | 0 | sf->inter_sf.reduce_inter_modes = boosted ? 1 : 2; |
963 | 0 | sf->inter_sf.selective_ref_frame = 1; |
964 | 0 | sf->inter_sf.use_dist_wtd_comp_flag = DIST_WTD_COMP_SKIP_MV_SEARCH; |
965 | |
|
966 | 0 | sf->interp_sf.use_fast_interpolation_filter_search = 1; |
967 | |
|
968 | 0 | sf->intra_sf.intra_pruning_with_hog = 1; |
969 | |
|
970 | 0 | sf->tx_sf.adaptive_txb_search_level = 1; |
971 | 0 | sf->tx_sf.intra_tx_size_search_init_depth_sqr = 1; |
972 | 0 | sf->tx_sf.model_based_prune_tx_search_level = 1; |
973 | 0 | sf->tx_sf.tx_type_search.use_reduced_intra_txset = 1; |
974 | |
|
975 | 0 | sf->tpl_sf.search_method = NSTEP_8PT; |
976 | |
|
977 | 0 | sf->rt_sf.use_nonrd_pick_mode = 0; |
978 | 0 | sf->rt_sf.use_real_time_ref_set = 0; |
979 | |
|
980 | 0 | if (cpi->twopass_frame.fr_content_type == FC_GRAPHICS_ANIMATION || |
981 | 0 | cpi->use_screen_content_tools) { |
982 | 0 | sf->mv_sf.exhaustive_searches_thresh = (1 << 20); |
983 | 0 | } else { |
984 | 0 | sf->mv_sf.exhaustive_searches_thresh = (1 << 25); |
985 | 0 | } |
986 | |
|
987 | 0 | sf->rd_sf.perform_coeff_opt = 1; |
988 | 0 | sf->hl_sf.superres_auto_search_type = SUPERRES_AUTO_DUAL; |
989 | |
|
990 | 0 | if (speed >= 1) { |
991 | 0 | sf->hl_sf.adjust_num_frames_for_arf_filtering = |
992 | 0 | allow_screen_content_tools ? 0 : 1; |
993 | |
|
994 | 0 | sf->part_sf.intra_cnn_based_part_prune_level = |
995 | 0 | allow_screen_content_tools ? 0 : 2; |
996 | 0 | sf->part_sf.simple_motion_search_early_term_none = 1; |
997 | | // TODO(Venkat): Clean-up frame type dependency for |
998 | | // simple_motion_search_split in partition search function and set the |
999 | | // speed feature accordingly |
1000 | 0 | sf->part_sf.simple_motion_search_split = allow_screen_content_tools ? 1 : 2; |
1001 | 0 | sf->part_sf.ml_predict_breakout_level = use_hbd ? 2 : 3; |
1002 | |
|
1003 | 0 | sf->mv_sf.exhaustive_searches_thresh <<= 1; |
1004 | 0 | sf->mv_sf.obmc_full_pixel_search_level = 1; |
1005 | 0 | sf->mv_sf.use_accurate_subpel_search = USE_4_TAPS; |
1006 | 0 | sf->mv_sf.disable_extensive_joint_motion_search = 1; |
1007 | |
|
1008 | 0 | sf->inter_sf.prune_comp_search_by_single_result = boosted ? 2 : 1; |
1009 | 0 | sf->inter_sf.prune_comp_type_by_comp_avg = 1; |
1010 | 0 | sf->inter_sf.prune_comp_type_by_model_rd = boosted ? 0 : 1; |
1011 | 0 | sf->inter_sf.prune_ref_frame_for_rect_partitions = |
1012 | 0 | (frame_is_intra_only(&cpi->common) || (allow_screen_content_tools)) |
1013 | 0 | ? 0 |
1014 | 0 | : (boosted ? 1 : 2); |
1015 | 0 | sf->inter_sf.reduce_inter_modes = boosted ? 1 : 3; |
1016 | 0 | sf->inter_sf.reuse_inter_intra_mode = 1; |
1017 | 0 | sf->inter_sf.selective_ref_frame = 2; |
1018 | 0 | sf->inter_sf.skip_arf_compound = 1; |
1019 | |
|
1020 | 0 | sf->interp_sf.use_interp_filter = 1; |
1021 | |
|
1022 | 0 | sf->intra_sf.prune_palette_search_level = 1; |
1023 | |
|
1024 | 0 | sf->tx_sf.adaptive_txb_search_level = 2; |
1025 | 0 | sf->tx_sf.inter_tx_size_search_init_depth_rect = 1; |
1026 | 0 | sf->tx_sf.inter_tx_size_search_init_depth_sqr = 1; |
1027 | 0 | sf->tx_sf.intra_tx_size_search_init_depth_rect = 1; |
1028 | 0 | sf->tx_sf.model_based_prune_tx_search_level = 0; |
1029 | 0 | sf->tx_sf.tx_type_search.ml_tx_split_thresh = 4000; |
1030 | 0 | sf->tx_sf.tx_type_search.prune_2d_txfm_mode = TX_TYPE_PRUNE_2; |
1031 | 0 | sf->tx_sf.tx_type_search.skip_tx_search = 1; |
1032 | |
|
1033 | 0 | sf->rd_sf.perform_coeff_opt = boosted ? 2 : 3; |
1034 | 0 | sf->rd_sf.tx_domain_dist_level = boosted ? 1 : 2; |
1035 | 0 | sf->rd_sf.tx_domain_dist_thres_level = 1; |
1036 | |
|
1037 | 0 | sf->lpf_sf.dual_sgr_penalty_level = 1; |
1038 | 0 | sf->lpf_sf.enable_sgr_ep_pruning = 1; |
1039 | | |
1040 | | // TODO(any, yunqing): move this feature to speed 0. |
1041 | 0 | sf->tpl_sf.skip_alike_starting_mv = 1; |
1042 | 0 | } |
1043 | |
|
1044 | 0 | if (speed >= 2) { |
1045 | 0 | sf->hl_sf.recode_loop = ALLOW_RECODE_KFARFGF; |
1046 | |
|
1047 | 0 | sf->fp_sf.skip_motion_search_threshold = 25; |
1048 | |
|
1049 | 0 | sf->gm_sf.num_refinement_steps = 2; |
1050 | |
|
1051 | 0 | sf->part_sf.reuse_best_prediction_for_part_ab = |
1052 | 0 | !frame_is_intra_only(&cpi->common); |
1053 | |
|
1054 | 0 | sf->mv_sf.simple_motion_subpel_force_stop = QUARTER_PEL; |
1055 | 0 | sf->mv_sf.subpel_iters_per_step = 1; |
1056 | 0 | sf->mv_sf.reduce_search_range = 1; |
1057 | | |
1058 | | // TODO(chiyotsai@google.com): We can get 10% speed up if we move |
1059 | | // adaptive_rd_thresh to speed 1. But currently it performs poorly on some |
1060 | | // clips (e.g. 5% loss on dinner_1080p). We need to examine the sequence a |
1061 | | // bit more closely to figure out why. |
1062 | 0 | sf->inter_sf.adaptive_rd_thresh = 1; |
1063 | 0 | sf->inter_sf.disable_interinter_wedge_var_thresh = 100; |
1064 | 0 | sf->inter_sf.fast_interintra_wedge_search = 1; |
1065 | 0 | sf->inter_sf.prune_comp_search_by_single_result = boosted ? 4 : 1; |
1066 | 0 | sf->inter_sf.prune_ext_comp_using_neighbors = 1; |
1067 | 0 | sf->inter_sf.prune_comp_using_best_single_mode_ref = 2; |
1068 | 0 | sf->inter_sf.prune_comp_type_by_comp_avg = 2; |
1069 | 0 | sf->inter_sf.selective_ref_frame = 3; |
1070 | 0 | sf->inter_sf.use_dist_wtd_comp_flag = DIST_WTD_COMP_DISABLED; |
1071 | 0 | sf->inter_sf.enable_fast_compound_mode_search = 1; |
1072 | 0 | sf->inter_sf.reuse_mask_search_results = 1; |
1073 | 0 | set_txfm_rd_gate_level(sf->inter_sf.txfm_rd_gate_level, boosted ? 0 : 1); |
1074 | 0 | sf->inter_sf.inter_mode_txfm_breakout = boosted ? 0 : 1; |
1075 | 0 | sf->inter_sf.alt_ref_search_fp = 1; |
1076 | |
|
1077 | 0 | sf->interp_sf.adaptive_interp_filter_search = 1; |
1078 | 0 | sf->interp_sf.disable_dual_filter = 1; |
1079 | |
|
1080 | 0 | sf->intra_sf.disable_smooth_intra = |
1081 | 0 | !frame_is_intra_only(&cpi->common) || (cpi->rc.frames_to_key > 1); |
1082 | 0 | sf->intra_sf.intra_pruning_with_hog = 2; |
1083 | 0 | sf->intra_sf.skip_intra_in_interframe = is_inter_frame ? 2 : 1; |
1084 | 0 | sf->intra_sf.skip_filter_intra_in_inter_frames = 1; |
1085 | |
|
1086 | 0 | sf->tpl_sf.prune_starting_mv = 1; |
1087 | 0 | sf->tpl_sf.search_method = DIAMOND; |
1088 | |
|
1089 | 0 | sf->rd_sf.perform_coeff_opt = is_boosted_arf2_bwd_type ? 3 : 4; |
1090 | 0 | sf->rd_sf.use_mb_rd_hash = 1; |
1091 | |
|
1092 | 0 | sf->lpf_sf.prune_wiener_based_on_src_var = 1; |
1093 | 0 | sf->lpf_sf.prune_sgr_based_on_wiener = 1; |
1094 | 0 | sf->lpf_sf.disable_loop_restoration_chroma = boosted ? 0 : 1; |
1095 | 0 | sf->lpf_sf.reduce_wiener_window_size = boosted ? 0 : 1; |
1096 | | |
1097 | | // TODO(any): Re-evaluate this feature set to 1 in speed 2. |
1098 | 0 | sf->tpl_sf.allow_compound_pred = 0; |
1099 | 0 | sf->tpl_sf.prune_ref_frames_in_tpl = 1; |
1100 | 0 | } |
1101 | |
|
1102 | 0 | if (speed >= 3) { |
1103 | 0 | sf->hl_sf.high_precision_mv_usage = CURRENT_Q; |
1104 | |
|
1105 | 0 | sf->gm_sf.prune_ref_frame_for_gm_search = 1; |
1106 | 0 | sf->gm_sf.prune_zero_mv_with_sse = 1; |
1107 | 0 | sf->gm_sf.num_refinement_steps = 0; |
1108 | |
|
1109 | 0 | sf->part_sf.less_rectangular_check_level = 2; |
1110 | 0 | sf->part_sf.simple_motion_search_prune_agg = |
1111 | 0 | allow_screen_content_tools |
1112 | 0 | ? SIMPLE_AGG_LVL0 |
1113 | 0 | : (boosted ? SIMPLE_AGG_LVL1 : QIDX_BASED_AGG_LVL1); |
1114 | 0 | sf->part_sf.prune_ext_part_using_split_info = 1; |
1115 | 0 | sf->part_sf.simple_motion_search_rect_split = 1; |
1116 | |
|
1117 | 0 | sf->mv_sf.full_pixel_search_level = 1; |
1118 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED; |
1119 | 0 | sf->mv_sf.search_method = DIAMOND; |
1120 | 0 | sf->mv_sf.disable_second_mv = 2; |
1121 | 0 | sf->mv_sf.prune_mesh_search = PRUNE_MESH_SEARCH_LVL_1; |
1122 | 0 | sf->mv_sf.use_intrabc = 0; |
1123 | |
|
1124 | 0 | sf->inter_sf.disable_interinter_wedge_newmv_search = boosted ? 0 : 1; |
1125 | 0 | sf->inter_sf.mv_cost_upd_level = INTERNAL_COST_UPD_SBROW; |
1126 | 0 | sf->inter_sf.disable_onesided_comp = 1; |
1127 | 0 | sf->inter_sf.disable_interintra_wedge_var_thresh = UINT_MAX; |
1128 | | // TODO(any): Experiment with the early exit mechanism for speeds 0, 1 and 2 |
1129 | | // and clean-up the speed feature |
1130 | 0 | sf->inter_sf.perform_best_rd_based_gating_for_chroma = 1; |
1131 | 0 | sf->inter_sf.prune_inter_modes_based_on_tpl = boosted ? 0 : 1; |
1132 | 0 | sf->inter_sf.prune_comp_search_by_single_result = boosted ? 4 : 2; |
1133 | 0 | sf->inter_sf.selective_ref_frame = 5; |
1134 | 0 | sf->inter_sf.reuse_compound_type_decision = 1; |
1135 | 0 | set_txfm_rd_gate_level(sf->inter_sf.txfm_rd_gate_level, |
1136 | 0 | boosted ? 0 : (is_boosted_arf2_bwd_type ? 1 : 2)); |
1137 | 0 | sf->inter_sf.inter_mode_txfm_breakout = boosted ? 0 : 2; |
1138 | |
|
1139 | 0 | sf->interp_sf.adaptive_interp_filter_search = 2; |
1140 | | |
1141 | | // TODO(chiyotsai@google.com): the thresholds chosen for intra hog are |
1142 | | // inherited directly from luma hog with some minor tweaking. Eventually we |
1143 | | // should run this with a bayesian optimizer to find the Pareto frontier. |
1144 | 0 | sf->intra_sf.chroma_intra_pruning_with_hog = 2; |
1145 | 0 | sf->intra_sf.intra_pruning_with_hog = 3; |
1146 | 0 | sf->intra_sf.prune_palette_search_level = 2; |
1147 | 0 | sf->intra_sf.top_intra_model_count_allowed = 2; |
1148 | |
|
1149 | 0 | sf->tpl_sf.prune_starting_mv = 2; |
1150 | 0 | sf->tpl_sf.skip_alike_starting_mv = 2; |
1151 | 0 | sf->tpl_sf.prune_intra_modes = 1; |
1152 | 0 | sf->tpl_sf.reduce_first_step_size = 6; |
1153 | 0 | sf->tpl_sf.subpel_force_stop = QUARTER_PEL; |
1154 | 0 | sf->tpl_sf.gop_length_decision_method = 1; |
1155 | |
|
1156 | 0 | sf->tx_sf.adaptive_txb_search_level = boosted ? 2 : 3; |
1157 | 0 | sf->tx_sf.tx_type_search.use_skip_flag_prediction = 2; |
1158 | 0 | sf->tx_sf.tx_type_search.prune_2d_txfm_mode = TX_TYPE_PRUNE_3; |
1159 | | |
1160 | | // TODO(any): Refactor the code related to following winner mode speed |
1161 | | // features |
1162 | 0 | sf->winner_mode_sf.enable_winner_mode_for_coeff_opt = 1; |
1163 | 0 | sf->winner_mode_sf.enable_winner_mode_for_use_tx_domain_dist = 1; |
1164 | 0 | sf->winner_mode_sf.motion_mode_for_winner_cand = |
1165 | 0 | boosted ? 0 |
1166 | 0 | : gf_group->update_type[cpi->gf_frame_index] == INTNL_ARF_UPDATE ? 1 |
1167 | 0 | : 2; |
1168 | 0 | sf->winner_mode_sf.prune_winner_mode_eval_level = boosted ? 0 : 4; |
1169 | | |
1170 | | // For screen content, "prune_sgr_based_on_wiener = 2" cause large quality |
1171 | | // loss. |
1172 | 0 | sf->lpf_sf.prune_sgr_based_on_wiener = allow_screen_content_tools ? 1 : 2; |
1173 | 0 | sf->lpf_sf.prune_wiener_based_on_src_var = 2; |
1174 | 0 | sf->lpf_sf.use_coarse_filter_level_search = |
1175 | 0 | frame_is_intra_only(&cpi->common) ? 0 : 1; |
1176 | 0 | sf->lpf_sf.use_downsampled_wiener_stats = 1; |
1177 | 0 | } |
1178 | |
|
1179 | 0 | if (speed >= 4) { |
1180 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE; |
1181 | |
|
1182 | 0 | sf->gm_sf.prune_zero_mv_with_sse = 2; |
1183 | 0 | sf->gm_sf.downsample_level = 1; |
1184 | |
|
1185 | 0 | sf->part_sf.simple_motion_search_prune_agg = |
1186 | 0 | allow_screen_content_tools ? SIMPLE_AGG_LVL0 : SIMPLE_AGG_LVL2; |
1187 | 0 | sf->part_sf.simple_motion_search_reduce_search_steps = 4; |
1188 | 0 | sf->part_sf.prune_ext_part_using_split_info = 2; |
1189 | 0 | sf->part_sf.ml_predict_breakout_level = 3; |
1190 | 0 | sf->part_sf.prune_rectangular_split_based_on_qidx = |
1191 | 0 | (allow_screen_content_tools || frame_is_intra_only(&cpi->common)) ? 0 |
1192 | 0 | : 1; |
1193 | |
|
1194 | 0 | sf->inter_sf.alt_ref_search_fp = 2; |
1195 | 0 | sf->inter_sf.txfm_rd_gate_level[TX_SEARCH_DEFAULT] = boosted ? 0 : 3; |
1196 | 0 | sf->inter_sf.txfm_rd_gate_level[TX_SEARCH_MOTION_MODE] = boosted ? 0 : 5; |
1197 | 0 | sf->inter_sf.txfm_rd_gate_level[TX_SEARCH_COMP_TYPE_MODE] = boosted ? 0 : 3; |
1198 | |
|
1199 | 0 | sf->inter_sf.prune_inter_modes_based_on_tpl = boosted ? 0 : 2; |
1200 | 0 | sf->inter_sf.prune_ext_comp_using_neighbors = 2; |
1201 | 0 | sf->inter_sf.prune_obmc_prob_thresh = INT_MAX; |
1202 | 0 | sf->inter_sf.disable_interinter_wedge_var_thresh = UINT_MAX; |
1203 | |
|
1204 | 0 | sf->interp_sf.cb_pred_filter_search = 1; |
1205 | 0 | sf->interp_sf.skip_sharp_interp_filter_search = 1; |
1206 | 0 | sf->interp_sf.use_interp_filter = 2; |
1207 | |
|
1208 | 0 | sf->intra_sf.intra_uv_mode_mask[TX_16X16] = UV_INTRA_DC_H_V_CFL; |
1209 | 0 | sf->intra_sf.intra_uv_mode_mask[TX_32X32] = UV_INTRA_DC_H_V_CFL; |
1210 | 0 | sf->intra_sf.intra_uv_mode_mask[TX_64X64] = UV_INTRA_DC_H_V_CFL; |
1211 | | // TODO(any): "intra_y_mode_mask" doesn't help much at speed 4. |
1212 | | // sf->intra_sf.intra_y_mode_mask[TX_16X16] = INTRA_DC_H_V; |
1213 | | // sf->intra_sf.intra_y_mode_mask[TX_32X32] = INTRA_DC_H_V; |
1214 | | // sf->intra_sf.intra_y_mode_mask[TX_64X64] = INTRA_DC_H_V; |
1215 | 0 | sf->intra_sf.skip_intra_in_interframe = 4; |
1216 | |
|
1217 | 0 | sf->mv_sf.simple_motion_subpel_force_stop = HALF_PEL; |
1218 | 0 | sf->mv_sf.prune_mesh_search = PRUNE_MESH_SEARCH_LVL_2; |
1219 | |
|
1220 | 0 | sf->tpl_sf.subpel_force_stop = HALF_PEL; |
1221 | 0 | sf->tpl_sf.search_method = FAST_BIGDIA; |
1222 | 0 | sf->tpl_sf.use_sad_for_mode_decision = 1; |
1223 | |
|
1224 | 0 | sf->tx_sf.tx_type_search.fast_intra_tx_type_search = 1; |
1225 | |
|
1226 | 0 | sf->rd_sf.perform_coeff_opt = is_boosted_arf2_bwd_type ? 5 : 7; |
1227 | | |
1228 | | // TODO(any): Extend multi-winner mode processing support for inter frames |
1229 | 0 | sf->winner_mode_sf.multi_winner_mode_type = |
1230 | 0 | frame_is_intra_only(&cpi->common) ? MULTI_WINNER_MODE_DEFAULT |
1231 | 0 | : MULTI_WINNER_MODE_OFF; |
1232 | 0 | sf->winner_mode_sf.dc_blk_pred_level = boosted ? 0 : 2; |
1233 | |
|
1234 | 0 | sf->lpf_sf.lpf_pick = LPF_PICK_FROM_FULL_IMAGE_NON_DUAL; |
1235 | 0 | } |
1236 | |
|
1237 | 0 | if (speed >= 5) { |
1238 | 0 | sf->hl_sf.weight_calc_level_in_tf = 1; |
1239 | 0 | sf->hl_sf.adjust_num_frames_for_arf_filtering = |
1240 | 0 | allow_screen_content_tools ? 0 : 2; |
1241 | |
|
1242 | 0 | sf->fp_sf.reduce_mv_step_param = 4; |
1243 | |
|
1244 | 0 | sf->part_sf.simple_motion_search_prune_agg = |
1245 | 0 | allow_screen_content_tools ? SIMPLE_AGG_LVL0 : SIMPLE_AGG_LVL3; |
1246 | 0 | sf->part_sf.ext_partition_eval_thresh = |
1247 | 0 | allow_screen_content_tools ? BLOCK_8X8 : BLOCK_16X16; |
1248 | 0 | sf->part_sf.prune_sub_8x8_partition_level = |
1249 | 0 | allow_screen_content_tools ? 1 : 2; |
1250 | |
|
1251 | 0 | sf->mv_sf.warp_search_method = WARP_SEARCH_DIAMOND; |
1252 | |
|
1253 | 0 | sf->inter_sf.prune_inter_modes_if_skippable = 1; |
1254 | 0 | sf->inter_sf.prune_single_ref = is_boosted_arf2_bwd_type ? 0 : 1; |
1255 | 0 | sf->inter_sf.txfm_rd_gate_level[TX_SEARCH_DEFAULT] = boosted ? 0 : 4; |
1256 | 0 | sf->inter_sf.txfm_rd_gate_level[TX_SEARCH_COMP_TYPE_MODE] = boosted ? 0 : 5; |
1257 | 0 | sf->inter_sf.enable_fast_compound_mode_search = 2; |
1258 | |
|
1259 | 0 | sf->interp_sf.skip_interp_filter_search = boosted ? 0 : 1; |
1260 | |
|
1261 | 0 | sf->intra_sf.chroma_intra_pruning_with_hog = 3; |
1262 | | |
1263 | | // TODO(any): Extend multi-winner mode processing support for inter frames |
1264 | 0 | sf->winner_mode_sf.multi_winner_mode_type = |
1265 | 0 | frame_is_intra_only(&cpi->common) ? MULTI_WINNER_MODE_FAST |
1266 | 0 | : MULTI_WINNER_MODE_OFF; |
1267 | | |
1268 | | // Disable Self-guided Loop restoration filter. |
1269 | 0 | sf->lpf_sf.disable_sgr_filter = true; |
1270 | 0 | sf->lpf_sf.disable_wiener_coeff_refine_search = true; |
1271 | |
|
1272 | 0 | sf->tpl_sf.prune_starting_mv = 3; |
1273 | 0 | sf->tpl_sf.use_y_only_rate_distortion = 1; |
1274 | 0 | sf->tpl_sf.subpel_force_stop = FULL_PEL; |
1275 | 0 | sf->tpl_sf.gop_length_decision_method = 2; |
1276 | 0 | sf->tpl_sf.use_sad_for_mode_decision = 2; |
1277 | |
|
1278 | 0 | sf->winner_mode_sf.dc_blk_pred_level = 2; |
1279 | |
|
1280 | 0 | sf->fp_sf.disable_recon = 1; |
1281 | 0 | } |
1282 | |
|
1283 | 0 | if (speed >= 6) { |
1284 | 0 | sf->hl_sf.disable_extra_sc_testing = 1; |
1285 | 0 | sf->hl_sf.second_alt_ref_filtering = 0; |
1286 | |
|
1287 | 0 | sf->gm_sf.downsample_level = 2; |
1288 | |
|
1289 | 0 | sf->inter_sf.prune_inter_modes_based_on_tpl = boosted ? 0 : 3; |
1290 | 0 | sf->inter_sf.selective_ref_frame = 6; |
1291 | 0 | sf->inter_sf.prune_single_ref = is_boosted_arf2_bwd_type ? 0 : 2; |
1292 | 0 | sf->inter_sf.prune_ext_comp_using_neighbors = 3; |
1293 | |
|
1294 | 0 | sf->intra_sf.chroma_intra_pruning_with_hog = 4; |
1295 | 0 | sf->intra_sf.intra_pruning_with_hog = 4; |
1296 | 0 | sf->intra_sf.intra_uv_mode_mask[TX_32X32] = UV_INTRA_DC; |
1297 | 0 | sf->intra_sf.intra_uv_mode_mask[TX_64X64] = UV_INTRA_DC; |
1298 | 0 | sf->intra_sf.intra_y_mode_mask[TX_32X32] = INTRA_DC; |
1299 | 0 | sf->intra_sf.intra_y_mode_mask[TX_64X64] = INTRA_DC; |
1300 | 0 | sf->intra_sf.early_term_chroma_palette_size_search = 1; |
1301 | |
|
1302 | 0 | sf->part_sf.prune_rectangular_split_based_on_qidx = |
1303 | 0 | boosted || allow_screen_content_tools ? 0 : 2; |
1304 | |
|
1305 | 0 | sf->part_sf.prune_part4_search = 3; |
1306 | |
|
1307 | 0 | sf->mv_sf.simple_motion_subpel_force_stop = FULL_PEL; |
1308 | 0 | sf->mv_sf.use_bsize_dependent_search_method = 1; |
1309 | |
|
1310 | 0 | sf->tpl_sf.gop_length_decision_method = 3; |
1311 | |
|
1312 | 0 | sf->rd_sf.perform_coeff_opt = is_boosted_arf2_bwd_type ? 6 : 8; |
1313 | |
|
1314 | 0 | sf->winner_mode_sf.dc_blk_pred_level = 3; |
1315 | 0 | sf->winner_mode_sf.multi_winner_mode_type = MULTI_WINNER_MODE_OFF; |
1316 | |
|
1317 | 0 | sf->fp_sf.skip_zeromv_motion_search = 1; |
1318 | 0 | } |
1319 | 0 | } |
1320 | | |
1321 | | static void set_rt_speed_feature_framesize_dependent(const AV1_COMP *const cpi, |
1322 | | SPEED_FEATURES *const sf, |
1323 | 0 | int speed) { |
1324 | 0 | const AV1_COMMON *const cm = &cpi->common; |
1325 | 0 | const int boosted = frame_is_boosted(cpi); |
1326 | 0 | const int is_1080p_or_larger = AOMMIN(cm->width, cm->height) >= 1080; |
1327 | 0 | const int is_720p_or_larger = AOMMIN(cm->width, cm->height) >= 720; |
1328 | 0 | const int is_480p_or_larger = AOMMIN(cm->width, cm->height) >= 480; |
1329 | 0 | const int is_360p_or_larger = AOMMIN(cm->width, cm->height) >= 360; |
1330 | |
|
1331 | 0 | if (!is_360p_or_larger) { |
1332 | 0 | sf->rt_sf.prune_intra_mode_based_on_mv_range = 1; |
1333 | 0 | sf->rt_sf.prune_inter_modes_wrt_gf_arf_based_on_sad = 1; |
1334 | 0 | if (speed >= 6) |
1335 | 0 | sf->winner_mode_sf.prune_winner_mode_eval_level = boosted ? 0 : 2; |
1336 | 0 | if (speed == 7) sf->rt_sf.prefer_large_partition_blocks = 2; |
1337 | 0 | if (speed >= 7) { |
1338 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_PICK_FROM_Q; |
1339 | 0 | sf->rt_sf.check_only_zero_zeromv_on_large_blocks = true; |
1340 | 0 | sf->rt_sf.use_rtc_tf = 2; |
1341 | 0 | } |
1342 | 0 | if (speed == 8) sf->rt_sf.prefer_large_partition_blocks = 1; |
1343 | 0 | if (speed >= 8) { |
1344 | 0 | sf->rt_sf.use_nonrd_filter_search = 1; |
1345 | 0 | sf->rt_sf.tx_size_level_based_on_qstep = 1; |
1346 | 0 | } |
1347 | 0 | if (speed >= 9) { |
1348 | 0 | sf->rt_sf.use_comp_ref_nonrd = 0; |
1349 | 0 | sf->rt_sf.nonrd_aggressive_skip = 1; |
1350 | 0 | sf->rt_sf.skip_intra_pred = 1; |
1351 | | // Only turn on enable_ref_short_signaling for low resolution when only |
1352 | | // LAST and GOLDEN ref frames are used. |
1353 | 0 | sf->rt_sf.enable_ref_short_signaling = |
1354 | 0 | (!sf->rt_sf.use_nonrd_altref_frame && |
1355 | 0 | (!sf->rt_sf.use_comp_ref_nonrd || |
1356 | 0 | (!sf->rt_sf.ref_frame_comp_nonrd[1] && |
1357 | 0 | !sf->rt_sf.ref_frame_comp_nonrd[2]))); |
1358 | | |
1359 | | // TODO(kyslov) Re-enable when AV1 models are trained |
1360 | | #if 0 |
1361 | | #if CONFIG_RT_ML_PARTITIONING |
1362 | | if (!frame_is_intra_only(cm)) { |
1363 | | sf->part_sf.partition_search_type = ML_BASED_PARTITION; |
1364 | | sf->rt_sf.reuse_inter_pred_nonrd = 0; |
1365 | | } |
1366 | | #endif |
1367 | | #endif |
1368 | 0 | sf->rt_sf.use_adaptive_subpel_search = false; |
1369 | 0 | } |
1370 | 0 | if (speed >= 10) { |
1371 | | // TODO(yunqingwang@google.com): To be conservative, disable |
1372 | | // sf->rt_sf.estimate_motion_for_var_based_partition = 3 for speed 10/qvga |
1373 | | // for now. May enable it in the future. |
1374 | 0 | sf->rt_sf.estimate_motion_for_var_based_partition = 0; |
1375 | 0 | sf->rt_sf.skip_intra_pred = 2; |
1376 | 0 | sf->rt_sf.hybrid_intra_pickmode = 3; |
1377 | 0 | sf->rt_sf.reduce_mv_pel_precision_lowcomplex = 1; |
1378 | 0 | sf->rt_sf.reduce_mv_pel_precision_highmotion = 2; |
1379 | 0 | sf->rt_sf.use_nonrd_filter_search = 0; |
1380 | 0 | } |
1381 | 0 | } else { |
1382 | 0 | sf->rt_sf.prune_intra_mode_based_on_mv_range = 2; |
1383 | 0 | sf->intra_sf.skip_filter_intra_in_inter_frames = 1; |
1384 | 0 | if (speed <= 5) { |
1385 | 0 | sf->tx_sf.tx_type_search.fast_inter_tx_type_prob_thresh = |
1386 | 0 | boosted ? INT_MAX : 350; |
1387 | 0 | sf->winner_mode_sf.prune_winner_mode_eval_level = boosted ? 0 : 2; |
1388 | 0 | } |
1389 | 0 | if (speed == 6) sf->part_sf.disable_8x8_part_based_on_qidx = 1; |
1390 | 0 | if (speed >= 6) sf->rt_sf.skip_newmv_mode_based_on_sse = 2; |
1391 | 0 | if (speed == 7) { |
1392 | 0 | sf->rt_sf.prefer_large_partition_blocks = 1; |
1393 | | // Enable this feature for [360p, 720p] resolution range initially. |
1394 | | // Only enable for low bitdepth to mitigate issue: b/303023614. |
1395 | 0 | if (!cpi->rc.rtc_external_ratectrl && |
1396 | 0 | AOMMIN(cm->width, cm->height) <= 720 && !cpi->oxcf.use_highbitdepth) |
1397 | 0 | sf->hl_sf.accurate_bit_estimate = cpi->oxcf.q_cfg.aq_mode == NO_AQ; |
1398 | 0 | } |
1399 | 0 | if (speed >= 7) { |
1400 | 0 | sf->rt_sf.use_rtc_tf = 1; |
1401 | 0 | } |
1402 | 0 | if (speed == 8 && !cpi->ppi->use_svc) { |
1403 | 0 | sf->rt_sf.short_circuit_low_temp_var = 0; |
1404 | 0 | sf->rt_sf.use_nonrd_altref_frame = 1; |
1405 | 0 | } |
1406 | 0 | if (speed >= 8) sf->rt_sf.tx_size_level_based_on_qstep = 2; |
1407 | 0 | if (speed >= 9) { |
1408 | 0 | sf->rt_sf.gf_length_lvl = 1; |
1409 | 0 | sf->rt_sf.skip_cdef_sb = 1; |
1410 | 0 | sf->rt_sf.sad_based_adp_altref_lag = 2; |
1411 | 0 | sf->rt_sf.reduce_mv_pel_precision_highmotion = 2; |
1412 | 0 | sf->rt_sf.use_adaptive_subpel_search = true; |
1413 | 0 | sf->interp_sf.cb_pred_filter_search = 1; |
1414 | 0 | } |
1415 | 0 | if (speed >= 10) { |
1416 | 0 | sf->rt_sf.hybrid_intra_pickmode = 2; |
1417 | 0 | sf->rt_sf.sad_based_adp_altref_lag = 4; |
1418 | 0 | sf->rt_sf.tx_size_level_based_on_qstep = 0; |
1419 | 0 | sf->rt_sf.reduce_mv_pel_precision_highmotion = 3; |
1420 | 0 | sf->rt_sf.use_adaptive_subpel_search = false; |
1421 | 0 | sf->interp_sf.cb_pred_filter_search = 2; |
1422 | 0 | } |
1423 | 0 | } |
1424 | 0 | if (!is_480p_or_larger) { |
1425 | 0 | if (speed == 7) { |
1426 | 0 | sf->rt_sf.nonrd_check_partition_merge_mode = 2; |
1427 | 0 | } |
1428 | 0 | } |
1429 | 0 | if (!is_720p_or_larger) { |
1430 | 0 | if (speed >= 9) { |
1431 | 0 | sf->rt_sf.force_large_partition_blocks_intra = 1; |
1432 | 0 | } |
1433 | 0 | } else { |
1434 | 0 | if (speed >= 6) sf->rt_sf.skip_newmv_mode_based_on_sse = 3; |
1435 | 0 | if (speed == 7) sf->rt_sf.prefer_large_partition_blocks = 0; |
1436 | 0 | if (speed >= 7) { |
1437 | 0 | sf->rt_sf.reduce_mv_pel_precision_lowcomplex = 2; |
1438 | 0 | sf->rt_sf.reduce_mv_pel_precision_highmotion = 1; |
1439 | 0 | } |
1440 | 0 | if (speed >= 9) { |
1441 | 0 | sf->rt_sf.sad_based_adp_altref_lag = 1; |
1442 | 0 | sf->rt_sf.reduce_mv_pel_precision_lowcomplex = 0; |
1443 | 0 | sf->rt_sf.reduce_mv_pel_precision_highmotion = 2; |
1444 | 0 | } |
1445 | 0 | if (speed >= 10) { |
1446 | 0 | sf->rt_sf.sad_based_adp_altref_lag = 3; |
1447 | 0 | sf->rt_sf.reduce_mv_pel_precision_highmotion = 3; |
1448 | 0 | } |
1449 | 0 | } |
1450 | | // TODO(Any): Check/Tune settings of other sfs for 1080p. |
1451 | 0 | if (is_1080p_or_larger) { |
1452 | 0 | if (speed >= 7) { |
1453 | 0 | sf->rt_sf.reduce_mv_pel_precision_highmotion = 0; |
1454 | 0 | sf->rt_sf.use_adaptive_subpel_search = 0; |
1455 | 0 | } |
1456 | 0 | if (speed >= 9) sf->interp_sf.cb_pred_filter_search = 0; |
1457 | 0 | } else { |
1458 | 0 | if (speed >= 9) sf->lpf_sf.cdef_pick_method = CDEF_PICK_FROM_Q; |
1459 | 0 | if (speed >= 10) sf->rt_sf.nonrd_aggressive_skip = 1; |
1460 | 0 | } |
1461 | | // TODO(marpan): Tune settings for speed 11 video mode, |
1462 | 0 | if (speed >= 11 && cpi->oxcf.tune_cfg.content != AOM_CONTENT_SCREEN) { |
1463 | 0 | sf->rt_sf.skip_cdef_sb = 1; |
1464 | 0 | sf->rt_sf.force_only_last_ref = 1; |
1465 | 0 | sf->rt_sf.selective_cdf_update = 1; |
1466 | 0 | sf->rt_sf.use_nonrd_filter_search = 0; |
1467 | 0 | if (is_360p_or_larger) { |
1468 | 0 | sf->part_sf.fixed_partition_size = BLOCK_32X32; |
1469 | 0 | sf->rt_sf.use_fast_fixed_part = 1; |
1470 | 0 | sf->rt_sf.reduce_mv_pel_precision_lowcomplex = 2; |
1471 | 0 | } |
1472 | 0 | sf->rt_sf.increase_source_sad_thresh = 1; |
1473 | 0 | sf->rt_sf.part_early_exit_zeromv = 2; |
1474 | 0 | sf->rt_sf.set_zeromv_skip_based_on_source_sad = 2; |
1475 | 0 | for (int i = 0; i < BLOCK_SIZES; ++i) { |
1476 | 0 | sf->rt_sf.intra_y_mode_bsize_mask_nrd[i] = INTRA_DC; |
1477 | 0 | } |
1478 | 0 | sf->rt_sf.hybrid_intra_pickmode = 0; |
1479 | 0 | } |
1480 | | // Setting for SVC, or when the ref_frame_config control is |
1481 | | // used to set the reference structure. |
1482 | 0 | if (cpi->ppi->use_svc || cpi->ppi->rtc_ref.set_ref_frame_config) { |
1483 | 0 | const RTC_REF *const rtc_ref = &cpi->ppi->rtc_ref; |
1484 | | // For SVC: for greater than 2 temporal layers, use better mv search on |
1485 | | // base temporal layers, and only on base spatial layer if highest |
1486 | | // resolution is above 640x360. |
1487 | 0 | if (cpi->svc.number_temporal_layers >= 2 && |
1488 | 0 | cpi->svc.temporal_layer_id == 0 && |
1489 | 0 | (cpi->svc.spatial_layer_id == 0 || |
1490 | 0 | cpi->oxcf.frm_dim_cfg.width * cpi->oxcf.frm_dim_cfg.height <= |
1491 | 0 | 640 * 360)) { |
1492 | 0 | sf->mv_sf.search_method = NSTEP; |
1493 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED; |
1494 | 0 | sf->rt_sf.fullpel_search_step_param = 10; |
1495 | 0 | sf->rt_sf.reduce_mv_pel_precision_highmotion = 0; |
1496 | 0 | if (cm->width * cm->height <= 352 * 288) |
1497 | 0 | sf->rt_sf.nonrd_prune_ref_frame_search = 2; |
1498 | 0 | sf->rt_sf.force_large_partition_blocks_intra = 0; |
1499 | 0 | } |
1500 | 0 | if (speed >= 8) { |
1501 | 0 | if (cpi->svc.number_temporal_layers > 2) |
1502 | 0 | sf->rt_sf.disable_cdf_update_non_reference_frame = true; |
1503 | 0 | sf->rt_sf.reduce_mv_pel_precision_highmotion = 3; |
1504 | 0 | if (rtc_ref->non_reference_frame) { |
1505 | 0 | sf->rt_sf.nonrd_aggressive_skip = 1; |
1506 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE; |
1507 | 0 | } |
1508 | 0 | } |
1509 | 0 | if (speed <= 9 && cpi->svc.number_temporal_layers > 2 && |
1510 | 0 | cpi->svc.temporal_layer_id == 0) |
1511 | 0 | sf->rt_sf.check_only_zero_zeromv_on_large_blocks = false; |
1512 | 0 | else |
1513 | 0 | sf->rt_sf.check_only_zero_zeromv_on_large_blocks = true; |
1514 | 0 | sf->rt_sf.frame_level_mode_cost_update = false; |
1515 | | |
1516 | | // Compound mode enabling. |
1517 | 0 | if (rtc_ref->ref_frame_comp[0] || rtc_ref->ref_frame_comp[1] || |
1518 | 0 | rtc_ref->ref_frame_comp[2]) { |
1519 | 0 | sf->rt_sf.use_comp_ref_nonrd = 1; |
1520 | 0 | sf->rt_sf.ref_frame_comp_nonrd[0] = |
1521 | 0 | rtc_ref->ref_frame_comp[0] && rtc_ref->reference[GOLDEN_FRAME - 1]; |
1522 | 0 | sf->rt_sf.ref_frame_comp_nonrd[1] = |
1523 | 0 | rtc_ref->ref_frame_comp[1] && rtc_ref->reference[LAST2_FRAME - 1]; |
1524 | 0 | sf->rt_sf.ref_frame_comp_nonrd[2] = |
1525 | 0 | rtc_ref->ref_frame_comp[2] && rtc_ref->reference[ALTREF_FRAME - 1]; |
1526 | 0 | } else { |
1527 | 0 | sf->rt_sf.use_comp_ref_nonrd = 0; |
1528 | 0 | } |
1529 | |
|
1530 | 0 | if (cpi->svc.number_spatial_layers > 1 || |
1531 | 0 | cpi->svc.number_temporal_layers > 1) |
1532 | 0 | sf->hl_sf.accurate_bit_estimate = 0; |
1533 | |
|
1534 | 0 | sf->rt_sf.estimate_motion_for_var_based_partition = 1; |
1535 | | |
1536 | | // For single layers RPS: bias/adjustment for recovery frame. |
1537 | 0 | if (cpi->ppi->rtc_ref.bias_recovery_frame) { |
1538 | 0 | sf->mv_sf.search_method = NSTEP; |
1539 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE; |
1540 | 0 | sf->rt_sf.fullpel_search_step_param = 8; |
1541 | 0 | sf->rt_sf.nonrd_aggressive_skip = 0; |
1542 | 0 | } |
1543 | 0 | } |
1544 | | // Screen settings. |
1545 | 0 | if (cpi->oxcf.tune_cfg.content == AOM_CONTENT_SCREEN) { |
1546 | | // TODO(marpan): Check settings for speed 7 and 8. |
1547 | 0 | if (speed >= 7) { |
1548 | 0 | sf->rt_sf.reduce_mv_pel_precision_highmotion = 1; |
1549 | 0 | sf->mv_sf.use_bsize_dependent_search_method = 0; |
1550 | 0 | sf->rt_sf.skip_cdef_sb = 1; |
1551 | 0 | sf->rt_sf.increase_color_thresh_palette = 1; |
1552 | 0 | if (!frame_is_intra_only(cm)) sf->rt_sf.dct_only_palette_nonrd = 1; |
1553 | 0 | } |
1554 | 0 | if (speed >= 8) { |
1555 | 0 | sf->rt_sf.nonrd_check_partition_merge_mode = 3; |
1556 | 0 | sf->rt_sf.nonrd_prune_ref_frame_search = 1; |
1557 | 0 | sf->rt_sf.use_nonrd_filter_search = 0; |
1558 | 0 | sf->rt_sf.prune_hv_pred_modes_using_src_sad = false; |
1559 | 0 | } |
1560 | 0 | if (speed >= 9) { |
1561 | 0 | sf->rt_sf.prune_idtx_nonrd = 1; |
1562 | 0 | sf->rt_sf.part_early_exit_zeromv = 2; |
1563 | 0 | sf->rt_sf.skip_lf_screen = 1; |
1564 | 0 | sf->rt_sf.nonrd_prune_ref_frame_search = 3; |
1565 | 0 | sf->rt_sf.var_part_split_threshold_shift = 10; |
1566 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE; |
1567 | 0 | sf->rt_sf.reduce_mv_pel_precision_highmotion = 3; |
1568 | 0 | sf->rt_sf.reduce_mv_pel_precision_lowcomplex = 1; |
1569 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_PICK_FROM_Q; |
1570 | 0 | sf->rt_sf.nonrd_check_partition_merge_mode = 0; |
1571 | 0 | sf->interp_sf.cb_pred_filter_search = 0; |
1572 | 0 | } |
1573 | 0 | if (speed >= 10) { |
1574 | 0 | if (cm->width * cm->height > 1920 * 1080) |
1575 | 0 | sf->part_sf.disable_8x8_part_based_on_qidx = 1; |
1576 | 0 | sf->rt_sf.screen_content_cdef_filter_qindex_thresh = 80; |
1577 | 0 | sf->rt_sf.part_early_exit_zeromv = 1; |
1578 | 0 | sf->rt_sf.nonrd_aggressive_skip = 1; |
1579 | 0 | sf->rt_sf.thresh_active_maps_skip_lf_cdef = 90; |
1580 | 0 | sf->rt_sf.hybrid_intra_pickmode = 0; |
1581 | 0 | sf->rt_sf.dct_only_palette_nonrd = 1; |
1582 | 0 | sf->rt_sf.prune_palette_search_nonrd = 1; |
1583 | 0 | sf->rt_sf.prune_intra_mode_using_best_sad_so_far = true; |
1584 | 0 | sf->rt_sf.rc_faster_convergence_static = 1; |
1585 | 0 | sf->rt_sf.rc_compute_spatial_var_sc = 1; |
1586 | 0 | } |
1587 | 0 | if (speed >= 11) { |
1588 | 0 | sf->rt_sf.skip_lf_screen = 2; |
1589 | 0 | sf->rt_sf.skip_cdef_sb = 2; |
1590 | 0 | sf->rt_sf.prune_palette_search_nonrd = 2; |
1591 | 0 | sf->rt_sf.increase_color_thresh_palette = 0; |
1592 | 0 | sf->rt_sf.prune_h_pred_using_best_mode_so_far = true; |
1593 | 0 | sf->rt_sf.enable_intra_mode_pruning_using_neighbors = true; |
1594 | 0 | } |
1595 | 0 | sf->rt_sf.skip_encoding_non_reference_slide_change = |
1596 | 0 | cpi->oxcf.rc_cfg.drop_frames_water_mark > 0 ? 1 : 0; |
1597 | 0 | sf->rt_sf.skip_newmv_flat_blocks_screen = 1; |
1598 | 0 | sf->rt_sf.use_idtx_nonrd = 1; |
1599 | 0 | sf->rt_sf.higher_thresh_scene_detection = 0; |
1600 | 0 | sf->rt_sf.use_nonrd_altref_frame = 0; |
1601 | 0 | sf->rt_sf.use_rtc_tf = 0; |
1602 | 0 | sf->rt_sf.use_comp_ref_nonrd = 0; |
1603 | 0 | sf->rt_sf.source_metrics_sb_nonrd = 1; |
1604 | 0 | if (cpi->rc.high_source_sad == 1) { |
1605 | 0 | sf->rt_sf.prefer_large_partition_blocks = 0; |
1606 | 0 | sf->part_sf.max_intra_bsize = BLOCK_128X128; |
1607 | 0 | for (int i = 0; i < BLOCK_SIZES; ++i) { |
1608 | 0 | if (i > BLOCK_32X32) |
1609 | 0 | sf->rt_sf.intra_y_mode_bsize_mask_nrd[i] = INTRA_DC; |
1610 | 0 | else |
1611 | 0 | sf->rt_sf.intra_y_mode_bsize_mask_nrd[i] = INTRA_DC_H_V; |
1612 | 0 | } |
1613 | 0 | } |
1614 | 0 | if (speed >= 11 && cpi->rc.high_motion_content_screen_rtc) { |
1615 | 0 | sf->rt_sf.higher_thresh_scene_detection = 1; |
1616 | 0 | sf->rt_sf.force_only_last_ref = 1; |
1617 | 0 | sf->rt_sf.use_nonrd_filter_search = 0; |
1618 | 0 | sf->part_sf.fixed_partition_size = BLOCK_32X32; |
1619 | 0 | sf->rt_sf.use_fast_fixed_part = 1; |
1620 | 0 | sf->rt_sf.increase_source_sad_thresh = 1; |
1621 | 0 | sf->rt_sf.selective_cdf_update = 1; |
1622 | 0 | sf->mv_sf.search_method = FAST_DIAMOND; |
1623 | 0 | } else if (cpi->rc.max_block_source_sad > 20000 && |
1624 | 0 | cpi->rc.frame_source_sad > 100 && speed >= 6 && |
1625 | 0 | (cpi->rc.percent_blocks_with_motion > 1 || |
1626 | 0 | cpi->svc.last_layer_dropped[0])) { |
1627 | 0 | sf->mv_sf.search_method = NSTEP; |
1628 | 0 | sf->rt_sf.fullpel_search_step_param = 2; |
1629 | 0 | } |
1630 | 0 | if (cpi->rc.high_source_sad && cpi->ppi->rtc_ref.non_reference_frame) { |
1631 | 0 | sf->rt_sf.use_idtx_nonrd = 0; |
1632 | 0 | sf->rt_sf.prefer_large_partition_blocks = 1; |
1633 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE; |
1634 | 0 | sf->rt_sf.fullpel_search_step_param = 10; |
1635 | 0 | } |
1636 | 0 | sf->rt_sf.partition_direct_merging = 0; |
1637 | 0 | sf->hl_sf.accurate_bit_estimate = 0; |
1638 | | // This feature is for nonrd_pickmode. |
1639 | 0 | if (sf->rt_sf.use_nonrd_pick_mode) |
1640 | 0 | sf->rt_sf.estimate_motion_for_var_based_partition = 1; |
1641 | 0 | else |
1642 | 0 | sf->rt_sf.estimate_motion_for_var_based_partition = 0; |
1643 | 0 | } |
1644 | 0 | if (is_lossless_requested(&cpi->oxcf.rc_cfg)) { |
1645 | 0 | sf->rt_sf.use_rtc_tf = 0; |
1646 | | // TODO(aomedia:3412): The setting accurate_bit_estimate = 0 |
1647 | | // can be removed once it's fixed for lossless mode. |
1648 | 0 | sf->hl_sf.accurate_bit_estimate = 0; |
1649 | 0 | } |
1650 | 0 | if (cpi->oxcf.use_highbitdepth) { |
1651 | | // Disable for use_highbitdepth = 1 to mitigate issue: b/303023614. |
1652 | 0 | sf->rt_sf.estimate_motion_for_var_based_partition = 0; |
1653 | 0 | } |
1654 | 0 | if (cpi->oxcf.superres_cfg.enable_superres) { |
1655 | 0 | sf->rt_sf.use_rtc_tf = 0; |
1656 | 0 | sf->rt_sf.nonrd_prune_ref_frame_search = 1; |
1657 | 0 | } |
1658 | | // rtc_tf feature allocates new source because of possible |
1659 | | // temporal filtering which may change the input source during encoding: |
1660 | | // this causes an issue on resized frames when psnr is calculated, |
1661 | | // so disable it here for frames that are resized (encoding width/height |
1662 | | // different from configured width/height). |
1663 | 0 | if (is_psnr_calc_enabled(cpi) && (cpi->oxcf.frm_dim_cfg.width != cm->width || |
1664 | 0 | cpi->oxcf.frm_dim_cfg.height != cm->height)) |
1665 | 0 | sf->rt_sf.use_rtc_tf = 0; |
1666 | 0 | } |
1667 | | |
1668 | | static void set_rt_speed_features_framesize_independent(AV1_COMP *cpi, |
1669 | | SPEED_FEATURES *sf, |
1670 | 0 | int speed) { |
1671 | 0 | AV1_COMMON *const cm = &cpi->common; |
1672 | 0 | const int boosted = frame_is_boosted(cpi); |
1673 | | |
1674 | | // Currently, rt speed 0, 1, 2, 3, 4, 5 are the same. |
1675 | | // Following set of speed features are not impacting encoder's decisions as |
1676 | | // the relevant tools are disabled by default. |
1677 | 0 | sf->gm_sf.gm_search_type = GM_DISABLE_SEARCH; |
1678 | 0 | sf->hl_sf.recode_loop = ALLOW_RECODE_KFARFGF; |
1679 | 0 | sf->inter_sf.reuse_inter_intra_mode = 1; |
1680 | 0 | sf->inter_sf.prune_compound_using_single_ref = 0; |
1681 | 0 | sf->inter_sf.prune_comp_search_by_single_result = 2; |
1682 | 0 | sf->inter_sf.prune_comp_type_by_comp_avg = 2; |
1683 | 0 | sf->inter_sf.fast_wedge_sign_estimate = 1; |
1684 | 0 | sf->inter_sf.use_dist_wtd_comp_flag = DIST_WTD_COMP_DISABLED; |
1685 | 0 | sf->inter_sf.mv_cost_upd_level = INTERNAL_COST_UPD_SBROW; |
1686 | 0 | sf->inter_sf.disable_interinter_wedge_var_thresh = 100; |
1687 | 0 | sf->interp_sf.cb_pred_filter_search = 0; |
1688 | 0 | sf->interp_sf.skip_interp_filter_search = 1; |
1689 | 0 | sf->part_sf.ml_prune_partition = 1; |
1690 | 0 | sf->part_sf.reuse_prev_rd_results_for_part_ab = 1; |
1691 | 0 | sf->part_sf.prune_ext_partition_types_search_level = 2; |
1692 | 0 | sf->part_sf.less_rectangular_check_level = 2; |
1693 | 0 | sf->mv_sf.obmc_full_pixel_search_level = 1; |
1694 | 0 | sf->intra_sf.dv_cost_upd_level = INTERNAL_COST_UPD_OFF; |
1695 | 0 | sf->tx_sf.model_based_prune_tx_search_level = 0; |
1696 | 0 | sf->lpf_sf.dual_sgr_penalty_level = 1; |
1697 | | // Disable Wiener and Self-guided Loop restoration filters. |
1698 | 0 | sf->lpf_sf.disable_wiener_filter = true; |
1699 | 0 | sf->lpf_sf.disable_sgr_filter = true; |
1700 | 0 | sf->intra_sf.prune_palette_search_level = 2; |
1701 | 0 | sf->intra_sf.prune_luma_palette_size_search_level = 2; |
1702 | 0 | sf->intra_sf.early_term_chroma_palette_size_search = 1; |
1703 | | |
1704 | | // End of set |
1705 | | |
1706 | | // TODO(any, yunqing): tune these features for real-time use cases. |
1707 | 0 | sf->hl_sf.superres_auto_search_type = SUPERRES_AUTO_SOLO; |
1708 | 0 | sf->hl_sf.frame_parameter_update = 0; |
1709 | |
|
1710 | 0 | sf->inter_sf.model_based_post_interp_filter_breakout = 1; |
1711 | | // TODO(any): As per the experiments, this speed feature is doing redundant |
1712 | | // computation since the model rd based pruning logic is similar to model rd |
1713 | | // based gating when inter_mode_rd_model_estimation = 2. Enable this SF if |
1714 | | // either of the condition becomes true. |
1715 | | // (1) inter_mode_rd_model_estimation != 2 |
1716 | | // (2) skip_interp_filter_search == 0 |
1717 | | // (3) Motion mode or compound mode is enabled */ |
1718 | 0 | sf->inter_sf.prune_mode_search_simple_translation = 0; |
1719 | 0 | sf->inter_sf.prune_ref_frame_for_rect_partitions = !boosted; |
1720 | 0 | sf->inter_sf.disable_interintra_wedge_var_thresh = UINT_MAX; |
1721 | 0 | sf->inter_sf.selective_ref_frame = 4; |
1722 | 0 | sf->inter_sf.alt_ref_search_fp = 2; |
1723 | 0 | set_txfm_rd_gate_level(sf->inter_sf.txfm_rd_gate_level, boosted ? 0 : 4); |
1724 | 0 | sf->inter_sf.limit_txfm_eval_per_mode = 3; |
1725 | |
|
1726 | 0 | sf->inter_sf.adaptive_rd_thresh = 4; |
1727 | 0 | sf->inter_sf.inter_mode_rd_model_estimation = 2; |
1728 | 0 | sf->inter_sf.prune_inter_modes_if_skippable = 1; |
1729 | 0 | sf->inter_sf.prune_nearmv_using_neighbors = PRUNE_NEARMV_LEVEL3; |
1730 | 0 | sf->inter_sf.reduce_inter_modes = boosted ? 1 : 3; |
1731 | 0 | sf->inter_sf.skip_newmv_in_drl = 4; |
1732 | |
|
1733 | 0 | sf->interp_sf.use_fast_interpolation_filter_search = 1; |
1734 | 0 | sf->interp_sf.use_interp_filter = 1; |
1735 | 0 | sf->interp_sf.adaptive_interp_filter_search = 1; |
1736 | 0 | sf->interp_sf.disable_dual_filter = 1; |
1737 | |
|
1738 | 0 | sf->part_sf.default_max_partition_size = BLOCK_128X128; |
1739 | 0 | sf->part_sf.default_min_partition_size = BLOCK_8X8; |
1740 | 0 | sf->part_sf.use_best_rd_for_pruning = 1; |
1741 | 0 | sf->part_sf.early_term_after_none_split = 1; |
1742 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 25); |
1743 | 0 | sf->part_sf.max_intra_bsize = BLOCK_16X16; |
1744 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 500; |
1745 | 0 | sf->part_sf.partition_search_type = VAR_BASED_PARTITION; |
1746 | 0 | sf->part_sf.adjust_var_based_rd_partitioning = 2; |
1747 | |
|
1748 | 0 | sf->mv_sf.full_pixel_search_level = 1; |
1749 | 0 | sf->mv_sf.exhaustive_searches_thresh = INT_MAX; |
1750 | 0 | sf->mv_sf.auto_mv_step_size = 1; |
1751 | 0 | sf->mv_sf.subpel_iters_per_step = 1; |
1752 | 0 | sf->mv_sf.use_accurate_subpel_search = USE_2_TAPS; |
1753 | 0 | sf->mv_sf.search_method = FAST_DIAMOND; |
1754 | 0 | sf->mv_sf.subpel_force_stop = EIGHTH_PEL; |
1755 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED; |
1756 | |
|
1757 | 0 | for (int i = 0; i < TX_SIZES; ++i) { |
1758 | 0 | sf->intra_sf.intra_y_mode_mask[i] = INTRA_DC; |
1759 | 0 | sf->intra_sf.intra_uv_mode_mask[i] = UV_INTRA_DC_CFL; |
1760 | 0 | } |
1761 | 0 | sf->intra_sf.skip_intra_in_interframe = 5; |
1762 | 0 | sf->intra_sf.disable_smooth_intra = 1; |
1763 | 0 | sf->intra_sf.skip_filter_intra_in_inter_frames = 1; |
1764 | |
|
1765 | 0 | sf->tx_sf.intra_tx_size_search_init_depth_sqr = 1; |
1766 | 0 | sf->tx_sf.tx_type_search.use_reduced_intra_txset = 1; |
1767 | 0 | sf->tx_sf.adaptive_txb_search_level = 2; |
1768 | 0 | sf->tx_sf.intra_tx_size_search_init_depth_rect = 1; |
1769 | 0 | sf->tx_sf.tx_size_search_lgr_block = 1; |
1770 | 0 | sf->tx_sf.tx_type_search.ml_tx_split_thresh = 4000; |
1771 | 0 | sf->tx_sf.tx_type_search.skip_tx_search = 1; |
1772 | 0 | sf->tx_sf.inter_tx_size_search_init_depth_rect = 1; |
1773 | 0 | sf->tx_sf.inter_tx_size_search_init_depth_sqr = 1; |
1774 | 0 | sf->tx_sf.tx_type_search.prune_2d_txfm_mode = TX_TYPE_PRUNE_3; |
1775 | 0 | sf->tx_sf.refine_fast_tx_search_results = 0; |
1776 | 0 | sf->tx_sf.tx_type_search.fast_intra_tx_type_search = 1; |
1777 | 0 | sf->tx_sf.tx_type_search.use_skip_flag_prediction = 2; |
1778 | 0 | sf->tx_sf.tx_type_search.winner_mode_tx_type_pruning = 4; |
1779 | |
|
1780 | 0 | sf->rd_sf.optimize_coefficients = NO_TRELLIS_OPT; |
1781 | 0 | sf->rd_sf.simple_model_rd_from_var = 1; |
1782 | 0 | sf->rd_sf.tx_domain_dist_level = 2; |
1783 | 0 | sf->rd_sf.tx_domain_dist_thres_level = 2; |
1784 | |
|
1785 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL4; |
1786 | 0 | sf->lpf_sf.lpf_pick = LPF_PICK_FROM_Q; |
1787 | |
|
1788 | 0 | sf->winner_mode_sf.dc_blk_pred_level = frame_is_intra_only(cm) ? 0 : 3; |
1789 | 0 | sf->winner_mode_sf.enable_winner_mode_for_tx_size_srch = 1; |
1790 | 0 | sf->winner_mode_sf.tx_size_search_level = 1; |
1791 | 0 | sf->winner_mode_sf.winner_mode_ifs = 1; |
1792 | |
|
1793 | 0 | sf->rt_sf.check_intra_pred_nonrd = 1; |
1794 | 0 | sf->rt_sf.estimate_motion_for_var_based_partition = 2; |
1795 | 0 | sf->rt_sf.hybrid_intra_pickmode = 1; |
1796 | 0 | sf->rt_sf.use_comp_ref_nonrd = 0; |
1797 | 0 | sf->rt_sf.ref_frame_comp_nonrd[0] = 0; |
1798 | 0 | sf->rt_sf.ref_frame_comp_nonrd[1] = 0; |
1799 | 0 | sf->rt_sf.ref_frame_comp_nonrd[2] = 0; |
1800 | 0 | sf->rt_sf.use_nonrd_filter_search = 1; |
1801 | 0 | sf->rt_sf.mode_search_skip_flags |= FLAG_SKIP_INTRA_DIRMISMATCH; |
1802 | 0 | sf->rt_sf.num_inter_modes_for_tx_search = 5; |
1803 | 0 | sf->rt_sf.prune_inter_modes_using_temp_var = 1; |
1804 | 0 | sf->rt_sf.use_real_time_ref_set = 1; |
1805 | 0 | sf->rt_sf.use_simple_rd_model = 1; |
1806 | 0 | sf->rt_sf.prune_inter_modes_with_golden_ref = boosted ? 0 : 1; |
1807 | | // TODO(any): This sf could be removed. |
1808 | 0 | sf->rt_sf.short_circuit_low_temp_var = 1; |
1809 | 0 | sf->rt_sf.check_scene_detection = 1; |
1810 | 0 | if (cpi->rc.rtc_external_ratectrl) sf->rt_sf.check_scene_detection = 0; |
1811 | 0 | if (cm->current_frame.frame_type != KEY_FRAME && |
1812 | 0 | cpi->oxcf.rc_cfg.mode == AOM_CBR) |
1813 | 0 | sf->rt_sf.overshoot_detection_cbr = FAST_DETECTION_MAXQ; |
1814 | | // Enable noise estimation only for high resolutions for now. |
1815 | | // |
1816 | | // Since use_temporal_noise_estimate has no effect for all-intra frame |
1817 | | // encoding, it is disabled for this case. |
1818 | 0 | if (cpi->oxcf.kf_cfg.key_freq_max != 0 && cm->width * cm->height > 640 * 480) |
1819 | 0 | sf->rt_sf.use_temporal_noise_estimate = 1; |
1820 | 0 | sf->rt_sf.skip_tx_no_split_var_based_partition = 1; |
1821 | 0 | sf->rt_sf.skip_newmv_mode_based_on_sse = 1; |
1822 | 0 | sf->rt_sf.mode_search_skip_flags = |
1823 | 0 | (cm->current_frame.frame_type == KEY_FRAME) |
1824 | 0 | ? 0 |
1825 | 0 | : FLAG_SKIP_INTRA_DIRMISMATCH | FLAG_SKIP_INTRA_BESTINTER | |
1826 | 0 | FLAG_SKIP_COMP_BESTINTRA | FLAG_SKIP_INTRA_LOWVAR | |
1827 | 0 | FLAG_EARLY_TERMINATE; |
1828 | 0 | sf->rt_sf.var_part_split_threshold_shift = 5; |
1829 | 0 | if (!frame_is_intra_only(&cpi->common)) sf->rt_sf.var_part_based_on_qidx = 1; |
1830 | 0 | sf->rt_sf.use_fast_fixed_part = 0; |
1831 | 0 | sf->rt_sf.increase_source_sad_thresh = 0; |
1832 | |
|
1833 | 0 | if (speed >= 6) { |
1834 | 0 | sf->mv_sf.use_fullpel_costlist = 1; |
1835 | |
|
1836 | 0 | sf->rd_sf.tx_domain_dist_thres_level = 3; |
1837 | |
|
1838 | 0 | sf->tx_sf.tx_type_search.fast_inter_tx_type_prob_thresh = 0; |
1839 | 0 | sf->inter_sf.limit_inter_mode_cands = 4; |
1840 | 0 | sf->inter_sf.prune_warped_prob_thresh = 8; |
1841 | 0 | sf->inter_sf.extra_prune_warped = 1; |
1842 | |
|
1843 | 0 | sf->rt_sf.gf_refresh_based_on_qp = 1; |
1844 | 0 | sf->rt_sf.prune_inter_modes_wrt_gf_arf_based_on_sad = 1; |
1845 | 0 | sf->rt_sf.var_part_split_threshold_shift = 7; |
1846 | 0 | if (!frame_is_intra_only(&cpi->common)) |
1847 | 0 | sf->rt_sf.var_part_based_on_qidx = 2; |
1848 | |
|
1849 | 0 | sf->winner_mode_sf.prune_winner_mode_eval_level = boosted ? 0 : 3; |
1850 | 0 | } |
1851 | |
|
1852 | 0 | if (speed >= 7) { |
1853 | 0 | sf->rt_sf.sse_early_term_inter_search = EARLY_TERM_IDX_1; |
1854 | 0 | sf->rt_sf.use_comp_ref_nonrd = 1; |
1855 | 0 | sf->rt_sf.ref_frame_comp_nonrd[2] = 1; // LAST_ALTREF |
1856 | 0 | sf->tx_sf.intra_tx_size_search_init_depth_sqr = 2; |
1857 | 0 | sf->part_sf.partition_search_type = VAR_BASED_PARTITION; |
1858 | 0 | sf->part_sf.max_intra_bsize = BLOCK_32X32; |
1859 | |
|
1860 | 0 | sf->mv_sf.search_method = FAST_DIAMOND; |
1861 | 0 | sf->mv_sf.subpel_force_stop = QUARTER_PEL; |
1862 | |
|
1863 | 0 | sf->inter_sf.inter_mode_rd_model_estimation = 2; |
1864 | | // This sf is not applicable in non-rd path. |
1865 | 0 | sf->inter_sf.skip_newmv_in_drl = 0; |
1866 | |
|
1867 | 0 | sf->interp_sf.skip_interp_filter_search = 0; |
1868 | | |
1869 | | // Disable intra_y_mode_mask pruning since the performance at speed 7 isn't |
1870 | | // good. May need more study. |
1871 | 0 | for (int i = 0; i < TX_SIZES; ++i) { |
1872 | 0 | sf->intra_sf.intra_y_mode_mask[i] = INTRA_ALL; |
1873 | 0 | } |
1874 | |
|
1875 | 0 | sf->lpf_sf.lpf_pick = LPF_PICK_FROM_Q; |
1876 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL5; |
1877 | |
|
1878 | 0 | sf->rt_sf.mode_search_skip_flags |= FLAG_SKIP_INTRA_DIRMISMATCH; |
1879 | 0 | sf->rt_sf.nonrd_prune_ref_frame_search = 1; |
1880 | | // This is for rd path only. |
1881 | 0 | sf->rt_sf.prune_inter_modes_using_temp_var = 0; |
1882 | 0 | sf->rt_sf.prune_inter_modes_wrt_gf_arf_based_on_sad = 0; |
1883 | 0 | sf->rt_sf.prune_intra_mode_based_on_mv_range = 0; |
1884 | 0 | #if !CONFIG_REALTIME_ONLY |
1885 | 0 | sf->rt_sf.reuse_inter_pred_nonrd = |
1886 | 0 | (cpi->oxcf.motion_mode_cfg.enable_warped_motion == 0); |
1887 | | #else |
1888 | | sf->rt_sf.reuse_inter_pred_nonrd = 1; |
1889 | | #endif |
1890 | | #if CONFIG_AV1_TEMPORAL_DENOISING |
1891 | | sf->rt_sf.reuse_inter_pred_nonrd = (cpi->oxcf.noise_sensitivity == 0); |
1892 | | #endif |
1893 | 0 | sf->rt_sf.short_circuit_low_temp_var = 0; |
1894 | | // For spatial layers, only LAST and GOLDEN are currently used in the SVC |
1895 | | // for nonrd. The flag use_nonrd_altref_frame can disable GOLDEN in the |
1896 | | // get_ref_frame_flags() for some patterns, so disable it here for |
1897 | | // spatial layers. |
1898 | 0 | sf->rt_sf.use_nonrd_altref_frame = |
1899 | 0 | (cpi->svc.number_spatial_layers > 1) ? 0 : 1; |
1900 | 0 | sf->rt_sf.use_nonrd_pick_mode = 1; |
1901 | 0 | sf->rt_sf.nonrd_check_partition_merge_mode = 3; |
1902 | 0 | sf->rt_sf.skip_intra_pred = 1; |
1903 | 0 | sf->rt_sf.source_metrics_sb_nonrd = 1; |
1904 | | // Set mask for intra modes. |
1905 | 0 | for (int i = 0; i < BLOCK_SIZES; ++i) |
1906 | 0 | if (i >= BLOCK_32X32) |
1907 | 0 | sf->rt_sf.intra_y_mode_bsize_mask_nrd[i] = INTRA_DC; |
1908 | 0 | else |
1909 | | // Use DC, H, V intra mode for block sizes < 32X32. |
1910 | 0 | sf->rt_sf.intra_y_mode_bsize_mask_nrd[i] = INTRA_DC_H_V; |
1911 | |
|
1912 | 0 | sf->winner_mode_sf.dc_blk_pred_level = 0; |
1913 | 0 | sf->rt_sf.var_part_based_on_qidx = 3; |
1914 | 0 | sf->rt_sf.prune_compoundmode_with_singlecompound_var = true; |
1915 | 0 | sf->rt_sf.prune_compoundmode_with_singlemode_var = true; |
1916 | 0 | sf->rt_sf.skip_compound_based_on_var = true; |
1917 | 0 | sf->rt_sf.use_adaptive_subpel_search = true; |
1918 | 0 | } |
1919 | |
|
1920 | 0 | if (speed >= 8) { |
1921 | 0 | sf->rt_sf.sse_early_term_inter_search = EARLY_TERM_IDX_2; |
1922 | 0 | sf->intra_sf.intra_pruning_with_hog = 1; |
1923 | 0 | sf->rt_sf.short_circuit_low_temp_var = 1; |
1924 | 0 | sf->rt_sf.use_nonrd_altref_frame = 0; |
1925 | 0 | sf->rt_sf.nonrd_prune_ref_frame_search = 2; |
1926 | 0 | sf->rt_sf.nonrd_check_partition_merge_mode = 0; |
1927 | 0 | sf->rt_sf.var_part_split_threshold_shift = 8; |
1928 | 0 | sf->rt_sf.var_part_based_on_qidx = 4; |
1929 | 0 | sf->rt_sf.partition_direct_merging = 1; |
1930 | 0 | sf->rt_sf.prune_compoundmode_with_singlemode_var = false; |
1931 | 0 | sf->mv_sf.use_bsize_dependent_search_method = 2; |
1932 | 0 | sf->rt_sf.prune_hv_pred_modes_using_src_sad = true; |
1933 | 0 | } |
1934 | 0 | if (speed >= 9) { |
1935 | 0 | sf->rt_sf.sse_early_term_inter_search = EARLY_TERM_IDX_3; |
1936 | 0 | sf->rt_sf.estimate_motion_for_var_based_partition = 3; |
1937 | 0 | sf->rt_sf.prefer_large_partition_blocks = 3; |
1938 | 0 | sf->rt_sf.skip_intra_pred = 2; |
1939 | 0 | sf->rt_sf.var_part_split_threshold_shift = 9; |
1940 | 0 | for (int i = 0; i < BLOCK_SIZES; ++i) |
1941 | 0 | sf->rt_sf.intra_y_mode_bsize_mask_nrd[i] = INTRA_DC; |
1942 | 0 | sf->rt_sf.var_part_based_on_qidx = 0; |
1943 | 0 | sf->rt_sf.frame_level_mode_cost_update = true; |
1944 | 0 | sf->rt_sf.check_only_zero_zeromv_on_large_blocks = true; |
1945 | 0 | sf->rt_sf.reduce_mv_pel_precision_highmotion = 0; |
1946 | 0 | sf->rt_sf.use_adaptive_subpel_search = true; |
1947 | 0 | sf->mv_sf.use_bsize_dependent_search_method = 0; |
1948 | 0 | } |
1949 | 0 | if (speed >= 10) { |
1950 | 0 | sf->rt_sf.sse_early_term_inter_search = EARLY_TERM_IDX_4; |
1951 | 0 | sf->rt_sf.nonrd_prune_ref_frame_search = 3; |
1952 | 0 | sf->rt_sf.var_part_split_threshold_shift = 10; |
1953 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE; |
1954 | 0 | } |
1955 | 0 | if (speed >= 11 && !frame_is_intra_only(cm) && |
1956 | 0 | cpi->oxcf.tune_cfg.content == AOM_CONTENT_SCREEN) { |
1957 | 0 | sf->winner_mode_sf.dc_blk_pred_level = 3; |
1958 | 0 | } |
1959 | 0 | } |
1960 | | |
1961 | 0 | static inline void init_hl_sf(HIGH_LEVEL_SPEED_FEATURES *hl_sf) { |
1962 | | // best quality defaults |
1963 | 0 | hl_sf->frame_parameter_update = 1; |
1964 | 0 | hl_sf->recode_loop = ALLOW_RECODE; |
1965 | | // Recode loop tolerance %. |
1966 | 0 | hl_sf->recode_tolerance = 25; |
1967 | 0 | hl_sf->high_precision_mv_usage = CURRENT_Q; |
1968 | 0 | hl_sf->superres_auto_search_type = SUPERRES_AUTO_ALL; |
1969 | 0 | hl_sf->disable_extra_sc_testing = 0; |
1970 | 0 | hl_sf->second_alt_ref_filtering = 1; |
1971 | 0 | hl_sf->adjust_num_frames_for_arf_filtering = 0; |
1972 | 0 | hl_sf->accurate_bit_estimate = 0; |
1973 | 0 | hl_sf->weight_calc_level_in_tf = 0; |
1974 | 0 | hl_sf->allow_sub_blk_me_in_tf = 0; |
1975 | 0 | } |
1976 | | |
1977 | 0 | static inline void init_fp_sf(FIRST_PASS_SPEED_FEATURES *fp_sf) { |
1978 | 0 | fp_sf->reduce_mv_step_param = 3; |
1979 | 0 | fp_sf->skip_motion_search_threshold = 0; |
1980 | 0 | fp_sf->disable_recon = 0; |
1981 | 0 | fp_sf->skip_zeromv_motion_search = 0; |
1982 | 0 | } |
1983 | | |
1984 | 0 | static inline void init_tpl_sf(TPL_SPEED_FEATURES *tpl_sf) { |
1985 | 0 | tpl_sf->gop_length_decision_method = 0; |
1986 | 0 | tpl_sf->prune_intra_modes = 0; |
1987 | 0 | tpl_sf->prune_starting_mv = 0; |
1988 | 0 | tpl_sf->reduce_first_step_size = 0; |
1989 | 0 | tpl_sf->skip_alike_starting_mv = 0; |
1990 | 0 | tpl_sf->subpel_force_stop = EIGHTH_PEL; |
1991 | 0 | tpl_sf->search_method = NSTEP; |
1992 | 0 | tpl_sf->prune_ref_frames_in_tpl = 0; |
1993 | 0 | tpl_sf->allow_compound_pred = 1; |
1994 | 0 | tpl_sf->use_y_only_rate_distortion = 0; |
1995 | 0 | tpl_sf->use_sad_for_mode_decision = 0; |
1996 | 0 | tpl_sf->reduce_num_frames = 0; |
1997 | 0 | } |
1998 | | |
1999 | 0 | static inline void init_gm_sf(GLOBAL_MOTION_SPEED_FEATURES *gm_sf) { |
2000 | 0 | gm_sf->gm_search_type = GM_FULL_SEARCH; |
2001 | 0 | gm_sf->prune_ref_frame_for_gm_search = 0; |
2002 | 0 | gm_sf->prune_zero_mv_with_sse = 0; |
2003 | 0 | gm_sf->disable_gm_search_based_on_stats = 0; |
2004 | 0 | gm_sf->downsample_level = 0; |
2005 | 0 | gm_sf->num_refinement_steps = GM_MAX_REFINEMENT_STEPS; |
2006 | 0 | } |
2007 | | |
2008 | 0 | static inline void init_part_sf(PARTITION_SPEED_FEATURES *part_sf) { |
2009 | 0 | part_sf->partition_search_type = SEARCH_PARTITION; |
2010 | 0 | part_sf->less_rectangular_check_level = 0; |
2011 | 0 | part_sf->use_square_partition_only_threshold = BLOCK_128X128; |
2012 | 0 | part_sf->auto_max_partition_based_on_simple_motion = NOT_IN_USE; |
2013 | 0 | part_sf->default_max_partition_size = BLOCK_LARGEST; |
2014 | 0 | part_sf->default_min_partition_size = BLOCK_4X4; |
2015 | 0 | part_sf->adjust_var_based_rd_partitioning = 0; |
2016 | 0 | part_sf->max_intra_bsize = BLOCK_LARGEST; |
2017 | | // This setting only takes effect when partition_search_type is set |
2018 | | // to FIXED_PARTITION. |
2019 | 0 | part_sf->fixed_partition_size = BLOCK_16X16; |
2020 | | // Recode loop tolerance %. |
2021 | 0 | part_sf->partition_search_breakout_dist_thr = 0; |
2022 | 0 | part_sf->partition_search_breakout_rate_thr = 0; |
2023 | 0 | part_sf->prune_ext_partition_types_search_level = 0; |
2024 | 0 | part_sf->prune_part4_search = 0; |
2025 | 0 | part_sf->ml_prune_partition = 0; |
2026 | 0 | part_sf->ml_early_term_after_part_split_level = 0; |
2027 | 0 | for (int i = 0; i < PARTITION_BLOCK_SIZES; ++i) { |
2028 | 0 | part_sf->ml_partition_search_breakout_thresh[i] = |
2029 | 0 | -1; // -1 means not enabled. |
2030 | 0 | } |
2031 | 0 | part_sf->simple_motion_search_prune_agg = SIMPLE_AGG_LVL0; |
2032 | 0 | part_sf->simple_motion_search_split = 0; |
2033 | 0 | part_sf->simple_motion_search_prune_rect = 0; |
2034 | 0 | part_sf->simple_motion_search_early_term_none = 0; |
2035 | 0 | part_sf->simple_motion_search_reduce_search_steps = 0; |
2036 | 0 | part_sf->intra_cnn_based_part_prune_level = 0; |
2037 | 0 | part_sf->ext_partition_eval_thresh = BLOCK_8X8; |
2038 | 0 | part_sf->rect_partition_eval_thresh = BLOCK_128X128; |
2039 | 0 | part_sf->ext_part_eval_based_on_cur_best = 0; |
2040 | 0 | part_sf->prune_ext_part_using_split_info = 0; |
2041 | 0 | part_sf->prune_rectangular_split_based_on_qidx = 0; |
2042 | 0 | part_sf->prune_rect_part_using_4x4_var_deviation = false; |
2043 | 0 | part_sf->prune_rect_part_using_none_pred_mode = false; |
2044 | 0 | part_sf->early_term_after_none_split = 0; |
2045 | 0 | part_sf->ml_predict_breakout_level = 0; |
2046 | 0 | part_sf->prune_sub_8x8_partition_level = 0; |
2047 | 0 | part_sf->simple_motion_search_rect_split = 0; |
2048 | 0 | part_sf->reuse_prev_rd_results_for_part_ab = 0; |
2049 | 0 | part_sf->reuse_best_prediction_for_part_ab = 0; |
2050 | 0 | part_sf->use_best_rd_for_pruning = 0; |
2051 | 0 | part_sf->skip_non_sq_part_based_on_none = 0; |
2052 | 0 | part_sf->disable_8x8_part_based_on_qidx = 0; |
2053 | 0 | } |
2054 | | |
2055 | 0 | static inline void init_mv_sf(MV_SPEED_FEATURES *mv_sf) { |
2056 | 0 | mv_sf->full_pixel_search_level = 0; |
2057 | 0 | mv_sf->auto_mv_step_size = 0; |
2058 | 0 | mv_sf->exhaustive_searches_thresh = 0; |
2059 | 0 | mv_sf->obmc_full_pixel_search_level = 0; |
2060 | 0 | mv_sf->prune_mesh_search = PRUNE_MESH_SEARCH_DISABLED; |
2061 | 0 | mv_sf->reduce_search_range = 0; |
2062 | 0 | mv_sf->search_method = NSTEP; |
2063 | 0 | mv_sf->simple_motion_subpel_force_stop = EIGHTH_PEL; |
2064 | 0 | mv_sf->subpel_force_stop = EIGHTH_PEL; |
2065 | 0 | mv_sf->subpel_iters_per_step = 2; |
2066 | 0 | mv_sf->subpel_search_method = SUBPEL_TREE; |
2067 | 0 | mv_sf->use_accurate_subpel_search = USE_8_TAPS; |
2068 | 0 | mv_sf->use_bsize_dependent_search_method = 0; |
2069 | 0 | mv_sf->use_fullpel_costlist = 0; |
2070 | 0 | mv_sf->use_downsampled_sad = 0; |
2071 | 0 | mv_sf->disable_extensive_joint_motion_search = 0; |
2072 | 0 | mv_sf->disable_second_mv = 0; |
2073 | 0 | mv_sf->skip_fullpel_search_using_startmv = 0; |
2074 | 0 | mv_sf->warp_search_method = WARP_SEARCH_SQUARE; |
2075 | 0 | mv_sf->warp_search_iters = 8; |
2076 | 0 | mv_sf->use_intrabc = 1; |
2077 | 0 | } |
2078 | | |
2079 | 0 | static inline void init_inter_sf(INTER_MODE_SPEED_FEATURES *inter_sf) { |
2080 | 0 | inter_sf->adaptive_rd_thresh = 0; |
2081 | 0 | inter_sf->model_based_post_interp_filter_breakout = 0; |
2082 | 0 | inter_sf->reduce_inter_modes = 0; |
2083 | 0 | inter_sf->alt_ref_search_fp = 0; |
2084 | 0 | inter_sf->prune_single_ref = 0; |
2085 | 0 | inter_sf->prune_comp_ref_frames = 0; |
2086 | 0 | inter_sf->selective_ref_frame = 0; |
2087 | 0 | inter_sf->prune_ref_frame_for_rect_partitions = 0; |
2088 | 0 | inter_sf->fast_wedge_sign_estimate = 0; |
2089 | 0 | inter_sf->use_dist_wtd_comp_flag = DIST_WTD_COMP_ENABLED; |
2090 | 0 | inter_sf->reuse_inter_intra_mode = 0; |
2091 | 0 | inter_sf->mv_cost_upd_level = INTERNAL_COST_UPD_SB; |
2092 | 0 | inter_sf->coeff_cost_upd_level = INTERNAL_COST_UPD_SB; |
2093 | 0 | inter_sf->mode_cost_upd_level = INTERNAL_COST_UPD_SB; |
2094 | 0 | inter_sf->prune_inter_modes_based_on_tpl = 0; |
2095 | 0 | inter_sf->prune_nearmv_using_neighbors = PRUNE_NEARMV_OFF; |
2096 | 0 | inter_sf->prune_comp_search_by_single_result = 0; |
2097 | 0 | inter_sf->skip_repeated_ref_mv = 0; |
2098 | 0 | inter_sf->skip_newmv_in_drl = 0; |
2099 | 0 | inter_sf->inter_mode_rd_model_estimation = 0; |
2100 | 0 | inter_sf->prune_compound_using_single_ref = 0; |
2101 | 0 | inter_sf->prune_ext_comp_using_neighbors = 0; |
2102 | 0 | inter_sf->skip_ext_comp_nearmv_mode = 0; |
2103 | 0 | inter_sf->prune_comp_using_best_single_mode_ref = 0; |
2104 | 0 | inter_sf->prune_nearest_near_mv_using_refmv_weight = 0; |
2105 | 0 | inter_sf->disable_onesided_comp = 0; |
2106 | 0 | inter_sf->prune_mode_search_simple_translation = 0; |
2107 | 0 | inter_sf->prune_comp_type_by_comp_avg = 0; |
2108 | 0 | inter_sf->disable_interinter_wedge_newmv_search = 0; |
2109 | 0 | inter_sf->fast_interintra_wedge_search = 0; |
2110 | 0 | inter_sf->prune_comp_type_by_model_rd = 0; |
2111 | 0 | inter_sf->perform_best_rd_based_gating_for_chroma = 0; |
2112 | 0 | inter_sf->prune_obmc_prob_thresh = 0; |
2113 | 0 | inter_sf->disable_interinter_wedge_var_thresh = 0; |
2114 | 0 | inter_sf->disable_interintra_wedge_var_thresh = 0; |
2115 | 0 | inter_sf->prune_ref_mv_idx_search = 0; |
2116 | 0 | inter_sf->prune_warped_prob_thresh = 0; |
2117 | 0 | inter_sf->reuse_compound_type_decision = 0; |
2118 | 0 | inter_sf->prune_inter_modes_if_skippable = 0; |
2119 | 0 | inter_sf->disable_masked_comp = 0; |
2120 | 0 | inter_sf->enable_fast_compound_mode_search = 0; |
2121 | 0 | inter_sf->reuse_mask_search_results = 0; |
2122 | 0 | inter_sf->enable_fast_wedge_mask_search = 0; |
2123 | 0 | inter_sf->inter_mode_txfm_breakout = 0; |
2124 | 0 | inter_sf->limit_inter_mode_cands = 0; |
2125 | 0 | inter_sf->limit_txfm_eval_per_mode = 0; |
2126 | 0 | inter_sf->skip_arf_compound = 0; |
2127 | 0 | set_txfm_rd_gate_level(inter_sf->txfm_rd_gate_level, 0); |
2128 | 0 | } |
2129 | | |
2130 | 0 | static inline void init_interp_sf(INTERP_FILTER_SPEED_FEATURES *interp_sf) { |
2131 | 0 | interp_sf->adaptive_interp_filter_search = 0; |
2132 | 0 | interp_sf->cb_pred_filter_search = 0; |
2133 | 0 | interp_sf->disable_dual_filter = 0; |
2134 | 0 | interp_sf->skip_sharp_interp_filter_search = 0; |
2135 | 0 | interp_sf->use_fast_interpolation_filter_search = 0; |
2136 | 0 | interp_sf->use_interp_filter = 0; |
2137 | 0 | interp_sf->skip_interp_filter_search = 0; |
2138 | 0 | } |
2139 | | |
2140 | 0 | static inline void init_intra_sf(INTRA_MODE_SPEED_FEATURES *intra_sf) { |
2141 | 0 | intra_sf->dv_cost_upd_level = INTERNAL_COST_UPD_SB; |
2142 | 0 | intra_sf->skip_intra_in_interframe = 1; |
2143 | 0 | intra_sf->intra_pruning_with_hog = 0; |
2144 | 0 | intra_sf->chroma_intra_pruning_with_hog = 0; |
2145 | 0 | intra_sf->prune_palette_search_level = 0; |
2146 | 0 | intra_sf->prune_luma_palette_size_search_level = 0; |
2147 | |
|
2148 | 0 | for (int i = 0; i < TX_SIZES; i++) { |
2149 | 0 | intra_sf->intra_y_mode_mask[i] = INTRA_ALL; |
2150 | 0 | intra_sf->intra_uv_mode_mask[i] = UV_INTRA_ALL; |
2151 | 0 | } |
2152 | 0 | intra_sf->disable_smooth_intra = 0; |
2153 | 0 | intra_sf->prune_smooth_intra_mode_for_chroma = 0; |
2154 | 0 | intra_sf->prune_filter_intra_level = 0; |
2155 | 0 | intra_sf->prune_chroma_modes_using_luma_winner = 0; |
2156 | 0 | intra_sf->cfl_search_range = 3; |
2157 | 0 | intra_sf->top_intra_model_count_allowed = TOP_INTRA_MODEL_COUNT; |
2158 | 0 | intra_sf->adapt_top_model_rd_count_using_neighbors = 0; |
2159 | 0 | intra_sf->early_term_chroma_palette_size_search = 0; |
2160 | 0 | intra_sf->skip_filter_intra_in_inter_frames = 0; |
2161 | 0 | intra_sf->prune_luma_odd_delta_angles_in_intra = 0; |
2162 | 0 | } |
2163 | | |
2164 | 0 | static inline void init_tx_sf(TX_SPEED_FEATURES *tx_sf) { |
2165 | 0 | tx_sf->inter_tx_size_search_init_depth_sqr = 0; |
2166 | 0 | tx_sf->inter_tx_size_search_init_depth_rect = 0; |
2167 | 0 | tx_sf->intra_tx_size_search_init_depth_rect = 0; |
2168 | 0 | tx_sf->intra_tx_size_search_init_depth_sqr = 0; |
2169 | 0 | tx_sf->tx_size_search_lgr_block = 0; |
2170 | 0 | tx_sf->model_based_prune_tx_search_level = 0; |
2171 | 0 | tx_sf->tx_type_search.prune_2d_txfm_mode = TX_TYPE_PRUNE_1; |
2172 | 0 | tx_sf->tx_type_search.ml_tx_split_thresh = 8500; |
2173 | 0 | tx_sf->tx_type_search.use_skip_flag_prediction = 1; |
2174 | 0 | tx_sf->tx_type_search.use_reduced_intra_txset = 0; |
2175 | 0 | tx_sf->tx_type_search.fast_intra_tx_type_search = 0; |
2176 | 0 | tx_sf->tx_type_search.fast_inter_tx_type_prob_thresh = INT_MAX; |
2177 | 0 | tx_sf->tx_type_search.skip_tx_search = 0; |
2178 | 0 | tx_sf->tx_type_search.prune_tx_type_using_stats = 0; |
2179 | 0 | tx_sf->tx_type_search.prune_tx_type_est_rd = 0; |
2180 | 0 | tx_sf->tx_type_search.winner_mode_tx_type_pruning = 0; |
2181 | 0 | tx_sf->txb_split_cap = 1; |
2182 | 0 | tx_sf->adaptive_txb_search_level = 0; |
2183 | 0 | tx_sf->refine_fast_tx_search_results = 1; |
2184 | 0 | tx_sf->prune_tx_size_level = 0; |
2185 | 0 | tx_sf->prune_intra_tx_depths_using_nn = false; |
2186 | 0 | tx_sf->use_rd_based_breakout_for_intra_tx_search = false; |
2187 | 0 | } |
2188 | | |
2189 | | static inline void init_rd_sf(RD_CALC_SPEED_FEATURES *rd_sf, |
2190 | 0 | const AV1EncoderConfig *oxcf) { |
2191 | 0 | const int disable_trellis_quant = oxcf->algo_cfg.disable_trellis_quant; |
2192 | 0 | if (disable_trellis_quant == 3) { |
2193 | 0 | rd_sf->optimize_coefficients = !is_lossless_requested(&oxcf->rc_cfg) |
2194 | 0 | ? NO_ESTIMATE_YRD_TRELLIS_OPT |
2195 | 0 | : NO_TRELLIS_OPT; |
2196 | 0 | } else if (disable_trellis_quant == 2) { |
2197 | 0 | rd_sf->optimize_coefficients = !is_lossless_requested(&oxcf->rc_cfg) |
2198 | 0 | ? FINAL_PASS_TRELLIS_OPT |
2199 | 0 | : NO_TRELLIS_OPT; |
2200 | 0 | } else if (disable_trellis_quant == 0) { |
2201 | 0 | if (is_lossless_requested(&oxcf->rc_cfg)) { |
2202 | 0 | rd_sf->optimize_coefficients = NO_TRELLIS_OPT; |
2203 | 0 | } else { |
2204 | 0 | rd_sf->optimize_coefficients = FULL_TRELLIS_OPT; |
2205 | 0 | } |
2206 | 0 | } else if (disable_trellis_quant == 1) { |
2207 | 0 | rd_sf->optimize_coefficients = NO_TRELLIS_OPT; |
2208 | 0 | } else { |
2209 | 0 | assert(0 && "Invalid disable_trellis_quant value"); |
2210 | 0 | } |
2211 | 0 | rd_sf->use_mb_rd_hash = 0; |
2212 | 0 | rd_sf->simple_model_rd_from_var = 0; |
2213 | 0 | rd_sf->tx_domain_dist_level = 0; |
2214 | 0 | rd_sf->tx_domain_dist_thres_level = 0; |
2215 | 0 | rd_sf->perform_coeff_opt = 0; |
2216 | 0 | } |
2217 | | |
2218 | | static inline void init_winner_mode_sf( |
2219 | 0 | WINNER_MODE_SPEED_FEATURES *winner_mode_sf) { |
2220 | 0 | winner_mode_sf->motion_mode_for_winner_cand = 0; |
2221 | | // Set this at the appropriate speed levels |
2222 | 0 | winner_mode_sf->tx_size_search_level = 0; |
2223 | 0 | winner_mode_sf->enable_winner_mode_for_coeff_opt = 0; |
2224 | 0 | winner_mode_sf->enable_winner_mode_for_tx_size_srch = 0; |
2225 | 0 | winner_mode_sf->enable_winner_mode_for_use_tx_domain_dist = 0; |
2226 | 0 | winner_mode_sf->multi_winner_mode_type = 0; |
2227 | 0 | winner_mode_sf->dc_blk_pred_level = 0; |
2228 | 0 | winner_mode_sf->winner_mode_ifs = 0; |
2229 | 0 | winner_mode_sf->prune_winner_mode_eval_level = 0; |
2230 | 0 | } |
2231 | | |
2232 | 0 | static inline void init_lpf_sf(LOOP_FILTER_SPEED_FEATURES *lpf_sf) { |
2233 | 0 | lpf_sf->disable_loop_restoration_chroma = 0; |
2234 | 0 | lpf_sf->disable_loop_restoration_luma = 0; |
2235 | 0 | lpf_sf->min_lr_unit_size = RESTORATION_PROC_UNIT_SIZE; |
2236 | 0 | lpf_sf->max_lr_unit_size = RESTORATION_UNITSIZE_MAX; |
2237 | 0 | lpf_sf->prune_wiener_based_on_src_var = 0; |
2238 | 0 | lpf_sf->prune_sgr_based_on_wiener = 0; |
2239 | 0 | lpf_sf->enable_sgr_ep_pruning = 0; |
2240 | 0 | lpf_sf->reduce_wiener_window_size = 0; |
2241 | 0 | lpf_sf->lpf_pick = LPF_PICK_FROM_FULL_IMAGE; |
2242 | 0 | lpf_sf->use_coarse_filter_level_search = 0; |
2243 | 0 | lpf_sf->cdef_pick_method = CDEF_FULL_SEARCH; |
2244 | | // Set decoder side speed feature to use less dual sgr modes |
2245 | 0 | lpf_sf->dual_sgr_penalty_level = 0; |
2246 | | // Enable Wiener and Self-guided Loop restoration filters by default. |
2247 | 0 | lpf_sf->disable_wiener_filter = false; |
2248 | 0 | lpf_sf->disable_sgr_filter = false; |
2249 | 0 | lpf_sf->disable_wiener_coeff_refine_search = false; |
2250 | 0 | lpf_sf->use_downsampled_wiener_stats = 0; |
2251 | 0 | } |
2252 | | |
2253 | 0 | static inline void init_rt_sf(REAL_TIME_SPEED_FEATURES *rt_sf) { |
2254 | 0 | rt_sf->check_intra_pred_nonrd = 0; |
2255 | 0 | rt_sf->skip_intra_pred = 0; |
2256 | 0 | rt_sf->estimate_motion_for_var_based_partition = 0; |
2257 | 0 | rt_sf->nonrd_check_partition_merge_mode = 0; |
2258 | 0 | rt_sf->nonrd_check_partition_split = 0; |
2259 | 0 | rt_sf->mode_search_skip_flags = 0; |
2260 | 0 | rt_sf->nonrd_prune_ref_frame_search = 0; |
2261 | 0 | rt_sf->use_nonrd_pick_mode = 0; |
2262 | 0 | rt_sf->use_nonrd_altref_frame = 0; |
2263 | 0 | rt_sf->use_comp_ref_nonrd = 0; |
2264 | 0 | rt_sf->use_real_time_ref_set = 0; |
2265 | 0 | rt_sf->short_circuit_low_temp_var = 0; |
2266 | 0 | rt_sf->reuse_inter_pred_nonrd = 0; |
2267 | 0 | rt_sf->num_inter_modes_for_tx_search = INT_MAX; |
2268 | 0 | rt_sf->use_nonrd_filter_search = 0; |
2269 | 0 | rt_sf->use_simple_rd_model = 0; |
2270 | 0 | rt_sf->hybrid_intra_pickmode = 0; |
2271 | 0 | rt_sf->prune_palette_search_nonrd = 0; |
2272 | 0 | rt_sf->source_metrics_sb_nonrd = 0; |
2273 | 0 | rt_sf->overshoot_detection_cbr = NO_DETECTION; |
2274 | 0 | rt_sf->check_scene_detection = 0; |
2275 | 0 | rt_sf->rc_adjust_keyframe = 0; |
2276 | 0 | rt_sf->rc_compute_spatial_var_sc = 0; |
2277 | 0 | rt_sf->prefer_large_partition_blocks = 0; |
2278 | 0 | rt_sf->use_temporal_noise_estimate = 0; |
2279 | 0 | rt_sf->fullpel_search_step_param = 0; |
2280 | 0 | for (int i = 0; i < BLOCK_SIZES; ++i) |
2281 | 0 | rt_sf->intra_y_mode_bsize_mask_nrd[i] = INTRA_ALL; |
2282 | 0 | rt_sf->prune_hv_pred_modes_using_src_sad = false; |
2283 | 0 | rt_sf->nonrd_aggressive_skip = 0; |
2284 | 0 | rt_sf->skip_cdef_sb = 0; |
2285 | 0 | rt_sf->force_large_partition_blocks_intra = 0; |
2286 | 0 | rt_sf->skip_tx_no_split_var_based_partition = 0; |
2287 | 0 | rt_sf->skip_newmv_mode_based_on_sse = 0; |
2288 | 0 | rt_sf->gf_length_lvl = 0; |
2289 | 0 | rt_sf->prune_inter_modes_with_golden_ref = 0; |
2290 | 0 | rt_sf->prune_inter_modes_wrt_gf_arf_based_on_sad = 0; |
2291 | 0 | rt_sf->prune_inter_modes_using_temp_var = 0; |
2292 | 0 | rt_sf->reduce_mv_pel_precision_highmotion = 0; |
2293 | 0 | rt_sf->reduce_mv_pel_precision_lowcomplex = 0; |
2294 | 0 | rt_sf->prune_intra_mode_based_on_mv_range = 0; |
2295 | 0 | rt_sf->var_part_split_threshold_shift = 7; |
2296 | 0 | rt_sf->gf_refresh_based_on_qp = 0; |
2297 | 0 | rt_sf->use_rtc_tf = 0; |
2298 | 0 | rt_sf->use_idtx_nonrd = 0; |
2299 | 0 | rt_sf->prune_idtx_nonrd = 0; |
2300 | 0 | rt_sf->dct_only_palette_nonrd = 0; |
2301 | 0 | rt_sf->part_early_exit_zeromv = 0; |
2302 | 0 | rt_sf->sse_early_term_inter_search = EARLY_TERM_DISABLED; |
2303 | 0 | rt_sf->skip_lf_screen = 0; |
2304 | 0 | rt_sf->thresh_active_maps_skip_lf_cdef = 100; |
2305 | 0 | rt_sf->sad_based_adp_altref_lag = 0; |
2306 | 0 | rt_sf->partition_direct_merging = 0; |
2307 | 0 | rt_sf->var_part_based_on_qidx = 0; |
2308 | 0 | rt_sf->tx_size_level_based_on_qstep = 0; |
2309 | 0 | rt_sf->vbp_prune_16x16_split_using_min_max_sub_blk_var = false; |
2310 | 0 | rt_sf->prune_compoundmode_with_singlecompound_var = false; |
2311 | 0 | rt_sf->frame_level_mode_cost_update = false; |
2312 | 0 | rt_sf->prune_h_pred_using_best_mode_so_far = false; |
2313 | 0 | rt_sf->enable_intra_mode_pruning_using_neighbors = false; |
2314 | 0 | rt_sf->prune_intra_mode_using_best_sad_so_far = false; |
2315 | 0 | rt_sf->check_only_zero_zeromv_on_large_blocks = false; |
2316 | 0 | rt_sf->disable_cdf_update_non_reference_frame = false; |
2317 | 0 | rt_sf->prune_compoundmode_with_singlemode_var = false; |
2318 | 0 | rt_sf->skip_compound_based_on_var = false; |
2319 | 0 | rt_sf->set_zeromv_skip_based_on_source_sad = 1; |
2320 | 0 | rt_sf->use_adaptive_subpel_search = false; |
2321 | 0 | rt_sf->screen_content_cdef_filter_qindex_thresh = 0; |
2322 | 0 | rt_sf->enable_ref_short_signaling = false; |
2323 | 0 | rt_sf->check_globalmv_on_single_ref = true; |
2324 | 0 | rt_sf->increase_color_thresh_palette = false; |
2325 | 0 | rt_sf->selective_cdf_update = 0; |
2326 | 0 | rt_sf->force_only_last_ref = 0; |
2327 | 0 | rt_sf->higher_thresh_scene_detection = 1; |
2328 | 0 | rt_sf->skip_newmv_flat_blocks_screen = 0; |
2329 | 0 | rt_sf->skip_encoding_non_reference_slide_change = 0; |
2330 | 0 | rt_sf->rc_faster_convergence_static = 0; |
2331 | 0 | } |
2332 | | |
2333 | | static fractional_mv_step_fp |
2334 | | *const fractional_mv_search[SUBPEL_SEARCH_METHODS] = { |
2335 | | av1_find_best_sub_pixel_tree, // SUBPEL_TREE = 0 |
2336 | | av1_find_best_sub_pixel_tree_pruned, // SUBPEL_TREE_PRUNED = 1 |
2337 | | av1_find_best_sub_pixel_tree_pruned_more // SUBPEL_TREE_PRUNED_MORE = 2 |
2338 | | }; |
2339 | | |
2340 | | // Populate appropriate sub-pel search method based on speed feature and user |
2341 | | // specified settings |
2342 | | static void set_subpel_search_method( |
2343 | | MotionVectorSearchParams *mv_search_params, |
2344 | | unsigned int motion_vector_unit_test, |
2345 | 0 | SUBPEL_SEARCH_METHOD subpel_search_method) { |
2346 | 0 | assert(subpel_search_method <= SUBPEL_TREE_PRUNED_MORE); |
2347 | 0 | mv_search_params->find_fractional_mv_step = |
2348 | 0 | fractional_mv_search[subpel_search_method]; |
2349 | | |
2350 | | // This is only used in motion vector unit test. |
2351 | 0 | if (motion_vector_unit_test == 1) |
2352 | 0 | mv_search_params->find_fractional_mv_step = av1_return_max_sub_pixel_mv; |
2353 | 0 | else if (motion_vector_unit_test == 2) |
2354 | 0 | mv_search_params->find_fractional_mv_step = av1_return_min_sub_pixel_mv; |
2355 | 0 | } |
2356 | | |
2357 | 0 | void av1_set_speed_features_framesize_dependent(AV1_COMP *cpi, int speed) { |
2358 | 0 | SPEED_FEATURES *const sf = &cpi->sf; |
2359 | 0 | const AV1EncoderConfig *const oxcf = &cpi->oxcf; |
2360 | |
|
2361 | 0 | switch (oxcf->mode) { |
2362 | 0 | case GOOD: |
2363 | 0 | set_good_speed_feature_framesize_dependent(cpi, sf, speed); |
2364 | 0 | break; |
2365 | 0 | case ALLINTRA: |
2366 | 0 | set_allintra_speed_feature_framesize_dependent(cpi, sf, speed); |
2367 | 0 | break; |
2368 | 0 | case REALTIME: |
2369 | 0 | set_rt_speed_feature_framesize_dependent(cpi, sf, speed); |
2370 | 0 | break; |
2371 | 0 | } |
2372 | | |
2373 | 0 | if (!cpi->ppi->seq_params_locked) { |
2374 | 0 | cpi->common.seq_params->enable_masked_compound &= |
2375 | 0 | !sf->inter_sf.disable_masked_comp; |
2376 | 0 | cpi->common.seq_params->enable_interintra_compound &= |
2377 | 0 | (sf->inter_sf.disable_interintra_wedge_var_thresh != UINT_MAX); |
2378 | 0 | } |
2379 | |
|
2380 | 0 | set_subpel_search_method(&cpi->mv_search_params, |
2381 | 0 | cpi->oxcf.unit_test_cfg.motion_vector_unit_test, |
2382 | 0 | sf->mv_sf.subpel_search_method); |
2383 | | |
2384 | | // For multi-thread use case with row_mt enabled, cost update for a set of |
2385 | | // SB rows is not desirable. Hence, the sf mv_cost_upd_level is set to |
2386 | | // INTERNAL_COST_UPD_SBROW in such cases. |
2387 | 0 | if ((cpi->oxcf.row_mt == 1) && (cpi->mt_info.num_workers > 1)) { |
2388 | 0 | if (sf->inter_sf.mv_cost_upd_level == INTERNAL_COST_UPD_SBROW_SET) { |
2389 | | // Set mv_cost_upd_level to use row level update. |
2390 | 0 | sf->inter_sf.mv_cost_upd_level = INTERNAL_COST_UPD_SBROW; |
2391 | 0 | } |
2392 | 0 | } |
2393 | 0 | } |
2394 | | |
2395 | 0 | void av1_set_speed_features_framesize_independent(AV1_COMP *cpi, int speed) { |
2396 | 0 | SPEED_FEATURES *const sf = &cpi->sf; |
2397 | 0 | WinnerModeParams *const winner_mode_params = &cpi->winner_mode_params; |
2398 | 0 | const AV1EncoderConfig *const oxcf = &cpi->oxcf; |
2399 | 0 | int i; |
2400 | |
|
2401 | 0 | init_hl_sf(&sf->hl_sf); |
2402 | 0 | init_fp_sf(&sf->fp_sf); |
2403 | 0 | init_tpl_sf(&sf->tpl_sf); |
2404 | 0 | init_gm_sf(&sf->gm_sf); |
2405 | 0 | init_part_sf(&sf->part_sf); |
2406 | 0 | init_mv_sf(&sf->mv_sf); |
2407 | 0 | init_inter_sf(&sf->inter_sf); |
2408 | 0 | init_interp_sf(&sf->interp_sf); |
2409 | 0 | init_intra_sf(&sf->intra_sf); |
2410 | 0 | init_tx_sf(&sf->tx_sf); |
2411 | 0 | init_rd_sf(&sf->rd_sf, oxcf); |
2412 | 0 | init_winner_mode_sf(&sf->winner_mode_sf); |
2413 | 0 | init_lpf_sf(&sf->lpf_sf); |
2414 | 0 | init_rt_sf(&sf->rt_sf); |
2415 | |
|
2416 | 0 | switch (oxcf->mode) { |
2417 | 0 | case GOOD: |
2418 | 0 | set_good_speed_features_framesize_independent(cpi, sf, speed); |
2419 | 0 | break; |
2420 | 0 | case ALLINTRA: |
2421 | 0 | set_allintra_speed_features_framesize_independent(cpi, sf, speed); |
2422 | 0 | break; |
2423 | 0 | case REALTIME: |
2424 | 0 | set_rt_speed_features_framesize_independent(cpi, sf, speed); |
2425 | 0 | break; |
2426 | 0 | } |
2427 | | |
2428 | | // Note: when use_nonrd_pick_mode is true, the transform size is the |
2429 | | // minimum of 16x16 and the largest possible size of the current block, |
2430 | | // which conflicts with the speed feature "enable_tx_size_search". |
2431 | 0 | if (!oxcf->txfm_cfg.enable_tx_size_search && |
2432 | 0 | sf->rt_sf.use_nonrd_pick_mode == 0) { |
2433 | 0 | sf->winner_mode_sf.tx_size_search_level = 3; |
2434 | 0 | } |
2435 | |
|
2436 | 0 | if (cpi->mt_info.num_workers > 1) { |
2437 | | // Loop restoration stage is conditionally disabled for speed 5, 6 when |
2438 | | // num_workers > 1. Since av1_pick_filter_restoration() is not |
2439 | | // multi-threaded, enabling the Loop restoration stage will cause an |
2440 | | // increase in encode time (3% to 7% increase depends on frame |
2441 | | // resolution). |
2442 | | // TODO(aomedia:3446): Implement multi-threading of |
2443 | | // av1_pick_filter_restoration() and enable Wiener filter for speed 5, 6 |
2444 | | // similar to single thread encoding path. |
2445 | 0 | if (speed >= 5) { |
2446 | 0 | sf->lpf_sf.disable_sgr_filter = true; |
2447 | 0 | sf->lpf_sf.disable_wiener_filter = true; |
2448 | 0 | } |
2449 | 0 | } |
2450 | |
|
2451 | 0 | if (!cpi->ppi->seq_params_locked) { |
2452 | 0 | cpi->common.seq_params->order_hint_info.enable_dist_wtd_comp &= |
2453 | 0 | (sf->inter_sf.use_dist_wtd_comp_flag != DIST_WTD_COMP_DISABLED); |
2454 | 0 | cpi->common.seq_params->enable_dual_filter &= |
2455 | 0 | !sf->interp_sf.disable_dual_filter; |
2456 | | // Set the flag 'enable_restoration', if one the Loop restoration filters |
2457 | | // (i.e., Wiener or Self-guided) is enabled. |
2458 | 0 | cpi->common.seq_params->enable_restoration &= |
2459 | 0 | (!sf->lpf_sf.disable_wiener_filter || !sf->lpf_sf.disable_sgr_filter); |
2460 | |
|
2461 | 0 | cpi->common.seq_params->enable_interintra_compound &= |
2462 | 0 | (sf->inter_sf.disable_interintra_wedge_var_thresh != UINT_MAX); |
2463 | 0 | } |
2464 | |
|
2465 | 0 | const int mesh_speed = AOMMIN(speed, MAX_MESH_SPEED); |
2466 | 0 | for (i = 0; i < MAX_MESH_STEP; ++i) { |
2467 | 0 | sf->mv_sf.mesh_patterns[i].range = |
2468 | 0 | good_quality_mesh_patterns[mesh_speed][i].range; |
2469 | 0 | sf->mv_sf.mesh_patterns[i].interval = |
2470 | 0 | good_quality_mesh_patterns[mesh_speed][i].interval; |
2471 | 0 | } |
2472 | | |
2473 | | // Update the mesh pattern of exhaustive motion search for intraBC |
2474 | | // Though intraBC mesh pattern is populated for all frame types, it is used |
2475 | | // only for intra frames of screen contents |
2476 | 0 | for (i = 0; i < MAX_MESH_STEP; ++i) { |
2477 | 0 | sf->mv_sf.intrabc_mesh_patterns[i].range = |
2478 | 0 | intrabc_mesh_patterns[mesh_speed][i].range; |
2479 | 0 | sf->mv_sf.intrabc_mesh_patterns[i].interval = |
2480 | 0 | intrabc_mesh_patterns[mesh_speed][i].interval; |
2481 | 0 | } |
2482 | | |
2483 | | // Slow quant, dct and trellis not worthwhile for first pass |
2484 | | // so make sure they are always turned off. |
2485 | 0 | if (is_stat_generation_stage(cpi)) |
2486 | 0 | sf->rd_sf.optimize_coefficients = NO_TRELLIS_OPT; |
2487 | | |
2488 | | // No recode for 1 pass. |
2489 | 0 | if (oxcf->pass == AOM_RC_ONE_PASS && has_no_stats_stage(cpi)) |
2490 | 0 | sf->hl_sf.recode_loop = DISALLOW_RECODE; |
2491 | |
|
2492 | 0 | set_subpel_search_method(&cpi->mv_search_params, |
2493 | 0 | cpi->oxcf.unit_test_cfg.motion_vector_unit_test, |
2494 | 0 | sf->mv_sf.subpel_search_method); |
2495 | | |
2496 | | // assert ensures that tx_domain_dist_level is accessed correctly |
2497 | 0 | assert(cpi->sf.rd_sf.tx_domain_dist_thres_level >= 0 && |
2498 | 0 | cpi->sf.rd_sf.tx_domain_dist_thres_level < 4); |
2499 | 0 | memcpy(winner_mode_params->tx_domain_dist_threshold, |
2500 | 0 | tx_domain_dist_thresholds[cpi->sf.rd_sf.tx_domain_dist_thres_level], |
2501 | 0 | sizeof(winner_mode_params->tx_domain_dist_threshold)); |
2502 | |
|
2503 | 0 | assert(cpi->sf.rd_sf.tx_domain_dist_level >= 0 && |
2504 | 0 | cpi->sf.rd_sf.tx_domain_dist_level < TX_DOMAIN_DIST_LEVELS); |
2505 | 0 | memcpy(winner_mode_params->use_transform_domain_distortion, |
2506 | 0 | tx_domain_dist_types[cpi->sf.rd_sf.tx_domain_dist_level], |
2507 | 0 | sizeof(winner_mode_params->use_transform_domain_distortion)); |
2508 | | |
2509 | | // assert ensures that coeff_opt_thresholds is accessed correctly |
2510 | 0 | assert(cpi->sf.rd_sf.perform_coeff_opt >= 0 && |
2511 | 0 | cpi->sf.rd_sf.perform_coeff_opt < 9); |
2512 | 0 | memcpy(winner_mode_params->coeff_opt_thresholds, |
2513 | 0 | &coeff_opt_thresholds[cpi->sf.rd_sf.perform_coeff_opt], |
2514 | 0 | sizeof(winner_mode_params->coeff_opt_thresholds)); |
2515 | | |
2516 | | // assert ensures that predict_skip_levels is accessed correctly |
2517 | 0 | assert(cpi->sf.tx_sf.tx_type_search.use_skip_flag_prediction >= 0 && |
2518 | 0 | cpi->sf.tx_sf.tx_type_search.use_skip_flag_prediction < 3); |
2519 | 0 | memcpy(winner_mode_params->skip_txfm_level, |
2520 | 0 | predict_skip_levels[cpi->sf.tx_sf.tx_type_search |
2521 | 0 | .use_skip_flag_prediction], |
2522 | 0 | sizeof(winner_mode_params->skip_txfm_level)); |
2523 | | |
2524 | | // assert ensures that tx_size_search_level is accessed correctly |
2525 | 0 | assert(cpi->sf.winner_mode_sf.tx_size_search_level >= 0 && |
2526 | 0 | cpi->sf.winner_mode_sf.tx_size_search_level <= 3); |
2527 | 0 | memcpy(winner_mode_params->tx_size_search_methods, |
2528 | 0 | tx_size_search_methods[cpi->sf.winner_mode_sf.tx_size_search_level], |
2529 | 0 | sizeof(winner_mode_params->tx_size_search_methods)); |
2530 | 0 | memcpy(winner_mode_params->predict_dc_level, |
2531 | 0 | predict_dc_levels[cpi->sf.winner_mode_sf.dc_blk_pred_level], |
2532 | 0 | sizeof(winner_mode_params->predict_dc_level)); |
2533 | |
|
2534 | 0 | if (cpi->oxcf.row_mt == 1 && (cpi->mt_info.num_workers > 1)) { |
2535 | 0 | if (sf->inter_sf.inter_mode_rd_model_estimation == 1) { |
2536 | | // Revert to type 2 |
2537 | 0 | sf->inter_sf.inter_mode_rd_model_estimation = 2; |
2538 | 0 | } |
2539 | |
|
2540 | 0 | #if !CONFIG_FPMT_TEST |
2541 | | // Disable the speed feature 'prune_ref_frame_for_gm_search' to achieve |
2542 | | // better parallelism when number of threads available are greater than or |
2543 | | // equal to maximum number of reference frames allowed for global motion. |
2544 | 0 | if (sf->gm_sf.gm_search_type != GM_DISABLE_SEARCH && |
2545 | 0 | (cpi->mt_info.num_workers >= |
2546 | 0 | gm_available_reference_frames[sf->gm_sf.gm_search_type])) |
2547 | 0 | sf->gm_sf.prune_ref_frame_for_gm_search = 0; |
2548 | 0 | #endif |
2549 | 0 | } |
2550 | | |
2551 | | // This only applies to the real time mode. Adaptive gf refresh is disabled if |
2552 | | // gf_cbr_boost_pct that is set by the user is larger than 0. |
2553 | 0 | if (cpi->oxcf.rc_cfg.gf_cbr_boost_pct > 0) |
2554 | 0 | sf->rt_sf.gf_refresh_based_on_qp = 0; |
2555 | 0 | } |
2556 | | |
2557 | | // Override some speed features based on qindex |
2558 | 0 | void av1_set_speed_features_qindex_dependent(AV1_COMP *cpi, int speed) { |
2559 | 0 | AV1_COMMON *const cm = &cpi->common; |
2560 | 0 | SPEED_FEATURES *const sf = &cpi->sf; |
2561 | 0 | WinnerModeParams *const winner_mode_params = &cpi->winner_mode_params; |
2562 | 0 | const int boosted = frame_is_boosted(cpi); |
2563 | 0 | const int is_480p_or_lesser = AOMMIN(cm->width, cm->height) <= 480; |
2564 | 0 | const int is_480p_or_larger = AOMMIN(cm->width, cm->height) >= 480; |
2565 | 0 | const int is_720p_or_larger = AOMMIN(cm->width, cm->height) >= 720; |
2566 | 0 | const int is_1080p_or_larger = AOMMIN(cm->width, cm->height) >= 1080; |
2567 | 0 | const int is_1440p_or_larger = AOMMIN(cm->width, cm->height) >= 1440; |
2568 | 0 | const int is_arf2_bwd_type = |
2569 | 0 | cpi->ppi->gf_group.update_type[cpi->gf_frame_index] == INTNL_ARF_UPDATE; |
2570 | |
|
2571 | 0 | if (cpi->oxcf.mode == REALTIME) { |
2572 | 0 | if (speed >= 6) { |
2573 | 0 | const int qindex_thresh = boosted ? 190 : (is_720p_or_larger ? 120 : 150); |
2574 | 0 | sf->part_sf.adjust_var_based_rd_partitioning = |
2575 | 0 | frame_is_intra_only(cm) |
2576 | 0 | ? 0 |
2577 | 0 | : cm->quant_params.base_qindex > qindex_thresh; |
2578 | 0 | } |
2579 | 0 | return; |
2580 | 0 | } |
2581 | | |
2582 | 0 | if (speed == 0) { |
2583 | | // qindex_thresh for resolution < 720p |
2584 | 0 | const int qindex_thresh = boosted ? 70 : (is_arf2_bwd_type ? 110 : 140); |
2585 | 0 | if (!is_720p_or_larger && cm->quant_params.base_qindex <= qindex_thresh) { |
2586 | 0 | sf->part_sf.simple_motion_search_split = |
2587 | 0 | cm->features.allow_screen_content_tools ? 1 : 2; |
2588 | 0 | sf->part_sf.simple_motion_search_early_term_none = 1; |
2589 | 0 | sf->tx_sf.model_based_prune_tx_search_level = 0; |
2590 | 0 | } |
2591 | |
|
2592 | 0 | if (is_720p_or_larger && cm->quant_params.base_qindex <= 128) { |
2593 | 0 | sf->rd_sf.perform_coeff_opt = 2 + is_1080p_or_larger; |
2594 | 0 | memcpy(winner_mode_params->coeff_opt_thresholds, |
2595 | 0 | &coeff_opt_thresholds[sf->rd_sf.perform_coeff_opt], |
2596 | 0 | sizeof(winner_mode_params->coeff_opt_thresholds)); |
2597 | 0 | sf->part_sf.simple_motion_search_split = |
2598 | 0 | cm->features.allow_screen_content_tools ? 1 : 2; |
2599 | 0 | sf->tx_sf.inter_tx_size_search_init_depth_rect = 1; |
2600 | 0 | sf->tx_sf.inter_tx_size_search_init_depth_sqr = 1; |
2601 | 0 | sf->tx_sf.intra_tx_size_search_init_depth_rect = 1; |
2602 | 0 | sf->tx_sf.model_based_prune_tx_search_level = 0; |
2603 | |
|
2604 | 0 | if (is_1080p_or_larger && cm->quant_params.base_qindex <= 108) { |
2605 | 0 | sf->inter_sf.selective_ref_frame = 2; |
2606 | 0 | sf->rd_sf.tx_domain_dist_level = boosted ? 1 : 2; |
2607 | 0 | sf->rd_sf.tx_domain_dist_thres_level = 1; |
2608 | 0 | sf->part_sf.simple_motion_search_early_term_none = 1; |
2609 | 0 | sf->tx_sf.tx_type_search.ml_tx_split_thresh = 4000; |
2610 | 0 | sf->interp_sf.cb_pred_filter_search = 0; |
2611 | 0 | sf->tx_sf.tx_type_search.prune_2d_txfm_mode = TX_TYPE_PRUNE_2; |
2612 | 0 | sf->tx_sf.tx_type_search.skip_tx_search = 1; |
2613 | 0 | } |
2614 | 0 | } |
2615 | 0 | } |
2616 | |
|
2617 | 0 | if (speed >= 2) { |
2618 | | // Disable extended partitions for lower quantizers |
2619 | 0 | const int aggr = AOMMIN(4, speed - 2); |
2620 | 0 | const int qindex_thresh1[4] = { 50, 50, 80, 100 }; |
2621 | 0 | const int qindex_thresh2[4] = { 80, 100, 120, 160 }; |
2622 | 0 | int qindex_thresh; |
2623 | 0 | if (aggr <= 1) { |
2624 | 0 | const int qthresh2 = |
2625 | 0 | (!aggr && !is_480p_or_larger) ? 70 : qindex_thresh2[aggr]; |
2626 | 0 | qindex_thresh = cm->features.allow_screen_content_tools |
2627 | 0 | ? qindex_thresh1[aggr] |
2628 | 0 | : qthresh2; |
2629 | 0 | if (cm->quant_params.base_qindex <= qindex_thresh && !boosted) |
2630 | 0 | sf->part_sf.ext_partition_eval_thresh = BLOCK_128X128; |
2631 | 0 | } else if (aggr <= 2) { |
2632 | 0 | qindex_thresh = boosted ? qindex_thresh1[aggr] : qindex_thresh2[aggr]; |
2633 | 0 | if (cm->quant_params.base_qindex <= qindex_thresh && |
2634 | 0 | !frame_is_intra_only(cm)) |
2635 | 0 | sf->part_sf.ext_partition_eval_thresh = BLOCK_128X128; |
2636 | 0 | } else if (aggr <= 3) { |
2637 | 0 | if (!is_480p_or_larger) { |
2638 | 0 | sf->part_sf.ext_partition_eval_thresh = BLOCK_128X128; |
2639 | 0 | } else if (!is_720p_or_larger && !frame_is_intra_only(cm) && |
2640 | 0 | !cm->features.allow_screen_content_tools) { |
2641 | 0 | sf->part_sf.ext_partition_eval_thresh = BLOCK_128X128; |
2642 | 0 | } else { |
2643 | 0 | qindex_thresh = boosted ? qindex_thresh1[aggr] : qindex_thresh2[aggr]; |
2644 | 0 | if (cm->quant_params.base_qindex <= qindex_thresh && |
2645 | 0 | !frame_is_intra_only(cm)) |
2646 | 0 | sf->part_sf.ext_partition_eval_thresh = BLOCK_128X128; |
2647 | 0 | } |
2648 | 0 | } else { |
2649 | 0 | sf->part_sf.ext_partition_eval_thresh = BLOCK_128X128; |
2650 | 0 | } |
2651 | 0 | } |
2652 | |
|
2653 | 0 | if (speed >= 4) { |
2654 | | // Disable rectangular partitions for lower quantizers |
2655 | 0 | const int aggr = AOMMIN(1, speed - 4); |
2656 | 0 | const int qindex_thresh[2] = { 65, 80 }; |
2657 | 0 | int disable_rect_part; |
2658 | 0 | disable_rect_part = !boosted; |
2659 | 0 | if (cm->quant_params.base_qindex <= qindex_thresh[aggr] && |
2660 | 0 | disable_rect_part && is_480p_or_larger) { |
2661 | 0 | sf->part_sf.rect_partition_eval_thresh = BLOCK_8X8; |
2662 | 0 | } |
2663 | 0 | } |
2664 | |
|
2665 | 0 | if (speed <= 2) { |
2666 | 0 | if (!is_stat_generation_stage(cpi)) { |
2667 | | // Use faster full-pel motion search for high quantizers. |
2668 | | // Also use reduced total search range for low resolutions at high |
2669 | | // quantizers. |
2670 | 0 | const int aggr = speed; |
2671 | 0 | const int qindex_thresh1 = ms_qindex_thresh[aggr][is_720p_or_larger][0]; |
2672 | 0 | const int qindex_thresh2 = ms_qindex_thresh[aggr][is_720p_or_larger][1]; |
2673 | 0 | const SEARCH_METHODS search_method = |
2674 | 0 | motion_search_method[is_720p_or_larger]; |
2675 | 0 | if (cm->quant_params.base_qindex > qindex_thresh1) { |
2676 | 0 | sf->mv_sf.search_method = search_method; |
2677 | 0 | sf->tpl_sf.search_method = search_method; |
2678 | 0 | } else if (cm->quant_params.base_qindex > qindex_thresh2) { |
2679 | 0 | sf->mv_sf.search_method = NSTEP_8PT; |
2680 | 0 | } |
2681 | 0 | } |
2682 | 0 | } |
2683 | |
|
2684 | 0 | if (speed >= 4) { |
2685 | | // Disable LR search at low and high quantizers and enable only for |
2686 | | // mid-quantizer range. |
2687 | 0 | if (!boosted && !is_arf2_bwd_type) { |
2688 | 0 | const int qindex_low[2] = { 100, 60 }; |
2689 | 0 | const int qindex_high[2] = { 180, 160 }; |
2690 | 0 | if (cm->quant_params.base_qindex <= qindex_low[is_720p_or_larger] || |
2691 | 0 | cm->quant_params.base_qindex > qindex_high[is_720p_or_larger]) { |
2692 | 0 | sf->lpf_sf.disable_loop_restoration_luma = 1; |
2693 | 0 | } |
2694 | 0 | } |
2695 | 0 | } |
2696 | |
|
2697 | 0 | if (speed == 1) { |
2698 | | // Reuse interinter wedge mask search from first search for non-boosted |
2699 | | // non-internal-arf frames, except at very high quantizers. |
2700 | 0 | if (cm->quant_params.base_qindex <= 200) { |
2701 | 0 | if (!boosted && !is_arf2_bwd_type) |
2702 | 0 | sf->inter_sf.reuse_mask_search_results = 1; |
2703 | 0 | } |
2704 | 0 | } |
2705 | |
|
2706 | 0 | if (speed == 5) { |
2707 | 0 | if (!(frame_is_intra_only(&cpi->common) || |
2708 | 0 | cm->features.allow_screen_content_tools)) { |
2709 | 0 | const int qindex[2] = { 256, 128 }; |
2710 | | // Set the sf value as 3 for low resolution and |
2711 | | // for higher resolutions with low quantizers. |
2712 | 0 | if (cm->quant_params.base_qindex < qindex[is_480p_or_larger]) |
2713 | 0 | sf->tx_sf.tx_type_search.winner_mode_tx_type_pruning = 3; |
2714 | 0 | } |
2715 | 0 | } |
2716 | |
|
2717 | 0 | if (speed >= 5) { |
2718 | | // Disable the sf for low quantizers in case of low resolution screen |
2719 | | // contents. |
2720 | 0 | if (cm->features.allow_screen_content_tools && |
2721 | 0 | cm->quant_params.base_qindex < 128 && is_480p_or_lesser) { |
2722 | 0 | sf->part_sf.prune_sub_8x8_partition_level = 0; |
2723 | 0 | } |
2724 | 0 | } |
2725 | | |
2726 | | // Loop restoration size search |
2727 | | // At speed 0, always search all available sizes for the maximum possible gain |
2728 | 0 | sf->lpf_sf.min_lr_unit_size = RESTORATION_PROC_UNIT_SIZE; |
2729 | 0 | sf->lpf_sf.max_lr_unit_size = RESTORATION_UNITSIZE_MAX; |
2730 | |
|
2731 | 0 | if (speed >= 1) { |
2732 | | // For large frames, small restoration units are almost never useful, |
2733 | | // so prune them away |
2734 | 0 | if (is_1440p_or_larger) { |
2735 | 0 | sf->lpf_sf.min_lr_unit_size = RESTORATION_UNITSIZE_MAX; |
2736 | 0 | } else if (is_720p_or_larger) { |
2737 | 0 | sf->lpf_sf.min_lr_unit_size = RESTORATION_UNITSIZE_MAX >> 1; |
2738 | 0 | } |
2739 | 0 | } |
2740 | |
|
2741 | 0 | if (speed >= 3 || (cpi->oxcf.mode == ALLINTRA && speed >= 1)) { |
2742 | | // At this speed, a full search is too expensive. Instead, pick a single |
2743 | | // size based on size and qindex. Note that, in general, higher quantizers |
2744 | | // (== lower quality) and larger frames generally want to use larger |
2745 | | // restoration units. |
2746 | 0 | int qindex_thresh = 96; |
2747 | 0 | if (cm->quant_params.base_qindex <= qindex_thresh && !is_1440p_or_larger) { |
2748 | 0 | sf->lpf_sf.min_lr_unit_size = RESTORATION_UNITSIZE_MAX >> 1; |
2749 | 0 | sf->lpf_sf.max_lr_unit_size = RESTORATION_UNITSIZE_MAX >> 1; |
2750 | 0 | } else { |
2751 | 0 | sf->lpf_sf.min_lr_unit_size = RESTORATION_UNITSIZE_MAX; |
2752 | 0 | sf->lpf_sf.max_lr_unit_size = RESTORATION_UNITSIZE_MAX; |
2753 | 0 | } |
2754 | 0 | } |
2755 | |
|
2756 | 0 | set_subpel_search_method(&cpi->mv_search_params, |
2757 | 0 | cpi->oxcf.unit_test_cfg.motion_vector_unit_test, |
2758 | 0 | sf->mv_sf.subpel_search_method); |
2759 | 0 | } |