From 5e35c3c9a0a6a0cdb584b79e9f415414aa1a7cd6 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 17 Aug 2015 20:17:00 -0700 Subject: [PATCH 1/5] vp9_encoder: make vp9_alloc_compressor_data private Change-Id: I38b4de692f4f7e880766316783981cbd1134bed9 --- vp9/encoder/vp9_encoder.c | 6 +++--- vp9/encoder/vp9_encoder.h | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 3cb935f97..02cafe5cb 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -686,7 +686,7 @@ static int alloc_context_buffers_ext(VP9_COMP *cpi) { return 0; } -void vp9_alloc_compressor_data(VP9_COMP *cpi) { +static void alloc_compressor_data(VP9_COMP *cpi) { VP9_COMMON *cm = &cpi->common; vp9_alloc_context_buffers(cm, cm->width, cm->height); @@ -775,7 +775,7 @@ static void init_config(struct VP9_COMP *cpi, VP9EncoderConfig *oxcf) { cm->width = oxcf->width; cm->height = oxcf->height; - vp9_alloc_compressor_data(cpi); + alloc_compressor_data(cpi); cpi->svc.temporal_layering_mode = oxcf->temporal_layering_mode; @@ -1510,7 +1510,7 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) { if (cpi->initial_width) { if (cm->width > cpi->initial_width || cm->height > cpi->initial_height) { vp9_free_context_buffers(cm); - vp9_alloc_compressor_data(cpi); + alloc_compressor_data(cpi); realloc_segmentation_maps(cpi); cpi->initial_width = cpi->initial_height = 0; } diff --git a/vp9/encoder/vp9_encoder.h b/vp9/encoder/vp9_encoder.h index c10abd20d..7c2101850 100644 --- a/vp9/encoder/vp9_encoder.h +++ b/vp9/encoder/vp9_encoder.h @@ -605,8 +605,6 @@ int64_t vp9_highbd_get_y_sse(const YV12_BUFFER_CONFIG *a, const YV12_BUFFER_CONFIG *b); #endif // CONFIG_VP9_HIGHBITDEPTH -void vp9_alloc_compressor_data(VP9_COMP *cpi); - void vp9_scale_references(VP9_COMP *cpi); void vp9_update_reference_frames(VP9_COMP *cpi); From c6eadc3309c3bf093a6ea3527376d1d7f0ed4dbe Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 17 Aug 2015 20:17:47 -0700 Subject: [PATCH 2/5] vp9_firstpass: make vp9_init_subsampling private Change-Id: I03b2ae99ec2e212c76bf815de7d5745b5c965d57 --- vp9/encoder/vp9_firstpass.c | 4 ++-- vp9/encoder/vp9_firstpass.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 65bf4b41d..e409a3ae4 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -1237,7 +1237,7 @@ static void setup_rf_level_maxq(VP9_COMP *cpi) { } } -void vp9_init_subsampling(VP9_COMP *cpi) { +static void init_subsampling(VP9_COMP *cpi) { const VP9_COMMON *const cm = &cpi->common; RATE_CONTROL *const rc = &cpi->rc; const int w = cm->width; @@ -1332,7 +1332,7 @@ void vp9_init_second_pass(VP9_COMP *cpi) { twopass->last_kfgroup_zeromotion_pct = 100; if (oxcf->resize_mode != RESIZE_NONE) { - vp9_init_subsampling(cpi); + init_subsampling(cpi); } } diff --git a/vp9/encoder/vp9_firstpass.h b/vp9/encoder/vp9_firstpass.h index 49f9da38e..5875a7b9b 100644 --- a/vp9/encoder/vp9_firstpass.h +++ b/vp9/encoder/vp9_firstpass.h @@ -153,8 +153,6 @@ void vp9_twopass_postencode_update(struct VP9_COMP *cpi); // Post encode update of the rate control parameters for 2-pass void vp9_twopass_postencode_update(struct VP9_COMP *cpi); -void vp9_init_subsampling(struct VP9_COMP *cpi); - void calculate_coded_size(struct VP9_COMP *cpi, int *scaled_frame_width, int *scaled_frame_height); From d743a55adba5864179ec6514bcf339933a2b7ec1 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 17 Aug 2015 20:57:14 -0700 Subject: [PATCH 3/5] vp9_temporal_filter: use vp9_full_pixel_search(HEX) instead of calling vp9_hex_search() directly. this will allow the function to be made private Change-Id: I8c8cfc61fca4faef593c1c3fc29824dc417cae22 --- vp9/encoder/vp9_temporal_filter.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c index 9c1629ede..3f2c8eba7 100644 --- a/vp9/encoder/vp9_temporal_filter.c +++ b/vp9/encoder/vp9_temporal_filter.c @@ -216,7 +216,8 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi, int stride) { MACROBLOCK *const x = &cpi->td.mb; MACROBLOCKD *const xd = &x->e_mbd; - const MV_SPEED_FEATURES *const mv_sf = &cpi->sf.mv; + MV_SPEED_FEATURES *const mv_sf = &cpi->sf.mv; + const SEARCH_METHODS old_search_method = mv_sf->search_method; int step_param; int sadpb = x->sadperbit16; int bestsme = INT_MAX; @@ -244,10 +245,11 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi, step_param = mv_sf->reduce_first_step_size; step_param = VPXMIN(step_param, MAX_MVSEARCH_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, - cond_cost_list(cpi, cost_list), - &cpi->fn_ptr[BLOCK_16X16], 0, &best_ref_mv1, ref_mv); + mv_sf->search_method = HEX; + vp9_full_pixel_search(cpi, x, BLOCK_16X16, &best_ref_mv1_full, step_param, + sadpb, cond_cost_list(cpi, cost_list), &best_ref_mv1, + ref_mv, 0, 0); + mv_sf->search_method = old_search_method; // Ignore mv costing by sending NULL pointer instead of cost array bestsme = cpi->find_fractional_mv_step(x, ref_mv, From 4e218309874abbfb97150345934519549af0703f Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 17 Aug 2015 20:57:14 -0700 Subject: [PATCH 4/5] vp9_mbgraph: use vp9_full_pixel_search(HEX) instead of calling vp9_hex_search() directly. this will allow the function to be made private Change-Id: I2f9d4779763aa5b24eda4eb01c78954e061e45ac --- vp9/encoder/vp9_mbgraph.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/vp9/encoder/vp9_mbgraph.c b/vp9/encoder/vp9_mbgraph.c index 178466672..0ac1bc2de 100644 --- a/vp9/encoder/vp9_mbgraph.c +++ b/vp9/encoder/vp9_mbgraph.c @@ -29,7 +29,8 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi, int mb_col) { MACROBLOCK *const x = &cpi->td.mb; MACROBLOCKD *const xd = &x->e_mbd; - const MV_SPEED_FEATURES *const mv_sf = &cpi->sf.mv; + MV_SPEED_FEATURES *const mv_sf = &cpi->sf.mv; + const SEARCH_METHODS old_search_method = mv_sf->search_method; const vp9_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[BLOCK_16X16]; const int tmp_col_min = x->mv_col_min; @@ -48,10 +49,11 @@ static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi, ref_full.col = ref_mv->col >> 3; ref_full.row = ref_mv->row >> 3; - /*cpi->sf.search_method == HEX*/ - vp9_hex_search(x, &ref_full, step_param, x->errorperbit, 0, - cond_cost_list(cpi, cost_list), - &v_fn_ptr, 0, ref_mv, dst_mv); + mv_sf->search_method = HEX; + vp9_full_pixel_search(cpi, x, BLOCK_16X16, &ref_full, step_param, + x->errorperbit, cond_cost_list(cpi, cost_list), ref_mv, + dst_mv, 0, 0); + mv_sf->search_method = old_search_method; // Try sub-pixel MC // if (bestsme > error_thresh && bestsme < INT_MAX) From ff03d5448a37bb8a119af1d8e5889ea1dbfb5389 Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 17 Aug 2015 20:18:31 -0700 Subject: [PATCH 5/5] vp9_mcomp: make search functions private vp9_full_pixel_search() can be used as a replacement as it dispatches to all search methods Change-Id: I57fcb79c1362b569dc95237bdcc8390f54efd440 --- vp9/encoder/vp9_mcomp.c | 145 ++++++++++++++++++++-------------------- vp9/encoder/vp9_mcomp.h | 26 ------- 2 files changed, 73 insertions(+), 98 deletions(-) diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c index 6a02481fa..b8423aa67 100644 --- a/vp9/encoder/vp9_mcomp.c +++ b/vp9/encoder/vp9_mcomp.c @@ -1371,15 +1371,15 @@ int vp9_get_mvpred_av_var(const MACROBLOCK *x, x->mvcost, x->errorperbit) : 0); } -int vp9_hex_search(const MACROBLOCK *x, - MV *ref_mv, - int search_param, - int sad_per_bit, - int do_init_search, - int *cost_list, - const vp9_variance_fn_ptr_t *vfp, - int use_mvcost, - const MV *center_mv, MV *best_mv) { +static int hex_search(const MACROBLOCK *x, + MV *ref_mv, + int search_param, + int sad_per_bit, + int do_init_search, + int *cost_list, + const vp9_variance_fn_ptr_t *vfp, + int use_mvcost, + const MV *center_mv, MV *best_mv) { // First scale has 8-closest points, the rest have 6 points in hex shape // at increasing scales static const int hex_num_candidates[MAX_PATTERN_SCALES] = { @@ -1406,16 +1406,16 @@ int vp9_hex_search(const MACROBLOCK *x, hex_num_candidates, hex_candidates); } -int vp9_bigdia_search(const MACROBLOCK *x, - MV *ref_mv, - int search_param, - int sad_per_bit, - int do_init_search, - int *cost_list, - const vp9_variance_fn_ptr_t *vfp, - int use_mvcost, - const MV *center_mv, - MV *best_mv) { +static int bigdia_search(const MACROBLOCK *x, + MV *ref_mv, + int search_param, + int sad_per_bit, + int do_init_search, + int *cost_list, + const vp9_variance_fn_ptr_t *vfp, + int use_mvcost, + const MV *center_mv, + MV *best_mv) { // First scale has 4-closest points, the rest have 8 points in diamond // shape at increasing scales static const int bigdia_num_candidates[MAX_PATTERN_SCALES] = { @@ -1448,16 +1448,16 @@ int vp9_bigdia_search(const MACROBLOCK *x, bigdia_num_candidates, bigdia_candidates); } -int vp9_square_search(const MACROBLOCK *x, - MV *ref_mv, - int search_param, - int sad_per_bit, - int do_init_search, - int *cost_list, - const vp9_variance_fn_ptr_t *vfp, - int use_mvcost, - const MV *center_mv, - MV *best_mv) { +static int square_search(const MACROBLOCK *x, + MV *ref_mv, + int search_param, + int sad_per_bit, + int do_init_search, + int *cost_list, + const vp9_variance_fn_ptr_t *vfp, + int use_mvcost, + const MV *center_mv, + MV *best_mv) { // All scales have 8 closest points in square shape static const int square_num_candidates[MAX_PATTERN_SCALES] = { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, @@ -1490,32 +1490,32 @@ int vp9_square_search(const MACROBLOCK *x, square_num_candidates, square_candidates); } -int vp9_fast_hex_search(const MACROBLOCK *x, - MV *ref_mv, - int search_param, - int sad_per_bit, - int do_init_search, // must be zero for fast_hex - int *cost_list, - const vp9_variance_fn_ptr_t *vfp, - int use_mvcost, - const MV *center_mv, - MV *best_mv) { - return vp9_hex_search(x, ref_mv, VPXMAX(MAX_MVSEARCH_STEPS - 2, search_param), - sad_per_bit, do_init_search, cost_list, vfp, use_mvcost, - center_mv, best_mv); +static int fast_hex_search(const MACROBLOCK *x, + MV *ref_mv, + int search_param, + int sad_per_bit, + int do_init_search, // must be zero for fast_hex + int *cost_list, + const vp9_variance_fn_ptr_t *vfp, + int use_mvcost, + const MV *center_mv, + MV *best_mv) { + return hex_search(x, ref_mv, VPXMAX(MAX_MVSEARCH_STEPS - 2, search_param), + sad_per_bit, do_init_search, cost_list, vfp, use_mvcost, + center_mv, best_mv); } -int vp9_fast_dia_search(const MACROBLOCK *x, - MV *ref_mv, - int search_param, - int sad_per_bit, - int do_init_search, - int *cost_list, - const vp9_variance_fn_ptr_t *vfp, - int use_mvcost, - const MV *center_mv, - MV *best_mv) { - return vp9_bigdia_search( +static int fast_dia_search(const MACROBLOCK *x, + MV *ref_mv, + int search_param, + int sad_per_bit, + int do_init_search, + int *cost_list, + const vp9_variance_fn_ptr_t *vfp, + int use_mvcost, + const MV *center_mv, + MV *best_mv) { + return bigdia_search( x, ref_mv, VPXMAX(MAX_MVSEARCH_STEPS - 2, search_param), sad_per_bit, do_init_search, cost_list, vfp, use_mvcost, center_mv, best_mv); } @@ -1946,15 +1946,16 @@ unsigned int vp9_int_pro_motion_estimation(const VP9_COMP *cpi, MACROBLOCK *x, return best_sad; } +// Runs sequence of diamond searches in smaller steps for RD. /* do_refine: If last step (1-away) of n-step search doesn't pick the center point as the best match, we will do a final 1-away diamond refining search */ -int vp9_full_pixel_diamond(const VP9_COMP *cpi, MACROBLOCK *x, - MV *mvp_full, int step_param, - int sadpb, int further_steps, int do_refine, - int *cost_list, - const vp9_variance_fn_ptr_t *fn_ptr, - const MV *ref_mv, MV *dst_mv) { +static int full_pixel_diamond(const VP9_COMP *cpi, MACROBLOCK *x, + MV *mvp_full, int step_param, + int sadpb, int further_steps, int do_refine, + int *cost_list, + const vp9_variance_fn_ptr_t *fn_ptr, + const MV *ref_mv, MV *dst_mv) { MV temp_mv; int thissme, n, num00 = 0; int bestsme = cpi->diamond_search_sad(x, &cpi->ss_cfg, mvp_full, &temp_mv, @@ -2346,29 +2347,29 @@ int vp9_full_pixel_search(VP9_COMP *cpi, MACROBLOCK *x, switch (method) { case FAST_DIAMOND: - var = vp9_fast_dia_search(x, mvp_full, step_param, error_per_bit, 0, - cost_list, fn_ptr, 1, ref_mv, tmp_mv); + var = fast_dia_search(x, mvp_full, step_param, error_per_bit, 0, + cost_list, fn_ptr, 1, ref_mv, tmp_mv); break; case FAST_HEX: - var = vp9_fast_hex_search(x, mvp_full, step_param, error_per_bit, 0, - cost_list, fn_ptr, 1, ref_mv, tmp_mv); + var = fast_hex_search(x, mvp_full, step_param, error_per_bit, 0, + cost_list, fn_ptr, 1, ref_mv, tmp_mv); break; case HEX: - var = vp9_hex_search(x, mvp_full, step_param, error_per_bit, 1, - cost_list, fn_ptr, 1, ref_mv, tmp_mv); + var = hex_search(x, mvp_full, step_param, error_per_bit, 1, + cost_list, fn_ptr, 1, ref_mv, tmp_mv); break; case SQUARE: - var = vp9_square_search(x, mvp_full, step_param, error_per_bit, 1, - cost_list, fn_ptr, 1, ref_mv, tmp_mv); + var = square_search(x, mvp_full, step_param, error_per_bit, 1, + cost_list, fn_ptr, 1, ref_mv, tmp_mv); break; case BIGDIA: - var = vp9_bigdia_search(x, mvp_full, step_param, error_per_bit, 1, - cost_list, fn_ptr, 1, ref_mv, tmp_mv); + var = bigdia_search(x, mvp_full, step_param, error_per_bit, 1, + cost_list, fn_ptr, 1, ref_mv, tmp_mv); break; case NSTEP: - var = vp9_full_pixel_diamond(cpi, x, mvp_full, step_param, error_per_bit, - MAX_MVSEARCH_STEPS - 1 - step_param, - 1, cost_list, fn_ptr, ref_mv, tmp_mv); + var = full_pixel_diamond(cpi, x, mvp_full, step_param, error_per_bit, + MAX_MVSEARCH_STEPS - 1 - step_param, + 1, cost_list, fn_ptr, ref_mv, tmp_mv); break; default: assert(0 && "Invalid search method."); diff --git a/vp9/encoder/vp9_mcomp.h b/vp9/encoder/vp9_mcomp.h index 817bd7959..5efd5435b 100644 --- a/vp9/encoder/vp9_mcomp.h +++ b/vp9/encoder/vp9_mcomp.h @@ -72,38 +72,12 @@ int vp9_refining_search_sad(const struct macroblock *x, const struct vp9_variance_vtable *fn_ptr, const struct mv *center_mv); -// Runs sequence of diamond searches in smaller steps for RD. -int vp9_full_pixel_diamond(const struct VP9_COMP *cpi, MACROBLOCK *x, - MV *mvp_full, int step_param, - int sadpb, int further_steps, int do_refine, - int *cost_list, - const vp9_variance_fn_ptr_t *fn_ptr, - const MV *ref_mv, MV *dst_mv); - // Perform integral projection based motion estimation. unsigned int vp9_int_pro_motion_estimation(const struct VP9_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, int mi_row, int mi_col); -typedef int (integer_mv_pattern_search_fn) ( - const MACROBLOCK *x, - MV *ref_mv, - int search_param, - int error_per_bit, - int do_init_search, - int *cost_list, - const vp9_variance_fn_ptr_t *vf, - int use_mvcost, - const MV *center_mv, - MV *best_mv); - -integer_mv_pattern_search_fn vp9_hex_search; -integer_mv_pattern_search_fn vp9_bigdia_search; -integer_mv_pattern_search_fn vp9_square_search; -integer_mv_pattern_search_fn vp9_fast_hex_search; -integer_mv_pattern_search_fn vp9_fast_dia_search; - typedef int (fractional_mv_step_fp) ( const MACROBLOCK *x, MV *bestmv, const MV *ref_mv,