1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

avfilter/vf_mix: improve speed of processing

This commit is contained in:
Paul B Mahol 2022-02-14 23:54:24 +01:00
parent e235c76487
commit 0da255dd10

View File

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