[FFmpeg-cvslog] avfilter: dont use AVFilterLink as priv for pictures as its freed too early .

Michael Niedermayer git at videolan.org
Sat May 7 01:03:08 CEST 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat May  7 01:02:38 2011 +0200| [c34cb130b6bf3e957484fd236c1ba477720882c0] | committer: Michael Niedermayer

avfilter: dont use AVFilterLink as priv for pictures as its freed too early.
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c34cb130b6bf3e957484fd236c1ba477720882c0
---

 libavfilter/avfilter.c |    9 +--------
 libavfilter/defaults.c |    5 +++--
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 0518e6d..72e0a87 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -73,15 +73,10 @@ AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
 static void store_in_pool(AVFilterBufferRef *ref)
 {
     int i;
-    AVFilterLink *link= ref->buf->priv;
-    AVFilterPool *pool;
+    AVFilterPool *pool= ref->buf->priv;
 
     av_assert0(ref->buf->data[0]);
 
-    if(!link->pool)
-        link->pool = av_mallocz(sizeof(AVFilterPool));
-    pool= link->pool;
-
     if(pool->count == POOL_SIZE){
         AVFilterBufferRef *ref1= pool->pic[0];
         av_freep(&ref1->video);
@@ -685,7 +680,6 @@ void avfilter_free(AVFilterContext *filter)
         if ((link = filter->inputs[i])) {
             if (link->src)
                 link->src->outputs[link->srcpad - link->src->output_pads] = NULL;
-            av_freep(&link->pool);
             avfilter_formats_unref(&link->in_formats);
             avfilter_formats_unref(&link->out_formats);
         }
@@ -695,7 +689,6 @@ void avfilter_free(AVFilterContext *filter)
         if ((link = filter->outputs[i])) {
             if (link->dst)
                 link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL;
-            av_freep(&link->pool);
             avfilter_formats_unref(&link->in_formats);
             avfilter_formats_unref(&link->out_formats);
         }
diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c
index 63bca6b..9ee23e5 100644
--- a/libavfilter/defaults.c
+++ b/libavfilter/defaults.c
@@ -57,7 +57,8 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per
             memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize));
             return picref;
         }
-    }
+    }else
+        pool = link->pool = av_mallocz(sizeof(AVFilterPool));
 
     // +2 is needed for swscaler, +16 to be SIMD-friendly
     if ((i=av_image_alloc(data, linesize, w, h, link->format, 16)) < 0)
@@ -71,7 +72,7 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per
     }
     memset(data[0], 128, i);
 
-    picref->buf->priv= link;
+    picref->buf->priv= pool;
     picref->buf->free= NULL;
 
     return picref;



More information about the ffmpeg-cvslog mailing list