From f2a6bcfb18c9fc6c92ae26b00e502fb25b98bf68 Mon Sep 17 00:00:00 2001 From: Scott LaVarnway Date: Thu, 11 Jul 2013 10:47:28 -0400 Subject: [PATCH] Eliminated prev_mip memsets/memcpys in encoder This patch is in experimental but was not merged into master. This patch swaps ptrs instead of copying and uses the last show_frame flag instead of setting the entire buffer to zero. Change-Id: Ia0950466c8ba301a2a5bf917ff3d07bc1a2c2311 --- vp9/encoder/vp9_onyx_if.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index 67d0c4c76..63b00f5a2 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -3416,15 +3416,24 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, cm->last_width = cm->width; cm->last_height = cm->height; - // Don't increment frame counters if this was an altref buffer - // update not a real frame + // reset to normal state now that we are done. cm->last_show_frame = cm->show_frame; if (cm->show_frame) { + // 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; + + // Don't increment frame counters if this was an altref buffer + // update not a real frame ++cm->current_video_frame; ++cpi->frames_since_key; } - - // reset to normal state now that we are done. + // restore prev_mi + cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1; #if 0 { @@ -3442,17 +3451,6 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, vp9_write_yuv_rec_frame(cm); #endif - if (cm->show_frame) { - vpx_memcpy(cm->prev_mip, cm->mip, - cm->mode_info_stride * (cm->mi_rows + MI_BLOCK_SIZE) * - sizeof(MODE_INFO)); - } else { - vpx_memset(cm->prev_mip, 0, - cm->mode_info_stride * (cm->mi_rows + MI_BLOCK_SIZE) * - sizeof(MODE_INFO)); - } - // restore prev_mi - cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1; } static void Pass2Encode(VP9_COMP *cpi, unsigned long *size,