1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-23 15:22:09 +00:00

sws_utils: allow setting zimg options directly

One could wonder, why not just use the zimg wrapper directly?
This commit is contained in:
wm4 2020-05-09 17:56:21 +02:00
parent 43591ba96b
commit d61ced37ae
4 changed files with 18 additions and 8 deletions

View File

@ -244,6 +244,8 @@ int mp_sws_reinit(struct mp_sws_context *ctx)
ctx->zimg->log = ctx->log;
ctx->zimg->src = *src;
ctx->zimg->dst = *dst;
if (ctx->zimg_opts)
ctx->zimg->opts = *ctx->zimg_opts;
if (mp_zimg_config(ctx->zimg)) {
ctx->zimg_ok = true;
MP_VERBOSE(ctx, "Using zimg.\n");

View File

@ -44,6 +44,10 @@ struct mp_sws_context {
// This is unfortunately a hack: bypass command line choice
enum mp_sws_scaler force_scaler;
// If zimg is used. Need to manually invalidate cache (set force_reload).
// Conflicts with enabling command line opts.
struct zimg_opts *zimg_opts;
// Changing these requires setting force_reload=true.
// By default, they are NULL.
// Freeing the mp_sws_context will deallocate these if set.

View File

@ -43,6 +43,15 @@ static const struct m_opt_choice_alternatives mp_zimg_scalers[] = {
{0}
};
const struct zimg_opts zimg_opts_defaults = {
.scaler = ZIMG_RESIZE_LANCZOS,
.scaler_params = {NAN, NAN},
.scaler_chroma_params = {NAN, NAN},
.scaler_chroma = ZIMG_RESIZE_BILINEAR,
.dither = ZIMG_DITHER_RANDOM,
.fast = 1,
};
#define OPT_PARAM(var) OPT_DOUBLE(var), .flags = M_OPT_DEFAULT_NAN
#define OPT_BASE_STRUCT struct zimg_opts
@ -63,14 +72,7 @@ const struct m_sub_options zimg_conf = {
{0}
},
.size = sizeof(struct zimg_opts),
.defaults = &(const struct zimg_opts){
.scaler = ZIMG_RESIZE_LANCZOS,
.scaler_params = {NAN, NAN},
.scaler_chroma_params = {NAN, NAN},
.scaler_chroma = ZIMG_RESIZE_BILINEAR,
.dither = ZIMG_DITHER_RANDOM,
.fast = 1,
},
.defaults = &zimg_opts_defaults,
};
struct mp_zimg_repack {

View File

@ -22,6 +22,8 @@ struct zimg_opts {
int fast;
};
extern const struct zimg_opts zimg_opts_defaults;
struct mp_zimg_context {
// Can be set for verbose error printing.
struct mp_log *log;