mirror of
https://github.com/mpv-player/mpv
synced 2025-03-04 13:18:12 +00:00
options: use new code for parsing --vo
Nothing should change from user perspective. mpv --vo=opengl:help now works. Remove the vo_opengl inline help text. The new code can list option names for you, but that's it. Refer to the manpage if you have trouble.
This commit is contained in:
parent
999dad454f
commit
c1afd75142
@ -700,6 +700,9 @@ static void load_per_output_config(m_config_t *conf, char *cfg, char *out)
|
||||
char profile[strlen(cfg) + strlen(out) + 1];
|
||||
m_profile_t *p;
|
||||
|
||||
if (!out && !out[0])
|
||||
return;
|
||||
|
||||
sprintf(profile, "%s%s", cfg, out);
|
||||
p = m_config_get_profile(conf, profile);
|
||||
if (p) {
|
||||
@ -4102,7 +4105,7 @@ static void play_current_file(struct MPContext *mpctx)
|
||||
|
||||
if (opts->vo.video_driver_list)
|
||||
load_per_output_config(mpctx->mconfig, PROFILE_CFG_VO,
|
||||
opts->vo.video_driver_list[0]);
|
||||
opts->vo.video_driver_list[0].name);
|
||||
if (opts->audio_driver_list)
|
||||
load_per_output_config(mpctx->mconfig, PROFILE_CFG_AO,
|
||||
opts->audio_driver_list[0]);
|
||||
@ -4492,11 +4495,6 @@ static bool handle_help_options(struct MPContext *mpctx)
|
||||
{
|
||||
struct MPOpts *opts = &mpctx->opts;
|
||||
int opt_exit = 0;
|
||||
if (opts->vo.video_driver_list &&
|
||||
strcmp(opts->vo.video_driver_list[0], "help") == 0) {
|
||||
list_video_out();
|
||||
opt_exit = 1;
|
||||
}
|
||||
if (opts->audio_driver_list &&
|
||||
strcmp(opts->audio_driver_list[0], "help") == 0) {
|
||||
list_audio_out();
|
||||
|
@ -182,6 +182,7 @@ extern char *dvd_device, *cdrom_device;
|
||||
extern double mf_fps;
|
||||
extern char * mf_type;
|
||||
extern const struct m_obj_list vf_obj_list;
|
||||
extern const struct m_obj_list vo_obj_list;
|
||||
|
||||
static const m_option_t mfopts_conf[]={
|
||||
{"fps", &mf_fps, CONF_TYPE_DOUBLE, 0, 0, 0, NULL},
|
||||
@ -518,7 +519,7 @@ const m_option_t mp_opts[] = {
|
||||
OPT_SUBSTRUCT("sub-text", sub_text_style, osd_style_conf, 0),
|
||||
|
||||
//---------------------- libao/libvo options ------------------------
|
||||
OPT_STRINGLIST("vo", vo.video_driver_list, 0),
|
||||
OPT_SETTINGSLIST("vo", vo.video_driver_list, 0, &vo_obj_list),
|
||||
OPT_STRINGLIST("ao", audio_driver_list, 0),
|
||||
OPT_FLAG("fixed-vo", fixed_vo, CONF_GLOBAL),
|
||||
OPT_FLAG("ontop", vo.ontop, 0),
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "core/m_option.h"
|
||||
|
||||
typedef struct mp_vo_opts {
|
||||
char **video_driver_list;
|
||||
struct m_obj_settings *video_driver_list;
|
||||
|
||||
int screenwidth;
|
||||
int screenheight;
|
||||
|
183
video/out/vo.c
183
video/out/vo.c
@ -103,35 +103,67 @@ const struct vo_driver *video_out_drivers[] =
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
static int vo_preinit(struct vo *vo, char *arg)
|
||||
static bool get_desc(struct m_obj_desc *dst, int index)
|
||||
{
|
||||
if (index >= MP_ARRAY_SIZE(video_out_drivers) - 1)
|
||||
return false;
|
||||
const struct vo_driver *vo = video_out_drivers[index];
|
||||
*dst = (struct m_obj_desc) {
|
||||
.name = vo->info->short_name,
|
||||
.description = vo->info->name,
|
||||
.priv_size = vo->priv_size,
|
||||
.priv_defaults = vo->priv_defaults,
|
||||
.options = vo->options,
|
||||
.init_options = vo->init_option_string,
|
||||
.p = vo,
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
// For the vo option
|
||||
const struct m_obj_list vo_obj_list = {
|
||||
.get_desc = get_desc,
|
||||
.description = "video outputs",
|
||||
.aliases = {
|
||||
{"gl", "opengl"},
|
||||
{"gl3", "opengl-hq"},
|
||||
{0}
|
||||
},
|
||||
.allow_unknown_entries = true,
|
||||
.allow_trailer = true,
|
||||
};
|
||||
|
||||
static struct vo *vo_create(struct mp_vo_opts *opts,
|
||||
struct input_ctx *input_ctx,
|
||||
struct encode_lavc_context *encode_lavc_ctx,
|
||||
char *name, char **args)
|
||||
{
|
||||
struct m_obj_desc desc;
|
||||
if (!m_obj_list_find(&desc, &vo_obj_list, bstr0(name))) {
|
||||
mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "Video output %s not found!\n", name);
|
||||
return NULL;
|
||||
};
|
||||
struct vo *vo = talloc_ptrtype(NULL, vo);
|
||||
*vo = (struct vo) {
|
||||
.driver = desc.p,
|
||||
.opts = opts,
|
||||
.encode_lavc_ctx = encode_lavc_ctx,
|
||||
.input_ctx = input_ctx,
|
||||
.event_fd = -1,
|
||||
.registered_fd = -1,
|
||||
.aspdat = { .monitor_par = 1 },
|
||||
};
|
||||
if (vo->driver->encode != !!vo->encode_lavc_ctx)
|
||||
return -1;
|
||||
if (vo->driver->priv_size) {
|
||||
vo->priv = talloc_zero_size(vo, vo->driver->priv_size);
|
||||
if (vo->driver->priv_defaults)
|
||||
memcpy(vo->priv, vo->driver->priv_defaults, vo->driver->priv_size);
|
||||
}
|
||||
if (vo->driver->options) {
|
||||
struct m_config *cfg = m_config_simple(vo->priv);
|
||||
talloc_steal(vo->priv, cfg);
|
||||
m_config_register_options(cfg, vo->driver->options);
|
||||
char n[50];
|
||||
int l = snprintf(n, sizeof(n), "vo/%s", vo->driver->info->short_name);
|
||||
assert(l < sizeof(n));
|
||||
if (vo->driver->init_option_string) {
|
||||
m_config_parse_suboptions(cfg, n,
|
||||
(char *)vo->driver->init_option_string);
|
||||
}
|
||||
int r = m_config_parse_suboptions(cfg, n, arg);
|
||||
if (r < 0) {
|
||||
if (vo->driver->help_text)
|
||||
mp_msg(MSGT_VO, MSGL_FATAL, "%s\n", vo->driver->help_text);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
return vo->driver->preinit(vo, arg);
|
||||
goto error;
|
||||
struct m_config *config = m_config_from_obj_desc(vo, &desc);
|
||||
if (m_config_initialize_obj(config, &desc, &vo->priv, &args) < 0)
|
||||
goto error;
|
||||
if (vo->driver->preinit(vo, (char *)args))
|
||||
goto error;
|
||||
return vo;
|
||||
error:
|
||||
talloc_free(vo);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int vo_control(struct vo *vo, uint32_t request, void *data)
|
||||
@ -255,89 +287,32 @@ void vo_destroy(struct vo *vo)
|
||||
talloc_free(vo);
|
||||
}
|
||||
|
||||
void list_video_out(void)
|
||||
{
|
||||
mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "Available video output drivers:\n");
|
||||
mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_OUTPUTS\n");
|
||||
for (int i = 0; video_out_drivers[i]; i++) {
|
||||
const vo_info_t *info = video_out_drivers[i]->info;
|
||||
if (!video_out_drivers[i]->encode) {
|
||||
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n",
|
||||
info->short_name, info->name);
|
||||
}
|
||||
}
|
||||
mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
|
||||
}
|
||||
|
||||
static void replace_legacy_vo_name(bstr *name)
|
||||
{
|
||||
bstr new = *name;
|
||||
if (bstr_equals0(*name, "gl"))
|
||||
new = bstr0("opengl");
|
||||
if (bstr_equals0(*name, "gl3"))
|
||||
new = bstr0("opengl-hq");
|
||||
if (!bstr_equals(*name, new)) {
|
||||
mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "VO driver '%.*s' has been replaced "
|
||||
"with '%.*s'!\n", BSTR_P(*name), BSTR_P(new));
|
||||
}
|
||||
*name = new;
|
||||
}
|
||||
|
||||
struct vo *init_best_video_out(struct mp_vo_opts *opts,
|
||||
struct input_ctx *input_ctx,
|
||||
struct encode_lavc_context *encode_lavc_ctx)
|
||||
{
|
||||
char **vo_list = opts->video_driver_list;
|
||||
int i;
|
||||
struct vo *vo = talloc_ptrtype(NULL, vo);
|
||||
struct vo initial_values = {
|
||||
.opts = opts,
|
||||
.encode_lavc_ctx = encode_lavc_ctx,
|
||||
.input_ctx = input_ctx,
|
||||
.event_fd = -1,
|
||||
.registered_fd = -1,
|
||||
.aspdat = { .monitor_par = 1 },
|
||||
};
|
||||
struct m_obj_settings *vo_list = opts->video_driver_list;
|
||||
// first try the preferred drivers, with their optional subdevice param:
|
||||
if (vo_list && vo_list[0])
|
||||
while (vo_list[0][0]) {
|
||||
char *arg = vo_list[0];
|
||||
bstr name = bstr0(arg);
|
||||
char *params = strchr(arg, ':');
|
||||
if (params) {
|
||||
name = bstr_splice(name, 0, params - arg);
|
||||
params++;
|
||||
}
|
||||
replace_legacy_vo_name(&name);
|
||||
for (i = 0; video_out_drivers[i]; i++) {
|
||||
const struct vo_driver *video_driver = video_out_drivers[i];
|
||||
const vo_info_t *info = video_driver->info;
|
||||
if (bstr_equals0(name, info->short_name)) {
|
||||
// name matches, try it
|
||||
*vo = initial_values;
|
||||
vo->driver = video_driver;
|
||||
if (!vo_preinit(vo, params))
|
||||
return vo; // success!
|
||||
talloc_free_children(vo);
|
||||
}
|
||||
}
|
||||
// continue...
|
||||
++vo_list;
|
||||
if (!(vo_list[0])) {
|
||||
talloc_free(vo);
|
||||
return NULL; // do NOT fallback to others
|
||||
}
|
||||
}
|
||||
// now try the rest...
|
||||
for (i = 0; video_out_drivers[i]; i++) {
|
||||
const struct vo_driver *video_driver = video_out_drivers[i];
|
||||
*vo = initial_values;
|
||||
vo->driver = video_driver;
|
||||
if (!vo_preinit(vo, NULL))
|
||||
return vo; // success!
|
||||
talloc_free_children(vo);
|
||||
if (vo_list && vo_list[0].name) {
|
||||
for (int n = 0; vo_list[n].name; n++) {
|
||||
// Something like "-vo name," allows fallback to autoprobing.
|
||||
if (strlen(vo_list[n].name) == 0)
|
||||
goto autoprobe;
|
||||
struct vo *vo = vo_create(opts, input_ctx, encode_lavc_ctx,
|
||||
vo_list[n].name, vo_list[n].attribs);
|
||||
if (vo)
|
||||
return vo;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
autoprobe:
|
||||
// now try the rest...
|
||||
for (int i = 0; video_out_drivers[i]; i++) {
|
||||
struct vo *vo = vo_create(opts, input_ctx, encode_lavc_ctx,
|
||||
(char *)video_out_drivers[i]->info->short_name, NULL);
|
||||
if (vo)
|
||||
return vo;
|
||||
}
|
||||
talloc_free(vo);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -230,9 +230,6 @@ struct vo_driver {
|
||||
// List of options to parse into priv struct (requires privsize to be set)
|
||||
const struct m_option *options;
|
||||
|
||||
// Help text to print when option parsing fails
|
||||
const char *help_text;
|
||||
|
||||
// Parse these options before parsing user options
|
||||
const char *init_option_string;
|
||||
};
|
||||
@ -291,7 +288,6 @@ struct vo *init_best_video_out(struct mp_vo_opts *opts,
|
||||
struct input_ctx *input_ctx,
|
||||
struct encode_lavc_context *encode_lavc_ctx);
|
||||
int vo_reconfig(struct vo *vo, struct mp_image_params *p, int flags);
|
||||
void list_video_out(void);
|
||||
|
||||
int vo_control(struct vo *vo, uint32_t request, void *data);
|
||||
void vo_queue_image(struct vo *vo, struct mp_image *mpi);
|
||||
|
@ -364,8 +364,6 @@ const struct m_option options[] = {
|
||||
{0},
|
||||
};
|
||||
|
||||
static const char help_text[];
|
||||
|
||||
const struct vo_driver video_out_opengl = {
|
||||
.info = &(const vo_info_t) {
|
||||
"Extended OpenGL Renderer",
|
||||
@ -383,7 +381,6 @@ const struct vo_driver video_out_opengl = {
|
||||
.uninit = uninit,
|
||||
.priv_size = sizeof(struct gl_priv),
|
||||
.options = options,
|
||||
.help_text = help_text,
|
||||
};
|
||||
|
||||
const struct vo_driver video_out_opengl_hq = {
|
||||
@ -403,39 +400,5 @@ const struct vo_driver video_out_opengl_hq = {
|
||||
.uninit = uninit,
|
||||
.priv_size = sizeof(struct gl_priv),
|
||||
.options = options,
|
||||
.help_text = help_text,
|
||||
.init_option_string = "lscale=lanczos2:dither-depth=auto:pbo:fbo-format=rgb16",
|
||||
};
|
||||
|
||||
static const char help_text[] =
|
||||
"\n--vo=opengl command line help:\n"
|
||||
"Example: mpv --vo=opengl:scale-sep:lscale=lanczos2\n"
|
||||
"\nOptions:\n"
|
||||
" lscale=<filter>\n"
|
||||
" Set the scaling filter. Includes, but is not limited to:\n"
|
||||
" bilinear: bilinear texture filtering (fastest).\n"
|
||||
" bicubic_fast: bicubic filter (without lookup texture).\n"
|
||||
" sharpen3: unsharp masking (sharpening) with radius=3.\n"
|
||||
" sharpen5: unsharp masking (sharpening) with radius=5.\n"
|
||||
" lanczos2: Lanczos with radius=2 (recommended).\n"
|
||||
" lanczos3: Lanczos with radius=3 (not recommended).\n"
|
||||
" mitchell: Mitchell-Netravali.\n"
|
||||
" Default: bilinear\n"
|
||||
" lparam1=<value> / lparam2=<value>\n"
|
||||
" Set parameters for configurable filters. Affects chroma scaler\n"
|
||||
" as well.\n"
|
||||
" Filters which use this:\n"
|
||||
" mitchell: b and c params (defaults: b=1/3 c=1/3)\n"
|
||||
" kaiser: (defaults: 6.33 6.33)\n"
|
||||
" sharpen3: lparam1 sets sharpening strength (default: 0.5)\n"
|
||||
" sharpen5: as with sharpen3\n"
|
||||
" cscale=<n>\n"
|
||||
" As lscale but for chroma (Much slower with little visible effect).\n"
|
||||
" For details, refer to the man-pages (see link below).\n"
|
||||
"\n"
|
||||
"Note: all defaults mentioned are for 'opengl', not 'opengl-hq'.\n"
|
||||
" 'opengl-hq' is merely 'opengl' with different default settings applied.\n"
|
||||
"\n"
|
||||
"There are many more options. Read:\n"
|
||||
" https://github.com/mpv-player/mpv/blob/master/DOCS/man/en/vo.rst#vo-opengl\n"
|
||||
"\n";
|
||||
|
Loading…
Reference in New Issue
Block a user