Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libavfilter/vf_fieldorder.c')
-rw-r--r--libavfilter/vf_fieldorder.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/libavfilter/vf_fieldorder.c b/libavfilter/vf_fieldorder.c
index e7745e1690..1ef2ad8ab3 100644
--- a/libavfilter/vf_fieldorder.c
+++ b/libavfilter/vf_fieldorder.c
@@ -1,20 +1,20 @@
/*
* Copyright (c) 2011 Mark Himsley
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -23,11 +23,7 @@
* video field order filter, heavily influenced by vf_pad.c
*/
-/* #define DEBUG */
-
-#include <stdio.h>
-#include <string.h>
-
+#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/pixdesc.h"
@@ -36,34 +32,37 @@
#include "internal.h"
#include "video.h"
-typedef struct
-{
+enum FieldOrder {
+ ORDER_TFF,
+ ORDER_BFF,
+ ORDER_NB,
+};
+
+typedef struct {
+ const AVClass *class;
+ enum FieldOrder order;
unsigned int dst_tff; ///< output bff/tff
int line_size[4]; ///< bytes of pixel data per line for each plane
} FieldOrderContext;
+#define OFFSET(x) offsetof(FieldOrderContext, x)
+#define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
+
+static const AVOption fieldorder_options[] = {
+ { "order", "set output field order", OFFSET(order), AV_OPT_TYPE_INT, {.i64=ORDER_TFF}, 0, ORDER_NB-1, FLAGS, "order" },
+ { "tff", "set top field first", 0, AV_OPT_TYPE_CONST, {.i64=ORDER_TFF}, .flags=FLAGS, .unit="order" },
+ { "bff", "set bottom field first", 0, AV_OPT_TYPE_CONST, {.i64=ORDER_BFF}, .flags=FLAGS, .unit="order" },
+ { NULL }
+};
+
+AVFILTER_DEFINE_CLASS(fieldorder);
+
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);
+ fieldorder->dst_tff = fieldorder->order == ORDER_TFF;
+ av_log(ctx, AV_LOG_VERBOSE, "tff:%d\n", fieldorder->dst_tff);
return 0;
}
@@ -197,6 +196,8 @@ static const AVFilterPad avfilter_vf_fieldorder_outputs[] = {
{ NULL }
};
+static const char *const shorthand[] = { "order", NULL };
+
AVFilter avfilter_vf_fieldorder = {
.name = "fieldorder",
.description = NULL_IF_CONFIG_SMALL("Set the field order."),
@@ -205,4 +206,6 @@ AVFilter avfilter_vf_fieldorder = {
.query_formats = query_formats,
.inputs = avfilter_vf_fieldorder_inputs,
.outputs = avfilter_vf_fieldorder_outputs,
+ .priv_class = &fieldorder_class,
+ .shorthand = shorthand,
};