summaryrefslogtreecommitdiff
path: root/libavfilter/avfilter.c
diff options
context:
space:
mode:
authorVitor Sessak <vitor1001@gmail.com>2008-02-15 21:35:45 +0000
committerVitor Sessak <vitor1001@gmail.com>2008-02-15 21:35:45 +0000
commite0752603a1e22923e6a5d1f004f2390e6f02168c (patch)
tree88e3f5be64356c1faf7de62b47a37f08ed9435b0 /libavfilter/avfilter.c
parent89e64908a3e2e7f9b225487008e2bd090f0ee477 (diff)
Rework filter initialization sequence. Now supports passing user parameters,
querying supported colorspaces, etc. Commited in SoC by Bobby Bingham on 2007-07-05 20:48:48 Originally committed as revision 11974 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavfilter/avfilter.c')
-rw-r--r--libavfilter/avfilter.c44
1 files changed, 40 insertions, 4 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index ea8df43a98..cb6be057cf 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -19,6 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@@ -91,6 +92,7 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
AVFilterContext *dst, unsigned dstpad)
{
AVFilterLink *link;
+ int *fmts[2], i, j;
if(src->outputs[srcpad] || dst->inputs[dstpad])
return -1;
@@ -104,7 +106,29 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
link->dstpad = dstpad;
link->cur_pic = NULL;
- src->filter->outputs[dstpad].set_video_props(link);
+ /* find a format both filters support - TODO: auto-insert conversion filter */
+ fmts[0] = src->filter->outputs[srcpad].query_formats(link);
+ fmts[1] = dst->filter->inputs[dstpad].query_formats(link);
+ for(i = 0; fmts[0][i] != -1; i ++)
+ for(j = 0; fmts[1][j] != -1; j ++)
+ if(fmts[0][i] == fmts[1][j]) {
+ link->format = fmts[0][i];
+ goto format_done;
+ }
+
+format_done:
+ av_free(fmts[0]);
+ av_free(fmts[1]);
+ if(link->format == -1) {
+ /* failed to find a format. fail at creating the link */
+ av_free(link);
+ src->outputs[srcpad] = NULL;
+ dst->inputs[dstpad] = NULL;
+ return -1;
+ }
+
+ src->filter->outputs[srcpad].config_props(link);
+ dst->filter->inputs[dstpad].config_props(link);
return 0;
}
@@ -263,9 +287,21 @@ int avfilter_init_filter(AVFilterContext *filter, const char *args)
if(filter->filter->init)
if((ret = filter->filter->init(filter, args))) return ret;
- for(i = 0; i < pad_count(filter->filter->outputs); i ++)
- if(filter->outputs[i])
- filter->filter->outputs[i].set_video_props(filter->outputs[i]);
return 0;
}
+int *avfilter_make_format_list(int len, ...)
+{
+ int *ret, i;
+ va_list vl;
+
+ ret = av_malloc(sizeof(int) * (len + 1));
+ va_start(vl, len);
+ for(i = 0; i < len; i ++)
+ ret[i] = va_arg(vl, int);
+ va_end(vl);
+ ret[len] = -1;
+
+ return ret;
+}
+