summaryrefslogtreecommitdiff
path: root/libavfilter/avfilter.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefano.sabatini-lala@poste.it>2011-06-02 17:45:33 +0200
committerStefano Sabatini <stefano.sabatini-lala@poste.it>2011-06-03 00:41:32 +0200
commite977ca2645cc6b23589ddf97ab08861064ba8792 (patch)
tree6e78c502176ac72bf4649d2bbc894d3963486365 /libavfilter/avfilter.c
parentb932eb1be62b47b29969667f14a207e425e79a55 (diff)
lavfi: add avfilter_link_free() function
Allow to free the buffers cached in each AVFilterLink pool. Fix leak.
Diffstat (limited to 'libavfilter/avfilter.c')
-rw-r--r--libavfilter/avfilter.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index b7ad6f0503..037d5864ae 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -165,6 +165,31 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
return 0;
}
+void avfilter_link_free(AVFilterLink **link)
+{
+ if (!*link)
+ return;
+
+ if ((*link)->pool) {
+ int i;
+ for (i = 0; i < POOL_SIZE; i++) {
+ if ((*link)->pool->pic[i]) {
+ AVFilterBufferRef *picref = (*link)->pool->pic[i];
+ /* free buffer: picrefs stored in the pool are not
+ * supposed to contain a free callback */
+ av_freep(&picref->buf->data[0]);
+ av_freep(&picref->buf);
+
+ av_freep(&picref->audio);
+ av_freep(&picref->video);
+ av_freep(&picref);
+ }
+ }
+ av_freep(&(*link)->pool);
+ }
+ av_freep(link);
+}
+
int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt,
unsigned filt_srcpad_idx, unsigned filt_dstpad_idx)
{
@@ -683,7 +708,7 @@ void avfilter_free(AVFilterContext *filter)
avfilter_formats_unref(&link->in_formats);
avfilter_formats_unref(&link->out_formats);
}
- av_freep(&link);
+ avfilter_link_free(&link);
}
for (i = 0; i < filter->output_count; i++) {
if ((link = filter->outputs[i])) {
@@ -692,7 +717,7 @@ void avfilter_free(AVFilterContext *filter)
avfilter_formats_unref(&link->in_formats);
avfilter_formats_unref(&link->out_formats);
}
- av_freep(&link);
+ avfilter_link_free(&link);
}
av_freep(&filter->name);