lavfi: unref AVFilterLink.cur_buf in ff_end_frame().

This reduces code duplication and prevents stale pointers from remaining
on the link.
This commit is contained in:
Anton Khirnov 2012-07-14 17:09:43 +02:00
parent 533fd5b5b4
commit 07bad27810
17 changed files with 5 additions and 20 deletions

View File

@ -91,6 +91,7 @@ static int add_to_queue(AVFilterLink *inlink, AVFilterBufferRef *buf)
static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *buf)
{
add_to_queue(inlink, buf);
inlink->cur_buf = NULL;
}
static void queue_pop(FifoContext *s)

View File

@ -89,8 +89,6 @@ static void end_frame(AVFilterLink *inlink)
for (i = 0; i < ctx->nb_outputs; i++)
ff_end_frame(ctx->outputs[i]);
avfilter_unref_buffer(inlink->cur_buf);
}
AVFilter avfilter_vf_split = {

View File

@ -317,7 +317,6 @@ static void end_frame(AVFilterLink *link)
CropContext *crop = link->dst->priv;
crop->var_values[VAR_N] += 1.0;
avfilter_unref_buffer(link->cur_buf);
ff_end_frame(link->dst->outputs[0]);
}

View File

@ -260,7 +260,6 @@ static void end_frame(AVFilterLink *inlink)
ff_draw_slice(outlink, 0, inlink->h, 1);
ff_end_frame(outlink);
avfilter_unref_buffer(inpicref);
avfilter_unref_buffer(outpicref);
}

View File

@ -868,7 +868,6 @@ static void end_frame(AVFilterLink *inlink)
ff_draw_slice(outlink, 0, picref->video->h, 1);
ff_end_frame(outlink);
avfilter_unref_buffer(inlink->cur_buf);
}
AVFilter avfilter_vf_drawtext = {

View File

@ -213,7 +213,6 @@ static void end_frame(AVFilterLink *inlink)
}
ff_end_frame(outlink);
avfilter_unref_buffer(inpicref);
avfilter_unref_bufferp(&outlink->out_buf);
}

View File

@ -175,6 +175,7 @@ static void end_frame(AVFilterLink *inlink)
int64_t delta;
int i;
inlink->cur_buf = NULL;
s->frames_in++;
/* discard frames until we get the first timestamp */
if (s->pts == AV_NOPTS_VALUE) {

View File

@ -352,7 +352,6 @@ static void end_frame(AVFilterLink *inlink)
frei0r->update(frei0r->instance, inpicref->pts * av_q2d(inlink->time_base) * 1000,
(const uint32_t *)inpicref->data[0],
(uint32_t *)outpicref->data[0]);
avfilter_unref_buffer(inpicref);
ff_draw_slice(outlink, 0, outlink->h, 1);
ff_end_frame(outlink);
avfilter_unref_buffer(outpicref);

View File

@ -225,7 +225,6 @@ static void end_frame(AVFilterLink *inlink)
ff_draw_slice(outlink, 0, inlink->h, 1);
ff_end_frame(outlink);
avfilter_unref_buffer(inpic);
avfilter_unref_buffer(outpic);
}

View File

@ -322,7 +322,6 @@ static void end_frame(AVFilterLink *inlink)
ff_draw_slice(outlink, 0, inpic->video->h, 1);
ff_end_frame(outlink);
avfilter_unref_buffer(inpic);
avfilter_unref_buffer(outpic);
}

View File

@ -365,7 +365,6 @@ static void end_frame(AVFilterLink *inlink)
ocv->end_frame_filter(ctx, &inimg, &outimg);
fill_picref_from_iplimage(outpicref, &outimg, inlink->format);
avfilter_unref_buffer(inpicref);
ff_draw_slice(outlink, 0, outlink->h, 1);
ff_end_frame(outlink);
avfilter_unref_buffer(outpicref);

View File

@ -339,7 +339,6 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
static void end_frame(AVFilterLink *inlink)
{
ff_end_frame(inlink->dst->outputs[0]);
avfilter_unref_buffer(inlink->cur_buf);
}
static void null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { }

View File

@ -348,7 +348,6 @@ static void end_frame(AVFilterLink *link)
{
ff_end_frame(link->dst->outputs[0]);
avfilter_unref_buffer(link->dst->outputs[0]->out_buf);
avfilter_unref_buffer(link->cur_buf);
}
static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, int before_slice)

View File

@ -258,14 +258,12 @@ static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
static void end_frame(AVFilterLink *inlink)
{
SelectContext *select = inlink->dst->priv;
AVFilterBufferRef *picref = inlink->cur_buf;
if (select->select) {
if (select->cache_frames)
return;
ff_end_frame(inlink->dst->outputs[0]);
}
avfilter_unref_buffer(picref);
}
static int request_frame(AVFilterLink *outlink)

View File

@ -192,7 +192,6 @@ static void end_frame(AVFilterLink *inlink)
}
}
avfilter_unref_buffer(inpic);
ff_draw_slice(outlink, 0, outpic->video->h, 1);
ff_end_frame(outlink);
avfilter_unref_buffer(outpic);

View File

@ -225,7 +225,6 @@ static void end_frame(AVFilterLink *link)
apply_unsharp(out->data[1], out->linesize[1], in->data[1], in->linesize[1], cw, ch, &unsharp->chroma);
apply_unsharp(out->data[2], out->linesize[2], in->data[2], in->linesize[2], cw, ch, &unsharp->chroma);
avfilter_unref_buffer(in);
ff_draw_slice(link->dst->outputs[0], 0, link->h, 1);
ff_end_frame(link->dst->outputs[0]);
avfilter_unref_buffer(out);

View File

@ -162,7 +162,8 @@ AVFilterBufferRef *ff_get_video_buffer(AVFilterLink *link, int perms, int w, int
void ff_null_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
{
ff_start_frame(link->dst->outputs[0], picref);
AVFilterBufferRef *buf_out = avfilter_ref_buffer(picref, ~0);
ff_start_frame(link->dst->outputs[0], buf_out);
}
static void default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
@ -223,9 +224,6 @@ static void default_end_frame(AVFilterLink *inlink)
if (inlink->dst->nb_outputs)
outlink = inlink->dst->outputs[0];
avfilter_unref_buffer(inlink->cur_buf);
inlink->cur_buf = NULL;
if (outlink) {
if (outlink->out_buf) {
avfilter_unref_buffer(outlink->out_buf);
@ -250,6 +248,7 @@ void ff_end_frame(AVFilterLink *link)
avfilter_unref_buffer(link->src_buf);
link->src_buf = NULL;
}
avfilter_unref_bufferp(&link->cur_buf);
}
void ff_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)