diff options
Diffstat (limited to 'video')
-rw-r--r-- | video/filter/vf.c | 89 | ||||
-rw-r--r-- | video/filter/vf.h | 6 | ||||
-rw-r--r-- | video/filter/vf_crop.c | 24 | ||||
-rw-r--r-- | video/filter/vf_delogo.c | 32 | ||||
-rw-r--r-- | video/filter/vf_dlopen.c | 60 | ||||
-rw-r--r-- | video/filter/vf_expand.c | 32 | ||||
-rw-r--r-- | video/filter/vf_format.c | 24 | ||||
-rw-r--r-- | video/filter/vf_gradfun.c | 23 | ||||
-rw-r--r-- | video/filter/vf_lavfi.c | 21 | ||||
-rw-r--r-- | video/filter/vf_noformat.c | 20 | ||||
-rw-r--r-- | video/filter/vf_scale.c | 31 | ||||
-rw-r--r-- | video/filter/vf_stereo3d.c | 26 | ||||
-rw-r--r-- | video/filter/vf_sub.c | 22 | ||||
-rw-r--r-- | video/filter/vf_yadif.c | 21 |
14 files changed, 179 insertions, 252 deletions
diff --git a/video/filter/vf.c b/video/filter/vf.c index c9fd80bceb..5d2b9b8431 100644 --- a/video/filter/vf.c +++ b/video/filter/vf.c @@ -28,7 +28,7 @@ #include "core/mp_msg.h" #include "core/m_option.h" -#include "core/m_struct.h" +#include "core/m_config.h" #include "core/options.h" @@ -115,12 +115,26 @@ static const vf_info_t *const filter_list[] = { 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 -const m_obj_list_t vf_obj_list = { - (void **)filter_list, - M_ST_OFF(vf_info_t, name), - M_ST_OFF(vf_info_t, info), - M_ST_OFF(vf_info_t, opts) +const struct m_obj_list vf_obj_list = { + .get_desc = get_desc, + .description = "video filters", }; 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, const char *name, char **args) { - vf_instance_t *vf; - int i; - for (i = 0;; i++) { - if (!filter_list[i]) { - mp_tmsg(MSGT_VFILTER, MSGL_ERR, - "Couldn't find video filter '%s'.\n", name); - return NULL; // no such filter! - } - if (!strcmp(filter_list[i]->name, name)) - break; + struct m_obj_desc desc; + if (!m_obj_list_find(&desc, &vf_obj_list, bstr0(name))) { + mp_tmsg(MSGT_VFILTER, MSGL_ERR, + "Couldn't find video filter '%s'.\n", name); + return NULL; } - vf = talloc_zero(NULL, struct vf_instance); - vf->opts = opts; - vf->info = filter_list[i]; - vf->next = next; - vf->config = vf_next_config; - vf->control = vf_next_control; - vf->query_format = vf_default_query_format; - vf->filter = vf_default_filter; - vf->out_pool = talloc_steal(vf, mp_image_pool_new(16)); - if (vf->info->opts) { // vf_vo get some special argument - const m_struct_t *st = vf->info->opts; - void *vf_priv = m_struct_alloc(st); - int n; - for (n = 0; args && args[2 * n]; n++) - m_struct_set(st, vf_priv, args[2 * n], bstr0(args[2 * n + 1])); - vf->priv = vf_priv; - args = NULL; - } else // Otherwise we should have the '_oldargs_' - if (args && !strcmp(args[0], "_oldargs_")) - args = (char **)args[1]; - else - args = NULL; + vf_instance_t *vf = talloc_zero(NULL, struct vf_instance); + *vf = (vf_instance_t) { + .info = desc.p, + .opts = opts, + .next = next, + .config = vf_next_config, + .control = vf_next_control, + .query_format = vf_default_query_format, + .filter = vf_default_filter, + .out_pool = talloc_steal(vf, mp_image_pool_new(16)), + }; + struct m_config *config = m_config_from_obj_desc(vf, &desc); + void *priv = NULL; + if (m_config_initialize_obj(config, &desc, &priv, &args) < 0) + goto error; + vf->priv = priv; int retcode = vf->info->vf_open(vf, (char *)args); - if (retcode > 0) - return vf; + if (retcode < 0) + goto error; + return vf; + +error: talloc_free(vf); return NULL; } @@ -551,9 +557,6 @@ void vf_uninit_filter(vf_instance_t *vf) if (vf->uninit) vf->uninit(vf); vf_forget_frames(vf); - const m_struct_t *st = vf->info->opts; - if (st) - m_struct_free(st, vf->priv); talloc_free(vf); } diff --git a/video/filter/vf.h b/video/filter/vf.h index b47f44a7ca..067e857f0d 100644 --- a/video/filter/vf.h +++ b/video/filter/vf.h @@ -36,8 +36,10 @@ typedef struct vf_info { const char *author; const char *comment; int (*vf_open)(struct vf_instance *vf, char *args); - // Ptr to a struct describing the options - const void *opts; + void *damn_you; + int priv_size; + const void *priv_defaults; + const struct m_option *options; } vf_info_t; struct vf_format { diff --git a/video/filter/vf_crop.c b/video/filter/vf_crop.c index 49b4e7e55b..c84dd22b84 100644 --- a/video/filter/vf_crop.c +++ b/video/filter/vf_crop.c @@ -29,7 +29,6 @@ #include "vf.h" #include "core/m_option.h" -#include "core/m_struct.h" static const struct vf_priv_s { int crop_w,crop_h; @@ -95,20 +94,13 @@ static int vf_open(vf_instance_t *vf, char *args){ 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[] = { - {"w", ST_OFF(crop_w), CONF_TYPE_INT, M_OPT_MIN,0 ,0, NULL}, - {"h", ST_OFF(crop_h), CONF_TYPE_INT, M_OPT_MIN,0 ,0, NULL}, - {"x", ST_OFF(crop_x), CONF_TYPE_INT, M_OPT_MIN,-1 ,0, NULL}, - {"y", ST_OFF(crop_y), CONF_TYPE_INT, M_OPT_MIN,-1 ,0, NULL}, - { NULL, NULL, 0, 0, 0, 0, NULL } -}; - -static const m_struct_t vf_opts = { - "crop", - sizeof(struct vf_priv_s), - &vf_priv_dflt, - vf_opts_fields + OPT_INT("w", crop_w, M_OPT_MIN, .min = 0), + OPT_INT("h", crop_h, M_OPT_MIN, .min = 0), + OPT_INT("x", crop_x, M_OPT_MIN, .min = -1), + OPT_INT("y", crop_y, M_OPT_MIN, .min = -1), + {0} }; const vf_info_t vf_info_crop = { @@ -117,7 +109,9 @@ const vf_info_t vf_info_crop = { "A'rpi", "", vf_open, - &vf_opts + .priv_size = sizeof(struct vf_priv_s), + .priv_defaults = &vf_priv_dflt, + .options = vf_opts_fields, }; //===========================================================================// diff --git a/video/filter/vf_delogo.c b/video/filter/vf_delogo.c index d90d852057..6b716cab14 100644 --- a/video/filter/vf_delogo.c +++ b/video/filter/vf_delogo.c @@ -36,14 +36,13 @@ #include "video/memcpy_pic.h" #include "core/m_option.h" -#include "core/m_struct.h" //===========================================================================// static struct vf_priv_s { unsigned int outfmt; int xoff, yoff, lw, lh, band, show; - const char *file; + char *file; struct timed_rectangle { int ts, x, y, w, h, b; } *timed_rect; @@ -304,23 +303,16 @@ static int vf_open(vf_instance_t *vf, char *args){ 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[] = { - { "x", ST_OFF(xoff), CONF_TYPE_INT, 0, 0, 0, NULL }, - { "y", ST_OFF(yoff), CONF_TYPE_INT, 0, 0, 0, NULL }, - { "w", ST_OFF(lw), CONF_TYPE_INT, 0, 0, 0, NULL }, - { "h", ST_OFF(lh), CONF_TYPE_INT, 0, 0, 0, NULL }, - { "t", ST_OFF(band), CONF_TYPE_INT, 0, 0, 0, NULL }, - { "band", ST_OFF(band), CONF_TYPE_INT, 0, 0, 0, NULL }, // alias - { "file", ST_OFF(file), CONF_TYPE_STRING, 0, 0, 0, NULL }, - { NULL, NULL, 0, 0, 0, 0, NULL } -}; - -static const m_struct_t vf_opts = { - "delogo", - sizeof(struct vf_priv_s), - &vf_priv_dflt, - vf_opts_fields + OPT_INT("x", xoff, 0), + OPT_INT("y", yoff, 0), + OPT_INT("w", lw, 0), + OPT_INT("h", lh, 0), + OPT_INT("t", band, 0), + OPT_INT("band", band, 0), // alias + OPT_STRING("file", file, 0), + {0} }; const vf_info_t vf_info_delogo = { @@ -329,7 +321,9 @@ const vf_info_t vf_info_delogo = { "Jindrich Makovicka, Alex Beregszaszi", "", vf_open, - &vf_opts + .priv_size = sizeof(struct vf_priv_s), + .priv_defaults = &vf_priv_dflt, + .options = vf_opts_fields, }; //===========================================================================// diff --git a/video/filter/vf_dlopen.c b/video/filter/vf_dlopen.c index 72e747c2a7..f40762beab 100644 --- a/video/filter/vf_dlopen.c +++ b/video/filter/vf_dlopen.c @@ -29,7 +29,6 @@ #include "vf.h" #include "core/m_option.h" -#include "core/m_struct.h" #include "vf_dlopen.h" @@ -46,9 +45,9 @@ #endif static struct vf_priv_s { - const char *cfg_dllname; + char *cfg_dllname; int cfg_argc; - const char *cfg_argv[16]; + char *cfg_argv[16]; void *dll; 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) 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, "function did not create a filter: %s\n", vf->priv->cfg_dllname); @@ -351,33 +352,26 @@ static int vf_open(vf_instance_t *vf, char *args) return 1; } -#define ST_OFF(f) M_ST_OFF(struct vf_priv_s, f) -static m_option_t vf_opts_fields[] = { - {"dll", ST_OFF(cfg_dllname), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"a0", ST_OFF(cfg_argv[0]), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"a1", ST_OFF(cfg_argv[1]), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"a2", ST_OFF(cfg_argv[2]), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"a3", ST_OFF(cfg_argv[3]), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"a4", ST_OFF(cfg_argv[4]), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"a5", ST_OFF(cfg_argv[5]), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"a6", ST_OFF(cfg_argv[6]), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"a7", ST_OFF(cfg_argv[7]), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"a8", ST_OFF(cfg_argv[8]), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"a9", ST_OFF(cfg_argv[9]), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"a10", ST_OFF(cfg_argv[10]), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"a11", ST_OFF(cfg_argv[11]), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"a12", ST_OFF(cfg_argv[12]), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"a13", ST_OFF(cfg_argv[13]), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"a14", ST_OFF(cfg_argv[14]), CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"a15", ST_OFF(cfg_argv[15]), CONF_TYPE_STRING, 0, 0, 0, NULL}, - { NULL, NULL, 0, 0, 0, 0, NULL } -}; - -static const m_struct_t vf_opts = { - "dlopen", - sizeof(struct vf_priv_s), - &vf_priv_dflt, - vf_opts_fields +#define OPT_BASE_STRUCT struct vf_priv_s +static const m_option_t vf_opts_fields[] = { + OPT_STRING("dll", cfg_dllname, 0), + OPT_STRING("a0", cfg_argv[0], 0), + OPT_STRING("a1", cfg_argv[1], 0), + OPT_STRING("a2", cfg_argv[2], 0), + OPT_STRING("a3", cfg_argv[3], 0), + OPT_STRING("a4", cfg_argv[4], 0), + OPT_STRING("a5", cfg_argv[5], 0), + OPT_STRING("a6", cfg_argv[6], 0), + OPT_STRING("a7", cfg_argv[7], 0), + OPT_STRING("a8", cfg_argv[8], 0), + OPT_STRING("a9", cfg_argv[9], 0), + OPT_STRING("a10", cfg_argv[10], 0), + OPT_STRING("a11", cfg_argv[11], 0), + OPT_STRING("a12", cfg_argv[12], 0), + OPT_STRING("a13", cfg_argv[13], 0), + OPT_STRING("a14", cfg_argv[14], 0), + OPT_STRING("a15", cfg_argv[15], 0), + {0} }; const vf_info_t vf_info_dlopen = { @@ -386,7 +380,9 @@ const vf_info_t vf_info_dlopen = { "Rudolf Polzer", "", vf_open, - &vf_opts + .priv_size = sizeof(struct vf_priv_s), + .priv_defaults = &vf_priv_dflt, + .options = vf_opts_fields, }; //===========================================================================// diff --git a/video/filter/vf_expand.c b/video/filter/vf_expand.c index efe3f9dbb3..7b1b76ee97 100644 --- a/video/filter/vf_expand.c +++ b/video/filter/vf_expand.c @@ -34,7 +34,6 @@ #include "video/memcpy_pic.h" #include "core/m_option.h" -#include "core/m_struct.h" static struct vf_priv_s { // 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; } -#define ST_OFF(f) M_ST_OFF(struct vf_priv_s,f) -static m_option_t vf_opts_fields[] = { - {"w", ST_OFF(cfg_exp_w), CONF_TYPE_INT, 0, 0 ,0, NULL}, - {"h", ST_OFF(cfg_exp_h), CONF_TYPE_INT, 0, 0 ,0, NULL}, - {"x", ST_OFF(cfg_exp_x), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL}, - {"y", ST_OFF(cfg_exp_y), CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL}, - {"aspect", ST_OFF(aspect), CONF_TYPE_DOUBLE, M_OPT_MIN, 0, 0, NULL}, - {"round", ST_OFF(round), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL}, - { NULL, NULL, 0, 0, 0, 0, NULL } +#define OPT_BASE_STRUCT struct vf_priv_s +static const m_option_t vf_opts_fields[] = { + OPT_INT("w", cfg_exp_w, 0), + OPT_INT("h", cfg_exp_h, 0), + OPT_INT("x", cfg_exp_x, M_OPT_MIN, .min = -1), + OPT_INT("y", cfg_exp_y, M_OPT_MIN, .min = -1), + OPT_DOUBLE("aspect", aspect, M_OPT_MIN, .min = 0), + OPT_INT("round", round, M_OPT_MIN, .min = 1), + {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 = { "expanding", "expand", "A'rpi", "", vf_open, - &vf_opts + .priv_size = sizeof(struct vf_priv_s), + .priv_defaults = &vf_priv_dflt, + .options = vf_opts_fields, }; //===========================================================================// diff --git a/video/filter/vf_format.c b/video/filter/vf_format.c index d37778e38d..639a564113 100644 --- a/video/filter/vf_format.c +++ b/video/filter/vf_format.c @@ -29,11 +29,10 @@ #include "vf.h" #include "core/m_option.h" -#include "core/m_struct.h" static struct vf_priv_s { - unsigned int fmt; - unsigned int outfmt; + int fmt; + int outfmt; } const vf_priv_dflt = { IMGFMT_YUYV, 0 @@ -73,18 +72,11 @@ static int vf_open(vf_instance_t *vf, char *args){ 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[] = { - {"fmt", ST_OFF(fmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL}, - {"outfmt", ST_OFF(outfmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL}, - { NULL, NULL, 0, 0, 0, 0, NULL } -}; - -static const m_struct_t vf_opts = { - "format", - sizeof(struct vf_priv_s), - &vf_priv_dflt, - vf_opts_fields + OPT_IMAGEFORMAT("fmt", fmt, 0), + OPT_IMAGEFORMAT("outfmt", outfmt, 0), + {0} }; const vf_info_t vf_info_format = { @@ -93,7 +85,9 @@ const vf_info_t vf_info_format = { "A'rpi", "FIXME! get_image()/put_image()", vf_open, - &vf_opts + .priv_size = sizeof(struct vf_priv_s), + .priv_defaults = &vf_priv_dflt, + .options = vf_opts_fields, }; //===========================================================================// diff --git a/video/filter/vf_gradfun.c b/video/filter/vf_gradfun.c index 227e16b028..4217af0b4d 100644 --- a/video/filter/vf_gradfun.c +++ b/video/filter/vf_gradfun.c @@ -44,7 +44,6 @@ #include "compat/x86_cpu.h" #include "core/m_option.h" -#include "core/m_struct.h" struct vf_priv_s { float cfg_thresh; @@ -393,20 +392,12 @@ static int vf_open(vf_instance_t *vf, char *args) return 1; } -#undef ST_OFF -#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[] = { - {"strength", ST_OFF(cfg_thresh), CONF_TYPE_FLOAT, M_OPT_RANGE, 0.51, 255, NULL}, - {"radius", ST_OFF(cfg_radius), CONF_TYPE_INT, M_OPT_RANGE, 4, 32, NULL}, - {"size", ST_OFF(cfg_size), CONF_TYPE_FLOAT, M_OPT_RANGE, 0.1, 5.0, NULL}, - { NULL, NULL, 0, 0, 0, 0, NULL } -}; - -static const m_struct_t vf_opts = { - "gradfun", - sizeof(struct vf_priv_s), - &vf_priv_dflt, - vf_opts_fields + OPT_FLOATRANGE("strength", cfg_thresh, 0, 0.51, 255), + OPT_INTRANGE("radius", cfg_radius, 0, 4, 32), + OPT_FLOATRANGE("size", cfg_size, 0, 0.1, 5.0), + {0} }; const vf_info_t vf_info_gradfun = { @@ -415,5 +406,7 @@ const vf_info_t vf_info_gradfun = { "Loren Merritt", "", vf_open, - &vf_opts + .priv_size = sizeof(struct vf_priv_s), + .priv_defaults = &vf_priv_dflt, + .options = vf_opts_fields, }; diff --git a/video/filter/vf_lavfi.c b/video/filter/vf_lavfi.c index 6d5735b433..d1e7a6e0cf 100644 --- a/video/filter/vf_lavfi.c +++ b/video/filter/vf_lavfi.c @@ -37,7 +37,6 @@ #include "core/mp_msg.h" #include "core/m_option.h" -#include "core/m_struct.h" #include "core/av_opts.h" #include "video/img_format.h" @@ -326,27 +325,21 @@ static int vf_open(vf_instance_t *vf, char *args) return 1; } -#undef ST_OFF -#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[] = { - {"graph", ST_OFF(cfg_graph), CONF_TYPE_STRING, CONF_MIN, 1}, - {"sws_flags", ST_OFF(cfg_sws_flags), CONF_TYPE_INT64}, - {"o", ST_OFF(cfg_avopts), CONF_TYPE_STRING}, + OPT_STRING("graph", cfg_graph, M_OPT_MIN, .min = 1), + OPT_INT64("sws_flags", cfg_sws_flags, 0), + OPT_STRING("o", cfg_avopts, 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 = { "libavfilter bridge", "lavfi", "", "", vf_open, - &vf_opts + .priv_size = sizeof(struct vf_priv_s), + .priv_defaults = &vf_priv_dflt, + .options = vf_opts_fields, }; diff --git a/video/filter/vf_noformat.c b/video/filter/vf_noformat.c index 3d7e841db6..cfdf91401a 100644 --- a/video/filter/vf_noformat.c +++ b/video/filter/vf_noformat.c @@ -29,10 +29,9 @@ #include "vf.h" #include "core/m_option.h" -#include "core/m_struct.h" static struct vf_priv_s { - unsigned int fmt; + int fmt; } const vf_priv_dflt = { IMGFMT_420P }; @@ -50,17 +49,10 @@ static int vf_open(vf_instance_t *vf, char *args){ 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[] = { - {"fmt", ST_OFF(fmt), CONF_TYPE_IMGFMT, 0,0 ,0, NULL}, - { NULL, NULL, 0, 0, 0, 0, NULL } -}; - -static const m_struct_t vf_opts = { - "noformat", - sizeof(struct vf_priv_s), - &vf_priv_dflt, - vf_opts_fields + OPT_IMAGEFORMAT("fmt", fmt, 0), + {0} }; const vf_info_t vf_info_noformat = { @@ -69,7 +61,9 @@ const vf_info_t vf_info_noformat = { "Joey", "", vf_open, - &vf_opts + .priv_size = sizeof(struct vf_priv_s), + .priv_defaults = &vf_priv_dflt, + .options = vf_opts_fields, }; //===========================================================================// diff --git a/video/filter/vf_scale.c b/video/filter/vf_scale.c index 4653b3bcbe..7237a2c224 100644 --- a/video/filter/vf_scale.c +++ b/video/filter/vf_scale.c @@ -40,7 +40,6 @@ #include "video/out/vo.h" #include "core/m_option.h" -#include "core/m_struct.h" static struct vf_priv_s { int w, h; @@ -432,24 +431,16 @@ static int vf_open(vf_instance_t *vf, char *args) return 1; } -#undef ST_OFF -#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[] = { - {"w", ST_OFF(cfg_w), CONF_TYPE_INT, M_OPT_MIN, -11, 0, NULL}, - {"h", ST_OFF(cfg_h), CONF_TYPE_INT, M_OPT_MIN, -11, 0, NULL}, - {"chr-drop", ST_OFF(v_chr_drop), CONF_TYPE_INT, M_OPT_RANGE, 0, 3, NULL}, - {"param", ST_OFF(param[0]), CONF_TYPE_DOUBLE, M_OPT_RANGE, 0.0, 100.0, NULL}, - {"param2", ST_OFF(param[1]), CONF_TYPE_DOUBLE, M_OPT_RANGE, 0.0, 100.0, NULL}, - {"noup", ST_OFF(noup), CONF_TYPE_INT, M_OPT_RANGE, 0, 2, NULL}, - {"arnd", ST_OFF(accurate_rnd), CONF_TYPE_FLAG, 0, 0, 1, NULL}, - { NULL, NULL, 0, 0, 0, 0, NULL } -}; - -static const m_struct_t vf_opts = { - "scale", - sizeof(struct vf_priv_s), - &vf_priv_dflt, - vf_opts_fields + OPT_INT("w", cfg_w, M_OPT_MIN, .min = -11), + OPT_INT("h", cfg_h, M_OPT_MIN, .min = -11), + OPT_DOUBLE("param", param[0], M_OPT_RANGE, .min = 0.0, .max = 100.0), + OPT_DOUBLE("param2", param[1], M_OPT_RANGE, .min = 0.0, .max = 100.0), + OPT_INTRANGE("chr-drop", v_chr_drop, 0, 0, 3), + OPT_INTRANGE("noup", noup, 0, 0, 2), + OPT_FLAG("arnd", accurate_rnd, 0), + {0} }; const vf_info_t vf_info_scale = { @@ -458,7 +449,9 @@ const vf_info_t vf_info_scale = { "A'rpi", "", vf_open, - &vf_opts + .priv_size = sizeof(struct vf_priv_s), + .priv_defaults = &vf_priv_dflt, + .options = vf_opts_fields, }; //===========================================================================// diff --git a/video/filter/vf_stereo3d.c b/video/filter/vf_stereo3d.c index 555e87f78e..9d546388ff 100644 --- a/video/filter/vf_stereo3d.c +++ b/video/filter/vf_stereo3d.c @@ -30,7 +30,6 @@ #include "video/img_format.h" #include "video/mp_image.h" #include "vf.h" -#include "core/m_struct.h" #include "core/m_option.h" #include "libavutil/common.h" @@ -66,7 +65,7 @@ typedef enum stereo_code { } stereo_code; typedef struct component { - stereo_code fmt; + int fmt; unsigned int width; unsigned int height; unsigned int off_left; @@ -455,22 +454,15 @@ const struct m_opt_choice_alternatives stereo_code_names[] = { { NULL, 0} }; -#undef ST_OFF -#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[] = { - {"in", ST_OFF(in.fmt), CONF_TYPE_CHOICE, .priv = (void *)stereo_code_names}, - {"out", ST_OFF(out.fmt), CONF_TYPE_CHOICE, .priv = (void *)stereo_code_names}, - { NULL, NULL, 0, 0, 0, 0, NULL } + OPT_GENERAL(int, "in", in.fmt, 0, .type = CONF_TYPE_CHOICE, + .priv = (void *)stereo_code_names), + 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==// const vf_info_t vf_info_stereo3d = { "stereoscopic 3d view", @@ -478,5 +470,7 @@ const vf_info_t vf_info_stereo3d = { "Gordon Schmidt", "view stereoscopic videos", vf_open, - &vf_opts + .priv_size = sizeof(struct vf_priv_s), + .priv_defaults = &vf_priv_default, + .options = vf_opts_fields, }; diff --git a/video/filter/vf_sub.c b/video/filter/vf_sub.c index e85a58afb7..519f3c3eb7 100644 --- a/video/filter/vf_sub.c +++ b/video/filter/vf_sub.c @@ -41,7 +41,6 @@ #include "video/memcpy_pic.h" #include "core/m_option.h" -#include "core/m_struct.h" static const struct vf_priv_s { int opt_top_margin, opt_bottom_margin; @@ -140,20 +139,11 @@ static int vf_open(vf_instance_t *vf, char *args) 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[] = { - {"bottom-margin", ST_OFF(opt_bottom_margin), - CONF_TYPE_INT, M_OPT_RANGE, 0, 2000}, - {"top-margin", ST_OFF(opt_top_margin), - 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 + OPT_INTRANGE("bottom-margin", opt_bottom_margin, 0, 0, 2000), + OPT_INTRANGE("top-margin", opt_top_margin, 0, 0, 2000), + {0} }; const vf_info_t vf_info_sub = { @@ -162,5 +152,7 @@ const vf_info_t vf_info_sub = { "Evgeniy Stepanov", "", vf_open, - &vf_opts + .priv_size = sizeof(struct vf_priv_s), + .priv_defaults = &vf_priv_dflt, + .options = vf_opts_fields, }; diff --git a/video/filter/vf_yadif.c b/video/filter/vf_yadif.c index 017e7c515c..02b23c61c5 100644 --- a/video/filter/vf_yadif.c +++ b/video/filter/vf_yadif.c @@ -27,7 +27,6 @@ #include "config.h" #include "core/cpudetect.h" #include "core/options.h" -#include "core/m_struct.h" #include "core/mp_msg.h" #include "video/img_format.h" @@ -517,19 +516,11 @@ static int vf_open(vf_instance_t *vf, char *args){ return 1; } -#undef ST_OFF -#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[] = { - {"mode", ST_OFF(mode), CONF_TYPE_INT, M_OPT_RANGE, 0, 3}, - {"enabled", ST_OFF(do_deinterlace), CONF_TYPE_FLAG, 0, 0, 1}, - {0} -}; - -static const m_struct_t vf_opts = { - "yadif", - sizeof(struct vf_priv_s), - &vf_priv_default, - vf_opts_fields + OPT_INTRANGE("mode", mode, 0, 0, 3), + OPT_INTRANGE("enabled", do_deinterlace, 0, 0, 1), + {0} }; const vf_info_t vf_info_yadif = { @@ -538,5 +529,7 @@ const vf_info_t vf_info_yadif = { "Michael Niedermayer", "", vf_open, - &vf_opts + .priv_size = sizeof(struct vf_priv_s), + .priv_defaults = &vf_priv_default, + .options = vf_opts_fields, }; |