]> granicus.if.org Git - libvpx/commitdiff
Refactor calc_frame_boost()
authorangiebird <angiebird@google.com>
Thu, 10 Oct 2019 00:59:56 +0000 (17:59 -0700)
committerangiebird <angiebird@google.com>
Thu, 10 Oct 2019 22:45:58 +0000 (15:45 -0700)
Replace detect_flash() by detect_flash_from_frame_stats()

Change-Id: I31862820926b5167ff70cebe2009c04aa745a019

vp9/encoder/vp9_firstpass.c

index b8777cd123487d01b2d5ad308b7cb69d92a1671c..6f91836e7019269e68ad73935cbcb785d9c08752 100644 (file)
@@ -1839,7 +1839,7 @@ static int detect_flash_from_frame_stats(const FIRSTPASS_STATS *frame_stats) {
   // The recovery after a flash is indicated by a high pcnt_second_ref
   // useage or a second ref coded error notabley lower than the last
   // frame coded error.
-  if (frame_stats == 0) {
+  if (frame_stats == NULL) {
     return 0;
   }
   return (frame_stats->sr_coded_error < frame_stats->coded_error) ||
@@ -1972,6 +1972,7 @@ static int calc_arf_boost(VP9_COMP *cpi, int f_frames, int b_frames) {
   // Search forward from the proposed arf/next gf position.
   for (i = 0; i < f_frames; ++i) {
     const FIRSTPASS_STATS *this_frame = read_frame_stats(twopass, i);
+    const FIRSTPASS_STATS *next_frame = read_frame_stats(twopass, i + 1);
     if (this_frame == NULL) break;
 
     // Update the motion related elements to the boost calculation.
@@ -1981,7 +1982,8 @@ static int calc_arf_boost(VP9_COMP *cpi, int f_frames, int b_frames) {
 
     // We want to discount the flash frame itself and the recovery
     // frame that follows as both will have poor scores.
-    flash_detected = detect_flash(twopass, i) || detect_flash(twopass, i + 1);
+    flash_detected = detect_flash_from_frame_stats(this_frame) ||
+                     detect_flash_from_frame_stats(next_frame);
 
     // Accumulate the effect of prediction quality decay.
     if (!flash_detected) {
@@ -2008,6 +2010,7 @@ static int calc_arf_boost(VP9_COMP *cpi, int f_frames, int b_frames) {
   // Search backward towards last gf position.
   for (i = -1; i >= -b_frames; --i) {
     const FIRSTPASS_STATS *this_frame = read_frame_stats(twopass, i);
+    const FIRSTPASS_STATS *next_frame = read_frame_stats(twopass, i + 1);
     if (this_frame == NULL) break;
 
     // Update the motion related elements to the boost calculation.
@@ -2017,7 +2020,8 @@ static int calc_arf_boost(VP9_COMP *cpi, int f_frames, int b_frames) {
 
     // We want to discount the the flash frame itself and the recovery
     // frame that follows as both will have poor scores.
-    flash_detected = detect_flash(twopass, i) || detect_flash(twopass, i + 1);
+    flash_detected = detect_flash_from_frame_stats(this_frame) ||
+                     detect_flash_from_frame_stats(next_frame);
 
     // Cumulative effect of prediction quality decay.
     if (!flash_detected) {