Add fast-adapt mechanism for VNR
author“Michael <mhoro@google.com>
Tue, 9 Apr 2019 21:28:06 +0000 (16:28 -0500)
committer“Michael <mhoro@google.com>
Tue, 9 Apr 2019 21:30:32 +0000 (16:30 -0500)
Change-Id: Ia1d9cde418cc981ee08dc94a2e375d6cb4542250

vp9/encoder/vp9_noise_estimate.c
vp9/encoder/vp9_noise_estimate.h

index 2ed192a..9696529 100644 (file)
@@ -46,6 +46,7 @@ void vp9_noise_estimate_init(NOISE_ESTIMATE *const ne, int width, int height) {
     ne->thresh = 115;
   }
   ne->num_frames_estimate = 15;
+  ne->adapt_thresh = (3 * ne->thresh) >> 1;
 }
 
 static int enable_noise_estimation(VP9_COMP *const cpi) {
@@ -277,7 +278,12 @@ void vp9_update_noise_estimate(VP9_COMP *const cpi) {
 
     // Scale by 40 to work with existing thresholds
     ne->value = (int)((3 * ne->value + max_bin * 40) >> 2);
-    ne->count++;
+    // Quickly increase VNR strength when the noise level increases suddenly.
+    if (ne->level < kMedium && ne->value > ne->adapt_thresh) {
+      ne->count = ne->num_frames_estimate;
+    } else {
+      ne->count++;
+    }
     if (ne->count == ne->num_frames_estimate) {
       // Reset counter and check noise level condition.
       ne->num_frames_estimate = 30;
index e30ad31..7fc94ff 100644 (file)
@@ -32,6 +32,7 @@ typedef struct noise_estimate {
   NOISE_LEVEL level;
   int value;
   int thresh;
+  int adapt_thresh;
   int count;
   int last_w;
   int last_h;