mirror of
https://github.com/mpv-player/mpv
synced 2024-12-19 21:31:52 +00:00
9db818279a
This reworks all of mpv's unit tests so they are compiled as separate executables (optional) and run via meson test. Because most of the tests are dependant on mpv's internals, existing compiled objects are leveraged to create static libs and used when necessary. As an aside, a function was moved into video/out/gpu/utils for sanity's sake (otherwise most of vo would have been needed). As a plus, meson multithreads running tests automatically and also the output no longer pollutes the source directory. There are tests that can break due to ffmpeg changes, so they require a specific minimum libavutil version to be built.
57 lines
1.7 KiB
C
57 lines
1.7 KiB
C
#include <libswscale/swscale.h>
|
|
|
|
#include "scale_test.h"
|
|
#include "video/fmt-conversion.h"
|
|
#include "video/zimg.h"
|
|
|
|
static bool scale(void *pctx, struct mp_image *dst, struct mp_image *src)
|
|
{
|
|
struct mp_zimg_context *ctx = pctx;
|
|
return mp_zimg_convert(ctx, dst, src);
|
|
}
|
|
|
|
static bool supports_fmts(void *pctx, int imgfmt_dst, int imgfmt_src)
|
|
{
|
|
return mp_zimg_supports_in_format(imgfmt_src) &&
|
|
mp_zimg_supports_out_format(imgfmt_dst);
|
|
}
|
|
|
|
static const struct scale_test_fns fns = {
|
|
.scale = scale,
|
|
.supports_fmts = supports_fmts,
|
|
};
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
struct mp_zimg_context *zimg = mp_zimg_alloc();
|
|
zimg->opts.threads = 1;
|
|
|
|
struct scale_test *stest = talloc_zero(NULL, struct scale_test);
|
|
stest->fns = &fns;
|
|
stest->fns_priv = zimg;
|
|
stest->test_name = "repack_zimg";
|
|
stest->refdir = talloc_strdup(stest, argv[1]);
|
|
stest->outdir = talloc_strdup(stest, argv[2]);
|
|
|
|
repack_test_run(stest);
|
|
|
|
FILE *f = test_open_out(stest->outdir, "zimg_formats.txt");
|
|
for (int n = 0; n < num_imgfmts; n++) {
|
|
int imgfmt = imgfmts[n];
|
|
fprintf(f, "%15s%7s%7s%7s%8s |\n", mp_imgfmt_to_name(imgfmt),
|
|
mp_zimg_supports_in_format(imgfmt) ? " Zin" : "",
|
|
mp_zimg_supports_out_format(imgfmt) ? " Zout" : "",
|
|
sws_isSupportedInput(imgfmt2pixfmt(imgfmt)) ? " SWSin" : "",
|
|
sws_isSupportedOutput(imgfmt2pixfmt(imgfmt)) ? " SWSout" : "");
|
|
|
|
}
|
|
fclose(f);
|
|
|
|
assert_text_files_equal(stest->refdir, stest->outdir, "zimg_formats.txt",
|
|
"This can fail if FFmpeg/libswscale adds or removes pixfmts.");
|
|
|
|
talloc_free(stest);
|
|
talloc_free(zimg);
|
|
return 0;
|
|
}
|