]> granicus.if.org Git - libvpx/commitdiff
Pass first_pass_info/show_idx to test_candidate_kf
authorangiebird <angiebird@google.com>
Tue, 22 Oct 2019 01:04:49 +0000 (18:04 -0700)
committerangiebird <angiebird@google.com>
Tue, 22 Oct 2019 01:04:49 +0000 (18:04 -0700)
Change-Id: I5c18de464be9981236f95c62391258c4963e469b

vp9/encoder/vp9_firstpass.c
vp9/encoder/vp9_firstpass.h

index 8e58011f62547c22947179411fde6b8baa55ef5a..f75abdb875c52839833b9c5402da4360cfe67f21 100644 (file)
@@ -2945,9 +2945,14 @@ static int intra_step_transition(const FIRSTPASS_STATS *this_frame,
 #define V_LOW_INTRA 0.5
 
 static int test_candidate_kf(TWO_PASS *twopass,
-                             const FIRSTPASS_STATS *last_frame,
-                             const FIRSTPASS_STATS *this_frame,
-                             const FIRSTPASS_STATS *next_frame) {
+                             const FIRST_PASS_INFO *first_pass_info,
+                             int show_idx) {
+  const FIRSTPASS_STATS *last_frame =
+      fps_get_frame_stats(first_pass_info, show_idx - 1);
+  const FIRSTPASS_STATS *this_frame =
+      fps_get_frame_stats(first_pass_info, show_idx);
+  const FIRSTPASS_STATS *next_frame =
+      fps_get_frame_stats(first_pass_info, show_idx + 1);
   int is_viable_kf = 0;
   double pcnt_intra = 1.0 - this_frame->pcnt_inter;
 
@@ -3106,9 +3111,6 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) {
     int i = 0;
     while (twopass->stats_in < twopass->stats_in_end &&
            rc->frames_to_key < cpi->oxcf.key_freq) {
-      // Load the next frame's stats.
-      const FIRSTPASS_STATS *last_frame =
-          fps_get_frame_stats(first_pass_info, kf_show_idx + i);
       FIRSTPASS_STATS this_frame;
       input_stats(twopass, &this_frame);
 
@@ -3117,8 +3119,7 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) {
         double loop_decay_rate;
 
         // Check for a scene cut.
-        if (test_candidate_kf(twopass, last_frame, &this_frame,
-                              twopass->stats_in))
+        if (test_candidate_kf(twopass, first_pass_info, kf_show_idx + i + 1))
           break;
 
         // How fast is the prediction quality decaying?
index 6aa296bd0feade680b244a8a24fda191249e1339..2158dfe4fa6fb500bbb40326f4fc6dc505a5cd3b 100644 (file)
@@ -164,7 +164,7 @@ static INLINE int fps_get_num_frames(const FIRST_PASS_INFO *first_pass_info) {
 
 static INLINE const FIRSTPASS_STATS *fps_get_frame_stats(
     const FIRST_PASS_INFO *first_pass_info, int show_idx) {
-  if (show_idx >= first_pass_info->num_frames) {
+  if (show_idx < 0 || show_idx >= first_pass_info->num_frames) {
     return NULL;
   }
   return &first_pass_info->stats[show_idx];