]> granicus.if.org Git - libvpx/commitdiff
postproc: noise style fixes.
authorJim Bankoski <jimbankoski@google.com>
Wed, 13 Jul 2016 19:39:01 +0000 (12:39 -0700)
committerJim Bankoski <jimbankoski@google.com>
Wed, 13 Jul 2016 19:39:01 +0000 (12:39 -0700)
Change-Id: Ifdcb36b8e77b65faeeb10644256e175acb32275d

test/add_noise_test.cc
vp8/common/postproc.c
vp9/common/vp9_postproc.c
vpx_dsp/add_noise.c
vpx_dsp/postproc.h

index 44b8d74c6f658c520094a368f87e66160d03b013..35aaadfa7c8f6f538943f4ea354362849edd3a7e 100644 (file)
@@ -49,7 +49,7 @@ TEST_P(AddNoiseTest, CheckNoiseAdded) {
   const int height = 64;
   const int image_size = width * height;
   char noise[3072];
-  const int clamp = vpx_setup_noise(sizeof(noise), 4.4, noise);
+  const int clamp = vpx_setup_noise(4.4, sizeof(noise), noise);
 
   for (int i = 0; i < 16; i++) {
     blackclamp[i] = clamp;
@@ -84,7 +84,7 @@ TEST_P(AddNoiseTest, CheckNoiseAdded) {
 
   // Check to make sure don't roll over.
   for (int i = 0; i < image_size; ++i) {
-    EXPECT_GT((int)s[i], clamp) << "i = " << i;
+    EXPECT_GT(static_cast<int>(s[i]), clamp) << "i = " << i;
   }
 
   // Initialize pixels in the image to 0 and check for roll under.
@@ -95,7 +95,7 @@ TEST_P(AddNoiseTest, CheckNoiseAdded) {
 
   // Check to make sure don't roll under.
   for (int i = 0; i < image_size; ++i) {
-    EXPECT_LT((int)s[i], 255 - clamp) << "i = " << i;
+    EXPECT_LT(static_cast<int>(s[i]), 255 - clamp) << "i = " << i;
   }
 
   vpx_free(s);
@@ -110,7 +110,7 @@ TEST_P(AddNoiseTest, CheckCvsAssembly) {
   const int image_size = width * height;
   char noise[3072];
 
-  const int clamp = vpx_setup_noise(sizeof(noise), 4.4, noise);
+  const int clamp = vpx_setup_noise(4.4, sizeof(noise), noise);
 
   for (int i = 0; i < 16; i++) {
     blackclamp[i] = clamp;
@@ -133,7 +133,7 @@ TEST_P(AddNoiseTest, CheckCvsAssembly) {
                                                  width, height, width));
 
   for (int i = 0; i < image_size; ++i) {
-    EXPECT_EQ((int)s[i], (int)d[i]) << "i = " << i;
+    EXPECT_EQ(static_cast<int>(s[i]), static_cast<int>(d[i])) << "i = " << i;
   }
 
   vpx_free(d);
index 82b66001d18f830652d0a6e171fa3d84a72cf1d1..05e2bfc6036153d355c6597a8f94decdf44e4ab5 100644 (file)
@@ -495,7 +495,7 @@ int vp8_post_proc_frame(VP8_COMMON *oci, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t
             struct postproc_state *ppstate = &oci->postproc_state;
             vp8_clear_system_state();
             sigma = noise_level + .5 + .6 * q / 63.0;
-            clamp = vpx_setup_noise(sizeof(ppstate->noise), sigma,
+            clamp = vpx_setup_noise(sigma, sizeof(ppstate->noise),
                                     ppstate->noise);
             for (i = 0; i < 16; i++)
             {
index 265c37fd2277f0ce7dd616ddac059e4696b4dc21..a3697b9b95903077ef941e9665f47dcc256926d8 100644 (file)
@@ -421,7 +421,7 @@ int vp9_post_proc_frame(struct VP9Common *cm,
       int clamp, i;
       vpx_clear_system_state();
       sigma = noise_level + .5 + .6 * q / 63.0;
-      clamp = vpx_setup_noise(sizeof(ppstate->noise), sigma,
+      clamp = vpx_setup_noise(sigma, sizeof(ppstate->noise),
                               ppstate->noise);
 
       for (i = 0; i < 16; i++) {
index baede28506761d3672abcaac22a5298982c8b9b2..4ae67a813ec8a33abe642a2bfa590aa81f9922fa 100644 (file)
@@ -24,11 +24,11 @@ void vpx_plane_add_noise_c(uint8_t *start, char *noise,
                            unsigned int width, unsigned int height, int pitch) {
   unsigned int i, j;
 
-  for (i = 0; i < height; i++) {
+  for (i = 0; i < height; ++i) {
     uint8_t *pos = start + i * pitch;
     char  *ref = (char *)(noise + (rand() & 0xff));  // NOLINT
 
-    for (j = 0; j < width; j++) {
+    for (j = 0; j < width; ++j) {
       int v = pos[j];
 
       v = clamp(v - blackclamp[0], 0, 255);
@@ -45,28 +45,27 @@ static double gaussian(double sigma, double mu, double x) {
          (exp(-(x - mu) * (x - mu) / (2 * sigma * sigma)));
 }
 
-int vpx_setup_noise(int size, double sigma, char *noise) {
+int vpx_setup_noise(double sigma, int size, char *noise) {
   char char_dist[256];
-  int next, i, j;
-
-  next = 0;
+  int next = 0, i, j;
 
   // set up a 256 entry lookup that matches gaussian distribution
-  for (i = -32; i < 32; i++) {
-    int a_i = (int) (0.5 + 256 * gaussian(sigma, 0, i));
+  for (i = -32; i < 32; ++i) {
+    const int a_i = (int) (0.5 + 256 * gaussian(sigma, 0, i));
     if (a_i) {
-      for (j = 0; j < a_i; j++) {
-        char_dist[next + j] = (char) (i);
+      for (j = 0; j < a_i; ++j) {
+        char_dist[next + j] = (char)i;
       }
       next = next + j;
     }
   }
 
   // Rounding error - might mean we have less than 256.
-  for (; next < 256; next++)
+  for (; next < 256; ++next) {
     char_dist[next] = 0;
+  }
 
-  for (i = 0; i < size; i++) {
+  for (i = 0; i < size; ++i) {
     noise[i] = char_dist[rand() & 0xff];  // NOLINT
   }
 
index 389b0eed7444bf06de18a0a007af4b9a3c74e5e2..78d11b186cee75c9d853be4d3ffe7708e7413dfe 100644 (file)
@@ -15,7 +15,8 @@
 extern "C" {
 #endif
 
-int vpx_setup_noise(int size, double sigma, char *noise);
+// Fills a noise buffer with gaussian noise strength determined by sigma.
+int vpx_setup_noise(double sigma, int size, char *noise);
 
 #ifdef __cplusplus
 }