/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 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 MESH_PATTERN intrabc_mesh_patterns[MAX_MESH_SPEED + 1][MAX_MESH_STEP] = { |
38 | | { { 256, 1 }, { 256, 1 }, { 0, 0 }, { 0, 0 } }, |
39 | | { { 256, 1 }, { 256, 1 }, { 0, 0 }, { 0, 0 } }, |
40 | | { { 64, 1 }, { 64, 1 }, { 0, 0 }, { 0, 0 } }, |
41 | | { { 64, 1 }, { 64, 1 }, { 0, 0 }, { 0, 0 } }, |
42 | | { { 64, 4 }, { 16, 1 }, { 0, 0 }, { 0, 0 } }, |
43 | | { { 64, 4 }, { 16, 1 }, { 0, 0 }, { 0, 0 } }, |
44 | | }; |
45 | | |
46 | | // Threshold values to be used for pruning the txfm_domain_distortion |
47 | | // based on block MSE |
48 | | // Index 0: Default mode evaluation, Winner mode processing is not |
49 | | // applicable (Eg : IntraBc). Index 1: Mode evaluation. |
50 | | // Index 2: Winner mode evaluation. Index 1 and 2 are applicable when |
51 | | // enable_winner_mode_for_use_tx_domain_dist speed feature is ON |
52 | | // TODO(any): Experiment the threshold logic based on variance metric |
53 | | static unsigned int tx_domain_dist_thresholds[4][MODE_EVAL_TYPES] = { |
54 | | { UINT_MAX, UINT_MAX, UINT_MAX }, |
55 | | { 22026, 22026, 22026 }, |
56 | | { 1377, 1377, 1377 }, |
57 | | { 0, 0, 0 } |
58 | | }; |
59 | | |
60 | | // Transform domain distortion type to be used for default, mode and winner mode |
61 | | // evaluation Index 0: Default mode evaluation, Winner mode processing is not |
62 | | // applicable (Eg : IntraBc). Index 1: Mode evaluation. Index 2: Winner mode |
63 | | // evaluation. Index 1 and 2 are applicable when |
64 | | // enable_winner_mode_for_use_tx_domain_dist speed feature is ON |
65 | | static unsigned int tx_domain_dist_types[3][MODE_EVAL_TYPES] = { { 0, 2, 0 }, |
66 | | { 1, 2, 0 }, |
67 | | { 2, 2, 0 } }; |
68 | | |
69 | | // Threshold values to be used for disabling coeff RD-optimization |
70 | | // based on block MSE / qstep^2. |
71 | | // TODO(any): Experiment the threshold logic based on variance metric. |
72 | | // Table has satd and dist threshold value index 0 : dist,index 1: satd |
73 | | // For each row, the indices are as follows. |
74 | | // Index 0: Default mode evaluation, Winner mode processing is not applicable |
75 | | // (Eg : IntraBc) |
76 | | // Index 1: Mode evaluation. |
77 | | // Index 2: Winner mode evaluation. |
78 | | // Index 1 and 2 are applicable when enable_winner_mode_for_coeff_opt speed |
79 | | // feature is ON |
80 | | // There are 7 levels with increasing speed, mapping to vertical indices. |
81 | | static unsigned int coeff_opt_thresholds[9][MODE_EVAL_TYPES][2] = { |
82 | | { { UINT_MAX, UINT_MAX }, { UINT_MAX, UINT_MAX }, { UINT_MAX, UINT_MAX } }, |
83 | | { { 3200, UINT_MAX }, { 250, UINT_MAX }, { UINT_MAX, UINT_MAX } }, |
84 | | { { 1728, UINT_MAX }, { 142, UINT_MAX }, { UINT_MAX, UINT_MAX } }, |
85 | | { { 864, UINT_MAX }, { 142, UINT_MAX }, { UINT_MAX, UINT_MAX } }, |
86 | | { { 432, UINT_MAX }, { 86, UINT_MAX }, { UINT_MAX, UINT_MAX } }, |
87 | | { { 864, 97 }, { 142, 16 }, { UINT_MAX, UINT_MAX } }, |
88 | | { { 432, 97 }, { 86, 16 }, { UINT_MAX, UINT_MAX } }, |
89 | | { { 216, 25 }, { 86, 10 }, { UINT_MAX, UINT_MAX } }, |
90 | | { { 216, 25 }, { 0, 10 }, { UINT_MAX, UINT_MAX } } |
91 | | }; |
92 | | |
93 | | // Transform size to be used for default, mode and winner mode evaluation |
94 | | // Index 0: Default mode evaluation, Winner mode processing is not applicable |
95 | | // (Eg : IntraBc) Index 1: Mode evaluation. Index 2: Winner mode evaluation. |
96 | | // Index 1 and 2 are applicable when enable_winner_mode_for_tx_size_srch speed |
97 | | // feature is ON |
98 | | static TX_SIZE_SEARCH_METHOD tx_size_search_methods[4][MODE_EVAL_TYPES] = { |
99 | | { USE_FULL_RD, USE_LARGESTALL, USE_FULL_RD }, |
100 | | { USE_FAST_RD, USE_LARGESTALL, USE_FULL_RD }, |
101 | | { USE_LARGESTALL, USE_LARGESTALL, USE_FULL_RD }, |
102 | | { USE_LARGESTALL, USE_LARGESTALL, USE_LARGESTALL } |
103 | | }; |
104 | | |
105 | | // Predict transform skip levels to be used for default, mode and winner mode |
106 | | // evaluation. Index 0: Default mode evaluation, Winner mode processing is not |
107 | | // applicable. Index 1: Mode evaluation, Index 2: Winner mode evaluation |
108 | | // Values indicate the aggressiveness of skip flag prediction. |
109 | | // 0 : no early skip prediction |
110 | | // 1 : conservative early skip prediction using DCT_DCT |
111 | | // 2 : early skip prediction based on SSE |
112 | | static unsigned int predict_skip_levels[3][MODE_EVAL_TYPES] = { { 0, 0, 0 }, |
113 | | { 1, 1, 1 }, |
114 | | { 1, 2, 1 } }; |
115 | | |
116 | | // Predict DC block levels to be used for default, mode and winner mode |
117 | | // evaluation. Index 0: Default mode evaluation, Winner mode processing is not |
118 | | // applicable. Index 1: Mode evaluation, Index 2: Winner mode evaluation |
119 | | // Values indicate the aggressiveness of skip flag prediction. |
120 | | // 0 : no early DC block prediction |
121 | | // 1 : Early DC block prediction based on error variance |
122 | | static unsigned int predict_dc_levels[3][MODE_EVAL_TYPES] = { { 0, 0, 0 }, |
123 | | { 1, 1, 0 }, |
124 | | { 1, 1, 1 } }; |
125 | | |
126 | | #if !CONFIG_FRAME_PARALLEL_ENCODE || \ |
127 | | (CONFIG_FRAME_PARALLEL_ENCODE && !CONFIG_FPMT_TEST) |
128 | | // This table holds the maximum number of reference frames for global motion. |
129 | | // The table is indexed as per the speed feature 'gm_search_type'. |
130 | | // 0 : All reference frames are allowed. |
131 | | // 1 : All reference frames except L2 and L3 are allowed. |
132 | | // 2 : All reference frames except L2, L3 and ARF2 are allowed. |
133 | | // 3 : No reference frame is allowed. |
134 | | static int gm_available_reference_frames[GM_DISABLE_SEARCH + 1] = { |
135 | | INTER_REFS_PER_FRAME, INTER_REFS_PER_FRAME - 2, INTER_REFS_PER_FRAME - 3, 0 |
136 | | }; |
137 | | #endif |
138 | | |
139 | | // Qindex threshold levels used for selecting full-pel motion search. |
140 | | // ms_qthresh[i][j][k] indicates the qindex boundary value for 'k'th qindex band |
141 | | // for resolution index 'j' for aggressiveness level 'i'. |
142 | | // Aggressiveness increases from i = 0 to 2. |
143 | | // j = 0: lower than 720p resolution, j = 1: 720p or larger resolution. |
144 | | // Currently invoked only for speed 0, 1 and 2. |
145 | | static int ms_qindex_thresh[3][2][2] = { { { 200, 70 }, { MAXQ, 200 } }, |
146 | | { { 170, 50 }, { MAXQ, 200 } }, |
147 | | { { 170, 40 }, { 200, 40 } } }; |
148 | | |
149 | | // Full-pel search methods for aggressive search based on qindex. |
150 | | // Index 0 is for resolutions lower than 720p, index 1 for 720p or larger |
151 | | // resolutions. Currently invoked only for speed 1 and 2. |
152 | | static SEARCH_METHODS motion_search_method[2] = { CLAMPED_DIAMOND, DIAMOND }; |
153 | | |
154 | | // Intra only frames, golden frames (except alt ref overlays) and |
155 | | // alt ref frames tend to be coded at a higher than ambient quality |
156 | 0 | static int frame_is_boosted(const AV1_COMP *cpi) { |
157 | 0 | return frame_is_kf_gf_arf(cpi); |
158 | 0 | } |
159 | | |
160 | | static void set_allintra_speed_feature_framesize_dependent( |
161 | 0 | const AV1_COMP *const cpi, SPEED_FEATURES *const sf, int speed) { |
162 | 0 | const AV1_COMMON *const cm = &cpi->common; |
163 | 0 | const int is_480p_or_larger = AOMMIN(cm->width, cm->height) >= 480; |
164 | 0 | const int is_720p_or_larger = AOMMIN(cm->width, cm->height) >= 720; |
165 | 0 | const int is_1080p_or_larger = AOMMIN(cm->width, cm->height) >= 1080; |
166 | 0 | const int is_4k_or_larger = AOMMIN(cm->width, cm->height) >= 2160; |
167 | 0 | const bool use_hbd = cpi->oxcf.use_highbitdepth; |
168 | |
|
169 | 0 | if (is_480p_or_larger) { |
170 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_128X128; |
171 | 0 | if (is_720p_or_larger) |
172 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = ADAPT_PRED; |
173 | 0 | else |
174 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = RELAXED_PRED; |
175 | 0 | } else { |
176 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_64X64; |
177 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = DIRECT_PRED; |
178 | 0 | if (use_hbd) sf->tx_sf.prune_tx_size_level = 1; |
179 | 0 | } |
180 | |
|
181 | 0 | if (is_4k_or_larger) { |
182 | 0 | sf->part_sf.default_min_partition_size = BLOCK_8X8; |
183 | 0 | } |
184 | | |
185 | | // TODO(huisu@google.com): train models for 720P and above. |
186 | 0 | if (!is_720p_or_larger) { |
187 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[0] = 200; // BLOCK_8X8 |
188 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[1] = 250; // BLOCK_16X16 |
189 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[2] = 300; // BLOCK_32X32 |
190 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[3] = 500; // BLOCK_64X64 |
191 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[4] = -1; // BLOCK_128X128 |
192 | 0 | sf->part_sf.ml_early_term_after_part_split_level = 1; |
193 | 0 | } |
194 | |
|
195 | 0 | if (is_720p_or_larger) { |
196 | | // TODO(chiyotsai@google.com): make this speed feature adaptive based on |
197 | | // current block's vertical texture instead of hardcoded with resolution |
198 | 0 | sf->mv_sf.use_downsampled_sad = 1; |
199 | 0 | } |
200 | |
|
201 | 0 | if (speed >= 1) { |
202 | 0 | if (is_720p_or_larger) { |
203 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_128X128; |
204 | 0 | } else if (is_480p_or_larger) { |
205 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_64X64; |
206 | 0 | } else { |
207 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_32X32; |
208 | 0 | } |
209 | |
|
210 | 0 | if (!is_720p_or_larger) { |
211 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[0] = 200; // BLOCK_8X8 |
212 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[1] = 250; // BLOCK_16X16 |
213 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[2] = 300; // BLOCK_32X32 |
214 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[3] = 300; // BLOCK_64X64 |
215 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[4] = -1; // BLOCK_128X128 |
216 | 0 | } |
217 | 0 | sf->part_sf.ml_early_term_after_part_split_level = 2; |
218 | 0 | } |
219 | |
|
220 | 0 | if (speed >= 2) { |
221 | 0 | if (is_720p_or_larger) { |
222 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_64X64; |
223 | 0 | } else if (is_480p_or_larger) { |
224 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_32X32; |
225 | 0 | } else { |
226 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_32X32; |
227 | 0 | } |
228 | |
|
229 | 0 | if (is_720p_or_larger) { |
230 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 24); |
231 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 120; |
232 | 0 | } else { |
233 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 22); |
234 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 100; |
235 | 0 | } |
236 | |
|
237 | 0 | if (is_480p_or_larger) { |
238 | 0 | sf->tx_sf.tx_type_search.prune_tx_type_using_stats = 1; |
239 | 0 | if (use_hbd) sf->tx_sf.prune_tx_size_level = 2; |
240 | 0 | } else { |
241 | 0 | if (use_hbd) sf->tx_sf.prune_tx_size_level = 3; |
242 | 0 | } |
243 | 0 | } |
244 | |
|
245 | 0 | if (speed >= 3) { |
246 | 0 | sf->part_sf.ml_early_term_after_part_split_level = 0; |
247 | |
|
248 | 0 | if (is_720p_or_larger) { |
249 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 25); |
250 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 200; |
251 | 0 | } else { |
252 | 0 | sf->part_sf.max_intra_bsize = BLOCK_32X32; |
253 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 23); |
254 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 120; |
255 | 0 | } |
256 | 0 | if (use_hbd) sf->tx_sf.prune_tx_size_level = 3; |
257 | 0 | } |
258 | |
|
259 | 0 | if (speed >= 4) { |
260 | 0 | if (is_720p_or_larger) { |
261 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 26); |
262 | 0 | } else { |
263 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 24); |
264 | 0 | } |
265 | |
|
266 | 0 | if (is_480p_or_larger) { |
267 | 0 | sf->tx_sf.tx_type_search.prune_tx_type_using_stats = 2; |
268 | 0 | } |
269 | 0 | } |
270 | |
|
271 | 0 | if (speed >= 6) { |
272 | 0 | if (is_720p_or_larger) { |
273 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = NOT_IN_USE; |
274 | 0 | } else if (is_480p_or_larger) { |
275 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = DIRECT_PRED; |
276 | 0 | } |
277 | |
|
278 | 0 | if (is_1080p_or_larger) { |
279 | 0 | sf->part_sf.default_min_partition_size = BLOCK_8X8; |
280 | 0 | } |
281 | |
|
282 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_16X16; |
283 | 0 | } |
284 | |
|
285 | 0 | if (speed >= 7) { |
286 | | // TODO(kyslov): add more speed features to control speed/quality |
287 | 0 | } |
288 | |
|
289 | 0 | if (speed >= 8) { |
290 | 0 | if (!is_480p_or_larger) { |
291 | 0 | sf->rt_sf.nonrd_check_partition_merge_mode = 2; |
292 | 0 | } |
293 | 0 | if (is_720p_or_larger) { |
294 | 0 | sf->rt_sf.force_large_partition_blocks_intra = 1; |
295 | 0 | } |
296 | 0 | } |
297 | |
|
298 | 0 | if (speed >= 9) { |
299 | | // TODO(kyslov): add more speed features to control speed/quality |
300 | 0 | if (!is_4k_or_larger) { |
301 | 0 | sf->inter_sf.coeff_cost_upd_level = INTERNAL_COST_UPD_OFF; |
302 | 0 | sf->inter_sf.mode_cost_upd_level = INTERNAL_COST_UPD_OFF; |
303 | 0 | } |
304 | 0 | } |
305 | 0 | } |
306 | | |
307 | | static void set_allintra_speed_features_framesize_independent( |
308 | 0 | const AV1_COMP *const cpi, SPEED_FEATURES *const sf, int speed) { |
309 | 0 | const AV1_COMMON *const cm = &cpi->common; |
310 | 0 | const int allow_screen_content_tools = |
311 | 0 | cm->features.allow_screen_content_tools; |
312 | 0 | const int use_hbd = cpi->oxcf.use_highbitdepth; |
313 | |
|
314 | 0 | sf->part_sf.less_rectangular_check_level = 1; |
315 | 0 | sf->part_sf.ml_prune_partition = 1; |
316 | 0 | sf->part_sf.prune_ext_partition_types_search_level = 1; |
317 | 0 | sf->part_sf.prune_part4_search = 2; |
318 | 0 | sf->part_sf.simple_motion_search_prune_rect = 1; |
319 | 0 | sf->part_sf.ml_predict_breakout_level = use_hbd ? 1 : 3; |
320 | 0 | sf->part_sf.reuse_prev_rd_results_for_part_ab = 1; |
321 | 0 | sf->part_sf.use_best_rd_for_pruning = 1; |
322 | |
|
323 | 0 | sf->intra_sf.intra_pruning_with_hog = 1; |
324 | 0 | sf->intra_sf.prune_luma_palette_size_search_level = 1; |
325 | 0 | sf->intra_sf.dv_cost_upd_level = INTERNAL_COST_UPD_OFF; |
326 | 0 | sf->intra_sf.early_term_chroma_palette_size_search = 1; |
327 | |
|
328 | 0 | sf->tx_sf.adaptive_txb_search_level = 1; |
329 | 0 | sf->tx_sf.intra_tx_size_search_init_depth_sqr = 1; |
330 | 0 | sf->tx_sf.model_based_prune_tx_search_level = 1; |
331 | 0 | sf->tx_sf.tx_type_search.use_reduced_intra_txset = 1; |
332 | |
|
333 | 0 | sf->rt_sf.use_nonrd_pick_mode = 0; |
334 | 0 | sf->rt_sf.use_real_time_ref_set = 0; |
335 | |
|
336 | 0 | if (cpi->twopass_frame.fr_content_type == FC_GRAPHICS_ANIMATION || |
337 | 0 | cpi->use_screen_content_tools) { |
338 | 0 | sf->mv_sf.exhaustive_searches_thresh = (1 << 20); |
339 | 0 | } else { |
340 | 0 | sf->mv_sf.exhaustive_searches_thresh = (1 << 25); |
341 | 0 | } |
342 | |
|
343 | 0 | sf->rd_sf.perform_coeff_opt = 1; |
344 | 0 | sf->hl_sf.superres_auto_search_type = SUPERRES_AUTO_DUAL; |
345 | |
|
346 | 0 | if (speed >= 1) { |
347 | 0 | sf->part_sf.intra_cnn_based_part_prune_level = |
348 | 0 | allow_screen_content_tools ? 0 : 2; |
349 | 0 | sf->part_sf.simple_motion_search_early_term_none = 1; |
350 | | // TODO(Venkat): Clean-up frame type dependency for |
351 | | // simple_motion_search_split in partition search function and set the |
352 | | // speed feature accordingly |
353 | 0 | sf->part_sf.simple_motion_search_split = allow_screen_content_tools ? 1 : 2; |
354 | 0 | sf->part_sf.ml_predict_breakout_level = use_hbd ? 2 : 3; |
355 | 0 | sf->part_sf.reuse_best_prediction_for_part_ab = 1; |
356 | |
|
357 | 0 | sf->mv_sf.exhaustive_searches_thresh <<= 1; |
358 | |
|
359 | 0 | sf->intra_sf.prune_palette_search_level = 1; |
360 | 0 | sf->intra_sf.prune_luma_palette_size_search_level = 2; |
361 | 0 | sf->intra_sf.top_intra_model_count_allowed = 3; |
362 | |
|
363 | 0 | sf->tx_sf.adaptive_txb_search_level = 2; |
364 | 0 | sf->tx_sf.inter_tx_size_search_init_depth_rect = 1; |
365 | 0 | sf->tx_sf.inter_tx_size_search_init_depth_sqr = 1; |
366 | 0 | sf->tx_sf.intra_tx_size_search_init_depth_rect = 1; |
367 | 0 | sf->tx_sf.model_based_prune_tx_search_level = 0; |
368 | 0 | sf->tx_sf.tx_type_search.ml_tx_split_thresh = 4000; |
369 | 0 | sf->tx_sf.tx_type_search.prune_2d_txfm_mode = TX_TYPE_PRUNE_2; |
370 | 0 | sf->tx_sf.tx_type_search.skip_tx_search = 1; |
371 | |
|
372 | 0 | sf->rd_sf.perform_coeff_opt = 2; |
373 | 0 | sf->rd_sf.tx_domain_dist_level = 1; |
374 | 0 | sf->rd_sf.tx_domain_dist_thres_level = 1; |
375 | |
|
376 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL1; |
377 | 0 | sf->lpf_sf.dual_sgr_penalty_level = 1; |
378 | 0 | sf->lpf_sf.enable_sgr_ep_pruning = 1; |
379 | 0 | } |
380 | |
|
381 | 0 | if (speed >= 2) { |
382 | 0 | sf->mv_sf.auto_mv_step_size = 1; |
383 | |
|
384 | 0 | sf->intra_sf.disable_smooth_intra = 1; |
385 | 0 | sf->intra_sf.intra_pruning_with_hog = 2; |
386 | 0 | sf->intra_sf.prune_filter_intra_level = 1; |
387 | |
|
388 | 0 | sf->rd_sf.perform_coeff_opt = 3; |
389 | |
|
390 | 0 | sf->lpf_sf.prune_wiener_based_on_src_var = 1; |
391 | 0 | sf->lpf_sf.prune_sgr_based_on_wiener = 1; |
392 | 0 | } |
393 | |
|
394 | 0 | if (speed >= 3) { |
395 | 0 | sf->hl_sf.high_precision_mv_usage = CURRENT_Q; |
396 | 0 | sf->hl_sf.recode_loop = ALLOW_RECODE_KFARFGF; |
397 | |
|
398 | 0 | sf->part_sf.less_rectangular_check_level = 2; |
399 | 0 | sf->part_sf.simple_motion_search_prune_agg = SIMPLE_AGG_LVL1; |
400 | 0 | sf->part_sf.prune_ext_part_using_split_info = 1; |
401 | |
|
402 | 0 | sf->mv_sf.full_pixel_search_level = 1; |
403 | 0 | sf->mv_sf.search_method = DIAMOND; |
404 | | |
405 | | // TODO(chiyotsai@google.com): the thresholds chosen for intra hog are |
406 | | // inherited directly from luma hog with some minor tweaking. Eventually we |
407 | | // should run this with a bayesian optimizer to find the Pareto frontier. |
408 | 0 | sf->intra_sf.chroma_intra_pruning_with_hog = 2; |
409 | 0 | sf->intra_sf.intra_pruning_with_hog = 3; |
410 | 0 | sf->intra_sf.prune_palette_search_level = 2; |
411 | |
|
412 | 0 | sf->tx_sf.adaptive_txb_search_level = 2; |
413 | 0 | sf->tx_sf.tx_type_search.use_skip_flag_prediction = 2; |
414 | | |
415 | | // TODO(any): evaluate if these lpf features can be moved to speed 2. |
416 | | // For screen content, "prune_sgr_based_on_wiener = 2" cause large quality |
417 | | // loss. |
418 | 0 | sf->lpf_sf.prune_sgr_based_on_wiener = allow_screen_content_tools ? 1 : 2; |
419 | 0 | sf->lpf_sf.disable_loop_restoration_chroma = 0; |
420 | 0 | sf->lpf_sf.reduce_wiener_window_size = 1; |
421 | 0 | sf->lpf_sf.prune_wiener_based_on_src_var = 2; |
422 | 0 | } |
423 | |
|
424 | 0 | if (speed >= 4) { |
425 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE; |
426 | |
|
427 | 0 | sf->part_sf.simple_motion_search_prune_agg = SIMPLE_AGG_LVL2; |
428 | 0 | sf->part_sf.simple_motion_search_reduce_search_steps = 4; |
429 | 0 | sf->part_sf.prune_ext_part_using_split_info = 2; |
430 | 0 | sf->part_sf.early_term_after_none_split = 1; |
431 | 0 | sf->part_sf.ml_predict_breakout_level = 3; |
432 | |
|
433 | 0 | sf->intra_sf.prune_chroma_modes_using_luma_winner = 1; |
434 | |
|
435 | 0 | sf->mv_sf.simple_motion_subpel_force_stop = HALF_PEL; |
436 | |
|
437 | 0 | sf->tpl_sf.prune_starting_mv = 2; |
438 | 0 | sf->tpl_sf.subpel_force_stop = HALF_PEL; |
439 | 0 | sf->tpl_sf.search_method = FAST_BIGDIA; |
440 | |
|
441 | 0 | sf->tx_sf.tx_type_search.winner_mode_tx_type_pruning = 2; |
442 | 0 | sf->tx_sf.tx_type_search.fast_intra_tx_type_search = 1; |
443 | 0 | sf->tx_sf.tx_type_search.prune_2d_txfm_mode = TX_TYPE_PRUNE_3; |
444 | 0 | sf->tx_sf.tx_type_search.prune_tx_type_est_rd = 1; |
445 | |
|
446 | 0 | sf->rd_sf.perform_coeff_opt = 5; |
447 | 0 | sf->rd_sf.tx_domain_dist_thres_level = 3; |
448 | |
|
449 | 0 | sf->lpf_sf.lpf_pick = LPF_PICK_FROM_FULL_IMAGE_NON_DUAL; |
450 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL3; |
451 | |
|
452 | 0 | sf->mv_sf.reduce_search_range = 1; |
453 | |
|
454 | 0 | sf->winner_mode_sf.enable_winner_mode_for_coeff_opt = 1; |
455 | 0 | sf->winner_mode_sf.enable_winner_mode_for_use_tx_domain_dist = 1; |
456 | 0 | sf->winner_mode_sf.multi_winner_mode_type = MULTI_WINNER_MODE_DEFAULT; |
457 | 0 | sf->winner_mode_sf.enable_winner_mode_for_tx_size_srch = 1; |
458 | 0 | } |
459 | |
|
460 | 0 | if (speed >= 5) { |
461 | 0 | sf->part_sf.simple_motion_search_prune_agg = SIMPLE_AGG_LVL3; |
462 | 0 | sf->part_sf.ext_partition_eval_thresh = |
463 | 0 | allow_screen_content_tools ? BLOCK_8X8 : BLOCK_16X16; |
464 | 0 | sf->part_sf.intra_cnn_based_part_prune_level = |
465 | 0 | allow_screen_content_tools ? 1 : 2; |
466 | |
|
467 | 0 | sf->intra_sf.chroma_intra_pruning_with_hog = 3; |
468 | |
|
469 | 0 | sf->lpf_sf.use_coarse_filter_level_search = 0; |
470 | 0 | sf->lpf_sf.disable_lr_filter = 1; |
471 | |
|
472 | 0 | sf->mv_sf.prune_mesh_search = PRUNE_MESH_SEARCH_LVL_2; |
473 | |
|
474 | 0 | sf->winner_mode_sf.multi_winner_mode_type = MULTI_WINNER_MODE_FAST; |
475 | 0 | } |
476 | |
|
477 | 0 | if (speed >= 6) { |
478 | 0 | sf->intra_sf.prune_filter_intra_level = 2; |
479 | 0 | sf->intra_sf.chroma_intra_pruning_with_hog = 4; |
480 | 0 | sf->intra_sf.intra_pruning_with_hog = 4; |
481 | 0 | sf->intra_sf.cfl_search_range = 1; |
482 | 0 | sf->intra_sf.top_intra_model_count_allowed = 2; |
483 | 0 | sf->intra_sf.adapt_top_model_rd_count_using_neighbors = 1; |
484 | |
|
485 | 0 | sf->part_sf.prune_rectangular_split_based_on_qidx = |
486 | 0 | allow_screen_content_tools ? 0 : 2; |
487 | 0 | sf->part_sf.prune_sub_8x8_partition_level = |
488 | 0 | allow_screen_content_tools ? 0 : 1; |
489 | 0 | sf->part_sf.prune_part4_search = 3; |
490 | | // TODO(jingning): This might not be a good trade off if the |
491 | | // target image quality is very low. |
492 | 0 | sf->part_sf.default_max_partition_size = BLOCK_32X32; |
493 | |
|
494 | 0 | sf->mv_sf.use_bsize_dependent_search_method = 1; |
495 | |
|
496 | 0 | sf->tx_sf.tx_type_search.winner_mode_tx_type_pruning = 3; |
497 | 0 | sf->tx_sf.tx_type_search.prune_tx_type_est_rd = 0; |
498 | |
|
499 | 0 | sf->rd_sf.perform_coeff_opt = 6; |
500 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL4; |
501 | 0 | sf->lpf_sf.lpf_pick = LPF_PICK_FROM_Q; |
502 | |
|
503 | 0 | sf->winner_mode_sf.multi_winner_mode_type = MULTI_WINNER_MODE_OFF; |
504 | 0 | sf->winner_mode_sf.prune_winner_mode_processing_using_src_var = 1; |
505 | 0 | } |
506 | | // The following should make all-intra mode speed 7 approximately equal |
507 | | // to real-time speed 6, |
508 | | // all-intra speed 8 close to real-time speed 7, and all-intra speed 9 |
509 | | // close to real-time speed 8 |
510 | 0 | if (speed >= 7) { |
511 | 0 | sf->part_sf.default_min_partition_size = BLOCK_8X8; |
512 | 0 | sf->part_sf.partition_search_type = VAR_BASED_PARTITION; |
513 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_PICK_FROM_Q; |
514 | 0 | sf->rt_sf.mode_search_skip_flags |= FLAG_SKIP_INTRA_DIRMISMATCH; |
515 | 0 | sf->rt_sf.var_part_split_threshold_shift = 7; |
516 | 0 | } |
517 | |
|
518 | 0 | if (speed >= 8) { |
519 | 0 | sf->rt_sf.hybrid_intra_pickmode = 1; |
520 | 0 | sf->rt_sf.use_nonrd_pick_mode = 1; |
521 | 0 | sf->rt_sf.nonrd_check_partition_merge_mode = 1; |
522 | 0 | sf->rt_sf.nonrd_check_partition_split = 0; |
523 | 0 | sf->rt_sf.var_part_split_threshold_shift = 8; |
524 | | // Set mask for intra modes. |
525 | 0 | for (int i = 0; i < BLOCK_SIZES; ++i) |
526 | 0 | if (i >= BLOCK_32X32) |
527 | 0 | sf->rt_sf.intra_y_mode_bsize_mask_nrd[i] = INTRA_DC; |
528 | 0 | else |
529 | | // Use DC, H, V intra mode for block sizes < 32X32. |
530 | 0 | sf->rt_sf.intra_y_mode_bsize_mask_nrd[i] = INTRA_DC_H_V; |
531 | 0 | } |
532 | |
|
533 | 0 | if (speed >= 9) { |
534 | 0 | sf->inter_sf.coeff_cost_upd_level = INTERNAL_COST_UPD_SBROW; |
535 | 0 | sf->inter_sf.mode_cost_upd_level = INTERNAL_COST_UPD_SBROW; |
536 | |
|
537 | 0 | sf->rt_sf.nonrd_check_partition_merge_mode = 0; |
538 | 0 | sf->rt_sf.hybrid_intra_pickmode = 0; |
539 | 0 | sf->rt_sf.var_part_split_threshold_shift = 9; |
540 | 0 | } |
541 | 0 | } |
542 | | |
543 | | static void set_good_speed_feature_framesize_dependent( |
544 | 0 | const AV1_COMP *const cpi, SPEED_FEATURES *const sf, int speed) { |
545 | 0 | const AV1_COMMON *const cm = &cpi->common; |
546 | 0 | const int is_480p_or_lesser = AOMMIN(cm->width, cm->height) <= 480; |
547 | 0 | const int is_480p_or_larger = AOMMIN(cm->width, cm->height) >= 480; |
548 | 0 | const int is_720p_or_larger = AOMMIN(cm->width, cm->height) >= 720; |
549 | 0 | const int is_1080p_or_larger = AOMMIN(cm->width, cm->height) >= 1080; |
550 | 0 | const int is_4k_or_larger = AOMMIN(cm->width, cm->height) >= 2160; |
551 | 0 | const bool use_hbd = cpi->oxcf.use_highbitdepth; |
552 | 0 | const int boosted = frame_is_boosted(cpi); |
553 | 0 | const int is_boosted_arf2_bwd_type = |
554 | 0 | boosted || |
555 | 0 | cpi->ppi->gf_group.update_type[cpi->gf_frame_index] == INTNL_ARF_UPDATE; |
556 | 0 | const int is_lf_frame = |
557 | 0 | cpi->ppi->gf_group.update_type[cpi->gf_frame_index] == LF_UPDATE; |
558 | |
|
559 | 0 | if (is_480p_or_larger) { |
560 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_128X128; |
561 | 0 | if (is_720p_or_larger) |
562 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = ADAPT_PRED; |
563 | 0 | else |
564 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = RELAXED_PRED; |
565 | 0 | } else { |
566 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_64X64; |
567 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = DIRECT_PRED; |
568 | 0 | if (use_hbd) sf->tx_sf.prune_tx_size_level = 1; |
569 | 0 | } |
570 | |
|
571 | 0 | if (is_4k_or_larger) { |
572 | 0 | sf->part_sf.default_min_partition_size = BLOCK_8X8; |
573 | 0 | } |
574 | | |
575 | | // TODO(huisu@google.com): train models for 720P and above. |
576 | 0 | if (!is_720p_or_larger) { |
577 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[0] = 200; // BLOCK_8X8 |
578 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[1] = 250; // BLOCK_16X16 |
579 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[2] = 300; // BLOCK_32X32 |
580 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[3] = 500; // BLOCK_64X64 |
581 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[4] = -1; // BLOCK_128X128 |
582 | 0 | sf->part_sf.ml_early_term_after_part_split_level = 1; |
583 | 0 | } |
584 | |
|
585 | 0 | if (is_720p_or_larger) { |
586 | | // TODO(chiyotsai@google.com): make this speed feature adaptive based on |
587 | | // current block's vertical texture instead of hardcoded with resolution |
588 | 0 | sf->mv_sf.use_downsampled_sad = 1; |
589 | 0 | } |
590 | |
|
591 | 0 | if (!is_720p_or_larger) { |
592 | 0 | const RateControlCfg *const rc_cfg = &cpi->oxcf.rc_cfg; |
593 | 0 | const int rate_tolerance = |
594 | 0 | AOMMIN(rc_cfg->under_shoot_pct, rc_cfg->over_shoot_pct); |
595 | 0 | sf->hl_sf.recode_tolerance = 25 + (rate_tolerance >> 2); |
596 | 0 | } |
597 | |
|
598 | 0 | if (speed >= 1) { |
599 | 0 | if (is_480p_or_lesser) sf->inter_sf.skip_newmv_in_drl = 1; |
600 | |
|
601 | 0 | if (is_720p_or_larger) { |
602 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_128X128; |
603 | 0 | } else if (is_480p_or_larger) { |
604 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_64X64; |
605 | 0 | } else { |
606 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_32X32; |
607 | 0 | } |
608 | |
|
609 | 0 | if (!is_720p_or_larger) { |
610 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[0] = 200; // BLOCK_8X8 |
611 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[1] = 250; // BLOCK_16X16 |
612 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[2] = 300; // BLOCK_32X32 |
613 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[3] = 300; // BLOCK_64X64 |
614 | 0 | sf->part_sf.ml_partition_search_breakout_thresh[4] = -1; // BLOCK_128X128 |
615 | 0 | } |
616 | 0 | sf->part_sf.ml_early_term_after_part_split_level = 2; |
617 | |
|
618 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL1; |
619 | 0 | } |
620 | |
|
621 | 0 | if (speed >= 2) { |
622 | 0 | if (is_720p_or_larger) { |
623 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_64X64; |
624 | 0 | } else if (is_480p_or_larger) { |
625 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_32X32; |
626 | 0 | } else { |
627 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_32X32; |
628 | 0 | } |
629 | |
|
630 | 0 | if (is_720p_or_larger) { |
631 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 24); |
632 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 120; |
633 | 0 | } else { |
634 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 22); |
635 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 100; |
636 | 0 | } |
637 | |
|
638 | 0 | if (is_720p_or_larger) { |
639 | 0 | sf->inter_sf.prune_obmc_prob_thresh = 16; |
640 | 0 | } else { |
641 | 0 | sf->inter_sf.prune_obmc_prob_thresh = 8; |
642 | 0 | } |
643 | |
|
644 | 0 | if (is_480p_or_larger) { |
645 | 0 | sf->inter_sf.disable_interintra_wedge_var_thresh = 100; |
646 | 0 | } else { |
647 | 0 | sf->inter_sf.disable_interintra_wedge_var_thresh = UINT_MAX; |
648 | 0 | } |
649 | |
|
650 | 0 | if (is_480p_or_lesser) sf->inter_sf.skip_ext_comp_nearmv_mode = 1; |
651 | |
|
652 | 0 | if (is_720p_or_larger) { |
653 | 0 | sf->inter_sf.limit_inter_mode_cands = is_lf_frame ? 1 : 0; |
654 | 0 | } else { |
655 | 0 | sf->inter_sf.limit_inter_mode_cands = is_lf_frame ? 2 : 0; |
656 | 0 | } |
657 | |
|
658 | 0 | if (is_480p_or_larger) { |
659 | 0 | sf->tx_sf.tx_type_search.prune_tx_type_using_stats = 1; |
660 | 0 | if (use_hbd) sf->tx_sf.prune_tx_size_level = 2; |
661 | 0 | } else { |
662 | 0 | if (use_hbd) sf->tx_sf.prune_tx_size_level = 3; |
663 | 0 | sf->tx_sf.tx_type_search.winner_mode_tx_type_pruning = boosted ? 0 : 1; |
664 | 0 | sf->winner_mode_sf.enable_winner_mode_for_tx_size_srch = boosted ? 0 : 1; |
665 | 0 | } |
666 | |
|
667 | 0 | if (!is_720p_or_larger) { |
668 | 0 | sf->mv_sf.disable_second_mv = 1; |
669 | 0 | sf->mv_sf.auto_mv_step_size = 2; |
670 | 0 | } else { |
671 | 0 | sf->mv_sf.disable_second_mv = boosted ? 0 : 2; |
672 | 0 | sf->mv_sf.auto_mv_step_size = 1; |
673 | 0 | } |
674 | |
|
675 | 0 | if (!is_720p_or_larger) { |
676 | 0 | sf->hl_sf.recode_tolerance = 50; |
677 | 0 | sf->inter_sf.disable_interinter_wedge_newmv_search = |
678 | 0 | is_boosted_arf2_bwd_type ? 0 : 1; |
679 | 0 | sf->inter_sf.enable_fast_wedge_mask_search = 1; |
680 | 0 | } |
681 | 0 | } |
682 | |
|
683 | 0 | if (speed >= 3) { |
684 | 0 | sf->inter_sf.enable_fast_wedge_mask_search = 1; |
685 | 0 | sf->inter_sf.skip_newmv_in_drl = 2; |
686 | 0 | sf->inter_sf.skip_ext_comp_nearmv_mode = 1; |
687 | 0 | sf->inter_sf.limit_inter_mode_cands = is_lf_frame ? 3 : 0; |
688 | 0 | sf->inter_sf.disable_interinter_wedge_newmv_search = boosted ? 0 : 1; |
689 | 0 | sf->tx_sf.tx_type_search.winner_mode_tx_type_pruning = 1; |
690 | 0 | sf->winner_mode_sf.enable_winner_mode_for_tx_size_srch = |
691 | 0 | frame_is_intra_only(&cpi->common) ? 0 : 1; |
692 | |
|
693 | 0 | sf->part_sf.ml_early_term_after_part_split_level = 0; |
694 | |
|
695 | 0 | if (is_720p_or_larger) { |
696 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 25); |
697 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 200; |
698 | 0 | sf->part_sf.skip_non_sq_part_based_on_none = is_lf_frame ? 2 : 0; |
699 | 0 | } else { |
700 | 0 | sf->part_sf.max_intra_bsize = BLOCK_32X32; |
701 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 23); |
702 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 120; |
703 | 0 | sf->part_sf.skip_non_sq_part_based_on_none = is_lf_frame ? 1 : 0; |
704 | 0 | } |
705 | 0 | if (use_hbd) sf->tx_sf.prune_tx_size_level = 3; |
706 | |
|
707 | 0 | if (is_480p_or_larger) { |
708 | 0 | sf->part_sf.early_term_after_none_split = 1; |
709 | 0 | } else { |
710 | 0 | sf->part_sf.early_term_after_none_split = 0; |
711 | 0 | } |
712 | 0 | if (is_720p_or_larger) { |
713 | 0 | sf->intra_sf.skip_intra_in_interframe = boosted ? 1 : 2; |
714 | 0 | } else { |
715 | 0 | sf->intra_sf.skip_intra_in_interframe = boosted ? 1 : 3; |
716 | 0 | } |
717 | |
|
718 | 0 | if (is_720p_or_larger) { |
719 | 0 | sf->inter_sf.disable_interinter_wedge_var_thresh = 100; |
720 | 0 | sf->inter_sf.limit_txfm_eval_per_mode = boosted ? 0 : 1; |
721 | 0 | } else { |
722 | 0 | sf->inter_sf.disable_interinter_wedge_var_thresh = UINT_MAX; |
723 | 0 | sf->inter_sf.limit_txfm_eval_per_mode = boosted ? 0 : 2; |
724 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL2; |
725 | 0 | } |
726 | |
|
727 | 0 | sf->inter_sf.disable_interintra_wedge_var_thresh = UINT_MAX; |
728 | 0 | } |
729 | |
|
730 | 0 | if (speed >= 4) { |
731 | 0 | sf->tx_sf.tx_type_search.winner_mode_tx_type_pruning = 2; |
732 | 0 | sf->winner_mode_sf.enable_winner_mode_for_tx_size_srch = 1; |
733 | 0 | if (is_720p_or_larger) { |
734 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 26); |
735 | 0 | } else { |
736 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 24); |
737 | 0 | } |
738 | 0 | sf->part_sf.early_term_after_none_split = 1; |
739 | |
|
740 | 0 | if (is_480p_or_larger) { |
741 | 0 | sf->tx_sf.tx_type_search.prune_tx_type_using_stats = 2; |
742 | 0 | } |
743 | |
|
744 | 0 | sf->inter_sf.disable_interinter_wedge_var_thresh = UINT_MAX; |
745 | 0 | sf->inter_sf.prune_obmc_prob_thresh = INT_MAX; |
746 | 0 | sf->inter_sf.limit_txfm_eval_per_mode = boosted ? 0 : 2; |
747 | 0 | if (is_480p_or_lesser) sf->inter_sf.skip_newmv_in_drl = 3; |
748 | |
|
749 | 0 | if (is_720p_or_larger) |
750 | 0 | sf->hl_sf.recode_tolerance = 32; |
751 | 0 | else |
752 | 0 | sf->hl_sf.recode_tolerance = 55; |
753 | |
|
754 | 0 | sf->intra_sf.skip_intra_in_interframe = 4; |
755 | |
|
756 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL3; |
757 | 0 | } |
758 | |
|
759 | 0 | if (speed >= 5) { |
760 | 0 | if (is_720p_or_larger) { |
761 | 0 | sf->inter_sf.prune_warped_prob_thresh = 16; |
762 | 0 | } else if (is_480p_or_larger) { |
763 | 0 | sf->inter_sf.prune_warped_prob_thresh = 8; |
764 | 0 | } |
765 | 0 | if (is_720p_or_larger) sf->hl_sf.recode_tolerance = 40; |
766 | |
|
767 | 0 | sf->inter_sf.skip_newmv_in_drl = 4; |
768 | |
|
769 | 0 | if (!is_720p_or_larger) { |
770 | 0 | sf->inter_sf.mv_cost_upd_level = INTERNAL_COST_UPD_SBROW_SET; |
771 | 0 | } |
772 | |
|
773 | 0 | if (!is_480p_or_larger) { |
774 | 0 | sf->tx_sf.tx_type_search.fast_inter_tx_type_prob_thresh = |
775 | 0 | boosted ? INT_MAX : 250; |
776 | 0 | } |
777 | |
|
778 | 0 | if (is_480p_or_lesser) { |
779 | 0 | sf->inter_sf.prune_nearmv_using_neighbors = PRUNE_NEARMV_LEVEL1; |
780 | 0 | } else { |
781 | 0 | sf->inter_sf.prune_nearmv_using_neighbors = PRUNE_NEARMV_LEVEL2; |
782 | 0 | } |
783 | 0 | } |
784 | |
|
785 | 0 | if (speed >= 6) { |
786 | 0 | sf->tx_sf.tx_type_search.winner_mode_tx_type_pruning = 4; |
787 | 0 | sf->inter_sf.prune_nearmv_using_neighbors = PRUNE_NEARMV_LEVEL3; |
788 | 0 | if (is_720p_or_larger) { |
789 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = NOT_IN_USE; |
790 | 0 | } else if (is_480p_or_larger) { |
791 | 0 | sf->part_sf.auto_max_partition_based_on_simple_motion = DIRECT_PRED; |
792 | 0 | } |
793 | |
|
794 | 0 | if (is_1080p_or_larger) { |
795 | 0 | sf->part_sf.default_min_partition_size = BLOCK_8X8; |
796 | 0 | } |
797 | |
|
798 | 0 | if (is_720p_or_larger) { |
799 | 0 | sf->inter_sf.disable_masked_comp = 1; |
800 | 0 | } |
801 | |
|
802 | 0 | if (!is_720p_or_larger) { |
803 | 0 | sf->inter_sf.coeff_cost_upd_level = INTERNAL_COST_UPD_SBROW; |
804 | 0 | sf->inter_sf.mode_cost_upd_level = INTERNAL_COST_UPD_SBROW; |
805 | 0 | } |
806 | |
|
807 | 0 | if (is_720p_or_larger) { |
808 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_32X32; |
809 | 0 | } else { |
810 | 0 | sf->part_sf.use_square_partition_only_threshold = BLOCK_16X16; |
811 | 0 | } |
812 | |
|
813 | 0 | if (is_720p_or_larger) { |
814 | 0 | sf->inter_sf.prune_ref_mv_idx_search = 2; |
815 | 0 | } else { |
816 | 0 | sf->inter_sf.prune_ref_mv_idx_search = 1; |
817 | 0 | } |
818 | |
|
819 | 0 | if (!is_720p_or_larger) { |
820 | 0 | sf->tx_sf.tx_type_search.fast_inter_tx_type_prob_thresh = 150; |
821 | 0 | } |
822 | |
|
823 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL4; |
824 | 0 | } |
825 | 0 | } |
826 | | |
827 | | static void set_good_speed_features_framesize_independent( |
828 | 0 | const AV1_COMP *const cpi, SPEED_FEATURES *const sf, int speed) { |
829 | 0 | const AV1_COMMON *const cm = &cpi->common; |
830 | 0 | const GF_GROUP *const gf_group = &cpi->ppi->gf_group; |
831 | 0 | const int boosted = frame_is_boosted(cpi); |
832 | 0 | const int is_boosted_arf2_bwd_type = |
833 | 0 | boosted || gf_group->update_type[cpi->gf_frame_index] == INTNL_ARF_UPDATE; |
834 | 0 | const int is_inter_frame = |
835 | 0 | gf_group->frame_type[cpi->gf_frame_index] == INTER_FRAME; |
836 | 0 | const int allow_screen_content_tools = |
837 | 0 | cm->features.allow_screen_content_tools; |
838 | 0 | const int use_hbd = cpi->oxcf.use_highbitdepth; |
839 | 0 | if (!cpi->oxcf.tile_cfg.enable_large_scale_tile) { |
840 | 0 | sf->hl_sf.high_precision_mv_usage = LAST_MV_DATA; |
841 | 0 | } |
842 | | |
843 | | // Speed 0 for all speed features that give neutral coding performance change. |
844 | 0 | sf->gm_sf.gm_search_type = GM_REDUCED_REF_SEARCH_SKIP_L2_L3; |
845 | |
|
846 | 0 | sf->part_sf.less_rectangular_check_level = 1; |
847 | 0 | sf->part_sf.ml_prune_partition = 1; |
848 | 0 | sf->part_sf.prune_ext_partition_types_search_level = 1; |
849 | 0 | sf->part_sf.prune_part4_search = 2; |
850 | 0 | sf->part_sf.simple_motion_search_prune_rect = 1; |
851 | 0 | sf->part_sf.ml_predict_breakout_level = use_hbd ? 1 : 3; |
852 | 0 | sf->part_sf.reuse_prev_rd_results_for_part_ab = 1; |
853 | 0 | sf->part_sf.use_best_rd_for_pruning = 1; |
854 | 0 | sf->part_sf.simple_motion_search_prune_agg = |
855 | 0 | allow_screen_content_tools ? NO_PRUNING : SIMPLE_AGG_LVL0; |
856 | | |
857 | | // TODO(debargha): Test, tweak and turn on either 1 or 2 |
858 | 0 | sf->inter_sf.inter_mode_rd_model_estimation = 1; |
859 | 0 | sf->inter_sf.model_based_post_interp_filter_breakout = 1; |
860 | 0 | sf->inter_sf.prune_compound_using_single_ref = 1; |
861 | 0 | sf->inter_sf.prune_mode_search_simple_translation = 1; |
862 | 0 | sf->inter_sf.prune_ref_frame_for_rect_partitions = |
863 | 0 | (boosted || (allow_screen_content_tools)) |
864 | 0 | ? 0 |
865 | 0 | : (is_boosted_arf2_bwd_type ? 1 : 2); |
866 | 0 | sf->inter_sf.reduce_inter_modes = boosted ? 1 : 2; |
867 | 0 | sf->inter_sf.selective_ref_frame = 1; |
868 | 0 | sf->inter_sf.use_dist_wtd_comp_flag = DIST_WTD_COMP_SKIP_MV_SEARCH; |
869 | |
|
870 | 0 | sf->interp_sf.use_fast_interpolation_filter_search = 1; |
871 | |
|
872 | 0 | sf->intra_sf.intra_pruning_with_hog = 1; |
873 | |
|
874 | 0 | sf->tx_sf.adaptive_txb_search_level = 1; |
875 | 0 | sf->tx_sf.intra_tx_size_search_init_depth_sqr = 1; |
876 | 0 | sf->tx_sf.model_based_prune_tx_search_level = 1; |
877 | 0 | sf->tx_sf.tx_type_search.use_reduced_intra_txset = 1; |
878 | |
|
879 | 0 | sf->tpl_sf.search_method = NSTEP_8PT; |
880 | |
|
881 | 0 | sf->rt_sf.use_nonrd_pick_mode = 0; |
882 | 0 | sf->rt_sf.use_real_time_ref_set = 0; |
883 | |
|
884 | 0 | if (cpi->twopass_frame.fr_content_type == FC_GRAPHICS_ANIMATION || |
885 | 0 | cpi->use_screen_content_tools) { |
886 | 0 | sf->mv_sf.exhaustive_searches_thresh = (1 << 20); |
887 | 0 | } else { |
888 | 0 | sf->mv_sf.exhaustive_searches_thresh = (1 << 25); |
889 | 0 | } |
890 | |
|
891 | 0 | sf->rd_sf.perform_coeff_opt = 1; |
892 | 0 | sf->hl_sf.superres_auto_search_type = SUPERRES_AUTO_DUAL; |
893 | |
|
894 | 0 | if (speed >= 1) { |
895 | 0 | sf->gm_sf.gm_search_type = GM_REDUCED_REF_SEARCH_SKIP_L2_L3_ARF2; |
896 | 0 | sf->gm_sf.prune_ref_frame_for_gm_search = boosted ? 0 : 1; |
897 | |
|
898 | 0 | sf->part_sf.intra_cnn_based_part_prune_level = |
899 | 0 | allow_screen_content_tools ? 0 : 2; |
900 | 0 | sf->part_sf.simple_motion_search_early_term_none = 1; |
901 | | // TODO(Venkat): Clean-up frame type dependency for |
902 | | // simple_motion_search_split in partition search function and set the |
903 | | // speed feature accordingly |
904 | 0 | sf->part_sf.simple_motion_search_split = allow_screen_content_tools ? 1 : 2; |
905 | 0 | sf->part_sf.ml_predict_breakout_level = use_hbd ? 2 : 3; |
906 | |
|
907 | 0 | sf->mv_sf.exhaustive_searches_thresh <<= 1; |
908 | 0 | sf->mv_sf.obmc_full_pixel_search_level = 1; |
909 | 0 | sf->mv_sf.use_accurate_subpel_search = USE_4_TAPS; |
910 | 0 | sf->mv_sf.disable_extensive_joint_motion_search = 1; |
911 | |
|
912 | 0 | sf->inter_sf.prune_comp_search_by_single_result = boosted ? 2 : 1; |
913 | 0 | sf->inter_sf.prune_comp_type_by_comp_avg = 1; |
914 | 0 | sf->inter_sf.prune_comp_type_by_model_rd = boosted ? 0 : 1; |
915 | 0 | sf->inter_sf.prune_ref_frame_for_rect_partitions = |
916 | 0 | (frame_is_intra_only(&cpi->common) || (allow_screen_content_tools)) |
917 | 0 | ? 0 |
918 | 0 | : (boosted ? 1 : 2); |
919 | 0 | sf->inter_sf.reduce_inter_modes = boosted ? 1 : 3; |
920 | 0 | sf->inter_sf.reuse_inter_intra_mode = 1; |
921 | 0 | sf->inter_sf.selective_ref_frame = 2; |
922 | 0 | sf->inter_sf.skip_arf_compound = 1; |
923 | |
|
924 | 0 | sf->interp_sf.use_interp_filter = 1; |
925 | |
|
926 | 0 | sf->intra_sf.prune_palette_search_level = 1; |
927 | |
|
928 | 0 | sf->tx_sf.adaptive_txb_search_level = 2; |
929 | 0 | sf->tx_sf.inter_tx_size_search_init_depth_rect = 1; |
930 | 0 | sf->tx_sf.inter_tx_size_search_init_depth_sqr = 1; |
931 | 0 | sf->tx_sf.intra_tx_size_search_init_depth_rect = 1; |
932 | 0 | sf->tx_sf.model_based_prune_tx_search_level = 0; |
933 | 0 | sf->tx_sf.tx_type_search.ml_tx_split_thresh = 4000; |
934 | 0 | sf->tx_sf.tx_type_search.prune_2d_txfm_mode = TX_TYPE_PRUNE_2; |
935 | 0 | sf->tx_sf.tx_type_search.skip_tx_search = 1; |
936 | |
|
937 | 0 | sf->rd_sf.perform_coeff_opt = boosted ? 2 : 3; |
938 | 0 | sf->rd_sf.tx_domain_dist_level = boosted ? 1 : 2; |
939 | 0 | sf->rd_sf.tx_domain_dist_thres_level = 1; |
940 | |
|
941 | 0 | sf->lpf_sf.dual_sgr_penalty_level = 1; |
942 | 0 | sf->lpf_sf.enable_sgr_ep_pruning = 1; |
943 | | |
944 | | // TODO(any, yunqing): move this feature to speed 0. |
945 | 0 | sf->tpl_sf.skip_alike_starting_mv = 1; |
946 | 0 | } |
947 | |
|
948 | 0 | if (speed >= 2) { |
949 | 0 | sf->hl_sf.recode_loop = ALLOW_RECODE_KFARFGF; |
950 | |
|
951 | 0 | sf->fp_sf.skip_motion_search_threshold = 25; |
952 | |
|
953 | 0 | sf->gm_sf.disable_gm_search_based_on_stats = 1; |
954 | |
|
955 | 0 | sf->part_sf.reuse_best_prediction_for_part_ab = |
956 | 0 | !frame_is_intra_only(&cpi->common); |
957 | |
|
958 | 0 | sf->mv_sf.simple_motion_subpel_force_stop = QUARTER_PEL; |
959 | 0 | sf->mv_sf.subpel_iters_per_step = 1; |
960 | 0 | sf->mv_sf.reduce_search_range = 1; |
961 | | |
962 | | // TODO(chiyotsai@google.com): We can get 10% speed up if we move |
963 | | // adaptive_rd_thresh to speed 1. But currently it performs poorly on some |
964 | | // clips (e.g. 5% loss on dinner_1080p). We need to examine the sequence a |
965 | | // bit more closely to figure out why. |
966 | 0 | sf->inter_sf.adaptive_rd_thresh = 1; |
967 | 0 | sf->inter_sf.disable_interinter_wedge_var_thresh = 100; |
968 | 0 | sf->inter_sf.fast_interintra_wedge_search = 1; |
969 | 0 | sf->inter_sf.prune_comp_search_by_single_result = boosted ? 4 : 1; |
970 | 0 | sf->inter_sf.prune_ext_comp_using_neighbors = 1; |
971 | 0 | sf->inter_sf.prune_comp_using_best_single_mode_ref = 2; |
972 | 0 | sf->inter_sf.prune_comp_type_by_comp_avg = 2; |
973 | 0 | sf->inter_sf.selective_ref_frame = 3; |
974 | 0 | sf->inter_sf.use_dist_wtd_comp_flag = DIST_WTD_COMP_DISABLED; |
975 | | // Enable fast search only for COMPOUND_DIFFWTD type. |
976 | 0 | sf->inter_sf.enable_fast_compound_mode_search = 1; |
977 | 0 | sf->inter_sf.reuse_mask_search_results = 1; |
978 | 0 | sf->inter_sf.txfm_rd_gate_level = boosted ? 0 : 1; |
979 | 0 | sf->inter_sf.inter_mode_txfm_breakout = boosted ? 0 : 1; |
980 | 0 | sf->inter_sf.alt_ref_search_fp = 1; |
981 | |
|
982 | 0 | sf->interp_sf.adaptive_interp_filter_search = 1; |
983 | 0 | sf->interp_sf.disable_dual_filter = 1; |
984 | |
|
985 | 0 | sf->intra_sf.disable_smooth_intra = |
986 | 0 | !frame_is_intra_only(&cpi->common) || (cpi->rc.frames_to_key > 1); |
987 | 0 | sf->intra_sf.intra_pruning_with_hog = 2; |
988 | 0 | sf->intra_sf.skip_intra_in_interframe = is_inter_frame ? 2 : 1; |
989 | 0 | sf->intra_sf.skip_filter_intra_in_inter_frames = 1; |
990 | |
|
991 | 0 | sf->tpl_sf.prune_starting_mv = 1; |
992 | 0 | sf->tpl_sf.search_method = DIAMOND; |
993 | |
|
994 | 0 | sf->rd_sf.perform_coeff_opt = is_boosted_arf2_bwd_type ? 3 : 4; |
995 | 0 | sf->rd_sf.use_mb_rd_hash = 1; |
996 | |
|
997 | 0 | sf->lpf_sf.prune_wiener_based_on_src_var = 1; |
998 | 0 | sf->lpf_sf.prune_sgr_based_on_wiener = 1; |
999 | 0 | sf->lpf_sf.disable_loop_restoration_chroma = boosted ? 0 : 1; |
1000 | 0 | sf->lpf_sf.reduce_wiener_window_size = boosted ? 0 : 1; |
1001 | | |
1002 | | // TODO(any): Re-evaluate this feature set to 1 in speed 2. |
1003 | 0 | sf->tpl_sf.allow_compound_pred = 0; |
1004 | 0 | sf->tpl_sf.prune_ref_frames_in_tpl = 1; |
1005 | 0 | } |
1006 | |
|
1007 | 0 | if (speed >= 3) { |
1008 | 0 | sf->hl_sf.high_precision_mv_usage = CURRENT_Q; |
1009 | |
|
1010 | 0 | sf->gm_sf.gm_search_type = GM_DISABLE_SEARCH; |
1011 | 0 | sf->gm_sf.prune_zero_mv_with_sse = 1; |
1012 | |
|
1013 | 0 | sf->part_sf.less_rectangular_check_level = 2; |
1014 | 0 | sf->part_sf.simple_motion_search_prune_agg = |
1015 | 0 | allow_screen_content_tools |
1016 | 0 | ? SIMPLE_AGG_LVL0 |
1017 | 0 | : (boosted ? SIMPLE_AGG_LVL1 : QIDX_BASED_AGG_LVL1); |
1018 | 0 | sf->part_sf.prune_ext_part_using_split_info = 1; |
1019 | 0 | sf->part_sf.simple_motion_search_rect_split = 1; |
1020 | |
|
1021 | 0 | sf->mv_sf.full_pixel_search_level = 1; |
1022 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED; |
1023 | 0 | sf->mv_sf.search_method = DIAMOND; |
1024 | 0 | sf->mv_sf.disable_second_mv = 2; |
1025 | 0 | sf->mv_sf.prune_mesh_search = PRUNE_MESH_SEARCH_LVL_1; |
1026 | |
|
1027 | 0 | sf->inter_sf.disable_interinter_wedge_newmv_search = boosted ? 0 : 1; |
1028 | 0 | sf->inter_sf.mv_cost_upd_level = INTERNAL_COST_UPD_SBROW; |
1029 | 0 | sf->inter_sf.disable_onesided_comp = 1; |
1030 | 0 | sf->inter_sf.disable_interintra_wedge_var_thresh = UINT_MAX; |
1031 | | // TODO(any): Experiment with the early exit mechanism for speeds 0, 1 and 2 |
1032 | | // and clean-up the speed feature |
1033 | 0 | sf->inter_sf.perform_best_rd_based_gating_for_chroma = 1; |
1034 | 0 | sf->inter_sf.prune_inter_modes_based_on_tpl = boosted ? 0 : 1; |
1035 | 0 | sf->inter_sf.prune_comp_search_by_single_result = boosted ? 4 : 2; |
1036 | 0 | sf->inter_sf.selective_ref_frame = 5; |
1037 | 0 | sf->inter_sf.skip_repeated_ref_mv = 1; |
1038 | 0 | sf->inter_sf.reuse_compound_type_decision = 1; |
1039 | 0 | sf->inter_sf.txfm_rd_gate_level = |
1040 | 0 | boosted ? 0 : (is_boosted_arf2_bwd_type ? 1 : 2); |
1041 | 0 | sf->inter_sf.inter_mode_txfm_breakout = boosted ? 0 : 2; |
1042 | |
|
1043 | 0 | sf->interp_sf.adaptive_interp_filter_search = 2; |
1044 | | |
1045 | | // TODO(chiyotsai@google.com): the thresholds chosen for intra hog are |
1046 | | // inherited directly from luma hog with some minor tweaking. Eventually we |
1047 | | // should run this with a bayesian optimizer to find the Pareto frontier. |
1048 | 0 | sf->intra_sf.chroma_intra_pruning_with_hog = 2; |
1049 | 0 | sf->intra_sf.intra_pruning_with_hog = 3; |
1050 | 0 | sf->intra_sf.prune_palette_search_level = 2; |
1051 | 0 | sf->intra_sf.top_intra_model_count_allowed = 2; |
1052 | |
|
1053 | 0 | sf->tpl_sf.prune_starting_mv = 2; |
1054 | 0 | sf->tpl_sf.skip_alike_starting_mv = 2; |
1055 | 0 | sf->tpl_sf.prune_intra_modes = 1; |
1056 | 0 | sf->tpl_sf.reduce_first_step_size = 6; |
1057 | 0 | sf->tpl_sf.subpel_force_stop = QUARTER_PEL; |
1058 | 0 | sf->tpl_sf.gop_length_decision_method = 1; |
1059 | |
|
1060 | 0 | sf->tx_sf.adaptive_txb_search_level = boosted ? 2 : 3; |
1061 | 0 | sf->tx_sf.tx_type_search.use_skip_flag_prediction = 2; |
1062 | 0 | sf->tx_sf.tx_type_search.prune_2d_txfm_mode = TX_TYPE_PRUNE_3; |
1063 | | |
1064 | | // TODO(any): Refactor the code related to following winner mode speed |
1065 | | // features |
1066 | 0 | sf->winner_mode_sf.enable_winner_mode_for_coeff_opt = 1; |
1067 | 0 | sf->winner_mode_sf.enable_winner_mode_for_use_tx_domain_dist = 1; |
1068 | 0 | sf->winner_mode_sf.motion_mode_for_winner_cand = |
1069 | 0 | boosted ? 0 |
1070 | 0 | : gf_group->update_type[cpi->gf_frame_index] == INTNL_ARF_UPDATE |
1071 | 0 | ? 1 |
1072 | 0 | : 2; |
1073 | 0 | sf->winner_mode_sf.disable_winner_mode_eval_for_txskip = boosted ? 0 : 1; |
1074 | | |
1075 | | // For screen content, "prune_sgr_based_on_wiener = 2" cause large quality |
1076 | | // loss. |
1077 | 0 | sf->lpf_sf.prune_sgr_based_on_wiener = allow_screen_content_tools ? 1 : 2; |
1078 | 0 | sf->lpf_sf.prune_wiener_based_on_src_var = 2; |
1079 | 0 | sf->lpf_sf.use_coarse_filter_level_search = |
1080 | 0 | frame_is_intra_only(&cpi->common) ? 0 : 1; |
1081 | 0 | sf->lpf_sf.use_downsampled_wiener_stats = 1; |
1082 | 0 | } |
1083 | |
|
1084 | 0 | if (speed >= 4) { |
1085 | 0 | sf->gm_sf.prune_zero_mv_with_sse = 2; |
1086 | |
|
1087 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE; |
1088 | |
|
1089 | 0 | sf->part_sf.simple_motion_search_prune_agg = |
1090 | 0 | allow_screen_content_tools ? SIMPLE_AGG_LVL0 : SIMPLE_AGG_LVL2; |
1091 | 0 | sf->part_sf.simple_motion_search_reduce_search_steps = 4; |
1092 | 0 | sf->part_sf.prune_ext_part_using_split_info = 2; |
1093 | 0 | sf->part_sf.ml_predict_breakout_level = 3; |
1094 | 0 | sf->part_sf.prune_rectangular_split_based_on_qidx = |
1095 | 0 | (allow_screen_content_tools || frame_is_intra_only(&cpi->common)) ? 0 |
1096 | 0 | : 1; |
1097 | |
|
1098 | 0 | sf->inter_sf.alt_ref_search_fp = 2; |
1099 | 0 | sf->inter_sf.txfm_rd_gate_level = boosted ? 0 : 3; |
1100 | |
|
1101 | 0 | sf->inter_sf.prune_inter_modes_based_on_tpl = boosted ? 0 : 2; |
1102 | 0 | sf->inter_sf.prune_ext_comp_using_neighbors = 2; |
1103 | 0 | sf->inter_sf.prune_obmc_prob_thresh = INT_MAX; |
1104 | 0 | sf->inter_sf.disable_interinter_wedge_var_thresh = UINT_MAX; |
1105 | 0 | sf->inter_sf.prune_nearest_near_mv_using_refmv_weight = boosted ? 0 : 1; |
1106 | |
|
1107 | 0 | sf->interp_sf.cb_pred_filter_search = 1; |
1108 | 0 | sf->interp_sf.skip_sharp_interp_filter_search = 1; |
1109 | 0 | sf->interp_sf.use_interp_filter = 2; |
1110 | |
|
1111 | 0 | sf->intra_sf.intra_uv_mode_mask[TX_16X16] = UV_INTRA_DC_H_V_CFL; |
1112 | 0 | sf->intra_sf.intra_uv_mode_mask[TX_32X32] = UV_INTRA_DC_H_V_CFL; |
1113 | 0 | sf->intra_sf.intra_uv_mode_mask[TX_64X64] = UV_INTRA_DC_H_V_CFL; |
1114 | | // TODO(any): "intra_y_mode_mask" doesn't help much at speed 4. |
1115 | | // sf->intra_sf.intra_y_mode_mask[TX_16X16] = INTRA_DC_H_V; |
1116 | | // sf->intra_sf.intra_y_mode_mask[TX_32X32] = INTRA_DC_H_V; |
1117 | | // sf->intra_sf.intra_y_mode_mask[TX_64X64] = INTRA_DC_H_V; |
1118 | 0 | sf->intra_sf.skip_intra_in_interframe = 4; |
1119 | |
|
1120 | 0 | sf->mv_sf.simple_motion_subpel_force_stop = HALF_PEL; |
1121 | 0 | sf->mv_sf.prune_mesh_search = PRUNE_MESH_SEARCH_LVL_2; |
1122 | |
|
1123 | 0 | sf->tpl_sf.subpel_force_stop = HALF_PEL; |
1124 | 0 | sf->tpl_sf.search_method = FAST_BIGDIA; |
1125 | |
|
1126 | 0 | sf->tx_sf.tx_type_search.fast_intra_tx_type_search = 1; |
1127 | |
|
1128 | 0 | sf->rd_sf.perform_coeff_opt = is_boosted_arf2_bwd_type ? 5 : 7; |
1129 | | |
1130 | | // TODO(any): Extend multi-winner mode processing support for inter frames |
1131 | 0 | sf->winner_mode_sf.multi_winner_mode_type = |
1132 | 0 | frame_is_intra_only(&cpi->common) ? MULTI_WINNER_MODE_DEFAULT |
1133 | 0 | : MULTI_WINNER_MODE_OFF; |
1134 | 0 | sf->winner_mode_sf.dc_blk_pred_level = boosted ? 0 : 1; |
1135 | |
|
1136 | 0 | sf->lpf_sf.lpf_pick = LPF_PICK_FROM_FULL_IMAGE_NON_DUAL; |
1137 | 0 | } |
1138 | |
|
1139 | 0 | if (speed >= 5) { |
1140 | 0 | sf->fp_sf.reduce_mv_step_param = 4; |
1141 | |
|
1142 | 0 | sf->part_sf.simple_motion_search_prune_agg = |
1143 | 0 | allow_screen_content_tools ? SIMPLE_AGG_LVL0 : SIMPLE_AGG_LVL3; |
1144 | 0 | sf->part_sf.ext_partition_eval_thresh = |
1145 | 0 | allow_screen_content_tools ? BLOCK_8X8 : BLOCK_16X16; |
1146 | 0 | sf->part_sf.prune_sub_8x8_partition_level = |
1147 | 0 | (allow_screen_content_tools || frame_is_intra_only(&cpi->common)) ? 0 |
1148 | 0 | : 2; |
1149 | |
|
1150 | 0 | sf->inter_sf.prune_inter_modes_if_skippable = 1; |
1151 | 0 | sf->inter_sf.txfm_rd_gate_level = boosted ? 0 : 4; |
1152 | | // Enable fast search for all valid compound modes. |
1153 | 0 | sf->inter_sf.enable_fast_compound_mode_search = 2; |
1154 | |
|
1155 | 0 | sf->intra_sf.chroma_intra_pruning_with_hog = 3; |
1156 | | |
1157 | | // TODO(any): Extend multi-winner mode processing support for inter frames |
1158 | 0 | sf->winner_mode_sf.multi_winner_mode_type = |
1159 | 0 | frame_is_intra_only(&cpi->common) ? MULTI_WINNER_MODE_FAST |
1160 | 0 | : MULTI_WINNER_MODE_OFF; |
1161 | |
|
1162 | 0 | sf->lpf_sf.disable_lr_filter = 1; |
1163 | |
|
1164 | 0 | sf->tpl_sf.prune_starting_mv = 3; |
1165 | 0 | sf->tpl_sf.use_y_only_rate_distortion = 1; |
1166 | 0 | sf->tpl_sf.subpel_force_stop = FULL_PEL; |
1167 | 0 | sf->tpl_sf.gop_length_decision_method = 2; |
1168 | |
|
1169 | 0 | sf->winner_mode_sf.dc_blk_pred_level = 1; |
1170 | |
|
1171 | 0 | sf->fp_sf.disable_recon = 1; |
1172 | 0 | } |
1173 | |
|
1174 | 0 | if (speed >= 6) { |
1175 | 0 | sf->hl_sf.disable_extra_sc_testing = 1; |
1176 | 0 | sf->hl_sf.second_alt_ref_filtering = 0; |
1177 | 0 | sf->hl_sf.recode_tolerance = 55; |
1178 | |
|
1179 | 0 | sf->inter_sf.prune_inter_modes_based_on_tpl = boosted ? 0 : 3; |
1180 | 0 | sf->inter_sf.selective_ref_frame = 6; |
1181 | 0 | sf->inter_sf.prune_ext_comp_using_neighbors = 3; |
1182 | |
|
1183 | 0 | sf->intra_sf.chroma_intra_pruning_with_hog = 4; |
1184 | 0 | sf->intra_sf.intra_pruning_with_hog = 4; |
1185 | 0 | sf->intra_sf.intra_uv_mode_mask[TX_32X32] = UV_INTRA_DC; |
1186 | 0 | sf->intra_sf.intra_uv_mode_mask[TX_64X64] = UV_INTRA_DC; |
1187 | 0 | sf->intra_sf.intra_y_mode_mask[TX_32X32] = INTRA_DC; |
1188 | 0 | sf->intra_sf.intra_y_mode_mask[TX_64X64] = INTRA_DC; |
1189 | 0 | sf->intra_sf.early_term_chroma_palette_size_search = 1; |
1190 | |
|
1191 | 0 | sf->part_sf.prune_rectangular_split_based_on_qidx = |
1192 | 0 | boosted || allow_screen_content_tools ? 0 : 2; |
1193 | 0 | sf->part_sf.prune_sub_8x8_partition_level = |
1194 | 0 | allow_screen_content_tools ? 0 |
1195 | 0 | : frame_is_intra_only(&cpi->common) ? 1 : 2; |
1196 | 0 | sf->part_sf.prune_part4_search = 3; |
1197 | |
|
1198 | 0 | sf->mv_sf.simple_motion_subpel_force_stop = FULL_PEL; |
1199 | 0 | sf->mv_sf.use_bsize_dependent_search_method = 1; |
1200 | |
|
1201 | 0 | sf->tpl_sf.gop_length_decision_method = 3; |
1202 | 0 | sf->tpl_sf.disable_filtered_key_tpl = 1; |
1203 | |
|
1204 | 0 | sf->rd_sf.perform_coeff_opt = is_boosted_arf2_bwd_type ? 6 : 8; |
1205 | |
|
1206 | 0 | sf->winner_mode_sf.dc_blk_pred_level = 2; |
1207 | 0 | sf->winner_mode_sf.multi_winner_mode_type = MULTI_WINNER_MODE_OFF; |
1208 | |
|
1209 | 0 | sf->fp_sf.skip_zeromv_motion_search = 1; |
1210 | 0 | } |
1211 | 0 | } |
1212 | | |
1213 | | static void set_rt_speed_feature_framesize_dependent(const AV1_COMP *const cpi, |
1214 | | SPEED_FEATURES *const sf, |
1215 | 0 | int speed) { |
1216 | 0 | const AV1_COMMON *const cm = &cpi->common; |
1217 | 0 | const int boosted = frame_is_boosted(cpi); |
1218 | 0 | const int is_720p_or_larger = AOMMIN(cm->width, cm->height) >= 720; |
1219 | 0 | const int is_480p_or_larger = AOMMIN(cm->width, cm->height) >= 480; |
1220 | 0 | const int is_360p_or_larger = AOMMIN(cm->width, cm->height) >= 360; |
1221 | |
|
1222 | 0 | if (!is_360p_or_larger) { |
1223 | 0 | sf->rt_sf.prune_intra_mode_based_on_mv_range = 1; |
1224 | 0 | if (speed >= 5) sf->rt_sf.prune_inter_modes_wrt_gf_arf_based_on_sad = 1; |
1225 | 0 | if (speed >= 7) sf->lpf_sf.cdef_pick_method = CDEF_PICK_FROM_Q; |
1226 | 0 | if (speed >= 8) sf->rt_sf.use_nonrd_filter_search = 0; |
1227 | 0 | if (speed >= 9) { |
1228 | 0 | sf->rt_sf.use_comp_ref_nonrd = 0; |
1229 | 0 | sf->rt_sf.nonrd_agressive_skip = 1; |
1230 | | // TODO(kyslov) Re-enable when AV1 models are trained |
1231 | | #if 0 |
1232 | | #if CONFIG_RT_ML_PARTITIONING |
1233 | | if (!frame_is_intra_only(cm)) { |
1234 | | sf->part_sf.partition_search_type = ML_BASED_PARTITION; |
1235 | | sf->rt_sf.reuse_inter_pred_nonrd = 0; |
1236 | | } |
1237 | | #endif |
1238 | | #endif |
1239 | 0 | } |
1240 | 0 | } else { |
1241 | 0 | sf->rt_sf.prune_intra_mode_based_on_mv_range = 2; |
1242 | 0 | sf->intra_sf.skip_filter_intra_in_inter_frames = 1; |
1243 | 0 | if (speed == 5) { |
1244 | 0 | sf->tx_sf.tx_type_search.fast_inter_tx_type_prob_thresh = |
1245 | 0 | boosted ? INT_MAX : 350; |
1246 | 0 | } |
1247 | 0 | if (speed == 8 && !cpi->ppi->use_svc) { |
1248 | 0 | sf->rt_sf.short_circuit_low_temp_var = 0; |
1249 | 0 | sf->rt_sf.use_nonrd_altref_frame = 1; |
1250 | 0 | } |
1251 | 0 | if (speed >= 9) { |
1252 | 0 | sf->rt_sf.gf_length_lvl = 1; |
1253 | 0 | sf->rt_sf.skip_cdef_sb = 1; |
1254 | 0 | } |
1255 | 0 | } |
1256 | 0 | if (!is_480p_or_larger) { |
1257 | 0 | if (speed == 7) { |
1258 | 0 | sf->rt_sf.nonrd_check_partition_merge_mode = 2; |
1259 | 0 | } |
1260 | 0 | if (speed >= 8) { |
1261 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE; |
1262 | 0 | sf->rt_sf.estimate_motion_for_var_based_partition = 1; |
1263 | 0 | } |
1264 | 0 | if (speed >= 9) { |
1265 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED; |
1266 | 0 | sf->rt_sf.estimate_motion_for_var_based_partition = 0; |
1267 | 0 | } |
1268 | 0 | } |
1269 | 0 | if (!is_720p_or_larger) { |
1270 | 0 | if (speed >= 9) { |
1271 | 0 | sf->rt_sf.force_large_partition_blocks_intra = 1; |
1272 | 0 | } |
1273 | 0 | } |
1274 | 0 | if (cpi->ppi->use_svc) { |
1275 | 0 | sf->rt_sf.use_comp_ref_nonrd = 0; |
1276 | 0 | if (cpi->svc.ref_frame_comp[0] || cpi->svc.ref_frame_comp[1] || |
1277 | 0 | cpi->svc.ref_frame_comp[2]) { |
1278 | 0 | sf->rt_sf.use_comp_ref_nonrd = 1; |
1279 | 0 | sf->rt_sf.ref_frame_comp_nonrd[0] = |
1280 | 0 | cpi->svc.ref_frame_comp[0] && cpi->svc.reference[GOLDEN_FRAME - 1]; |
1281 | 0 | sf->rt_sf.ref_frame_comp_nonrd[1] = |
1282 | 0 | cpi->svc.ref_frame_comp[1] && cpi->svc.reference[LAST2_FRAME - 1]; |
1283 | 0 | sf->rt_sf.ref_frame_comp_nonrd[2] = |
1284 | 0 | cpi->svc.ref_frame_comp[2] && cpi->svc.reference[ALTREF_FRAME - 1]; |
1285 | 0 | } |
1286 | 0 | } |
1287 | 0 | if (cpi->oxcf.tune_cfg.content == AOM_CONTENT_SCREEN) |
1288 | 0 | sf->rt_sf.use_comp_ref_nonrd = 0; |
1289 | 0 | } |
1290 | | |
1291 | | // TODO(kyslov): now this is very similar to |
1292 | | // set_good_speed_features_framesize_independent |
1293 | | // except it sets non-rd flag on speed8. This function will likely |
1294 | | // be modified in the future with RT-specific speed features |
1295 | | static void set_rt_speed_features_framesize_independent(AV1_COMP *cpi, |
1296 | | SPEED_FEATURES *sf, |
1297 | 0 | int speed) { |
1298 | 0 | AV1_COMMON *const cm = &cpi->common; |
1299 | 0 | const int boosted = frame_is_boosted(cpi); |
1300 | | |
1301 | | // Currently, rt speed 0, 1, 2, 3, 4, 5 are the same. |
1302 | | // Following set of speed features are not impacting encoder's decisions as |
1303 | | // the relevant tools are disabled by default. |
1304 | 0 | sf->gm_sf.gm_search_type = GM_REDUCED_REF_SEARCH_SKIP_L2_L3_ARF2; |
1305 | 0 | sf->hl_sf.recode_loop = ALLOW_RECODE_KFARFGF; |
1306 | 0 | sf->inter_sf.reuse_inter_intra_mode = 1; |
1307 | 0 | sf->inter_sf.prune_compound_using_single_ref = 0; |
1308 | 0 | sf->inter_sf.prune_comp_search_by_single_result = 2; |
1309 | 0 | sf->inter_sf.prune_comp_type_by_comp_avg = 2; |
1310 | 0 | sf->inter_sf.fast_wedge_sign_estimate = 1; |
1311 | 0 | sf->inter_sf.use_dist_wtd_comp_flag = DIST_WTD_COMP_DISABLED; |
1312 | 0 | sf->inter_sf.mv_cost_upd_level = INTERNAL_COST_UPD_SBROW; |
1313 | 0 | sf->inter_sf.disable_interinter_wedge_var_thresh = 100; |
1314 | 0 | sf->interp_sf.cb_pred_filter_search = 0; |
1315 | 0 | sf->part_sf.ml_prune_partition = 1; |
1316 | 0 | sf->part_sf.reuse_prev_rd_results_for_part_ab = 1; |
1317 | 0 | sf->part_sf.prune_ext_partition_types_search_level = 2; |
1318 | 0 | sf->part_sf.less_rectangular_check_level = 2; |
1319 | 0 | sf->mv_sf.obmc_full_pixel_search_level = 1; |
1320 | 0 | sf->intra_sf.dv_cost_upd_level = INTERNAL_COST_UPD_OFF; |
1321 | 0 | sf->tx_sf.model_based_prune_tx_search_level = 0; |
1322 | 0 | sf->lpf_sf.dual_sgr_penalty_level = 1; |
1323 | 0 | sf->lpf_sf.disable_lr_filter = 1; |
1324 | 0 | sf->rt_sf.skip_interp_filter_search = 1; |
1325 | | // End of set |
1326 | | |
1327 | | // TODO(any, yunqing): tune these features for real-time use cases. |
1328 | 0 | sf->hl_sf.superres_auto_search_type = SUPERRES_AUTO_SOLO; |
1329 | 0 | sf->hl_sf.frame_parameter_update = 0; |
1330 | |
|
1331 | 0 | sf->inter_sf.model_based_post_interp_filter_breakout = 1; |
1332 | | // TODO(any): As per the experiments, this speed feature is doing redundant |
1333 | | // computation since the model rd based pruning logic is similar to model rd |
1334 | | // based gating when inter_mode_rd_model_estimation = 2. Enable this SF if |
1335 | | // either of the condition becomes true. |
1336 | | // (1) inter_mode_rd_model_estimation != 2 |
1337 | | // (2) skip_interp_filter_search == 0 |
1338 | | // (3) Motion mode or compound mode is enabled */ |
1339 | 0 | sf->inter_sf.prune_mode_search_simple_translation = 0; |
1340 | 0 | sf->inter_sf.prune_ref_frame_for_rect_partitions = !boosted; |
1341 | 0 | sf->inter_sf.disable_interintra_wedge_var_thresh = UINT_MAX; |
1342 | 0 | sf->inter_sf.selective_ref_frame = 4; |
1343 | 0 | sf->inter_sf.alt_ref_search_fp = 2; |
1344 | 0 | sf->inter_sf.txfm_rd_gate_level = boosted ? 0 : 4; |
1345 | |
|
1346 | 0 | sf->inter_sf.adaptive_rd_thresh = 4; |
1347 | 0 | sf->inter_sf.inter_mode_rd_model_estimation = 2; |
1348 | 0 | sf->inter_sf.prune_inter_modes_if_skippable = 1; |
1349 | 0 | sf->inter_sf.prune_nearmv_using_neighbors = PRUNE_NEARMV_LEVEL3; |
1350 | 0 | sf->inter_sf.reduce_inter_modes = boosted ? 1 : 3; |
1351 | 0 | sf->inter_sf.skip_newmv_in_drl = 4; |
1352 | |
|
1353 | 0 | sf->interp_sf.use_fast_interpolation_filter_search = 1; |
1354 | 0 | sf->interp_sf.use_interp_filter = 1; |
1355 | 0 | sf->interp_sf.adaptive_interp_filter_search = 1; |
1356 | 0 | sf->interp_sf.disable_dual_filter = 1; |
1357 | |
|
1358 | 0 | sf->part_sf.default_max_partition_size = BLOCK_128X128; |
1359 | 0 | sf->part_sf.default_min_partition_size = BLOCK_8X8; |
1360 | 0 | sf->part_sf.use_best_rd_for_pruning = 1; |
1361 | 0 | sf->part_sf.early_term_after_none_split = 1; |
1362 | 0 | sf->part_sf.partition_search_breakout_dist_thr = (1 << 25); |
1363 | 0 | sf->part_sf.max_intra_bsize = BLOCK_16X16; |
1364 | 0 | sf->part_sf.partition_search_breakout_rate_thr = 500; |
1365 | 0 | sf->part_sf.partition_search_type = VAR_BASED_PARTITION; |
1366 | 0 | sf->part_sf.adjust_var_based_rd_partitioning = 2; |
1367 | |
|
1368 | 0 | sf->mv_sf.full_pixel_search_level = 1; |
1369 | 0 | sf->mv_sf.exhaustive_searches_thresh = INT_MAX; |
1370 | 0 | sf->mv_sf.auto_mv_step_size = 1; |
1371 | 0 | sf->mv_sf.subpel_iters_per_step = 1; |
1372 | 0 | sf->mv_sf.use_accurate_subpel_search = USE_2_TAPS; |
1373 | 0 | sf->mv_sf.search_method = FAST_DIAMOND; |
1374 | 0 | sf->mv_sf.subpel_force_stop = EIGHTH_PEL; |
1375 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED; |
1376 | |
|
1377 | 0 | for (int i = 0; i < TX_SIZES; ++i) { |
1378 | 0 | sf->intra_sf.intra_y_mode_mask[i] = INTRA_DC; |
1379 | 0 | sf->intra_sf.intra_uv_mode_mask[i] = UV_INTRA_DC_CFL; |
1380 | 0 | } |
1381 | 0 | sf->intra_sf.skip_intra_in_interframe = 5; |
1382 | 0 | sf->intra_sf.disable_smooth_intra = 1; |
1383 | 0 | sf->intra_sf.skip_filter_intra_in_inter_frames = 1; |
1384 | |
|
1385 | 0 | sf->tx_sf.intra_tx_size_search_init_depth_sqr = 1; |
1386 | 0 | sf->tx_sf.tx_type_search.use_reduced_intra_txset = 1; |
1387 | 0 | sf->tx_sf.adaptive_txb_search_level = 2; |
1388 | 0 | sf->tx_sf.intra_tx_size_search_init_depth_rect = 1; |
1389 | 0 | sf->tx_sf.tx_size_search_lgr_block = 1; |
1390 | 0 | sf->tx_sf.tx_type_search.ml_tx_split_thresh = 4000; |
1391 | 0 | sf->tx_sf.tx_type_search.skip_tx_search = 1; |
1392 | 0 | sf->tx_sf.inter_tx_size_search_init_depth_rect = 1; |
1393 | 0 | sf->tx_sf.inter_tx_size_search_init_depth_sqr = 1; |
1394 | 0 | sf->tx_sf.tx_type_search.prune_2d_txfm_mode = TX_TYPE_PRUNE_3; |
1395 | 0 | sf->tx_sf.refine_fast_tx_search_results = 0; |
1396 | 0 | sf->tx_sf.tx_type_search.fast_intra_tx_type_search = 1; |
1397 | 0 | sf->tx_sf.tx_type_search.use_skip_flag_prediction = 2; |
1398 | 0 | sf->tx_sf.tx_type_search.winner_mode_tx_type_pruning = 4; |
1399 | |
|
1400 | 0 | sf->rd_sf.optimize_coefficients = NO_TRELLIS_OPT; |
1401 | 0 | sf->rd_sf.simple_model_rd_from_var = 1; |
1402 | 0 | sf->rd_sf.tx_domain_dist_level = 2; |
1403 | 0 | sf->rd_sf.tx_domain_dist_thres_level = 2; |
1404 | |
|
1405 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL4; |
1406 | 0 | sf->lpf_sf.lpf_pick = LPF_PICK_FROM_Q; |
1407 | |
|
1408 | 0 | sf->winner_mode_sf.dc_blk_pred_level = frame_is_intra_only(cm) ? 0 : 2; |
1409 | 0 | sf->winner_mode_sf.enable_winner_mode_for_tx_size_srch = 1; |
1410 | 0 | sf->winner_mode_sf.tx_size_search_level = 1; |
1411 | 0 | sf->winner_mode_sf.winner_mode_ifs = 1; |
1412 | |
|
1413 | 0 | sf->rt_sf.check_intra_pred_nonrd = 1; |
1414 | 0 | sf->rt_sf.estimate_motion_for_var_based_partition = 1; |
1415 | 0 | sf->rt_sf.hybrid_intra_pickmode = 1; |
1416 | 0 | sf->rt_sf.use_comp_ref_nonrd = 0; |
1417 | 0 | sf->rt_sf.ref_frame_comp_nonrd[0] = 0; |
1418 | 0 | sf->rt_sf.ref_frame_comp_nonrd[1] = 0; |
1419 | 0 | sf->rt_sf.ref_frame_comp_nonrd[2] = 0; |
1420 | 0 | sf->rt_sf.use_nonrd_filter_search = 1; |
1421 | 0 | sf->rt_sf.mode_search_skip_flags |= FLAG_SKIP_INTRA_DIRMISMATCH; |
1422 | 0 | sf->rt_sf.num_inter_modes_for_tx_search = 5; |
1423 | 0 | sf->rt_sf.prune_inter_modes_using_temp_var = 1; |
1424 | 0 | sf->rt_sf.use_real_time_ref_set = 1; |
1425 | 0 | sf->rt_sf.use_simple_rd_model = 1; |
1426 | 0 | sf->rt_sf.prune_inter_modes_with_golden_ref = boosted ? 0 : 1; |
1427 | | // TODO(any): This sf could be removed. |
1428 | 0 | sf->rt_sf.short_circuit_low_temp_var = 1; |
1429 | 0 | sf->rt_sf.check_scene_detection = 1; |
1430 | 0 | if (cpi->rc.rtc_external_ratectrl) sf->rt_sf.check_scene_detection = 0; |
1431 | 0 | if (cm->current_frame.frame_type != KEY_FRAME && |
1432 | 0 | cpi->oxcf.rc_cfg.mode == AOM_CBR) |
1433 | 0 | sf->rt_sf.overshoot_detection_cbr = FAST_DETECTION_MAXQ; |
1434 | | // Enable noise estimation only for high resolutions for now. |
1435 | | // |
1436 | | // Since use_temporal_noise_estimate has no effect for all-intra frame |
1437 | | // encoding, it is disabled for this case. |
1438 | 0 | if (cpi->oxcf.kf_cfg.key_freq_max != 0 && cm->width * cm->height > 640 * 480) |
1439 | 0 | sf->rt_sf.use_temporal_noise_estimate = 1; |
1440 | 0 | sf->rt_sf.skip_tx_no_split_var_based_partition = 1; |
1441 | 0 | sf->rt_sf.skip_newmv_mode_based_on_sse = 1; |
1442 | 0 | sf->rt_sf.mode_search_skip_flags = |
1443 | 0 | (cm->current_frame.frame_type == KEY_FRAME) |
1444 | 0 | ? 0 |
1445 | 0 | : FLAG_SKIP_INTRA_DIRMISMATCH | FLAG_SKIP_INTRA_BESTINTER | |
1446 | 0 | FLAG_SKIP_COMP_BESTINTRA | FLAG_SKIP_INTRA_LOWVAR | |
1447 | 0 | FLAG_EARLY_TERMINATE; |
1448 | 0 | sf->rt_sf.var_part_split_threshold_shift = 5; |
1449 | | |
1450 | | // For SVC: use better mv search on base temporal layers, and only |
1451 | | // on base spatial layer if highest resolution is above 640x360. |
1452 | 0 | if (cpi->svc.number_temporal_layers > 1 && |
1453 | 0 | cpi->svc.temporal_layer_id < cpi->svc.number_temporal_layers - 1 && |
1454 | 0 | (cpi->svc.spatial_layer_id == 0 || |
1455 | 0 | cpi->oxcf.frm_dim_cfg.width * cpi->oxcf.frm_dim_cfg.height <= |
1456 | 0 | 640 * 360)) { |
1457 | 0 | sf->mv_sf.search_method = NSTEP; |
1458 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE; |
1459 | 0 | sf->rt_sf.fullpel_search_step_param = 6; |
1460 | 0 | } |
1461 | |
|
1462 | 0 | if (speed >= 6) { |
1463 | 0 | sf->mv_sf.use_fullpel_costlist = 1; |
1464 | |
|
1465 | 0 | sf->rd_sf.tx_domain_dist_thres_level = 3; |
1466 | |
|
1467 | 0 | sf->tx_sf.tx_type_search.fast_inter_tx_type_prob_thresh = 0; |
1468 | 0 | sf->inter_sf.limit_inter_mode_cands = 4; |
1469 | 0 | sf->inter_sf.limit_txfm_eval_per_mode = 3; |
1470 | 0 | sf->inter_sf.prune_warped_prob_thresh = 8; |
1471 | 0 | sf->inter_sf.extra_prune_warped = 1; |
1472 | |
|
1473 | 0 | sf->rt_sf.gf_refresh_based_on_qp = 1; |
1474 | 0 | sf->rt_sf.prune_inter_modes_wrt_gf_arf_based_on_sad = 1; |
1475 | 0 | sf->rt_sf.var_part_split_threshold_shift = 7; |
1476 | 0 | } |
1477 | |
|
1478 | 0 | if (speed >= 7) { |
1479 | 0 | sf->rt_sf.use_comp_ref_nonrd = 1; |
1480 | 0 | sf->rt_sf.ref_frame_comp_nonrd[2] = 1; // LAST_ALTREF |
1481 | 0 | sf->tx_sf.intra_tx_size_search_init_depth_sqr = 2; |
1482 | 0 | sf->part_sf.partition_search_type = VAR_BASED_PARTITION; |
1483 | 0 | sf->part_sf.max_intra_bsize = BLOCK_32X32; |
1484 | |
|
1485 | 0 | sf->gm_sf.gm_search_type = GM_DISABLE_SEARCH; |
1486 | |
|
1487 | 0 | sf->mv_sf.search_method = FAST_DIAMOND; |
1488 | 0 | sf->mv_sf.subpel_force_stop = QUARTER_PEL; |
1489 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED; |
1490 | |
|
1491 | 0 | sf->inter_sf.inter_mode_rd_model_estimation = 2; |
1492 | | // This sf is not applicable in non-rd path. |
1493 | 0 | sf->inter_sf.skip_newmv_in_drl = 0; |
1494 | | |
1495 | | // Disable intra_y_mode_mask pruning since the performance at speed 7 isn't |
1496 | | // good. May need more study. |
1497 | 0 | for (int i = 0; i < TX_SIZES; ++i) { |
1498 | 0 | sf->intra_sf.intra_y_mode_mask[i] = INTRA_ALL; |
1499 | 0 | } |
1500 | |
|
1501 | 0 | sf->lpf_sf.lpf_pick = LPF_PICK_FROM_Q; |
1502 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_FAST_SEARCH_LVL5; |
1503 | |
|
1504 | 0 | sf->rt_sf.mode_search_skip_flags |= FLAG_SKIP_INTRA_DIRMISMATCH; |
1505 | 0 | sf->rt_sf.nonrd_prune_ref_frame_search = 1; |
1506 | | // This is for rd path only. |
1507 | 0 | sf->rt_sf.prune_inter_modes_using_temp_var = 0; |
1508 | 0 | sf->rt_sf.prune_inter_modes_wrt_gf_arf_based_on_sad = 0; |
1509 | 0 | sf->rt_sf.prune_intra_mode_based_on_mv_range = 0; |
1510 | 0 | #if !CONFIG_REALTIME_ONLY |
1511 | 0 | sf->rt_sf.reuse_inter_pred_nonrd = |
1512 | 0 | (cpi->oxcf.motion_mode_cfg.enable_warped_motion == 0); |
1513 | | #else |
1514 | | sf->rt_sf.reuse_inter_pred_nonrd = 1; |
1515 | | #endif |
1516 | | #if CONFIG_AV1_TEMPORAL_DENOISING |
1517 | | sf->rt_sf.reuse_inter_pred_nonrd = (cpi->oxcf.noise_sensitivity == 0); |
1518 | | #endif |
1519 | 0 | sf->rt_sf.short_circuit_low_temp_var = 0; |
1520 | 0 | sf->rt_sf.skip_interp_filter_search = 0; |
1521 | | // For spatial layers, only LAST and GOLDEN are currently used in the SVC |
1522 | | // for nonrd. The flag use_nonrd_altref_frame can disable GOLDEN in the |
1523 | | // get_ref_frame_flags() for some patterns, so disable it here for |
1524 | | // spatial layers. |
1525 | 0 | sf->rt_sf.use_nonrd_altref_frame = |
1526 | 0 | (cpi->svc.number_spatial_layers > 1) ? 0 : 1; |
1527 | 0 | sf->rt_sf.use_nonrd_pick_mode = 1; |
1528 | 0 | sf->rt_sf.nonrd_check_partition_merge_mode = 1; |
1529 | 0 | sf->rt_sf.nonrd_check_partition_split = 0; |
1530 | 0 | sf->rt_sf.skip_intra_pred_if_tx_skip = 1; |
1531 | 0 | sf->rt_sf.source_metrics_sb_nonrd = 1; |
1532 | | // For SVC: use better mv search on base temporal layers, and only |
1533 | | // on base spatial layer if highest resolution is above 640x360. |
1534 | 0 | if (cpi->svc.number_temporal_layers > 1 && |
1535 | 0 | cpi->svc.temporal_layer_id < cpi->svc.number_temporal_layers - 1 && |
1536 | 0 | (cpi->svc.spatial_layer_id == 0 || |
1537 | 0 | cpi->oxcf.frm_dim_cfg.width * cpi->oxcf.frm_dim_cfg.height <= |
1538 | 0 | 640 * 360)) { |
1539 | 0 | sf->mv_sf.search_method = NSTEP; |
1540 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE; |
1541 | 0 | sf->rt_sf.fullpel_search_step_param = 6; |
1542 | 0 | } else if (cpi->svc.non_reference_frame) { |
1543 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE; |
1544 | 0 | sf->rt_sf.fullpel_search_step_param = 10; |
1545 | 0 | } |
1546 | | // Set mask for intra modes. |
1547 | 0 | for (int i = 0; i < BLOCK_SIZES; ++i) |
1548 | 0 | if (i >= BLOCK_32X32) |
1549 | 0 | sf->rt_sf.intra_y_mode_bsize_mask_nrd[i] = INTRA_DC; |
1550 | 0 | else |
1551 | | // Use DC, H, V intra mode for block sizes < 32X32. |
1552 | 0 | sf->rt_sf.intra_y_mode_bsize_mask_nrd[i] = INTRA_DC_H_V; |
1553 | |
|
1554 | 0 | sf->winner_mode_sf.dc_blk_pred_level = 0; |
1555 | 0 | } |
1556 | |
|
1557 | 0 | if (speed >= 8) { |
1558 | 0 | sf->intra_sf.intra_pruning_with_hog = 1; |
1559 | 0 | sf->rt_sf.estimate_motion_for_var_based_partition = 1; |
1560 | 0 | sf->rt_sf.short_circuit_low_temp_var = 1; |
1561 | 0 | sf->rt_sf.use_nonrd_altref_frame = 0; |
1562 | 0 | sf->rt_sf.nonrd_prune_ref_frame_search = 2; |
1563 | 0 | sf->rt_sf.nonrd_check_partition_merge_mode = 0; |
1564 | 0 | sf->rt_sf.nonrd_check_partition_split = 0; |
1565 | 0 | sf->rt_sf.skip_intra_pred_if_tx_skip = 0; |
1566 | 0 | sf->rt_sf.var_part_split_threshold_shift = 8; |
1567 | 0 | sf->interp_sf.cb_pred_filter_search = 1; |
1568 | 0 | } |
1569 | 0 | if (speed >= 9) { |
1570 | 0 | sf->lpf_sf.cdef_pick_method = CDEF_PICK_FROM_Q; |
1571 | 0 | sf->rt_sf.estimate_motion_for_var_based_partition = 0; |
1572 | 0 | sf->rt_sf.force_large_partition_blocks = 1; |
1573 | 0 | sf->rt_sf.var_part_split_threshold_shift = 9; |
1574 | 0 | for (int i = 0; i < BLOCK_SIZES; ++i) |
1575 | 0 | sf->rt_sf.intra_y_mode_bsize_mask_nrd[i] = INTRA_DC; |
1576 | 0 | } |
1577 | 0 | if (speed >= 10) { |
1578 | 0 | sf->rt_sf.skip_intra_pred_if_tx_skip = 1; |
1579 | 0 | sf->rt_sf.nonrd_agressive_skip = 1; |
1580 | 0 | sf->rt_sf.nonrd_prune_ref_frame_search = 3; |
1581 | 0 | sf->rt_sf.var_part_split_threshold_shift = 10; |
1582 | 0 | sf->mv_sf.subpel_search_method = SUBPEL_TREE_PRUNED_MORE; |
1583 | 0 | sf->rt_sf.force_half_pel_block = 1; |
1584 | 0 | } |
1585 | 0 | } |
1586 | | |
1587 | 0 | static AOM_INLINE void init_hl_sf(HIGH_LEVEL_SPEED_FEATURES *hl_sf) { |
1588 | | // best quality defaults |
1589 | 0 | hl_sf->frame_parameter_update = 1; |
1590 | 0 | hl_sf->recode_loop = ALLOW_RECODE; |
1591 | | // Recode loop tolerance %. |
1592 | 0 | hl_sf->recode_tolerance = 25; |
1593 | 0 | hl_sf->high_precision_mv_usage = CURRENT_Q; |
1594 | 0 | hl_sf->superres_auto_search_type = SUPERRES_AUTO_ALL; |
1595 | 0 | hl_sf->disable_extra_sc_testing = 0; |
1596 | 0 | hl_sf->second_alt_ref_filtering = 1; |
1597 | 0 | } |
1598 | | |
1599 | 0 | static AOM_INLINE void init_fp_sf(FIRST_PASS_SPEED_FEATURES *fp_sf) { |
1600 | 0 | fp_sf->reduce_mv_step_param = 3; |
1601 | 0 | fp_sf->skip_motion_search_threshold = 0; |
1602 | 0 | fp_sf->disable_recon = 0; |
1603 | 0 | fp_sf->skip_zeromv_motion_search = 0; |
1604 | 0 | } |
1605 | | |
1606 | 0 | static AOM_INLINE void init_tpl_sf(TPL_SPEED_FEATURES *tpl_sf) { |
1607 | 0 | tpl_sf->gop_length_decision_method = 0; |
1608 | 0 | tpl_sf->prune_intra_modes = 0; |
1609 | 0 | tpl_sf->prune_starting_mv = 0; |
1610 | 0 | tpl_sf->reduce_first_step_size = 0; |
1611 | 0 | tpl_sf->skip_alike_starting_mv = 0; |
1612 | 0 | tpl_sf->subpel_force_stop = EIGHTH_PEL; |
1613 | 0 | tpl_sf->search_method = NSTEP; |
1614 | 0 | tpl_sf->disable_filtered_key_tpl = 0; |
1615 | 0 | tpl_sf->prune_ref_frames_in_tpl = 0; |
1616 | 0 | tpl_sf->allow_compound_pred = 1; |
1617 | 0 | tpl_sf->use_y_only_rate_distortion = 0; |
1618 | 0 | } |
1619 | | |
1620 | 0 | static AOM_INLINE void init_gm_sf(GLOBAL_MOTION_SPEED_FEATURES *gm_sf) { |
1621 | 0 | gm_sf->gm_search_type = GM_FULL_SEARCH; |
1622 | 0 | gm_sf->prune_ref_frame_for_gm_search = 0; |
1623 | 0 | gm_sf->prune_zero_mv_with_sse = 0; |
1624 | 0 | gm_sf->disable_gm_search_based_on_stats = 0; |
1625 | 0 | } |
1626 | | |
1627 | 0 | static AOM_INLINE void init_part_sf(PARTITION_SPEED_FEATURES *part_sf) { |
1628 | 0 | part_sf->partition_search_type = SEARCH_PARTITION; |
1629 | 0 | part_sf->less_rectangular_check_level = 0; |
1630 | 0 | part_sf->use_square_partition_only_threshold = BLOCK_128X128; |
1631 | 0 | part_sf->auto_max_partition_based_on_simple_motion = NOT_IN_USE; |
1632 | 0 | part_sf->default_max_partition_size = BLOCK_LARGEST; |
1633 | 0 | part_sf->default_min_partition_size = BLOCK_4X4; |
1634 | 0 | part_sf->adjust_var_based_rd_partitioning = 0; |
1635 | 0 | part_sf->max_intra_bsize = BLOCK_LARGEST; |
1636 | | // This setting only takes effect when partition_search_type is set |
1637 | | // to FIXED_PARTITION. |
1638 | 0 | part_sf->fixed_partition_size = BLOCK_16X16; |
1639 | | // Recode loop tolerance %. |
1640 | 0 | part_sf->partition_search_breakout_dist_thr = 0; |
1641 | 0 | part_sf->partition_search_breakout_rate_thr = 0; |
1642 | 0 | part_sf->prune_ext_partition_types_search_level = 0; |
1643 | 0 | part_sf->prune_part4_search = 0; |
1644 | 0 | part_sf->ml_prune_partition = 0; |
1645 | 0 | part_sf->ml_early_term_after_part_split_level = 0; |
1646 | 0 | for (int i = 0; i < PARTITION_BLOCK_SIZES; ++i) { |
1647 | 0 | part_sf->ml_partition_search_breakout_thresh[i] = |
1648 | 0 | -1; // -1 means not enabled. |
1649 | 0 | } |
1650 | 0 | part_sf->simple_motion_search_prune_agg = SIMPLE_AGG_LVL0; |
1651 | 0 | part_sf->simple_motion_search_split = 0; |
1652 | 0 | part_sf->simple_motion_search_prune_rect = 0; |
1653 | 0 | part_sf->simple_motion_search_early_term_none = 0; |
1654 | 0 | part_sf->simple_motion_search_reduce_search_steps = 0; |
1655 | 0 | part_sf->intra_cnn_based_part_prune_level = 0; |
1656 | 0 | part_sf->ext_partition_eval_thresh = BLOCK_8X8; |
1657 | 0 | part_sf->rect_partition_eval_thresh = BLOCK_128X128; |
1658 | 0 | part_sf->prune_ext_part_using_split_info = 0; |
1659 | 0 | part_sf->prune_rectangular_split_based_on_qidx = 0; |
1660 | 0 | part_sf->early_term_after_none_split = 0; |
1661 | 0 | part_sf->ml_predict_breakout_level = 0; |
1662 | 0 | part_sf->prune_sub_8x8_partition_level = 0; |
1663 | 0 | part_sf->simple_motion_search_rect_split = 0; |
1664 | 0 | part_sf->reuse_prev_rd_results_for_part_ab = 0; |
1665 | 0 | part_sf->reuse_best_prediction_for_part_ab = 0; |
1666 | 0 | part_sf->use_best_rd_for_pruning = 0; |
1667 | 0 | part_sf->skip_non_sq_part_based_on_none = 0; |
1668 | 0 | } |
1669 | | |
1670 | 0 | static AOM_INLINE void init_mv_sf(MV_SPEED_FEATURES *mv_sf) { |
1671 | 0 | mv_sf->full_pixel_search_level = 0; |
1672 | 0 | mv_sf->auto_mv_step_size = 0; |
1673 | 0 | mv_sf->exhaustive_searches_thresh = 0; |
1674 | 0 | mv_sf->obmc_full_pixel_search_level = 0; |
1675 | 0 | mv_sf->prune_mesh_search = PRUNE_MESH_SEARCH_DISABLED; |
1676 | 0 | mv_sf->reduce_search_range = 0; |
1677 | 0 | mv_sf->search_method = NSTEP; |
1678 | 0 | mv_sf->simple_motion_subpel_force_stop = EIGHTH_PEL; |
1679 | 0 | mv_sf->subpel_force_stop = EIGHTH_PEL; |
1680 | 0 | mv_sf->subpel_iters_per_step = 2; |
1681 | 0 | mv_sf->subpel_search_method = SUBPEL_TREE; |
1682 | 0 | mv_sf->use_accurate_subpel_search = USE_8_TAPS; |
1683 | 0 | mv_sf->use_bsize_dependent_search_method = 0; |
1684 | 0 | mv_sf->use_fullpel_costlist = 0; |
1685 | 0 | mv_sf->use_downsampled_sad = 0; |
1686 | 0 | mv_sf->disable_extensive_joint_motion_search = 0; |
1687 | 0 | mv_sf->disable_second_mv = 0; |
1688 | 0 | } |
1689 | | |
1690 | 0 | static AOM_INLINE void init_inter_sf(INTER_MODE_SPEED_FEATURES *inter_sf) { |
1691 | 0 | inter_sf->adaptive_rd_thresh = 0; |
1692 | 0 | inter_sf->model_based_post_interp_filter_breakout = 0; |
1693 | 0 | inter_sf->reduce_inter_modes = 0; |
1694 | 0 | inter_sf->alt_ref_search_fp = 0; |
1695 | 0 | inter_sf->selective_ref_frame = 0; |
1696 | 0 | inter_sf->prune_ref_frame_for_rect_partitions = 0; |
1697 | 0 | inter_sf->fast_wedge_sign_estimate = 0; |
1698 | 0 | inter_sf->use_dist_wtd_comp_flag = DIST_WTD_COMP_ENABLED; |
1699 | 0 | inter_sf->reuse_inter_intra_mode = 0; |
1700 | 0 | inter_sf->mv_cost_upd_level = INTERNAL_COST_UPD_SB; |
1701 | 0 | inter_sf->coeff_cost_upd_level = INTERNAL_COST_UPD_SB; |
1702 | 0 | inter_sf->mode_cost_upd_level = INTERNAL_COST_UPD_SB; |
1703 | 0 | inter_sf->prune_inter_modes_based_on_tpl = 0; |
1704 | 0 | inter_sf->prune_nearmv_using_neighbors = PRUNE_NEARMV_OFF; |
1705 | 0 | inter_sf->prune_comp_search_by_single_result = 0; |
1706 | 0 | inter_sf->skip_repeated_ref_mv = 0; |
1707 | 0 | inter_sf->skip_newmv_in_drl = 0; |
1708 | 0 | inter_sf->inter_mode_rd_model_estimation = 0; |
1709 | 0 | inter_sf->prune_compound_using_single_ref = 0; |
1710 | 0 | inter_sf->prune_ext_comp_using_neighbors = 0; |
1711 | 0 | inter_sf->skip_ext_comp_nearmv_mode = 0; |
1712 | 0 | inter_sf->prune_comp_using_best_single_mode_ref = 0; |
1713 | 0 | inter_sf->prune_nearest_near_mv_using_refmv_weight = 0; |
1714 | 0 | inter_sf->disable_onesided_comp = 0; |
1715 | 0 | inter_sf->prune_mode_search_simple_translation = 0; |
1716 | 0 | inter_sf->prune_comp_type_by_comp_avg = 0; |
1717 | 0 | inter_sf->disable_interinter_wedge_newmv_search = 0; |
1718 | 0 | inter_sf->fast_interintra_wedge_search = 0; |
1719 | 0 | inter_sf->prune_comp_type_by_model_rd = 0; |
1720 | 0 | inter_sf->perform_best_rd_based_gating_for_chroma = 0; |
1721 | 0 | inter_sf->prune_obmc_prob_thresh = 0; |
1722 | 0 | inter_sf->disable_interinter_wedge_var_thresh = 0; |
1723 | 0 | inter_sf->disable_interintra_wedge_var_thresh = 0; |
1724 | 0 | inter_sf->prune_ref_mv_idx_search = 0; |
1725 | 0 | inter_sf->prune_warped_prob_thresh = 0; |
1726 | 0 | inter_sf->reuse_compound_type_decision = 0; |
1727 | 0 | inter_sf->txfm_rd_gate_level = 0; |
1728 | 0 | inter_sf->prune_inter_modes_if_skippable = 0; |
1729 | 0 | inter_sf->disable_masked_comp = 0; |
1730 | 0 | inter_sf->enable_fast_compound_mode_search = 0; |
1731 | 0 | inter_sf->reuse_mask_search_results = 0; |
1732 | 0 | inter_sf->enable_fast_wedge_mask_search = 0; |
1733 | 0 | inter_sf->inter_mode_txfm_breakout = 0; |
1734 | 0 | inter_sf->limit_inter_mode_cands = 0; |
1735 | 0 | inter_sf->limit_txfm_eval_per_mode = 0; |
1736 | 0 | inter_sf->skip_arf_compound = 0; |
1737 | 0 | } |
1738 | | |
1739 | 0 | static AOM_INLINE void init_interp_sf(INTERP_FILTER_SPEED_FEATURES *interp_sf) { |
1740 | 0 | interp_sf->adaptive_interp_filter_search = 0; |
1741 | 0 | interp_sf->cb_pred_filter_search = 0; |
1742 | 0 | interp_sf->disable_dual_filter = 0; |
1743 | 0 | interp_sf->skip_sharp_interp_filter_search = 0; |
1744 | 0 | interp_sf->use_fast_interpolation_filter_search = 0; |
1745 | 0 | interp_sf->use_interp_filter = 0; |
1746 | 0 | } |
1747 | | |
1748 | 0 | static AOM_INLINE void init_intra_sf(INTRA_MODE_SPEED_FEATURES *intra_sf) { |
1749 | 0 | intra_sf->dv_cost_upd_level = INTERNAL_COST_UPD_SB; |
1750 | 0 | intra_sf->skip_intra_in_interframe = 1; |
1751 | 0 | intra_sf->intra_pruning_with_hog = 0; |
1752 | 0 | intra_sf->chroma_intra_pruning_with_hog = 0; |
1753 | 0 | intra_sf->prune_palette_search_level = 0; |
1754 | 0 | intra_sf->prune_luma_palette_size_search_level = 0; |
1755 | |
|
1756 | 0 | for (int i = 0; i < TX_SIZES; i++) { |
1757 | 0 | intra_sf->intra_y_mode_mask[i] = INTRA_ALL; |
1758 | 0 | intra_sf->intra_uv_mode_mask[i] = UV_INTRA_ALL; |
1759 | 0 | } |
1760 | 0 | intra_sf->disable_smooth_intra = 0; |
1761 | 0 | intra_sf->prune_filter_intra_level = 0; |
1762 | 0 | intra_sf->prune_chroma_modes_using_luma_winner = 0; |
1763 | 0 | intra_sf->cfl_search_range = 3; |
1764 | 0 | intra_sf->top_intra_model_count_allowed = TOP_INTRA_MODEL_COUNT; |
1765 | 0 | intra_sf->adapt_top_model_rd_count_using_neighbors = 0; |
1766 | 0 | intra_sf->early_term_chroma_palette_size_search = 0; |
1767 | 0 | intra_sf->skip_filter_intra_in_inter_frames = 0; |
1768 | 0 | } |
1769 | | |
1770 | 0 | static AOM_INLINE void init_tx_sf(TX_SPEED_FEATURES *tx_sf) { |
1771 | 0 | tx_sf->inter_tx_size_search_init_depth_sqr = 0; |
1772 | 0 | tx_sf->inter_tx_size_search_init_depth_rect = 0; |
1773 | 0 | tx_sf->intra_tx_size_search_init_depth_rect = 0; |
1774 | 0 | tx_sf->intra_tx_size_search_init_depth_sqr = 0; |
1775 | 0 | tx_sf->tx_size_search_lgr_block = 0; |
1776 | 0 | tx_sf->model_based_prune_tx_search_level = 0; |
1777 | 0 | tx_sf->tx_type_search.prune_2d_txfm_mode = TX_TYPE_PRUNE_1; |
1778 | 0 | tx_sf->tx_type_search.ml_tx_split_thresh = 8500; |
1779 | 0 | tx_sf->tx_type_search.use_skip_flag_prediction = 1; |
1780 | 0 | tx_sf->tx_type_search.use_reduced_intra_txset = 0; |
1781 | 0 | tx_sf->tx_type_search.fast_intra_tx_type_search = 0; |
1782 | 0 | tx_sf->tx_type_search.fast_inter_tx_type_prob_thresh = INT_MAX; |
1783 | 0 | tx_sf->tx_type_search.skip_tx_search = 0; |
1784 | 0 | tx_sf->tx_type_search.prune_tx_type_using_stats = 0; |
1785 | 0 | tx_sf->tx_type_search.prune_tx_type_est_rd = 0; |
1786 | 0 | tx_sf->tx_type_search.winner_mode_tx_type_pruning = 0; |
1787 | 0 | tx_sf->txb_split_cap = 1; |
1788 | 0 | tx_sf->adaptive_txb_search_level = 0; |
1789 | 0 | tx_sf->refine_fast_tx_search_results = 1; |
1790 | 0 | tx_sf->prune_tx_size_level = 0; |
1791 | 0 | } |
1792 | | |
1793 | | static AOM_INLINE void init_rd_sf(RD_CALC_SPEED_FEATURES *rd_sf, |
1794 | 0 | const AV1EncoderConfig *oxcf) { |
1795 | 0 | const int disable_trellis_quant = oxcf->algo_cfg.disable_trellis_quant; |
1796 | 0 | if (disable_trellis_quant == 3) { |
1797 | 0 | rd_sf->optimize_coefficients = !is_lossless_requested(&oxcf->rc_cfg) |
1798 | 0 | ? NO_ESTIMATE_YRD_TRELLIS_OPT |
1799 | 0 | : NO_TRELLIS_OPT; |
1800 | 0 | } else if (disable_trellis_quant == 2) { |
1801 | 0 | rd_sf->optimize_coefficients = !is_lossless_requested(&oxcf->rc_cfg) |
1802 | 0 | ? FINAL_PASS_TRELLIS_OPT |
1803 | 0 | : NO_TRELLIS_OPT; |
1804 | 0 | } else if (disable_trellis_quant == 0) { |
1805 | 0 | if (is_lossless_requested(&oxcf->rc_cfg)) { |
1806 | 0 | rd_sf->optimize_coefficients = NO_TRELLIS_OPT; |
1807 | 0 | } else { |
1808 | 0 | rd_sf->optimize_coefficients = FULL_TRELLIS_OPT; |
1809 | 0 | } |
1810 | 0 | } else if (disable_trellis_quant == 1) { |
1811 | 0 | rd_sf->optimize_coefficients = NO_TRELLIS_OPT; |
1812 | 0 | } else { |
1813 | 0 | assert(0 && "Invalid disable_trellis_quant value"); |
1814 | 0 | } |
1815 | 0 | rd_sf->use_mb_rd_hash = 0; |
1816 | 0 | rd_sf->simple_model_rd_from_var = 0; |
1817 | 0 | rd_sf->tx_domain_dist_level = 0; |
1818 | 0 | rd_sf->tx_domain_dist_thres_level = 0; |
1819 | 0 | rd_sf->perform_coeff_opt = 0; |
1820 | 0 | } |
1821 | | |
1822 | | static AOM_INLINE void init_winner_mode_sf( |
1823 | 0 | WINNER_MODE_SPEED_FEATURES *winner_mode_sf) { |
1824 | 0 | winner_mode_sf->motion_mode_for_winner_cand = 0; |
1825 | | // Set this at the appropriate speed levels |
1826 | 0 | winner_mode_sf->tx_size_search_level = 0; |
1827 | 0 | winner_mode_sf->enable_winner_mode_for_coeff_opt = 0; |
1828 | 0 | winner_mode_sf->enable_winner_mode_for_tx_size_srch = 0; |
1829 | 0 | winner_mode_sf->enable_winner_mode_for_use_tx_domain_dist = 0; |
1830 | 0 | winner_mode_sf->multi_winner_mode_type = 0; |
1831 | 0 | winner_mode_sf->dc_blk_pred_level = 0; |
1832 | 0 | winner_mode_sf->winner_mode_ifs = 0; |
1833 | 0 | winner_mode_sf->prune_winner_mode_processing_using_src_var = 0; |
1834 | 0 | winner_mode_sf->disable_winner_mode_eval_for_txskip = 0; |
1835 | 0 | } |
1836 | | |
1837 | 0 | static AOM_INLINE void init_lpf_sf(LOOP_FILTER_SPEED_FEATURES *lpf_sf) { |
1838 | 0 | lpf_sf->disable_loop_restoration_chroma = 0; |
1839 | 0 | lpf_sf->disable_loop_restoration_luma = 0; |
1840 | 0 | lpf_sf->prune_wiener_based_on_src_var = 0; |
1841 | 0 | lpf_sf->prune_sgr_based_on_wiener = 0; |
1842 | 0 | lpf_sf->enable_sgr_ep_pruning = 0; |
1843 | 0 | lpf_sf->reduce_wiener_window_size = 0; |
1844 | 0 | lpf_sf->lpf_pick = LPF_PICK_FROM_FULL_IMAGE; |
1845 | 0 | lpf_sf->use_coarse_filter_level_search = 0; |
1846 | 0 | lpf_sf->cdef_pick_method = CDEF_FULL_SEARCH; |
1847 | | // Set decoder side speed feature to use less dual sgr modes |
1848 | 0 | lpf_sf->dual_sgr_penalty_level = 0; |
1849 | 0 | lpf_sf->disable_lr_filter = 0; |
1850 | 0 | lpf_sf->use_downsampled_wiener_stats = 0; |
1851 | 0 | } |
1852 | | |
1853 | 0 | static AOM_INLINE void init_rt_sf(REAL_TIME_SPEED_FEATURES *rt_sf) { |
1854 | 0 | rt_sf->check_intra_pred_nonrd = 0; |
1855 | 0 | rt_sf->skip_intra_pred_if_tx_skip = 0; |
1856 | 0 | rt_sf->estimate_motion_for_var_based_partition = 0; |
1857 | 0 | rt_sf->nonrd_check_partition_merge_mode = 0; |
1858 | 0 | rt_sf->nonrd_check_partition_split = 0; |
1859 | 0 | rt_sf->mode_search_skip_flags = 0; |
1860 | 0 | rt_sf->nonrd_prune_ref_frame_search = 0; |
1861 | 0 | rt_sf->use_nonrd_pick_mode = 0; |
1862 | 0 | rt_sf->use_nonrd_altref_frame = 0; |
1863 | 0 | rt_sf->use_comp_ref_nonrd = 0; |
1864 | 0 | rt_sf->use_real_time_ref_set = 0; |
1865 | 0 | rt_sf->short_circuit_low_temp_var = 0; |
1866 | 0 | rt_sf->use_modeled_non_rd_cost = 0; |
1867 | 0 | rt_sf->reuse_inter_pred_nonrd = 0; |
1868 | 0 | rt_sf->num_inter_modes_for_tx_search = INT_MAX; |
1869 | 0 | rt_sf->use_nonrd_filter_search = 0; |
1870 | 0 | rt_sf->use_simple_rd_model = 0; |
1871 | 0 | rt_sf->skip_interp_filter_search = 0; |
1872 | 0 | rt_sf->hybrid_intra_pickmode = 0; |
1873 | 0 | rt_sf->source_metrics_sb_nonrd = 0; |
1874 | 0 | rt_sf->overshoot_detection_cbr = NO_DETECTION; |
1875 | 0 | rt_sf->check_scene_detection = 0; |
1876 | 0 | rt_sf->force_large_partition_blocks = 0; |
1877 | 0 | rt_sf->use_temporal_noise_estimate = 0; |
1878 | 0 | rt_sf->fullpel_search_step_param = 0; |
1879 | 0 | for (int i = 0; i < BLOCK_SIZES; ++i) |
1880 | 0 | rt_sf->intra_y_mode_bsize_mask_nrd[i] = INTRA_ALL; |
1881 | 0 | rt_sf->nonrd_agressive_skip = 0; |
1882 | 0 | rt_sf->skip_cdef_sb = 0; |
1883 | 0 | rt_sf->force_large_partition_blocks_intra = 0; |
1884 | 0 | rt_sf->skip_tx_no_split_var_based_partition = 0; |
1885 | 0 | rt_sf->skip_newmv_mode_based_on_sse = 0; |
1886 | 0 | rt_sf->gf_length_lvl = 0; |
1887 | 0 | rt_sf->prune_inter_modes_with_golden_ref = 0; |
1888 | 0 | rt_sf->prune_inter_modes_wrt_gf_arf_based_on_sad = 0; |
1889 | 0 | rt_sf->prune_inter_modes_using_temp_var = 0; |
1890 | 0 | rt_sf->force_half_pel_block = 0; |
1891 | 0 | rt_sf->prune_intra_mode_based_on_mv_range = 0; |
1892 | 0 | rt_sf->var_part_split_threshold_shift = 7; |
1893 | 0 | rt_sf->gf_refresh_based_on_qp = 0; |
1894 | 0 | } |
1895 | | |
1896 | 0 | void av1_set_speed_features_framesize_dependent(AV1_COMP *cpi, int speed) { |
1897 | 0 | SPEED_FEATURES *const sf = &cpi->sf; |
1898 | 0 | const AV1EncoderConfig *const oxcf = &cpi->oxcf; |
1899 | |
|
1900 | 0 | switch (oxcf->mode) { |
1901 | 0 | case GOOD: |
1902 | 0 | set_good_speed_feature_framesize_dependent(cpi, sf, speed); |
1903 | 0 | break; |
1904 | 0 | case ALLINTRA: |
1905 | 0 | set_allintra_speed_feature_framesize_dependent(cpi, sf, speed); |
1906 | 0 | break; |
1907 | 0 | case REALTIME: |
1908 | 0 | set_rt_speed_feature_framesize_dependent(cpi, sf, speed); |
1909 | 0 | break; |
1910 | 0 | } |
1911 | | |
1912 | 0 | if (!cpi->ppi->seq_params_locked) { |
1913 | 0 | cpi->common.seq_params->enable_masked_compound &= |
1914 | 0 | !sf->inter_sf.disable_masked_comp; |
1915 | 0 | cpi->common.seq_params->enable_interintra_compound &= |
1916 | 0 | (sf->inter_sf.disable_interintra_wedge_var_thresh != UINT_MAX); |
1917 | 0 | } |
1918 | | |
1919 | | // This is only used in motion vector unit test. |
1920 | 0 | if (cpi->oxcf.unit_test_cfg.motion_vector_unit_test == 1) |
1921 | 0 | cpi->mv_search_params.find_fractional_mv_step = av1_return_max_sub_pixel_mv; |
1922 | 0 | else if (cpi->oxcf.unit_test_cfg.motion_vector_unit_test == 2) |
1923 | 0 | cpi->mv_search_params.find_fractional_mv_step = av1_return_min_sub_pixel_mv; |
1924 | | |
1925 | | // For multi-thread use case with row_mt enabled, cost update for a set of |
1926 | | // SB rows is not desirable. Hence, the sf mv_cost_upd_level is set to |
1927 | | // INTERNAL_COST_UPD_SBROW in such cases. |
1928 | 0 | if ((cpi->oxcf.row_mt == 1) && (cpi->mt_info.num_workers > 1)) { |
1929 | 0 | if (sf->inter_sf.mv_cost_upd_level == INTERNAL_COST_UPD_SBROW_SET) { |
1930 | | // Set mv_cost_upd_level to use row level update. |
1931 | 0 | sf->inter_sf.mv_cost_upd_level = INTERNAL_COST_UPD_SBROW; |
1932 | 0 | } |
1933 | 0 | } |
1934 | 0 | } |
1935 | | |
1936 | 0 | void av1_set_speed_features_framesize_independent(AV1_COMP *cpi, int speed) { |
1937 | 0 | SPEED_FEATURES *const sf = &cpi->sf; |
1938 | 0 | WinnerModeParams *const winner_mode_params = &cpi->winner_mode_params; |
1939 | 0 | const AV1EncoderConfig *const oxcf = &cpi->oxcf; |
1940 | 0 | int i; |
1941 | |
|
1942 | 0 | init_hl_sf(&sf->hl_sf); |
1943 | 0 | init_fp_sf(&sf->fp_sf); |
1944 | 0 | init_tpl_sf(&sf->tpl_sf); |
1945 | 0 | init_gm_sf(&sf->gm_sf); |
1946 | 0 | init_part_sf(&sf->part_sf); |
1947 | 0 | init_mv_sf(&sf->mv_sf); |
1948 | 0 | init_inter_sf(&sf->inter_sf); |
1949 | 0 | init_interp_sf(&sf->interp_sf); |
1950 | 0 | init_intra_sf(&sf->intra_sf); |
1951 | 0 | init_tx_sf(&sf->tx_sf); |
1952 | 0 | init_rd_sf(&sf->rd_sf, oxcf); |
1953 | 0 | init_winner_mode_sf(&sf->winner_mode_sf); |
1954 | 0 | init_lpf_sf(&sf->lpf_sf); |
1955 | 0 | init_rt_sf(&sf->rt_sf); |
1956 | |
|
1957 | 0 | switch (oxcf->mode) { |
1958 | 0 | case GOOD: |
1959 | 0 | set_good_speed_features_framesize_independent(cpi, sf, speed); |
1960 | 0 | break; |
1961 | 0 | case ALLINTRA: |
1962 | 0 | set_allintra_speed_features_framesize_independent(cpi, sf, speed); |
1963 | 0 | break; |
1964 | 0 | case REALTIME: |
1965 | 0 | set_rt_speed_features_framesize_independent(cpi, sf, speed); |
1966 | 0 | break; |
1967 | 0 | } |
1968 | | |
1969 | 0 | if (!oxcf->txfm_cfg.enable_tx_size_search) { |
1970 | 0 | sf->winner_mode_sf.tx_size_search_level = 3; |
1971 | 0 | } |
1972 | |
|
1973 | 0 | if (!cpi->ppi->seq_params_locked) { |
1974 | 0 | cpi->common.seq_params->order_hint_info.enable_dist_wtd_comp &= |
1975 | 0 | (sf->inter_sf.use_dist_wtd_comp_flag != DIST_WTD_COMP_DISABLED); |
1976 | 0 | cpi->common.seq_params->enable_dual_filter &= |
1977 | 0 | !sf->interp_sf.disable_dual_filter; |
1978 | 0 | cpi->common.seq_params->enable_restoration &= !sf->lpf_sf.disable_lr_filter; |
1979 | |
|
1980 | 0 | cpi->common.seq_params->enable_interintra_compound &= |
1981 | 0 | (sf->inter_sf.disable_interintra_wedge_var_thresh != UINT_MAX); |
1982 | 0 | } |
1983 | | |
1984 | | // sf->part_sf.partition_search_breakout_dist_thr is set assuming max 64x64 |
1985 | | // blocks. Normalise this if the blocks are bigger. |
1986 | 0 | if (MAX_SB_SIZE_LOG2 > 6) { |
1987 | 0 | sf->part_sf.partition_search_breakout_dist_thr <<= |
1988 | 0 | 2 * (MAX_SB_SIZE_LOG2 - 6); |
1989 | 0 | } |
1990 | |
|
1991 | 0 | const int mesh_speed = AOMMIN(speed, MAX_MESH_SPEED); |
1992 | 0 | for (i = 0; i < MAX_MESH_STEP; ++i) { |
1993 | 0 | sf->mv_sf.mesh_patterns[i].range = |
1994 | 0 | good_quality_mesh_patterns[mesh_speed][i].range; |
1995 | 0 | sf->mv_sf.mesh_patterns[i].interval = |
1996 | 0 | good_quality_mesh_patterns[mesh_speed][i].interval; |
1997 | 0 | } |
1998 | | |
1999 | | // Update the mesh pattern of exhaustive motion search for intraBC |
2000 | | // Though intraBC mesh pattern is populated for all frame types, it is used |
2001 | | // only for intra frames of screen contents |
2002 | 0 | for (i = 0; i < MAX_MESH_STEP; ++i) { |
2003 | 0 | sf->mv_sf.intrabc_mesh_patterns[i].range = |
2004 | 0 | intrabc_mesh_patterns[mesh_speed][i].range; |
2005 | 0 | sf->mv_sf.intrabc_mesh_patterns[i].interval = |
2006 | 0 | intrabc_mesh_patterns[mesh_speed][i].interval; |
2007 | 0 | } |
2008 | | |
2009 | | // Slow quant, dct and trellis not worthwhile for first pass |
2010 | | // so make sure they are always turned off. |
2011 | 0 | if (is_stat_generation_stage(cpi)) |
2012 | 0 | sf->rd_sf.optimize_coefficients = NO_TRELLIS_OPT; |
2013 | | |
2014 | | // No recode for 1 pass. |
2015 | 0 | if (oxcf->pass == AOM_RC_ONE_PASS && has_no_stats_stage(cpi)) |
2016 | 0 | sf->hl_sf.recode_loop = DISALLOW_RECODE; |
2017 | |
|
2018 | 0 | MotionVectorSearchParams *const mv_search_params = &cpi->mv_search_params; |
2019 | 0 | if (sf->mv_sf.subpel_search_method == SUBPEL_TREE) { |
2020 | 0 | mv_search_params->find_fractional_mv_step = av1_find_best_sub_pixel_tree; |
2021 | 0 | } else if (sf->mv_sf.subpel_search_method == SUBPEL_TREE_PRUNED) { |
2022 | 0 | mv_search_params->find_fractional_mv_step = |
2023 | 0 | av1_find_best_sub_pixel_tree_pruned; |
2024 | 0 | } else if (sf->mv_sf.subpel_search_method == SUBPEL_TREE_PRUNED_MORE) { |
2025 | 0 | mv_search_params->find_fractional_mv_step = |
2026 | 0 | av1_find_best_sub_pixel_tree_pruned_more; |
2027 | 0 | } |
2028 | | |
2029 | | // This is only used in motion vector unit test. |
2030 | 0 | if (cpi->oxcf.unit_test_cfg.motion_vector_unit_test == 1) |
2031 | 0 | mv_search_params->find_fractional_mv_step = av1_return_max_sub_pixel_mv; |
2032 | 0 | else if (cpi->oxcf.unit_test_cfg.motion_vector_unit_test == 2) |
2033 | 0 | mv_search_params->find_fractional_mv_step = av1_return_min_sub_pixel_mv; |
2034 | | |
2035 | | // assert ensures that tx_domain_dist_level is accessed correctly |
2036 | 0 | assert(cpi->sf.rd_sf.tx_domain_dist_thres_level >= 0 && |
2037 | 0 | cpi->sf.rd_sf.tx_domain_dist_thres_level < 4); |
2038 | 0 | memcpy(winner_mode_params->tx_domain_dist_threshold, |
2039 | 0 | tx_domain_dist_thresholds[cpi->sf.rd_sf.tx_domain_dist_thres_level], |
2040 | 0 | sizeof(winner_mode_params->tx_domain_dist_threshold)); |
2041 | |
|
2042 | 0 | assert(cpi->sf.rd_sf.tx_domain_dist_level >= 0 && |
2043 | 0 | cpi->sf.rd_sf.tx_domain_dist_level < 3); |
2044 | 0 | memcpy(winner_mode_params->use_transform_domain_distortion, |
2045 | 0 | tx_domain_dist_types[cpi->sf.rd_sf.tx_domain_dist_level], |
2046 | 0 | sizeof(winner_mode_params->use_transform_domain_distortion)); |
2047 | | |
2048 | | // assert ensures that coeff_opt_thresholds is accessed correctly |
2049 | 0 | assert(cpi->sf.rd_sf.perform_coeff_opt >= 0 && |
2050 | 0 | cpi->sf.rd_sf.perform_coeff_opt < 9); |
2051 | 0 | memcpy(winner_mode_params->coeff_opt_thresholds, |
2052 | 0 | &coeff_opt_thresholds[cpi->sf.rd_sf.perform_coeff_opt], |
2053 | 0 | sizeof(winner_mode_params->coeff_opt_thresholds)); |
2054 | | |
2055 | | // assert ensures that predict_skip_levels is accessed correctly |
2056 | 0 | assert(cpi->sf.tx_sf.tx_type_search.use_skip_flag_prediction >= 0 && |
2057 | 0 | cpi->sf.tx_sf.tx_type_search.use_skip_flag_prediction < 3); |
2058 | 0 | memcpy(winner_mode_params->skip_txfm_level, |
2059 | 0 | predict_skip_levels[cpi->sf.tx_sf.tx_type_search |
2060 | 0 | .use_skip_flag_prediction], |
2061 | 0 | sizeof(winner_mode_params->skip_txfm_level)); |
2062 | | |
2063 | | // assert ensures that tx_size_search_level is accessed correctly |
2064 | 0 | assert(cpi->sf.winner_mode_sf.tx_size_search_level >= 0 && |
2065 | 0 | cpi->sf.winner_mode_sf.tx_size_search_level < 3); |
2066 | 0 | memcpy(winner_mode_params->tx_size_search_methods, |
2067 | 0 | tx_size_search_methods[cpi->sf.winner_mode_sf.tx_size_search_level], |
2068 | 0 | sizeof(winner_mode_params->tx_size_search_methods)); |
2069 | 0 | memcpy(winner_mode_params->predict_dc_level, |
2070 | 0 | predict_dc_levels[cpi->sf.winner_mode_sf.dc_blk_pred_level], |
2071 | 0 | sizeof(winner_mode_params->predict_dc_level)); |
2072 | |
|
2073 | 0 | if (cpi->oxcf.row_mt == 1 && (cpi->mt_info.num_workers > 1)) { |
2074 | 0 | if (sf->inter_sf.inter_mode_rd_model_estimation == 1) { |
2075 | | // Revert to type 2 |
2076 | 0 | sf->inter_sf.inter_mode_rd_model_estimation = 2; |
2077 | 0 | } |
2078 | |
|
2079 | 0 | #if !CONFIG_FRAME_PARALLEL_ENCODE || \ |
2080 | 0 | (CONFIG_FRAME_PARALLEL_ENCODE && !CONFIG_FPMT_TEST) |
2081 | | // Disable the speed feature 'prune_ref_frame_for_gm_search' to achieve |
2082 | | // better parallelism when number of threads available are greater than or |
2083 | | // equal to maximum number of reference frames allowed for global motion. |
2084 | 0 | if (sf->gm_sf.gm_search_type != GM_DISABLE_SEARCH && |
2085 | 0 | (cpi->mt_info.num_workers >= |
2086 | 0 | gm_available_reference_frames[sf->gm_sf.gm_search_type])) |
2087 | 0 | sf->gm_sf.prune_ref_frame_for_gm_search = 0; |
2088 | 0 | #endif |
2089 | 0 | } |
2090 | | |
2091 | | // This only applies to the real time mode. Adaptive gf refresh is disabled if |
2092 | | // gf_cbr_boost_pct that is set by the user is larger than 0. |
2093 | 0 | if (cpi->oxcf.rc_cfg.gf_cbr_boost_pct > 0) |
2094 | 0 | sf->rt_sf.gf_refresh_based_on_qp = 0; |
2095 | 0 | } |
2096 | | |
2097 | | // Override some speed features based on qindex |
2098 | 0 | void av1_set_speed_features_qindex_dependent(AV1_COMP *cpi, int speed) { |
2099 | 0 | AV1_COMMON *const cm = &cpi->common; |
2100 | 0 | SPEED_FEATURES *const sf = &cpi->sf; |
2101 | 0 | WinnerModeParams *const winner_mode_params = &cpi->winner_mode_params; |
2102 | 0 | const int boosted = frame_is_boosted(cpi); |
2103 | 0 | const int is_480p_or_larger = AOMMIN(cm->width, cm->height) >= 480; |
2104 | 0 | const int is_720p_or_larger = AOMMIN(cm->width, cm->height) >= 720; |
2105 | 0 | const int is_1080p_or_larger = AOMMIN(cm->width, cm->height) >= 1080; |
2106 | 0 | const int is_arf2_bwd_type = |
2107 | 0 | cpi->ppi->gf_group.update_type[cpi->gf_frame_index] == INTNL_ARF_UPDATE; |
2108 | |
|
2109 | 0 | if (cpi->oxcf.mode == REALTIME) { |
2110 | 0 | if (speed >= 6) { |
2111 | 0 | const int qindex_thresh = boosted ? 190 : (is_720p_or_larger ? 120 : 150); |
2112 | 0 | sf->part_sf.adjust_var_based_rd_partitioning = |
2113 | 0 | frame_is_intra_only(cm) |
2114 | 0 | ? 0 |
2115 | 0 | : cm->quant_params.base_qindex > qindex_thresh; |
2116 | 0 | } |
2117 | 0 | return; |
2118 | 0 | } |
2119 | | |
2120 | 0 | if (speed == 0) { |
2121 | | // qindex_thresh for resolution < 720p |
2122 | 0 | const int qindex_thresh = boosted ? 70 : (is_arf2_bwd_type ? 110 : 140); |
2123 | 0 | if (!is_720p_or_larger && cm->quant_params.base_qindex <= qindex_thresh) { |
2124 | 0 | sf->part_sf.simple_motion_search_split = |
2125 | 0 | cm->features.allow_screen_content_tools ? 1 : 2; |
2126 | 0 | sf->part_sf.simple_motion_search_early_term_none = 1; |
2127 | 0 | sf->tx_sf.model_based_prune_tx_search_level = 0; |
2128 | 0 | } |
2129 | |
|
2130 | 0 | if (is_720p_or_larger && cm->quant_params.base_qindex <= 128) { |
2131 | 0 | sf->rd_sf.perform_coeff_opt = 2 + is_1080p_or_larger; |
2132 | 0 | memcpy(winner_mode_params->coeff_opt_thresholds, |
2133 | 0 | &coeff_opt_thresholds[sf->rd_sf.perform_coeff_opt], |
2134 | 0 | sizeof(winner_mode_params->coeff_opt_thresholds)); |
2135 | 0 | sf->part_sf.simple_motion_search_split = |
2136 | 0 | cm->features.allow_screen_content_tools ? 1 : 2; |
2137 | 0 | sf->tx_sf.inter_tx_size_search_init_depth_rect = 1; |
2138 | 0 | sf->tx_sf.inter_tx_size_search_init_depth_sqr = 1; |
2139 | 0 | sf->tx_sf.intra_tx_size_search_init_depth_rect = 1; |
2140 | 0 | sf->tx_sf.model_based_prune_tx_search_level = 0; |
2141 | |
|
2142 | 0 | if (is_1080p_or_larger && cm->quant_params.base_qindex <= 108) { |
2143 | 0 | sf->inter_sf.selective_ref_frame = 2; |
2144 | 0 | sf->rd_sf.tx_domain_dist_level = boosted ? 1 : 2; |
2145 | 0 | sf->rd_sf.tx_domain_dist_thres_level = 1; |
2146 | 0 | sf->part_sf.simple_motion_search_early_term_none = 1; |
2147 | 0 | sf->tx_sf.tx_type_search.ml_tx_split_thresh = 4000; |
2148 | 0 | sf->interp_sf.cb_pred_filter_search = 0; |
2149 | 0 | sf->tx_sf.tx_type_search.prune_2d_txfm_mode = TX_TYPE_PRUNE_2; |
2150 | 0 | sf->tx_sf.tx_type_search.skip_tx_search = 1; |
2151 | 0 | } |
2152 | 0 | } |
2153 | 0 | } |
2154 | |
|
2155 | 0 | if (speed >= 2) { |
2156 | | // Disable extended partitions for lower quantizers |
2157 | 0 | const int aggr = AOMMIN(3, speed - 2); |
2158 | 0 | const int qindex_thresh1[4] = { 50, 50, 80, 100 }; |
2159 | 0 | const int qindex_thresh2[4] = { 80, 100, 120, 160 }; |
2160 | 0 | int qindex_thresh; |
2161 | 0 | int disable_ext_part; |
2162 | 0 | if (aggr <= 1) { |
2163 | 0 | const int qthresh2 = |
2164 | 0 | (!aggr && !is_480p_or_larger) ? 70 : qindex_thresh2[aggr]; |
2165 | 0 | qindex_thresh = cm->features.allow_screen_content_tools |
2166 | 0 | ? qindex_thresh1[aggr] |
2167 | 0 | : qthresh2; |
2168 | 0 | disable_ext_part = !boosted; |
2169 | 0 | } else { |
2170 | 0 | qindex_thresh = boosted ? qindex_thresh1[aggr] : qindex_thresh2[aggr]; |
2171 | 0 | disable_ext_part = !frame_is_intra_only(cm); |
2172 | 0 | } |
2173 | 0 | if (cm->quant_params.base_qindex <= qindex_thresh && disable_ext_part) { |
2174 | 0 | sf->part_sf.ext_partition_eval_thresh = BLOCK_128X128; |
2175 | 0 | } |
2176 | 0 | } |
2177 | |
|
2178 | 0 | if (speed >= 4) { |
2179 | | // Disable rectangular partitions for lower quantizers |
2180 | 0 | const int aggr = AOMMIN(1, speed - 4); |
2181 | 0 | const int qindex_thresh[2] = { 65, 80 }; |
2182 | 0 | int disable_rect_part; |
2183 | 0 | disable_rect_part = !boosted; |
2184 | 0 | if (cm->quant_params.base_qindex <= qindex_thresh[aggr] && |
2185 | 0 | disable_rect_part && is_480p_or_larger) { |
2186 | 0 | sf->part_sf.rect_partition_eval_thresh = BLOCK_8X8; |
2187 | 0 | } |
2188 | 0 | } |
2189 | |
|
2190 | 0 | if (speed <= 2) { |
2191 | 0 | if (!is_stat_generation_stage(cpi)) { |
2192 | | // Use faster full-pel motion search for high quantizers. |
2193 | | // Also use reduced total search range for low resolutions at high |
2194 | | // quantizers. |
2195 | 0 | const int aggr = speed; |
2196 | 0 | const int qindex_thresh1 = ms_qindex_thresh[aggr][is_720p_or_larger][0]; |
2197 | 0 | const int qindex_thresh2 = ms_qindex_thresh[aggr][is_720p_or_larger][1]; |
2198 | 0 | const SEARCH_METHODS search_method = |
2199 | 0 | motion_search_method[is_720p_or_larger]; |
2200 | 0 | if (cm->quant_params.base_qindex > qindex_thresh1) { |
2201 | 0 | sf->mv_sf.search_method = search_method; |
2202 | 0 | sf->tpl_sf.search_method = search_method; |
2203 | 0 | } else if (cm->quant_params.base_qindex > qindex_thresh2) { |
2204 | 0 | sf->mv_sf.search_method = NSTEP_8PT; |
2205 | 0 | } |
2206 | 0 | } |
2207 | 0 | } |
2208 | |
|
2209 | 0 | if (speed >= 4) { |
2210 | | // Disable LR search at low and high quantizers and enable only for |
2211 | | // mid-quantizer range. |
2212 | 0 | if (!boosted && !is_arf2_bwd_type) { |
2213 | 0 | const int qindex_low[2] = { 100, 60 }; |
2214 | 0 | const int qindex_high[2] = { 180, 160 }; |
2215 | 0 | if (cm->quant_params.base_qindex <= qindex_low[is_720p_or_larger] || |
2216 | 0 | cm->quant_params.base_qindex > qindex_high[is_720p_or_larger]) { |
2217 | 0 | sf->lpf_sf.disable_loop_restoration_luma = 1; |
2218 | 0 | } |
2219 | 0 | } |
2220 | 0 | } |
2221 | 0 | } |