summaryrefslogtreecommitdiff
path: root/libavfilter/vf_fieldorder.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-02-25 21:21:29 +0100
committerAnton Khirnov <anton@khirnov.net>2013-04-09 19:03:56 +0200
commita39c154049a2d0c4fb02a5c74f58d6986ec21cec (patch)
treebb07b51fc2b6a7681c73a4bd5f781f38e975161c /libavfilter/vf_fieldorder.c
parentb9dfee9fa259dfc885508179a359dccc9e7840bd (diff)
vf_fieldorder: switch to an AVOptions-based system.
Diffstat (limited to 'libavfilter/vf_fieldorder.c')
-rw-r--r--libavfilter/vf_fieldorder.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c
index e7745e1690..a7183a2091 100644
--- a/libavfilter/vf_fieldorder.c
+++ b/libavfilter/vf_fieldorder.c
@@ -30,6 +30,7 @@
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
+#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "formats.h"
@@ -38,36 +39,11 @@
typedef struct
{
- unsigned int dst_tff; ///< output bff/tff
+ const AVClass *class;
+ int dst_tff; ///< output bff/tff
int line_size[4]; ///< bytes of pixel data per line for each plane
} FieldOrderContext;
-static av_cold int init(AVFilterContext *ctx, const char *args)
-{
- FieldOrderContext *fieldorder = ctx->priv;
-
- const char *tff = "tff";
- const char *bff = "bff";
-
- if (!args) {
- fieldorder->dst_tff = 1;
- } else if (sscanf(args, "%u", &fieldorder->dst_tff) == 1) {
- fieldorder->dst_tff = !!fieldorder->dst_tff;
- } else if (!strcmp(tff, args)) {
- fieldorder->dst_tff = 1;
- } else if (!strcmp(bff, args)) {
- fieldorder->dst_tff = 0;
- } else {
- av_log(ctx, AV_LOG_ERROR, "Invalid argument '%s'.\n", args);
- return AVERROR(EINVAL);
- }
-
- av_log(ctx, AV_LOG_VERBOSE, "output field order: %s\n",
- fieldorder->dst_tff ? tff : bff);
-
- return 0;
-}
-
static int query_formats(AVFilterContext *ctx)
{
AVFilterFormats *formats;
@@ -177,6 +153,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
return ff_filter_frame(outlink, frame);
}
+#define OFFSET(x) offsetof(FieldOrderContext, x)
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
+static const AVOption options[] = {
+ { "order", "output field order", OFFSET(dst_tff), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS, "order" },
+ { "bff", "bottom field first", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, .unit = "order" },
+ { "tff", "top field first", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, .unit = "order" },
+ { NULL },
+};
+
+static const AVClass fieldorder_class = {
+ .class_name = "fieldorder",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
static const AVFilterPad avfilter_vf_fieldorder_inputs[] = {
{
.name = "default",
@@ -200,8 +192,8 @@ static const AVFilterPad avfilter_vf_fieldorder_outputs[] = {
AVFilter avfilter_vf_fieldorder = {
.name = "fieldorder",
.description = NULL_IF_CONFIG_SMALL("Set the field order."),
- .init = init,
.priv_size = sizeof(FieldOrderContext),
+ .priv_class = &fieldorder_class,
.query_formats = query_formats,
.inputs = avfilter_vf_fieldorder_inputs,
.outputs = avfilter_vf_fieldorder_outputs,