summaryrefslogtreecommitdiff
path: root/vp8/encoder/onyx_if.c
diff options
context:
space:
mode:
authorYunqing Wang <yunqingwang@google.com>2010-12-03 11:26:21 -0500
committerYunqing Wang <yunqingwang@google.com>2010-12-03 15:23:35 -0500
commitc3bbb29164239a48d948a7de2d6d8a1d161a5a0e (patch)
tree56efa6c5177c3454be41cd6de1fcf852833aa5d3 /vp8/encoder/onyx_if.c
parenta5397dbaf13c87516bbf404dea35fe49bfe805e3 (diff)
downloadlibvpx-c3bbb29164239a48d948a7de2d6d8a1d161a5a0e.tar
libvpx-c3bbb29164239a48d948a7de2d6d8a1d161a5a0e.tar.gz
libvpx-c3bbb29164239a48d948a7de2d6d8a1d161a5a0e.tar.bz2
libvpx-c3bbb29164239a48d948a7de2d6d8a1d161a5a0e.zip
Improve MV prediction accuracy to achieve performance gain
Add vp8_mv_pred() to better predict starting MV for NEWMV mode in vp8_rd_pick_inter_mode(). Set different search ranges according to MV prediction accuracy, which improves encoder performance without hurting the quality. Also, as Yaowu suggested, using diamond search result as full search starting point and therefore adjusting(reducing) full search range helps the performance. Change-Id: Ie4a3c8df87e697c1f4f6e2ddb693766bba1b77b6
Diffstat (limited to 'vp8/encoder/onyx_if.c')
-rw-r--r--vp8/encoder/onyx_if.c74
1 files changed, 73 insertions, 1 deletions
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index 5f02a5a02..fd7b5668a 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -283,6 +283,21 @@ static void setup_features(VP8_COMP *cpi)
void vp8_dealloc_compressor_data(VP8_COMP *cpi)
{
+ // Delete last frame MV storage buffers
+ if (cpi->lfmv != 0)
+ vpx_free(cpi->lfmv);
+
+ cpi->lfmv = 0;
+
+ if (cpi->lf_ref_frame_sign_bias != 0)
+ vpx_free(cpi->lf_ref_frame_sign_bias);
+
+ cpi->lf_ref_frame_sign_bias = 0;
+
+ if (cpi->lf_ref_frame != 0)
+ vpx_free(cpi->lf_ref_frame);
+
+ cpi->lf_ref_frame = 0;
// Delete sementation map
if (cpi->segmentation_map != 0)
@@ -2145,7 +2160,10 @@ VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf)
cpi->alt_is_last = 0 ;
cpi->gold_is_alt = 0 ;
-
+ // allocate memory for storing last frame's MVs for MV prediction.
+ CHECK_MEM_ERROR(cpi->lfmv, vpx_calloc((cpi->common.mb_rows+1) * (cpi->common.mb_cols+1), sizeof(int_mv)));
+ CHECK_MEM_ERROR(cpi->lf_ref_frame_sign_bias, vpx_calloc((cpi->common.mb_rows+1) * (cpi->common.mb_cols+1), sizeof(int)));
+ CHECK_MEM_ERROR(cpi->lf_ref_frame, vpx_calloc((cpi->common.mb_rows+1) * (cpi->common.mb_cols+1), sizeof(int)));
// Create the encoder segmentation map and set all entries to 0
CHECK_MEM_ERROR(cpi->segmentation_map, vpx_calloc(cpi->common.mb_rows * cpi->common.mb_cols, 1));
@@ -4165,6 +4183,60 @@ static void encode_frame_to_data_rate
}
#endif
+
+
+
+////////////////////////////////
+////////////////////////////////
+ // This frame's MVs are saved and will be used in next frame's MV prediction.
+ if(cm->show_frame) //do not save for altref frame
+ {
+ int mb_row;
+ int mb_col;
+ MODE_INFO *tmp = cm->mip; //point to beginning of allocated MODE_INFO arrays.
+ //static int last_video_frame = 0;
+
+ /*
+ if (cm->current_video_frame == 0) //first frame: set to 0
+ {
+ for (mb_row = 0; mb_row < cm->mb_rows+1; mb_row ++)
+ {
+ for (mb_col = 0; mb_col < cm->mb_cols+1; mb_col ++)
+ {
+ cpi->lfmv[mb_col + mb_row*(cm->mode_info_stride)].as_int = 0;
+ cpi->lf_ref_frame_sign_bias[mb_col + mb_row*(cm->mode_info_stride)] = 0;
+ cpi->lf_ref_frame[mb_col + mb_row*(cm->mode_info_stride)] = 0;
+ }
+ }
+ }else
+ */
+
+ if(cm->frame_type != KEY_FRAME)
+ {
+ for (mb_row = 0; mb_row < cm->mb_rows+1; mb_row ++)
+ {
+ for (mb_col = 0; mb_col < cm->mb_cols+1; mb_col ++)
+ {
+ if(tmp->mbmi.ref_frame != INTRA_FRAME)
+ cpi->lfmv[mb_col + mb_row*(cm->mode_info_stride)].as_int = tmp->mbmi.mv.as_int;
+
+ cpi->lf_ref_frame_sign_bias[mb_col + mb_row*(cm->mode_info_stride)] = cm->ref_frame_sign_bias[tmp->mbmi.ref_frame];
+ cpi->lf_ref_frame[mb_col + mb_row*(cm->mode_info_stride)] = tmp->mbmi.ref_frame;
+ //printf("[%d, %d] ", cpi->lfmv[mb_col + mb_row*(cm->mode_info_stride-1)].as_mv.row, cpi->lfmv[mb_col + mb_row*(cm->mode_info_stride-1)].as_mv.col);
+ tmp++;
+ }
+ }
+
+ //last_video_frame = cm->current_video_frame;
+ }
+ }
+
+//printf("after: %d %d \n", cm->current_video_frame, cm->show_frame );
+
+
+
+
+
// Update the GF useage maps.
// This is done after completing the compression of a frame when all modes etc. are finalized but before loop filter
vp8_update_gf_useage_maps(cpi, cm, &cpi->mb);