Unlike avfilter_graph_parse(), it returns unlinked inputs and outputs to the caller, which allows parsing of graphs where inputs/outputs are not known in advance.
Showing the changes to libavfilter/avfiltergraph.h (1 of 2 files). Show all
Unified · Split
| @@ -91,11 +91,11 @@ void avfilter_graph_free(AVFilterGraph **graph); · 90 unmodified lines | |||
| 91 | /** | 91 | /** |
| 92 | * A linked-list of the inputs/outputs of the filter chain. | 92 | * A linked-list of the inputs/outputs of the filter chain. |
| 93 | * | 93 | * |
| 94 | * This is mainly useful for avfilter_graph_parse(), since this | 94 | * This is mainly useful for avfilter_graph_parse() / avfilter_graph_parse2(), |
| 95 | * function may accept a description of a graph with not connected | 95 | * where it is used to communicate open (unlinked) inputs and outputs from and |
| 96 | * input/output pads. This struct specifies, per each not connected | 96 | * to the caller. |
| 97 | * pad contained in the graph, the filter context and the pad index | 97 | * This struct specifies, per each not connected pad contained in the graph, the |
| 98 | * required for establishing a link. | 98 | * filter context and the pad index required for establishing a link. |
| 99 | */ | 99 | */ |
| 100 | typedef struct AVFilterInOut { | 100 | typedef struct AVFilterInOut { |
| 101 | /** unique name for this input/output in the list */ | 101 | /** unique name for this input/output in the list */ |
| @@ -124,4 +124,38 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 22 unmodified lines | |||
| 124 | AVFilterInOut *inputs, AVFilterInOut *outputs, | 124 | AVFilterInOut *inputs, AVFilterInOut *outputs, |
| 125 | void *log_ctx); | 125 | void *log_ctx); |
| 126 | 126 | ||
| 127 | /** | ||
| 128 | * Add a graph described by a string to a graph. | ||
| 129 | * | ||
| 130 | * @param[in] graph the filter graph where to link the parsed graph context | ||
| 131 | * @param[in] filters string to be parsed | ||
| 132 | * @param[out] inputs a linked list of all free (unlinked) inputs of the | ||
| 133 | * parsed graph will be returned here. It is to be freed | ||
| 134 | * by the caller using avfilter_inout_free(). | ||
| 135 | * @param[out] outputs a linked list of all free (unlinked) outputs of the | ||
| 136 | * parsed graph will be returned here. It is to be freed by the | ||
| 137 | * caller using avfilter_inout_free(). | ||
| 138 | * @return zero on success, a negative AVERROR code on error | ||
| 139 | * | ||
| 140 | * @note the difference between avfilter_graph_parse2() and | ||
| 141 | * avfilter_graph_parse() is that in avfilter_graph_parse(), the caller provides | ||
| 142 | * the lists of inputs and outputs, which therefore must be known before calling | ||
| 143 | * the function. On the other hand, avfilter_graph_parse2() \em returns the | ||
| 144 | * inputs and outputs that are left unlinked after parsing the graph and the | ||
| 145 | * caller then deals with them. Another difference is that in | ||
| 146 | * avfilter_graph_parse(), the inputs parameter describes inputs of the | ||
| 147 | * <em>already existing</em> part of the graph; i.e. from the point of view of | ||
| 148 | * the newly created part, they are outputs. Similarly the outputs parameter | ||
| 149 | * describes outputs of the already existing filters, which are provided as | ||
| 150 | * inputs to the parsed filters. | ||
| 151 | * avfilter_graph_parse2() takes the opposite approach -- it makes no reference | ||
| 152 | * whatsoever to already existing parts of the graph and the inputs parameter | ||
| 153 | * will on return contain inputs of the newly parsed part of the graph. | ||
| 154 | * Analogously the outputs parameter will contain outputs of the newly created | ||
| 155 | * filters. | ||
| 156 | */ | ||
| 157 | int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, | ||
| 158 | AVFilterInOut **inputs, | ||
| 159 | AVFilterInOut **outputs); | ||
| 160 | |||
| 127 | #endif /* AVFILTER_AVFILTERGRAPH_H */ | 161 | #endif /* AVFILTER_AVFILTERGRAPH_H */ |