summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorDebargha Mukherjee <debargha@google.com>2015-07-10 09:49:17 -0700
committerpaulwilkins <paulwilkins@google.com>2015-07-14 18:32:38 +0100
commit3c5244886a804c8c05898ca8d78c3356f6c40507 (patch)
treefa92079c19a89123d97dd6d567b07e285aa1762a /vp9
parentcda17e12ed6483359d126b0fee3013774443d3df (diff)
downloadlibvpx-3c5244886a804c8c05898ca8d78c3356f6c40507.tar
libvpx-3c5244886a804c8c05898ca8d78c3356f6c40507.tar.gz
libvpx-3c5244886a804c8c05898ca8d78c3356f6c40507.tar.bz2
libvpx-3c5244886a804c8c05898ca8d78c3356f6c40507.zip
Fixes part of merge regression from adding arf parameters.
From Change Ibf0c30b72074b3f71918ab278ccccc02a95a70a0 There is still an issue relating to one animated test clip with repeat patterns where this change effectively increase the default maximum arf interval by +1. This can be examined seperately. Change-Id: Idd01d5480fc45202d8a059a0c3afc0997cc5bdd1
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_firstpass.c17
-rw-r--r--vp9/encoder/vp9_ratectrl.c9
-rw-r--r--vp9/vp9_cx_iface.c5
3 files changed, 17 insertions, 14 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 61279f872..5caf2cbd8 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -1883,7 +1883,7 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
double gf_group_error_left;
int gf_arf_bits;
const int is_key_frame = frame_is_intra_only(cm);
- const int kf_or_arf_active = is_key_frame || rc->source_alt_ref_active;
+ const int arf_active_or_kf = is_key_frame || rc->source_alt_ref_active;
// Reset the GF group data structures unless this is a key
// frame in which case it will already have been done.
@@ -1903,7 +1903,7 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// If this is a key frame or the overlay from a previous arf then
// the error score / cost of this frame has already been accounted for.
- if (is_key_frame || rc->source_alt_ref_active) {
+ if (arf_active_or_kf) {
gf_group_err -= gf_first_frame_err;
#if GROUP_ADAPTIVE_MAXQ
gf_group_raw_error -= this_frame->coded_error;
@@ -1936,7 +1936,7 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// bits to spare and are better with a smaller interval and smaller boost.
// At high Q when there are few bits to spare we are better with a longer
// interval to spread the cost of the GF.
- active_max_gf_interval = rc->max_gf_interval - 4 + MIN(4, (int_lbq / 6));
+ active_max_gf_interval = 12 + MIN(4, (int_lbq / 6));
if (active_max_gf_interval < active_min_gf_interval)
active_max_gf_interval = active_min_gf_interval;
@@ -2001,11 +2001,11 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// Break out conditions.
if (
// Break at active_max_gf_interval unless almost totally static.
- ((i >= active_max_gf_interval + kf_or_arf_active) &&
- (zero_motion_accumulator < 0.995)) ||
+ (i >= (active_max_gf_interval + arf_active_or_kf) &&
+ zero_motion_accumulator < 0.995) ||
(
// Don't break out with a very short interval.
- (i >= active_min_gf_interval + kf_or_arf_active) &&
+ (i >= active_min_gf_interval + arf_active_or_kf) &&
(!flash_detected) &&
((mv_ratio_accumulator > mv_ratio_accumulator_thresh) ||
(abs_mv_in_out_accumulator > 3.0) ||
@@ -2043,10 +2043,7 @@ static void define_gf_group(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
}
// Set the interval until the next gf.
- if (is_key_frame || rc->source_alt_ref_pending)
- rc->baseline_gf_interval = i - 1;
- else
- rc->baseline_gf_interval = i;
+ rc->baseline_gf_interval = i - (is_key_frame || rc->source_alt_ref_pending);
// Only encode alt reference frame in temporal base layer. So
// baseline_gf_interval should be multiple of a temporal layer group
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index be09bca0c..926afe1c5 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -281,11 +281,14 @@ int vp9_rc_get_default_min_gf_interval(
// Assume we do not need any constraint lower than 4K 20 fps
static const double factor_safe = 3840 * 2160 * 20.0;
const double factor = width * height * framerate;
+ const double default_interval =
+ MIN(MAX_GF_INTERVAL, MAX(MIN_GF_INTERVAL, (int)(framerate * 0.125)));
if (factor <= factor_safe)
- return MIN_GF_INTERVAL;
+ return (int)default_interval;
else
- return (int)(MIN_GF_INTERVAL * factor / factor_safe + 0.5);
+ return (int)MAX(default_interval,
+ (int)(MIN_GF_INTERVAL * factor / factor_safe + 0.5));
// Note this logic makes:
// 4K24: 5
// 4K30: 6
@@ -294,6 +297,7 @@ int vp9_rc_get_default_min_gf_interval(
int vp9_rc_get_default_max_gf_interval(double framerate, int min_gf_interval) {
int interval = MIN(MAX_GF_INTERVAL, (int)(framerate * 0.75));
+ interval += (interval & 0x01); // Round to even value
return MAX(interval, min_gf_interval);
}
@@ -1693,7 +1697,6 @@ void vp9_rc_set_gf_interval_range(const VP9_COMP *const cpi,
if (rc->max_gf_interval == 0)
rc->max_gf_interval = vp9_rc_get_default_max_gf_interval(
cpi->framerate, rc->min_gf_interval);
- rc->max_gf_interval += (rc->max_gf_interval & 0x01);
// Extended interval for genuinely static scenes
rc->static_scene_max_gf_interval = MAX_LAG_BUFFERS * 2;
diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c
index d2d9288ee..f155b9aef 100644
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -173,9 +173,12 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx,
RANGE_CHECK(cfg, g_pass, VPX_RC_ONE_PASS, VPX_RC_LAST_PASS);
RANGE_CHECK(extra_cfg, min_gf_interval, 0, (MAX_LAG_BUFFERS - 1));
RANGE_CHECK(extra_cfg, max_gf_interval, 0, (MAX_LAG_BUFFERS - 1));
+ if (extra_cfg->max_gf_interval > 0) {
+ RANGE_CHECK(extra_cfg, max_gf_interval, 2, (MAX_LAG_BUFFERS - 1));
+ }
if (extra_cfg->min_gf_interval > 0 && extra_cfg->max_gf_interval > 0) {
RANGE_CHECK(extra_cfg, max_gf_interval, extra_cfg->min_gf_interval,
- (MAX_LAG_BUFFERS - 1));
+ (MAX_LAG_BUFFERS - 1));
}
if (cfg->rc_resize_allowed == 1) {