shithub: libvpx

Download patch

ref: b12e353424cdb71b0b5807931508ca167bbdc71b
parent: 623e988addfa8add7a21c69aa893ba42f7d5236e
author: Marco <marpan@google.com>
date: Thu Dec 3 08:08:37 EST 2015

vp9-noise estimate: Move level setting to a function.

This is so we may update level at any time (e.g., to be used
for setting thresholds in variance-based partition).

Change-Id: I32caad2271b8e03017a531f9ea456a6dbb9d49c7

--- a/vp9/encoder/vp9_noise_estimate.c
+++ b/vp9/encoder/vp9_noise_estimate.c
@@ -82,6 +82,21 @@
   }
 }
 
+NOISE_LEVEL vp9_noise_estimate_extract_level(NOISE_ESTIMATE *const ne) {
+  int noise_level = kLowLow;
+  if (ne->value > (ne->thresh << 1)) {
+    noise_level = kHigh;
+  } else {
+    if (ne->value > ne->thresh)
+      noise_level = kMedium;
+    else if (ne->value > (ne->thresh >> 1))
+      noise_level = kLow;
+    else
+      noise_level = kLowLow;
+  }
+  return noise_level;
+}
+
 void vp9_update_noise_estimate(VP9_COMP *const cpi) {
   const VP9_COMMON *const cm = &cpi->common;
   CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
@@ -220,16 +235,7 @@
         // Reset counter and check noise level condition.
         ne->num_frames_estimate = 30;
         ne->count = 0;
-        if (ne->value > (ne->thresh << 1)) {
-          ne->level = kHigh;
-        } else {
-          if (ne->value > ne->thresh)
-            ne->level = kMedium;
-          else if (ne->value > (ne->thresh >> 1))
-            ne->level = kLow;
-          else
-            ne->level = kLowLow;
-        }
+        ne->level = vp9_noise_estimate_extract_level(ne);
 #if CONFIG_VP9_TEMPORAL_DENOISING
         if (cpi->oxcf.noise_sensitivity > 0)
           vp9_denoiser_set_noise_level(&cpi->denoiser, ne->level);
--- a/vp9/encoder/vp9_noise_estimate.h
+++ b/vp9/encoder/vp9_noise_estimate.h
@@ -47,6 +47,8 @@
                              int width,
                              int height);
 
+NOISE_LEVEL vp9_noise_estimate_extract_level(NOISE_ESTIMATE *const ne);
+
 void vp9_update_noise_estimate(struct VP9_COMP *const cpi);
 
 #ifdef __cplusplus