]> git.sesse.net Git - vlc/commitdiff
avcodec: encoder: Fix rounding issue
authorHugo Beauzée-Luyssen <hugo@beauzee.fr>
Tue, 10 Jun 2014 21:35:52 +0000 (00:35 +0300)
committerHugo Beauzée-Luyssen <hugo@beauzee.fr>
Wed, 11 Jun 2014 17:20:11 +0000 (20:20 +0300)
modules/codec/avcodec/encoder.c

index 04e62303b221f2ff0796972e7cfeacd657f5f71e..65ce2854a273114b70496cd2b51731b0c8dccda2 100644 (file)
@@ -1021,13 +1021,12 @@ static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
      * This is done here instead of OpenEncoder() because we need the actual
      * 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 :
+    const int bitsPerPixel = p_enc->fmt_out.video.i_bits_per_pixel ?
+                         p_enc->fmt_out.video.i_bits_per_pixel :
                          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 );
+                         p_sys->p_context->bits_per_coded_sample :
+                         24;
+    const int blocksize = __MAX( FF_MIN_BUFFER_SIZE, ( bitsPerPixel * p_sys->p_context->height * p_sys->p_context->width ) / 8 + 200 );
     block_t *p_block = block_Alloc( blocksize );
     if( unlikely(p_block == NULL) )
         return NULL;