ref: 017257a317be2605e91341b20f539028730dc89b
parent: 963cc22cefc0b35bd5675d63604a8e96954f1b03
author: Marco <marpan@google.com>
date: Mon Oct 9 13:53:21 EDT 2017
Adjustment to scene detection and key frame. For 1 pass vbr: use higher threshold on avg_sad and force key frame under scene cut detection if above the threshold. Allow it for speed >= 6 for now, since it does not use the full nonrd_pickmode partition (as in speed 5). Improves quality somewhat on scene cut frames. Neutral on overall metrics and fps for speed 6 on ytlive set. Change-Id: I12626f7627419ca14f9d0d249df86c7104438162
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -2276,6 +2276,7 @@
int start_frame = 0;
int frames_to_buffer = 1;
int frame = 0;
+ int scene_cut_force_key_frame = 0;
uint64_t avg_sad_current = 0;
uint32_t min_thresh = 4000;
float thresh = 8.0f;
@@ -2306,6 +2307,8 @@
rc->high_source_sad = 1;
else
rc->high_source_sad = 0;
+ if (rc->high_source_sad && avg_sad_current > min_thresh << 1)
+ scene_cut_force_key_frame = 1;
// Update recursive average for current frame.
if (avg_sad_current > 0)
rc->avg_source_sad[0] =
@@ -2366,6 +2369,8 @@
rc->high_source_sad = 1;
else
rc->high_source_sad = 0;
+ if (rc->high_source_sad && avg_sad > min_thresh << 1)
+ scene_cut_force_key_frame = 1;
if (avg_sad > 0 || cpi->oxcf.rc_mode == VPX_CBR)
rc->avg_source_sad[0] = (3 * rc->avg_source_sad[0] + avg_sad) >> 2;
} else {
@@ -2397,6 +2402,8 @@
cpi->ext_refresh_frame_flags_pending == 0) {
int target;
cpi->refresh_golden_frame = 1;
+ if (cpi->oxcf.speed >= 6 && scene_cut_force_key_frame)
+ cm->frame_type = KEY_FRAME;
rc->source_alt_ref_pending = 0;
if (cpi->sf.use_altref_onepass && cpi->oxcf.enable_auto_arf)
rc->source_alt_ref_pending = 1;