diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2013-01-02 14:40:02 +0400 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2013-01-04 14:48:54 +0400 |
commit | f7dc6aa6b194ea7b8e0d6f475f8ba04c3cd50a99 (patch) | |
tree | 7a0265b3c3721787917702b551d326415519af70 /libavfilter/vf_yadif.c | |
parent | 8674597fe53179538a27093e12fc81ed9f84e017 (diff) |
lavfi/yadif: add support to named options and options introspection
Also rename the "enable_auto" field to "deint", to match the name of the
option.
Diffstat (limited to 'libavfilter/vf_yadif.c')
-rw-r--r-- | libavfilter/vf_yadif.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 040c6230f9..824137b178 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -20,6 +20,7 @@ #include "libavutil/avassert.h" #include "libavutil/cpu.h" #include "libavutil/common.h" +#include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "avfilter.h" #include "formats.h" @@ -231,7 +232,7 @@ static int filter_frame(AVFilterLink *link, AVFilterBufferRef *picref) if (!yadif->cur) return 0; - if (yadif->auto_enable && !yadif->cur->video->interlaced) { + if (yadif->deint && !yadif->cur->video->interlaced) { yadif->out = avfilter_ref_buffer(yadif->cur, ~AV_PERM_WRITE); if (!yadif->out) return AVERROR(ENOMEM); @@ -296,6 +297,18 @@ static int request_frame(AVFilterLink *link) return 0; } +#define OFFSET(x) offsetof(YADIFContext, x) +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption yadif_options[] = { + { "mode", "specify the interlacing mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 3, FLAGS }, + { "parity", "specify the assumed picture field parity", OFFSET(parity), AV_OPT_TYPE_INT, {.i64=-1}, -1, 1, FLAGS }, + { "deint", "specify which frames to deinterlace", OFFSET(deint), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS }, + {NULL}, +}; + +AVFILTER_DEFINE_CLASS(yadif); + static av_cold void uninit(AVFilterContext *ctx) { YADIFContext *yadif = ctx->priv; @@ -304,6 +317,7 @@ static av_cold void uninit(AVFilterContext *ctx) avfilter_unref_bufferp(&yadif->cur ); avfilter_unref_bufferp(&yadif->next); av_freep(&yadif->temp_line); yadif->temp_line_size = 0; + av_opt_free(yadif); } static int query_formats(AVFilterContext *ctx) @@ -341,23 +355,24 @@ static int query_formats(AVFilterContext *ctx) static av_cold int init(AVFilterContext *ctx, const char *args) { YADIFContext *yadif = ctx->priv; + static const char *shorthand[] = { "mode", "parity", "enable", NULL }; + int ret; - yadif->mode = 0; - yadif->parity = -1; - yadif->auto_enable = 0; yadif->csp = NULL; - if (args) - sscanf(args, "%d:%d:%d", - &yadif->mode, &yadif->parity, &yadif->auto_enable); + yadif->class = &yadif_class; + av_opt_set_defaults(yadif); + + if ((ret = av_opt_set_from_string(yadif, args, shorthand, "=", ":")) < 0) + return ret; yadif->filter_line = filter_line_c; if (ARCH_X86) ff_yadif_init_x86(yadif); - av_log(ctx, AV_LOG_VERBOSE, "mode:%d parity:%d auto_enable:%d\n", - yadif->mode, yadif->parity, yadif->auto_enable); + av_log(ctx, AV_LOG_VERBOSE, "mode:%d parity:%d deint:%d\n", + yadif->mode, yadif->parity, yadif->deint); return 0; } @@ -413,6 +428,7 @@ AVFilter avfilter_vf_yadif = { .query_formats = query_formats, .inputs = avfilter_vf_yadif_inputs, - .outputs = avfilter_vf_yadif_outputs, + + .priv_class = &yadif_class, }; |