diff mbox series

[FFmpeg-devel,2/7] swscale/tests/swscale: Split sws_getContext()

Message ID 20240214220631.9641-2-michael@niedermayer.cc
State Accepted
Commit 247f485448d8030b18abf534823a3b2d6e55497a
Headers show
Series [FFmpeg-devel,1/7] swscale/tests/swscale: Implement isALPHA() using AVPixFmtDescriptor | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer Feb. 14, 2024, 10:06 p.m. UTC
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libswscale/tests/swscale.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index f853bc4c913..6792fcaa3dc 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -30,6 +30,7 @@ 
 #include "libavutil/mem.h"
 #include "libavutil/avutil.h"
 #include "libavutil/crc.h"
+#include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/lfg.h"
 
@@ -165,10 +166,26 @@  static int doTest(const uint8_t * const ref[4], int refStride[4], int w, int h,
         }
     }
 
-    dstContext = sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat,
-                                flags, NULL, NULL, NULL);
+    dstContext = sws_alloc_context();
     if (!dstContext) {
-        fprintf(stderr, "Failed to get %s ---> %s\n",
+        fprintf(stderr, "Failed to alloc %s ---> %s\n",
+                desc_src->name, desc_dst->name);
+        res = -1;
+        goto end;
+    }
+
+    av_opt_set_int(dstContext, "sws_flags",  flags, 0);
+    av_opt_set_int(dstContext, "srcw",       srcW, 0);
+    av_opt_set_int(dstContext, "srch",       srcH, 0);
+    av_opt_set_int(dstContext, "dstw",       dstW, 0);
+    av_opt_set_int(dstContext, "dsth",       dstH, 0);
+    av_opt_set_int(dstContext, "src_format", srcFormat, 0);
+    av_opt_set_int(dstContext, "dst_format", dstFormat, 0);
+    av_opt_set(dstContext, "alphablend", "none", 0);
+
+    if (sws_init_context(dstContext, NULL, NULL) < 0) {
+        sws_freeContext(dstContext);
+        fprintf(stderr, "Failed to init %s ---> %s\n",
                 desc_src->name, desc_dst->name);
         res = -1;
         goto end;