diff --git a/vp9/encoder/vp9_mbgraph.c b/vp9/encoder/vp9_mbgraph.c index 65fdcbe50cf614658a4cfe298dd5104b4ce5cd61..1b8f873184e6b71a16372f277cc88e22547bb985 100644 --- a/vp9/encoder/vp9_mbgraph.c +++ b/vp9/encoder/vp9_mbgraph.c @@ -35,8 +35,9 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi, int_mv ref_full; // Further step/diamond searches as necessary - int step_param = cpi->sf.first_step + + int step_param = cpi->sf.reduce_first_step_size + (cpi->speed < 8 ? (cpi->speed > 5 ? 1 : 0) : 2); + step_param = MIN(step_param, (cpi->sf.max_step_search_steps - 2)); vp9_clamp_mv_min_max(x, ref_mv); diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c index 212dce3b8292583d846e9beb47418bafe6cf6a77..3df312af5dd6d4ec6eaf7ffcb5829412cb43197e 100644 --- a/vp9/encoder/vp9_mcomp.c +++ b/vp9/encoder/vp9_mcomp.c @@ -38,16 +38,17 @@ void vp9_clamp_mv_min_max(MACROBLOCK *x, int_mv *ref_mv) { x->mv_row_max = row_max; } -int vp9_init_search_range(int width, int height) { +int vp9_init_search_range(VP9_COMP *cpi, int size) { int sr = 0; - int frm = MIN(width, height); - while ((frm << sr) < MAX_FULL_PEL_VAL) + while ((size << sr) < MAX_FULL_PEL_VAL) sr++; if (sr) sr--; + sr += cpi->sf.reduce_first_step_size; + sr = MIN(sr, (cpi->sf.max_step_search_steps - 2)); return sr; } diff --git a/vp9/encoder/vp9_mcomp.h b/vp9/encoder/vp9_mcomp.h index 28b2efd288b58b2426d442ef42b32f550a96b7e7..c13ea7597f2d0ab067379cd8b9e9bf0c2c92d81d 100644 --- a/vp9/encoder/vp9_mcomp.h +++ b/vp9/encoder/vp9_mcomp.h @@ -24,15 +24,15 @@ #define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS-1)) void vp9_clamp_mv_min_max(MACROBLOCK *x, int_mv *ref_mv); -int vp9_init_search_range(int width, int height); - int vp9_mv_bit_cost(int_mv *mv, int_mv *ref, int *mvjcost, int *mvcost[2], int weight, int ishp); void vp9_init_dsmotion_compensation(MACROBLOCK *x, int stride); void vp9_init3smotion_compensation(MACROBLOCK *x, int stride); -// Runs sequence of diamond searches in smaller steps for RD struct VP9_COMP; +int vp9_init_search_range(struct VP9_COMP *cpi, int size); + +// Runs sequence of diamond searches in smaller steps for RD int vp9_full_pixel_diamond(struct VP9_COMP *cpi, MACROBLOCK *x, int_mv *mvp_full, int step_param, int sadpb, int further_steps, int do_refine, diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index 571d94a128071f6a0272c4e1319a09d6a94e368d..33b3a42c5154da70a4869b16e11c12c2d490f0a3 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -680,7 +680,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) { sf->half_pixel_search = 1; sf->iterative_sub_pixel = 1; sf->optimize_coefficients = !cpi->oxcf.lossless; - sf->first_step = 0; + sf->reduce_first_step_size = 0; sf->max_step_search_steps = MAX_MVSEARCH_STEPS; sf->comp_inter_joint_search_thresh = BLOCK_SIZE_AB4X4; sf->adpative_rd_thresh = 0; @@ -721,7 +721,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) { if (speed == 1) { sf->comp_inter_joint_search_thresh = BLOCK_SIZE_TYPES; sf->optimize_coefficients = 0; - sf->first_step = 1; + sf->reduce_first_step_size = 1; sf->use_avoid_tested_higherror = 1; sf->adjust_thresholds_by_speed = 1; sf->use_largest_txform = !(cpi->common.frame_type == KEY_FRAME || @@ -731,27 +731,27 @@ void vp9_set_speed_features(VP9_COMP *cpi) { if (speed == 2) { sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8; sf->use_lastframe_partitioning = 1; - sf->first_step = 0; + sf->reduce_first_step_size = 0; } if (speed == 3) { sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8; sf->partition_by_variance = 1; - sf->first_step = 0; + sf->reduce_first_step_size = 0; } if (speed == 4) { - sf->first_step = 0; + sf->reduce_first_step_size = 0; sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8; sf->use_one_partition_size_always = 1; sf->always_this_block_size = BLOCK_SIZE_MB16X16; } if (speed == 2) { - sf->first_step = 0; + sf->reduce_first_step_size = 0; sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8; sf->use_partitions_less_than = 1; sf->less_than_block_size = BLOCK_SIZE_MB16X16; } if (speed == 3) { - sf->first_step = 0; + sf->reduce_first_step_size = 0; sf->comp_inter_joint_search_thresh = BLOCK_SIZE_SB8X8; sf->use_partitions_greater_than = 1; sf->greater_than_block_size = BLOCK_SIZE_SB8X8; diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h index 0811976d0f18fe14341c518f09bb25257ca1ee43..1204ce0920c251bf98313429c005c2dc0c520a5b 100644 --- a/vp9/encoder/vp9_onyx_int.h +++ b/vp9/encoder/vp9_onyx_int.h @@ -210,7 +210,7 @@ typedef struct { int quarter_pixel_search; int thresh_mult[MAX_MODES]; int max_step_search_steps; - int first_step; + int reduce_first_step_size; int optimize_coefficients; int search_best_filter; int static_segmentation; diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index fe724d5c098b8e8521209b38df043cd06e72881f..20080884cc5ab51805ed7d81f148928250c1b8d4 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -1989,12 +1989,11 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x, MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi; struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0}}; int bestsme = INT_MAX; - int further_steps, step_param = cpi->sf.first_step; + int further_steps, step_param; int sadpb = x->sadperbit16; int_mv mvp_full; int ref = mbmi->ref_frame[0]; int_mv ref_mv = mbmi->ref_mvs[ref][0]; - int sr = 0; const enum BlockSize block_size = get_plane_block_size(bsize, &xd->plane[0]); int tmp_col_min = x->mv_col_min; @@ -2018,7 +2017,8 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x, vp9_clamp_mv_min_max(x, &ref_mv); - sr = vp9_init_search_range(cpi->common.width, cpi->common.height); + step_param = vp9_init_search_range( + cpi, MIN(cpi->common.width, cpi->common.height)); // mvp_full.as_int = ref_mv[0].as_int; mvp_full.as_int = @@ -2027,9 +2027,6 @@ static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x, mvp_full.as_mv.col >>= 3; mvp_full.as_mv.row >>= 3; - // adjust search range according to sr from mv prediction - step_param = MAX(step_param, sr); - // Further step/diamond searches as necessary further_steps = (cpi->sf.max_step_search_steps - 1) - step_param; diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c index 872bf267a32cbd1176b95c2710e0cf84ef1028af..c1bd93bf579584cb20c6f77060ea4ef61045b9c2 100644 --- a/vp9/encoder/vp9_temporal_filter.c +++ b/vp9/encoder/vp9_temporal_filter.c @@ -148,9 +148,10 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi, // Further step/diamond searches as necessary if (cpi->speed < 8) - step_param = cpi->sf.first_step + ((cpi->speed > 5) ? 1 : 0); + step_param = cpi->sf.reduce_first_step_size + ((cpi->speed > 5) ? 1 : 0); else - step_param = cpi->sf.first_step + 2; + step_param = cpi->sf.reduce_first_step_size + 2; + step_param = MIN(step_param, (cpi->sf.max_step_search_steps - 2)); /*cpi->sf.search_method == HEX*/ // TODO Check that the 16x16 vf & sdf are selected here