aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2013-01-02 11:40:02 +0100
committerStefano Sabatini <stefasab@gmail.com>2013-01-04 11:48:54 +0100
commitf7dc6aa6b194ea7b8e0d6f475f8ba04c3cd50a99 (patch)
tree7a0265b3c3721787917702b551d326415519af70 /libavfilter
parent8674597fe53179538a27093e12fc81ed9f84e017 (diff)
downloadffmpeg-f7dc6aa6b194ea7b8e0d6f475f8ba04c3cd50a99.tar.gz
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')
-rw-r--r--libavfilter/version.h2
-rw-r--r--libavfilter/vf_yadif.c36
-rw-r--r--libavfilter/yadif.h4
3 files changed, 30 insertions, 12 deletions
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 3cc91fbeea..505cea0ded 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,7 +30,7 @@
#define LIBAVFILTER_VERSION_MAJOR 3
#define LIBAVFILTER_VERSION_MINOR 30
-#define LIBAVFILTER_VERSION_MICRO 102
+#define LIBAVFILTER_VERSION_MICRO 103
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
LIBAVFILTER_VERSION_MINOR, \
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,
};
diff --git a/libavfilter/yadif.h b/libavfilter/yadif.h
index 41691de65d..22904fb660 100644
--- a/libavfilter/yadif.h
+++ b/libavfilter/yadif.h
@@ -23,6 +23,8 @@
#include "avfilter.h"
typedef struct YADIFContext {
+ const AVClass *class;
+
/**
* 0: send 1 frame for each frame
* 1: send 1 frame for each field
@@ -44,7 +46,7 @@ typedef struct YADIFContext {
* 0: deinterlace all frames
* 1: only deinterlace frames marked as interlaced
*/
- int auto_enable;
+ int deint;
AVFilterBufferRef *cur;
AVFilterBufferRef *next;