mirror of https://github.com/mpv-player/mpv
sws_utils: don't force callers to provide option struct
mp_sws_set_from_cmdline() has the only purpose to respect the --sws- command line options. Instead of forcing callers to get the option struct containing these, let callers pass mpv_global, and get it from the option core code directly. This avoids minor annoyances later on.
This commit is contained in:
parent
c59db62f51
commit
ca67928d7a
|
@ -78,7 +78,7 @@ static int reconfig(struct vf_instance *vf, struct mp_image_params *in,
|
|||
|
||||
mp_image_params_guess_csp(out);
|
||||
|
||||
mp_sws_set_from_cmdline(vf->priv->sws, vf->chain->opts->vo->sws_opts);
|
||||
mp_sws_set_from_cmdline(vf->priv->sws, vf->chain->global);
|
||||
vf->priv->sws->src = *in;
|
||||
vf->priv->sws->dst = *out;
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ static int reconfig(struct vo *vo, struct mp_image_params *params)
|
|||
p->osd.mr = MPMIN(0, p->osd.mr);
|
||||
p->osd.ml = MPMIN(0, p->osd.ml);
|
||||
|
||||
mp_sws_set_from_cmdline(p->sws, vo->opts->sws_opts);
|
||||
mp_sws_set_from_cmdline(p->sws, vo->global);
|
||||
p->sws->src = *params;
|
||||
p->sws->dst = (struct mp_image_params) {
|
||||
.imgfmt = IMGFMT,
|
||||
|
|
|
@ -207,7 +207,7 @@ static int reconfig(struct vo *vo, struct mp_image_params *params)
|
|||
if (p->buffer)
|
||||
free(p->buffer);
|
||||
|
||||
mp_sws_set_from_cmdline(p->sws, vo->opts->sws_opts);
|
||||
mp_sws_set_from_cmdline(p->sws, vo->global);
|
||||
p->sws->src = *params;
|
||||
p->sws->dst = (struct mp_image_params) {
|
||||
.imgfmt = IMGFMT,
|
||||
|
|
|
@ -244,7 +244,7 @@ static bool resize(struct vo *vo)
|
|||
return -1;
|
||||
}
|
||||
|
||||
mp_sws_set_from_cmdline(p->sws, vo->opts->sws_opts);
|
||||
mp_sws_set_from_cmdline(p->sws, vo->global);
|
||||
p->sws->dst = (struct mp_image_params) {
|
||||
.imgfmt = fmte->mpfmt,
|
||||
.w = p->dst_w,
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "sws_utils.h"
|
||||
|
||||
#include "common/common.h"
|
||||
#include "options/m_config.h"
|
||||
#include "options/m_option.h"
|
||||
#include "video/mp_image.h"
|
||||
#include "video/img_format.h"
|
||||
|
@ -84,8 +85,10 @@ const int mp_sws_hq_flags = SWS_LANCZOS | SWS_FULL_CHR_H_INT |
|
|||
const int mp_sws_fast_flags = SWS_BILINEAR;
|
||||
|
||||
// Set ctx parameters to global command line flags.
|
||||
void mp_sws_set_from_cmdline(struct mp_sws_context *ctx, struct sws_opts *opts)
|
||||
void mp_sws_set_from_cmdline(struct mp_sws_context *ctx, struct mpv_global *g)
|
||||
{
|
||||
struct sws_opts *opts = mp_get_config_group(NULL, g, &sws_conf);
|
||||
|
||||
sws_freeFilter(ctx->src_filter);
|
||||
ctx->src_filter = sws_getDefaultFilter(opts->lum_gblur, opts->chr_gblur,
|
||||
opts->lum_sharpen, opts->chr_sharpen,
|
||||
|
@ -94,6 +97,8 @@ void mp_sws_set_from_cmdline(struct mp_sws_context *ctx, struct sws_opts *opts)
|
|||
|
||||
ctx->flags = SWS_PRINT_INFO;
|
||||
ctx->flags |= opts->scaler;
|
||||
|
||||
talloc_free(opts);
|
||||
}
|
||||
|
||||
bool mp_sws_supported_format(int imgfmt)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "mp_image.h"
|
||||
|
||||
struct mp_image;
|
||||
struct sws_opts;
|
||||
struct mpv_global;
|
||||
|
||||
// libswscale currently requires 16 bytes alignment for row pointers and
|
||||
// strides. Otherwise, it will print warnings and use slow codepaths.
|
||||
|
@ -52,7 +52,7 @@ struct mp_sws_context {
|
|||
|
||||
struct mp_sws_context *mp_sws_alloc(void *talloc_ctx);
|
||||
int mp_sws_reinit(struct mp_sws_context *ctx);
|
||||
void mp_sws_set_from_cmdline(struct mp_sws_context *ctx, struct sws_opts *opts);
|
||||
void mp_sws_set_from_cmdline(struct mp_sws_context *ctx, struct mpv_global *g);
|
||||
int mp_sws_scale(struct mp_sws_context *ctx, struct mp_image *dst,
|
||||
struct mp_image *src);
|
||||
|
||||
|
|
Loading…
Reference in New Issue