[FFmpeg-cvslog] swscale/graph: make noop loop more robust

Niklas Haas git at videolan.org
Sun May 18 16:01:29 EEST 2025


ffmpeg | branch: master | Niklas Haas <git at haasn.dev> | Thu Mar  6 10:47:21 2025 +0100| [bc9696bff80d996b5d526c02b596caa5d64e2db2] | committer: Niklas Haas

swscale/graph: make noop loop more robust

The current loop only works if the input and output have the same number
of planes. However, with the new scaling logic, we can also optimize into a
noop the case where the input has extra unneeded planes.

For the memcpy fallback to work in these cases we have to instead check if
the *output* pointer is set, rather than the input pointer.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bc9696bff80d996b5d526c02b596caa5d64e2db2
---

 libswscale/graph.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libswscale/graph.c b/libswscale/graph.c
index 6cfcf4f2c6..c5a46eb257 100644
--- a/libswscale/graph.c
+++ b/libswscale/graph.c
@@ -115,8 +115,10 @@ static void run_copy(const SwsImg *out_base, const SwsImg *in_base,
     SwsImg in  = shift_img(in_base,  y);
     SwsImg out = shift_img(out_base, y);
 
-    for (int i = 0; i < FF_ARRAY_ELEMS(in.data) && in.data[i]; i++) {
+    for (int i = 0; i < FF_ARRAY_ELEMS(out.data) && out.data[i]; i++) {
         const int lines = h >> vshift(in.fmt, i);
+        av_assert1(in.data[i]);
+
         if (in.linesize[i] == out.linesize[i]) {
             memcpy(out.data[i], in.data[i], lines * out.linesize[i]);
         } else {



More information about the ffmpeg-cvslog mailing list