Merge changes I412c24aa,I28a8bbf0 * changes: mcomp: Remove an obsolete undef. mcomp: Remove an obsolete comment.
diff --git a/vp10/encoder/encoder.c b/vp10/encoder/encoder.c index 31a9390..e7fff82 100644 --- a/vp10/encoder/encoder.c +++ b/vp10/encoder/encoder.c
@@ -1858,6 +1858,8 @@ const double dr = (double)cpi->bytes * (double) 8 / (double)1000 / time_encoded; const double peak = (double)((1 << cpi->oxcf.input_bit_depth) - 1); + const double target_rate = (double)cpi->oxcf.target_bandwidth / 1000; + const double rate_err = ((100.0 * (dr - target_rate)) / target_rate); if (cpi->b_calculate_psnr) { const double total_psnr = @@ -1909,8 +1911,9 @@ SNPRINT2(results, "\t%7.3f", cpi->ssimg.worst); } - fprintf(f, "%s\t Time\n", headings); - fprintf(f, "%s\t%8.0f\n", results, total_encode_time); + fprintf(f, "%s\t Time Rc-Err Abs Err\n", headings); + fprintf(f, "%s\t%8.0f %7.2f %7.2f\n", results, + total_encode_time, rate_err, fabs(rate_err)); } fclose(f);
diff --git a/vp10/encoder/firstpass.c b/vp10/encoder/firstpass.c index bc1ce00..7c5d3c0 100644 --- a/vp10/encoder/firstpass.c +++ b/vp10/encoder/firstpass.c
@@ -45,7 +45,6 @@ #define BOOST_BREAKOUT 12.5 #define BOOST_FACTOR 12.5 -#define ERR_DIVISOR 128.0 #define FACTOR_PT_LOW 0.70 #define FACTOR_PT_HIGH 0.90 #define FIRST_PASS_Q 10.0 @@ -231,6 +230,13 @@ section->duration -= frame->duration; } +// Calculate the linear size relative to a baseline of 1080P +#define BASE_SIZE 2073600.0 // 1920x1080 +static double get_linear_size_factor(const VP10_COMP *cpi) { + const double this_area = cpi->initial_width * cpi->initial_height; + return pow(this_area / BASE_SIZE, 0.5); +} + // Calculate an active area of the image that discounts formatting // bars and partially discounts other 0 energy areas. #define MIN_ACTIVE_AREA 0.5 @@ -1103,11 +1109,7 @@ return fclamp(pow(error_term, power_term), 0.05, 5.0); } -// Larger image formats are expected to be a little harder to code relatively -// given the same prediction error score. This in part at least relates to the -// increased size and hence coding cost of motion vectors. -#define EDIV_SIZE_FACTOR 800 - +#define ERR_DIVISOR 100.0 static int get_twopass_worst_quality(const VP10_COMP *cpi, const double section_err, double inactive_zone, @@ -1126,12 +1128,22 @@ const int active_mbs = VPXMAX(1, num_mbs - (int)(num_mbs * inactive_zone)); const double av_err_per_mb = section_err / active_mbs; const double speed_term = 1.0 + 0.04 * oxcf->speed; - const double ediv_size_correction = (double)num_mbs / EDIV_SIZE_FACTOR; + double ediv_size_correction; const int target_norm_bits_per_mb = ((uint64_t)section_target_bandwidth << BPER_MB_NORMBITS) / active_mbs; - int q; + // Larger image formats are expected to be a little harder to code + // relatively given the same prediction error score. This in part at + // least relates to the increased size and hence coding overheads of + // motion vectors. Some account of this is made through adjustment of + // the error divisor. + ediv_size_correction = + VPXMAX(0.2, VPXMIN(5.0, get_linear_size_factor(cpi))); + if (ediv_size_correction < 1.0) + ediv_size_correction = -(1.0 / ediv_size_correction); + ediv_size_correction *= 4.0; + // Try and pick a max Q that will be high enough to encode the // content at the given rate. for (q = rc->best_quality; q < rc->worst_quality; ++q) {
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index 88c191e..6617422 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c
@@ -2257,6 +2257,8 @@ double total_encode_time = (cpi->time_receive_data + cpi->time_compress_data) / 1000.000; double dr = (double)cpi->bytes * 8.0 / 1000.0 / time_encoded; + const double target_rate = (double)cpi->oxcf.target_bandwidth / 1000; + const double rate_err = ((100.0 * (dr - target_rate)) / target_rate); if (cpi->b_calculate_psnr) { @@ -2302,12 +2304,14 @@ cpi->summed_weights, 8.0); fprintf(f, "Bitrate\tAVGPsnr\tGLBPsnr\tAVPsnrP\t" - "GLPsnrP\tVPXSSIM\t Time(us)\n"); + "GLPsnrP\tVPXSSIM\t Time(us) Rc-Err " + "Abs Err\n"); fprintf(f, "%7.3f\t%7.3f\t%7.3f\t%7.3f\t%7.3f\t" - "%7.3f\t%8.0f\n", + "%7.3f\t%8.0f %7.2f %7.2f\n", dr, cpi->total / cpi->count, total_psnr, cpi->totalp / cpi->count, total_psnr2, - total_ssim, total_encode_time); + total_ssim, total_encode_time, + rate_err, fabs(rate_err)); } }
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index ff6e62a..8201794 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c
@@ -2026,6 +2026,8 @@ const double dr = (double)cpi->bytes * (double) 8 / (double)1000 / time_encoded; const double peak = (double)((1 << cpi->oxcf.input_bit_depth) - 1); + const double target_rate = (double)cpi->oxcf.target_bandwidth / 1000; + const double rate_err = ((100.0 * (dr - target_rate)) / target_rate); if (cpi->b_calculate_psnr) { const double total_psnr = @@ -2077,8 +2079,9 @@ SNPRINT2(results, "\t%7.3f", cpi->ssimg.worst); } - fprintf(f, "%s\t Time\n", headings); - fprintf(f, "%s\t%8.0f\n", results, total_encode_time); + fprintf(f, "%s\t Time Rc-Err Abs Err\n", headings); + fprintf(f, "%s\t%8.0f %7.2f %7.2f\n", results, + total_encode_time, rate_err, fabs(rate_err)); } fclose(f);
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index 14ddaa2..f456f37 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c
@@ -45,7 +45,6 @@ #define BOOST_BREAKOUT 12.5 #define BOOST_FACTOR 12.5 -#define ERR_DIVISOR 128.0 #define FACTOR_PT_LOW 0.70 #define FACTOR_PT_HIGH 0.90 #define FIRST_PASS_Q 10.0 @@ -237,6 +236,13 @@ section->duration -= frame->duration; } +// Calculate the linear size relative to a baseline of 1080P +#define BASE_SIZE 2073600.0 // 1920x1080 +static double get_linear_size_factor(const VP9_COMP *cpi) { + const double this_area = cpi->initial_width * cpi->initial_height; + return pow(this_area / BASE_SIZE, 0.5); +} + // Calculate an active area of the image that discounts formatting // bars and partially discounts other 0 energy areas. #define MIN_ACTIVE_AREA 0.5 @@ -1241,11 +1247,7 @@ return fclamp(pow(error_term, power_term), 0.05, 5.0); } -// Larger image formats are expected to be a little harder to code relatively -// given the same prediction error score. This in part at least relates to the -// increased size and hence coding cost of motion vectors. -#define EDIV_SIZE_FACTOR 800 - +#define ERR_DIVISOR 100.0 static int get_twopass_worst_quality(const VP9_COMP *cpi, const double section_err, double inactive_zone, @@ -1267,16 +1269,25 @@ const int active_mbs = VPXMAX(1, num_mbs - (int)(num_mbs * inactive_zone)); const double av_err_per_mb = section_err / active_mbs; const double speed_term = 1.0 + 0.04 * oxcf->speed; - const double ediv_size_correction = (double)num_mbs / EDIV_SIZE_FACTOR; + double ediv_size_correction; const int target_norm_bits_per_mb = ((uint64_t)target_rate << BPER_MB_NORMBITS) / active_mbs; - int q; int is_svc_upper_layer = 0; if (is_two_pass_svc(cpi) && cpi->svc.spatial_layer_id > 0) is_svc_upper_layer = 1; + // Larger image formats are expected to be a little harder to code + // relatively given the same prediction error score. This in part at + // least relates to the increased size and hence coding overheads of + // motion vectors. Some account of this is made through adjustment of + // the error divisor. + ediv_size_correction = + VPXMAX(0.2, VPXMIN(5.0, get_linear_size_factor(cpi))); + if (ediv_size_correction < 1.0) + ediv_size_correction = -(1.0 / ediv_size_correction); + ediv_size_correction *= 4.0; // Try and pick a max Q that will be high enough to encode the // content at the given rate.