1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <limits.h>
12
13 #include "vp9/encoder/vp9_encoder.h"
14 #include "vp9/encoder/vp9_speed_features.h"
15 #include "vp9/encoder/vp9_rdopt.h"
16
17
18 // Intra only frames, golden frames (except alt ref overlays) and
19 // alt ref frames tend to be coded at a higher than ambient quality
frame_is_boosted(const VP9_COMP * cpi)20 static int frame_is_boosted(const VP9_COMP *cpi) {
21 return frame_is_kf_gf_arf(cpi) || vp9_is_upper_layer_key_frame(cpi);
22 }
23
24 // Sets a partition size down to which the auto partition code will always
25 // search (can go lower), based on the image dimensions. The logic here
26 // is that the extent to which ringing artefacts are offensive, depends
27 // partly on the screen area that over which they propogate. Propogation is
28 // limited by transform block size but the screen area take up by a given block
29 // size will be larger for a small image format stretched to full screen.
set_partition_min_limit(VP9_COMMON * const cm)30 static BLOCK_SIZE set_partition_min_limit(VP9_COMMON *const cm) {
31 unsigned int screen_area = (cm->width * cm->height);
32
33 // Select block size based on image format size.
34 if (screen_area < 1280 * 720) {
35 // Formats smaller in area than 720P
36 return BLOCK_4X4;
37 } else if (screen_area < 1920 * 1080) {
38 // Format >= 720P and < 1080P
39 return BLOCK_8X8;
40 } else {
41 // Formats 1080P and up
42 return BLOCK_16X16;
43 }
44 }
45
set_good_speed_feature_framesize_dependent(VP9_COMP * cpi,SPEED_FEATURES * sf,int speed)46 static void set_good_speed_feature_framesize_dependent(VP9_COMP *cpi,
47 SPEED_FEATURES *sf,
48 int speed) {
49 VP9_COMMON *const cm = &cpi->common;
50
51 if (speed >= 1) {
52 if (MIN(cm->width, cm->height) >= 720) {
53 sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
54 : DISABLE_ALL_INTER_SPLIT;
55 sf->partition_search_breakout_dist_thr = (1 << 23);
56 } else {
57 sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
58 sf->partition_search_breakout_dist_thr = (1 << 21);
59 }
60 }
61
62 if (speed >= 2) {
63 if (MIN(cm->width, cm->height) >= 720) {
64 sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
65 : DISABLE_ALL_INTER_SPLIT;
66 sf->adaptive_pred_interp_filter = 0;
67 sf->partition_search_breakout_dist_thr = (1 << 24);
68 sf->partition_search_breakout_rate_thr = 120;
69 } else {
70 sf->disable_split_mask = LAST_AND_INTRA_SPLIT_ONLY;
71 sf->partition_search_breakout_dist_thr = (1 << 22);
72 sf->partition_search_breakout_rate_thr = 100;
73 }
74 sf->rd_auto_partition_min_limit = set_partition_min_limit(cm);
75 }
76
77 if (speed >= 3) {
78 if (MIN(cm->width, cm->height) >= 720) {
79 sf->disable_split_mask = DISABLE_ALL_SPLIT;
80 sf->schedule_mode_search = cm->base_qindex < 220 ? 1 : 0;
81 sf->partition_search_breakout_dist_thr = (1 << 25);
82 sf->partition_search_breakout_rate_thr = 200;
83 } else {
84 sf->max_intra_bsize = BLOCK_32X32;
85 sf->disable_split_mask = DISABLE_ALL_INTER_SPLIT;
86 sf->schedule_mode_search = cm->base_qindex < 175 ? 1 : 0;
87 sf->partition_search_breakout_dist_thr = (1 << 23);
88 sf->partition_search_breakout_rate_thr = 120;
89 }
90 }
91
92 // If this is a two pass clip that fits the criteria for animated or
93 // graphics content then reset disable_split_mask for speeds 1-4.
94 // Also if the image edge is internal to the coded area.
95 if ((speed >= 1) && (cpi->oxcf.pass == 2) &&
96 ((cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION) ||
97 (vp9_internal_image_edge(cpi)))) {
98 sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
99 }
100
101 if (speed >= 4) {
102 if (MIN(cm->width, cm->height) >= 720) {
103 sf->partition_search_breakout_dist_thr = (1 << 26);
104 } else {
105 sf->partition_search_breakout_dist_thr = (1 << 24);
106 }
107 sf->disable_split_mask = DISABLE_ALL_SPLIT;
108 }
109 }
110
set_good_speed_feature(VP9_COMP * cpi,VP9_COMMON * cm,SPEED_FEATURES * sf,int speed)111 static void set_good_speed_feature(VP9_COMP *cpi, VP9_COMMON *cm,
112 SPEED_FEATURES *sf, int speed) {
113 const int boosted = frame_is_boosted(cpi);
114
115 sf->adaptive_rd_thresh = 1;
116 sf->allow_skip_recode = 1;
117
118 if (speed >= 1) {
119 if ((cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION) ||
120 vp9_internal_image_edge(cpi)) {
121 sf->use_square_partition_only = !frame_is_boosted(cpi);
122 } else {
123 sf->use_square_partition_only = !frame_is_intra_only(cm);
124 }
125
126 sf->less_rectangular_check = 1;
127
128 sf->use_rd_breakout = 1;
129 sf->adaptive_motion_search = 1;
130 sf->mv.auto_mv_step_size = 1;
131 sf->adaptive_rd_thresh = 2;
132 sf->mv.subpel_iters_per_step = 1;
133 sf->mode_skip_start = 10;
134 sf->adaptive_pred_interp_filter = 1;
135
136 sf->recode_loop = ALLOW_RECODE_KFARFGF;
137 sf->intra_y_mode_mask[TX_32X32] = INTRA_DC_H_V;
138 sf->intra_uv_mode_mask[TX_32X32] = INTRA_DC_H_V;
139 sf->intra_y_mode_mask[TX_16X16] = INTRA_DC_H_V;
140 sf->intra_uv_mode_mask[TX_16X16] = INTRA_DC_H_V;
141
142 sf->tx_size_search_breakout = 1;
143 sf->partition_search_breakout_rate_thr = 80;
144 }
145
146 if (speed >= 2) {
147 sf->tx_size_search_method = frame_is_boosted(cpi) ? USE_FULL_RD
148 : USE_LARGESTALL;
149
150 // Reference masking is not supported in dynamic scaling mode.
151 sf->reference_masking = cpi->oxcf.resize_mode != RESIZE_DYNAMIC ? 1 : 0;
152
153 sf->mode_search_skip_flags = (cm->frame_type == KEY_FRAME) ? 0 :
154 FLAG_SKIP_INTRA_DIRMISMATCH |
155 FLAG_SKIP_INTRA_BESTINTER |
156 FLAG_SKIP_COMP_BESTINTRA |
157 FLAG_SKIP_INTRA_LOWVAR;
158 sf->disable_filter_search_var_thresh = 100;
159 sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
160 sf->auto_min_max_partition_size = RELAXED_NEIGHBORING_MIN_MAX;
161 sf->allow_partition_search_skip = 1;
162 }
163
164 if (speed >= 3) {
165 sf->use_square_partition_only = !frame_is_intra_only(cm);
166 sf->tx_size_search_method = frame_is_intra_only(cm) ? USE_FULL_RD
167 : USE_LARGESTALL;
168 sf->mv.subpel_search_method = SUBPEL_TREE_PRUNED;
169 sf->adaptive_pred_interp_filter = 0;
170 sf->adaptive_mode_search = 1;
171 sf->cb_partition_search = !boosted;
172 sf->cb_pred_filter_search = 1;
173 sf->alt_ref_search_fp = 1;
174 sf->recode_loop = ALLOW_RECODE_KFMAXBW;
175 sf->adaptive_rd_thresh = 3;
176 sf->mode_skip_start = 6;
177 sf->intra_y_mode_mask[TX_32X32] = INTRA_DC;
178 sf->intra_uv_mode_mask[TX_32X32] = INTRA_DC;
179 sf->adaptive_interp_filter_search = 1;
180 }
181
182 if (speed >= 4) {
183 sf->use_square_partition_only = 1;
184 sf->tx_size_search_method = USE_LARGESTALL;
185 sf->mv.search_method = BIGDIA;
186 sf->mv.subpel_search_method = SUBPEL_TREE_PRUNED_MORE;
187 sf->adaptive_rd_thresh = 4;
188 if (cm->frame_type != KEY_FRAME)
189 sf->mode_search_skip_flags |= FLAG_EARLY_TERMINATE;
190 sf->disable_filter_search_var_thresh = 200;
191 sf->use_lp32x32fdct = 1;
192 sf->use_fast_coef_updates = ONE_LOOP_REDUCED;
193 sf->use_fast_coef_costing = 1;
194 sf->motion_field_mode_search = !boosted;
195 sf->partition_search_breakout_rate_thr = 300;
196 }
197
198 if (speed >= 5) {
199 int i;
200 sf->optimize_coefficients = 0;
201 sf->mv.search_method = HEX;
202 sf->disable_filter_search_var_thresh = 500;
203 for (i = 0; i < TX_SIZES; ++i) {
204 sf->intra_y_mode_mask[i] = INTRA_DC;
205 sf->intra_uv_mode_mask[i] = INTRA_DC;
206 }
207 sf->partition_search_breakout_rate_thr = 500;
208 sf->mv.reduce_first_step_size = 1;
209 sf->simple_model_rd_from_var = 1;
210 }
211 }
212
set_rt_speed_feature_framesize_dependent(VP9_COMP * cpi,SPEED_FEATURES * sf,int speed)213 static void set_rt_speed_feature_framesize_dependent(VP9_COMP *cpi,
214 SPEED_FEATURES *sf, int speed) {
215 VP9_COMMON *const cm = &cpi->common;
216
217 if (speed >= 1) {
218 if (MIN(cm->width, cm->height) >= 720) {
219 sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
220 : DISABLE_ALL_INTER_SPLIT;
221 } else {
222 sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
223 }
224 }
225
226 if (speed >= 2) {
227 if (MIN(cm->width, cm->height) >= 720) {
228 sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
229 : DISABLE_ALL_INTER_SPLIT;
230 } else {
231 sf->disable_split_mask = LAST_AND_INTRA_SPLIT_ONLY;
232 }
233 }
234
235 if (speed >= 5) {
236 if (MIN(cm->width, cm->height) >= 720) {
237 sf->partition_search_breakout_dist_thr = (1 << 25);
238 } else {
239 sf->partition_search_breakout_dist_thr = (1 << 23);
240 }
241 }
242
243 if (speed >= 7) {
244 sf->encode_breakout_thresh = (MIN(cm->width, cm->height) >= 720) ?
245 800 : 300;
246 }
247 }
248
set_rt_speed_feature(VP9_COMP * cpi,SPEED_FEATURES * sf,int speed,vp9e_tune_content content)249 static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf,
250 int speed, vp9e_tune_content content) {
251 VP9_COMMON *const cm = &cpi->common;
252 const int is_keyframe = cm->frame_type == KEY_FRAME;
253 const int frames_since_key = is_keyframe ? 0 : cpi->rc.frames_since_key;
254 sf->static_segmentation = 0;
255 sf->adaptive_rd_thresh = 1;
256 sf->use_fast_coef_costing = 1;
257
258 if (speed >= 1) {
259 sf->use_square_partition_only = !frame_is_intra_only(cm);
260 sf->less_rectangular_check = 1;
261 sf->tx_size_search_method = frame_is_intra_only(cm) ? USE_FULL_RD
262 : USE_LARGESTALL;
263
264 sf->use_rd_breakout = 1;
265
266 sf->adaptive_motion_search = 1;
267 sf->adaptive_pred_interp_filter = 1;
268 sf->mv.auto_mv_step_size = 1;
269 sf->adaptive_rd_thresh = 2;
270 sf->intra_y_mode_mask[TX_32X32] = INTRA_DC_H_V;
271 sf->intra_uv_mode_mask[TX_32X32] = INTRA_DC_H_V;
272 sf->intra_uv_mode_mask[TX_16X16] = INTRA_DC_H_V;
273 }
274
275 if (speed >= 2) {
276 sf->mode_search_skip_flags = (cm->frame_type == KEY_FRAME) ? 0 :
277 FLAG_SKIP_INTRA_DIRMISMATCH |
278 FLAG_SKIP_INTRA_BESTINTER |
279 FLAG_SKIP_COMP_BESTINTRA |
280 FLAG_SKIP_INTRA_LOWVAR;
281 sf->adaptive_pred_interp_filter = 2;
282
283 // Disable reference masking if using spatial scaling since
284 // pred_mv_sad will not be set (since vp9_mv_pred will not
285 // be called).
286 // TODO(marpan/agrange): Fix this condition.
287 sf->reference_masking = (cpi->oxcf.resize_mode != RESIZE_DYNAMIC &&
288 cpi->svc.number_spatial_layers == 1) ? 1 : 0;
289
290 sf->disable_filter_search_var_thresh = 50;
291 sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
292 sf->auto_min_max_partition_size = RELAXED_NEIGHBORING_MIN_MAX;
293 sf->lf_motion_threshold = LOW_MOTION_THRESHOLD;
294 sf->adjust_partitioning_from_last_frame = 1;
295 sf->last_partitioning_redo_frequency = 3;
296 sf->use_lp32x32fdct = 1;
297 sf->mode_skip_start = 11;
298 sf->intra_y_mode_mask[TX_16X16] = INTRA_DC_H_V;
299 }
300
301 if (speed >= 3) {
302 sf->use_square_partition_only = 1;
303 sf->disable_filter_search_var_thresh = 100;
304 sf->use_uv_intra_rd_estimate = 1;
305 sf->skip_encode_sb = 1;
306 sf->mv.subpel_iters_per_step = 1;
307 sf->adaptive_rd_thresh = 4;
308 sf->mode_skip_start = 6;
309 sf->allow_skip_recode = 0;
310 sf->optimize_coefficients = 0;
311 sf->disable_split_mask = DISABLE_ALL_SPLIT;
312 sf->lpf_pick = LPF_PICK_FROM_Q;
313 }
314
315 if (speed >= 4) {
316 int i;
317 sf->last_partitioning_redo_frequency = 4;
318 sf->adaptive_rd_thresh = 5;
319 sf->use_fast_coef_costing = 0;
320 sf->auto_min_max_partition_size = STRICT_NEIGHBORING_MIN_MAX;
321 sf->adjust_partitioning_from_last_frame =
322 cm->last_frame_type != cm->frame_type || (0 ==
323 (frames_since_key + 1) % sf->last_partitioning_redo_frequency);
324 sf->mv.subpel_force_stop = 1;
325 for (i = 0; i < TX_SIZES; i++) {
326 sf->intra_y_mode_mask[i] = INTRA_DC_H_V;
327 sf->intra_uv_mode_mask[i] = INTRA_DC;
328 }
329 sf->intra_y_mode_mask[TX_32X32] = INTRA_DC;
330 sf->frame_parameter_update = 0;
331 sf->mv.search_method = FAST_HEX;
332
333 sf->inter_mode_mask[BLOCK_32X32] = INTER_NEAREST_NEAR_NEW;
334 sf->inter_mode_mask[BLOCK_32X64] = INTER_NEAREST;
335 sf->inter_mode_mask[BLOCK_64X32] = INTER_NEAREST;
336 sf->inter_mode_mask[BLOCK_64X64] = INTER_NEAREST;
337 sf->max_intra_bsize = BLOCK_32X32;
338 sf->allow_skip_recode = 1;
339 }
340
341 if (speed >= 5) {
342 sf->use_quant_fp = !is_keyframe;
343 sf->auto_min_max_partition_size = is_keyframe ? RELAXED_NEIGHBORING_MIN_MAX
344 : STRICT_NEIGHBORING_MIN_MAX;
345 sf->default_max_partition_size = BLOCK_32X32;
346 sf->default_min_partition_size = BLOCK_8X8;
347 sf->force_frame_boost = is_keyframe ||
348 (frames_since_key % (sf->last_partitioning_redo_frequency << 1) == 1);
349 sf->max_delta_qindex = is_keyframe ? 20 : 15;
350 sf->partition_search_type = REFERENCE_PARTITION;
351 sf->use_nonrd_pick_mode = 1;
352 sf->allow_skip_recode = 0;
353 sf->inter_mode_mask[BLOCK_32X32] = INTER_NEAREST_NEW_ZERO;
354 sf->inter_mode_mask[BLOCK_32X64] = INTER_NEAREST_NEW_ZERO;
355 sf->inter_mode_mask[BLOCK_64X32] = INTER_NEAREST_NEW_ZERO;
356 sf->inter_mode_mask[BLOCK_64X64] = INTER_NEAREST_NEW_ZERO;
357 sf->adaptive_rd_thresh = 2;
358 // This feature is only enabled when partition search is disabled.
359 sf->reuse_inter_pred_sby = 1;
360 sf->partition_search_breakout_rate_thr = 200;
361 sf->coeff_prob_appx_step = 4;
362 sf->use_fast_coef_updates = is_keyframe ? TWO_LOOP : ONE_LOOP_REDUCED;
363 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH;
364 sf->tx_size_search_method = is_keyframe ? USE_LARGESTALL : USE_TX_8X8;
365 sf->simple_model_rd_from_var = 1;
366
367 if (!is_keyframe) {
368 int i;
369 if (content == VP9E_CONTENT_SCREEN) {
370 for (i = 0; i < BLOCK_SIZES; ++i)
371 sf->intra_y_mode_bsize_mask[i] = INTRA_DC_TM_H_V;
372 } else {
373 for (i = 0; i < BLOCK_SIZES; ++i)
374 if (i >= BLOCK_16X16)
375 sf->intra_y_mode_bsize_mask[i] = INTRA_DC;
376 else
377 // Use H and V intra mode for block sizes <= 16X16.
378 sf->intra_y_mode_bsize_mask[i] = INTRA_DC_H_V;
379 }
380 }
381 }
382
383 if (speed >= 6) {
384 // Adaptively switch between SOURCE_VAR_BASED_PARTITION and FIXED_PARTITION.
385 sf->partition_search_type = VAR_BASED_PARTITION;
386 // Turn on this to use non-RD key frame coding mode.
387 sf->use_nonrd_pick_mode = 1;
388 sf->mv.search_method = NSTEP;
389 sf->mv.reduce_first_step_size = 1;
390 sf->skip_encode_sb = 0;
391 }
392
393 if (speed >= 7) {
394 sf->adaptive_rd_thresh = 3;
395 sf->mv.search_method = FAST_DIAMOND;
396 sf->mv.fullpel_search_step_param = 10;
397 if (cpi->svc.number_temporal_layers > 2 &&
398 cpi->svc.temporal_layer_id == 0) {
399 sf->mv.search_method = NSTEP;
400 sf->mv.fullpel_search_step_param = 6;
401 }
402 }
403 if (speed >= 8) {
404 sf->adaptive_rd_thresh = 4;
405 sf->mv.subpel_force_stop = 2;
406 sf->lpf_pick = LPF_PICK_MINIMAL_LPF;
407 }
408 }
409
vp9_set_speed_features_framesize_dependent(VP9_COMP * cpi)410 void vp9_set_speed_features_framesize_dependent(VP9_COMP *cpi) {
411 SPEED_FEATURES *const sf = &cpi->sf;
412 const VP9EncoderConfig *const oxcf = &cpi->oxcf;
413 RD_OPT *const rd = &cpi->rd;
414 int i;
415
416 if (oxcf->mode == REALTIME) {
417 set_rt_speed_feature_framesize_dependent(cpi, sf, oxcf->speed);
418 } else if (oxcf->mode == GOOD) {
419 set_good_speed_feature_framesize_dependent(cpi, sf, oxcf->speed);
420 }
421
422 if (sf->disable_split_mask == DISABLE_ALL_SPLIT) {
423 sf->adaptive_pred_interp_filter = 0;
424 }
425
426 if (cpi->encode_breakout && oxcf->mode == REALTIME &&
427 sf->encode_breakout_thresh > cpi->encode_breakout) {
428 cpi->encode_breakout = sf->encode_breakout_thresh;
429 }
430
431 // Check for masked out split cases.
432 for (i = 0; i < MAX_REFS; ++i) {
433 if (sf->disable_split_mask & (1 << i)) {
434 rd->thresh_mult_sub8x8[i] = INT_MAX;
435 }
436 }
437 }
438
vp9_set_speed_features_framesize_independent(VP9_COMP * cpi)439 void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi) {
440 SPEED_FEATURES *const sf = &cpi->sf;
441 VP9_COMMON *const cm = &cpi->common;
442 MACROBLOCK *const x = &cpi->td.mb;
443 const VP9EncoderConfig *const oxcf = &cpi->oxcf;
444 int i;
445
446 // best quality defaults
447 sf->frame_parameter_update = 1;
448 sf->mv.search_method = NSTEP;
449 sf->recode_loop = ALLOW_RECODE;
450 sf->mv.subpel_search_method = SUBPEL_TREE;
451 sf->mv.subpel_iters_per_step = 2;
452 sf->mv.subpel_force_stop = 0;
453 sf->optimize_coefficients = !is_lossless_requested(&cpi->oxcf);
454 sf->mv.reduce_first_step_size = 0;
455 sf->coeff_prob_appx_step = 1;
456 sf->mv.auto_mv_step_size = 0;
457 sf->mv.fullpel_search_step_param = 6;
458 sf->comp_inter_joint_search_thresh = BLOCK_4X4;
459 sf->adaptive_rd_thresh = 0;
460 sf->tx_size_search_method = USE_FULL_RD;
461 sf->use_lp32x32fdct = 0;
462 sf->adaptive_motion_search = 0;
463 sf->adaptive_pred_interp_filter = 0;
464 sf->adaptive_mode_search = 0;
465 sf->cb_pred_filter_search = 0;
466 sf->cb_partition_search = 0;
467 sf->motion_field_mode_search = 0;
468 sf->alt_ref_search_fp = 0;
469 sf->use_quant_fp = 0;
470 sf->reference_masking = 0;
471 sf->partition_search_type = SEARCH_PARTITION;
472 sf->less_rectangular_check = 0;
473 sf->use_square_partition_only = 0;
474 sf->auto_min_max_partition_size = NOT_IN_USE;
475 sf->rd_auto_partition_min_limit = BLOCK_4X4;
476 sf->default_max_partition_size = BLOCK_64X64;
477 sf->default_min_partition_size = BLOCK_4X4;
478 sf->adjust_partitioning_from_last_frame = 0;
479 sf->last_partitioning_redo_frequency = 4;
480 sf->disable_split_mask = 0;
481 sf->mode_search_skip_flags = 0;
482 sf->force_frame_boost = 0;
483 sf->max_delta_qindex = 0;
484 sf->disable_filter_search_var_thresh = 0;
485 sf->adaptive_interp_filter_search = 0;
486 sf->allow_partition_search_skip = 0;
487
488 for (i = 0; i < TX_SIZES; i++) {
489 sf->intra_y_mode_mask[i] = INTRA_ALL;
490 sf->intra_uv_mode_mask[i] = INTRA_ALL;
491 }
492 sf->use_rd_breakout = 0;
493 sf->skip_encode_sb = 0;
494 sf->use_uv_intra_rd_estimate = 0;
495 sf->allow_skip_recode = 0;
496 sf->lpf_pick = LPF_PICK_FROM_FULL_IMAGE;
497 sf->use_fast_coef_updates = TWO_LOOP;
498 sf->use_fast_coef_costing = 0;
499 sf->mode_skip_start = MAX_MODES; // Mode index at which mode skip mask set
500 sf->schedule_mode_search = 0;
501 sf->use_nonrd_pick_mode = 0;
502 for (i = 0; i < BLOCK_SIZES; ++i)
503 sf->inter_mode_mask[i] = INTER_ALL;
504 sf->max_intra_bsize = BLOCK_64X64;
505 sf->reuse_inter_pred_sby = 0;
506 // This setting only takes effect when partition_search_type is set
507 // to FIXED_PARTITION.
508 sf->always_this_block_size = BLOCK_16X16;
509 sf->search_type_check_frequency = 50;
510 sf->encode_breakout_thresh = 0;
511 // Recode loop tolerance %.
512 sf->recode_tolerance = 25;
513 sf->default_interp_filter = SWITCHABLE;
514 sf->tx_size_search_breakout = 0;
515 sf->partition_search_breakout_dist_thr = 0;
516 sf->partition_search_breakout_rate_thr = 0;
517 sf->simple_model_rd_from_var = 0;
518
519 if (oxcf->mode == REALTIME)
520 set_rt_speed_feature(cpi, sf, oxcf->speed, oxcf->content);
521 else if (oxcf->mode == GOOD)
522 set_good_speed_feature(cpi, cm, sf, oxcf->speed);
523
524 cpi->full_search_sad = vp9_full_search_sad;
525 cpi->diamond_search_sad = oxcf->mode == BEST ? vp9_full_range_search
526 : vp9_diamond_search_sad;
527
528 // Slow quant, dct and trellis not worthwhile for first pass
529 // so make sure they are always turned off.
530 if (oxcf->pass == 1)
531 sf->optimize_coefficients = 0;
532
533 // No recode for 1 pass.
534 if (oxcf->pass == 0) {
535 sf->recode_loop = DISALLOW_RECODE;
536 sf->optimize_coefficients = 0;
537 }
538
539 if (sf->mv.subpel_search_method == SUBPEL_TREE) {
540 cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_tree;
541 } else if (sf->mv.subpel_search_method == SUBPEL_TREE_PRUNED) {
542 cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_tree_pruned;
543 } else if (sf->mv.subpel_search_method == SUBPEL_TREE_PRUNED_MORE) {
544 cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_tree_pruned_more;
545 } else if (sf->mv.subpel_search_method == SUBPEL_TREE_PRUNED_EVENMORE) {
546 cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_tree_pruned_evenmore;
547 }
548
549 x->optimize = sf->optimize_coefficients == 1 && oxcf->pass != 1;
550
551 x->min_partition_size = sf->default_min_partition_size;
552 x->max_partition_size = sf->default_max_partition_size;
553
554 if (!cpi->oxcf.frame_periodic_boost) {
555 sf->max_delta_qindex = 0;
556 }
557 }
558