[FFmpeg-devel] [PATCH] examples/muxing.c: use av_image_alloc() for allocating an image buffer

Michael Niedermayer michaelni at gmx.at
Sat Jul 9 21:45:24 CEST 2011


On Sat, Jul 09, 2011 at 03:27:46PM +0200, Stefano Sabatini wrote:
> On date Saturday 2011-07-09 09:16:42 +0200, Michael Niedermayer encoded:
> > On Fri, Jul 08, 2011 at 10:12:27AM +0200, Stefano Sabatini wrote:
> > > Simplify.
> > > ---
> > >  doc/examples/encoding.c |   15 ++++-----------
> > >  1 files changed, 4 insertions(+), 11 deletions(-)
> > > 
> > > diff --git a/doc/examples/encoding.c b/doc/examples/encoding.c
> > > index afe7e4f..ffb6246 100644
> > > --- a/doc/examples/encoding.c
> > > +++ b/doc/examples/encoding.c
> > > @@ -205,7 +205,7 @@ static void video_encode_example(const char *filename)
> > >      int i, out_size, size, x, y, outbuf_size;
> > >      FILE *f;
> > >      AVFrame *picture;
> > > -    uint8_t *outbuf, *picture_buf;
> > > +    uint8_t *outbuf;
> > >  
> > >      printf("Video encoding\n");
> > >  
> > > @@ -245,15 +245,8 @@ static void video_encode_example(const char *filename)
> > >      /* alloc image and output buffer */
> > >      outbuf_size = 100000;
> > >      outbuf = malloc(outbuf_size);
> > > -    size = c->width * c->height;
> > > -    picture_buf = malloc((size * 3) / 2); /* size for YUV 420 */
> > > -
> > > -    picture->data[0] = picture_buf;
> > > -    picture->data[1] = picture->data[0] + size;
> > > -    picture->data[2] = picture->data[1] + size / 4;
> > > -    picture->linesize[0] = c->width;
> > > -    picture->linesize[1] = c->width / 2;
> > > -    picture->linesize[2] = c->width / 2;
> > > +    av_image_alloc(picture->data, picture->linesize,
> > > +                   c->width, c->height, c->pix_fmt, 1);
> > 
> > I suggest, as this is an example to also write (in a comment)
> > that the image can be allocated by any means and av_image_alloc() is
> > just the most convenient way if av_malloc is to be used
> 
> Check attached. I'll apply soon if I see no more comments.
> -- 
> FFmpeg = Fast & Fiendish Monstrous Proud Evangelical God

>  encoding.c |   16 ++++++----------
>  1 file changed, 6 insertions(+), 10 deletions(-)
> 0a43a32ae54b59149ff3488d2d4b12f91683c7f8  0001-examples-encoding.c-use-av_image_alloc-for-allocatin.patch
> From 557a19dee6d6c9cdf1bc44cf66d667c21f5c56d1 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> Date: Fri, 8 Jul 2011 09:52:07 +0200
> Subject: [PATCH] examples/encoding.c: use av_image_alloc() for allocating an image buffer

LGTM, thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"    - "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110709/1929c7a8/attachment.asc>


More information about the ffmpeg-devel mailing list