From 017257a317be2605e91341b20f539028730dc89b Mon Sep 17 00:00:00 2001 From: Marco Date: Mon, 9 Oct 2017 17:53:21 -0700 Subject: 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 --- vp9/encoder/vp9_ratectrl.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'vp9') diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c index 536af35fa..8c71beaff 100644 --- a/vp9/encoder/vp9_ratectrl.c +++ b/vp9/encoder/vp9_ratectrl.c @@ -2276,6 +2276,7 @@ void vp9_scene_detection_onepass(VP9_COMP *cpi) { 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 @@ void vp9_scene_detection_onepass(VP9_COMP *cpi) { 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 @@ void vp9_scene_detection_onepass(VP9_COMP *cpi) { 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 @@ void vp9_scene_detection_onepass(VP9_COMP *cpi) { 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; -- cgit v1.2.3