Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-16 16:28:47 +0400
committerMichael Niedermayer <michaelni@gmx.at>2014-10-16 16:28:47 +0400
commitaba61b22f70ff5407cd5ff1f797fff42dee07359 (patch)
treeb0ce8ee76ed867b29a300532d1f710dcfd891b32 /libavfilter/vf_noise.c
parent411be72dcbc99b339a7b3fbd1011b54a9185add3 (diff)
avfilter/vf_noise: move shift calculation to filter_frame()
This makes the temporal noise case deterministic with threads Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/vf_noise.c')
-rw-r--r--libavfilter/vf_noise.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/libavfilter/vf_noise.c b/libavfilter/vf_noise.c
index 051ccc206a..6250253fba 100644
--- a/libavfilter/vf_noise.c
+++ b/libavfilter/vf_noise.c
@@ -157,12 +157,6 @@ static av_cold int init_noise(NoiseContext *n, int comp)
for (j = 0; j < 3; j++)
fp->prev_shift[i][j] = noise + (av_lfg_get(lfg) & (MAX_SHIFT - 1));
- if (!n->rand_shift_init) {
- for (i = 0; i < MAX_RES; i++)
- n->rand_shift[i] = av_lfg_get(lfg) & (MAX_SHIFT - 1);
- n->rand_shift_init = 1;
- }
-
fp->noise = noise;
return 0;
}
@@ -337,8 +331,7 @@ static void noise(uint8_t *dst, const uint8_t *src,
FilterParams *p = &n->param[comp];
int8_t *noise = p->noise;
const int flags = p->flags;
- AVLFG *lfg = &p->lfg;
- int shift, y;
+ int y;
if (!noise) {
if (dst != src)
@@ -351,10 +344,7 @@ static void noise(uint8_t *dst, const uint8_t *src,
int x;
for (x=0; x < width; x+= MAX_RES) {
int w = FFMIN(width - x, MAX_RES);
- if (flags & NOISE_TEMPORAL)
- shift = av_lfg_get(lfg) & (MAX_SHIFT - 1);
- else
- shift = n->rand_shift[ix];
+ int shift = n->rand_shift[ix];
if (flags & NOISE_AVERAGED) {
n->line_noise_avg(dst + x, src + x, w, (const int8_t**)p->prev_shift[ix]);
@@ -393,6 +383,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
NoiseContext *n = ctx->priv;
ThreadData td;
AVFrame *out;
+ int comp, i;
if (av_frame_is_writable(inpicref)) {
out = inpicref;
@@ -405,6 +396,18 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
av_frame_copy_props(out, inpicref);
}
+ for (comp = 0; comp < 4; comp++) {
+ FilterParams *fp = &n->param[comp];
+
+ if ((!n->rand_shift_init || (fp->flags & NOISE_TEMPORAL)) && fp->strength) {
+
+ for (i = 0; i < MAX_RES; i++) {
+ n->rand_shift[i] = av_lfg_get(&fp->lfg) & (MAX_SHIFT - 1);
+ }
+ n->rand_shift_init = 1;
+ }
+ }
+
td.in = inpicref; td.out = out;
ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(n->height[0], ctx->graph->nb_threads));
emms_c();