shithub: libvpx

Download patch

ref: efb150bb3092045b2f9011b4b7e35743689e5775
parent: 2336853be1f387f08e16a0b13d24d8da22b35583
parent: 84520829ed508a24e66b05b5202f5fca77443f75
author: Dmitry Kovalev <[email protected]>
date: Fri Jan 3 10:13:22 EST 2014

Merge "Cleaning up get_prediction_decay_rate() function."

--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -1163,32 +1163,15 @@
 // the prediction quality is decaying from frame to frame.
 static double get_prediction_decay_rate(VP9_COMP *cpi,
                                         FIRSTPASS_STATS *next_frame) {
-  double prediction_decay_rate;
-  double second_ref_decay;
-  double mb_sr_err_diff;
-
-  // Initial basis is the % mbs inter coded
-  prediction_decay_rate = next_frame->pcnt_inter;
-
   // Look at the observed drop in prediction quality between the last frame
   // and the GF buffer (which contains an older frame).
-  mb_sr_err_diff = (next_frame->sr_coded_error - next_frame->coded_error) /
-                   cpi->common.MBs;
-  if (mb_sr_err_diff <= 512.0) {
-    second_ref_decay = 1.0 - (mb_sr_err_diff / 512.0);
-    second_ref_decay = pow(second_ref_decay, 0.5);
-    if (second_ref_decay < 0.85)
-      second_ref_decay = 0.85;
-    else if (second_ref_decay > 1.0)
-      second_ref_decay = 1.0;
-  } else {
-    second_ref_decay = 0.85;
-  }
+  const double mb_sr_err_diff = (next_frame->sr_coded_error -
+                                     next_frame->coded_error) / cpi->common.MBs;
+  const double second_ref_decay = mb_sr_err_diff <= 512.0
+      ? fclamp(pow(1.0 - (mb_sr_err_diff / 512.0), 0.5), 0.85, 1.0)
+      : 0.85;
 
-  if (second_ref_decay < prediction_decay_rate)
-    prediction_decay_rate = second_ref_decay;
-
-  return prediction_decay_rate;
+  return MIN(second_ref_decay, next_frame->pcnt_inter);
 }
 
 // Function to test for a condition where a complex transition is followed