Commit 4ff1a614 authored by Dmitry Kovalev's avatar Dmitry Kovalev

Adding MV_SPEED_FEATURES struct.

Moving all motion vector related speed parameters from SPEED_FEATURES to
MV_SPEED_FEATURES.

Change-Id: I3e9af0039c7162f8671878c5920bce3cb256a84e
parent c90cd4d5
......@@ -216,7 +216,7 @@ void vp9_encode_mv(VP9_COMP* cpi, vp9_writer* w,
// If auto_mv_step_size is enabled then keep track of the largest
// motion vector component used.
if (!cpi->dummy_packing && cpi->sf.auto_mv_step_size) {
if (!cpi->dummy_packing && cpi->sf.mv.auto_mv_step_size) {
unsigned int maxv = MAX(abs(mv->row), abs(mv->col)) >> 3;
cpi->max_mv_magnitude = MAX(maxv, cpi->max_mv_magnitude);
}
......
......@@ -484,9 +484,9 @@ static void update_frame_size(VP9_COMP *cpi) {
{
int y_stride = cpi->scaled_source.y_stride;
if (cpi->sf.search_method == NSTEP) {
if (cpi->sf.mv.search_method == NSTEP) {
vp9_init3smotion_compensation(&cpi->ss_cfg, y_stride);
} else if (cpi->sf.search_method == DIAMOND) {
} else if (cpi->sf.mv.search_method == DIAMOND) {
vp9_init_dsmotion_compensation(&cpi->ss_cfg, y_stride);
}
}
......@@ -2012,7 +2012,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
// Initialize cpi->mv_step_param to default based on max resolution.
cpi->mv_step_param = vp9_init_search_range(sf, max_mv_def);
// Initialize cpi->max_mv_magnitude and cpi->mv_step_param if appropriate.
if (sf->auto_mv_step_size) {
if (sf->mv.auto_mv_step_size) {
if (frame_is_intra_only(cm)) {
// Initialize max_mv_magnitude for use in the first INTER frame
// after a key/intra-only frame.
......
......@@ -25,9 +25,10 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi,
MV *dst_mv,
int mb_row,
int mb_col) {
MACROBLOCK *const x = &cpi->mb;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
vp9_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[BLOCK_16X16];
const MV_SPEED_FEATURES *const mv_sf = &cpi->sf.mv;
const vp9_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[BLOCK_16X16];
const int tmp_col_min = x->mv_col_min;
const int tmp_col_max = x->mv_col_max;
......@@ -36,9 +37,9 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi,
MV ref_full;
// Further step/diamond searches as necessary
int step_param = cpi->sf.reduce_first_step_size +
int step_param = mv_sf->reduce_first_step_size +
(cpi->oxcf.speed > 5 ? 1 : 0);
step_param = MIN(step_param, cpi->sf.max_step_search_steps - 2);
step_param = MIN(step_param, mv_sf->max_step_search_steps - 2);
vp9_set_mv_search_range(x, ref_mv);
......@@ -56,7 +57,7 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi,
unsigned int sse;
cpi->find_fractional_mv_step(
x, dst_mv, ref_mv, cpi->common.allow_high_precision_mv, x->errorperbit,
&v_fn_ptr, 0, cpi->sf.subpel_iters_per_step, NULL, NULL, &distortion,
&v_fn_ptr, 0, mv_sf->subpel_iters_per_step, NULL, NULL, &distortion,
&sse);
}
......
......@@ -60,8 +60,8 @@ int vp9_init_search_range(const SPEED_FEATURES *sf, int size) {
while ((size << sr) < MAX_FULL_PEL_VAL)
sr++;
sr += sf->reduce_first_step_size;
sr = MIN(sr, (sf->max_step_search_steps - 2));
sr += sf->mv.reduce_first_step_size;
sr = MIN(sr, (sf->mv.max_step_search_steps - 2));
return sr;
}
......@@ -1600,7 +1600,7 @@ int vp9_full_pixel_search(VP9_COMP *cpi, MACROBLOCK *x,
const MV *ref_mv, MV *tmp_mv,
int var_max, int rd) {
const SPEED_FEATURES *const sf = &cpi->sf;
const SEARCH_METHODS method = sf->search_method;
const SEARCH_METHODS method = sf->mv.search_method;
vp9_variance_fn_ptr_t *fn_ptr = &cpi->fn_ptr[bsize];
int var = 0;
......@@ -1627,7 +1627,8 @@ int vp9_full_pixel_search(VP9_COMP *cpi, MACROBLOCK *x,
break;
case NSTEP:
var = vp9_full_pixel_diamond(cpi, x, mvp_full, step_param, error_per_bit,
(sf->max_step_search_steps - 1) - step_param,
(sf->mv.max_step_search_steps - 1) -
step_param,
1, fn_ptr, ref_mv, tmp_mv);
break;
default:
......
......@@ -132,8 +132,8 @@ static void sub_pixel_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
cpi->common.allow_high_precision_mv,
x->errorperbit,
&cpi->fn_ptr[bsize],
cpi->sf.subpel_force_stop,
cpi->sf.subpel_iters_per_step,
cpi->sf.mv.subpel_force_stop,
cpi->sf.mv.subpel_iters_per_step,
x->nmvjointcost, x->mvcost,
&dis, &x->pred_sse[ref]);
......
......@@ -1826,7 +1826,7 @@ static int64_t rd_pick_best_sub8x8_mode(VP9_COMP *cpi, MACROBLOCK *x,
else
max_mv = MAX(abs(bsi->mvp.as_mv.row), abs(bsi->mvp.as_mv.col)) >> 3;
if (cpi->sf.auto_mv_step_size && cm->show_frame) {
if (cpi->sf.mv.auto_mv_step_size && cm->show_frame) {
// Take wtd average of the step_params based on the last frame's
// max mv magnitude and the best ref mvs of the current block for
// the given reference.
......@@ -1881,8 +1881,8 @@ static int64_t rd_pick_best_sub8x8_mode(VP9_COMP *cpi, MACROBLOCK *x,
&bsi->ref_mv[0]->as_mv,
cm->allow_high_precision_mv,
x->errorperbit, &cpi->fn_ptr[bsize],
cpi->sf.subpel_force_stop,
cpi->sf.subpel_iters_per_step,
cpi->sf.mv.subpel_force_stop,
cpi->sf.mv.subpel_iters_per_step,
x->nmvjointcost, x->mvcost,
&distortion,
&x->pred_sse[mbmi->ref_frame[0]]);
......@@ -2338,7 +2338,7 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
// Work out the size of the first step in the mv step search.
// 0 here is maximum length first step. 1 is MAX >> 1 etc.
if (cpi->sf.auto_mv_step_size && cm->show_frame) {
if (cpi->sf.mv.auto_mv_step_size && cm->show_frame) {
// Take wtd average of the step_params based on the last frame's
// max mv magnitude and that based on the best ref mvs of the current
// block for the given reference.
......@@ -2399,8 +2399,8 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
cm->allow_high_precision_mv,
x->errorperbit,
&cpi->fn_ptr[bsize],
cpi->sf.subpel_force_stop,
cpi->sf.subpel_iters_per_step,
cpi->sf.mv.subpel_force_stop,
cpi->sf.mv.subpel_iters_per_step,
x->nmvjointcost, x->mvcost,
&dis, &x->pred_sse[ref]);
}
......@@ -2524,7 +2524,7 @@ static void joint_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
cpi->common.allow_high_precision_mv,
x->errorperbit,
&cpi->fn_ptr[bsize],
0, cpi->sf.subpel_iters_per_step,
0, cpi->sf.mv.subpel_iters_per_step,
x->nmvjointcost, x->mvcost,
&dis, &sse, second_pred,
pw, ph);
......
......@@ -69,9 +69,9 @@ static void set_good_speed_feature(VP9_COMP *cpi, VP9_COMMON *cm,
sf->disable_split_mask = DISABLE_COMPOUND_SPLIT;
sf->use_rd_breakout = 1;
sf->adaptive_motion_search = 1;
sf->auto_mv_step_size = 1;
sf->mv.auto_mv_step_size = 1;
sf->adaptive_rd_thresh = 2;
sf->subpel_iters_per_step = 1;
sf->mv.subpel_iters_per_step = 1;
sf->mode_skip_start = 10;
sf->adaptive_pred_interp_filter = 1;
......@@ -140,7 +140,7 @@ static void set_good_speed_feature(VP9_COMP *cpi, VP9_COMMON *cm,
sf->partition_search_type = FIXED_PARTITION;
sf->optimize_coefficients = 0;
sf->search_method = HEX;
sf->mv.search_method = HEX;
sf->disable_filter_search_var_thresh = 500;
for (i = 0; i < TX_SIZES; ++i) {
sf->intra_y_mode_mask[i] = INTRA_DC;
......@@ -174,7 +174,7 @@ static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf,
sf->use_rd_breakout = 1;
sf->adaptive_motion_search = 1;
sf->adaptive_pred_interp_filter = 1;
sf->auto_mv_step_size = 1;
sf->mv.auto_mv_step_size = 1;
sf->adaptive_rd_thresh = 2;
sf->intra_y_mode_mask[TX_32X32] = INTRA_DC_H_V;
sf->intra_uv_mode_mask[TX_32X32] = INTRA_DC_H_V;
......@@ -213,7 +213,7 @@ static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf,
sf->constrain_copy_partition = 1;
sf->use_uv_intra_rd_estimate = 1;
sf->skip_encode_sb = 1;
sf->subpel_iters_per_step = 1;
sf->mv.subpel_iters_per_step = 1;
sf->use_fast_coef_updates = ONE_LOOP_REDUCED;
sf->adaptive_rd_thresh = 4;
sf->mode_skip_start = 6;
......@@ -232,14 +232,14 @@ static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf,
sf->adjust_partitioning_from_last_frame =
cm->last_frame_type != cm->frame_type || (0 ==
(frames_since_key + 1) % sf->last_partitioning_redo_frequency);
sf->subpel_force_stop = 1;
sf->mv.subpel_force_stop = 1;
for (i = 0; i < TX_SIZES; i++) {
sf->intra_y_mode_mask[i] = INTRA_DC_H_V;
sf->intra_uv_mode_mask[i] = INTRA_DC;
}
sf->intra_y_mode_mask[TX_32X32] = INTRA_DC;
sf->frame_parameter_update = 0;
sf->search_method = FAST_HEX;
sf->mv.search_method = FAST_HEX;
sf->inter_mode_mask[BLOCK_32X32] = INTER_NEAREST_NEAR_NEW;
sf->inter_mode_mask[BLOCK_32X64] = INTER_NEAREST;
sf->inter_mode_mask[BLOCK_64X32] = INTER_NEAREST;
......@@ -259,7 +259,7 @@ static void set_rt_speed_feature(VP9_COMP *cpi, SPEED_FEATURES *sf,
sf->max_delta_qindex = (cm->frame_type == KEY_FRAME) ? 20 : 15;
sf->partition_search_type = REFERENCE_PARTITION;
sf->use_nonrd_pick_mode = 1;
sf->search_method = FAST_DIAMOND;
sf->mv.search_method = FAST_DIAMOND;
sf->allow_skip_recode = 0;
}
......@@ -287,15 +287,15 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
// best quality defaults
sf->frame_parameter_update = 1;
sf->search_method = NSTEP;
sf->mv.search_method = NSTEP;
sf->recode_loop = ALLOW_RECODE;
sf->subpel_search_method = SUBPEL_TREE;
sf->subpel_iters_per_step = 2;
sf->subpel_force_stop = 0;
sf->mv.subpel_search_method = SUBPEL_TREE;
sf->mv.subpel_iters_per_step = 2;
sf->mv.subpel_force_stop = 0;
sf->optimize_coefficients = !is_lossless_requested(&cpi->oxcf);
sf->reduce_first_step_size = 0;
sf->auto_mv_step_size = 0;
sf->max_step_search_steps = MAX_MVSEARCH_STEPS;
sf->mv.reduce_first_step_size = 0;
sf->mv.auto_mv_step_size = 0;
sf->mv.max_step_search_steps = MAX_MVSEARCH_STEPS;
sf->comp_inter_joint_search_thresh = BLOCK_4X4;
sf->adaptive_rd_thresh = 0;
sf->use_lastframe_partitioning = LAST_FRAME_PARTITION_OFF;
......@@ -370,7 +370,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
sf->optimize_coefficients = 0;
}
if (sf->subpel_search_method == SUBPEL_TREE) {
if (sf->mv.subpel_search_method == SUBPEL_TREE) {
cpi->find_fractional_mv_step = vp9_find_best_sub_pixel_tree;
cpi->find_fractional_mv_step_comp = vp9_find_best_sub_pixel_comp_tree;
}
......
......@@ -133,14 +133,21 @@ typedef enum {
ONE_LOOP_REDUCED = 2
} FAST_COEFF_UPDATE;
typedef struct SPEED_FEATURES {
// Frame level coding parameter update
int frame_parameter_update;
typedef struct MV_SPEED_FEATURES {
// Motion search method (Diamond, NSTEP, Hex, Big Diamond, Square, etc).
SEARCH_METHODS search_method;
RECODE_LOOP_TYPE recode_loop;
// This parameter controls the number of steps we'll do in a diamond
// search.
int max_step_search_steps;
// This parameter controls which step in the n-step process we start at.
// It's changed adaptively based on circumstances.
int reduce_first_step_size;
// If this is set to 1, we limit the motion search range to 2 times the
// largest motion vector found in the last frame.
int auto_mv_step_size;
// Subpel_search_method can only be subpel_tree which does a subpixel
// logarithmic search that keeps stepping at 1/2 pixel units until
......@@ -153,18 +160,15 @@ typedef struct SPEED_FEATURES {
// Control when to stop subpel search
int subpel_force_stop;
} MV_SPEED_FEATURES;
// This parameter controls the number of steps we'll do in a diamond
// search.
int max_step_search_steps;
typedef struct SPEED_FEATURES {
MV_SPEED_FEATURES mv;
// This parameter controls which step in the n-step process we start at.
// It's changed adaptively based on circumstances.
int reduce_first_step_size;
// Frame level coding parameter update
int frame_parameter_update;
// If this is set to 1, we limit the motion search range to 2 times the
// largest motion vector found in the last frame.
int auto_mv_step_size;
RECODE_LOOP_TYPE recode_loop;
// Trellis (dynamic programming) optimization of quantized values (+1, 0).
int optimize_coefficients;
......
......@@ -137,8 +137,9 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi,
uint8_t *arf_frame_buf,
uint8_t *frame_ptr_buf,
int stride) {
MACROBLOCK *x = &cpi->mb;
MACROBLOCKD* const xd = &x->e_mbd;
MACROBLOCK *const x = &cpi->mb;
MACROBLOCKD *const xd = &x->e_mbd;
const MV_SPEED_FEATURES *const mv_sf = &cpi->sf.mv;
int step_param;
int sadpb = x->sadperbit16;
int bestsme = INT_MAX;
......@@ -162,8 +163,8 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi,
xd->plane[0].pre[0].buf = frame_ptr_buf;
xd->plane[0].pre[0].stride = stride;
step_param = cpi->sf.reduce_first_step_size + (cpi->oxcf.speed > 5 ? 1 : 0);
step_param = MIN(step_param, cpi->sf.max_step_search_steps - 2);
step_param = mv_sf->reduce_first_step_size + (cpi->oxcf.speed > 5 ? 1 : 0);
step_param = MIN(step_param, mv_sf->max_step_search_steps - 2);
// Ignore mv costing by sending NULL pointer instead of cost arrays
vp9_hex_search(x, &best_ref_mv1_full, step_param, sadpb, 1,
......@@ -175,7 +176,7 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi,
cpi->common.allow_high_precision_mv,
x->errorperbit,
&cpi->fn_ptr[BLOCK_16X16],
0, cpi->sf.subpel_iters_per_step,
0, mv_sf->subpel_iters_per_step,
NULL, NULL,
&distortion, &sse);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment