... | ... |
@@ -2385,6 +2385,28 @@ To change the sample aspect ratio to 10:11, specify: |
2385 | 2385 |
setsar=10:11 |
2386 | 2386 |
@end example |
2387 | 2387 |
|
2388 |
+@section setfield |
|
2389 |
+ |
|
2390 |
+Force field for the output video frame. |
|
2391 |
+ |
|
2392 |
+The @code{setfield} filter marks the interlace type field for the |
|
2393 |
+output frames. It does not change the input frame, but only sets the |
|
2394 |
+corresponding property, which affects how the frame is treated by |
|
2395 |
+followig filters (e.g. @code{fieldorder} or @code{yadif}). |
|
2396 |
+ |
|
2397 |
+It accepts a parameter representing an integer or a string, which can |
|
2398 |
+assume the following values: |
|
2399 |
+@table @samp |
|
2400 |
+@item -1, auto |
|
2401 |
+Keep the same field property. |
|
2402 |
+ |
|
2403 |
+@item 0, bff |
|
2404 |
+Mark the frame as bottom-field-first. |
|
2405 |
+ |
|
2406 |
+@item 1, tff |
|
2407 |
+Mark the frame as top-field-first. |
|
2408 |
+@end table |
|
2409 |
+ |
|
2388 | 2410 |
@section setpts |
2389 | 2411 |
|
2390 | 2412 |
Change the PTS (presentation timestamp) of the input video frames. |
... | ... |
@@ -79,6 +79,7 @@ OBJS-$(CONFIG_PIXDESCTEST_FILTER) += vf_pixdesctest.o |
79 | 79 |
OBJS-$(CONFIG_SCALE_FILTER) += vf_scale.o |
80 | 80 |
OBJS-$(CONFIG_SELECT_FILTER) += vf_select.o |
81 | 81 |
OBJS-$(CONFIG_SETDAR_FILTER) += vf_aspect.o |
82 |
+OBJS-$(CONFIG_SETFIELD_FILTER) += vf_setfield.o |
|
82 | 83 |
OBJS-$(CONFIG_SETPTS_FILTER) += vf_setpts.o |
83 | 84 |
OBJS-$(CONFIG_SETSAR_FILTER) += vf_aspect.o |
84 | 85 |
OBJS-$(CONFIG_SETTB_FILTER) += vf_settb.o |
... | ... |
@@ -87,6 +87,7 @@ void avfilter_register_all(void) |
87 | 87 |
REGISTER_FILTER (SCALE, scale, vf); |
88 | 88 |
REGISTER_FILTER (SELECT, select, vf); |
89 | 89 |
REGISTER_FILTER (SETDAR, setdar, vf); |
90 |
+ REGISTER_FILTER (SETFIELD, setfield, vf); |
|
90 | 91 |
REGISTER_FILTER (SETPTS, setpts, vf); |
91 | 92 |
REGISTER_FILTER (SETSAR, setsar, vf); |
92 | 93 |
REGISTER_FILTER (SETTB, settb, vf); |
... | ... |
@@ -29,7 +29,7 @@ |
29 | 29 |
#include "libavutil/avutil.h" |
30 | 30 |
|
31 | 31 |
#define LIBAVFILTER_VERSION_MAJOR 2 |
32 |
-#define LIBAVFILTER_VERSION_MINOR 61 |
|
32 |
+#define LIBAVFILTER_VERSION_MINOR 62 |
|
33 | 33 |
#define LIBAVFILTER_VERSION_MICRO 100 |
34 | 34 |
|
35 | 35 |
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
36 | 36 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,92 @@ |
0 |
+/* |
|
1 |
+ * Copyright (c) 2012 Stefano Sabatini |
|
2 |
+ * |
|
3 |
+ * This file is part of FFmpeg. |
|
4 |
+ * |
|
5 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
6 |
+ * modify it under the terms of the GNU Lesser General Public |
|
7 |
+ * License as published by the Free Software Foundation; either |
|
8 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
9 |
+ * |
|
10 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
11 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 |
+ * Lesser General Public License for more details. |
|
14 |
+ * |
|
15 |
+ * You should have received a copy of the GNU Lesser General Public |
|
16 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
17 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
18 |
+ */ |
|
19 |
+ |
|
20 |
+/** |
|
21 |
+ * @file |
|
22 |
+ * set field order |
|
23 |
+ */ |
|
24 |
+ |
|
25 |
+#include "avfilter.h" |
|
26 |
+ |
|
27 |
+typedef struct { |
|
28 |
+ int top_field_first; |
|
29 |
+} SetFieldContext; |
|
30 |
+ |
|
31 |
+static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) |
|
32 |
+{ |
|
33 |
+ SetFieldContext *setfield = ctx->priv; |
|
34 |
+ |
|
35 |
+ setfield->top_field_first = -1; |
|
36 |
+ |
|
37 |
+ if (args) { |
|
38 |
+ char c; |
|
39 |
+ if (sscanf(args, "%d%c", &setfield->top_field_first, &c) != 1) { |
|
40 |
+ if (!strcmp("tff", args)) setfield->top_field_first = 1; |
|
41 |
+ else if (!strcmp("bff", args)) setfield->top_field_first = 0; |
|
42 |
+ else if (!strcmp("auto", args)) setfield->top_field_first = -1; |
|
43 |
+ else { |
|
44 |
+ av_log(ctx, AV_LOG_ERROR, "Invalid argument '%s'\n", args); |
|
45 |
+ return AVERROR(EINVAL); |
|
46 |
+ } |
|
47 |
+ } |
|
48 |
+ } |
|
49 |
+ |
|
50 |
+ if (setfield->top_field_first < -1 || setfield->top_field_first > 1) { |
|
51 |
+ av_log(ctx, AV_LOG_ERROR, |
|
52 |
+ "Provided integer value %d must be included between -1 and +1\n", |
|
53 |
+ setfield->top_field_first); |
|
54 |
+ return AVERROR(EINVAL); |
|
55 |
+ } |
|
56 |
+ |
|
57 |
+ return 0; |
|
58 |
+} |
|
59 |
+ |
|
60 |
+static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) |
|
61 |
+{ |
|
62 |
+ SetFieldContext *setfield = inlink->dst->priv; |
|
63 |
+ AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0); |
|
64 |
+ |
|
65 |
+ if (setfield->top_field_first != -1) { |
|
66 |
+ outpicref->video->interlaced = 1; |
|
67 |
+ outpicref->video->top_field_first = setfield->top_field_first; |
|
68 |
+ } |
|
69 |
+ avfilter_start_frame(inlink->dst->outputs[0], outpicref); |
|
70 |
+} |
|
71 |
+ |
|
72 |
+AVFilter avfilter_vf_setfield = { |
|
73 |
+ .name = "setfield", |
|
74 |
+ .description = NULL_IF_CONFIG_SMALL("Force field for the output video frame."), |
|
75 |
+ .init = init, |
|
76 |
+ |
|
77 |
+ .priv_size = sizeof(SetFieldContext), |
|
78 |
+ |
|
79 |
+ .inputs = (const AVFilterPad[]) { |
|
80 |
+ { .name = "default", |
|
81 |
+ .type = AVMEDIA_TYPE_VIDEO, |
|
82 |
+ .get_video_buffer = avfilter_null_get_video_buffer, |
|
83 |
+ .start_frame = start_frame, }, |
|
84 |
+ { .name = NULL } |
|
85 |
+ }, |
|
86 |
+ .outputs = (const AVFilterPad[]) { |
|
87 |
+ { .name = "default", |
|
88 |
+ .type = AVMEDIA_TYPE_VIDEO, }, |
|
89 |
+ { .name = NULL } |
|
90 |
+ }, |
|
91 |
+}; |