shithub: libvpx

Download patch

ref: 30fc1a814de999e8f470b0e172d40dc3ba3c3ce6
parent: 7e9664934625daf58e33828b2c9fb87e8f1ff75b
parent: e2435ff1f85679d8d67e1f9bb62835fdb948cbeb
author: Angie Chiang <angiebird@google.com>
date: Wed Mar 13 20:18:04 EDT 2019

Merge "Safe guard zero median filter outcome case"

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -4793,9 +4793,12 @@
       // Wiener filter
       for (idx = 1; idx < coeff_count; ++idx) {
         int64_t sqr_coeff = (int64_t)coeff[idx] * coeff[idx];
-        coeff[idx] = (int16_t)((sqr_coeff * coeff[idx]) /
-                               (sqr_coeff + (int64_t)median_val * median_val));
-        wiener_variance += (int64_t)coeff[idx] * coeff[idx];
+        int64_t tmp_coeff = (int64_t)coeff[idx];
+        if (median_val) {
+          tmp_coeff = (sqr_coeff * coeff[idx]) /
+                      (sqr_coeff + (int64_t)median_val * median_val);
+        }
+        wiener_variance += tmp_coeff * tmp_coeff;
       }
       cpi->mb_wiener_variance[mb_row * cm->mb_cols + mb_col] =
           wiener_variance / coeff_count;