[FFmpeg-cvslog] swscale/swscale: combine the input/output checks in sws_frame_setup()

James Almer git at videolan.org
Wed Jan 22 17:16:04 EET 2025


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Wed Jan 22 12:12:13 2025 -0300| [abdc20727c22433e9a3368359dccc61da835c66a] | committer: James Almer

swscale/swscale: combine the input/output checks in sws_frame_setup()

Cosmetic change in preparation for the next commit.

Signed-off-by: James Almer <jamrial at gmail.com>

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

 libswscale/swscale.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 30fbc590fd..84657bb17c 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -1442,6 +1442,7 @@ int sws_frame_setup(SwsContext *ctx, const AVFrame *dst, const AVFrame *src)
     for (int field = 0; field < 2; field++) {
         SwsFormat src_fmt = ff_fmt_from_frame(src, field);
         SwsFormat dst_fmt = ff_fmt_from_frame(dst, field);
+        int src_ok, dst_ok;
 
         if ((src->flags ^ dst->flags) & AV_FRAME_FLAG_INTERLACED) {
             err_msg = "Cannot convert interlaced to progressive frames or vice versa.\n";
@@ -1449,14 +1450,10 @@ int sws_frame_setup(SwsContext *ctx, const AVFrame *dst, const AVFrame *src)
             goto fail;
         }
 
-        if (!ff_test_fmt(&src_fmt, 0)) {
-            err_msg = "Unsupported input";
-            ret = AVERROR(ENOTSUP);
-            goto fail;
-        }
-
-        if (!ff_test_fmt(&dst_fmt, 1)) {
-            err_msg = "Unsupported output";
+        src_ok = ff_test_fmt(&src_fmt, 0);
+        dst_ok = ff_test_fmt(&dst_fmt, 1);
+        if ((!src_ok || !dst_ok)) {
+            err_msg = src_ok ? "Unsupported output" : "Unsupported input";
             ret = AVERROR(ENOTSUP);
             goto fail;
         }



More information about the ffmpeg-cvslog mailing list