Commit 2d54bbb9 authored by Michael Niedermayer's avatar Michael Niedermayer

vsrc_buffer: Store allocated scale filter and free it later.

Fixes a memleak.
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent c5f9a66f
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
typedef struct { typedef struct {
AVFilterBufferRef *picref; AVFilterBufferRef *picref;
AVFilterContext *scale;
int h, w; int h, w;
enum PixelFormat pix_fmt; enum PixelFormat pix_fmt;
AVRational time_base; ///< time_base to set in the output link AVRational time_base; ///< time_base to set in the output link
...@@ -81,14 +82,14 @@ int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_filter, ...@@ -81,14 +82,14 @@ int av_vsrc_buffer_add_video_buffer_ref(AVFilterContext *buffer_filter,
if ((ret = avfilter_open(&scale, f, "Input equalizer")) < 0) if ((ret = avfilter_open(&scale, f, "Input equalizer")) < 0)
return ret; return ret;
c->scale = scale;
snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s", c->w, c->h, c->sws_param); snprintf(scale_param, sizeof(scale_param)-1, "%d:%d:%s", c->w, c->h, c->sws_param);
if ((ret = avfilter_init_filter(scale, scale_param, NULL)) < 0) { if ((ret = avfilter_init_filter(scale, scale_param, NULL)) < 0) {
avfilter_free(scale);
return ret; return ret;
} }
if ((ret = avfilter_insert_filter(buffer_filter->outputs[0], scale, 0, 0)) < 0) { if ((ret = avfilter_insert_filter(buffer_filter->outputs[0], scale, 0, 0)) < 0) {
avfilter_free(scale);
return ret; return ret;
} }
scale->outputs[0]->time_base = scale->inputs[0]->time_base; scale->outputs[0]->time_base = scale->inputs[0]->time_base;
...@@ -188,6 +189,8 @@ static av_cold void uninit(AVFilterContext *ctx) ...@@ -188,6 +189,8 @@ static av_cold void uninit(AVFilterContext *ctx)
if (s->picref) if (s->picref)
avfilter_unref_buffer(s->picref); avfilter_unref_buffer(s->picref);
s->picref = NULL; s->picref = NULL;
avfilter_free(s->scale);
s->scale = NULL;
} }
static int query_formats(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment