This is required for letting applications to create and destroy
AVFilterInOut structs in a convenient way.
Signed-off-by: Anton Khirnov <anton@khirnov.net>
| ... | ... |
@@ -592,8 +592,8 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost) |
| 592 | 592 |
ost->graph->scale_sws_opts = av_strdup(args); |
| 593 | 593 |
|
| 594 | 594 |
if (ost->avfilter) {
|
| 595 |
- AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut)); |
|
| 596 |
- AVFilterInOut *inputs = av_malloc(sizeof(AVFilterInOut)); |
|
| 595 |
+ AVFilterInOut *outputs = avfilter_inout_alloc(); |
|
| 596 |
+ AVFilterInOut *inputs = avfilter_inout_alloc(); |
|
| 597 | 597 |
|
| 598 | 598 |
outputs->name = av_strdup("in");
|
| 599 | 599 |
outputs->filter_ctx = last_filter; |
| ... | ... |
@@ -1716,8 +1716,8 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c |
| 1716 | 1716 |
return ret; |
| 1717 | 1717 |
|
| 1718 | 1718 |
if (vfilters) {
|
| 1719 |
- AVFilterInOut *outputs = av_malloc(sizeof(AVFilterInOut)); |
|
| 1720 |
- AVFilterInOut *inputs = av_malloc(sizeof(AVFilterInOut)); |
|
| 1719 |
+ AVFilterInOut *outputs = avfilter_inout_alloc(); |
|
| 1720 |
+ AVFilterInOut *inputs = avfilter_inout_alloc(); |
|
| 1721 | 1721 |
|
| 1722 | 1722 |
outputs->name = av_strdup("in");
|
| 1723 | 1723 |
outputs->filter_ctx = filt_src; |
| ... | ... |
@@ -12,6 +12,10 @@ libavutil: 2011-04-18 |
| 12 | 12 |
|
| 13 | 13 |
API changes, most recent first: |
| 14 | 14 |
|
| 15 |
+2012-xx-xx - xxxxxxx - lavfi 2.16.0 - avfiltergraph.h |
|
| 16 |
+ Add avfilter_graph_parse2(), avfilter_inout_alloc() and |
|
| 17 |
+ avfilter_inout_free() functions. |
|
| 18 |
+ |
|
| 15 | 19 |
2012-xx-xx - xxxxxxx - lavu 51.27.0 - samplefmt.h |
| 16 | 20 |
Add av_get_packed_sample_fmt() and av_get_planar_sample_fmt() |
| 17 | 21 |
|
| ... | ... |
@@ -112,6 +112,19 @@ typedef struct AVFilterInOut {
|
| 112 | 112 |
} AVFilterInOut; |
| 113 | 113 |
|
| 114 | 114 |
/** |
| 115 |
+ * Allocate a single AVFilterInOut entry. |
|
| 116 |
+ * Must be freed with avfilter_inout_free(). |
|
| 117 |
+ * @return allocated AVFilterInOut on success, NULL on failure. |
|
| 118 |
+ */ |
|
| 119 |
+AVFilterInOut *avfilter_inout_alloc(void); |
|
| 120 |
+ |
|
| 121 |
+/** |
|
| 122 |
+ * Free the supplied list of AVFilterInOut and set *inout to NULL. |
|
| 123 |
+ * If *inout is NULL, do nothing. |
|
| 124 |
+ */ |
|
| 125 |
+void avfilter_inout_free(AVFilterInOut **inout); |
|
| 126 |
+ |
|
| 127 |
+/** |
|
| 115 | 128 |
* Add a graph described by a string to a graph. |
| 116 | 129 |
* |
| 117 | 130 |
* @param graph the filter graph where to link the parsed graph context |
| ... | ... |
@@ -170,13 +170,18 @@ static int parse_filter(AVFilterContext **filt_ctx, const char **buf, AVFilterGr |
| 170 | 170 |
return ret; |
| 171 | 171 |
} |
| 172 | 172 |
|
| 173 |
-static void free_inout(AVFilterInOut *head) |
|
| 173 |
+AVFilterInOut *avfilter_inout_alloc(void) |
|
| 174 | 174 |
{
|
| 175 |
- while (head) {
|
|
| 176 |
- AVFilterInOut *next = head->next; |
|
| 177 |
- av_free(head->name); |
|
| 178 |
- av_free(head); |
|
| 179 |
- head = next; |
|
| 175 |
+ return av_mallocz(sizeof(AVFilterInOut)); |
|
| 176 |
+} |
|
| 177 |
+ |
|
| 178 |
+void avfilter_inout_free(AVFilterInOut **inout) |
|
| 179 |
+{
|
|
| 180 |
+ while (*inout) {
|
|
| 181 |
+ AVFilterInOut *next = (*inout)->next; |
|
| 182 |
+ av_freep(&(*inout)->name); |
|
| 183 |
+ av_freep(inout); |
|
| 184 |
+ *inout = next; |
|
| 180 | 185 |
} |
| 181 | 186 |
} |
| 182 | 187 |
|
| ... | ... |
@@ -431,9 +436,9 @@ int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, |
| 431 | 431 |
for (; graph->filter_count > 0; graph->filter_count--) |
| 432 | 432 |
avfilter_free(graph->filters[graph->filter_count - 1]); |
| 433 | 433 |
av_freep(&graph->filters); |
| 434 |
- free_inout(open_inputs); |
|
| 435 |
- free_inout(open_outputs); |
|
| 436 |
- free_inout(curr_inputs); |
|
| 434 |
+ avfilter_inout_free(&open_inputs); |
|
| 435 |
+ avfilter_inout_free(&open_outputs); |
|
| 436 |
+ avfilter_inout_free(&curr_inputs); |
|
| 437 | 437 |
|
| 438 | 438 |
*inputs = NULL; |
| 439 | 439 |
*outputs = NULL; |
| ... | ... |
@@ -467,7 +472,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, |
| 467 | 467 |
continue; |
| 468 | 468 |
ret = avfilter_link(match->filter_ctx, match->pad_idx, |
| 469 | 469 |
cur->filter_ctx, cur->pad_idx); |
| 470 |
- free_inout(match); |
|
| 470 |
+ avfilter_inout_free(&match); |
|
| 471 | 471 |
if (ret < 0) |
| 472 | 472 |
goto fail; |
| 473 | 473 |
} |
| ... | ... |
@@ -487,7 +492,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, |
| 487 | 487 |
continue; |
| 488 | 488 |
ret = avfilter_link(cur->filter_ctx, cur->pad_idx, |
| 489 | 489 |
match->filter_ctx, match->pad_idx); |
| 490 |
- free_inout(match); |
|
| 490 |
+ avfilter_inout_free(&match); |
|
| 491 | 491 |
if (ret < 0) |
| 492 | 492 |
goto fail; |
| 493 | 493 |
} |
| ... | ... |
@@ -498,9 +503,9 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, |
| 498 | 498 |
avfilter_free(graph->filters[graph->filter_count - 1]); |
| 499 | 499 |
av_freep(&graph->filters); |
| 500 | 500 |
} |
| 501 |
- free_inout(inputs); |
|
| 502 |
- free_inout(outputs); |
|
| 503 |
- free_inout(open_inputs); |
|
| 504 |
- free_inout(open_outputs); |
|
| 501 |
+ avfilter_inout_free(&inputs); |
|
| 502 |
+ avfilter_inout_free(&outputs); |
|
| 503 |
+ avfilter_inout_free(&open_inputs); |
|
| 504 |
+ avfilter_inout_free(&open_outputs); |
|
| 505 | 505 |
return ret; |
| 506 | 506 |
} |
| ... | ... |
@@ -29,7 +29,7 @@ |
| 29 | 29 |
#include "libavutil/avutil.h" |
| 30 | 30 |
|
| 31 | 31 |
#define LIBAVFILTER_VERSION_MAJOR 2 |
| 32 |
-#define LIBAVFILTER_VERSION_MINOR 15 |
|
| 32 |
+#define LIBAVFILTER_VERSION_MINOR 16 |
|
| 33 | 33 |
#define LIBAVFILTER_VERSION_MICRO 0 |
| 34 | 34 |
|
| 35 | 35 |
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |