+ dst-> inputs[dstpad] = link = av_mallocz(sizeof(AVFilterLink));
+
+ link->src = src;
+ link->dst = dst;
+ link->srcpad = srcpad;
+ link->dstpad = dstpad;
+ link->format = -1;
+
+ return 0;
+}
+
+int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
+ unsigned in, unsigned out)
+{
+ av_log(link->dst, AV_LOG_INFO, "auto-inserting filter '%s'\n",
+ filt->filter->name);
+
+ link->dst->inputs[link->dstpad] = NULL;
+ if(avfilter_link(filt, out, link->dst, link->dstpad)) {
+ /* failed to link output filter to new filter */
+ link->dst->inputs[link->dstpad] = link;
+ return -1;
+ }
+
+ /* re-hookup the link to the new destination filter we inserted */
+ link->dst = filt;
+ link->dstpad = in;
+ filt->inputs[in] = link;
+
+ /* if any information on supported colorspaces already exists on the
+ * link, we need to preserve that */
+ if(link->out_formats)
+ avfilter_formats_changeref(&link->out_formats,
+ &filt->outputs[out]->out_formats);
+
+ return 0;
+}
+
+int avfilter_config_links(AVFilterContext *filter)
+{
+ int (*config_link)(AVFilterLink *);
+ unsigned i;
+
+ for(i = 0; i < filter->input_count; i ++) {
+ AVFilterLink *link = filter->inputs[i];