ref: 1541211f7e63da60005dd56cba3bb3ea47277649
parent: f95f687e22e711c5fb53cad3d4a86a1428b1dcc5
parent: b0509e8868a2fb1d64ea015cd9bbf125fd3ddcaa
author: Jingning Han <[email protected]>
date: Fri May 24 12:35:27 EDT 2019
Merge "Increase active best quality linearly"
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2648,6 +2648,17 @@
rc->source_alt_ref_pending = 0;
}
+#define LAST_ALR_ACTIVE_BEST_QUALITY_ADJUSTMENT_FACTOR 0.2
+ rc->arf_active_best_quality_adjustment_factor = 1.0;
+ if (rc->source_alt_ref_pending && !is_lossless_requested(&cpi->oxcf) &&
+ rc->frames_to_key <= rc->arf_active_best_quality_adjustment_window) {
+ rc->arf_active_best_quality_adjustment_factor =
+ LAST_ALR_ACTIVE_BEST_QUALITY_ADJUSTMENT_FACTOR +
+ (1.0 - LAST_ALR_ACTIVE_BEST_QUALITY_ADJUSTMENT_FACTOR) *
+ (rc->frames_to_key - i) /
+ VPXMAX(1, (rc->arf_active_best_quality_adjustment_window - i));
+ }
+
#ifdef AGGRESSIVE_VBR
// Limit maximum boost based on interval length.
rc->gfu_boost = VPXMIN((int)rc->gfu_boost, i * 140);
@@ -3195,6 +3206,11 @@
// Default to normal-sized frame on keyframes.
cpi->rc.next_frame_size_selector = UNSCALED;
}
+#define ARF_ACTIVE_BEST_QUALITY_ADJUSTMENT_WINDOW_SIZE 64
+ // TODO([email protected]): Experiment without the below min
+ // condition. This might be helpful for small key frame intervals.
+ rc->arf_active_best_quality_adjustment_window =
+ VPXMIN(ARF_ACTIVE_BEST_QUALITY_ADJUSTMENT_WINDOW_SIZE, rc->frames_to_key);
}
static int is_skippable_frame(const VP9_COMP *cpi) {
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -435,6 +435,7 @@
rc->last_post_encode_dropped_scene_change = 0;
rc->use_post_encode_drop = 0;
rc->ext_use_post_encode_drop = 0;
+ rc->arf_active_best_quality_adjustment_factor = 1.0;
}
static int check_buffer_above_thresh(VP9_COMP *cpi, int drop_mark) {
@@ -1415,6 +1416,8 @@
int active_worst_quality = cpi->twopass.active_worst_quality;
int q;
int *inter_minq;
+ int arf_active_best_quality_adjustment, arf_active_best_quality_max;
+ int *arfgf_high_motion_minq;
const int boost_frame =
!rc->is_src_frame_alt_ref &&
(cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame);
@@ -1441,6 +1444,14 @@
if (q < cq_level) q = cq_level;
}
active_best_quality = get_gf_active_quality(cpi, q, cm->bit_depth);
+
+ ASSIGN_MINQ_TABLE(cm->bit_depth, arfgf_high_motion_minq);
+ arf_active_best_quality_max = arfgf_high_motion_minq[q];
+ arf_active_best_quality_adjustment =
+ arf_active_best_quality_max - active_best_quality;
+ active_best_quality = arf_active_best_quality_max -
+ (int)(arf_active_best_quality_adjustment *
+ rc->arf_active_best_quality_adjustment_factor);
// Modify best quality for second level arfs. For mode VPX_Q this
// becomes the baseline frame q.
--- a/vp9/encoder/vp9_ratectrl.h
+++ b/vp9/encoder/vp9_ratectrl.h
@@ -197,6 +197,8 @@
int ext_use_post_encode_drop;
int damped_adjustment[RATE_FACTOR_LEVELS];
+ double arf_active_best_quality_adjustment_factor;
+ int arf_active_best_quality_adjustment_window;
} RATE_CONTROL;
struct VP9_COMP;