diff options
author | Paul B Mahol <onemda@gmail.com> | 2022-02-14 23:54:24 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2022-02-14 23:57:58 +0100 |
commit | 0da255dd10fe8ca424291da583b32d9f1afeb3f9 (patch) | |
tree | 3706911fdf3b3c0da1f9fed7527875785f5ac8fa | |
parent | e235c7648767673c57d89ee5485663b30d592126 (diff) | |
download | ffmpeg-0da255dd10fe8ca424291da583b32d9f1afeb3f9.tar.gz |
avfilter/vf_mix: improve speed of processing
-rw-r--r-- | libavfilter/vf_mix.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/libavfilter/vf_mix.c b/libavfilter/vf_mix.c index b701b44faa..c97c09daef 100644 --- a/libavfilter/vf_mix.c +++ b/libavfilter/vf_mix.c @@ -138,6 +138,7 @@ static int mix_frames(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) ThreadData *td = arg; AVFrame **in = td->in; AVFrame *out = td->out; + const float *weights = s->weights; int i, p, x, y; if (s->depth <= 8) { @@ -148,15 +149,15 @@ static int mix_frames(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) for (y = slice_start; y < slice_end; y++) { for (x = 0; x < s->linesize[p]; x++) { - int val = 0; + float val = 0.f; for (i = 0; i < s->nb_inputs; i++) { uint8_t src = in[i]->data[p][y * in[i]->linesize[p] + x]; - val += src * s->weights[i]; + val += src * weights[i]; } - dst[x] = av_clip_uint8(val * s->wfactor); + dst[x] = av_clip_uint8(lrintf(val * s->wfactor)); } dst += out->linesize[p]; @@ -170,15 +171,15 @@ static int mix_frames(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) for (y = slice_start; y < slice_end; y++) { for (x = 0; x < s->linesize[p] / 2; x++) { - int val = 0; + float val = 0.f; for (i = 0; i < s->nb_inputs; i++) { uint16_t src = AV_RN16(in[i]->data[p] + y * in[i]->linesize[p] + x * 2); - val += src * s->weights[i]; + val += src * weights[i]; } - dst[x] = av_clip(val * s->wfactor, 0, s->max); + dst[x] = av_clip(lrintf(val * s->wfactor), 0, s->max); } dst += out->linesize[p] / 2; |