[vlc-commits] avcodec: encoder: Fix rounding issue

Hugo Beauzée-Luyssen git at videolan.org
Wed Jun 11 19:20:56 CEST 2014


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Wed Jun 11 00:35:52 2014 +0300| [7c1eb097a3a07c110af64cb3e8cd5c7ed9b5c880] | committer: Hugo Beauzée-Luyssen

avcodec: encoder: Fix rounding issue

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

 modules/codec/avcodec/encoder.c |   11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 04e6230..65ce285 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -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;



More information about the vlc-commits mailing list