MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / avfilter_link

Function avfilter_link

libavfilter/avfilter.c:149–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149int avfilter_link(AVFilterContext *src, unsigned srcpad,
150 AVFilterContext *dst, unsigned dstpad)
151{
152 FilterLinkInternal *li;
153 AVFilterLink *link;
154
155 av_assert0(src->graph);
156 av_assert0(dst->graph);
157 av_assert0(src->graph == dst->graph);
158
159 if (src->nb_outputs <= srcpad || dst->nb_inputs <= dstpad ||
160 src->outputs[srcpad] || dst->inputs[dstpad])
161 return AVERROR(EINVAL);
162
163 if (!(fffilterctx(src)->state_flags & AV_CLASS_STATE_INITIALIZED) ||
164 !(fffilterctx(dst)->state_flags & AV_CLASS_STATE_INITIALIZED)) {
165 av_log(src, AV_LOG_ERROR, "Filters must be initialized before linking.\n");
166 return AVERROR(EINVAL);
167 }
168
169 if (src->output_pads[srcpad].type != dst->input_pads[dstpad].type) {
170 av_log(src, AV_LOG_ERROR,
171 "Media type mismatch between the '%s' filter output pad %d (%s) and the '%s' filter input pad %d (%s)\n",
172 src->name, srcpad, (char *)av_x_if_null(av_get_media_type_string(src->output_pads[srcpad].type), "?"),
173 dst->name, dstpad, (char *)av_x_if_null(av_get_media_type_string(dst-> input_pads[dstpad].type), "?"));
174 return AVERROR(EINVAL);
175 }
176
177 li = av_mallocz(sizeof(*li));
178 if (!li)
179 return AVERROR(ENOMEM);
180 link = &li->l.pub;
181
182 src->outputs[srcpad] = dst->inputs[dstpad] = link;
183
184 link->src = src;
185 link->dst = dst;
186 link->srcpad = &src->output_pads[srcpad];
187 link->dstpad = &dst->input_pads[dstpad];
188 link->type = src->output_pads[srcpad].type;
189 li->l.graph = src->graph;
190 av_assert0(AV_PIX_FMT_NONE == -1 && AV_SAMPLE_FMT_NONE == -1);
191 link->format = -1;
192 link->colorspace = AVCOL_SPC_UNSPECIFIED;
193 ff_framequeue_init(&li->fifo, &fffiltergraph(src->graph)->frame_queues);
194
195 return 0;
196}
197
198static void link_free(AVFilterLink **link)
199{

Callers 15

lavfi_read_headerFunction · 0.85
create_sinkFunction · 0.85
insert_trimFunction · 0.85
insert_filterFunction · 0.85
configure_filtergraphFunction · 0.85
avfilter_graph_parseFunction · 0.85
link_inputsFunction · 0.85
link_outputsFunction · 0.85

Calls 7

fffilterctxFunction · 0.85
av_logFunction · 0.85
av_x_if_nullFunction · 0.85
av_get_media_type_stringFunction · 0.85
ff_framequeue_initFunction · 0.85
fffiltergraphFunction · 0.85
av_malloczFunction · 0.50

Tested by

no test coverage detected