[FFmpeg-cvslog] vf_tile: fix output buffer ownership.

Nicolas George git at videolan.org
Wed Aug 1 13:05:27 CEST 2012


ffmpeg | branch: master | Nicolas George <nicolas.george at normalesup.org> | Wed Aug  1 12:23:48 2012 +0200| [f952b23ed4b720b4544d520713458ea28e12c2d6] | committer: Nicolas George

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.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f952b23ed4b720b4544d520713458ea28e12c2d6
---

 libavfilter/vf_tile.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

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++;
 }
@@ -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;
 }



More information about the ffmpeg-cvslog mailing list