summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-01 00:12:10 +0100
committerwm4 <wm4@nowhere>2013-12-01 00:12:10 +0100
commitb18f02d1ad5e5ce4031438f1cd0f1f3aaaf83003 (patch)
treeb723192a213fbdb0b64a742c91bc106237e5d539 /mpvcore
parentaaddcb702ef93eac9087852202a59f91abb31433 (diff)
downloadmpv-b18f02d1ad5e5ce4031438f1cd0f1f3aaaf83003.tar.bz2
mpv-b18f02d1ad5e5ce4031438f1cd0f1f3aaaf83003.tar.xz
options: add options that set defaults for af/vf/ao/vo
There are some use cases for this. For example, you can use it to set defaults of automatically inserted filters (like af_lavrresample). It's also useful if you have a non-trivial VO configuration, and want to use --vo to quickly change between the drivers without repeating the whole configuration in the --vo argument.
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/m_config.c20
-rw-r--r--mpvcore/m_config.h6
-rw-r--r--mpvcore/options.c4
-rw-r--r--mpvcore/options.h8
4 files changed, 34 insertions, 4 deletions
diff --git a/mpvcore/m_config.c b/mpvcore/m_config.c
index 7ada99e068..2d6cc5a554 100644
--- a/mpvcore/m_config.c
+++ b/mpvcore/m_config.c
@@ -230,6 +230,26 @@ int m_config_set_obj_params(struct m_config *conf, char **args)
return 0;
}
+int m_config_apply_defaults(struct m_config *config, const char *name,
+ struct m_obj_settings *defaults)
+{
+ int r = 0;
+ for (int n = 0; defaults && defaults[n].name; n++) {
+ struct m_obj_settings *entry = &defaults[n];
+ if (name && strcmp(entry->name, name) == 0) {
+ if (entry->attribs && strcmp(entry->attribs[0], "_oldargs_") == 0) {
+ mp_tmsg(MSGT_CFGPARSER, MSGL_ERR,
+ "Filter '%s' can't take defaults, because it uses "
+ "custom option parsing.\n", name);
+ return -1;
+ }
+ r = m_config_set_obj_params(config, entry->attribs);
+ break;
+ }
+ }
+ return r;
+}
+
int m_config_initialize_obj(struct m_config *config, struct m_obj_desc *desc,
void **ppriv, char ***pargs)
{
diff --git a/mpvcore/m_config.h b/mpvcore/m_config.h
index 1098c5635c..c4c20a2ca5 100644
--- a/mpvcore/m_config.h
+++ b/mpvcore/m_config.h
@@ -33,6 +33,7 @@ struct m_option;
struct m_option_type;
struct m_sub_options;
struct m_obj_desc;
+struct m_obj_settings;
// Config option
struct m_config_option {
@@ -87,6 +88,11 @@ struct m_config *m_config_from_obj_desc_noalloc(void *talloc_ctx,
int m_config_set_obj_params(struct m_config *conf, char **args);
+// Search for the object with the given name in the defaults list, and apply
+// its parameters.
+int m_config_apply_defaults(struct m_config *config, const char *name,
+ struct m_obj_settings *defaults);
+
// Initialize an object (VO/VF/...) in one go, including legacy handling.
// This is pretty specialized, and is just for convenience.
int m_config_initialize_obj(struct m_config *config, struct m_obj_desc *desc,
diff --git a/mpvcore/options.c b/mpvcore/options.c
index f8aad2eeb6..c8112b496d 100644
--- a/mpvcore/options.c
+++ b/mpvcore/options.c
@@ -466,7 +466,9 @@ const m_option_t mp_opts[] = {
// ------------------------- codec/vfilter options --------------------
+ OPT_SETTINGSLIST("af-defaults", af_defs, 0, &af_obj_list),
OPT_SETTINGSLIST("af*", af_settings, 0, &af_obj_list),
+ OPT_SETTINGSLIST("vf-defaults", vf_defs, 0, &vf_obj_list),
OPT_SETTINGSLIST("vf*", vf_settings, 0, &vf_obj_list),
OPT_CHOICE("deinterlace", deinterlace, M_OPT_OPTIONAL_PARAM,
@@ -557,7 +559,9 @@ const m_option_t mp_opts[] = {
//---------------------- libao/libvo options ------------------------
OPT_SETTINGSLIST("vo", vo.video_driver_list, 0, &vo_obj_list),
+ OPT_SETTINGSLIST("vo-defaults", vo.vo_defs, 0, &vo_obj_list),
OPT_SETTINGSLIST("ao", audio_driver_list, 0, &ao_obj_list),
+ OPT_SETTINGSLIST("ao-defaults", ao_defs, 0, &ao_obj_list),
OPT_FLAG("fixed-vo", fixed_vo, CONF_GLOBAL),
OPT_FLAG("force-window", force_vo, CONF_GLOBAL),
OPT_FLAG("ontop", vo.ontop, 0),
diff --git a/mpvcore/options.h b/mpvcore/options.h
index 8b3411bc39..3a4333f891 100644
--- a/mpvcore/options.h
+++ b/mpvcore/options.h
@@ -6,7 +6,7 @@
#include "mpvcore/m_option.h"
typedef struct mp_vo_opts {
- struct m_obj_settings *video_driver_list;
+ struct m_obj_settings *video_driver_list, *vo_defs;
int screenwidth;
int screenheight;
@@ -48,7 +48,7 @@ typedef struct MPOpts {
char **lua_files;
int lua_load_osc;
- struct m_obj_settings *audio_driver_list;
+ struct m_obj_settings *audio_driver_list, *ao_defs;
int fixed_vo;
int force_vo;
int softvol;
@@ -174,8 +174,8 @@ typedef struct MPOpts {
int force_srate;
int dtshd;
double playback_speed;
- struct m_obj_settings *vf_settings;
- struct m_obj_settings *af_settings;
+ struct m_obj_settings *vf_settings, *vf_defs;
+ struct m_obj_settings *af_settings, *af_defs;
int deinterlace;
float movie_aspect;
int flip;