2020-04-13 13:57:05 +00:00
|
|
|
#include <libswscale/swscale.h>
|
|
|
|
|
2019-11-09 00:50:46 +00:00
|
|
|
#include "scale_test.h"
|
2020-04-13 13:57:05 +00:00
|
|
|
#include "video/fmt-conversion.h"
|
2019-11-09 00:50:46 +00:00
|
|
|
#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,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void run(struct test_ctx *ctx)
|
|
|
|
{
|
|
|
|
struct mp_zimg_context *zimg = mp_zimg_alloc();
|
zimg: add slice threading and use it by default
This probably makes it much faster (I wouldn't know, I didn't run any
benchmarks ). Seems to work as well (although I'm not sure, it's not
like I'd perform rigorous tests).
The scale_zimg test seems to mysteriously treat color in fully
transparent alpha differently, which makes no sense, and isn't visible
(but makes the test fail). I can't be bothered with investigating this
more. What do you do with failing tests? Correct, you disable them. Or
rather, you disable whatever appears to cause them to fail, which is the
threading in this case.
This change follows mostly the tile_example.cpp. The slice size uses a
minimum of 64, which was suggested by the zimg author. Some of this
commit is a bit inelegant and weird, such as recomputing the scale
factor for every slice, or the way slice_h is managed. Too lazy to make
this more elegant.
zimg git had a regressio around active_region (which is needed by the
slicing), which was fixed in commit 83071706b2e6bc634. Apparently, the
bug was never released, so just add a warning to the manpage.
2020-07-14 20:52:27 +00:00
|
|
|
zimg->opts.threads = 1;
|
2019-11-09 00:50:46 +00:00
|
|
|
|
|
|
|
struct scale_test *stest = talloc_zero(NULL, struct scale_test);
|
|
|
|
stest->fns = &fns;
|
|
|
|
stest->fns_priv = zimg;
|
|
|
|
stest->test_name = "repack_zimg";
|
|
|
|
stest->ctx = ctx;
|
|
|
|
|
|
|
|
repack_test_run(stest);
|
|
|
|
|
2020-04-13 13:57:05 +00:00
|
|
|
FILE *f = test_open_out(ctx, "zimg_formats.txt");
|
|
|
|
init_imgfmts_list();
|
|
|
|
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->ctx, "zimg_formats.txt", "zimg_formats.txt",
|
|
|
|
"This can fail if FFmpeg/libswscale adds or removes pixfmts.");
|
2020-05-02 15:39:18 +00:00
|
|
|
|
|
|
|
talloc_free(stest);
|
|
|
|
talloc_free(zimg);
|
2019-11-09 00:50:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const struct unittest test_repack_zimg = {
|
|
|
|
.name = "repack_zimg",
|
|
|
|
.run = run,
|
|
|
|
};
|