mirror of https://git.ffmpeg.org/ffmpeg.git
vf_tile: fix output buffer ownership.
There is no need to start_frame immediately on the output link since the rest is only done with the last frame of the tile. link->out_buf is now automatically dereferenced; since we give it away it must be cleared. Fix an assert failure; found by Clément Bœsch.
This commit is contained in:
parent
7ddf082f04
commit
f952b23ed4
|
@ -109,7 +109,7 @@ static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
|
|||
avfilter_copy_buffer_ref_props(outlink->out_buf, picref);
|
||||
outlink->out_buf->video->w = outlink->w;
|
||||
outlink->out_buf->video->h = outlink->h;
|
||||
return ff_start_frame(outlink, outlink->out_buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
|
||||
|
@ -129,16 +129,15 @@ static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void draw_blank_frame(AVFilterContext *ctx)
|
||||
static void draw_blank_frame(AVFilterContext *ctx, AVFilterBufferRef *out_buf)
|
||||
{
|
||||
TileContext *tile = ctx->priv;
|
||||
AVFilterLink *inlink = ctx->inputs[0];
|
||||
AVFilterLink *outlink = ctx->outputs[0];
|
||||
unsigned x0 = inlink->w * (tile->current % tile->w);
|
||||
unsigned y0 = inlink->h * (tile->current / tile->w);
|
||||
|
||||
ff_fill_rectangle(&tile->draw, &tile->blank,
|
||||
outlink->out_buf->data, outlink->out_buf->linesize,
|
||||
out_buf->data, out_buf->linesize,
|
||||
x0, y0, inlink->w, inlink->h);
|
||||
tile->current++;
|
||||
}
|
||||
|
@ -146,10 +145,13 @@ static void end_last_frame(AVFilterContext *ctx)
|
|||
{
|
||||
TileContext *tile = ctx->priv;
|
||||
AVFilterLink *outlink = ctx->outputs[0];
|
||||
AVFilterBufferRef *out_buf = outlink->out_buf;
|
||||
|
||||
outlink->out_buf = NULL;
|
||||
ff_start_frame(outlink, out_buf);
|
||||
while (tile->current < tile->w * tile->h)
|
||||
draw_blank_frame(ctx);
|
||||
ff_draw_slice(outlink, 0, outlink->out_buf->video->h, 1);
|
||||
draw_blank_frame(ctx, out_buf);
|
||||
ff_draw_slice(outlink, 0, out_buf->video->h, 1);
|
||||
ff_end_frame(outlink);
|
||||
tile->current = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue