summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-10 22:41:14 +0200
committerwm4 <wm4@nowhere>2014-06-11 00:39:13 +0200
commitfd5207f56d13f70a7750ac457dc5efdb514d9845 (patch)
treed2ff38fb1e1837467d25a5e4326c1ab695a8437a /video
parent2fc3be582c8c5aa510c92c7602ce72d5a1daa0ed (diff)
downloadmpv-fd5207f56d13f70a7750ac457dc5efdb514d9845.tar.bz2
mpv-fd5207f56d13f70a7750ac457dc5efdb514d9845.tar.xz
options: remove global variables for swscale options; rename them
Additionally to removing the global variables, this makes the options more uniform. --ssf-... becomes --sws-..., and --sws becomes --sws- scaler. For --sws-scaler, use choices instead of magic integer values.
Diffstat (limited to 'video')
-rw-r--r--video/filter/vf.c1
-rw-r--r--video/filter/vf.h1
-rw-r--r--video/filter/vf_scale.c2
-rw-r--r--video/out/vo_wayland.c2
-rw-r--r--video/out/vo_x11.c2
-rw-r--r--video/sws_utils.c71
-rw-r--r--video/sws_utils.h3
7 files changed, 51 insertions, 31 deletions
diff --git a/video/filter/vf.c b/video/filter/vf.c
index 32a376af3f..5326483444 100644
--- a/video/filter/vf.c
+++ b/video/filter/vf.c
@@ -275,6 +275,7 @@ static struct vf_instance *vf_open(struct vf_chain *c, const char *name,
.hwdec = c->hwdec,
.query_format = vf_default_query_format,
.out_pool = talloc_steal(vf, mp_image_pool_new(16)),
+ .chain = c,
};
struct m_config *config = m_config_from_obj_desc(vf, vf->log, &desc);
if (m_config_apply_defaults(config, name, c->opts->vf_defs) < 0)
diff --git a/video/filter/vf.h b/video/filter/vf.h
index 0e3a02b3a2..bfe573e618 100644
--- a/video/filter/vf.h
+++ b/video/filter/vf.h
@@ -93,6 +93,7 @@ typedef struct vf_instance {
// Caches valid output formats.
uint8_t last_outfmts[IMGFMT_END - IMGFMT_START];
+ struct vf_chain *chain;
struct vf_instance *next;
} vf_instance_t;
diff --git a/video/filter/vf_scale.c b/video/filter/vf_scale.c
index bcb4cae2f2..730994c12c 100644
--- a/video/filter/vf_scale.c
+++ b/video/filter/vf_scale.c
@@ -317,7 +317,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);
+ mp_sws_set_from_cmdline(vf->priv->sws, vf->chain->opts->vo.sws_opts);
vf->priv->sws->flags |= vf->priv->v_chr_drop << SWS_SRC_V_CHR_DROP_SHIFT;
vf->priv->sws->flags |= vf->priv->accurate_rnd * SWS_ACCURATE_RND;
vf->priv->sws->src = *in;
diff --git a/video/out/vo_wayland.c b/video/out/vo_wayland.c
index 54376d7e6d..7776bf4d4d 100644
--- a/video/out/vo_wayland.c
+++ b/video/out/vo_wayland.c
@@ -510,7 +510,7 @@ static bool resize(struct priv *p)
if (y != 0)
y = wl->window.height - p->dst_h;
- mp_sws_set_from_cmdline(p->sws);
+ mp_sws_set_from_cmdline(p->sws, p->vo->opts->sws_opts);
p->sws->src = p->in_format;
p->sws->dst = (struct mp_image_params) {
.imgfmt = p->video_format->mp_fmt,
diff --git a/video/out/vo_x11.c b/video/out/vo_x11.c
index a8b37d4016..26af641dbb 100644
--- a/video/out/vo_x11.c
+++ b/video/out/vo_x11.c
@@ -370,7 +370,7 @@ static bool resize(struct vo *vo)
}
p->bpp = p->myximage[0]->bits_per_pixel;
- mp_sws_set_from_cmdline(p->sws);
+ mp_sws_set_from_cmdline(p->sws, vo->opts->sws_opts);
p->sws->src = p->in_format;
p->sws->dst = (struct mp_image_params) {
.imgfmt = fmte->mpfmt,
diff --git a/video/sws_utils.c b/video/sws_utils.c
index d8fd492473..cd69802342 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_option.h"
#include "video/mp_image.h"
#include "video/img_format.h"
#include "fmt-conversion.h"
@@ -35,14 +36,44 @@
#include "video/filter/vf.h"
//global sws_flags from the command line
-int sws_flags = 2;
-
-float sws_lum_gblur = 0.0;
-float sws_chr_gblur = 0.0;
-int sws_chr_vshift = 0;
-int sws_chr_hshift = 0;
-float sws_chr_sharpen = 0.0;
-float sws_lum_sharpen = 0.0;
+struct sws_opts {
+ int scaler;
+ float lum_gblur;
+ float chr_gblur;
+ int chr_vshift;
+ int chr_hshift;
+ float chr_sharpen;
+ float lum_sharpen;
+};
+
+#define OPT_BASE_STRUCT struct sws_opts
+const struct m_sub_options sws_conf = {
+ .opts = (const m_option_t[]) {
+ OPT_CHOICE("scaler", scaler, 0,
+ ({"fast-bilinear", SWS_FAST_BILINEAR},
+ {"bilinear", SWS_BILINEAR},
+ {"bicubic", SWS_BICUBIC},
+ {"x", SWS_X},
+ {"point", SWS_POINT},
+ {"area", SWS_AREA},
+ {"bicublin", SWS_BICUBLIN},
+ {"gauss", SWS_GAUSS},
+ {"sinc", SWS_SINC},
+ {"lanczos", SWS_LANCZOS},
+ {"spline", SWS_SPLINE})),
+ OPT_FLOATRANGE("lgb", lum_gblur, 0, 0, 100.0),
+ OPT_FLOATRANGE("cgb", chr_gblur, 0, 0, 100.0),
+ OPT_INT("cvs", chr_vshift, 0),
+ OPT_INT("chs", chr_hshift, 0),
+ OPT_FLOATRANGE("ls", lum_sharpen, 0, -100.0, 100.0),
+ OPT_FLOATRANGE("cs", chr_sharpen, 0, -100.0, 100.0),
+ {0}
+ },
+ .size = sizeof(struct sws_opts),
+ .defaults = &(const struct sws_opts){
+ .scaler = SWS_BICUBIC,
+ },
+};
// Highest quality, but also slowest.
const int mp_sws_hq_flags = SWS_LANCZOS | SWS_FULL_CHR_H_INT |
@@ -53,30 +84,16 @@ 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)
+void mp_sws_set_from_cmdline(struct mp_sws_context *ctx, struct sws_opts *opts)
{
sws_freeFilter(ctx->src_filter);
- ctx->src_filter = sws_getDefaultFilter(sws_lum_gblur, sws_chr_gblur,
- sws_lum_sharpen, sws_chr_sharpen,
- sws_chr_hshift, sws_chr_vshift, 0);
+ ctx->src_filter = sws_getDefaultFilter(opts->lum_gblur, opts->chr_gblur,
+ opts->lum_sharpen, opts->chr_sharpen,
+ opts->chr_hshift, opts->chr_vshift, 0);
ctx->force_reload = true;
ctx->flags = SWS_PRINT_INFO;
-
- switch (sws_flags) {
- case 0: ctx->flags |= SWS_FAST_BILINEAR; break;
- case 1: ctx->flags |= SWS_BILINEAR; break;
- case 2: ctx->flags |= SWS_BICUBIC; break;
- case 3: ctx->flags |= SWS_X; break;
- case 4: ctx->flags |= SWS_POINT; break;
- case 5: ctx->flags |= SWS_AREA; break;
- case 6: ctx->flags |= SWS_BICUBLIN; break;
- case 7: ctx->flags |= SWS_GAUSS; break;
- case 8: ctx->flags |= SWS_SINC; break;
- case 9: ctx->flags |= SWS_LANCZOS; break;
- case 10: ctx->flags |= SWS_SPLINE; break;
- default: ctx->flags |= SWS_BILINEAR; break;
- }
+ ctx->flags |= opts->scaler;
}
bool mp_sws_supported_format(int imgfmt)
diff --git a/video/sws_utils.h b/video/sws_utils.h
index d20e197197..212e1405b4 100644
--- a/video/sws_utils.h
+++ b/video/sws_utils.h
@@ -7,6 +7,7 @@
struct mp_image;
struct mp_csp_details;
+struct sws_opts;
// libswscale currently requires 16 bytes alignment for row pointers and
// strides. Otherwise, it will print warnings and use slow codepaths.
@@ -51,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);
+void mp_sws_set_from_cmdline(struct mp_sws_context *ctx, struct sws_opts *opts);
int mp_sws_scale(struct mp_sws_context *ctx, struct mp_image *dst,
struct mp_image *src);