diff options
Diffstat (limited to 'vp9/encoder/vp9_encoder.c')
-rw-r--r-- | vp9/encoder/vp9_encoder.c | 74 |
1 files changed, 32 insertions, 42 deletions
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 1b3010c62..df4223a23 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -2377,6 +2377,19 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf, #endif // TODO(jingning): Reduce the actual memory use for tpl model build up. for (frame = 0; frame < MAX_ARF_GOP_SIZE; ++frame) { +#if CONFIG_NON_GREEDY_MV + int sqr_bsize; + int rf_idx; + for (rf_idx = 0; rf_idx < 3; ++rf_idx) { + for (sqr_bsize = 0; sqr_bsize < SQUARE_BLOCK_SIZES; ++sqr_bsize) { + CHECK_MEM_ERROR( + cm, cpi->tpl_stats[frame].pyramid_mv_arr[rf_idx][sqr_bsize], + vpx_calloc(mi_rows * mi_cols, + sizeof(*cpi->tpl_stats[frame] + .pyramid_mv_arr[rf_idx][sqr_bsize]))); + } + } +#endif CHECK_MEM_ERROR(cm, cpi->tpl_stats[frame].tpl_stats_ptr, vpx_calloc(mi_rows * mi_cols, sizeof(*cpi->tpl_stats[frame].tpl_stats_ptr))); @@ -5586,39 +5599,12 @@ 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, uint8_t *ref_frame_buf, int stride, BLOCK_SIZE bsize, int mi_row, int mi_col, - TplDepStats *tpl_stats, int rf_idx) { - MV *mv = &tpl_stats->mv_arr[rf_idx].as_mv; + MV *mv, int rf_idx, double *mv_dist, + double *mv_cost) { #else // CONFIG_NON_GREEDY_MV uint32_t motion_compensated_prediction(VP9_COMP *cpi, ThreadData *td, int frame_idx, uint8_t *cur_frame_buf, @@ -5664,12 +5650,11 @@ 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_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, - &tpl_stats->mv_dist[rf_idx], &tpl_stats->mv_cost[rf_idx]); + 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, mv, + mv_dist, mv_cost); #else (void)frame_idx; (void)mi_row; @@ -6002,7 +5987,8 @@ void mode_estimation(VP9_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *xd, #if CONFIG_NON_GREEDY_MV (void)td; - mv.as_int = tpl_stats->mv_arr[rf_idx].as_int; + mv.as_int = + get_pyramid_mv(tpl_frame, rf_idx, bsize, mi_row, mi_col)->as_int; #else motion_compensated_prediction( cpi, td, frame_idx, xd->cur_buf->y_buffer + mb_y_offset, @@ -6104,6 +6090,7 @@ static void do_motion_search(VP9_COMP *cpi, ThreadData *td, int frame_idx, set_mv_limits(cm, x, mi_row, mi_col); for (rf_idx = 0; rf_idx < 3; ++rf_idx) { + int_mv *mv = get_pyramid_mv(tpl_frame, rf_idx, bsize, mi_row, mi_col); if (ref_frame[rf_idx] == NULL) { tpl_stats->ready[rf_idx] = 0; continue; @@ -6113,7 +6100,8 @@ static void do_motion_search(VP9_COMP *cpi, ThreadData *td, int frame_idx, motion_compensated_prediction( cpi, td, frame_idx, xd->cur_buf->y_buffer + mb_y_offset, ref_frame[rf_idx]->y_buffer + mb_y_offset, xd->cur_buf->y_stride, bsize, - mi_row, mi_col, tpl_stats, rf_idx); + mi_row, mi_col, &mv->as_mv, rf_idx, &tpl_stats->mv_dist[rf_idx], + &tpl_stats->mv_cost[rf_idx]); } } @@ -6355,12 +6343,14 @@ void mc_flow_dispenser(VP9_COMP *cpi, GF_PICTURE *gf_picture, int frame_idx, &tpl_frame->tpl_stats_ptr[mi_row * tpl_frame->stride + mi_col]; for (rf_idx = 0; rf_idx < 3; ++rf_idx) { #if RE_COMPUTE_MV_INCONSISTENCY + MV this_mv = + get_pyramid_mv(tpl_frame, rf_idx, bsize, mi_row, mi_col)->as_mv; 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); - 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; + vp9_prepare_nb_full_mvs(tpl_frame, mi_row, mi_col, rf_idx, bsize, + nb_full_mvs); + full_mv.row = this_mv.row >> 3; + full_mv.col = this_mv.col >> 3; this_tpl_stats->mv_cost[rf_idx] = vp9_nb_mvs_inconsistency(&full_mv, nb_full_mvs, NB_MVS_NUM); #endif // RE_COMPUTE_MV_INCONSISTENCY @@ -6414,7 +6404,7 @@ static void dump_tpl_stats(const VP9_COMP *cpi, int tpl_group_frames, if ((mi_row % mi_height) == 0 && (mi_col % mi_width) == 0) { const TplDepStats *tpl_ptr = &tpl_frame->tpl_stats_ptr[mi_row * tpl_frame->stride + mi_col]; - int_mv mv = tpl_ptr->mv_arr[idx]; + int_mv mv = *get_pyramid_mv(tpl_frame, idx, bsize, mi_row, mi_col); printf("%d %d %d %d\n", mi_row, mi_col, mv.as_mv.row, mv.as_mv.col); } } |