1 // Test scaling using libswscale.
2 // Note: libswscale is already tested in FFmpeg. This code serves mostly to test
3 //       the functionality scale_test.h using the already tested libswscale as
4 //       reference.
5 
6 #include "scale_test.h"
7 #include "video/sws_utils.h"
8 
scale(void * pctx,struct mp_image * dst,struct mp_image * src)9 static bool scale(void *pctx, struct mp_image *dst, struct mp_image *src)
10 {
11     struct mp_sws_context *ctx = pctx;
12     return mp_sws_scale(ctx, dst, src) >= 0;
13 }
14 
supports_fmts(void * pctx,int imgfmt_dst,int imgfmt_src)15 static bool supports_fmts(void *pctx, int imgfmt_dst, int imgfmt_src)
16 {
17     struct mp_sws_context *ctx = pctx;
18     return mp_sws_supports_formats(ctx, imgfmt_dst, imgfmt_src);
19 }
20 
21 static const struct scale_test_fns fns = {
22     .scale = scale,
23     .supports_fmts = supports_fmts,
24 };
25 
run(struct test_ctx * ctx)26 static void run(struct test_ctx *ctx)
27 {
28     struct mp_sws_context *sws = mp_sws_alloc(NULL);
29 
30     struct scale_test *stest = talloc_zero(NULL, struct scale_test);
31     stest->fns = &fns;
32     stest->fns_priv = sws;
33     stest->test_name = "repack_sws";
34     stest->ctx = ctx;
35 
36     repack_test_run(stest);
37 
38     talloc_free(stest);
39     talloc_free(sws);
40 }
41 
42 const struct unittest test_repack_sws = {
43     .name = "repack_sws",
44     .run = run,
45 };
46