Browse code

Implement null video source.

Originally committed as revision 21240 to svn://svn.ffmpeg.org/ffmpeg/trunk

Stefano Sabatini authored on 2010/01/16 19:43:53
Showing 5 changed files
... ...
@@ -197,4 +197,20 @@ Flip the input video vertically.
197 197
 ./ffmpeg -i in.avi -vfilters "vflip" out.avi
198 198
 @end example
199 199
 
200
+@chapter Available video sources
201
+
202
+Below is a description of the currently available video sources.
203
+
204
+@section nullsrc
205
+
206
+Null video source, never return images. It is mainly useful as a
207
+template and to be employed in analysis / debugging tools.
208
+
209
+It accepts as optional parameter a string of the form
210
+``width:height'', where ``width'' and ``height'' specify the size of
211
+the configured source.
212
+
213
+The default values of ``width'' and ``height'' are respectively 352
214
+and 288 (corresponding to the CIF size format).
215
+
200 216
 @bye
... ...
@@ -20,4 +20,6 @@ OBJS-$(CONFIG_SCALE_FILTER)                  += vf_scale.o
20 20
 OBJS-$(CONFIG_SLICIFY_FILTER)                += vf_slicify.o
21 21
 OBJS-$(CONFIG_VFLIP_FILTER)                  += vf_vflip.o
22 22
 
23
+OBJS-$(CONFIG_NULLSRC_FILTER)                += vsrc_nullsrc.o
24
+
23 25
 include $(SUBDIR)../subdir.mak
... ...
@@ -41,4 +41,6 @@ void avfilter_register_all(void)
41 41
     REGISTER_FILTER (SCALE, scale, vf);
42 42
     REGISTER_FILTER (SLICIFY, slicify, vf);
43 43
     REGISTER_FILTER (VFLIP, vflip, vf);
44
+
45
+    REGISTER_FILTER (NULLSRC, nullsrc, vsrc);
44 46
 }
... ...
@@ -25,7 +25,7 @@
25 25
 #include "libavutil/avutil.h"
26 26
 
27 27
 #define LIBAVFILTER_VERSION_MAJOR  1
28
-#define LIBAVFILTER_VERSION_MINOR 15
28
+#define LIBAVFILTER_VERSION_MINOR 16
29 29
 #define LIBAVFILTER_VERSION_MICRO  0
30 30
 
31 31
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
32 32
new file mode 100644
... ...
@@ -0,0 +1,83 @@
0
+/*
1
+ * This file is part of FFmpeg.
2
+ *
3
+ * FFmpeg is free software; you can redistribute it and/or
4
+ * modify it under the terms of the GNU Lesser General Public
5
+ * License as published by the Free Software Foundation; either
6
+ * version 2.1 of the License, or (at your option) any later version.
7
+ *
8
+ * FFmpeg is distributed in the hope that it will be useful,
9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
+ * Lesser General Public License for more details.
12
+ *
13
+ * You should have received a copy of the GNU Lesser General Public
14
+ * License along with FFmpeg; if not, write to the Free Software
15
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+ */
17
+
18
+/**
19
+ * @file libavfilter/vsrc_nullsrc.c
20
+ * null video source
21
+ */
22
+
23
+#include "avfilter.h"
24
+
25
+typedef struct {
26
+    int w, h;
27
+} NullContext;
28
+
29
+static int init(AVFilterContext *ctx, const char *args, void *opaque)
30
+{
31
+    NullContext *priv = ctx->priv;
32
+
33
+    priv->w = 352;
34
+    priv->h = 288;
35
+
36
+    if (args)
37
+        sscanf(args, "%d:%d", &priv->w, &priv->h);
38
+
39
+    if (priv->w <= 0 || priv->h <= 0) {
40
+        av_log(ctx, AV_LOG_ERROR, "Non-positive size values are not acceptable.\n");
41
+        return -1;
42
+    }
43
+
44
+    return 0;
45
+}
46
+
47
+static int config_props(AVFilterLink *outlink)
48
+{
49
+    NullContext *priv = outlink->src->priv;
50
+
51
+    outlink->w = priv->w;
52
+    outlink->h = priv->h;
53
+
54
+    av_log(outlink->src, AV_LOG_INFO, "w:%d h:%d\n", priv->w, priv->h);
55
+
56
+    return 0;
57
+}
58
+
59
+static int request_frame(AVFilterLink *link)
60
+{
61
+    return -1;
62
+}
63
+
64
+AVFilter avfilter_vsrc_nullsrc = {
65
+    .name        = "nullsrc",
66
+    .description = "Null video source, never return images.",
67
+
68
+    .init       = init,
69
+    .priv_size = sizeof(NullContext),
70
+
71
+    .inputs    = (AVFilterPad[]) {{ .name = NULL}},
72
+
73
+    .outputs   = (AVFilterPad[]) {
74
+        {
75
+            .name            = "default",
76
+            .type            = CODEC_TYPE_VIDEO,
77
+            .config_props    = config_props,
78
+            .request_frame   = request_frame,
79
+        },
80
+        { .name = NULL}
81
+    },
82
+};