summaryrefslogtreecommitdiffstats
path: root/core/m_option.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-21 19:33:08 +0200
committerwm4 <wm4@nowhere>2013-07-21 23:27:31 +0200
commit6629a95b928499a46c9686f0800b65aec7fcbb22 (patch)
tree67e158d3678b54fc521b4fedb19a7dd20b823512 /core/m_option.h
parent111a455ec621103b714a199217471af5f3efe35a (diff)
downloadmpv-6629a95b928499a46c9686f0800b65aec7fcbb22.tar.bz2
mpv-6629a95b928499a46c9686f0800b65aec7fcbb22.tar.xz
options: use m_config for options instead of m_struct
For some reason, both m_config and m_struct are somewhat similar, except that m_config is much more powerful. m_config is used for VOs and some other things, so to unify them. We plan to kick out m_struct and use m_config for everything. (Unfortunately, m_config is also a bit more bloated, so this commit isn't all that great, but it will allow to reduce the option parser mess somewhat.) This commit also switches all video filters to use the option macros. One reason is that m_struct and m_config, even though they both use m_option, store the offsets of the option fields differently (sigh...), meaning the options defined for either are incompatible. It's easier to switch everything in one go. This commit will allow using the -vf option parser for other things, like VOs and AOs.
Diffstat (limited to 'core/m_option.h')
-rw-r--r--core/m_option.h39
1 files changed, 27 insertions, 12 deletions
diff --git a/core/m_option.h b/core/m_option.h
index c1aac93a82..5f95232076 100644
--- a/core/m_option.h
+++ b/core/m_option.h
@@ -93,18 +93,30 @@ struct m_geometry {
void m_geometry_apply(int *xpos, int *ypos, int *widw, int *widh,
int scrw, int scrh, struct m_geometry *gm);
+struct m_obj_desc {
+ // Name which will be used in the option string
+ const char *name;
+ // Will be printed when "help" is passed
+ const char *description;
+ // Size of the private struct
+ int priv_size;
+ // If not NULL, default values for private struct
+ const void *priv_defaults;
+ // Options which refer to members in the private struct
+ const struct m_option *options;
+ // For free use by the implementer of m_obj_list.get_desc
+ const void *p;
+};
+
// Extra definition needed for \ref m_option_type_obj_settings_list options.
-typedef struct {
- // Pointer to an array of pointer to some object type description struct.
- void **list;
- // Offset of the object type name (char*) in the description struct.
- void *name_off;
- // Offset of the object type info string (char*) in the description struct.
- void *info_off;
- // Offset of the object type parameter description (\ref m_struct_st)
- // in the description struct.
- void *desc_off;
-} m_obj_list_t;
+struct m_obj_list {
+ bool (*get_desc)(struct m_obj_desc *dst, int index);
+ const char *description;
+};
+
+// Find entry by name
+bool m_obj_list_find(struct m_obj_desc *dst, const struct m_obj_list *list,
+ bstr name);
// The data type used by \ref m_option_type_obj_settings_list.
typedef struct m_obj_settings {
@@ -559,7 +571,10 @@ int m_option_required_params(const m_option_t *opt);
#define OPT_SETTINGSLIST(optname, varname, flags, objlist) \
OPT_GENERAL(m_obj_settings_t*, optname, varname, flags, \
.type = &m_option_type_obj_settings_list, \
- .priv = objlist)
+ .priv = (void*)MP_EXPECT_TYPE(const struct m_obj_list*, objlist))
+
+#define OPT_IMAGEFORMAT(...) \
+ OPT_GENERAL(int, __VA_ARGS__, .type = &m_option_type_imgfmt)
#define OPT_AUDIOFORMAT(...) \
OPT_GENERAL(int, __VA_ARGS__, .type = &m_option_type_afmt)