1
0
mirror of https://github.com/mpv-player/mpv synced 2025-05-08 03:05:15 +00:00

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.
This commit is contained in:
wm4 2013-07-21 19:33:08 +02:00
parent 111a455ec6
commit 6629a95b92
20 changed files with 342 additions and 349 deletions

View File

@ -182,6 +182,49 @@ struct m_config *m_config_simple(void *optstruct)
return config; return config;
} }
struct m_config *m_config_from_obj_desc(void *talloc_parent,
struct m_obj_desc *desc)
{
struct m_config *config = m_config_simple(NULL);
talloc_steal(talloc_parent, config);
if (desc->priv_size) {
config->optstruct = talloc_zero_size(config, desc->priv_size);
if (desc->priv_defaults)
memcpy(config->optstruct, desc->priv_defaults, desc->priv_size);
m_config_register_options(config, desc->options);
}
return config;
}
int m_config_set_obj_params(struct m_config *conf, char **args)
{
for (int n = 0; args && args[n * 2 + 0]; n++) {
int r = m_config_set_option(conf, bstr0(args[n * 2 + 0]),
bstr0(args[n * 2 + 1]));
if (r < 0)
return r;
}
return 0;
}
int m_config_initialize_obj(struct m_config *config, struct m_obj_desc *desc,
void **ppriv, char ***pargs)
{
if (desc->priv_size) {
int r = m_config_set_obj_params(config, *pargs);
if (r < 0)
return r;
*ppriv = config->optstruct;
*pargs = NULL;
} else if (*pargs && !strcmp((*pargs)[0], "_oldargs_")) {
// Handle things which still use the old subopt parser
*pargs = (char **)((*pargs)[1]);
} else {
*pargs = NULL;
}
return 0;
}
struct m_config *m_config_new(void *optstruct, struct m_config *m_config_new(void *optstruct,
int includefunc(struct m_config *conf, int includefunc(struct m_config *conf,
char *filename)) char *filename))
@ -414,8 +457,14 @@ static void m_config_add_option(struct m_config *config,
// pretend that merge options don't exist (only their children matter) // pretend that merge options don't exist (only their children matter)
if (!is_merge_opt(co->opt)) { if (!is_merge_opt(co->opt)) {
co->next = config->opts; struct m_config_option **last = &config->opts;
config->opts = co; while (*last)
last = &(*last)->next;
*last = co;
if (!co->alias_owner) { // don't make no- etc. options positional
config->num_pos_opts += 1;
co->pos = config->num_pos_opts;
}
} }
add_negation_option(config, parent, arg); add_negation_option(config, parent, arg);
@ -425,10 +474,8 @@ int m_config_register_options(struct m_config *config,
const struct m_option *args) const struct m_option *args)
{ {
assert(config != NULL); assert(config != NULL);
assert(args != NULL); if (args)
add_options(config, NULL, args);
add_options(config, NULL, args);
return 1; return 1;
} }
@ -450,6 +497,15 @@ struct m_config_option *m_config_get_co(const struct m_config *config,
return NULL; return NULL;
} }
const char *m_config_get_positional_option(const struct m_config *config, int n)
{
for (struct m_config_option *co = config->opts; co; co = co->next) {
if (co->pos && co->pos - 1 == n)
return co->name;
}
return NULL;
}
static int parse_subopts(struct m_config *config, void *optstruct, char *name, static int parse_subopts(struct m_config *config, void *optstruct, char *name,
char *prefix, struct bstr param, int flags); char *prefix, struct bstr param, int flags);

View File

