mirror of
https://github.com/mpv-player/mpv
synced 2025-04-27 13:49:33 +00:00
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.
This commit is contained in:
parent
2fc3be582c
commit
fd5207f56d
@ -189,6 +189,7 @@ Command Line Switches
|
|||||||
``-spugauss`` ``--sub-gauss``
|
``-spugauss`` ``--sub-gauss``
|
||||||
``-srate`` ``--audio-samplerate``
|
``-srate`` ``--audio-samplerate``
|
||||||
``-ss`` ``--start``
|
``-ss`` ``--start``
|
||||||
|
``-ssf <sub>`` ``--sws-...``
|
||||||
``-stop-xscreensaver`` ``--stop-screensaver``
|
``-stop-xscreensaver`` ``--stop-screensaver``
|
||||||
``-sub-fuzziness`` ``--sub-auto``
|
``-sub-fuzziness`` ``--sub-auto``
|
||||||
``-sub`` ``--sub-file``
|
``-sub`` ``--sub-file``
|
||||||
@ -200,6 +201,7 @@ Command Line Switches
|
|||||||
``-subfont`` ``--sub-text-font``
|
``-subfont`` ``--sub-text-font``
|
||||||
``-subfps`` ``--sub-fps``
|
``-subfps`` ``--sub-fps``
|
||||||
``-subpos`` ``--sub-pos``
|
``-subpos`` ``--sub-pos``
|
||||||
|
``-sws`` ``--sws-scaler``
|
||||||
``-tvscan`` ``--tv-scan``
|
``-tvscan`` ``--tv-scan``
|
||||||
``-use-filename-title`` ``--title='${filename}'``
|
``-use-filename-title`` ``--title='${filename}'``
|
||||||
``-vc ffh264vdpau`` (etc.) ``--hwdec=vdpau``
|
``-vc ffh264vdpau`` (etc.) ``--hwdec=vdpau``
|
||||||
|
@ -2120,20 +2120,6 @@ OPTIONS
|
|||||||
|
|
||||||
Disabled by default.
|
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>``
|
``--sstep=<sec>``
|
||||||
Skip <sec> seconds after every frame.
|
Skip <sec> seconds after every frame.
|
||||||
|
|
||||||
@ -2309,29 +2295,32 @@ OPTIONS
|
|||||||
`--sub-speed=25/23.976`` plays frame based subtitles which have been
|
`--sub-speed=25/23.976`` plays frame based subtitles which have been
|
||||||
loaded assuming a framerate of 23.976 at 25 FPS.
|
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
|
Specify the software scaler algorithm to be used with ``--vf=scale``. This
|
||||||
also affects video output drivers which lack hardware acceleration,
|
also affects video output drivers which lack hardware acceleration,
|
||||||
e.g. ``x11``. See also ``--vf=scale``.
|
e.g. ``x11``. See also ``--vf=scale``.
|
||||||
|
|
||||||
Available types are:
|
To get a list of available scalers, run ``--sws-scaler=help``.
|
||||||
|
|
||||||
:0: fast bilinear
|
Default: ``bicubic``.
|
||||||
: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
|
|
||||||
|
|
||||||
.. note::
|
``--sws-lgb=<0-100>``
|
||||||
|
Software scaler gaussian blur filter (luma). See ``--sws-scaler``.
|
||||||
|
|
||||||
Some ``--sws`` options are tunable. The description of the ``scale``
|
``--sws-cgb=<0-100>``
|
||||||
video filter has further information.
|
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``.
|
||||||
|
|
||||||
|
``--sws-cvs=<v>``
|
||||||
|
Software scaler chroma vertical shifting. See ``--sws-scaler``.
|
||||||
|
|
||||||
``--term-osd, --no-term-osd``, ``--term-osd=force``
|
``--term-osd, --no-term-osd``, ``--term-osd=force``
|
||||||
Display OSD messages on the console when no video output is available.
|
Display OSD messages on the console when no video output is available.
|
||||||
|
@ -47,8 +47,6 @@
|
|||||||
extern const m_option_t demux_rawaudio_opts[];
|
extern const m_option_t demux_rawaudio_opts[];
|
||||||
extern const m_option_t demux_rawvideo_opts[];
|
extern const m_option_t demux_rawvideo_opts[];
|
||||||
|
|
||||||
extern int sws_flags;
|
|
||||||
|
|
||||||
extern const char mp_help_text[];
|
extern const char mp_help_text[];
|
||||||
|
|
||||||
static void print_version(struct mp_log *log)
|
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_pvr_conf;
|
||||||
extern const struct m_sub_options stream_cdda_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 stream_dvb_conf;
|
||||||
|
extern const struct m_sub_options sws_conf;
|
||||||
|
|
||||||
extern const m_option_t lavfdopts_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 double mf_fps;
|
||||||
extern char * mf_type;
|
extern char * mf_type;
|
||||||
extern const struct m_obj_list vf_obj_list;
|
extern const struct m_obj_list vf_obj_list;
|
||||||
@ -294,9 +276,8 @@ const m_option_t mp_opts[] = {
|
|||||||
{"vaapi-copy", 5})),
|
{"vaapi-copy", 5})),
|
||||||
OPT_STRING("hwdec-codecs", hwdec_codecs, 0),
|
OPT_STRING("hwdec-codecs", hwdec_codecs, 0),
|
||||||
|
|
||||||
// scaling:
|
OPT_SUBSTRUCT("sws", vo.sws_opts, sws_conf, 0),
|
||||||
{"sws", &sws_flags, CONF_TYPE_INT, 0, 0, 2, NULL},
|
|
||||||
{"ssf", (void *) scaler_filter_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
|
|
||||||
// -1 means auto aspect (prefer container size until aspect change)
|
// -1 means auto aspect (prefer container size until aspect change)
|
||||||
// 0 means square pixels
|
// 0 means square pixels
|
||||||
OPT_FLOATRANGE("video-aspect", movie_aspect, 0, -1.0, 10.0),
|
OPT_FLOATRANGE("video-aspect", movie_aspect, 0, -1.0, 10.0),
|
||||||
|
@ -38,6 +38,8 @@ typedef struct mp_vo_opts {
|
|||||||
int force_window_position;
|
int force_window_position;
|
||||||
|
|
||||||
int fs_missioncontrol;
|
int fs_missioncontrol;
|
||||||
|
|
||||||
|
struct sws_opts *sws_opts;
|
||||||
} mp_vo_opts;
|
} mp_vo_opts;
|
||||||
|
|
||||||
struct mp_cache_opts {
|
struct mp_cache_opts {
|
||||||
|
@ -275,6 +275,7 @@ static struct vf_instance *vf_open(struct vf_chain *c, const char *name,
|
|||||||
.hwdec = c->hwdec,
|
.hwdec = c->hwdec,
|
||||||
.query_format = vf_default_query_format,
|
.query_format = vf_default_query_format,
|
||||||
.out_pool = talloc_steal(vf, mp_image_pool_new(16)),
|
.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);
|
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)
|
if (m_config_apply_defaults(config, name, c->opts->vf_defs) < 0)
|
||||||
|
@ -93,6 +93,7 @@ typedef struct vf_instance {
|
|||||||
// Caches valid output formats.
|
// Caches valid output formats.
|
||||||
uint8_t last_outfmts[IMGFMT_END - IMGFMT_START];
|
uint8_t last_outfmts[IMGFMT_END - IMGFMT_START];
|
||||||
|
|
||||||
|
struct vf_chain *chain;
|
||||||
struct vf_instance *next;
|
struct vf_instance *next;
|
||||||
} vf_instance_t;
|
} vf_instance_t;
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ static int reconfig(struct vf_instance *vf, struct mp_image_params *in,
|
|||||||
}
|
}
|
||||||
mp_image_params_guess_csp(out);
|
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->v_chr_drop << SWS_SRC_V_CHR_DROP_SHIFT;
|
||||||
vf->priv->sws->flags |= vf->priv->accurate_rnd * SWS_ACCURATE_RND;
|
vf->priv->sws->flags |= vf->priv->accurate_rnd * SWS_ACCURATE_RND;
|
||||||
vf->priv->sws->src = *in;
|
vf->priv->sws->src = *in;
|
||||||
|
@ -510,7 +510,7 @@ static bool resize(struct priv *p)
|
|||||||
if (y != 0)
|
if (y != 0)
|
||||||
y = wl->window.height - p->dst_h;
|
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->src = p->in_format;
|
||||||
p->sws->dst = (struct mp_image_params) {
|
p->sws->dst = (struct mp_image_params) {
|
||||||
.imgfmt = p->video_format->mp_fmt,
|
.imgfmt = p->video_format->mp_fmt,
|
||||||
|
@ -370,7 +370,7 @@ static bool resize(struct vo *vo)
|
|||||||
}
|
}
|
||||||
p->bpp = p->myximage[0]->bits_per_pixel;
|
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->src = p->in_format;
|
||||||
p->sws->dst = (struct mp_image_params) {
|
p->sws->dst = (struct mp_image_params) {
|
||||||
.imgfmt = fmte->mpfmt,
|
.imgfmt = fmte->mpfmt,
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "sws_utils.h"
|
#include "sws_utils.h"
|
||||||
|
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
|
#include "options/m_option.h"
|
||||||
#include "video/mp_image.h"
|
#include "video/mp_image.h"
|
||||||
#include "video/img_format.h"
|
#include "video/img_format.h"
|
||||||
#include "fmt-conversion.h"
|
#include "fmt-conversion.h"
|
||||||
@ -35,14 +36,44 @@
|
|||||||
#include "video/filter/vf.h"
|
#include "video/filter/vf.h"
|
||||||
|
|
||||||
//global sws_flags from the command line
|
//global sws_flags from the command line
|
||||||
int sws_flags = 2;
|
struct sws_opts {
|
||||||
|
int scaler;
|
||||||
|
float lum_gblur;
|
||||||
|
float chr_gblur;
|
||||||
|
int chr_vshift;
|
||||||
|
int chr_hshift;
|
||||||
|
float chr_sharpen;
|
||||||
|
float lum_sharpen;
|
||||||
|
};
|
||||||
|
|
||||||
float sws_lum_gblur = 0.0;
|
#define OPT_BASE_STRUCT struct sws_opts
|
||||||
float sws_chr_gblur = 0.0;
|
const struct m_sub_options sws_conf = {
|
||||||
int sws_chr_vshift = 0;
|
.opts = (const m_option_t[]) {
|
||||||
int sws_chr_hshift = 0;
|
OPT_CHOICE("scaler", scaler, 0,
|
||||||
float sws_chr_sharpen = 0.0;
|
({"fast-bilinear", SWS_FAST_BILINEAR},
|
||||||
float sws_lum_sharpen = 0.0;
|
{"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.
|
// Highest quality, but also slowest.
|
||||||
const int mp_sws_hq_flags = SWS_LANCZOS | SWS_FULL_CHR_H_INT |
|
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;
|
const int mp_sws_fast_flags = SWS_BILINEAR;
|
||||||
|
|
||||||
// Set ctx parameters to global command line flags.
|
// 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);
|
sws_freeFilter(ctx->src_filter);
|
||||||
ctx->src_filter = sws_getDefaultFilter(sws_lum_gblur, sws_chr_gblur,
|
ctx->src_filter = sws_getDefaultFilter(opts->lum_gblur, opts->chr_gblur,
|
||||||
sws_lum_sharpen, sws_chr_sharpen,
|
opts->lum_sharpen, opts->chr_sharpen,
|
||||||
sws_chr_hshift, sws_chr_vshift, 0);
|
opts->chr_hshift, opts->chr_vshift, 0);
|
||||||
ctx->force_reload = true;
|
ctx->force_reload = true;
|
||||||
|
|
||||||
ctx->flags = SWS_PRINT_INFO;
|
ctx->flags = SWS_PRINT_INFO;
|
||||||
|
ctx->flags |= opts->scaler;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mp_sws_supported_format(int imgfmt)
|
bool mp_sws_supported_format(int imgfmt)
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
struct mp_image;
|
struct mp_image;
|
||||||
struct mp_csp_details;
|
struct mp_csp_details;
|
||||||
|
struct sws_opts;
|
||||||
|
|
||||||
// libswscale currently requires 16 bytes alignment for row pointers and
|
// libswscale currently requires 16 bytes alignment for row pointers and
|
||||||
// strides. Otherwise, it will print warnings and use slow codepaths.
|
// 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);
|
struct mp_sws_context *mp_sws_alloc(void *talloc_ctx);
|
||||||
int mp_sws_reinit(struct mp_sws_context *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,
|
int mp_sws_scale(struct mp_sws_context *ctx, struct mp_image *dst,
|
||||||
struct mp_image *src);
|
struct mp_image *src);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user