summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorDeepa K G <deepa.kg@ittiam.com>2019-05-27 18:02:00 +0530
committerDeepa K G <deepa.kg@ittiam.com>2019-05-27 18:02:00 +0530
commite3a061200eb7b96b3e568ecdc51ebfd5dbdebab7 (patch)
treeb2a01e6d58a3c52061b508ef3a7a58c5be177295 /vp9
parent14cc2c4709c37b4fde40b1d978f6081e5d7f4f09 (diff)
downloadlibvpx-e3a061200eb7b96b3e568ecdc51ebfd5dbdebab7.tar
libvpx-e3a061200eb7b96b3e568ecdc51ebfd5dbdebab7.tar.gz
libvpx-e3a061200eb7b96b3e568ecdc51ebfd5dbdebab7.tar.bz2
libvpx-e3a061200eb7b96b3e568ecdc51ebfd5dbdebab7.zip
Fix calculations in GF only group case
- Fix the number of frames considered in calculation of twopass active worst quality. For GF only group, frames considered should be one less than baseline gf interval accounting for the golden frame. - Fix in calculation of normal_frames. As baseline gf interval includes the golden frame, the number of normal frames should be one less than baseline gf interval. Change-Id: Ic752f7d13d23772687e2fa407698766b3fdf5c67
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_firstpass.c44
1 files changed, 27 insertions, 17 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 665b4c36e..4f38a6611 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2048,10 +2048,15 @@ static int calculate_section_intra_ratio(const FIRSTPASS_STATS *begin,
// Calculate the total bits to allocate in this GF/ARF group.
static int64_t calculate_total_gf_group_bits(VP9_COMP *cpi,
double gf_group_err) {
+ VP9_COMMON *const cm = &cpi->common;
const RATE_CONTROL *const rc = &cpi->rc;
const TWO_PASS *const twopass = &cpi->twopass;
const int max_bits = frame_max_bits(rc, &cpi->oxcf);
int64_t total_group_bits;
+ const int is_key_frame = frame_is_intra_only(cm);
+ const int arf_active_or_kf = is_key_frame || rc->source_alt_ref_active;
+ int gop_frames =
+ rc->baseline_gf_interval + rc->source_alt_ref_pending - arf_active_or_kf;
// Calculate the bits to be allocated to the group as a whole.
if ((twopass->kf_group_bits > 0) && (twopass->kf_group_error_left > 0.0)) {
@@ -2069,8 +2074,8 @@ static int64_t calculate_total_gf_group_bits(VP9_COMP *cpi,
: total_group_bits;
// Clip based on user supplied data rate variability limit.
- if (total_group_bits > (int64_t)max_bits * rc->baseline_gf_interval)
- total_group_bits = (int64_t)max_bits * rc->baseline_gf_interval;
+ if (total_group_bits > (int64_t)max_bits * gop_frames)
+ total_group_bits = (int64_t)max_bits * gop_frames;
return total_group_bits;
}
@@ -2290,7 +2295,7 @@ static void allocate_gf_group_bits(VP9_COMP *cpi, int64_t gf_group_bits,
// Define middle frame
mid_frame_idx = frame_index + (rc->baseline_gf_interval >> 1) - 1;
- normal_frames = (rc->baseline_gf_interval - rc->source_alt_ref_pending);
+ normal_frames = (rc->baseline_gf_interval - 1);
if (normal_frames > 1)
normal_frame_bits = (int)(total_group_bits / normal_frames);
else
@@ -2452,6 +2457,7 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
const int arf_active_or_kf = is_key_frame || rc->source_alt_ref_active;
double gop_intra_factor = 1.0;
+ int gop_frames;
// Reset the GF group data structures unless this is a key
// frame in which case it will already have been done.
@@ -2664,9 +2670,16 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// Calculate the bits to be allocated to the gf/arf group as a whole
gf_group_bits = calculate_total_gf_group_bits(cpi, gf_group_err);
+ gop_frames =
+ rc->baseline_gf_interval + rc->source_alt_ref_pending - arf_active_or_kf;
+
// Store the average moise level measured for the group
- twopass->gf_group.group_noise_energy =
- (int)(gf_group_noise / rc->baseline_gf_interval);
+ // TODO(any): Experiment with removal of else condition (gop_frames = 0) so
+ // that consumption of group noise energy is based on previous gf group
+ if (gop_frames > 0)
+ twopass->gf_group.group_noise_energy = (int)(gf_group_noise / gop_frames);
+ else
+ twopass->gf_group.group_noise_energy = 0;
// Calculate an estimate of the maxq needed for the group.
// We are more aggressive about correcting for sections
@@ -2674,15 +2687,12 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// sections where we do not wish to risk creating an overshoot
// of the allocated bit budget.
if ((cpi->oxcf.rc_mode != VPX_Q) && (rc->baseline_gf_interval > 1)) {
- const int vbr_group_bits_per_frame =
- (int)(gf_group_bits / rc->baseline_gf_interval);
- const double group_av_err = gf_group_raw_error / rc->baseline_gf_interval;
- const double group_av_noise = gf_group_noise / rc->baseline_gf_interval;
- const double group_av_skip_pct =
- gf_group_skip_pct / rc->baseline_gf_interval;
- const double group_av_inactive_zone =
- ((gf_group_inactive_zone_rows * 2) /
- (rc->baseline_gf_interval * (double)cm->mb_rows));
+ const int vbr_group_bits_per_frame = (int)(gf_group_bits / gop_frames);
+ const double group_av_err = gf_group_raw_error / gop_frames;
+ const double group_av_noise = gf_group_noise / gop_frames;
+ const double group_av_skip_pct = gf_group_skip_pct / gop_frames;
+ const double group_av_inactive_zone = ((gf_group_inactive_zone_rows * 2) /
+ (gop_frames * (double)cm->mb_rows));
int tmp_q = get_twopass_worst_quality(
cpi, group_av_err, (group_av_skip_pct + group_av_inactive_zone),
group_av_noise, vbr_group_bits_per_frame);
@@ -2698,9 +2708,9 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// Context Adjustment of ARNR filter strength
if (rc->baseline_gf_interval > 1) {
- adjust_group_arnr_filter(cpi, (gf_group_noise / rc->baseline_gf_interval),
- (gf_group_inter / rc->baseline_gf_interval),
- (gf_group_motion / rc->baseline_gf_interval));
+ adjust_group_arnr_filter(cpi, (gf_group_noise / gop_frames),
+ (gf_group_inter / gop_frames),
+ (gf_group_motion / gop_frames));
} else {
twopass->arnr_strength_adjustment = 0;
}