@ -31,10 +31,13 @@ typedef struct m_profile m_profile_t;
struct m_option; struct m_option;
struct m_option_type; struct m_option_type;
struct m_sub_options; struct m_sub_options;
struct m_obj_desc;
// Config option // Config option
struct m_config_option { struct m_config_option {
struct m_config_option *next; struct m_config_option *next;
// For positional parameters
int pos;
// Full name (ie option-subopt). // Full name (ie option-subopt).
char *name; char *name;
// Option description. // Option description.
@ -71,6 +74,7 @@ typedef struct m_config {
/** This contains all options and suboptions. /** This contains all options and suboptions.
*/ */
struct m_config_option *opts; struct m_config_option *opts;
int num_pos_opts;
// When options are set (via m_config_set_option or m_config_set_profile), // When options are set (via m_config_set_option or m_config_set_profile),
// back up the old value (unless it's already backed up). Used for restoring // back up the old value (unless it's already backed up). Used for restoring
// global options when per-file options are set. // global options when per-file options are set.
@ -92,6 +96,16 @@ m_config_new(void *optstruct,
struct m_config *m_config_simple(void *optstruct); struct m_config *m_config_simple(void *optstruct);
struct m_config *m_config_from_obj_desc(void *talloc_parent,
struct m_obj_desc *desc);
int m_config_set_obj_params(struct m_config *conf, char **args);
// 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,
void **ppriv, char ***pargs);
// Free a config object. // Free a config object.
void m_config_free(struct m_config *config); void m_config_free(struct m_config *config);
@ -149,6 +163,10 @@ const struct m_option *m_config_get_option(const struct m_config *config,
struct m_config_option *m_config_get_co(const struct m_config *config, struct m_config_option *m_config_get_co(const struct m_config *config,
struct bstr name); struct bstr name);
// Return the n-th option by position. n==0 is the first option. If there are
// less than (n + 1) options, return NULL.
const char *m_config_get_positional_option(const struct m_config *config, int n);
// Return a hint to the option parser whether a parameter is/may be required. // Return a hint to the option parser whether a parameter is/may be required.
// The option may still accept empty/non-empty parameters independent from // The option may still accept empty/non-empty parameters independent from
// this, and this function is useful only for handling ambiguous options like // this, and this function is useful only for handling ambiguous options like

View File

@ -38,6 +38,7 @@
#include "talloc.h" #include "talloc.h"
#include "core/mp_common.h" #include "core/mp_common.h"
#include "core/m_option.h" #include "core/m_option.h"
#include "core/m_config.h"
#include "core/mp_msg.h" #include "core/mp_msg.h"
char *m_option_strerror(int code) char *m_option_strerror(int code)
@ -1780,20 +1781,16 @@ const m_option_type_t m_option_type_rel_time = {
#undef VAL #undef VAL
#define VAL(x) (*(m_obj_settings_t **)(x)) #define VAL(x) (*(m_obj_settings_t **)(x))
static int find_obj_desc(struct bstr name, const m_obj_list_t *l, bool m_obj_list_find(struct m_obj_desc *dst, const struct m_obj_list *l,
const m_struct_t **ret) bstr name)
{ {
int i; for (int i = 0; ; i++) {
char *n; if (!l->get_desc(dst, i))
break;
for (i = 0; l->list[i]; i++) { if (bstr_equals0(name, dst->name))
n = M_ST_MB(char *, l->list[i], l->name_off); return true;
if (!bstrcmp0(name, n)) {
*ret = M_ST_MB(m_struct_t *, l->list[i], l->desc_off);
return 1;
}
} }
return 0; return false;
} }
static void obj_setting_free(m_obj_settings_t *item) static void obj_setting_free(m_obj_settings_t *item)
@ -1944,25 +1941,24 @@ static void copy_obj_settings_list(const m_option_t *opt, void *dst,
// Consider -vf a=b=c:d=e. This verifies "b"="c" and "d"="e" and that the // Consider -vf a=b=c:d=e. This verifies "b"="c" and "d"="e" and that the
// option names/values are correct. Try to determine whether an option // option names/values are correct. Try to determine whether an option
// without '=' sets a flag, or whether it's a positional argument. // without '=' sets a flag, or whether it's a positional argument.
static int get_obj_param(bstr opt_name, bstr obj_name, const m_struct_t *desc, static int get_obj_param(bstr opt_name, bstr obj_name, struct m_config *config,
bstr name, bstr val, int *nold, int oldmax, bstr name, bstr val, int *nold,
bstr *out_name, bstr *out_val) bstr *out_name, bstr *out_val)
{ {
const m_option_t *opt = m_option_list_findb(desc->fields, name);
int r; int r;
// va.start != NULL => of the form name=val (not positional) // va.start != NULL => of the form name=val (not positional)
// If it's just "name", and the associated option exists and is a flag, // If it's just "name", and the associated option exists and is a flag,
// don't accept it as positional argument. // don't accept it as positional argument.
if (val.start || (opt && m_option_required_params(opt) == 0)) { if (val.start || m_config_option_requires_param(config, name) == 0) {
if (!opt) { r = m_config_set_option(config, name, val);
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
"Option %.*s: %.*s doesn't have a %.*s parameter.\n",
BSTR_P(opt_name), BSTR_P(obj_name), BSTR_P(name));
return M_OPT_UNKNOWN;
}
r = m_option_parse(opt, name, val, NULL);
if (r < 0) { if (r < 0) {
if (r == M_OPT_UNKNOWN) {
mp_msg(MSGT_CFGPARSER, MSGL_ERR,
"Option %.*s: %.*s doesn't have a %.*s parameter.\n",
BSTR_P(opt_name), BSTR_P(obj_name), BSTR_P(name));
return M_OPT_UNKNOWN;
}
if (r > M_OPT_EXIT) if (r > M_OPT_EXIT)
mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %.*s: " mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %.*s: "
"Error while parsing %.*s parameter %.*s (%.*s)\n", "Error while parsing %.*s parameter %.*s (%.*s)\n",
@ -1980,22 +1976,22 @@ static int get_obj_param(bstr opt_name, bstr obj_name, const m_struct_t *desc,
(*nold)++; (*nold)++;
return 0; return 0;
} }
if ((*nold) >= oldmax) { const char *opt = m_config_get_positional_option(config, *nold);
mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %.*s: %.*s has only %d params, so you can't give more than %d unnamed params.\n", if (!opt) {
BSTR_P(opt_name), BSTR_P(obj_name), oldmax, oldmax); mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %.*s: %.*s has only %d "
"params, so you can't give more than %d unnamed params.\n",
BSTR_P(opt_name), BSTR_P(obj_name), *nold, *nold);
return M_OPT_OUT_OF_RANGE; return M_OPT_OUT_OF_RANGE;
} }
opt = &desc->fields[(*nold)]; r = m_config_set_option(config, bstr0(opt), val);
r = m_option_parse(opt, bstr0(opt->name), val, NULL);
if (r < 0) { if (r < 0) {
if (r > M_OPT_EXIT) if (r > M_OPT_EXIT)
mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %.*s: " mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %.*s: "
"Error while parsing %.*s parameter %s (%.*s)\n", "Error while parsing %.*s parameter %s (%.*s)\n",
BSTR_P(opt_name), BSTR_P(obj_name), opt->name, BSTR_P(opt_name), BSTR_P(obj_name), opt, BSTR_P(val));
BSTR_P(val));
return r; return r;
} }
*out_name = bstr0(opt->name); *out_name = bstr0(opt);
*out_val = val; *out_val = val;
(*nold)++; (*nold)++;
return 1; return 1;
@ -2006,16 +2002,15 @@ static int get_obj_param(bstr opt_name, bstr obj_name, const m_struct_t *desc,
// linear array in *_ret. In particular, desc contains what options a the // linear array in *_ret. In particular, desc contains what options a the
// object takes, and verifies the option values as well. // object takes, and verifies the option values as well.
static int get_obj_params(struct bstr opt_name, struct bstr name, static int get_obj_params(struct bstr opt_name, struct bstr name,
struct bstr *pstr, const m_struct_t *desc, struct bstr *pstr, struct m_obj_desc *desc,
char ***ret) char ***ret)
{ {
int n = 0, nold = 0, nopts; int nold = 0;
char **args = NULL; char **args = NULL;
int num_args = 0; int num_args = 0;
int r = 1; int r = 1;
for (nopts = 0; desc->fields[nopts].name; nopts++) struct m_config *config = m_config_from_obj_desc(NULL, desc);
/* NOP */;
while (pstr->len > 0) { while (pstr->len > 0) {
bstr fname, fval; bstr fname, fval;
@ -2024,7 +2019,7 @@ static int get_obj_params(struct bstr opt_name, struct bstr name,
goto exit; goto exit;
if (bstr_equals0(fname, "help")) if (bstr_equals0(fname, "help"))
goto print_help; goto print_help;
r = get_obj_param(opt_name, name, desc, fname, fval, &nold, nopts, r = get_obj_param(opt_name, name, config, fname, fval, &nold,
&fname, &fval); &fname, &fval);
if (r < 0) if (r < 0)
goto exit; goto exit;
@ -2049,36 +2044,15 @@ static int get_obj_params(struct bstr opt_name, struct bstr name,
} }
} }
exit: goto exit;
return r;
print_help: ; print_help: ;
char min[50], max[50]; m_config_print_option_list(config);
if (!desc->fields) { r = M_OPT_EXIT - 1;
mp_msg(MSGT_CFGPARSER, MSGL_INFO,
"%.*s doesn't have any options.\n\n", BSTR_P(name)); exit:
return M_OPT_EXIT - 1; talloc_free(config);
} return r;
mp_msg(MSGT_CFGPARSER, MSGL_INFO,
"\n Name Type Min Max\n\n");
for (n = 0; desc->fields[n].name; n++) {
const m_option_t *opt = &desc->fields[n];
if (opt->type->flags & M_OPT_TYPE_HAS_CHILD)
continue;
if (opt->flags & M_OPT_MIN)
sprintf(min, "%-8.0f", opt->min);
else
strcpy(min, "No");
if (opt->flags & M_OPT_MAX)
sprintf(max, "%-8.0f", opt->max);
else
strcpy(max, "No");
mp_msg(MSGT_CFGPARSER, MSGL_INFO,
" %-20.20s %-15.15s %-10.10s %-10.10s\n",
opt->name, opt->type->name, min, max);
}
mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\n");
return M_OPT_EXIT - 1;
} }
// Characters which may appear in a filter name // Characters which may appear in a filter name
@ -2086,12 +2060,12 @@ print_help: ;
// Parse one item, e.g. -vf a=b:c:d,e=f:g => parse a=b:c:d into "a" and "b:c:d" // Parse one item, e.g. -vf a=b:c:d,e=f:g => parse a=b:c:d into "a" and "b:c:d"
static int parse_obj_settings(struct bstr opt, struct bstr *pstr, static int parse_obj_settings(struct bstr opt, struct bstr *pstr,
const m_obj_list_t *list, const struct m_obj_list *list,
m_obj_settings_t **_ret) m_obj_settings_t **_ret)
{ {
int r; int r;
char **plist = NULL; char **plist = NULL;
const m_struct_t *desc; struct m_obj_desc desc;
bstr label = {0}; bstr label = {0};
if (bstr_eatstart0(pstr, "@")) { if (bstr_eatstart0(pstr, "@")) {
@ -2109,14 +2083,14 @@ static int parse_obj_settings(struct bstr opt, struct bstr *pstr,
if (bstr_eatstart0(pstr, "=")) if (bstr_eatstart0(pstr, "="))
has_param = true; has_param = true;
if (!find_obj_desc(str, list, &desc)) { if (!m_obj_list_find(&desc, list, str)) {
mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %.*s: %.*s doesn't exist.\n", mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %.*s: %.*s doesn't exist.\n",
BSTR_P(opt), BSTR_P(str)); BSTR_P(opt), BSTR_P(str));
return M_OPT_INVALID; return M_OPT_INVALID;
} }
if (has_param) { if (has_param) {
if (!desc) { if (!desc.options) {
// Should perhaps be parsed as escape-able string. But this is a // Should perhaps be parsed as escape-able string. But this is a
// compatibility path, so it's not worth the trouble. // compatibility path, so it's not worth the trouble.
int next = bstrcspn(*pstr, ","); int next = bstrcspn(*pstr, ",");
@ -2133,8 +2107,8 @@ static int parse_obj_settings(struct bstr opt, struct bstr *pstr,
plist[0] = talloc_strdup(NULL, "_oldargs_"); plist[0] = talloc_strdup(NULL, "_oldargs_");
plist[1] = bstrto0(NULL, param); plist[1] = bstrto0(NULL, param);
} }
} else if (desc) { } else {
r = get_obj_params(opt, str, pstr, desc, _ret ? &plist : NULL); r = get_obj_params(opt, str, pstr, &desc, _ret ? &plist : NULL);
if (r < 0) if (r < 0)
return r; return r;
} }
@ -2210,6 +2184,7 @@ static int parse_obj_settings_list(const m_option_t *opt, struct bstr name,
int op = OP_NONE; int op = OP_NONE;
bool *mark_del = NULL; bool *mark_del = NULL;
int num_items = obj_settings_list_num_items(dst ? VAL(dst) : 0); int num_items = obj_settings_list_num_items(dst ? VAL(dst) : 0);
struct m_obj_list *ol = opt->priv;
assert(opt->priv); assert(opt->priv);
@ -2253,12 +2228,14 @@ static int parse_obj_settings_list(const m_option_t *opt, struct bstr name,
} }
if (!bstrcmp0(param, "help")) { if (!bstrcmp0(param, "help")) {
m_obj_list_t *ol = opt->priv; mp_msg(MSGT_CFGPARSER, MSGL_INFO, "Available %s:\n", ol->description);
mp_msg(MSGT_CFGPARSER, MSGL_INFO, "Available video filters:\n"); for (int n = 0; ; n++) {
for (int n = 0; ol->list[n]; n++) struct m_obj_desc desc;
if (!ol->get_desc(&desc, n))
break;
mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %-15s: %s\n", mp_msg(MSGT_CFGPARSER, MSGL_INFO, " %-15s: %s\n",
M_ST_MB(char *, ol->list[n], ol->name_off), desc.name, desc.description);
M_ST_MB(char *, ol->list[n], ol->info_off)); }
mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\n"); mp_msg(MSGT_CFGPARSER, MSGL_INFO, "\n");
return M_OPT_EXIT - 1; return M_OPT_EXIT - 1;
} }
@ -2279,8 +2256,7 @@ static int parse_obj_settings_list(const m_option_t *opt, struct bstr name,
if (op == OP_DEL) if (op == OP_DEL)
r = parse_obj_settings_del(name, &param, dst, mark_del); r = parse_obj_settings_del(name, &param, dst, mark_del);
if (r == 0) { if (r == 0) {
r = parse_obj_settings(name, &param, opt->priv, r = parse_obj_settings(name, &param, ol, dst ? &res : NULL);
dst ? &res : NULL);
} }
if (r < 0) if (r < 0)
return r; return r;

View File

@ -93,18 +93,30 @@ struct m_geometry {
void m_geometry_apply(int *xpos, int *ypos, int *widw, int *widh, void m_geometry_apply(int *xpos, int *ypos, int *widw, int *widh,
int scrw, int scrh, struct m_geometry *gm); 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. // Extra definition needed for \ref m_option_type_obj_settings_list options.
typedef struct { struct m_obj_list {
// Pointer to an array of pointer to some object type description struct. bool (*get_desc)(struct m_obj_desc *dst, int index);
void **list; const char *description;
// 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. // Find entry by name
void *info_off; bool m_obj_list_find(struct m_obj_desc *dst, const struct m_obj_list *list,
// Offset of the object type parameter description (\ref m_struct_st) bstr name);
// in the description struct.
void *desc_off;
} m_obj_list_t;
// The data type used by \ref m_option_type_obj_settings_list. // The data type used by \ref m_option_type_obj_settings_list.
typedef struct m_obj_settings { 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) \ #define OPT_SETTINGSLIST(optname, varname, flags, objlist) \
OPT_GENERAL(m_obj_settings_t*, optname, varname, flags, \ OPT_GENERAL(m_obj_settings_t*, optname, varname, flags, \
.type = &m_option_type_obj_settings_list, \ .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(...) \ #define OPT_AUDIOFORMAT(...) \
OPT_GENERAL(int, __VA_ARGS__, .type = &m_option_type_afmt) OPT_GENERAL(int, __VA_ARGS__, .type = &m_option_type_afmt)

View File

@ -36,6 +36,7 @@
#define MPMAX(a, b) ((a) > (b) ? (a) : (b)) #define MPMAX(a, b) ((a) > (b) ? (a) : (b))
#define MPMIN(a, b) ((a) > (b) ? (b) : (a)) #define MPMIN(a, b) ((a) > (b) ? (b) : (a))
#define MP_ARRAY_SIZE(s) (sizeof(s) / sizeof((s)[0]))
#define CONTROL_OK 1 #define CONTROL_OK 1
#define CONTROL_TRUE 1 #define CONTROL_TRUE 1

View File

@ -181,7 +181,7 @@ extern char *dvd_device, *cdrom_device;
extern double mf_fps; extern double mf_fps;
extern char * mf_type; extern char * mf_type;
extern const m_obj_list_t vf_obj_list; extern const struct m_obj_list vf_obj_list;
static const m_option_t mfopts_conf[]={ static const m_option_t mfopts_conf[]={
{"fps", &mf_fps, CONF_TYPE_DOUBLE, 0, 0, 0, NULL}, {"fps", &mf_fps, CONF_TYPE_DOUBLE, 0, 0, 0, NULL},
@ -436,7 +436,7 @@ const m_option_t mp_opts[] = {
{"af*", &af_cfg.list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL}, {"af*", &af_cfg.list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
OPT_SETTINGSLIST("vf*", vf_settings, 0, (void *) &vf_obj_list), OPT_SETTINGSLIST("vf*", vf_settings, 0, &vf_obj_list),
OPT_STRING("ad", audio_decoders, 0), OPT_STRING("ad", audio_decoders, 0),
OPT_STRING("vd", video_decoders, 0), OPT_STRING("vd", video_decoders, 0),

View File

@ -28,7 +28,7 @@
#include "core/mp_msg.h" #include "core/mp_msg.h"
#include "core/m_option.h" #include "core/m_option.h"
#include "core/m_struct.h" #include "core/m_config.h"
#include "core/options.h" #include "core/options.h"
@ -115,12 +115,26 @@ static const vf_info_t *const filter_list[] = {
NULL NULL
}; };
static bool get_desc(struct m_obj_desc *dst, int index)
{
if (index >= MP_ARRAY_SIZE(filter_list) - 1)
return false;
const vf_info_t *vf = filter_list[index];
*dst = (struct m_obj_desc) {
.name = vf->name,
.description = vf->info,
.priv_size = vf->priv_size,
.priv_defaults = vf->priv_defaults,
.options = vf->options,
.p = vf,
};
return true;
}
// For the vf option // For the vf option
const m_obj_list_t vf_obj_list = { const struct m_obj_list vf_obj_list = {
(void **)filter_list, .get_desc = get_desc,
M_ST_OFF(vf_info_t, name), .description = "video filters",
M_ST_OFF(vf_info_t, info),
M_ST_OFF(vf_info_t, opts)
}; };
int vf_control(struct vf_instance *vf, int cmd, void *arg) int vf_control(struct vf_instance *vf, int cmd, void *arg)
@ -212,42 +226,34 @@ void vf_print_filter_chain(int msglevel, struct vf_instance *vf)
static struct vf_instance *vf_open(struct MPOpts *opts, vf_instance_t *next, static struct vf_instance *vf_open(struct MPOpts *opts, vf_instance_t *next,
const char *name, char **args) const char *name, char **args)
{ {
vf_instance_t *vf; struct m_obj_desc desc;
int i; if (!m_obj_list_find(&desc, &vf_obj_list, bstr0(name))) {
for (i = 0;; i++) { mp_tmsg(MSGT_VFILTER, MSGL_ERR,
if (!filter_list[i]) { "Couldn't find video filter '%s'.\n", name);
mp_tmsg(MSGT_VFILTER, MSGL_ERR, return NULL;
"Couldn't find video filter '%s'.\n", name);
return NULL; // no such filter!
}
if (!strcmp(filter_list[i]->name, name))
break;
} }
vf = talloc_zero(NULL, struct vf_instance); vf_instance_t *vf = talloc_zero(NULL, struct vf_instance);
vf->opts = opts; *vf = (vf_instance_t) {
vf->info = filter_list[i]; .info = desc.p,
vf->next = next; .opts = opts,
vf->config = vf_next_config; .next = next,
vf->control = vf_next_control; .config = vf_next_config,
vf->query_format = vf_default_query_format; .control = vf_next_control,
vf->filter = vf_default_filter; .query_format = vf_default_query_format,
vf->out_pool = talloc_steal(vf, mp_image_pool_new(16)); .filter = vf_default_filter,
if (vf->info->opts) { // vf_vo get some special argument .out_pool = talloc_steal(vf, mp_image_pool_new(16)),
const m_struct_t *st = vf->info->opts; };
void *vf_priv = m_struct_alloc(st); struct m_config *config = m_config_from_obj_desc(vf, &desc);
int n; void *priv = NULL;
for (n = 0; args && args[2 * n]; n++) if (m_config_initialize_obj(config, &desc, &priv, &args) < 0)
m_struct_set(st, vf_priv, args[2 * n], bstr0(args[2 * n + 1])); goto error;
vf->priv = vf_priv; vf->priv = priv;
args = NULL;
} else // Otherwise we should have the '_oldargs_'
if (args && !strcmp(args[0], "_oldargs_"))
args = (char **)args[1];
else
args = NULL;
int retcode = vf->info->vf_open(vf, (char *)args); int retcode = vf->info->vf_open(vf, (char *)args);
if (retcode > 0) if (retcode < 0)
return vf; goto error;
return vf;
error:
talloc_free(vf); talloc_free(vf);
return NULL; return NULL;
} }
@ -551,9 +557,6 @@ void vf_uninit_filter(vf_instance_t *vf)
if (vf->uninit) if (vf->uninit)
vf->uninit(vf); vf->uninit(vf);
vf_forget_frames(vf); vf_forget_frames(vf);
const m_struct_t *st = vf->info->opts;
if (st)
m_struct_free(st, vf->priv);
talloc_free(vf); talloc_free(vf);
} }

View File

@ -36,8 +36,10 @@ typedef struct vf_info {
const char *author; const char *author;
const char *comment; const char *comment;
int (*vf_open)(struct vf_instance *vf, char *args); int (*vf_open)(struct vf_instance *vf, char *args);
// Ptr to a struct describing the options void *damn_you;
const void *opts; int priv_size;
const void *priv_defaults;
const struct m_option *options;
} vf_info_t; } vf_info_t;
struct vf_format { struct vf_format {

View File

@ -29,7 +29,6 @@
#include "vf.h" #include "vf.h"
#include "core/m_option.h" #include "core/m_option.h"
#include "core/m_struct.h"
static const struct vf_priv_s { static const struct vf_priv_s {
int crop_w,crop_h; int crop_w,crop_h;
@ -95,20 +94,13 @@ static int vf_open(vf_instance_t *vf, char *args){
return 1; return 1;
} }
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) #define OPT_BASE_STRUCT struct vf_priv_s
static const m_option_t vf_opts_fields[] = { static const m_option_t vf_opts_fields[] = {
{"w", ST_OFF(crop_w), CONF_TYPE_INT, M_OPT_MIN,0 ,0, NULL}, OPT_INT("w", crop_w, M_OPT_MIN, .min = 0),
{"h", ST_OFF(crop_h), CONF_TYPE_INT, M_OPT_MIN,0 ,0, NULL}, OPT_INT("h", crop_h, M_OPT_MIN, .min = 0),
{"x", ST_OFF(crop_x), CONF_TYPE_INT, M_OPT_MIN,-1 ,0, NULL}, OPT_INT("x", crop_x, M_OPT_MIN, .min = -1),
{"y", ST_OFF(crop_y), CONF_TYPE_INT, M_OPT_MIN,-1 ,0, NULL}, OPT_INT("y", crop_y, M_OPT_MIN, .min = -1),
{ NULL, NULL, 0, 0, 0, 0, NULL } {0}
};
static const m_struct_t vf_opts = {
"crop",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
vf_opts_fields
}; };
const vf_info_t vf_info_crop = { const vf_info_t vf_info_crop = {
@ -117,7 +109,9 @@ const vf_info_t vf_info_crop = {
"A'rpi", "A'rpi",
"", "",
vf_open, vf_open,
&vf_opts .priv_size = sizeof(struct vf_priv_s),
.priv_defaults = &vf_priv_dflt,
.options = vf_opts_fields,
}; };
//===========================================================================// //===========================================================================//

View File

@ -36,14 +36,13 @@
#include "video/memcpy_pic.h" #include "video/memcpy_pic.h"
#include "core/m_option.h" #include "core/m_option.h"
#include "core/m_struct.h"
//===========================================================================// //===========================================================================//
static struct vf_priv_s { static struct vf_priv_s {
unsigned int outfmt; unsigned int outfmt;
int xoff, yoff, lw, lh, band, show; int xoff, yoff, lw, lh, band, show;
const char *file; char *file;
struct timed_rectangle { struct timed_rectangle {
int ts, x, y, w, h, b; int ts, x, y, w, h, b;
} *timed_rect; } *timed_rect;
@ -304,23 +303,16 @@ static int vf_open(vf_instance_t *vf, char *args){
return 1; return 1;
} }
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) #define OPT_BASE_STRUCT struct vf_priv_s
static const m_option_t vf_opts_fields[] = { static const m_option_t vf_opts_fields[] = {
{ "x", ST_OFF(xoff), CONF_TYPE_INT, 0, 0, 0, NULL }, OPT_INT("x", xoff, 0),
{ "y", ST_OFF(yoff), CONF_TYPE_INT, 0, 0, 0, NULL }, OPT_INT("y", yoff, 0),
{ "w", ST_OFF(lw), CONF_TYPE_INT, 0, 0, 0, NULL }, OPT_INT("w", lw, 0),
{ "h", ST_OFF(lh), CONF_TYPE_INT, 0, 0, 0, NULL }, OPT_INT("h", lh, 0),
{ "t", ST_OFF(band), CONF_TYPE_INT, 0, 0, 0, NULL }, OPT_INT("t", band, 0),
{ "band", ST_OFF(band), CONF_TYPE_INT, 0, 0, 0, NULL }, // alias OPT_INT("band", band, 0), // alias
{ "file", ST_OFF(file), CONF_TYPE_STRING, 0, 0, 0, NULL }, OPT_STRING("file", file, 0),
{ NULL, NULL, 0, 0, 0, 0, NULL } {0}
};
static const m_struct_t vf_opts = {
"delogo",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
vf_opts_fields
}; };
const vf_info_t vf_info_delogo = { const vf_info_t vf_info_delogo = {
@ -329,7 +321,9 @@ const vf_info_t vf_info_delogo = {
"Jindrich Makovicka, Alex Beregszaszi", "Jindrich Makovicka, Alex Beregszaszi",
"", "",
vf_open, vf_open,
&vf_opts .priv_size = sizeof(struct vf_priv_s),
.priv_defaults = &vf_priv_dflt,
.options = vf_opts_fields,
}; };
//===========================================================================// //===========================================================================//

View File

@ -29,7 +29,6 @@
#include "vf.h" #include "vf.h"
#include "core/m_option.h" #include "core/m_option.h"
#include "core/m_struct.h"
#include "vf_dlopen.h" #include "vf_dlopen.h"
@ -46,9 +45,9 @@
#endif #endif
static struct vf_priv_s { static struct vf_priv_s {
const char *cfg_dllname; char *cfg_dllname;
int cfg_argc; int cfg_argc;
const char *cfg_argv[16]; char *cfg_argv[16];
void *dll; void *dll;
struct vf_dlopen_context filter; struct vf_dlopen_context filter;
@ -329,7 +328,9 @@ static int vf_open(vf_instance_t *vf, char *args)
if (vf->priv->cfg_argv[i] == NULL) if (vf->priv->cfg_argv[i] == NULL)
vf->priv->cfg_argv[i] = talloc_strdup (vf->priv, ""); vf->priv->cfg_argv[i] = talloc_strdup (vf->priv, "");
if (func(&vf->priv->filter, vf->priv->cfg_argc, vf->priv->cfg_argv) < 0) { if (func(&vf->priv->filter, vf->priv->cfg_argc,
(const char **)vf->priv->cfg_argv) < 0)
{
mp_msg(MSGT_VFILTER, MSGL_ERR, mp_msg(MSGT_VFILTER, MSGL_ERR,
"function did not create a filter: %s\n", "function did not create a filter: %s\n",
vf->priv->cfg_dllname); vf->priv->cfg_dllname);
@ -351,33 +352,26 @@ static int vf_open(vf_instance_t *vf, char *args)
return 1; return 1;
} }
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s, f) #define OPT_BASE_STRUCT struct vf_priv_s
static m_option_t vf_opts_fields[] = { static const m_option_t vf_opts_fields[] = {
{"dll", ST_OFF(cfg_dllname), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("dll", cfg_dllname, 0),
{"a0", ST_OFF(cfg_argv[0]), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("a0", cfg_argv[0], 0),
{"a1", ST_OFF(cfg_argv[1]), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("a1", cfg_argv[1], 0),
{"a2", ST_OFF(cfg_argv[2]), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("a2", cfg_argv[2], 0),
{"a3", ST_OFF(cfg_argv[3]), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("a3", cfg_argv[3], 0),
{"a4", ST_OFF(cfg_argv[4]), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("a4", cfg_argv[4], 0),
{"a5", ST_OFF(cfg_argv[5]), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("a5", cfg_argv[5], 0),
{"a6", ST_OFF(cfg_argv[6]), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("a6", cfg_argv[6], 0),
{"a7", ST_OFF(cfg_argv[7]), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("a7", cfg_argv[7], 0),
{"a8", ST_OFF(cfg_argv[8]), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("a8", cfg_argv[8], 0),
{"a9", ST_OFF(cfg_argv[9]), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("a9", cfg_argv[9], 0),
{"a10", ST_OFF(cfg_argv[10]), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("a10", cfg_argv[10], 0),
{"a11", ST_OFF(cfg_argv[11]), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("a11", cfg_argv[11], 0),
{"a12", ST_OFF(cfg_argv[12]), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("a12", cfg_argv[12], 0),
{"a13", ST_OFF(cfg_argv[13]), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("a13", cfg_argv[13], 0),
{"a14", ST_OFF(cfg_argv[14]), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("a14", cfg_argv[14], 0),
{"a15", ST_OFF(cfg_argv[15]), CONF_TYPE_STRING, 0, 0, 0, NULL}, OPT_STRING("a15", cfg_argv[15], 0),
{ NULL, NULL, 0, 0, 0, 0, NULL } {0}
};
static const m_struct_t vf_opts = {
"dlopen",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
vf_opts_fields
}; };
const vf_info_t vf_info_dlopen = { const vf_info_t vf_info_dlopen = {
@ -386,7 +380,9 @@ const vf_info_t vf_info_dlopen = {
"Rudolf Polzer", "Rudolf Polzer",
"", "",
vf_open, vf_open,
&vf_opts .priv_size = sizeof(struct vf_priv_s),
.priv_defaults = &vf_priv_dflt,
.options = vf_opts_fields,
}; };
//===========================================================================// //===========================================================================//

View File

@ -34,7 +34,6 @@
#include "video/memcpy_pic.h" #include "video/memcpy_pic.h"
#include "core/m_option.h" #include "core/m_option.h"
#include "core/m_struct.h"
static struct vf_priv_s { static struct vf_priv_s {
// These four values are a backup of the values parsed from the command line. // These four values are a backup of the values parsed from the command line.
@ -164,33 +163,26 @@ static int vf_open(vf_instance_t *vf, char *args){
return 1; return 1;
} }
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) #define OPT_BASE_STRUCT struct vf_priv_s
static m_option_t vf_opts_fields[] = { static const m_option_t vf_opts_fields[] = {
{"w", ST_OFF(cfg_exp_w), CONF_TYPE_INT, 0, 0 ,0, NULL}, OPT_INT("w", cfg_exp_w, 0),
{"h", ST_OFF(cfg_exp_h), CONF_TYPE_INT, 0, 0 ,0, NULL}, OPT_INT("h", cfg_exp_h, 0),
{"x", ST_OFF(cfg_exp_x), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL}, OPT_INT("x", cfg_exp_x, M_OPT_MIN, .min = -1),
{"y", ST_OFF(cfg_exp_y), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL}, OPT_INT("y", cfg_exp_y, M_OPT_MIN, .min = -1),
{"aspect", ST_OFF(aspect), CONF_TYPE_DOUBLE, M_OPT_MIN, 0, 0, NULL}, OPT_DOUBLE("aspect", aspect, M_OPT_MIN, .min = 0),
{"round", ST_OFF(round), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL}, OPT_INT("round", round, M_OPT_MIN, .min = 1),
{ NULL, NULL, 0, 0, 0, 0, NULL } {0}
}; };
static const m_struct_t vf_opts = {
"expand",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
vf_opts_fields
};
const vf_info_t vf_info_expand = { const vf_info_t vf_info_expand = {
"expanding", "expanding",
"expand", "expand",
"A'rpi", "A'rpi",
"", "",
vf_open, vf_open,
&vf_opts .priv_size = sizeof(struct vf_priv_s),
.priv_defaults = &vf_priv_dflt,
.options = vf_opts_fields,
}; };
//===========================================================================// //===========================================================================//

View File

@ -29,11 +29,10 @@
#include "vf.h" #include "vf.h"
#include "core/m_option.h" #include "core/m_option.h"
#include "core/m_struct.h"
static struct vf_priv_s { static struct vf_priv_s {
unsigned int fmt; int fmt;
unsigned int outfmt; int outfmt;
} const vf_priv_dflt = { } const vf_priv_dflt = {
IMGFMT_YUYV, IMGFMT_YUYV,
0 0
@ -73,18 +72,11 @@ static int vf_open(vf_instance_t *vf, char *args){
return 1; return 1;
} }
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) #define OPT_BASE_STRUCT struct vf_priv_s
static const m_option_t vf_opts_fields[] = { static const m_option_t vf_opts_fields[] = {
{"fmt", ST_OFF(fmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL}, OPT_IMAGEFORMAT("fmt", fmt, 0),
{"outfmt", ST_OFF(outfmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL}, OPT_IMAGEFORMAT("outfmt", outfmt, 0),
{ NULL, NULL, 0, 0, 0, 0, NULL } {0}
};
static const m_struct_t vf_opts = {
"format",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
vf_opts_fields
}; };
const vf_info_t vf_info_format = { const vf_info_t vf_info_format = {
@ -93,7 +85,9 @@ const vf_info_t vf_info_format = {
"A'rpi", "A'rpi",
"FIXME! get_image()/put_image()", "FIXME! get_image()/put_image()",
vf_open, vf_open,
&vf_opts .priv_size = sizeof(struct vf_priv_s),
.priv_defaults = &vf_priv_dflt,
.options = vf_opts_fields,
}; };
//===========================================================================// //===========================================================================//

View File

@ -44,7 +44,6 @@
#include "compat/x86_cpu.h" #include "compat/x86_cpu.h"
#include "core/m_option.h" #include "core/m_option.h"
#include "core/m_struct.h"
struct vf_priv_s { struct vf_priv_s {
float cfg_thresh; float cfg_thresh;
@ -393,20 +392,12 @@ static int vf_open(vf_instance_t *vf, char *args)
return 1; return 1;
} }
#undef ST_OFF #define OPT_BASE_STRUCT struct vf_priv_s
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
static const m_option_t vf_opts_fields[] = { static const m_option_t vf_opts_fields[] = {
{"strength", ST_OFF(cfg_thresh), CONF_TYPE_FLOAT, M_OPT_RANGE, 0.51, 255, NULL}, OPT_FLOATRANGE("strength", cfg_thresh, 0, 0.51, 255),
{"radius", ST_OFF(cfg_radius), CONF_TYPE_INT, M_OPT_RANGE, 4, 32, NULL}, OPT_INTRANGE("radius", cfg_radius, 0, 4, 32),
{"size", ST_OFF(cfg_size), CONF_TYPE_FLOAT, M_OPT_RANGE, 0.1, 5.0, NULL}, OPT_FLOATRANGE("size", cfg_size, 0, 0.1, 5.0),
{ NULL, NULL, 0, 0, 0, 0, NULL } {0}
};
static const m_struct_t vf_opts = {
"gradfun",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
vf_opts_fields
}; };
const vf_info_t vf_info_gradfun = { const vf_info_t vf_info_gradfun = {
@ -415,5 +406,7 @@ const vf_info_t vf_info_gradfun = {
"Loren Merritt", "Loren Merritt",
"", "",
vf_open, vf_open,
&vf_opts .priv_size = sizeof(struct vf_priv_s),
.priv_defaults = &vf_priv_dflt,
.options = vf_opts_fields,
}; };

View File

@ -37,7 +37,6 @@
#include "core/mp_msg.h" #include "core/mp_msg.h"
#include "core/m_option.h" #include "core/m_option.h"
#include "core/m_struct.h"
#include "core/av_opts.h" #include "core/av_opts.h"
#include "video/img_format.h" #include "video/img_format.h"
@ -326,27 +325,21 @@ static int vf_open(vf_instance_t *vf, char *args)
return 1; return 1;
} }
#undef ST_OFF #define OPT_BASE_STRUCT struct vf_priv_s
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
static const m_option_t vf_opts_fields[] = { static const m_option_t vf_opts_fields[] = {
{"graph", ST_OFF(cfg_graph), CONF_TYPE_STRING, CONF_MIN, 1}, OPT_STRING("graph", cfg_graph, M_OPT_MIN, .min = 1),
{"sws_flags", ST_OFF(cfg_sws_flags), CONF_TYPE_INT64}, OPT_INT64("sws_flags", cfg_sws_flags, 0),
{"o", ST_OFF(cfg_avopts), CONF_TYPE_STRING}, OPT_STRING("o", cfg_avopts, 0),
{0} {0}
}; };
static const m_struct_t vf_opts = {
"lavfi",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
vf_opts_fields
};
const vf_info_t vf_info_lavfi = { const vf_info_t vf_info_lavfi = {
"libavfilter bridge", "libavfilter bridge",
"lavfi", "lavfi",
"", "",
"", "",
vf_open, vf_open,
&vf_opts .priv_size = sizeof(struct vf_priv_s),
.priv_defaults = &vf_priv_dflt,
.options = vf_opts_fields,
}; };

View File

@ -29,10 +29,9 @@
#include "vf.h" #include "vf.h"
#include "core/m_option.h" #include "core/m_option.h"
#include "core/m_struct.h"
static struct vf_priv_s { static struct vf_priv_s {
unsigned int fmt; int fmt;
} const vf_priv_dflt = { } const vf_priv_dflt = {
IMGFMT_420P IMGFMT_420P
}; };
@ -50,17 +49,10 @@ static int vf_open(vf_instance_t *vf, char *args){
return 1; return 1;
} }
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) #define OPT_BASE_STRUCT struct vf_priv_s
static const m_option_t vf_opts_fields[] = { static const m_option_t vf_opts_fields[] = {
{"fmt", ST_OFF(fmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL}, OPT_IMAGEFORMAT("fmt", fmt, 0),
{ NULL, NULL, 0, 0, 0, 0, NULL } {0}
};
static const m_struct_t vf_opts = {
"noformat",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
vf_opts_fields
}; };
const vf_info_t vf_info_noformat = { const vf_info_t vf_info_noformat = {
@ -69,7 +61,9 @@ const vf_info_t vf_info_noformat = {
"Joey", "Joey",
"", "",
vf_open, vf_open,
&vf_opts .priv_size = sizeof(struct vf_priv_s),
.priv_defaults = &vf_priv_dflt,
.options = vf_opts_fields,
}; };
//===========================================================================// //===========================================================================//

View File

@ -40,7 +40,6 @@
#include "video/out/vo.h" #include "video/out/vo.h"
#include "core/m_option.h" #include "core/m_option.h"
#include "core/m_struct.h"
static struct vf_priv_s { static struct vf_priv_s {
int w, h; int w, h;
@ -432,24 +431,16 @@ static int vf_open(vf_instance_t *vf, char *args)
return 1; return 1;
} }
#undef ST_OFF #define OPT_BASE_STRUCT struct vf_priv_s
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s, f)
static const m_option_t vf_opts_fields[] = { static const m_option_t vf_opts_fields[] = {
{"w", ST_OFF(cfg_w), CONF_TYPE_INT, M_OPT_MIN, -11, 0, NULL}, OPT_INT("w", cfg_w, M_OPT_MIN, .min = -11),
{"h", ST_OFF(cfg_h), CONF_TYPE_INT, M_OPT_MIN, -11, 0, NULL}, OPT_INT("h", cfg_h, M_OPT_MIN, .min = -11),
{"chr-drop", ST_OFF(v_chr_drop), CONF_TYPE_INT, M_OPT_RANGE, 0, 3, NULL}, OPT_DOUBLE("param", param[0], M_OPT_RANGE, .min = 0.0, .max = 100.0),
{"param", ST_OFF(param[0]), CONF_TYPE_DOUBLE, M_OPT_RANGE, 0.0, 100.0, NULL}, OPT_DOUBLE("param2", param[1], M_OPT_RANGE, .min = 0.0, .max = 100.0),
{"param2", ST_OFF(param[1]), CONF_TYPE_DOUBLE, M_OPT_RANGE, 0.0, 100.0, NULL}, OPT_INTRANGE("chr-drop", v_chr_drop, 0, 0, 3),
{"noup", ST_OFF(noup), CONF_TYPE_INT, M_OPT_RANGE, 0, 2, NULL}, OPT_INTRANGE("noup", noup, 0, 0, 2),
{"arnd", ST_OFF(accurate_rnd), CONF_TYPE_FLAG, 0, 0, 1, NULL}, OPT_FLAG("arnd", accurate_rnd, 0),
{ NULL, NULL, 0, 0, 0, 0, NULL } {0}
};
static const m_struct_t vf_opts = {
"scale",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
vf_opts_fields
}; };
const vf_info_t vf_info_scale = { const vf_info_t vf_info_scale = {
@ -458,7 +449,9 @@ const vf_info_t vf_info_scale = {
"A'rpi", "A'rpi",
"", "",
vf_open, vf_open,
&vf_opts .priv_size = sizeof(struct vf_priv_s),
.priv_defaults = &vf_priv_dflt,
.options = vf_opts_fields,
}; };
//===========================================================================// //===========================================================================//

View File

@ -30,7 +30,6 @@
#include "video/img_format.h" #include "video/img_format.h"
#include "video/mp_image.h" #include "video/mp_image.h"
#include "vf.h" #include "vf.h"
#include "core/m_struct.h"
#include "core/m_option.h" #include "core/m_option.h"
#include "libavutil/common.h" #include "libavutil/common.h"
@ -66,7 +65,7 @@ typedef enum stereo_code {
} stereo_code; } stereo_code;
typedef struct component { typedef struct component {
stereo_code fmt; int fmt;
unsigned int width; unsigned int width;
unsigned int height; unsigned int height;
unsigned int off_left; unsigned int off_left;
@ -455,22 +454,15 @@ const struct m_opt_choice_alternatives stereo_code_names[] = {
{ NULL, 0} { NULL, 0}
}; };
#undef ST_OFF #define OPT_BASE_STRUCT struct vf_priv_s
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
static const m_option_t vf_opts_fields[] = { static const m_option_t vf_opts_fields[] = {
{"in", ST_OFF(in.fmt), CONF_TYPE_CHOICE, .priv = (void *)stereo_code_names}, OPT_GENERAL(int, "in", in.fmt, 0, .type = CONF_TYPE_CHOICE,
{"out", ST_OFF(out.fmt), CONF_TYPE_CHOICE, .priv = (void *)stereo_code_names}, .priv = (void *)stereo_code_names),
{ NULL, NULL, 0, 0, 0, 0, NULL } OPT_GENERAL(int, "out", out.fmt, 0, .type = CONF_TYPE_CHOICE,
.priv = (void *)stereo_code_names),
{0}
}; };
static const m_struct_t vf_opts = {
"stereo3d",
sizeof(struct vf_priv_s),
&vf_priv_default,
vf_opts_fields
};
//==info struct==// //==info struct==//
const vf_info_t vf_info_stereo3d = { const vf_info_t vf_info_stereo3d = {
"stereoscopic 3d view", "stereoscopic 3d view",
@ -478,5 +470,7 @@ const vf_info_t vf_info_stereo3d = {
"Gordon Schmidt", "Gordon Schmidt",
"view stereoscopic videos", "view stereoscopic videos",
vf_open, vf_open,
&vf_opts .priv_size = sizeof(struct vf_priv_s),
.priv_defaults = &vf_priv_default,
.options = vf_opts_fields,
}; };

View File

@ -41,7 +41,6 @@
#include "video/memcpy_pic.h" #include "video/memcpy_pic.h"
#include "core/m_option.h" #include "core/m_option.h"
#include "core/m_struct.h"
static const struct vf_priv_s { static const struct vf_priv_s {
int opt_top_margin, opt_bottom_margin; int opt_top_margin, opt_bottom_margin;
@ -140,20 +139,11 @@ static int vf_open(vf_instance_t *vf, char *args)
return 1; return 1;
} }
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s, f) #define OPT_BASE_STRUCT struct vf_priv_s
static const m_option_t vf_opts_fields[] = { static const m_option_t vf_opts_fields[] = {
{"bottom-margin", ST_OFF(opt_bottom_margin), OPT_INTRANGE("bottom-margin", opt_bottom_margin, 0, 0, 2000),
CONF_TYPE_INT, M_OPT_RANGE, 0, 2000}, OPT_INTRANGE("top-margin", opt_top_margin, 0, 0, 2000),
{"top-margin", ST_OFF(opt_top_margin), {0}
CONF_TYPE_INT, M_OPT_RANGE, 0, 2000},
{0},
};
static const m_struct_t vf_opts = {
"sub",
sizeof(struct vf_priv_s),
&vf_priv_dflt,
vf_opts_fields
}; };
const vf_info_t vf_info_sub = { const vf_info_t vf_info_sub = {
@ -162,5 +152,7 @@ const vf_info_t vf_info_sub = {
"Evgeniy Stepanov", "Evgeniy Stepanov",
"", "",
vf_open, vf_open,
&vf_opts .priv_size = sizeof(struct vf_priv_s),
.priv_defaults = &vf_priv_dflt,
.options = vf_opts_fields,
}; };

View File

@ -27,7 +27,6 @@
#include "config.h" #include "config.h"
#include "core/cpudetect.h" #include "core/cpudetect.h"
#include "core/options.h" #include "core/options.h"
#include "core/m_struct.h"
#include "core/mp_msg.h" #include "core/mp_msg.h"
#include "video/img_format.h" #include "video/img_format.h"
@ -517,19 +516,11 @@ static int vf_open(vf_instance_t *vf, char *args){
return 1; return 1;
} }
#undef ST_OFF #define OPT_BASE_STRUCT struct vf_priv_s
#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f)
static const m_option_t vf_opts_fields[] = { static const m_option_t vf_opts_fields[] = {
{"mode", ST_OFF(mode), CONF_TYPE_INT, M_OPT_RANGE, 0, 3}, OPT_INTRANGE("mode", mode, 0, 0, 3),
{"enabled", ST_OFF(do_deinterlace), CONF_TYPE_FLAG, 0, 0, 1}, OPT_INTRANGE("enabled", do_deinterlace, 0, 0, 1),
{0} {0}
};
static const m_struct_t vf_opts = {
"yadif",
sizeof(struct vf_priv_s),
&vf_priv_default,
vf_opts_fields
}; };
const vf_info_t vf_info_yadif = { const vf_info_t vf_info_yadif = {
@ -538,5 +529,7 @@ const vf_info_t vf_info_yadif = {
"Michael Niedermayer", "Michael Niedermayer",
"", "",
vf_open, vf_open,
&vf_opts .priv_size = sizeof(struct vf_priv_s),
.priv_defaults = &vf_priv_default,
.options = vf_opts_fields,
}; };