[vlc-devel] [PATCH] avcodec encoder: get bytes per pixel from context if needed

Tristan Matthews le.businessman at gmail.com
Wed Apr 2 09:43:07 CEST 2014


1On Wed, Apr 2, 2014 at 3:18 AM, Rafaël Carré <funman at videolan.org> wrote:

> Hi,
>
> On 04/02/14 08:25, Tristan Matthews wrote:
> > Defaulting to 3 bytes broke the buffer allocation for BMP with ffmpeg,
> which
> > defaults to RGBA.
> >
> > Fixes #9687
> > ---
> >  modules/codec/avcodec/encoder.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/modules/codec/avcodec/encoder.c
> b/modules/codec/avcodec/encoder.c
> > index df77340..9bfe238 100644
> > --- a/modules/codec/avcodec/encoder.c
> > +++ b/modules/codec/avcodec/encoder.c
>
> OK
>
> > @@ -1017,7 +1017,11 @@ static block_t *EncodeVideo( encoder_t *p_enc,
> picture_t *p_pict )
>
>     /* Initialize the video output buffer the first time.
>      * This is done here instead of OpenEncoder() because we need the
> actual
>
> >       * bits_per_pixel value, without having to assume anything.
> >       */
>
> Can we use that value in OpenEncoder?
>

p_context->bits_per_coded sample gets set by avcodec_open2, which happens
in OpenEncoder. However, p_enc->fmt_out.video.i_bits_per_pixel is not
usable until EncodeVideo so I wouldn't want to break cases that depend on
it.


> >      const int bytesPerPixel = p_enc->fmt_out.video.i_bits_per_pixel ?
> > -                         p_enc->fmt_out.video.i_bits_per_pixel / 8 : 3;
> > +                         p_enc->fmt_out.video.i_bits_per_pixel / 8 :
> > +                         p_sys->p_context->bits_per_coded_sample ?
> > +                         p_sys->p_context->bits_per_coded_sample / 8 :
> > +                         3;
> > +
> >      const int blocksize = __MAX( FF_MIN_BUFFER_SIZE,bytesPerPixel *
> p_sys->p_context->height * p_sys->p_context->width + 200 );
> >      block_t *p_block = block_Alloc( blocksize );
> >      if( unlikely(p_block == NULL) )
> >
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20140402/4c815366/attachment.html>


More information about the vlc-devel mailing list