summaryrefslogtreecommitdiff
path: root/libavfilter/vf_noise.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2013-05-29 16:54:28 +0000
committerPaul B Mahol <onemda@gmail.com>2013-05-29 16:54:28 +0000
commitf8f42f48218138d37956407ebf10227eb86d4a2d (patch)
tree9f6b91a7c8e9841e6e66027135495e3043e6300d /libavfilter/vf_noise.c
parent83f97355927f8e5f343fc04039e658cadc5c8b39 (diff)
lavfi/noise: fix out of array access
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter/vf_noise.c')
-rw-r--r--libavfilter/vf_noise.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libavfilter/vf_noise.c b/libavfilter/vf_noise.c
index 274a1def23..9fd2a67ebc 100644
--- a/libavfilter/vf_noise.c
+++ b/libavfilter/vf_noise.c
@@ -35,7 +35,7 @@
#include "internal.h"
#include "video.h"
-#define MAX_NOISE 4096
+#define MAX_NOISE 5120
#define MAX_SHIFT 1024
#define MAX_RES (MAX_NOISE-MAX_SHIFT)
@@ -347,14 +347,15 @@ static void noise(uint8_t *dst, const uint8_t *src,
}
for (y = start; y < end; y++) {
+ const int ix = y & (MAX_RES - 1);
if (flags & NOISE_TEMPORAL)
shift = av_lfg_get(lfg) & (MAX_SHIFT - 1);
else
- shift = n->rand_shift[y];
+ shift = n->rand_shift[ix];
if (flags & NOISE_AVERAGED) {
- n->line_noise_avg(dst, src, width, p->prev_shift[y]);
- p->prev_shift[y][shift & 3] = noise + shift;
+ n->line_noise_avg(dst, src, width, p->prev_shift[ix]);
+ p->prev_shift[ix][shift & 3] = noise + shift;
} else {
n->line_noise(dst, src, noise, width, shift);
}