shithub: libvpx

Download patch

ref: 79c14b83e95fedbd955d8c03a2429b1dfb232446
parent: cb16652598961ec949000b42bb2de7af3e4763c1
parent: 41d3331d423c5dc08ea582316262492f29f4d623
author: Paul Wilkins <[email protected]>
date: Thu Feb 1 05:21:38 EST 2018

Merge "Further change to code detecting slide transitions."

--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2699,13 +2699,24 @@
 #endif
 }
 
+// Intra / Inter threshold very low
+#define VERY_LOW_II 1.5
+// Clean slide transitions we expect a sharp single frame spike in error.
+#define ERROR_SPIKE 5.0
+
 // Slide show transition detection.
 // Tests for case where there is very low error either side of the current frame
 // but much higher just for this frame. This can help detect key frames in
 // slide shows even where the slides are pictures of different sizes.
+// Also requires that intra and inter errors are very similar to help eliminate
+// harmful false positives.
 // It will not help if the transition is a fade or other multi-frame effect.
-static int slide_transition(double this_err, double last_err, double next_err) {
-  return (this_err > (last_err * 5.0)) && (this_err > (next_err * 5.0));
+static int slide_transition(const FIRSTPASS_STATS *this_frame,
+                            const FIRSTPASS_STATS *last_frame,
+                            const FIRSTPASS_STATS *next_frame) {
+  return (this_frame->intra_error < (this_frame->coded_error * VERY_LOW_II)) &&
+         (this_frame->coded_error > (last_frame->coded_error * ERROR_SPIKE)) &&
+         (this_frame->coded_error > (next_frame->coded_error * ERROR_SPIKE));
 }
 
 // Threshold for use of the lagging second reference frame. High second ref
@@ -2752,8 +2763,7 @@
   if ((this_frame->pcnt_second_ref < SECOND_REF_USEAGE_THRESH) &&
       (next_frame->pcnt_second_ref < SECOND_REF_USEAGE_THRESH) &&
       ((this_frame->pcnt_inter < VERY_LOW_INTER_THRESH) ||
-       (slide_transition(this_frame->coded_error, last_frame->coded_error,
-                         next_frame->coded_error)) ||
+       (slide_transition(this_frame, last_frame, next_frame)) ||
        ((pcnt_intra > MIN_INTRA_LEVEL) &&
         (pcnt_intra > (INTRA_VS_INTER_THRESH * modified_pcnt_inter)) &&
         ((this_frame->intra_error /