From f835e9f693c9365a7a506c5bfb25bbb9801557ad Mon Sep 17 00:00:00 2001 From: Angie Chiang Date: Mon, 10 Dec 2018 14:22:53 -0800 Subject: [PATCH] Move prepare_nb_full_mvs to vp9_mcomp.c Change-Id: I36e3bcae60751a9caeac03a3c94cb752b73a010b --- vp9/encoder/vp9_encoder.c | 35 ++++------------------------------- vp9/encoder/vp9_mcomp.c | 26 ++++++++++++++++++++++++++ vp9/encoder/vp9_mcomp.h | 5 +++++ 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 1b3010c62..d8ca3f4b9 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -5585,33 +5585,6 @@ void init_tpl_stats(VP9_COMP *cpi) { } } -#if CONFIG_NON_GREEDY_MV -static void prepare_nb_full_mvs(const TplDepFrame *tpl_frame, int mi_row, - int mi_col, int rf_idx, BLOCK_SIZE bsize, - int_mv *nb_full_mvs) { - const int mi_unit = num_8x8_blocks_wide_lookup[bsize]; - const int dirs[NB_MVS_NUM][2] = { { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 } }; - int i; - for (i = 0; i < NB_MVS_NUM; ++i) { - int r = dirs[i][0] * mi_unit; - int c = dirs[i][1] * mi_unit; - if (mi_row + r >= 0 && mi_row + r < tpl_frame->mi_rows && mi_col + c >= 0 && - mi_col + c < tpl_frame->mi_cols) { - const TplDepStats *tpl_ptr = - &tpl_frame - ->tpl_stats_ptr[(mi_row + r) * tpl_frame->stride + mi_col + c]; - if (tpl_ptr->ready[rf_idx]) { - nb_full_mvs[i].as_mv = get_full_mv(&tpl_ptr->mv_arr[rf_idx].as_mv); - } else { - nb_full_mvs[i].as_int = INVALID_MV; - } - } else { - nb_full_mvs[i].as_int = INVALID_MV; - } - } -} -#endif - #if CONFIG_NON_GREEDY_MV uint32_t motion_compensated_prediction(VP9_COMP *cpi, ThreadData *td, int frame_idx, uint8_t *cur_frame_buf, @@ -5664,8 +5637,8 @@ uint32_t motion_compensated_prediction(VP9_COMP *cpi, ThreadData *td, #if CONFIG_NON_GREEDY_MV (void)search_method; (void)sadpb; - prepare_nb_full_mvs(&cpi->tpl_stats[frame_idx], mi_row, mi_col, rf_idx, bsize, - nb_full_mvs); + vp9_prepare_nb_full_mvs(&cpi->tpl_stats[frame_idx], mi_row, mi_col, rf_idx, + bsize, nb_full_mvs); vp9_full_pixel_diamond_new( cpi, x, &best_ref_mv1_full, step_param, lambda, 1, &cpi->fn_ptr[bsize], nb_full_mvs, NB_MVS_NUM, &tpl_stats->mv_arr[rf_idx].as_mv, @@ -6357,8 +6330,8 @@ void mc_flow_dispenser(VP9_COMP *cpi, GF_PICTURE *gf_picture, int frame_idx, #if RE_COMPUTE_MV_INCONSISTENCY MV full_mv; int_mv nb_full_mvs[NB_MVS_NUM]; - prepare_nb_full_mvs(tpl_frame, mi_row, mi_col, rf_idx, bsize, - nb_full_mvs); + vp9_prepare_nb_full_mvs(tpl_frame, mi_row, mi_col, rf_idx, bsize, + nb_full_mvs); full_mv.row = this_tpl_stats->mv_arr[rf_idx].as_mv.row >> 3; full_mv.col = this_tpl_stats->mv_arr[rf_idx].as_mv.col >> 3; this_tpl_stats->mv_cost[rf_idx] = diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c index 316227e3c..50c268d28 100644 --- a/vp9/encoder/vp9_mcomp.c +++ b/vp9/encoder/vp9_mcomp.c @@ -1879,6 +1879,32 @@ double vp9_diamond_search_sad_new(const MACROBLOCK *x, } return bestsad; } + +void vp9_prepare_nb_full_mvs(const TplDepFrame *tpl_frame, int mi_row, + int mi_col, int rf_idx, BLOCK_SIZE bsize, + int_mv *nb_full_mvs) { + const int mi_width = num_8x8_blocks_wide_lookup[bsize]; + const int mi_height = num_8x8_blocks_high_lookup[bsize]; + const int dirs[NB_MVS_NUM][2] = { { -1, 0 }, { 0, -1 }, { 1, 0 }, { 0, 1 } }; + int i; + for (i = 0; i < NB_MVS_NUM; ++i) { + int r = dirs[i][0] * mi_height; + int c = dirs[i][1] * mi_width; + if (mi_row + r >= 0 && mi_row + r < tpl_frame->mi_rows && mi_col + c >= 0 && + mi_col + c < tpl_frame->mi_cols) { + const TplDepStats *tpl_ptr = + &tpl_frame + ->tpl_stats_ptr[(mi_row + r) * tpl_frame->stride + mi_col + c]; + if (tpl_ptr->ready[rf_idx]) { + nb_full_mvs[i].as_mv = get_full_mv(&tpl_ptr->mv_arr[rf_idx].as_mv); + } else { + nb_full_mvs[i].as_int = INVALID_MV; + } + } else { + nb_full_mvs[i].as_int = INVALID_MV; + } + } +} #endif // CONFIG_NON_GREEDY_MV int vp9_diamond_search_sad_c(const MACROBLOCK *x, const search_site_config *cfg, diff --git a/vp9/encoder/vp9_mcomp.h b/vp9/encoder/vp9_mcomp.h index 6d89fdfdd..ab69afdcd 100644 --- a/vp9/encoder/vp9_mcomp.h +++ b/vp9/encoder/vp9_mcomp.h @@ -143,6 +143,11 @@ static INLINE MV get_full_mv(const MV *mv) { out_mv.col = mv->col >> 3; return out_mv; } + +struct TplDepFrame; +void vp9_prepare_nb_full_mvs(const struct TplDepFrame *tpl_frame, int mi_row, + int mi_col, int rf_idx, BLOCK_SIZE bsize, + int_mv *nb_full_mvs); #endif // CONFIG_NON_GREEDY_MV #ifdef __cplusplus } // extern "C" -- 2.40.0