[FFmpeg-cvslog] avfilter/vf_mix: improve speed even more by avoiding using filter private context
Paul B Mahol
git at videolan.org
Fri May 19 20:34:14 EEST 2023
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri May 19 19:12:37 2023 +0200| [613f7164501ef6cb4a45e969477946dfa5fa1b00] | committer: Paul B Mahol
avfilter/vf_mix: improve speed even more by avoiding using filter private context
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=613f7164501ef6cb4a45e969477946dfa5fa1b00
---
libavfilter/vf_mix.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/libavfilter/vf_mix.c b/libavfilter/vf_mix.c
index 64d07bbbbb..70fe90ea30 100644
--- a/libavfilter/vf_mix.c
+++ b/libavfilter/vf_mix.c
@@ -161,27 +161,27 @@ typedef struct ThreadData {
continue; \
} \
\
- for (int i = 0; i < s->nb_inputs; i++) \
+ for (int i = 0; i < nb_inputs; i++) \
linesize[i] = in[i]->linesize[p]; \
\
- for (int i = 0; i < s->nb_inputs; i++) \
+ for (int i = 0; i < nb_inputs; i++) \
srcf[i] = in[i]->data[p] + slice_start * linesize[i]; \
\
for (int y = slice_start; y < slice_end; y++) { \
for (int x = 0; x < width; x++) { \
float val = 0.f; \
\
- for (int i = 0; i < s->nb_inputs; i++) { \
+ for (int i = 0; i < nb_inputs; i++) { \
float src = *(type *)(srcf[i] + x * sizeof(type)); \
\
val += src * weights[i]; \
} \
\
- dst[x] = clip(fun(val * s->wfactor), 0, s->max); \
+ dst[x] = clip(fun(val * wfactor), 0, max); \
} \
\
dst += dst_linesize; \
- for (int i = 0; i < s->nb_inputs; i++) \
+ for (int i = 0; i < nb_inputs; i++) \
srcf[i] += linesize[i]; \
} \
}
@@ -200,6 +200,9 @@ static int mix_frames(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
const float *weights = s->weights;
uint8_t **srcf = s->data + jobnr * s->nb_inputs;
int *linesize = s->linesize + jobnr * s->nb_inputs;
+ const int nb_inputs = s->nb_inputs;
+ const float wfactor = s->wfactor;
+ const int max = s->max;
if (s->depth <= 8) {
MIX_SLICE(uint8_t, lrintf, CLIP8)
More information about the ffmpeg-cvslog
mailing list