summaryrefslogtreecommitdiff
path: root/vpx_dsp/add_noise.c
diff options
context:
space:
mode:
Diffstat (limited to 'vpx_dsp/add_noise.c')
-rw-r--r--vpx_dsp/add_noise.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/vpx_dsp/add_noise.c b/vpx_dsp/add_noise.c
index 4ae67a813..4808e79d2 100644
--- a/vpx_dsp/add_noise.c
+++ b/vpx_dsp/add_noise.c
@@ -17,23 +17,20 @@
#include "vpx/vpx_integer.h"
#include "vpx_ports/mem.h"
-void vpx_plane_add_noise_c(uint8_t *start, char *noise,
- char blackclamp[16],
- char whiteclamp[16],
- char bothclamp[16],
- unsigned int width, unsigned int height, int pitch) {
+void vpx_plane_add_noise_c(uint8_t *start, const int8_t *noise, int blackclamp,
+ int whiteclamp, int width, int height, int pitch) {
unsigned int i, j;
-
+ int bothclamp = blackclamp + whiteclamp;
for (i = 0; i < height; ++i) {
uint8_t *pos = start + i * pitch;
- char *ref = (char *)(noise + (rand() & 0xff)); // NOLINT
+ const int8_t *ref = (const int8_t *)(noise + (rand() & 0xff)); // NOLINT
for (j = 0; j < width; ++j) {
int v = pos[j];
- v = clamp(v - blackclamp[0], 0, 255);
- v = clamp(v + bothclamp[0], 0, 255);
- v = clamp(v - whiteclamp[0], 0, 255);
+ v = clamp(v - blackclamp, 0, 255);
+ v = clamp(v + bothclamp, 0, 255);
+ v = clamp(v - whiteclamp, 0, 255);
pos[j] = v + ref[j];
}
@@ -45,7 +42,7 @@ static double gaussian(double sigma, double mu, double x) {
(exp(-(x - mu) * (x - mu) / (2 * sigma * sigma)));
}
-int vpx_setup_noise(double sigma, int size, char *noise) {
+int vpx_setup_noise(double sigma, int8_t *noise, int size) {
char char_dist[256];
int next = 0, i, j;