From b2be554351244e6e37ee81d1042aba4d550460aa Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Thu, 22 May 2014 13:04:43 -0700 Subject: [PATCH] Cleaning up vp9_init_second_pass(). modified_error_total from TWO_PASS struct is not required anymore. Change-Id: I0e07cac1e6d1b6a78418116be725bcd72bfbd847 --- vp9/encoder/vp9_firstpass.c | 30 ++++++++++++------------------ vp9/encoder/vp9_firstpass.h | 1 - 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index efc20f6b3..a601877a6 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -1003,25 +1003,19 @@ void vp9_init_second_pass(VP9_COMP *cpi) { // Scan the first pass file and calculate a modified total error based upon // the bias/power function used to allocate bits. { - const FIRSTPASS_STATS *const start_pos = twopass->stats_in; - FIRSTPASS_STATS this_frame; - const double av_error = stats->ssim_weighted_pred_err / - DOUBLE_DIVIDE_CHECK(stats->count); - - - twopass->modified_error_total = 0.0; - twopass->modified_error_min = - (av_error * oxcf->two_pass_vbrmin_section) / 100; - twopass->modified_error_max = - (av_error * oxcf->two_pass_vbrmax_section) / 100; - - while (input_stats(twopass, &this_frame) != EOF) { - twopass->modified_error_total += calculate_modified_err(twopass, oxcf, - &this_frame); + const double avg_error = stats->ssim_weighted_pred_err / + DOUBLE_DIVIDE_CHECK(stats->count); + const FIRSTPASS_STATS *s = twopass->stats_in; + double modified_error_total = 0.0; + twopass->modified_error_min = (avg_error * + oxcf->two_pass_vbrmin_section) / 100; + twopass->modified_error_max = (avg_error * + oxcf->two_pass_vbrmax_section) / 100; + while (s < twopass->stats_in_end) { + modified_error_total += calculate_modified_err(twopass, oxcf, s); + ++s; } - twopass->modified_error_left = twopass->modified_error_total; - - reset_fpf_position(twopass, start_pos); + twopass->modified_error_left = modified_error_total; } // Reset the vbr bits off target counter diff --git a/vp9/encoder/vp9_firstpass.h b/vp9/encoder/vp9_firstpass.h index d84793e28..1a61132c6 100644 --- a/vp9/encoder/vp9_firstpass.h +++ b/vp9/encoder/vp9_firstpass.h @@ -51,7 +51,6 @@ typedef struct { int64_t bits_left; double modified_error_min; double modified_error_max; - double modified_error_total; double modified_error_left; double kf_intra_err_min; double gf_intra_err_min; -- 2.40.0