Commit 21e6c1f57d for ffmpeg
commit 21e6c1f57dddf976a441c05c89b3275727821af6
Author: romainhedouin <romain.hedouin@epitech.eu>
Date: Fri Oct 16 22:37:20 2026 +0200
avfilter/vf_nnedi: use smaller per-thread buffers
The output buffer only needs one line now, and the input buffer half a
frame plus five lines. Both were as big as a whole frame.
For 1080p yuv420p this saves about 115 MB with 10 filter threads and
about 4 MB with one. The output is unchanged.
Found during a code review sweep of ffmpeg using an LLM.
Signed-off-by: romainhedouin <romain.hedouin@epitech.eu>
diff --git a/libavfilter/vf_nnedi.c b/libavfilter/vf_nnedi.c
index bad1b669cd..78a548c81f 100644
--- a/libavfilter/vf_nnedi.c
+++ b/libavfilter/vf_nnedi.c
@@ -1001,7 +1001,7 @@ static int config_input(AVFilterLink *inlink)
}
}
- s->input_size = (s->planewidth[0] + 64) * (s->planeheight[0] + 6);
+ s->input_size = (s->planewidth[0] + 64) * ((s->planeheight[0] + 1) / 2 + 5);
s->input_buf = av_calloc(s->nb_threads, sizeof(*s->input_buf));
if (!s->input_buf)
return AVERROR(ENOMEM);
@@ -1017,7 +1017,7 @@ static int config_input(AVFilterLink *inlink)
return AVERROR(ENOMEM);
for (int i = 0; i < s->nb_threads; i++) {
- s->output_buf[i] = av_calloc(s->input_size, sizeof(**s->output_buf));
+ s->output_buf[i] = av_calloc(s->planewidth[0], sizeof(**s->output_buf));
if (!s->output_buf[i])
return AVERROR(ENOMEM);
}