This is required for letting applications to create and destroy AVFilterInOut structs in a convenient way.
Unified · Split
| @@ -592,8 +592,8 @@ static int configure_video_filters(InputStream *ist, OutputStream *ost) · 591 unmodified lines | ||
| 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 · 1715 unmodified lines | ||
| 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 · 11 unmodified lines | ||
| 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 | |
| @@ -111,6 +111,19 @@ typedef struct AVFilterInOut { · 110 unmodified lines | ||
| 111 | 111 | struct AVFilterInOut *next; |
| 112 | 112 | } AVFilterInOut; |
| 113 | 113 | |
| 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 | + | |
| 114 | 127 | /** |
| 115 | 128 | * Add a graph described by a string to a graph. |
| 116 | 129 | * |
| @@ -170,13 +170,18 @@ static int parse_filter(AVFilterContext **filt_ctx, const char **buf, AVFilterGr · 169 unmodified lines | ||
| 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, · 248 unmodified lines | ||
| 431 | 436 | for (; graph->filter_count > 0; graph->filter_count--) |
| 432 | 437 | avfilter_free(graph->filters[graph->filter_count - 1]); |
| 433 | 438 | av_freep(&graph->filters); |
| 434 | − free_inout(open_inputs); | |
| 435 | − free_inout(open_outputs); | |
| 436 | − free_inout(curr_inputs); | |
| 439 | + avfilter_inout_free(&open_inputs); | |
| 440 | + avfilter_inout_free(&open_outputs); | |
| 441 | + avfilter_inout_free(&curr_inputs); | |
| 437 | 442 | |
| 438 | 443 | *inputs = NULL; |
| 439 | 444 | *outputs = NULL; |
| @@ -467,7 +472,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 27 unmodified lines | ||
| 467 | 472 | continue; |
| 468 | 473 | ret = avfilter_link(match->filter_ctx, match->pad_idx, |
| 469 | 474 | cur->filter_ctx, cur->pad_idx); |
| 470 | − free_inout(match); | |
| 475 | + avfilter_inout_free(&match); | |
| 471 | 476 | if (ret < 0) |
| 472 | 477 | goto fail; |
| 473 | 478 | } |
| @@ -487,7 +492,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 13 unmodified lines | ||
| 487 | 492 | continue; |
| 488 | 493 | ret = avfilter_link(cur->filter_ctx, cur->pad_idx, |
| 489 | 494 | match->filter_ctx, match->pad_idx); |
| 490 | − free_inout(match); | |
| 495 | + avfilter_inout_free(&match); | |
| 491 | 496 | if (ret < 0) |
| 492 | 497 | goto fail; |
| 493 | 498 | } |
| @@ -498,9 +503,9 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 4 unmodified lines | ||
| 498 | 503 | avfilter_free(graph->filters[graph->filter_count - 1]); |
| 499 | 504 | av_freep(&graph->filters); |
| 500 | 505 | } |
| 501 | − free_inout(inputs); | |
| 502 | − free_inout(outputs); | |
| 503 | − free_inout(open_inputs); | |
| 504 | − free_inout(open_outputs); | |
| 506 | + avfilter_inout_free(&inputs); | |
| 507 | + avfilter_inout_free(&outputs); | |
| 508 | + avfilter_inout_free(&open_inputs); | |
| 509 | + avfilter_inout_free(&open_outputs); | |
| 505 | 510 | return ret; |
| 506 | 511 | } |
| @@ -29,7 +29,7 @@ · 28 unmodified lines | ||
| 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, \ |