blob: d7017f269014fa0851b26c4af8ef7991f1caad56 [file] [log] [blame]
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -07001/*
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
Dmitry Kovalevef003072014-04-18 18:27:47 -070013#include "vp9/encoder/vp9_encoder.h"
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -070014#include "vp9/encoder/vp9_speed_features.h"
15
Dmitry Kovalevc1981bd2014-04-14 15:11:13 -070016enum {
Dmitry Kovalev26bdf262014-05-29 12:11:02 -070017 INTRA_ALL = (1 << DC_PRED) |
Dmitry Kovalevc1981bd2014-04-14 15:11:13 -070018 (1 << V_PRED) | (1 << H_PRED) |
19 (1 << D45_PRED) | (1 << D135_PRED) |
20 (1 << D117_PRED) | (1 << D153_PRED) |
21 (1 << D207_PRED) | (1 << D63_PRED) |
22 (1 << TM_PRED),
Dmitry Kovalev26bdf262014-05-29 12:11:02 -070023 INTRA_DC = (1 << DC_PRED),
24 INTRA_DC_TM = (1 << DC_PRED) | (1 << TM_PRED),
Dmitry Kovalevc1981bd2014-04-14 15:11:13 -070025 INTRA_DC_H_V = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED),
Dmitry Kovalev26bdf262014-05-29 12:11:02 -070026 INTRA_DC_TM_H_V = (1 << DC_PRED) | (1 << TM_PRED) | (1 << V_PRED) |
27 (1 << H_PRED)
Dmitry Kovalevc1981bd2014-04-14 15:11:13 -070028};
29
30enum {
Dmitry Kovalev40371992014-05-29 12:25:41 -070031 INTER_ALL = (1 << NEARESTMV) | (1 << NEARMV) | (1 << ZEROMV) | (1 << NEWMV),
32 INTER_NEAREST = (1 << NEARESTMV),
33 INTER_NEAREST_NEAR_NEW = (1 << NEARESTMV) | (1 << NEARMV) | (1 << NEWMV)
34};
35
36enum {
Dmitry Kovalevc1981bd2014-04-14 15:11:13 -070037 DISABLE_ALL_INTER_SPLIT = (1 << THR_COMP_GA) |
38 (1 << THR_COMP_LA) |
39 (1 << THR_ALTR) |
40 (1 << THR_GOLD) |
41 (1 << THR_LAST),
42
43 DISABLE_ALL_SPLIT = (1 << THR_INTRA) | DISABLE_ALL_INTER_SPLIT,
44
45 DISABLE_COMPOUND_SPLIT = (1 << THR_COMP_GA) | (1 << THR_COMP_LA),
46
47 LAST_AND_INTRA_SPLIT_ONLY = (1 << THR_COMP_GA) |
48 (1 << THR_COMP_LA) |
49 (1 << THR_ALTR) |
50 (1 << THR_GOLD)
51};
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -070052
Dmitry Kovalev233b5812014-04-04 10:52:20 -070053static void set_good_speed_feature(VP9_COMP *cpi, VP9_COMMON *cm,
54 SPEED_FEATURES *sf, int speed) {
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -070055 sf->adaptive_rd_thresh = 1;
Dmitry Kovalev233b5812014-04-04 10:52:20 -070056 sf->recode_loop = (speed < 1) ? ALLOW_RECODE : ALLOW_RECODE_KFMAXBW;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -070057 sf->allow_skip_recode = 1;
58
59 if (speed >= 1) {
60 sf->use_square_partition_only = !frame_is_intra_only(cm);
61 sf->less_rectangular_check = 1;
Paul Wilkins19536d62014-04-14 10:04:35 -070062 sf->tx_size_search_method = frame_is_boosted(cpi) ? USE_FULL_RD
63 : USE_LARGESTALL;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -070064
65 if (MIN(cm->width, cm->height) >= 720)
Dmitry Kovalev233b5812014-04-04 10:52:20 -070066 sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
67 : DISABLE_ALL_INTER_SPLIT;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -070068 else
69 sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
70 sf->use_rd_breakout = 1;
71 sf->adaptive_motion_search = 1;
Dmitry Kovalev4ff1a612014-06-12 12:35:57 -070072 sf->mv.auto_mv_step_size = 1;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -070073 sf->adaptive_rd_thresh = 2;
Dmitry Kovalev4ff1a612014-06-12 12:35:57 -070074 sf->mv.subpel_iters_per_step = 1;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -070075 sf->mode_skip_start = 10;
76 sf->adaptive_pred_interp_filter = 1;
77
78 sf->recode_loop = ALLOW_RECODE_KFARFGF;
79 sf->intra_y_mode_mask[TX_32X32] = INTRA_DC_H_V;
80 sf->intra_uv_mode_mask[TX_32X32] = INTRA_DC_H_V;
81 sf->intra_y_mode_mask[TX_16X16] = INTRA_DC_H_V;
82 sf->intra_uv_mode_mask[TX_16X16] = INTRA_DC_H_V;
83 }
Dmitry Kovalev233b5812014-04-04 10:52:20 -070084
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -070085 if (speed >= 2) {
Yaowu Xu3bda7ec2014-05-20 11:36:44 -070086 if (MIN(cm->width, cm->height) >= 720) {
Paul Wilkins8160a262014-06-17 15:31:24 +010087 sf->lf_motion_threshold = LOW_MOTION_THRESHOLD;
Yaowu Xu3bda7ec2014-05-20 11:36:44 -070088 sf->last_partitioning_redo_frequency = 3;
Dmitry Kovalev233b5812014-04-04 10:52:20 -070089 sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
90 : DISABLE_ALL_INTER_SPLIT;
Yaowu Xu3bda7ec2014-05-20 11:36:44 -070091 } else {
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -070092 sf->disable_split_mask = LAST_AND_INTRA_SPLIT_ONLY;
Yaowu Xu3bda7ec2014-05-20 11:36:44 -070093 sf->last_partitioning_redo_frequency = 2;
Paul Wilkins8160a262014-06-17 15:31:24 +010094 sf->lf_motion_threshold = NO_MOTION_THRESHOLD;
Yaowu Xu3bda7ec2014-05-20 11:36:44 -070095 }
Paul Wilkins8160a262014-06-17 15:31:24 +010096
97 sf->adaptive_pred_interp_filter = 0;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -070098 sf->reference_masking = 1;
99 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH |
100 FLAG_SKIP_INTRA_BESTINTER |
101 FLAG_SKIP_COMP_BESTINTRA |
102 FLAG_SKIP_INTRA_LOWVAR;
103 sf->disable_filter_search_var_thresh = 100;
104 sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700105 sf->auto_min_max_partition_size = RELAXED_NEIGHBORING_MIN_MAX;
106 sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_LOW_MOTION;
107 sf->adjust_partitioning_from_last_frame = 1;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700108 }
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700109
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700110 if (speed >= 3) {
Yaowu Xud928b342014-04-21 12:04:59 -0700111 sf->tx_size_search_method = frame_is_intra_only(cm) ? USE_FULL_RD
112 : USE_LARGESTALL;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700113 if (MIN(cm->width, cm->height) >= 720)
114 sf->disable_split_mask = DISABLE_ALL_SPLIT;
115 else
116 sf->disable_split_mask = DISABLE_ALL_INTER_SPLIT;
117
Paul Wilkins8160a262014-06-17 15:31:24 +0100118 sf->lf_motion_threshold = LOW_MOTION_THRESHOLD;
Yaowu Xu3bda7ec2014-05-20 11:36:44 -0700119 sf->last_partitioning_redo_frequency = 3;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700120 sf->recode_loop = ALLOW_RECODE_KFMAXBW;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700121 sf->adaptive_rd_thresh = 3;
122 sf->mode_skip_start = 6;
Dmitry Kovalev107929d2014-04-04 10:31:34 -0700123 sf->use_fast_coef_updates = ONE_LOOP_REDUCED;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700124 sf->use_fast_coef_costing = 1;
125 }
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700126
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700127 if (speed >= 4) {
128 sf->use_square_partition_only = 1;
129 sf->tx_size_search_method = USE_LARGESTALL;
130 sf->disable_split_mask = DISABLE_ALL_SPLIT;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700131 sf->adaptive_rd_thresh = 4;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700132 sf->mode_search_skip_flags |= FLAG_SKIP_COMP_REFMISMATCH |
133 FLAG_EARLY_TERMINATE;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700134 sf->disable_filter_search_var_thresh = 200;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700135 sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_ALL;
136 sf->use_lp32x32fdct = 1;
137 }
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700138
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700139 if (speed >= 5) {
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700140 int i;
141
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700142 sf->partition_search_type = FIXED_PARTITION;
143 sf->optimize_coefficients = 0;
Dmitry Kovalev4ff1a612014-06-12 12:35:57 -0700144 sf->mv.search_method = HEX;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700145 sf->disable_filter_search_var_thresh = 500;
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700146 for (i = 0; i < TX_SIZES; ++i) {
Dmitry Kovalev26bdf262014-05-29 12:11:02 -0700147 sf->intra_y_mode_mask[i] = INTRA_DC;
148 sf->intra_uv_mode_mask[i] = INTRA_DC;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700149 }
150 cpi->allow_encode_breakout = ENCODE_BREAKOUT_ENABLED;
151 }
152}
153
Alex Converseb9c24df2014-05-22 15:27:35 -0700154static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf,
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700155 int speed) {
Alex Converseb9c24df2014-05-22 15:27:35 -0700156 VP9_COMMON *const cm = &cpi->common;
157 const int frames_since_key =
158 cm->frame_type == KEY_FRAME ? 0 : cpi->rc.frames_since_key;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700159 sf->static_segmentation = 0;
160 sf->adaptive_rd_thresh = 1;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700161 sf->use_fast_coef_costing = 1;
162
Dmitry Kovalevd262cda2014-05-29 11:11:50 -0700163 if (speed >= 1) {
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700164 sf->use_square_partition_only = !frame_is_intra_only(cm);
165 sf->less_rectangular_check = 1;
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700166 sf->tx_size_search_method = frame_is_intra_only(cm) ? USE_FULL_RD
167 : USE_LARGESTALL;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700168
169 if (MIN(cm->width, cm->height) >= 720)
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700170 sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
171 : DISABLE_ALL_INTER_SPLIT;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700172 else
173 sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
174
175 sf->use_rd_breakout = 1;
176 sf->adaptive_motion_search = 1;
177 sf->adaptive_pred_interp_filter = 1;
Dmitry Kovalev4ff1a612014-06-12 12:35:57 -0700178 sf->mv.auto_mv_step_size = 1;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700179 sf->adaptive_rd_thresh = 2;
180 sf->intra_y_mode_mask[TX_32X32] = INTRA_DC_H_V;
181 sf->intra_uv_mode_mask[TX_32X32] = INTRA_DC_H_V;
182 sf->intra_uv_mode_mask[TX_16X16] = INTRA_DC_H_V;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700183 }
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700184
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700185 if (speed >= 2) {
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700186 if (MIN(cm->width, cm->height) >= 720)
Dmitry Kovalevd262cda2014-05-29 11:11:50 -0700187 sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
188 : DISABLE_ALL_INTER_SPLIT;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700189 else
190 sf->disable_split_mask = LAST_AND_INTRA_SPLIT_ONLY;
191
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700192 sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH |
193 FLAG_SKIP_INTRA_BESTINTER |
194 FLAG_SKIP_COMP_BESTINTRA |
195 FLAG_SKIP_INTRA_LOWVAR;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700196 sf->adaptive_pred_interp_filter = 2;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700197 sf->reference_masking = 1;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700198 sf->disable_filter_search_var_thresh = 50;
199 sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700200 sf->auto_min_max_partition_size = RELAXED_NEIGHBORING_MIN_MAX;
201 sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_LOW_MOTION;
Paul Wilkins8160a262014-06-17 15:31:24 +0100202 sf->lf_motion_threshold = LOW_MOTION_THRESHOLD;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700203 sf->adjust_partitioning_from_last_frame = 1;
204 sf->last_partitioning_redo_frequency = 3;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700205 sf->use_lp32x32fdct = 1;
206 sf->mode_skip_start = 11;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700207 sf->intra_y_mode_mask[TX_16X16] = INTRA_DC_H_V;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700208 }
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700209
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700210 if (speed >= 3) {
211 sf->use_square_partition_only = 1;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700212 sf->disable_filter_search_var_thresh = 100;
213 sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_ALL;
Marco Paniconi18194992014-04-04 15:10:14 -0700214 sf->constrain_copy_partition = 1;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700215 sf->use_uv_intra_rd_estimate = 1;
216 sf->skip_encode_sb = 1;
Dmitry Kovalev4ff1a612014-06-12 12:35:57 -0700217 sf->mv.subpel_iters_per_step = 1;
Dmitry Kovalev107929d2014-04-04 10:31:34 -0700218 sf->use_fast_coef_updates = ONE_LOOP_REDUCED;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700219 sf->adaptive_rd_thresh = 4;
220 sf->mode_skip_start = 6;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700221 sf->allow_skip_recode = 0;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700222 sf->optimize_coefficients = 0;
223 sf->disable_split_mask = DISABLE_ALL_SPLIT;
224 sf->lpf_pick = LPF_PICK_FROM_Q;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700225 }
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700226
Yaowu Xu6fc20a82014-03-26 16:15:00 -0700227 if (speed >= 4) {
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700228 int i;
229 sf->last_partitioning_redo_frequency = 4;
230 sf->adaptive_rd_thresh = 5;
231 sf->use_fast_coef_costing = 0;
232 sf->auto_min_max_partition_size = STRICT_NEIGHBORING_MIN_MAX;
233 sf->adjust_partitioning_from_last_frame =
234 cm->last_frame_type != cm->frame_type || (0 ==
Alex Converseb9c24df2014-05-22 15:27:35 -0700235 (frames_since_key + 1) % sf->last_partitioning_redo_frequency);
Dmitry Kovalev4ff1a612014-06-12 12:35:57 -0700236 sf->mv.subpel_force_stop = 1;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700237 for (i = 0; i < TX_SIZES; i++) {
238 sf->intra_y_mode_mask[i] = INTRA_DC_H_V;
Dmitry Kovalev26bdf262014-05-29 12:11:02 -0700239 sf->intra_uv_mode_mask[i] = INTRA_DC;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700240 }
Dmitry Kovalev26bdf262014-05-29 12:11:02 -0700241 sf->intra_y_mode_mask[TX_32X32] = INTRA_DC;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700242 sf->frame_parameter_update = 0;
Dmitry Kovalev4ff1a612014-06-12 12:35:57 -0700243 sf->mv.search_method = FAST_HEX;
Dmitry Kovalev40371992014-05-29 12:25:41 -0700244 sf->inter_mode_mask[BLOCK_32X32] = INTER_NEAREST_NEAR_NEW;
245 sf->inter_mode_mask[BLOCK_32X64] = INTER_NEAREST;
246 sf->inter_mode_mask[BLOCK_64X32] = INTER_NEAREST;
247 sf->inter_mode_mask[BLOCK_64X64] = INTER_NEAREST;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700248 sf->max_intra_bsize = BLOCK_32X32;
249 sf->allow_skip_recode = 1;
250 }
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700251
Yaowu Xu6fc20a82014-03-26 16:15:00 -0700252 if (speed >= 5) {
Jingning Hanc99a8fd2014-06-19 09:24:09 -0700253 sf->auto_min_max_partition_size = (cm->frame_type == KEY_FRAME) ?
254 RELAXED_NEIGHBORING_MIN_MAX : STRICT_NEIGHBORING_MIN_MAX;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700255 sf->max_partition_size = BLOCK_32X32;
256 sf->min_partition_size = BLOCK_8X8;
257 sf->partition_check =
Alex Converseb9c24df2014-05-22 15:27:35 -0700258 (frames_since_key % sf->last_partitioning_redo_frequency == 1);
Marco Paniconi0eb88c92014-04-03 15:49:03 -0700259 sf->force_frame_boost = cm->frame_type == KEY_FRAME ||
Alex Converseb9c24df2014-05-22 15:27:35 -0700260 (frames_since_key %
Jingning Han751d0022014-04-01 12:55:20 -0700261 (sf->last_partitioning_redo_frequency << 1) == 1);
Jingning Han2536a892014-04-02 22:44:06 -0700262 sf->max_delta_qindex = (cm->frame_type == KEY_FRAME) ? 20 : 15;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700263 sf->partition_search_type = REFERENCE_PARTITION;
264 sf->use_nonrd_pick_mode = 1;
Dmitry Kovalev4ff1a612014-06-12 12:35:57 -0700265 sf->mv.search_method = FAST_DIAMOND;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700266 sf->allow_skip_recode = 0;
267 }
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700268
Yaowu Xu6fc20a82014-03-26 16:15:00 -0700269 if (speed >= 6) {
Yunqing Wang4e662932014-04-01 17:32:20 -0700270 // Adaptively switch between SOURCE_VAR_BASED_PARTITION and FIXED_PARTITION.
271 sf->partition_search_type = SOURCE_VAR_BASED_PARTITION;
272 sf->search_type_check_frequency = 50;
273 sf->source_var_thresh = 360;
Yunqing Wangb04d7662014-05-29 16:53:23 -0700274
275 sf->tx_size_search_method = USE_TX_8X8;
Yunqing Wang55834d42014-06-17 16:59:28 -0700276 // TODO(yunqingwang): max_intra_bsize is used to decide if DC_PRED mode
277 // is checked for a partition block. Later, we can try to allow large
278 // partitions to do intra mode checking.
279 sf->max_intra_bsize = BLOCK_8X8;
Yunqing Wang0aae1002014-06-20 10:11:34 -0700280
281 // This feature is only enabled when partition search is disabled.
282 sf->reuse_inter_pred_sby = 1;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700283 }
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700284
Yaowu Xu6fc20a82014-03-26 16:15:00 -0700285 if (speed >= 7) {
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700286 int i;
287 for (i = 0; i < BLOCK_SIZES; ++i)
Dmitry Kovalev40371992014-05-29 12:25:41 -0700288 sf->inter_mode_mask[i] = INTER_NEAREST;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700289 }
290}
291
292void vp9_set_speed_features(VP9_COMP *cpi) {
293 SPEED_FEATURES *const sf = &cpi->sf;
294 VP9_COMMON *const cm = &cpi->common;
Dmitry Kovalev07f86d02014-04-18 11:01:36 -0700295 const VP9EncoderConfig *const oxcf = &cpi->oxcf;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700296 int i;
297
298 // best quality defaults
299 sf->frame_parameter_update = 1;
Dmitry Kovalev4ff1a612014-06-12 12:35:57 -0700300 sf->mv.search_method = NSTEP;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700301 sf->recode_loop = ALLOW_RECODE;
Dmitry Kovalev4ff1a612014-06-12 12:35:57 -0700302 sf->mv.subpel_search_method = SUBPEL_TREE;
303 sf->mv.subpel_iters_per_step = 2;
304 sf->mv.subpel_force_stop = 0;
Dmitry Kovalevbd0bb362014-06-03 12:52:49 -0700305 sf->optimize_coefficients = !is_lossless_requested(&cpi->oxcf);
Dmitry Kovalev4ff1a612014-06-12 12:35:57 -0700306 sf->mv.reduce_first_step_size = 0;
307 sf->mv.auto_mv_step_size = 0;
308 sf->mv.max_step_search_steps = MAX_MVSEARCH_STEPS;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700309 sf->comp_inter_joint_search_thresh = BLOCK_4X4;
310 sf->adaptive_rd_thresh = 0;
311 sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_OFF;
312 sf->tx_size_search_method = USE_FULL_RD;
313 sf->use_lp32x32fdct = 0;
314 sf->adaptive_motion_search = 0;
315 sf->adaptive_pred_interp_filter = 0;
316 sf->reference_masking = 0;
317 sf->partition_search_type = SEARCH_PARTITION;
318 sf->less_rectangular_check = 0;
319 sf->use_square_partition_only = 0;
320 sf->auto_min_max_partition_size = NOT_IN_USE;
321 sf->max_partition_size = BLOCK_64X64;
322 sf->min_partition_size = BLOCK_4X4;
323 sf->adjust_partitioning_from_last_frame = 0;
324 sf->last_partitioning_redo_frequency = 4;
Marco Paniconi18194992014-04-04 15:10:14 -0700325 sf->constrain_copy_partition = 0;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700326 sf->disable_split_mask = 0;
327 sf->mode_search_skip_flags = 0;
Marco Paniconi0eb88c92014-04-03 15:49:03 -0700328 sf->force_frame_boost = 0;
Jingning Hand8b8d872014-04-01 15:52:38 -0700329 sf->max_delta_qindex = 0;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700330 sf->disable_split_var_thresh = 0;
331 sf->disable_filter_search_var_thresh = 0;
332 for (i = 0; i < TX_SIZES; i++) {
Dmitry Kovalev26bdf262014-05-29 12:11:02 -0700333 sf->intra_y_mode_mask[i] = INTRA_ALL;
334 sf->intra_uv_mode_mask[i] = INTRA_ALL;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700335 }
336 sf->use_rd_breakout = 0;
337 sf->skip_encode_sb = 0;
338 sf->use_uv_intra_rd_estimate = 0;
339 sf->allow_skip_recode = 0;
340 sf->lpf_pick = LPF_PICK_FROM_FULL_IMAGE;
Dmitry Kovalev107929d2014-04-04 10:31:34 -0700341 sf->use_fast_coef_updates = TWO_LOOP;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700342 sf->use_fast_coef_costing = 0;
343 sf->mode_skip_start = MAX_MODES; // Mode index at which mode skip mask set
344 sf->use_nonrd_pick_mode = 0;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700345 for (i = 0; i < BLOCK_SIZES; ++i)
Dmitry Kovalev40371992014-05-29 12:25:41 -0700346 sf->inter_mode_mask[i] = INTER_ALL;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700347 sf->max_intra_bsize = BLOCK_64X64;
Yunqing Wang0aae1002014-06-20 10:11:34 -0700348 sf->reuse_inter_pred_sby = 0;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700349 // This setting only takes effect when partition_search_type is set
350 // to FIXED_PARTITION.
351 sf->always_this_block_size = BLOCK_16X16;
Yunqing Wang4e662932014-04-01 17:32:20 -0700352 sf->search_type_check_frequency = 50;
353 sf->source_var_thresh = 100;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700354
Paul Wilkins769cd782014-03-31 16:58:39 +0100355 // Recode loop tolerence %.
356 sf->recode_tolerance = 25;
357
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700358 switch (oxcf->mode) {
Dmitry Kovalevf3739f92014-04-14 14:09:39 -0700359 case ONE_PASS_BEST:
360 case TWO_PASS_SECOND_BEST: // This is the best quality mode.
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700361 cpi->diamond_search_sad = vp9_full_range_search;
362 break;
Dmitry Kovalevf3739f92014-04-14 14:09:39 -0700363 case TWO_PASS_FIRST:
364 case ONE_PASS_GOOD:
365 case TWO_PASS_SECOND_GOOD:
Dmitry Kovalev2c8c1f52014-04-16 18:31:42 -0700366 set_good_speed_feature(cpi, cm, sf, oxcf->speed);
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700367 break;
Dmitry Kovalevf3739f92014-04-14 14:09:39 -0700368 case REALTIME:
Alex Converseb9c24df2014-05-22 15:27:35 -0700369 set_rt_speed_feature(cpi, sf, oxcf->speed);
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700370 break;
371 }
372
373 // Slow quant, dct and trellis not worthwhile for first pass
374 // so make sure they are always turned off.
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700375 if (cpi->pass == 1)
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700376 sf->optimize_coefficients = 0;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700377
378 // No recode for 1 pass.
379 if (cpi->pass == 0) {
380 sf->recode_loop = DISALLOW_RECODE;
381 sf->optimize_coefficients = 0;
382 }
383
Dmitry Kovalev4ff1a612014-06-12 12:35:57 -0700384 if (sf->mv.subpel_search_method == SUBPEL_TREE) {
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700385 cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_tree;
386 cpi->find_fractional_mv_step_comp = vp9_find_best_sub_pixel_comp_tree;
387 }
388
Dmitry Kovalev233b5812014-04-04 10:52:20 -0700389 cpi->mb.optimize = sf->optimize_coefficients == 1 && cpi->pass != 1;
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700390
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700391 if (sf->disable_split_mask == DISABLE_ALL_SPLIT)
392 sf->adaptive_pred_interp_filter = 0;
Marco Paniconi0eb88c92014-04-03 15:49:03 -0700393
394 if (!cpi->oxcf.frame_periodic_boost) {
395 sf->max_delta_qindex = 0;
396 }
Dmitry Kovalev0a6d5542014-03-28 10:30:28 -0700397}