mirror of https://git.ffmpeg.org/ffmpeg.git
avfilter: dont use AVFilterLink as priv for pictures as its freed too early.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
21d84246d5
commit
c34cb130b6
|
@ -73,15 +73,10 @@ AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
|
||||||
static void store_in_pool(AVFilterBufferRef *ref)
|
static void store_in_pool(AVFilterBufferRef *ref)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
AVFilterLink *link= ref->buf->priv;
|
AVFilterPool *pool= ref->buf->priv;
|
||||||
AVFilterPool *pool;
|
|
||||||
|
|
||||||
av_assert0(ref->buf->data[0]);
|
av_assert0(ref->buf->data[0]);
|
||||||
|
|
||||||
if(!link->pool)
|
|
||||||
link->pool = av_mallocz(sizeof(AVFilterPool));
|
|
||||||
pool= link->pool;
|
|
||||||
|
|
||||||
if(pool->count == POOL_SIZE){
|
if(pool->count == POOL_SIZE){
|
||||||
AVFilterBufferRef *ref1= pool->pic[0];
|
AVFilterBufferRef *ref1= pool->pic[0];
|
||||||
av_freep(&ref1->video);
|
av_freep(&ref1->video);
|
||||||
|
@ -685,7 +680,6 @@ void avfilter_free(AVFilterContext *filter)
|
||||||
if ((link = filter->inputs[i])) {
|
if ((link = filter->inputs[i])) {
|
||||||
if (link->src)
|
if (link->src)
|
||||||
link->src->outputs[link->srcpad - link->src->output_pads] = NULL;
|
link->src->outputs[link->srcpad - link->src->output_pads] = NULL;
|
||||||
av_freep(&link->pool);
|
|
||||||
avfilter_formats_unref(&link->in_formats);
|
avfilter_formats_unref(&link->in_formats);
|
||||||
avfilter_formats_unref(&link->out_formats);
|
avfilter_formats_unref(&link->out_formats);
|
||||||
}
|
}
|
||||||
|
@ -695,7 +689,6 @@ void avfilter_free(AVFilterContext *filter)
|
||||||
if ((link = filter->outputs[i])) {
|
if ((link = filter->outputs[i])) {
|
||||||
if (link->dst)
|
if (link->dst)
|
||||||
link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL;
|
link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL;
|
||||||
av_freep(&link->pool);
|
|
||||||
avfilter_formats_unref(&link->in_formats);
|
avfilter_formats_unref(&link->in_formats);
|
||||||
avfilter_formats_unref(&link->out_formats);
|
avfilter_formats_unref(&link->out_formats);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,8 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per
|
||||||
memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize));
|
memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize));
|
||||||
return picref;
|
return picref;
|
||||||
}
|
}
|
||||||
}
|
}else
|
||||||
|
pool = link->pool = av_mallocz(sizeof(AVFilterPool));
|
||||||
|
|
||||||
// +2 is needed for swscaler, +16 to be SIMD-friendly
|
// +2 is needed for swscaler, +16 to be SIMD-friendly
|
||||||
if ((i=av_image_alloc(data, linesize, w, h, link->format, 16)) < 0)
|
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);
|
memset(data[0], 128, i);
|
||||||
|
|
||||||
picref->buf->priv= link;
|
picref->buf->priv= pool;
|
||||||
picref->buf->free= NULL;
|
picref->buf->free= NULL;
|
||||||
|
|
||||||
return picref;
|
return picref;
|
||||||
|
|
Loading…
Reference in New Issue