Merge "Avoid multiple test for same lvl in auto filter lvl pick"

This commit is contained in:
John Koleszar 2011-12-14 16:28:13 -08:00 committed by Gerrit Code Review
commit 72f459c77f

View File

@ -289,8 +289,12 @@ void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
int Bias = 0; // Bias against raising loop filter and in favor of lowering it int Bias = 0; // Bias against raising loop filter and in favor of lowering it
int ss_err[MAX_LOOP_FILTER];
YV12_BUFFER_CONFIG * saved_frame = cm->frame_to_show; YV12_BUFFER_CONFIG * saved_frame = cm->frame_to_show;
vpx_memset(ss_err, 0, sizeof(ss_err));
/* Replace unfiltered frame buffer with a new one */ /* Replace unfiltered frame buffer with a new one */
cm->frame_to_show = &cpi->pick_lf_lvl_frame; cm->frame_to_show = &cpi->pick_lf_lvl_frame;
@ -320,6 +324,9 @@ void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
best_err = vp8_calc_ss_err(sd, cm->frame_to_show, best_err = vp8_calc_ss_err(sd, cm->frame_to_show,
IF_RTCD(&cpi->rtcd.variance)); IF_RTCD(&cpi->rtcd.variance));
ss_err[filt_mid] = best_err;
filt_best = filt_mid; filt_best = filt_mid;
while (filter_step > 0) while (filter_step > 0)
@ -334,6 +341,8 @@ void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
filt_low = ((filt_mid - filter_step) < min_filter_level) ? min_filter_level : (filt_mid - filter_step); filt_low = ((filt_mid - filter_step) < min_filter_level) ? min_filter_level : (filt_mid - filter_step);
if ((filt_direction <= 0) && (filt_low != filt_mid)) if ((filt_direction <= 0) && (filt_low != filt_mid))
{
if(ss_err[filt_low] == 0)
{ {
// Get Low filter error score // Get Low filter error score
vp8_yv12_copy_y_ptr(saved_frame, cm->frame_to_show); vp8_yv12_copy_y_ptr(saved_frame, cm->frame_to_show);
@ -342,6 +351,10 @@ void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, filt_err = vp8_calc_ss_err(sd, cm->frame_to_show,
IF_RTCD(&cpi->rtcd.variance)); IF_RTCD(&cpi->rtcd.variance));
ss_err[filt_low] = filt_err;
}
else
filt_err = ss_err[filt_low];
// If value is close to the best so far then bias towards a lower loop filter value. // If value is close to the best so far then bias towards a lower loop filter value.
if ((filt_err - Bias) < best_err) if ((filt_err - Bias) < best_err)
@ -356,6 +369,8 @@ void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
// Now look at filt_high // Now look at filt_high
if ((filt_direction >= 0) && (filt_high != filt_mid)) if ((filt_direction >= 0) && (filt_high != filt_mid))
{
if(ss_err[filt_high] == 0)
{ {
vp8_yv12_copy_y_ptr(saved_frame, cm->frame_to_show); vp8_yv12_copy_y_ptr(saved_frame, cm->frame_to_show);
vp8cx_set_alt_lf_level(cpi, filt_high); vp8cx_set_alt_lf_level(cpi, filt_high);
@ -363,6 +378,10 @@ void vp8cx_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP8_COMP *cpi)
filt_err = vp8_calc_ss_err(sd, cm->frame_to_show, filt_err = vp8_calc_ss_err(sd, cm->frame_to_show,
IF_RTCD(&cpi->rtcd.variance)); IF_RTCD(&cpi->rtcd.variance));
ss_err[filt_high] = filt_err;
}
else
filt_err = ss_err[filt_high];
// Was it better than the previous best? // Was it better than the previous best?
if (filt_err < (best_err - Bias)) if (filt_err < (best_err - Bias))