From 0618ff14d6eeca27d6cca6b3999e4cd10fe7b096 Mon Sep 17 00:00:00 2001 From: Adrian Grange Date: Thu, 1 Jul 2010 14:17:04 +0100 Subject: [PATCH] Fix bug in 1st pass motion compensation In the case where the best reference mv is not (0,0) a secondary search is carried out centered on (0,0). However, rather than sending tmp_err into the search function, motion_error was inadvertently passed. As a result tmp_err remains set at INT_MAX and the (0,0)-based search result will never be selected, even if it is better. Change-Id: I3c82b246c8c82ba887b9d3fb4c9e0a0f2fe5a76c --- vp8/encoder/firstpass.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vp8/encoder/firstpass.c b/vp8/encoder/firstpass.c index 74feca314..0a33feb1c 100644 --- a/vp8/encoder/firstpass.c +++ b/vp8/encoder/firstpass.c @@ -639,14 +639,18 @@ void vp8_first_pass(VP8_COMP *cpi) d->bmi.mv.as_mv.row = 0; d->bmi.mv.as_mv.col = 0; - // Test last reference frame using the previous best mv as the starting point (best reference) for the search - vp8_first_pass_motion_search(cpi, x, &best_ref_mv, &d->bmi.mv.as_mv, &cm->last_frame, &motion_error, recon_yoffset); + // Test last reference frame using the previous best mv as the + // starting point (best reference) for the search + vp8_first_pass_motion_search(cpi, x, &best_ref_mv, + &d->bmi.mv.as_mv, &cm->last_frame, + &motion_error, recon_yoffset); // If the current best reference mv is not centred on 0,0 then do a 0,0 based search as well if ((best_ref_mv.col != 0) || (best_ref_mv.row != 0)) { tmp_err = INT_MAX; - vp8_first_pass_motion_search(cpi, x, &zero_ref_mv, &tmp_mv, &cm->last_frame, &motion_error, recon_yoffset); + vp8_first_pass_motion_search(cpi, x, &zero_ref_mv, &tmp_mv, + &cm->last_frame, &tmp_err, recon_yoffset); if ( tmp_err < motion_error ) { -- 2.40.0