History

avfiltergraph: make the AVFilterInOut alloc/free API public

This is required for letting applications to create and destroy AVFilterInOut structs in a convenient way.

Stefano Sabatini committed 15 years ago

Commit 91d3cbe1 parent 12e7e1d6 files · +42 −20Browse files

Showing the changes to libavfilter/graphparser.c (1 of 6 files). Show all

Unified · Split

libavfilter/graphparser.c+20−15
@@ -170,13 +170,18 @@ static int parse_filter(AVFilterContext **filt_ctx, const char **buf, AVFilterGr · 169 unmodified lines
170170 return ret;
171171 }
172172
173−static void free_inout(AVFilterInOut *head)
173+AVFilterInOut *avfilter_inout_alloc(void)
174174 {
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;
180185 }
181186 }
182187
@@ -431,9 +436,9 @@ int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, · 248 unmodified lines
431436 for (; graph->filter_count > 0; graph->filter_count--)
432437 avfilter_free(graph->filters[graph->filter_count - 1]);
433438 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);
437442
438443 *inputs = NULL;
439444 *outputs = NULL;
@@ -467,7 +472,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 27 unmodified lines
467472 continue;
468473 ret = avfilter_link(match->filter_ctx, match->pad_idx,
469474 cur->filter_ctx, cur->pad_idx);
470− free_inout(match);
475+ avfilter_inout_free(&match);
471476 if (ret < 0)
472477 goto fail;
473478 }
@@ -487,7 +492,7 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 13 unmodified lines
487492 continue;
488493 ret = avfilter_link(cur->filter_ctx, cur->pad_idx,
489494 match->filter_ctx, match->pad_idx);
490− free_inout(match);
495+ avfilter_inout_free(&match);
491496 if (ret < 0)
492497 goto fail;
493498 }
@@ -498,9 +503,9 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 4 unmodified lines
498503 avfilter_free(graph->filters[graph->filter_count - 1]);
499504 av_freep(&graph->filters);
500505 }
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);
505510 return ret;
506511 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t