summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-01-16 11:49:23 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-01-18 00:59:07 -0800
commitca67928d7ab176c080a7e99f0d4ce0c5d1070844 (patch)
treeb58c0101645ab42ad482a8cac9e5446df8133116
parentc59db62f510dcb7c4bdff0d35fb1cce2c3b2c7a5 (diff)
downloadmpv-ca67928d7ab176c080a7e99f0d4ce0c5d1070844.tar.bz2
mpv-ca67928d7ab176c080a7e99f0d4ce0c5d1070844.tar.xz
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.
-rw-r--r--video/filter/vf_convert.c2
-rw-r--r--video/out/vo_drm.c2
-rw-r--r--video/out/vo_tct.c2
-rw-r--r--video/out/vo_x11.c2
-rw-r--r--video/sws_utils.c7
-rw-r--r--video/sws_utils.h4
6 files changed, 12 insertions, 7 deletions
diff --git a/video/filter/vf_convert.c b/video/filter/vf_convert.c
index 0714a532d0..7a7fdce228 100644
--- a/video/filter/vf_convert.c
+++ b/video/filter/vf_convert.c
@@ -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;
diff --git a/video/out/vo_drm.c b/video/out/vo_drm.c
index 24189d5b02..f32ed59b28 100644
--- a/video/out/vo_drm.c
+++ b/video/out/vo_drm.c
@@ -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,
diff --git a/video/out/vo_tct.c b/video/out/vo_tct.c
index dbe5d69fb6..6a07786996 100644
--- a/video/out/vo_tct.c
+++ b/video/out/vo_tct.c
@@ -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,
diff --git a/video/out/vo_x11.c b/video/out/vo_x11.c
index 9c7595e1d8..13b22d1bfb 100644
--- a/video/out/vo_x11.c
+++ b/video/out/vo_x11.c
@@ -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,
diff --git a/video/sws_utils.c b/video/sws_utils.c
index c8dcf5493d..79017699c4 100644
--- a/video/sws_utils.c
+++ b/video/sws_utils.c
@@ -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)
diff --git a/video/sws_utils.h b/video/sws_utils.h
index a3e91b3aa9..41472b5ecf 100644
--- a/video/sws_utils.h
+++ b/video/sws_utils.h
@@ -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);