Fix a bug in VP9 denoiser.
authorJackyChen <jackychen@google.com>
Thu, 4 Sep 2014 18:16:56 +0000 (11:16 -0700)
committerJackyChen <jackychen@google.com>
Thu, 4 Sep 2014 18:46:36 +0000 (11:46 -0700)
When the first try of denoising turns out to be too much,
we will use a softer filter by adopting an adjustment to
make the result closer to original pixel (as in VP8 denoiser).
The old code made the adjustment in the wrong direction.

Change-Id: I84e28fa9e01eef47c5a37d5a2e6d3d378a06786b

vp9/encoder/vp9_denoiser.c

index e9fbf1b..e047f7e 100644 (file)
@@ -145,11 +145,17 @@ static VP9_DENOISER_DECISION denoiser_filter(const uint8_t *sig, int sig_stride,
         adj = delta;
       }
       if (diff > 0) {
+        // Diff positive means we made positive adjustment above
+        // (in first try/attempt), so now make negative adjustment to bring
+        // denoised signal down.
         avg[c] = MAX(0, avg[c] - adj);
-        total_adj += adj;
+        total_adj -= adj;
       } else {
+        // Diff negative means we made negative adjustment above
+        // (in first try/attempt), so now make positive adjustment to bring
+        // denoised signal up.
         avg[c] = MIN(UINT8_MAX, avg[c] + adj);
-        total_adj -= adj;
+        total_adj += adj;
       }
     }
     sig += sig_stride;