summaryrefslogtreecommitdiffstats
path: root/test/scale_sws.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:36:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:36:56 +0000
commit51de1d8436100f725f3576aefa24a2bd2057bc28 (patch)
treec6d1d5264b6d40a8d7ca34129f36b7d61e188af3 /test/scale_sws.c
parentInitial commit. (diff)
downloadmpv-51de1d8436100f725f3576aefa24a2bd2057bc28.tar.xz
mpv-51de1d8436100f725f3576aefa24a2bd2057bc28.zip
Adding upstream version 0.37.0.upstream/0.37.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/scale_sws.c')
-rw-r--r--test/scale_sws.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/scale_sws.c b/test/scale_sws.c
new file mode 100644
index 0000000..c9f5e31
--- /dev/null
+++ b/test/scale_sws.c
@@ -0,0 +1,42 @@
+// Test scaling using libswscale.
+// Note: libswscale is already tested in FFmpeg. This code serves mostly to test
+// the functionality scale_test.h using the already tested libswscale as
+// reference.
+
+#include "scale_test.h"
+#include "video/sws_utils.h"
+
+static bool scale(void *pctx, struct mp_image *dst, struct mp_image *src)
+{
+ struct mp_sws_context *ctx = pctx;
+ return mp_sws_scale(ctx, dst, src) >= 0;
+}
+
+static bool supports_fmts(void *pctx, int imgfmt_dst, int imgfmt_src)
+{
+ struct mp_sws_context *ctx = pctx;
+ return mp_sws_supports_formats(ctx, imgfmt_dst, imgfmt_src);
+}
+
+static const struct scale_test_fns fns = {
+ .scale = scale,
+ .supports_fmts = supports_fmts,
+};
+
+int main(int argc, char *argv[])
+{
+ struct mp_sws_context *sws = mp_sws_alloc(NULL);
+
+ struct scale_test *stest = talloc_zero(NULL, struct scale_test);
+ stest->fns = &fns;
+ stest->fns_priv = sws;
+ stest->test_name = "repack_sws";
+ stest->refdir = talloc_strdup(stest, argv[1]);
+ stest->outdir = talloc_strdup(stest, argv[2]);
+
+ repack_test_run(stest);
+
+ talloc_free(stest);
+ talloc_free(sws);
+ return 0;
+}