Browse code

Implement avfilter_graph_check_validity().

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

Stefano Sabatini authored on 2009/01/27 05:21:25
Showing 3 changed files
... ...
@@ -23,7 +23,7 @@
23 23
 #define AVFILTER_AVFILTER_H
24 24
 
25 25
 #define LIBAVFILTER_VERSION_MAJOR  0
26
-#define LIBAVFILTER_VERSION_MINOR  2
26
+#define LIBAVFILTER_VERSION_MINOR  3
27 27
 #define LIBAVFILTER_VERSION_MICRO  0
28 28
 
29 29
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
... ...
@@ -46,6 +46,36 @@ int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)
46 46
     return 0;
47 47
 }
48 48
 
49
+int avfilter_graph_check_validity(AVFilterGraph *graph, AVClass *log_ctx)
50
+{
51
+    AVFilterContext *filt;
52
+    int i, j;
53
+
54
+    for (i=0; i < graph->filter_count; i++) {
55
+        filt = graph->filters[i];
56
+
57
+        for (j = 0; j < filt->input_count; j++) {
58
+            if (!filt->inputs[j] || !filt->inputs[j]->src) {
59
+                av_log(log_ctx, AV_LOG_ERROR,
60
+                       "Input pad \"%s\" for the filter \"%s\" of type \"%s\" not connected to any source\n",
61
+                       filt->input_pads[j].name, filt->name, filt->filter->name);
62
+                return -1;
63
+            }
64
+        }
65
+
66
+        for (j = 0; j < filt->output_count; j++) {
67
+            if (!filt->outputs[j] || !filt->outputs[j]->dst) {
68
+                av_log(log_ctx, AV_LOG_ERROR,
69
+                       "Output pad \"%s\" for the filter \"%s\" of type \"%s\" not connected to any destination\n",
70
+                       filt->output_pads[j].name, filt->name, filt->filter->name);
71
+                return -1;
72
+            }
73
+        }
74
+    }
75
+
76
+    return 0;
77
+}
78
+
49 79
 AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, char *name)
50 80
 {
51 81
     int i;
... ...
@@ -45,6 +45,16 @@ AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, char *name);
45 45
 int avfilter_graph_add_filter(AVFilterGraph *graphctx, AVFilterContext *filter);
46 46
 
47 47
 /**
48
+ * Check for the validity of \p graph.
49
+ *
50
+ * A graph is considered valid if all its input and output pads are
51
+ * connected.
52
+ *
53
+ * @return 0 in case of success, a negative value otherwise
54
+ */
55
+int avfilter_graph_check_validity(AVFilterGraph *graphctx, AVClass *log_ctx);
56
+
57
+/**
48 58
  * Configure the formats of all the links in the graph.
49 59
  */
50 60
 int avfilter_graph_config_formats(AVFilterGraph *graphctx);