Line data Source code
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/encoder/encoder.h"
15 : #include "av1/encoder/speed_features.h"
16 : #include "av1/encoder/rdopt.h"
17 :
18 : #include "aom_dsp/aom_dsp_common.h"
19 :
20 : #define MAX_MESH_SPEED 5 // Max speed setting for mesh motion method
21 : static MESH_PATTERN
22 : good_quality_mesh_patterns[MAX_MESH_SPEED + 1][MAX_MESH_STEP] = {
23 : { { 64, 8 }, { 28, 4 }, { 15, 1 }, { 7, 1 } },
24 : { { 64, 8 }, { 28, 4 }, { 15, 1 }, { 7, 1 } },
25 : { { 64, 8 }, { 14, 2 }, { 7, 1 }, { 7, 1 } },
26 : { { 64, 16 }, { 24, 8 }, { 12, 4 }, { 7, 1 } },
27 : { { 64, 16 }, { 24, 8 }, { 12, 4 }, { 7, 1 } },
28 : { { 64, 16 }, { 24, 8 }, { 12, 4 }, { 7, 1 } },
29 : };
30 : static unsigned char good_quality_max_mesh_pct[MAX_MESH_SPEED + 1] = {
31 : 50, 25, 15, 5, 1, 1
32 : };
33 :
34 : #if CONFIG_INTRABC
35 : // TODO(aconverse@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 : { { 64, 1 }, { 64, 1 }, { 0, 0 }, { 0, 0 } },
39 : { { 64, 1 }, { 64, 1 }, { 0, 0 }, { 0, 0 } },
40 : { { 64, 1 }, { 64, 1 }, { 0, 0 }, { 0, 0 } },
41 : { { 64, 4 }, { 16, 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 : static uint8_t intrabc_max_mesh_pct[MAX_MESH_SPEED + 1] = { 100, 100, 100,
46 : 25, 25, 10 };
47 : #endif
48 :
49 : // Intra only frames, golden frames (except alt ref overlays) and
50 : // alt ref frames tend to be coded at a higher than ambient quality
51 0 : static int frame_is_boosted(const AV1_COMP *cpi) {
52 0 : return frame_is_kf_gf_arf(cpi);
53 : }
54 :
55 : // Sets a partition size down to which the auto partition code will always
56 : // search (can go lower), based on the image dimensions. The logic here
57 : // is that the extent to which ringing artefacts are offensive, depends
58 : // partly on the screen area that over which they propogate. Propogation is
59 : // limited by transform block size but the screen area take up by a given block
60 : // size will be larger for a small image format stretched to full screen.
61 0 : static BLOCK_SIZE set_partition_min_limit(AV1_COMMON *const cm) {
62 0 : unsigned int screen_area = (cm->width * cm->height);
63 :
64 : // Select block size based on image format size.
65 0 : if (screen_area < 1280 * 720) {
66 : // Formats smaller in area than 720P
67 0 : return BLOCK_4X4;
68 0 : } else if (screen_area < 1920 * 1080) {
69 : // Format >= 720P and < 1080P
70 0 : return BLOCK_8X8;
71 : } else {
72 : // Formats 1080P and up
73 0 : return BLOCK_16X16;
74 : }
75 : }
76 :
77 0 : static void set_good_speed_feature_framesize_dependent(AV1_COMP *cpi,
78 : SPEED_FEATURES *sf,
79 : int speed) {
80 0 : AV1_COMMON *const cm = &cpi->common;
81 :
82 0 : if (speed >= 1) {
83 0 : if (AOMMIN(cm->width, cm->height) >= 720) {
84 0 : sf->disable_split_mask =
85 0 : cm->show_frame ? DISABLE_ALL_SPLIT : DISABLE_ALL_INTER_SPLIT;
86 0 : sf->partition_search_breakout_dist_thr = (1 << 23);
87 : } else {
88 0 : sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
89 0 : sf->partition_search_breakout_dist_thr = (1 << 21);
90 : }
91 : }
92 :
93 0 : if (speed >= 2) {
94 0 : if (AOMMIN(cm->width, cm->height) >= 720) {
95 0 : sf->disable_split_mask =
96 0 : cm->show_frame ? DISABLE_ALL_SPLIT : DISABLE_ALL_INTER_SPLIT;
97 0 : sf->adaptive_pred_interp_filter = 0;
98 0 : sf->partition_search_breakout_dist_thr = (1 << 24);
99 0 : sf->partition_search_breakout_rate_thr = 120;
100 : } else {
101 0 : sf->disable_split_mask = LAST_AND_INTRA_SPLIT_ONLY;
102 0 : sf->partition_search_breakout_dist_thr = (1 << 22);
103 0 : sf->partition_search_breakout_rate_thr = 100;
104 : }
105 0 : sf->rd_auto_partition_min_limit = set_partition_min_limit(cm);
106 : }
107 :
108 0 : if (speed >= 3) {
109 0 : if (AOMMIN(cm->width, cm->height) >= 720) {
110 0 : sf->disable_split_mask = DISABLE_ALL_SPLIT;
111 0 : sf->schedule_mode_search = cm->base_qindex < 220 ? 1 : 0;
112 0 : sf->partition_search_breakout_dist_thr = (1 << 25);
113 0 : sf->partition_search_breakout_rate_thr = 200;
114 : } else {
115 0 : sf->max_intra_bsize = BLOCK_32X32;
116 0 : sf->disable_split_mask = DISABLE_ALL_INTER_SPLIT;
117 0 : sf->schedule_mode_search = cm->base_qindex < 175 ? 1 : 0;
118 0 : sf->partition_search_breakout_dist_thr = (1 << 23);
119 0 : sf->partition_search_breakout_rate_thr = 120;
120 : }
121 : }
122 :
123 : // If this is a two pass clip that fits the criteria for animated or
124 : // graphics content then reset disable_split_mask for speeds 1-4.
125 : // Also if the image edge is internal to the coded area.
126 0 : if ((speed >= 1) && (cpi->oxcf.pass == 2) &&
127 0 : ((cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION) ||
128 0 : (av1_internal_image_edge(cpi)))) {
129 0 : sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
130 : }
131 :
132 0 : if (speed >= 4) {
133 0 : if (AOMMIN(cm->width, cm->height) >= 720) {
134 0 : sf->partition_search_breakout_dist_thr = (1 << 26);
135 : } else {
136 0 : sf->partition_search_breakout_dist_thr = (1 << 24);
137 : }
138 0 : sf->disable_split_mask = DISABLE_ALL_SPLIT;
139 : }
140 0 : }
141 :
142 0 : static void set_good_speed_features_framesize_independent(AV1_COMP *cpi,
143 : SPEED_FEATURES *sf,
144 : int speed) {
145 0 : AV1_COMMON *const cm = &cpi->common;
146 0 : const int boosted = frame_is_boosted(cpi);
147 :
148 0 : if (speed >= 1) {
149 0 : sf->tx_type_search.fast_intra_tx_type_search = 1;
150 0 : sf->tx_type_search.fast_inter_tx_type_search = 1;
151 : }
152 :
153 0 : if (speed >= 2) {
154 0 : if ((cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION) ||
155 0 : av1_internal_image_edge(cpi)) {
156 0 : sf->use_square_partition_only = !frame_is_boosted(cpi);
157 : } else {
158 0 : sf->use_square_partition_only = !frame_is_intra_only(cm);
159 : }
160 :
161 0 : sf->less_rectangular_check = 1;
162 :
163 0 : sf->use_rd_breakout = 1;
164 0 : sf->adaptive_motion_search = 1;
165 0 : sf->mv.auto_mv_step_size = 1;
166 0 : sf->adaptive_rd_thresh = 1;
167 0 : sf->mv.subpel_iters_per_step = 1;
168 0 : sf->mode_skip_start = 10;
169 0 : sf->adaptive_pred_interp_filter = 1;
170 :
171 0 : sf->recode_loop = ALLOW_RECODE_KFARFGF;
172 : #if CONFIG_TX64X64
173 : sf->intra_y_mode_mask[TX_64X64] = INTRA_DC_H_V;
174 : sf->intra_uv_mode_mask[TX_64X64] = INTRA_DC_H_V;
175 : #endif // CONFIG_TX64X64
176 0 : sf->intra_y_mode_mask[TX_32X32] = INTRA_DC_H_V;
177 0 : sf->intra_uv_mode_mask[TX_32X32] = INTRA_DC_H_V;
178 0 : sf->intra_y_mode_mask[TX_16X16] = INTRA_DC_H_V;
179 0 : sf->intra_uv_mode_mask[TX_16X16] = INTRA_DC_H_V;
180 :
181 0 : sf->tx_size_search_breakout = 1;
182 0 : sf->partition_search_breakout_rate_thr = 80;
183 0 : sf->tx_type_search.prune_mode = PRUNE_ONE;
184 : // Use transform domain distortion.
185 : // Note var-tx expt always uses pixel domain distortion.
186 0 : sf->use_transform_domain_distortion = 1;
187 : #if CONFIG_EXT_INTER
188 0 : sf->disable_wedge_search_var_thresh = 100;
189 0 : sf->fast_wedge_sign_estimate = 1;
190 : #endif // CONFIG_EXT_INTER
191 : }
192 :
193 0 : if (speed >= 3) {
194 0 : sf->tx_size_search_method =
195 0 : frame_is_boosted(cpi) ? USE_FULL_RD : USE_LARGESTALL;
196 0 : sf->mode_search_skip_flags =
197 0 : (cm->frame_type == KEY_FRAME)
198 : ? 0
199 0 : : FLAG_SKIP_INTRA_DIRMISMATCH | FLAG_SKIP_INTRA_BESTINTER |
200 : FLAG_SKIP_COMP_BESTINTRA | FLAG_SKIP_INTRA_LOWVAR;
201 0 : sf->disable_filter_search_var_thresh = 100;
202 0 : sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
203 0 : sf->auto_min_max_partition_size = RELAXED_NEIGHBORING_MIN_MAX;
204 0 : sf->allow_partition_search_skip = 1;
205 0 : sf->use_upsampled_references = 0;
206 0 : sf->adaptive_rd_thresh = 2;
207 : #if CONFIG_EXT_TX
208 0 : sf->tx_type_search.prune_mode = PRUNE_TWO;
209 : #endif
210 : #if CONFIG_GLOBAL_MOTION
211 0 : sf->gm_search_type = GM_DISABLE_SEARCH;
212 : #endif // CONFIG_GLOBAL_MOTION
213 : }
214 :
215 0 : if (speed >= 4) {
216 0 : sf->use_square_partition_only = !frame_is_intra_only(cm);
217 0 : sf->tx_size_search_method =
218 0 : frame_is_intra_only(cm) ? USE_FULL_RD : USE_LARGESTALL;
219 0 : sf->mv.subpel_search_method = SUBPEL_TREE_PRUNED;
220 0 : sf->adaptive_pred_interp_filter = 0;
221 0 : sf->adaptive_mode_search = 1;
222 0 : sf->cb_partition_search = !boosted;
223 0 : sf->cb_pred_filter_search = 1;
224 0 : sf->alt_ref_search_fp = 1;
225 0 : sf->recode_loop = ALLOW_RECODE_KFMAXBW;
226 0 : sf->adaptive_rd_thresh = 3;
227 0 : sf->mode_skip_start = 6;
228 : #if CONFIG_TX64X64
229 : sf->intra_y_mode_mask[TX_64X64] = INTRA_DC;
230 : sf->intra_uv_mode_mask[TX_64X64] = INTRA_DC;
231 : #endif // CONFIG_TX64X64
232 0 : sf->intra_y_mode_mask[TX_32X32] = INTRA_DC;
233 0 : sf->intra_uv_mode_mask[TX_32X32] = INTRA_DC;
234 0 : sf->adaptive_interp_filter_search = 1;
235 : }
236 :
237 0 : if (speed >= 5) {
238 0 : sf->use_square_partition_only = 1;
239 0 : sf->tx_size_search_method = USE_LARGESTALL;
240 0 : sf->mv.search_method = BIGDIA;
241 0 : sf->mv.subpel_search_method = SUBPEL_TREE_PRUNED_MORE;
242 0 : sf->adaptive_rd_thresh = 4;
243 0 : if (cm->frame_type != KEY_FRAME)
244 0 : sf->mode_search_skip_flags |= FLAG_EARLY_TERMINATE;
245 0 : sf->disable_filter_search_var_thresh = 200;
246 0 : sf->use_fast_coef_updates = ONE_LOOP_REDUCED;
247 0 : sf->use_fast_coef_costing = 1;
248 0 : sf->partition_search_breakout_rate_thr = 300;
249 : }
250 :
251 0 : if (speed >= 6) {
252 : int i;
253 0 : sf->optimize_coefficients = 0;
254 0 : sf->mv.search_method = HEX;
255 0 : sf->disable_filter_search_var_thresh = 500;
256 0 : for (i = 0; i < TX_SIZES; ++i) {
257 0 : sf->intra_y_mode_mask[i] = INTRA_DC;
258 0 : sf->intra_uv_mode_mask[i] = INTRA_DC;
259 : }
260 0 : sf->partition_search_breakout_rate_thr = 500;
261 0 : sf->mv.reduce_first_step_size = 1;
262 0 : sf->simple_model_rd_from_var = 1;
263 : }
264 0 : if (speed >= 7) {
265 0 : const int is_keyframe = cm->frame_type == KEY_FRAME;
266 0 : const int frames_since_key = is_keyframe ? 0 : cpi->rc.frames_since_key;
267 0 : sf->default_max_partition_size = BLOCK_32X32;
268 0 : sf->default_min_partition_size = BLOCK_8X8;
269 : #if CONFIG_TX64X64
270 : sf->intra_y_mode_mask[TX_64X64] = INTRA_DC;
271 : #endif // CONFIG_TX64X64
272 0 : sf->intra_y_mode_mask[TX_32X32] = INTRA_DC;
273 0 : sf->frame_parameter_update = 0;
274 0 : sf->mv.search_method = FAST_HEX;
275 0 : sf->inter_mode_mask[BLOCK_32X32] = INTER_NEAREST_NEAR_NEW;
276 0 : sf->inter_mode_mask[BLOCK_32X64] = INTER_NEAREST;
277 0 : sf->inter_mode_mask[BLOCK_64X32] = INTER_NEAREST;
278 0 : sf->inter_mode_mask[BLOCK_64X64] = INTER_NEAREST;
279 : #if CONFIG_EXT_PARTITION
280 : sf->inter_mode_mask[BLOCK_64X128] = INTER_NEAREST;
281 : sf->inter_mode_mask[BLOCK_128X64] = INTER_NEAREST;
282 : sf->inter_mode_mask[BLOCK_128X128] = INTER_NEAREST;
283 : #endif // CONFIG_EXT_PARTITION
284 0 : sf->partition_search_type = REFERENCE_PARTITION;
285 0 : sf->default_min_partition_size = BLOCK_8X8;
286 0 : sf->reuse_inter_pred_sby = 1;
287 0 : sf->force_frame_boost =
288 0 : is_keyframe ||
289 0 : (frames_since_key % (sf->last_partitioning_redo_frequency << 1) == 1);
290 0 : sf->max_delta_qindex = is_keyframe ? 20 : 15;
291 0 : sf->coeff_prob_appx_step = 4;
292 0 : sf->mode_search_skip_flags |= FLAG_SKIP_INTRA_DIRMISMATCH;
293 : }
294 0 : if (speed >= 8) {
295 0 : sf->mv.search_method = FAST_DIAMOND;
296 0 : sf->mv.fullpel_search_step_param = 10;
297 0 : sf->mv.subpel_force_stop = 2;
298 0 : sf->lpf_pick = LPF_PICK_MINIMAL_LPF;
299 : }
300 0 : }
301 :
302 0 : void av1_set_speed_features_framesize_dependent(AV1_COMP *cpi) {
303 0 : SPEED_FEATURES *const sf = &cpi->sf;
304 0 : const AV1EncoderConfig *const oxcf = &cpi->oxcf;
305 0 : AV1_COMMON *const cm = &cpi->common;
306 0 : RD_OPT *const rd = &cpi->rd;
307 : int i;
308 :
309 : // Limit memory usage for high resolutions
310 : #if CONFIG_EXT_REFS
311 : // TODO(zoeliu): Temporary solution to resolve the insufficient RAM issue for
312 : // ext-refs. Need to work with @yunqingwang to have a more
313 : // effective solution.
314 0 : if (AOMMIN(cm->width, cm->height) > 720) {
315 : // Turn off the use of upsampled references for HD resolution
316 0 : sf->use_upsampled_references = 0;
317 0 : } else if ((AOMMIN(cm->width, cm->height) > 540) &&
318 0 : (oxcf->profile != PROFILE_0)) {
319 0 : sf->use_upsampled_references = 0;
320 : }
321 : #else
322 : if (AOMMIN(cm->width, cm->height) > 1080) {
323 : sf->use_upsampled_references = 0;
324 : } else if ((AOMMIN(cm->width, cm->height) > 720) &&
325 : (oxcf->profile != PROFILE_0)) {
326 : sf->use_upsampled_references = 0;
327 : }
328 : #endif // CONFIG_EXT_REFS
329 :
330 0 : if (oxcf->mode == GOOD) {
331 0 : set_good_speed_feature_framesize_dependent(cpi, sf, oxcf->speed);
332 : }
333 :
334 0 : if (sf->disable_split_mask == DISABLE_ALL_SPLIT) {
335 0 : sf->adaptive_pred_interp_filter = 0;
336 : }
337 :
338 : // Check for masked out split cases.
339 0 : for (i = 0; i < MAX_REFS; ++i) {
340 0 : if (sf->disable_split_mask & (1 << i)) {
341 0 : rd->thresh_mult_sub8x8[i] = INT_MAX;
342 : }
343 : }
344 :
345 : // This is only used in motion vector unit test.
346 0 : if (cpi->oxcf.motion_vector_unit_test == 1)
347 0 : cpi->find_fractional_mv_step = av1_return_max_sub_pixel_mv;
348 0 : else if (cpi->oxcf.motion_vector_unit_test == 2)
349 0 : cpi->find_fractional_mv_step = av1_return_min_sub_pixel_mv;
350 0 : }
351 :
352 0 : void av1_set_speed_features_framesize_independent(AV1_COMP *cpi) {
353 0 : AV1_COMMON *const cm = &cpi->common;
354 0 : SPEED_FEATURES *const sf = &cpi->sf;
355 0 : MACROBLOCK *const x = &cpi->td.mb;
356 0 : const AV1EncoderConfig *const oxcf = &cpi->oxcf;
357 : int i;
358 :
359 : (void)cm;
360 : // best quality defaults
361 0 : sf->frame_parameter_update = 1;
362 0 : sf->mv.search_method = NSTEP;
363 0 : sf->recode_loop = ALLOW_RECODE;
364 0 : sf->mv.subpel_search_method = SUBPEL_TREE;
365 0 : sf->mv.subpel_iters_per_step = 2;
366 0 : sf->mv.subpel_force_stop = 0;
367 0 : sf->optimize_coefficients = !is_lossless_requested(&cpi->oxcf);
368 0 : sf->mv.reduce_first_step_size = 0;
369 0 : sf->coeff_prob_appx_step = 1;
370 0 : sf->mv.auto_mv_step_size = 0;
371 0 : sf->mv.fullpel_search_step_param = 6;
372 0 : sf->comp_inter_joint_search_thresh = BLOCK_4X4;
373 0 : sf->adaptive_rd_thresh = 0;
374 0 : sf->tx_size_search_method = USE_FULL_RD;
375 0 : sf->adaptive_motion_search = 0;
376 0 : sf->adaptive_pred_interp_filter = 0;
377 0 : sf->adaptive_mode_search = 0;
378 0 : sf->cb_pred_filter_search = 0;
379 0 : sf->cb_partition_search = 0;
380 0 : sf->alt_ref_search_fp = 0;
381 0 : sf->partition_search_type = SEARCH_PARTITION;
382 0 : sf->tx_type_search.prune_mode = NO_PRUNE;
383 0 : sf->tx_type_search.fast_intra_tx_type_search = 0;
384 0 : sf->tx_type_search.fast_inter_tx_type_search = 0;
385 0 : sf->less_rectangular_check = 0;
386 0 : sf->use_square_partition_only = 0;
387 0 : sf->auto_min_max_partition_size = NOT_IN_USE;
388 0 : sf->rd_auto_partition_min_limit = BLOCK_4X4;
389 0 : sf->default_max_partition_size = BLOCK_LARGEST;
390 0 : sf->default_min_partition_size = BLOCK_4X4;
391 0 : sf->adjust_partitioning_from_last_frame = 0;
392 0 : sf->last_partitioning_redo_frequency = 4;
393 0 : sf->disable_split_mask = 0;
394 0 : sf->mode_search_skip_flags = 0;
395 0 : sf->force_frame_boost = 0;
396 0 : sf->max_delta_qindex = 0;
397 0 : sf->disable_filter_search_var_thresh = 0;
398 0 : sf->adaptive_interp_filter_search = 0;
399 0 : sf->allow_partition_search_skip = 0;
400 0 : sf->use_upsampled_references = 1;
401 : #if CONFIG_EXT_INTER
402 0 : sf->disable_wedge_search_var_thresh = 0;
403 0 : sf->fast_wedge_sign_estimate = 0;
404 : #endif // CONFIG_EXT_INTER
405 :
406 0 : for (i = 0; i < TX_SIZES; i++) {
407 0 : sf->intra_y_mode_mask[i] = INTRA_ALL;
408 0 : sf->intra_uv_mode_mask[i] = INTRA_ALL;
409 : }
410 0 : sf->use_rd_breakout = 0;
411 0 : sf->lpf_pick = LPF_PICK_FROM_FULL_IMAGE;
412 0 : sf->use_fast_coef_updates = TWO_LOOP;
413 0 : sf->use_fast_coef_costing = 0;
414 0 : sf->mode_skip_start = MAX_MODES; // Mode index at which mode skip mask set
415 0 : sf->schedule_mode_search = 0;
416 0 : for (i = 0; i < BLOCK_SIZES; ++i) sf->inter_mode_mask[i] = INTER_ALL;
417 0 : sf->max_intra_bsize = BLOCK_LARGEST;
418 0 : sf->reuse_inter_pred_sby = 0;
419 : // This setting only takes effect when partition_search_type is set
420 : // to FIXED_PARTITION.
421 0 : sf->always_this_block_size = BLOCK_16X16;
422 0 : sf->search_type_check_frequency = 50;
423 : // Recode loop tolerance %.
424 0 : sf->recode_tolerance = 25;
425 0 : sf->default_interp_filter = SWITCHABLE;
426 0 : sf->tx_size_search_breakout = 0;
427 0 : sf->partition_search_breakout_dist_thr = 0;
428 0 : sf->partition_search_breakout_rate_thr = 0;
429 0 : sf->simple_model_rd_from_var = 0;
430 :
431 : // Set this at the appropriate speed levels
432 0 : sf->use_transform_domain_distortion = 0;
433 : #if CONFIG_GLOBAL_MOTION
434 0 : sf->gm_search_type = GM_FULL_SEARCH;
435 : #endif // CONFIG_GLOBAL_MOTION
436 :
437 0 : if (oxcf->mode == GOOD
438 : #if CONFIG_XIPHRC
439 : || oxcf->pass == 1
440 : #endif
441 : )
442 0 : set_good_speed_features_framesize_independent(cpi, sf, oxcf->speed);
443 :
444 : // sf->partition_search_breakout_dist_thr is set assuming max 64x64
445 : // blocks. Normalise this if the blocks are bigger.
446 : if (MAX_SB_SIZE_LOG2 > 6) {
447 : sf->partition_search_breakout_dist_thr <<= 2 * (MAX_SB_SIZE_LOG2 - 6);
448 : }
449 :
450 0 : cpi->full_search_sad = av1_full_search_sad;
451 0 : cpi->diamond_search_sad = av1_diamond_search_sad;
452 :
453 0 : sf->allow_exhaustive_searches = 1;
454 0 : int speed = (oxcf->speed > MAX_MESH_SPEED) ? MAX_MESH_SPEED : oxcf->speed;
455 0 : if (cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION)
456 0 : sf->exhaustive_searches_thresh = (1 << 24);
457 : else
458 0 : sf->exhaustive_searches_thresh = (1 << 25);
459 0 : sf->max_exaustive_pct = good_quality_max_mesh_pct[speed];
460 0 : if (speed > 0)
461 0 : sf->exhaustive_searches_thresh = sf->exhaustive_searches_thresh << 1;
462 :
463 0 : for (i = 0; i < MAX_MESH_STEP; ++i) {
464 0 : sf->mesh_patterns[i].range = good_quality_mesh_patterns[speed][i].range;
465 0 : sf->mesh_patterns[i].interval =
466 0 : good_quality_mesh_patterns[speed][i].interval;
467 : }
468 : #if CONFIG_INTRABC
469 : if ((frame_is_intra_only(cm) && cm->allow_screen_content_tools) &&
470 : (cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION ||
471 : cpi->oxcf.content == AOM_CONTENT_SCREEN)) {
472 : for (i = 0; i < MAX_MESH_STEP; ++i) {
473 : sf->mesh_patterns[i].range = intrabc_mesh_patterns[speed][i].range;
474 : sf->mesh_patterns[i].interval = intrabc_mesh_patterns[speed][i].interval;
475 : }
476 : sf->max_exaustive_pct = intrabc_max_mesh_pct[speed];
477 : }
478 : #endif // CONFIG_INTRABC
479 :
480 : #if !CONFIG_XIPHRC
481 : // Slow quant, dct and trellis not worthwhile for first pass
482 : // so make sure they are always turned off.
483 0 : if (oxcf->pass == 1) sf->optimize_coefficients = 0;
484 : #endif
485 :
486 : // No recode for 1 pass.
487 0 : if (oxcf->pass == 0) {
488 0 : sf->recode_loop = DISALLOW_RECODE;
489 0 : sf->optimize_coefficients = 0;
490 : }
491 :
492 0 : if (sf->mv.subpel_search_method == SUBPEL_TREE) {
493 0 : cpi->find_fractional_mv_step = av1_find_best_sub_pixel_tree;
494 0 : } else if (sf->mv.subpel_search_method == SUBPEL_TREE_PRUNED) {
495 0 : cpi->find_fractional_mv_step = av1_find_best_sub_pixel_tree_pruned;
496 0 : } else if (sf->mv.subpel_search_method == SUBPEL_TREE_PRUNED_MORE) {
497 0 : cpi->find_fractional_mv_step = av1_find_best_sub_pixel_tree_pruned_more;
498 0 : } else if (sf->mv.subpel_search_method == SUBPEL_TREE_PRUNED_EVENMORE) {
499 0 : cpi->find_fractional_mv_step = av1_find_best_sub_pixel_tree_pruned_evenmore;
500 : }
501 :
502 : #if !CONFIG_AOM_QM
503 0 : x->optimize = sf->optimize_coefficients == 1 && oxcf->pass != 1;
504 : #else
505 : // FIXME: trellis not very efficient for quantisation matrices
506 : x->optimize = 0;
507 : #endif
508 :
509 0 : x->min_partition_size = sf->default_min_partition_size;
510 0 : x->max_partition_size = sf->default_max_partition_size;
511 :
512 0 : if (!cpi->oxcf.frame_periodic_boost) {
513 0 : sf->max_delta_qindex = 0;
514 : }
515 :
516 : // This is only used in motion vector unit test.
517 0 : if (cpi->oxcf.motion_vector_unit_test == 1)
518 0 : cpi->find_fractional_mv_step = av1_return_max_sub_pixel_mv;
519 0 : else if (cpi->oxcf.motion_vector_unit_test == 2)
520 0 : cpi->find_fractional_mv_step = av1_return_min_sub_pixel_mv;
521 0 : }
|