mirror of
https://github.com/mpv-player/mpv
synced 2024-12-30 19:22:11 +00:00
94d853d3a3
This tests the RGB repacker code in zimg, which deserves to be tested because it's tricky and there will be more formats. scale_test.c contains some code that can be used to test any scaler. Or at least that would be great; currently it can only test repacking of some byte-aligned-component RGB formats. It should be called repack_test.c, but I'm too lazy to change the filename now. The idea is that libswscale is used to cross-check the conversions performed by the zimg wrapper. This is why it's "OK" that scale_test.c does libswscale calls. scale_sws.c is the equivalent to scale_zimg.c, and is of course worthless (because it tests libswscale by comparing the results with libswscale), but still might help with finding bugs in scale_test.c. This borrows a sorted list of image formats from test/img_format.c, for the same reason that file sorts them. There's a slight possibility that this can be used to test vo_gpu.c too some times in the future.
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
// 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,
|
|
};
|
|
|
|
static void run(struct test_ctx *ctx)
|
|
{
|
|
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->ctx = ctx;
|
|
|
|
repack_test_run(stest);
|
|
|
|
talloc_free(stest);
|
|
talloc_free(sws);
|
|
}
|
|
|
|
const struct unittest test_repack_sws = {
|
|
.name = "repack_sws",
|
|
.run = run,
|
|
};
|