vp9_speed_features.c 19 KB

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