From 9662531d77d6a47e7d7cdc6b0c5d9f3388507c8f Mon Sep 17 00:00:00 2001 From: Scott LaVarnway Date: Fri, 19 Apr 2013 16:32:15 -0400 Subject: [PATCH] Eliminated prev_mip memsets/memcpys For 1080 material, this buffer is currently 2,270,928 bytes. This patch swaps ptrs instead of copying and uses the last show_frame flag instead of setting the entire buffer to zero. For the test clip used, the decoder improved by up to 1%. Change-Id: I686825712ad56043e09ada9808dc489f875a6ce0 --- vp9/common/vp9_alloccommon.c | 3 --- vp9/common/vp9_entropymode.c | 3 +++ vp9/common/vp9_onyxc_int.h | 1 + vp9/decoder/vp9_decodemv.c | 3 ++- vp9/decoder/vp9_decodframe.c | 2 ++ vp9/decoder/vp9_onyxd_if.c | 19 +++++++++++-------- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/vp9/common/vp9_alloccommon.c b/vp9/common/vp9_alloccommon.c index e142362..8d75c4d 100644 --- a/vp9/common/vp9_alloccommon.c +++ b/vp9/common/vp9_alloccommon.c @@ -137,9 +137,6 @@ int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) { return 1; } - vp9_update_mode_info_border(oci, oci->mip); - vp9_update_mode_info_in_image(oci, oci->mi); - return 0; } diff --git a/vp9/common/vp9_entropymode.c b/vp9/common/vp9_entropymode.c index f19dc12..9cb1d2b 100644 --- a/vp9/common/vp9_entropymode.c +++ b/vp9/common/vp9_entropymode.c @@ -718,6 +718,9 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) { vp9_update_mode_info_border(cm, cm->mip); vp9_update_mode_info_in_image(cm, cm->mi); + vp9_update_mode_info_border(cm, cm->prev_mip); + vp9_update_mode_info_in_image(cm, cm->prev_mi); + cm->ref_frame_sign_bias[GOLDEN_FRAME] = 0; cm->ref_frame_sign_bias[ALTREF_FRAME] = 0; diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index 13ec865..7f2ae51 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -214,6 +214,7 @@ typedef struct VP9Common { FRAME_TYPE frame_type; int show_frame; + int last_show_frame; int frame_flags; int MBs; diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c index 0c2bebf..eaf50ba 100644 --- a/vp9/decoder/vp9_decodemv.c +++ b/vp9/decoder/vp9_decodemv.c @@ -631,7 +631,8 @@ static void read_mb_modes_mv(VP9D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi, const int use_prev_in_find_mv_refs = cm->width == cm->last_width && cm->height == cm->last_height && - !cm->error_resilient_mode; + !cm->error_resilient_mode && + cm->last_show_frame; int mb_to_left_edge, mb_to_right_edge, mb_to_top_edge, mb_to_bottom_edge; diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index 7f95880..3ee0f61 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -1137,10 +1137,12 @@ static void update_frame_size(VP9D_COMP *pbi) { memset(cm->mip, 0, (cm->mb_cols + 1) * (cm->mb_rows + 1) * sizeof(MODE_INFO)); vp9_update_mode_info_border(cm, cm->mip); + vp9_update_mode_info_border(cm, cm->prev_mip); cm->mi = cm->mip + cm->mode_info_stride + 1; cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1; vp9_update_mode_info_in_image(cm, cm->mi); + vp9_update_mode_info_in_image(cm, cm->prev_mi); } static void setup_segmentation(VP9_COMMON *pc, MACROBLOCKD *xd, vp9_reader *r) { diff --git a/vp9/decoder/vp9_onyxd_if.c b/vp9/decoder/vp9_onyxd_if.c index b64b7e4..a07a8fd 100644 --- a/vp9/decoder/vp9_onyxd_if.c +++ b/vp9/decoder/vp9_onyxd_if.c @@ -365,20 +365,23 @@ int vp9_receive_compressed_data(VP9D_PTR ptr, vp9_clear_system_state(); + cm->last_show_frame = cm->show_frame; if (cm->show_frame) { - vpx_memcpy(cm->prev_mip, cm->mip, - (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO)); - } else { - vpx_memset(cm->prev_mip, 0, - (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO)); + // current mip will be the prev_mip for the next frame + MODE_INFO *temp = cm->prev_mip; + cm->prev_mip = cm->mip; + cm->mip = temp; + + // update the upper left visible macroblock ptrs + cm->mi = cm->mip + cm->mode_info_stride + 1; + cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1; + + cm->current_video_frame++; } /*vp9_print_modes_and_motion_vectors(cm->mi, cm->mb_rows,cm->mb_cols, cm->current_video_frame);*/ - if (cm->show_frame) - cm->current_video_frame++; - pbi->ready_for_new_data = 0; pbi->last_time_stamp = time_stamp; pbi->source_sz = 0; -- 2.7.4