Revision e0752603

View differences:

libavfilter/avfilter.c
19 19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 20
 */
21 21

  
22
#include <stdarg.h>
22 23
#include <stdlib.h>
23 24
#include <string.h>
24 25
#include <stdio.h>
......
91 92
                  AVFilterContext *dst, unsigned dstpad)
92 93
{
93 94
    AVFilterLink *link;
95
    int *fmts[2], i, j;
94 96

  
95 97
    if(src->outputs[srcpad] || dst->inputs[dstpad])
96 98
        return -1;
......
104 106
    link->dstpad = dstpad;
105 107
    link->cur_pic = NULL;
106 108

  
107
    src->filter->outputs[dstpad].set_video_props(link);
109
    /* find a format both filters support - TODO: auto-insert conversion filter */
110
    fmts[0] = src->filter->outputs[srcpad].query_formats(link);
111
    fmts[1] = dst->filter->inputs[dstpad].query_formats(link);
112
    for(i = 0; fmts[0][i] != -1; i ++)
113
        for(j = 0; fmts[1][j] != -1; j ++)
114
            if(fmts[0][i] == fmts[1][j]) {
115
                link->format = fmts[0][i];
116
                goto format_done;
117
            }
118

  
119
format_done:
120
    av_free(fmts[0]);
121
    av_free(fmts[1]);
122
    if(link->format == -1) {
123
        /* failed to find a format.  fail at creating the link */
124
        av_free(link);
125
        src->outputs[srcpad] = NULL;
126
        dst->inputs[dstpad]  = NULL;
127
        return -1;
128
    }
129

  
130
    src->filter->outputs[srcpad].config_props(link);
131
    dst->filter->inputs[dstpad].config_props(link);
108 132
    return 0;
109 133
}
110 134

  
......
263 287

  
264 288
    if(filter->filter->init)
265 289
        if((ret = filter->filter->init(filter, args))) return ret;
266
    for(i = 0; i < pad_count(filter->filter->outputs); i ++)
267
        if(filter->outputs[i])
268
            filter->filter->outputs[i].set_video_props(filter->outputs[i]);
269 290
    return 0;
270 291
}
271 292

  
293
int *avfilter_make_format_list(int len, ...)
294
{
295
    int *ret, i;
296
    va_list vl;
297

  
298
    ret = av_malloc(sizeof(int) * (len + 1));
299
    va_start(vl, len);
300
    for(i = 0; i < len; i ++)
301
        ret[i] = va_arg(vl, int);
302
    va_end(vl);
303
    ret[len] = -1;
304

  
305
    return ret;
306
}
307

  

Also available in: Unified diff