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

Function link_outputs

libavfilter/graphparser.c:747–812  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

745}
746
747static int link_outputs(AVFilterGraphSegment *seg, size_t idx_chain,
748 size_t idx_filter, AVFilterInOut **outputs)
749{
750 AVFilterChain *ch = seg->chains[idx_chain];
751 AVFilterParams *p = ch->filters[idx_filter];
752 AVFilterContext *f = p->filter;
753
754 int ret;
755
756 if (f->nb_outputs < p->nb_outputs) {
757 av_log(seg->graph, AV_LOG_ERROR,
758 "More output link labels specified for filter '%s' than "
759 "it has outputs: %u > %d\n", f->filter->name,
760 p->nb_outputs, f->nb_outputs);
761 return AVERROR(EINVAL);
762 }
763 for (unsigned out = 0; out < f->nb_outputs; out++) {
764 char *label = (out < p->nb_outputs) ? p->outputs[out]->label : NULL;
765
766 // skip already linked outputs
767 if (f->outputs[out])
768 continue;
769
770 if (label) {
771 AVFilterParams *po = NULL;
772 unsigned idx = find_linklabel(seg, label, 0, idx_chain, idx_filter, &po);
773
774 if (po) {
775 ret = avfilter_link(f, out, po->filter, idx);
776 if (ret < 0)
777 return ret;
778
779 continue;
780 }
781 }
782
783 // if this output is unlabeled, try linking it to an unlabeled
784 // input in the next non-disabled filter in the chain
785 for (size_t i = idx_filter + 1; i < ch->nb_filters && !label; i++) {
786 AVFilterParams *p_next = ch->filters[i];
787
788 if (!p_next->filter)
789 continue;
790
791 for (unsigned in = 0; in < p_next->filter->nb_inputs; in++) {
792 if (!p_next->filter->inputs[in] &&
793 (in >= p_next->nb_inputs || !p_next->inputs[in]->label)) {
794 ret = avfilter_link(f, out, p_next->filter, in);
795 if (ret < 0)
796 return ret;
797
798 goto cont;
799 }
800 }
801 break;
802 }
803
804 ret = inout_add(outputs, f, out, label);

Callers 1

Calls 4

av_logFunction · 0.85
find_linklabelFunction · 0.85
avfilter_linkFunction · 0.85
inout_addFunction · 0.85

Tested by

no test coverage detected