This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 83d572e6f6715055db8d18241bd8559201a86891
Author:     Niklas Haas <[email protected]>
AuthorDate: Fri Dec 5 18:32:10 2025 +0100
Commit:     Niklas Haas <[email protected]>
CommitDate: Tue Dec 9 09:47:48 2025 +0000

    swscale/format: check SwsPixelType in fmt_read_write()
    
    This is the only function that actually has the ability to return an
    error, so just move the pixel type assignment here and add a check to
    ensure a valid pixel type is found.
---
 libswscale/format.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/libswscale/format.c b/libswscale/format.c
index f9a156e29e..a1afa64f4d 100644
--- a/libswscale/format.c
+++ b/libswscale/format.c
@@ -788,12 +788,16 @@ static SwsConst fmt_clear(enum AVPixelFormat fmt)
 }
 
 static int fmt_read_write(enum AVPixelFormat fmt, SwsReadWriteOp *rw_op,
-                          SwsPackOp *pack_op)
+                          SwsPackOp *pack_op, SwsPixelType *pixel_type)
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
     if (!desc)
         return AVERROR(EINVAL);
 
+    *pixel_type = fmt_pixel_type(fmt);
+    if (!*pixel_type)
+        return AVERROR(ENOTSUP);
+
     switch (fmt) {
     case AV_PIX_FMT_NONE:
     case AV_PIX_FMT_NB:
@@ -1024,12 +1028,13 @@ static SwsPixelType get_packed_type(SwsPackOp pack)
 int ff_sws_decode_pixfmt(SwsOpList *ops, enum AVPixelFormat fmt)
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
-    SwsPixelType pixel_type = fmt_pixel_type(fmt);
-    SwsPixelType raw_type = pixel_type;
+    SwsPixelType pixel_type;
     SwsReadWriteOp rw_op;
     SwsPackOp unpack;
 
-    RET(fmt_read_write(fmt, &rw_op, &unpack));
+    RET(fmt_read_write(fmt, &rw_op, &unpack, &pixel_type));
+
+    SwsPixelType raw_type = pixel_type;
     if (unpack.pattern[0])
         raw_type = get_packed_type(unpack);
 
@@ -1085,12 +1090,13 @@ int ff_sws_decode_pixfmt(SwsOpList *ops, enum 
AVPixelFormat fmt)
 int ff_sws_encode_pixfmt(SwsOpList *ops, enum AVPixelFormat fmt)
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
-    SwsPixelType pixel_type = fmt_pixel_type(fmt);
-    SwsPixelType raw_type = pixel_type;
+    SwsPixelType pixel_type;
     SwsReadWriteOp rw_op;
     SwsPackOp pack;
 
-    RET(fmt_read_write(fmt, &rw_op, &pack));
+    RET(fmt_read_write(fmt, &rw_op, &pack, &pixel_type));
+
+    SwsPixelType raw_type = pixel_type;
     if (pack.pattern[0])
         raw_type = get_packed_type(pack);
 

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to