postproc: noise style fixes.

Change-Id: Ifdcb36b8e77b65faeeb10644256e175acb32275d
diff --git a/test/add_noise_test.cc b/test/add_noise_test.cc
index 44b8d74..35aaadf 100644
--- a/test/add_noise_test.cc
+++ b/test/add_noise_test.cc
@@ -49,7 +49,7 @@
   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 @@
 
   // 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 @@
 
   // 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 @@
   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 @@
                                                  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);
diff --git a/vp8/common/postproc.c b/vp8/common/postproc.c
index 82b6600..05e2bfc 100644
--- a/vp8/common/postproc.c
+++ b/vp8/common/postproc.c
@@ -495,7 +495,7 @@
             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++)
             {
diff --git a/vp9/common/vp9_postproc.c b/vp9/common/vp9_postproc.c
index 265c37f..a3697b9 100644
--- a/vp9/common/vp9_postproc.c
+++ b/vp9/common/vp9_postproc.c
@@ -421,7 +421,7 @@
       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++) {
diff --git a/vpx_dsp/add_noise.c b/vpx_dsp/add_noise.c
index baede28..4ae67a8 100644
--- a/vpx_dsp/add_noise.c
+++ b/vpx_dsp/add_noise.c
@@ -24,11 +24,11 @@
                            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 @@
          (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
   }
 
diff --git a/vpx_dsp/postproc.h b/vpx_dsp/postproc.h
index 389b0ee..78d11b1 100644
--- a/vpx_dsp/postproc.h
+++ b/vpx_dsp/postproc.h
@@ -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
 }