ref: b3bf91bdc60220c004a22d21c867cc392e684b81
parent: ff9395eb3bfd215e75f9759a055d505db5d6cf09
parent: 2adc0443dd3701d0236a44e9e0670b50c15d30a2
author: Marco Paniconi <marpan@google.com>
date: Mon May 22 02:27:30 EDT 2017
Merge "vp9: Adjustments to cyclic refresh for high motion."
--- a/vp9/encoder/vp9_aq_cyclicrefresh.c
+++ b/vp9/encoder/vp9_aq_cyclicrefresh.c
@@ -277,8 +277,6 @@
!cpi->oxcf.gf_cbr_boost_pct) {
// Force this frame as a golden update frame if this frame changes the
// resolution (resize_pending != 0).
- // TODO(marpan): check on forcing golden update if the background has very
- // high motion in current frame.
if (cpi->resize_pending != 0) {
vp9_cyclic_refresh_set_golden_update(cpi);
rc->frames_till_gf_update_due = rc->baseline_gf_interval;
@@ -316,6 +314,8 @@
else
rc->baseline_gf_interval = 40;
if (cpi->oxcf.rc_mode == VPX_VBR) rc->baseline_gf_interval = 20;
+ if (rc->avg_frame_low_motion < 50 && rc->frames_since_key > 40)
+ rc->baseline_gf_interval = 10;
}
// Update the segmentation map, and related quantities: cyclic refresh map,
@@ -425,6 +425,13 @@
int target_refresh = 0;
double weight_segment_target = 0;
double weight_segment = 0;
+ cr->apply_cyclic_refresh = 1;
+ if (cm->frame_type == KEY_FRAME || cpi->svc.temporal_layer_id > 0 ||
+ (!cpi->use_svc && rc->avg_frame_low_motion < 55 &&
+ rc->frames_since_key > 40)) {
+ cr->apply_cyclic_refresh = 0;
+ return;
+ }
cr->percent_refresh = 10;
if (cr->reduce_refresh) cr->percent_refresh = 5;
cr->max_qdelta_perc = 60;
@@ -493,14 +500,8 @@
const RATE_CONTROL *const rc = &cpi->rc;
CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
struct segmentation *const seg = &cm->seg;
- // TODO(marpan): Look into whether we should reduce the amount/delta-qp
- // instead of completely shutting off at low bitrates. For now keep it on.
- // const int apply_cyclic_refresh = apply_cyclic_refresh_bitrate(cm, rc);
- const int apply_cyclic_refresh = 1;
if (cm->current_video_frame == 0) cr->low_content_avg = 0.0;
- // Don't apply refresh on key frame or temporal enhancement layer frames.
- if (!apply_cyclic_refresh || (cm->frame_type == KEY_FRAME) ||
- (cpi->force_update_segmentation) || (cpi->svc.temporal_layer_id > 0)) {
+ if (!cr->apply_cyclic_refresh || (cpi->force_update_segmentation)) {
// Set segmentation map to 0 and disable.
unsigned char *const seg_map = cpi->segmentation_map;
memset(seg_map, 0, cm->mi_rows * cm->mi_cols);
--- a/vp9/encoder/vp9_aq_cyclicrefresh.h
+++ b/vp9/encoder/vp9_aq_cyclicrefresh.h
@@ -67,6 +67,7 @@
int qindex_delta[3];
int reduce_refresh;
double weight_segment;
+ int apply_cyclic_refresh;
};
struct VP9_COMP;
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -547,6 +547,7 @@
int vp9_rc_regulate_q(const VP9_COMP *cpi, int target_bits_per_frame,
int active_best_quality, int active_worst_quality) {
const VP9_COMMON *const cm = &cpi->common;
+ CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
int q = active_worst_quality;
int last_error = INT_MAX;
int i, target_bits_per_mb, bits_per_mb_at_this_q;
@@ -561,7 +562,7 @@
do {
if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled &&
- cpi->svc.temporal_layer_id == 0 &&
+ cr->apply_cyclic_refresh &&
(!cpi->oxcf.gf_cbr_boost_pct || !cpi->refresh_golden_frame)) {
bits_per_mb_at_this_q =
(int)vp9_cyclic_refresh_rc_bits_per_mb(cpi, i, correction_factor);