[FFmpeg-devel] [PATCH] vf_tile: fix output buffer ownership.
Stefano Sabatini
stefasab at gmail.com
Wed Aug 1 12:56:30 CEST 2012
On date Wednesday 2012-08-01 12:32:07 +0200, Nicolas George encoded:
> 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.
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> libavfilter/vf_tile.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
>
> Note: at some point I'll have to implement error checking for the push
> functions.
>
>
> diff --git a/libavfilter/vf_tile.c b/libavfilter/vf_tile.c
> index a6c7e7a..52d53eb 100644
> --- a/libavfilter/vf_tile.c
> +++ b/libavfilter/vf_tile.c
> @@ -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++;
> }
This seems unrelated, you can still access outlink->out_buf and clear
it just before ff_end_frame() (but I agree, it looks cleaner this
way).
> @@ -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;
> }
Should be good otherwise if tested, eventually split the patch (and:
we may consider the opportunity to add a FATE test for it), thanks.
--
FFmpeg = Fundamentalist Freak Mournful Political Exxagerate Glue
More information about the ffmpeg-devel
mailing list