ref: e34e417d9423d42fde6ea682c5849abc55484f9b
parent: 3c9dd6c3ef2ead74641ceb56366b5d034e69c7fd
parent: f3e9e2a0f8d277f3b3c59ded05c0de6fd00a7326
author: John Koleszar <jkoleszar@google.com>
date: Fri Mar 11 01:06:04 EST 2011
Merge "Fix incorrect macroblock counts in twopass rate control"
--- a/vp8/encoder/firstpass.c
+++ b/vp8/encoder/firstpass.c
@@ -841,10 +841,10 @@
extern const int vp8_bits_per_mb[2][QINDEX_RANGE];
#define BASE_ERRPERMB 150
-static int estimate_max_q(VP8_COMP *cpi, double section_err, int section_target_bandwitdh, int Height, int Width)
+static int estimate_max_q(VP8_COMP *cpi, double section_err, int section_target_bandwitdh)
{
int Q;
- int num_mbs = ((Height * Width) / (16 * 16));
+ int num_mbs = cpi->common.MBs;
int target_norm_bits_per_mb;
double err_per_mb = section_err / num_mbs;
@@ -941,10 +941,10 @@
return Q;
}
-static int estimate_q(VP8_COMP *cpi, double section_err, int section_target_bandwitdh, int Height, int Width)
+static int estimate_q(VP8_COMP *cpi, double section_err, int section_target_bandwitdh)
{
int Q;
- int num_mbs = ((Height * Width) / (16 * 16));
+ int num_mbs = cpi->common.MBs;
int target_norm_bits_per_mb;
double err_per_mb = section_err / num_mbs;
@@ -992,10 +992,10 @@
}
// Estimate a worst case Q for a KF group
-static int estimate_kf_group_q(VP8_COMP *cpi, double section_err, int section_target_bandwitdh, int Height, int Width, double group_iiratio)
+static int estimate_kf_group_q(VP8_COMP *cpi, double section_err, int section_target_bandwitdh, double group_iiratio)
{
int Q;
- int num_mbs = ((Height * Width) / (16 * 16));
+ int num_mbs = cpi->common.MBs;
int target_norm_bits_per_mb = (512 * section_target_bandwitdh) / num_mbs;
int bits_per_mb_at_this_q;
@@ -1090,11 +1090,10 @@
// For cq mode estimate a cq level that matches the observed
// complexity and data rate.
-static int estimate_cq(VP8_COMP *cpi, double section_err,
- int section_target_bandwitdh, int Height, int Width)
+static int estimate_cq(VP8_COMP *cpi, double section_err, int section_target_bandwitdh)
{
int Q;
- int num_mbs = ((Height * Width) / (16 * 16));
+ int num_mbs = cpi->common.MBs;
int target_norm_bits_per_mb;
double err_per_mb = section_err / num_mbs;
@@ -1608,7 +1607,7 @@
arf_frame_bits = (int)((double)Boost * (group_bits / (double)allocation_chunks));
// Estimate if there are enough bits available to make worthwhile use of an arf.
- tmp_q = estimate_q(cpi, mod_frame_err, (int)arf_frame_bits, cpi->common.Height, cpi->common.Width);
+ tmp_q = estimate_q(cpi, mod_frame_err, (int)arf_frame_bits);
// Only use an arf if it is likely we will be able to code it at a lower Q than the surrounding frames.
if (tmp_q < cpi->worst_quality)
@@ -2112,8 +2111,7 @@
est_cq =
estimate_cq( cpi,
(cpi->total_coded_error_left / frames_left),
- (int)(cpi->bits_left / frames_left),
- cpi->common.Height, cpi->common.Width);
+ (int)(cpi->bits_left / frames_left));
cpi->cq_target_quality = cpi->oxcf.cq_level;
if ( est_cq > cpi->cq_target_quality )
@@ -2125,9 +2123,7 @@
cpi->maxq_min_limit = cpi->best_quality;
tmp_q = estimate_max_q( cpi,
(cpi->total_coded_error_left / frames_left),
- (int)(cpi->bits_left / frames_left),
- cpi->common.Height,
- cpi->common.Width);
+ (int)(cpi->bits_left / frames_left));
// Limit the maxq value returned subsequently.
// This increases the risk of overspend or underspend if the initial
@@ -2155,7 +2151,7 @@
if (frames_left < 1)
frames_left = 1;
- tmp_q = estimate_max_q(cpi, (cpi->total_coded_error_left / frames_left), (int)(cpi->bits_left / frames_left), cpi->common.Height, cpi->common.Width);
+ tmp_q = estimate_max_q(cpi, (cpi->total_coded_error_left / frames_left), (int)(cpi->bits_left / frames_left));
// Move active_worst_quality but in a damped way
if (tmp_q > cpi->active_worst_quality)
@@ -2764,7 +2760,7 @@
bits_per_frame = (cpi->oxcf.target_bandwidth * cpi->oxcf.two_pass_vbrmin_section / 100);
// Work out if spatial resampling is necessary
- kf_q = estimate_kf_group_q(cpi, err_per_frame, bits_per_frame, new_height, new_width, group_iiratio);
+ kf_q = estimate_kf_group_q(cpi, err_per_frame, bits_per_frame, group_iiratio);
// If we project a required Q higher than the maximum allowed Q then make a guess at the actual size of frames in this section
projected_bits_perframe = bits_per_frame;
@@ -2835,7 +2831,7 @@
effective_size_ratio = (1.0 + (3.0 * effective_size_ratio)) / 4.0;
// Now try again and see what Q we get with the smaller image size
- kf_q = estimate_kf_group_q(cpi, err_per_frame * effective_size_ratio, bits_per_frame, new_height, new_width, group_iiratio);
+ kf_q = estimate_kf_group_q(cpi, err_per_frame * effective_size_ratio, bits_per_frame, group_iiratio);
if (0)
{
--
⑨