|
|
@@ -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(); |
|
|
|