aboutsummaryrefslogtreecommitdiffstats
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
parentb932eb1be62b47b29969667f14a207e425e79a55 (diff)
downloadffmpeg-e977ca2645cc6b23589ddf97ab08861064ba8792.tar.gz
lavfi: add avfilter_link_free() function
Allow to free the buffers cached in each AVFilterLink pool. Fix leak.
-rw-r--r--doc/APIchanges3
-rw-r--r--libavfilter/avfilter.c29
-rw-r--r--libavfilter/avfilter.h7
3 files changed, 36 insertions, 3 deletions
diff --git a/doc/APIchanges b/doc/APIchanges
index f88b7af7c1..937846ec62 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2011-04-18
API changes, most recent first:
+2011-06-03 - xxxxxx - lavfi 2.12.0 - avfilter_link_free()
+ Add avfilter_link_free() function.
+
2011-05-28 - xxxxxx - lavu 51.3.0 - pixdesc.h
Add av_get_pix_fmt_name() in libavutil/pixdesc.h, and deprecate
avcodec_get_pix_fmt_name() in libavcodec/avcodec.h in its favor.
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);
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 602b2437d9..e8e2a8b9d1 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -26,7 +26,7 @@
#include "libavutil/samplefmt.h"
#define LIBAVFILTER_VERSION_MAJOR 2
-#define LIBAVFILTER_VERSION_MINOR 11
+#define LIBAVFILTER_VERSION_MINOR 12
#define LIBAVFILTER_VERSION_MICRO 0
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
@@ -636,6 +636,11 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad,
AVFilterContext *dst, unsigned dstpad);
/**
+ * Free the link in *link, and set its pointer to NULL.
+ */
+void avfilter_link_free(AVFilterLink **link);
+
+/**
* Negotiate the media format, dimensions, etc of all inputs to a filter.
*
* @param filter the filter to negotiate the properties for its inputs