]> git.sesse.net Git - vlc/commitdiff
avcodec encoder: get bytes per pixel from context if needed
authorTristan Matthews <le.businessman@gmail.com>
Wed, 2 Apr 2014 06:18:33 +0000 (02:18 -0400)
committerTristan Matthews <le.businessman@gmail.com>
Wed, 2 Apr 2014 09:07:35 +0000 (05:07 -0400)
Falling back to 3 bytes broke the buffer allocation for BMP with ffmpeg, which
defaults to RGBA.

Fixes #9687

modules/codec/avcodec/encoder.c

index df77340c0ea06e0b99ac0614ee33884acc94cd05..9bfe2385efa59703961e9e061e4484394704a87c 100644 (file)
@@ -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) )