video: mess with the filte chain to enable zimg IMGFMT_RGB30 output

This was too hardcoded to libswscale. In particular, IMGFMT_RGB30 output
is only possible with the zimg wrapper, so the context needs to be taken
into account (since this depends on the --sws-allow-zimg option
dynamically). This is still slightly risky, because zimg currently will
still fall back to swscale in some cases, such as when it refuses to
initialize the particular color conversion that is requested.
f_autoconvert.c could actually handle this better, but I'm tool fucking
lazy right now, and nobody cares anyway, so go away, OK?
This commit is contained in:
wm4 2019-11-02 17:50:24 +01:00
parent 3e660f6164
commit e58e650a97
4 changed files with 7 additions and 8 deletions

View File

@ -309,7 +309,7 @@ static bool build_image_converter(struct mp_autoconvert *c, struct mp_log *log,
goto fail; goto fail;
} }
int out = mp_sws_find_best_out_format(src_fmt, fmts, num_fmts); int out = mp_sws_find_best_out_format(sws, src_fmt, fmts, num_fmts);
if (!out) { if (!out) {
mp_err(log, "can't find video conversion for %s\n", mp_err(log, "can't find video conversion for %s\n",
mp_imgfmt_to_name(src_fmt)); mp_imgfmt_to_name(src_fmt));

View File

@ -40,17 +40,14 @@
#include "filter.h" #include "filter.h"
#include "filter_internal.h" #include "filter_internal.h"
int mp_sws_find_best_out_format(int in_format, int *out_formats, int mp_sws_find_best_out_format(struct mp_sws_filter *sws, int in_format,
int num_out_formats) int *out_formats, int num_out_formats)
{ {
if (sws_isSupportedInput(imgfmt2pixfmt(in_format)) < 1)
return 0;
int best = 0; int best = 0;
for (int n = 0; n < num_out_formats; n++) { for (int n = 0; n < num_out_formats; n++) {
int out_format = out_formats[n]; int out_format = out_formats[n];
if (sws_isSupportedOutput(imgfmt2pixfmt(out_format)) < 1) if (!mp_sws_supports_formats(sws->sws, out_format, in_format))
continue; continue;
if (best) { if (best) {

View File

@ -23,7 +23,8 @@ struct mp_sws_filter *mp_sws_filter_create(struct mp_filter *parent);
// formats. This tries to set the output format to the one that will result in // formats. This tries to set the output format to the one that will result in
// the least loss. Returns a format from out_formats[], or 0 if no format could // the least loss. Returns a format from out_formats[], or 0 if no format could
// be chosen (or it's not supported by libswscale). // be chosen (or it's not supported by libswscale).
int mp_sws_find_best_out_format(int in_format, int *out_formats, int mp_sws_find_best_out_format(struct mp_sws_filter *sws,
int in_format, int *out_formats,
int num_out_formats); int num_out_formats);
// Whether the given format is supported as input format. // Whether the given format is supported as input format.

View File

@ -202,6 +202,7 @@ void mp_sws_enable_cmdline_opts(struct mp_sws_context *ctx, struct mpv_global *g
ctx->opts_cache = m_config_cache_alloc(ctx, g, &sws_conf); ctx->opts_cache = m_config_cache_alloc(ctx, g, &sws_conf);
ctx->force_reload = true; ctx->force_reload = true;
mp_sws_update_from_cmdline(ctx);
#if HAVE_ZIMG #if HAVE_ZIMG
mp_zimg_enable_cmdline_opts(ctx->zimg, g); mp_zimg_enable_cmdline_opts(ctx->zimg, g);