| Index: source/libvpx/vp9/encoder/vp9_speed_features.c
|
| ===================================================================
|
| --- source/libvpx/vp9/encoder/vp9_speed_features.c (revision 293081)
|
| +++ source/libvpx/vp9/encoder/vp9_speed_features.c (working copy)
|
| @@ -16,13 +16,62 @@
|
| // Intra only frames, golden frames (except alt ref overlays) and
|
| // alt ref frames tend to be coded at a higher than ambient quality
|
| static int frame_is_boosted(const VP9_COMP *cpi) {
|
| - return frame_is_intra_only(&cpi->common) ||
|
| - cpi->refresh_alt_ref_frame ||
|
| - (cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref) ||
|
| - vp9_is_upper_layer_key_frame(cpi);
|
| + return frame_is_kf_gf_arf(cpi) || vp9_is_upper_layer_key_frame(cpi);
|
| }
|
|
|
| +static void set_good_speed_feature_framesize_dependent(VP9_COMMON *cm,
|
| + SPEED_FEATURES *sf,
|
| + int speed) {
|
| + if (speed >= 1) {
|
| + if (MIN(cm->width, cm->height) >= 720) {
|
| + sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
|
| + : DISABLE_ALL_INTER_SPLIT;
|
| + sf->partition_search_breakout_dist_thr = (1 << 23);
|
| + } else {
|
| + sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
|
| + sf->partition_search_breakout_dist_thr = (1 << 21);
|
| + }
|
| + }
|
|
|
| + if (speed >= 2) {
|
| + if (MIN(cm->width, cm->height) >= 720) {
|
| + sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
|
| + : DISABLE_ALL_INTER_SPLIT;
|
| + sf->adaptive_pred_interp_filter = 0;
|
| + sf->partition_search_breakout_dist_thr = (1 << 24);
|
| + sf->partition_search_breakout_rate_thr = 120;
|
| + } else {
|
| + sf->disable_split_mask = LAST_AND_INTRA_SPLIT_ONLY;
|
| + sf->partition_search_breakout_dist_thr = (1 << 22);
|
| + sf->partition_search_breakout_rate_thr = 100;
|
| + }
|
| + }
|
| +
|
| + if (speed >= 3) {
|
| + if (MIN(cm->width, cm->height) >= 720) {
|
| + sf->disable_split_mask = DISABLE_ALL_SPLIT;
|
| + sf->schedule_mode_search = cm->base_qindex < 220 ? 1 : 0;
|
| + sf->partition_search_breakout_dist_thr = (1 << 25);
|
| + sf->partition_search_breakout_rate_thr = 200;
|
| + } else {
|
| + sf->max_intra_bsize = BLOCK_32X32;
|
| + sf->disable_split_mask = DISABLE_ALL_INTER_SPLIT;
|
| + sf->schedule_mode_search = cm->base_qindex < 175 ? 1 : 0;
|
| + sf->partition_search_breakout_dist_thr = (1 << 23);
|
| + sf->partition_search_breakout_rate_thr = 120;
|
| + }
|
| + }
|
| +
|
| + if (speed >= 4) {
|
| + if (MIN(cm->width, cm->height) >= 720) {
|
| + sf->partition_search_breakout_dist_thr = (1 << 26);
|
| + } else {
|
| + sf->partition_search_breakout_dist_thr = (1 << 24);
|
| + }
|
| + sf->disable_split_mask = DISABLE_ALL_SPLIT;
|
| + }
|
| +}
|
| +
|
| static void set_good_speed_feature(VP9_COMP *cpi, VP9_COMMON *cm,
|
| SPEED_FEATURES *sf, int speed) {
|
| const int boosted = frame_is_boosted(cpi);
|
| @@ -34,11 +83,6 @@
|
| sf->use_square_partition_only = !frame_is_intra_only(cm);
|
| sf->less_rectangular_check = 1;
|
|
|
| - if (MIN(cm->width, cm->height) >= 720)
|
| - sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
|
| - : DISABLE_ALL_INTER_SPLIT;
|
| - else
|
| - sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
|
| sf->use_rd_breakout = 1;
|
| sf->adaptive_motion_search = 1;
|
| sf->mv.auto_mv_step_size = 1;
|
| @@ -54,11 +98,6 @@
|
| sf->intra_uv_mode_mask[TX_16X16] = INTRA_DC_H_V;
|
|
|
| sf->tx_size_search_breakout = 1;
|
| -
|
| - if (MIN(cm->width, cm->height) >= 720)
|
| - sf->partition_search_breakout_dist_thr = (1 << 23);
|
| - else
|
| - sf->partition_search_breakout_dist_thr = (1 << 21);
|
| sf->partition_search_breakout_rate_thr = 80;
|
| }
|
|
|
| @@ -66,18 +105,6 @@
|
| sf->tx_size_search_method = frame_is_boosted(cpi) ? USE_FULL_RD
|
| : USE_LARGESTALL;
|
|
|
| - if (MIN(cm->width, cm->height) >= 720) {
|
| - sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
|
| - : DISABLE_ALL_INTER_SPLIT;
|
| - sf->adaptive_pred_interp_filter = 0;
|
| - sf->partition_search_breakout_dist_thr = (1 << 24);
|
| - sf->partition_search_breakout_rate_thr = 120;
|
| - } else {
|
| - sf->disable_split_mask = LAST_AND_INTRA_SPLIT_ONLY;
|
| - sf->partition_search_breakout_dist_thr = (1 << 22);
|
| - sf->partition_search_breakout_rate_thr = 100;
|
| - }
|
| -
|
| sf->reference_masking = 1;
|
| sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH |
|
| FLAG_SKIP_INTRA_BESTINTER |
|
| @@ -93,18 +120,6 @@
|
| if (speed >= 3) {
|
| sf->tx_size_search_method = frame_is_intra_only(cm) ? USE_FULL_RD
|
| : USE_LARGESTALL;
|
| - if (MIN(cm->width, cm->height) >= 720) {
|
| - sf->disable_split_mask = DISABLE_ALL_SPLIT;
|
| - sf->schedule_mode_search = cm->base_qindex < 220 ? 1 : 0;
|
| - sf->partition_search_breakout_dist_thr = (1 << 25);
|
| - sf->partition_search_breakout_rate_thr = 200;
|
| - } else {
|
| - sf->max_intra_bsize = BLOCK_32X32;
|
| - sf->disable_split_mask = DISABLE_ALL_INTER_SPLIT;
|
| - sf->schedule_mode_search = cm->base_qindex < 175 ? 1 : 0;
|
| - sf->partition_search_breakout_dist_thr = (1 << 23);
|
| - sf->partition_search_breakout_rate_thr = 120;
|
| - }
|
| sf->mv.subpel_search_method = SUBPEL_TREE_PRUNED;
|
| sf->adaptive_pred_interp_filter = 0;
|
| sf->adaptive_mode_search = 1;
|
| @@ -122,7 +137,6 @@
|
| if (speed >= 4) {
|
| sf->use_square_partition_only = 1;
|
| sf->tx_size_search_method = USE_LARGESTALL;
|
| - sf->disable_split_mask = DISABLE_ALL_SPLIT;
|
| sf->mv.search_method = BIGDIA;
|
| sf->mv.subpel_search_method = SUBPEL_TREE_PRUNED_MORE;
|
| sf->adaptive_rd_thresh = 4;
|
| @@ -132,18 +146,11 @@
|
| sf->use_fast_coef_updates = ONE_LOOP_REDUCED;
|
| sf->use_fast_coef_costing = 1;
|
| sf->motion_field_mode_search = !boosted;
|
| -
|
| - if (MIN(cm->width, cm->height) >= 720)
|
| - sf->partition_search_breakout_dist_thr = (1 << 26);
|
| - else
|
| - sf->partition_search_breakout_dist_thr = (1 << 24);
|
| sf->partition_search_breakout_rate_thr = 300;
|
| }
|
|
|
| if (speed >= 5) {
|
| int i;
|
| -
|
| - sf->partition_search_type = FIXED_PARTITION;
|
| sf->optimize_coefficients = 0;
|
| sf->mv.search_method = HEX;
|
| sf->disable_filter_search_var_thresh = 500;
|
| @@ -151,12 +158,47 @@
|
| sf->intra_y_mode_mask[i] = INTRA_DC;
|
| sf->intra_uv_mode_mask[i] = INTRA_DC;
|
| }
|
| - }
|
| - if (speed >= 6) {
|
| + sf->partition_search_breakout_rate_thr = 500;
|
| sf->mv.reduce_first_step_size = 1;
|
| }
|
| }
|
|
|
| +static void set_rt_speed_feature_framesize_dependent(VP9_COMP *cpi,
|
| + SPEED_FEATURES *sf, int speed) {
|
| + VP9_COMMON *const cm = &cpi->common;
|
| +
|
| + if (speed >= 1) {
|
| + if (MIN(cm->width, cm->height) >= 720) {
|
| + sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
|
| + : DISABLE_ALL_INTER_SPLIT;
|
| + } else {
|
| + sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
|
| + }
|
| + }
|
| +
|
| + if (speed >= 2) {
|
| + if (MIN(cm->width, cm->height) >= 720) {
|
| + sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
|
| + : DISABLE_ALL_INTER_SPLIT;
|
| + } else {
|
| + sf->disable_split_mask = LAST_AND_INTRA_SPLIT_ONLY;
|
| + }
|
| + }
|
| +
|
| + if (speed >= 5) {
|
| + if (MIN(cm->width, cm->height) >= 720) {
|
| + sf->partition_search_breakout_dist_thr = (1 << 25);
|
| + } else {
|
| + sf->partition_search_breakout_dist_thr = (1 << 23);
|
| + }
|
| + }
|
| +
|
| + if (speed >= 7) {
|
| + sf->encode_breakout_thresh = (MIN(cm->width, cm->height) >= 720) ?
|
| + 800 : 300;
|
| + }
|
| +}
|
| +
|
| static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf,
|
| int speed, vp9e_tune_content content) {
|
| VP9_COMMON *const cm = &cpi->common;
|
| @@ -172,12 +214,6 @@
|
| sf->tx_size_search_method = frame_is_intra_only(cm) ? USE_FULL_RD
|
| : USE_LARGESTALL;
|
|
|
| - if (MIN(cm->width, cm->height) >= 720)
|
| - sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
|
| - : DISABLE_ALL_INTER_SPLIT;
|
| - else
|
| - sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
|
| -
|
| sf->use_rd_breakout = 1;
|
|
|
| sf->adaptive_motion_search = 1;
|
| @@ -190,12 +226,6 @@
|
| }
|
|
|
| if (speed >= 2) {
|
| - if (MIN(cm->width, cm->height) >= 720)
|
| - sf->disable_split_mask = cm->show_frame ? DISABLE_ALL_SPLIT
|
| - : DISABLE_ALL_INTER_SPLIT;
|
| - else
|
| - sf->disable_split_mask = LAST_AND_INTRA_SPLIT_ONLY;
|
| -
|
| sf->mode_search_skip_flags = FLAG_SKIP_INTRA_DIRMISMATCH |
|
| FLAG_SKIP_INTRA_BESTINTER |
|
| FLAG_SKIP_COMP_BESTINTRA |
|
| @@ -205,7 +235,6 @@
|
| sf->disable_filter_search_var_thresh = 50;
|
| sf->comp_inter_joint_search_thresh = BLOCK_SIZES;
|
| sf->auto_min_max_partition_size = RELAXED_NEIGHBORING_MIN_MAX;
|
| - sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_LOW_MOTION;
|
| sf->lf_motion_threshold = LOW_MOTION_THRESHOLD;
|
| sf->adjust_partitioning_from_last_frame = 1;
|
| sf->last_partitioning_redo_frequency = 3;
|
| @@ -217,8 +246,6 @@
|
| if (speed >= 3) {
|
| sf->use_square_partition_only = 1;
|
| sf->disable_filter_search_var_thresh = 100;
|
| - sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_ALL;
|
| - sf->constrain_copy_partition = 1;
|
| sf->use_uv_intra_rd_estimate = 1;
|
| sf->skip_encode_sb = 1;
|
| sf->mv.subpel_iters_per_step = 1;
|
| @@ -261,10 +288,8 @@
|
| sf->use_quant_fp = !is_keyframe;
|
| sf->auto_min_max_partition_size = is_keyframe ? RELAXED_NEIGHBORING_MIN_MAX
|
| : STRICT_NEIGHBORING_MIN_MAX;
|
| - sf->max_partition_size = BLOCK_32X32;
|
| - sf->min_partition_size = BLOCK_8X8;
|
| - sf->partition_check =
|
| - (frames_since_key % sf->last_partitioning_redo_frequency == 1);
|
| + sf->default_max_partition_size = BLOCK_32X32;
|
| + sf->default_min_partition_size = BLOCK_8X8;
|
| sf->force_frame_boost = is_keyframe ||
|
| (frames_since_key % (sf->last_partitioning_redo_frequency << 1) == 1);
|
| sf->max_delta_qindex = is_keyframe ? 20 : 15;
|
| @@ -275,49 +300,41 @@
|
| sf->inter_mode_mask[BLOCK_32X64] = INTER_NEAREST_NEW_ZERO;
|
| sf->inter_mode_mask[BLOCK_64X32] = INTER_NEAREST_NEW_ZERO;
|
| sf->inter_mode_mask[BLOCK_64X64] = INTER_NEAREST_NEW_ZERO;
|
| -
|
| - if (MIN(cm->width, cm->height) >= 720)
|
| - sf->partition_search_breakout_dist_thr = (1 << 25);
|
| - else
|
| - sf->partition_search_breakout_dist_thr = (1 << 23);
|
| + sf->adaptive_rd_thresh = 2;
|
| + // This feature is only enabled when partition search is disabled.
|
| + sf->reuse_inter_pred_sby = 1;
|
| sf->partition_search_breakout_rate_thr = 200;
|
| + if (!is_keyframe) {
|
| + int i;
|
| + if (content == VP9E_CONTENT_SCREEN) {
|
| + for (i = 0; i < TX_SIZES; ++i)
|
| + sf->intra_y_mode_mask[i] = INTRA_DC_TM_H_V;
|
| + } else {
|
| + for (i = 0; i < TX_SIZES; i++)
|
| + sf->intra_y_mode_mask[i] = INTRA_DC;
|
| + }
|
| + }
|
| }
|
|
|
| if (speed >= 6) {
|
| - if (content == VP9E_CONTENT_SCREEN) {
|
| - int i;
|
| - // Allow fancy modes at all sizes since SOURCE_VAR_BASED_PARTITION is used
|
| - for (i = 0; i < BLOCK_SIZES; ++i)
|
| - sf->inter_mode_mask[i] = INTER_NEAREST_NEAR_NEW;
|
| - }
|
| -
|
| // Adaptively switch between SOURCE_VAR_BASED_PARTITION and FIXED_PARTITION.
|
| sf->partition_search_type = VAR_BASED_PARTITION;
|
| sf->search_type_check_frequency = 50;
|
| sf->mv.search_method = NSTEP;
|
| -
|
| sf->tx_size_search_method = is_keyframe ? USE_LARGESTALL : USE_TX_8X8;
|
| -
|
| - // This feature is only enabled when partition search is disabled.
|
| - sf->reuse_inter_pred_sby = 1;
|
| -
|
| - // Increase mode checking threshold for NEWMV.
|
| - sf->elevate_newmv_thresh = 1000;
|
| -
|
| sf->mv.reduce_first_step_size = 1;
|
| + sf->skip_encode_sb = 0;
|
| }
|
|
|
| if (speed >= 7) {
|
| + sf->adaptive_rd_thresh = 3;
|
| sf->mv.search_method = FAST_DIAMOND;
|
| sf->mv.fullpel_search_step_param = 10;
|
| sf->lpf_pick = LPF_PICK_MINIMAL_LPF;
|
| - sf->encode_breakout_thresh = (MIN(cm->width, cm->height) >= 720) ?
|
| - 800 : 300;
|
| - sf->elevate_newmv_thresh = 2500;
|
| }
|
|
|
| if (speed >= 12) {
|
| - sf->elevate_newmv_thresh = 4000;
|
| + sf->adaptive_rd_thresh = 4;
|
| sf->mv.subpel_force_stop = 2;
|
| }
|
|
|
| @@ -329,12 +346,43 @@
|
| }
|
| }
|
|
|
| -void vp9_set_speed_features(VP9_COMP *cpi) {
|
| +void vp9_set_speed_features_framesize_dependent(VP9_COMP *cpi) {
|
| SPEED_FEATURES *const sf = &cpi->sf;
|
| VP9_COMMON *const cm = &cpi->common;
|
| const VP9EncoderConfig *const oxcf = &cpi->oxcf;
|
| + RD_OPT *const rd = &cpi->rd;
|
| int i;
|
|
|
| + if (oxcf->mode == REALTIME) {
|
| + set_rt_speed_feature_framesize_dependent(cpi, sf, oxcf->speed);
|
| + } else if (oxcf->mode == GOOD) {
|
| + set_good_speed_feature_framesize_dependent(cm, sf, oxcf->speed);
|
| + }
|
| +
|
| + if (sf->disable_split_mask == DISABLE_ALL_SPLIT) {
|
| + sf->adaptive_pred_interp_filter = 0;
|
| + }
|
| +
|
| + if (cpi->encode_breakout && oxcf->mode == REALTIME &&
|
| + sf->encode_breakout_thresh > cpi->encode_breakout) {
|
| + cpi->encode_breakout = sf->encode_breakout_thresh;
|
| + }
|
| +
|
| + // Check for masked out split cases.
|
| + for (i = 0; i < MAX_REFS; ++i) {
|
| + if (sf->disable_split_mask & (1 << i)) {
|
| + rd->thresh_mult_sub8x8[i] = INT_MAX;
|
| + }
|
| + }
|
| +}
|
| +
|
| +void vp9_set_speed_features_framesize_independent(VP9_COMP *cpi) {
|
| + SPEED_FEATURES *const sf = &cpi->sf;
|
| + VP9_COMMON *const cm = &cpi->common;
|
| + MACROBLOCK *const x = &cpi->mb;
|
| + const VP9EncoderConfig *const oxcf = &cpi->oxcf;
|
| + int i;
|
| +
|
| // best quality defaults
|
| sf->frame_parameter_update = 1;
|
| sf->mv.search_method = NSTEP;
|
| @@ -348,7 +396,6 @@
|
| sf->mv.fullpel_search_step_param = 6;
|
| sf->comp_inter_joint_search_thresh = BLOCK_4X4;
|
| sf->adaptive_rd_thresh = 0;
|
| - sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_OFF;
|
| sf->tx_size_search_method = USE_FULL_RD;
|
| sf->use_lp32x32fdct = 0;
|
| sf->adaptive_motion_search = 0;
|
| @@ -364,11 +411,10 @@
|
| sf->less_rectangular_check = 0;
|
| sf->use_square_partition_only = 0;
|
| sf->auto_min_max_partition_size = NOT_IN_USE;
|
| - sf->max_partition_size = BLOCK_64X64;
|
| - sf->min_partition_size = BLOCK_4X4;
|
| + sf->default_max_partition_size = BLOCK_64X64;
|
| + sf->default_min_partition_size = BLOCK_4X4;
|
| sf->adjust_partitioning_from_last_frame = 0;
|
| sf->last_partitioning_redo_frequency = 4;
|
| - sf->constrain_copy_partition = 0;
|
| sf->disable_split_mask = 0;
|
| sf->mode_search_skip_flags = 0;
|
| sf->force_frame_boost = 0;
|
| @@ -401,7 +447,7 @@
|
| sf->search_type_check_frequency = 50;
|
| sf->encode_breakout_thresh = 0;
|
| sf->elevate_newmv_thresh = 0;
|
| - // Recode loop tolerence %.
|
| + // Recode loop tolerance %.
|
| sf->recode_tolerance = 25;
|
| sf->default_interp_filter = SWITCHABLE;
|
| sf->tx_size_search_breakout = 0;
|
| @@ -416,9 +462,7 @@
|
| cpi->full_search_sad = vp9_full_search_sad;
|
| cpi->diamond_search_sad = oxcf->mode == BEST ? vp9_full_range_search
|
| : vp9_diamond_search_sad;
|
| - cpi->refining_search_sad = vp9_refining_search_sad;
|
|
|
| -
|
| // Slow quant, dct and trellis not worthwhile for first pass
|
| // so make sure they are always turned off.
|
| if (oxcf->pass == 1)
|
| @@ -440,16 +484,12 @@
|
| cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_tree_pruned_evenmore;
|
| }
|
|
|
| - cpi->mb.optimize = sf->optimize_coefficients == 1 && oxcf->pass != 1;
|
| + x->optimize = sf->optimize_coefficients == 1 && oxcf->pass != 1;
|
|
|
| - if (sf->disable_split_mask == DISABLE_ALL_SPLIT)
|
| - sf->adaptive_pred_interp_filter = 0;
|
| + x->min_partition_size = sf->default_min_partition_size;
|
| + x->max_partition_size = sf->default_max_partition_size;
|
|
|
| if (!cpi->oxcf.frame_periodic_boost) {
|
| sf->max_delta_qindex = 0;
|
| }
|
| -
|
| - if (cpi->encode_breakout && oxcf->mode == REALTIME &&
|
| - sf->encode_breakout_thresh > cpi->encode_breakout)
|
| - cpi->encode_breakout = sf->encode_breakout_thresh;
|
| }
|
|
|