diff options
author | wm4 <wm4@nowhere> | 2014-06-10 22:41:14 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-06-11 00:39:13 +0200 |
commit | fd5207f56d13f70a7750ac457dc5efdb514d9845 (patch) | |
tree | d2ff38fb1e1837467d25a5e4326c1ab695a8437a | |
parent | 2fc3be582c8c5aa510c92c7602ce72d5a1daa0ed (diff) | |
download | mpv-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.
-rw-r--r-- | DOCS/man/en/changes.rst | 2 | ||||
-rw-r--r-- | DOCS/man/en/options.rst | 49 | ||||
-rw-r--r-- | options/options.c | 25 | ||||
-rw-r--r-- | options/options.h | 2 | ||||
-rw-r--r-- | video/filter/vf.c | 1 | ||||
-rw-r--r-- | video/filter/vf.h | 1 | ||||
-rw-r--r-- | video/filter/vf_scale.c | 2 | ||||
-rw-r--r-- | video/out/vo_wayland.c | 2 | ||||
-rw-r--r-- | video/out/vo_x11.c | 2 | ||||
-rw-r--r-- | video/sws_utils.c | 71 | ||||
-rw-r--r-- | video/sws_utils.h | 3 |
11 files changed, 77 insertions, 83 deletions
diff --git a/DOCS/man/en/changes.rst b/DOCS/man/en/changes.rst index 1387d03372..01a210fae8 100644 --- a/DOCS/man/en/changes.rst +++ b/DOCS/man/en/changes.rst @@ -189,6 +189,7 @@ Command Line Switches ``-spugauss`` ``--sub-gauss`` ``-srate`` ``--audio-samplerate`` ``-ss`` ``--start`` + ``-ssf <sub>`` ``--sws-...`` ``-stop-xscreensaver`` ``--stop-screensaver`` ``-sub-fuzziness`` ``--sub-auto`` ``-sub`` ``--sub-file`` @@ -200,6 +201,7 @@ Command Line Switches ``-subfont`` ``--sub-text-font`` ``-subfps`` ``--sub-fps`` ``-subpos`` ``--sub-pos`` + ``-sws`` ``--sws-scaler`` ``-tvscan`` ``--tv-scan`` ``-use-filename-title`` ``--title='${filename}'`` ``-vc ffh264vdpau`` (etc.) ``--hwdec=vdpau`` diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index 44219a35e9..d2ae257d91 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -2120,20 +2120,6 @@ OPTIONS Disabled by default. -``--ssf=<mode>`` - Specifies software scaler parameters. - - :lgb=<0-100>: gaussian blur filter (luma) - :cgb=<0-100>: gaussian blur filter (chroma) - :ls=<-100-100>: sharpen filter (luma) - :cs=<-100-100>: sharpen filter (chroma) - :chs=<h>: chroma horizontal shifting - :cvs=<v>: chroma vertical shifting - - .. admonition:: Example - - ``--vf=scale --ssf=lgb=3.0`` - ``--sstep=<sec>`` Skip <sec> seconds after every frame. @@ -2309,29 +2295,32 @@ OPTIONS `--sub-speed=25/23.976`` plays frame based subtitles which have been loaded assuming a framerate of 23.976 at 25 FPS. -``--sws=<n>`` +``--sws-scaler=<name>`` Specify the software scaler algorithm to be used with ``--vf=scale``. This also affects video output drivers which lack hardware acceleration, e.g. ``x11``. See also ``--vf=scale``. - Available types are: + To get a list of available scalers, run ``--sws-scaler=help``. - :0: fast bilinear - :1: bilinear - :2: bicubic (good quality) (default) - :3: experimental - :4: nearest neighbor (bad quality) - :5: area - :6: luma bicubic / chroma bilinear - :7: gauss - :8: sincR - :9: lanczos - :10: natural bicubic spline + Default: ``bicubic``. - .. note:: +``--sws-lgb=<0-100>`` + Software scaler gaussian blur filter (luma). See ``--sws-scaler``. + +``--sws-cgb=<0-100>`` + Software scaler gaussian blur filter (chroma). See ``--sws-scaler``. + +``--sws-ls=<-100-100>`` + Software scaler sharpen filter (luma). See ``--sws-scaler``. + +``--sws-cs=<-100-100>`` + Software scaler sharpen filter (chroma). See ``--sws-scaler``. + +``--sws-chs=<h>`` + Software scaler chroma horizontal shifting. See ``--sws-scaler``. - Some ``--sws`` options are tunable. The description of the ``scale`` - video filter has further information. +``--sws-cvs=<v>`` + Software scaler chroma vertical shifting. See ``--sws-scaler``. ``--term-osd, --no-term-osd``, ``--term-osd=force`` Display OSD messages on the console when no video output is available. diff --git a/options/options.c b/options/options.c index 09820aa6bf..ef88cab829 100644 --- a/options/options.c +++ b/options/options.c @@ -47,8 +47,6 @@ extern const m_option_t demux_rawaudio_opts[]; extern const m_option_t demux_rawvideo_opts[]; -extern int sws_flags; - extern const char mp_help_text[]; static void print_version(struct mp_log *log) @@ -65,26 +63,10 @@ extern const struct m_sub_options tv_params_conf; extern const struct m_sub_options stream_pvr_conf; extern const struct m_sub_options stream_cdda_conf; extern const struct m_sub_options stream_dvb_conf; +extern const struct m_sub_options sws_conf; extern const m_option_t lavfdopts_conf[]; -extern int sws_chr_vshift; -extern int sws_chr_hshift; -extern float sws_chr_gblur; -extern float sws_lum_gblur; -extern float sws_chr_sharpen; -extern float sws_lum_sharpen; - -static const m_option_t scaler_filter_conf[]={ - {"lgb", &sws_lum_gblur, CONF_TYPE_FLOAT, 0, 0, 100.0, NULL}, - {"cgb", &sws_chr_gblur, CONF_TYPE_FLOAT, 0, 0, 100.0, NULL}, - {"cvs", &sws_chr_vshift, CONF_TYPE_INT, 0, 0, 0, NULL}, - {"chs", &sws_chr_hshift, CONF_TYPE_INT, 0, 0, 0, NULL}, - {"ls", &sws_lum_sharpen, CONF_TYPE_FLOAT, 0, -100.0, 100.0, NULL}, - {"cs", &sws_chr_sharpen, CONF_TYPE_FLOAT, 0, -100.0, 100.0, NULL}, - {NULL, NULL, 0, 0, 0, 0, NULL} -}; - extern double mf_fps; extern char * mf_type; extern const struct m_obj_list vf_obj_list; @@ -294,9 +276,8 @@ const m_option_t mp_opts[] = { {"vaapi-copy", 5})), OPT_STRING("hwdec-codecs", hwdec_codecs, 0), - // scaling: - {"sws", &sws_flags, CONF_TYPE_INT, 0, 0, 2, NULL}, - {"ssf", (void *) scaler_filter_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL}, + OPT_SUBSTRUCT("sws", vo.sws_opts, sws_conf, 0), + // -1 means auto aspect (prefer container size until aspect change) // 0 means square pixels OPT_FLOATRANGE("video-aspect", movie_aspect, 0, -1.0, 10.0), diff --git a/options/options.h b/options/options.h index 7e8c22451d..cc57795446 100644 --- a/options/options.h +++ b/options/options.h @@ -38,6 +38,8 @@ typedef struct mp_vo_opts { int force_window_position; int fs_missioncontrol; + + struct sws_opts *sws_opts; } mp_vo_opts; struct mp_cache_opts { 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); |