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

Tristan Matthews git at videolan.org
Wed Apr 2 11:09:06 CEST 2014


vlc | branch: master | Tristan Matthews <le.businessman at gmail.com> | Wed Apr  2 02:18:33 2014 -0400| [f5a53d4ee1316bd42fbf7d62721901f24a5899be] | committer: Tristan Matthews

avcodec encoder: get bytes per pixel from context if needed

Falling back to 3 bytes broke the buffer allocation for BMP with ffmpeg, which
defaults to RGBA.

Fixes #9687

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

 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
@@ -1017,7 +1017,11 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
      * bits_per_pixel value, without having to assume anything.
      */
     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) )



More information about the vlc-commits mailing list