History

Merge commit '1565cbc65cbb9f95c11367314a080068895e0cf0'

* commit '1565cbc65cbb9f95c11367314a080068895e0cf0': lavfi: make avfilter_free() remove the filter from its graph. Conflicts: libavfilter/avfilter.c libavfilter/avfiltergraph.c libavfilter/graphparser.c

Michael Niedermayer committed 13 years ago

Commit eb0f7742 parents 4fde705 1565cbc5 files · +32 −10Browse files

Unified · Split

5 files
  1. libavfilter/avfilter.c +3 −0
  2. libavfilter/avfilter.h +2 −1
  3. libavfilter/avfiltergraph.c +18 −5
  4. libavfilter/graphparser.c +4 −4
  5. libavfilter/internal.h +5 −0
libavfilter/avfilter.c+3−0
@@ -571,6 +571,9 @@ void avfilter_free(AVFilterContext *filter) · 570 unmodified lines
571571 if (!filter)
572572 return;
573573
574+ if (filter->graph)
575+ ff_filter_graph_remove_filter(filter->graph, filter);
576+
574577 if (filter->filter->uninit)
575578 filter->filter->uninit(filter);
576579
libavfilter/avfilter.h+2−1
@@ -873,7 +873,8 @@ int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *in · 872 unmodified lines
873873 int avfilter_init_filter(AVFilterContext *filter, const char *args, void *opaque);
874874
875875 /**
876− * Free a filter context.
876+ * Free a filter context. This will also remove the filter from its
877+ * filtergraph's list of filters.
877878 *
878879 * @param filter the filter to free
879880 */
libavfilter/avfiltergraph.c+18−5
@@ -59,12 +59,27 @@ AVFilterGraph *avfilter_graph_alloc(void) · 58 unmodified lines
5959 return ret;
6060 }
6161
62+void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter)
63+{
64+ int i;
65+ for (i = 0; i < graph->nb_filters; i++) {
66+ if (graph->filters[i] == filter) {
67+ FFSWAP(AVFilterContext*, graph->filters[i],
68+ graph->filters[graph->nb_filters - 1]);
69+ graph->nb_filters--;
70+ return;
71+ }
72+ }
73+}
74+
6275 void avfilter_graph_free(AVFilterGraph **graph)
6376 {
6477 if (!*graph)
6578 return;
66− for (; (*graph)->nb_filters > 0; (*graph)->nb_filters--)
67− avfilter_free((*graph)->filters[(*graph)->nb_filters - 1]);
79+
80+ while ((*graph)->nb_filters)
81+ avfilter_free((*graph)->filters[0]);
82+
6883 av_freep(&(*graph)->sink_links);
6984 av_freep(&(*graph)->scale_sws_opts);
7085 av_freep(&(*graph)->aresample_swr_opts);
@@ -103,10 +118,8 @@ int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt, · 32 unmodified lines
103118 *filt_ctx = avfilter_graph_alloc_filter(graph_ctx, filt, name);
104119 if (!*filt_ctx)
105120 return AVERROR(ENOMEM);
106− if ((ret = avfilter_init_filter(*filt_ctx, args, opaque)) < 0) {
107− graph_ctx->filters[graph_ctx->nb_filters-1] = NULL;
121+ if ((ret = avfilter_init_filter(*filt_ctx, args, opaque)) < 0)
108122 goto fail;
109− }
110123
111124 return 0;
112125
libavfilter/graphparser.c+4−4
@@ -430,8 +430,8 @@ int avfilter_graph_parse2(AVFilterGraph *graph, const char *filters, · 429 unmodified lines
430430 return 0;
431431
432432 fail:end:
433− for (; graph->nb_filters > 0; graph->nb_filters--)
434− avfilter_free(graph->filters[graph->nb_filters - 1]);
433+ while (graph->nb_filters)
434+ avfilter_free(graph->filters[0]);
435435 av_freep(&graph->filters);
436436 avfilter_inout_free(&open_inputs);
437437 avfilter_inout_free(&open_outputs);
@@ -498,8 +498,8 @@ int avfilter_graph_parse(AVFilterGraph *graph, const char *filters, · 60 unmodified lines
498498
499499 fail:
500500 if (ret < 0) {
501− for (; graph->nb_filters > 0; graph->nb_filters--)
502− avfilter_free(graph->filters[graph->nb_filters - 1]);
501+ while (graph->nb_filters)
502+ avfilter_free(graph->filters[0]);
503503 av_freep(&graph->filters);
504504 }
505505 avfilter_inout_free(&inputs);
libavfilter/internal.h+5−0
@@ -349,4 +349,9 @@ enum { · 348 unmodified lines
349349 */
350350 AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name);
351351
352+/**
353+ * Remove a filter from a graph;
354+ */
355+void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter);
356+
352357 #endif /* AVFILTER_INTERNAL_H */

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