[vlc-devel] [PATCH] Fixing avi with raw video padding issue

Gal Vinograd bl3nderb at aol.com
Mon Oct 28 05:35:22 CET 2013


this patch fix the padding issue with playing avi files with raw video codec. according to the specification every raw line of video should be padded to multiples of 4.
here are the faulty files:
http://speedy.sh/x9bVq/test-odd253-rgb-highspeed.avi
http://speedy.sh/54jA8/test-odd253-8b-highspeed.avi

reffering to Remi Denis-Courmont comments
---
 modules/codec/rawvideo.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/modules/codec/rawvideo.c b/modules/codec/rawvideo.c
index f2db545..47d84fd 100644
--- a/modules/codec/rawvideo.c
+++ b/modules/codec/rawvideo.c
@@ -65,6 +65,9 @@ static void *DecodeBlock  ( decoder_t *, block_t ** );
 static picture_t *DecodeFrame( decoder_t *, block_t * );
 static block_t   *SendFrame  ( decoder_t *, block_t * );
 
+static void RawPictureFixPadding( picture_t *picture );
+
+
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -182,6 +185,8 @@ static int OpenDecoder( vlc_object_t *p_this )
     picture_Setup( &picture, p_dec->fmt_out.i_codec,
                    p_dec->fmt_in.video.i_width,
                    p_dec->fmt_in.video.i_height, 0, 1 );
+    RawPictureFixPadding( &picture );
+
     p_sys->i_raw_size = 0;
     for( int i = 0; i < picture.i_planes; i++ )
     {
@@ -298,7 +303,7 @@ static void FillPicture( decoder_t *p_dec, block_t *p_block, picture_t *p_pic )
 
         if( p_sys->b_invert )
             for( p_dst_end -= i_pitch; p_dst <= p_dst_end;
-                 p_dst_end -= i_pitch, p_src += i_visible_pitch )
+                 p_dst_end -= i_pitch, p_src += i_pitch )
                 memcpy( p_dst_end, p_src, i_visible_pitch );
         else
             for( ; p_dst < p_dst_end;
@@ -317,6 +322,7 @@ static picture_t *DecodeFrame( decoder_t *p_dec, block_t *p_block )
 
     /* Get a new picture */
     p_pic = decoder_NewPicture( p_dec );
+    RawPictureFixPadding( p_pic );
     if( !p_pic )
     {
         block_Release( p_block );
@@ -361,6 +367,7 @@ static block_t *SendFrame( decoder_t *p_dec, block_t *p_block )
         picture_Setup( &pic, p_dec->fmt_out.i_codec,
                        p_dec->fmt_out.video.i_width,
                        p_dec->fmt_out.video.i_height, 0, 1 );
+        RawPictureFixPadding( &pic );
 
         if( !pic.i_planes )
         {
@@ -404,3 +411,13 @@ static void CloseDecoder( vlc_object_t *p_this )
     decoder_t *p_dec = (decoder_t*)p_this;
     free( p_dec->p_sys );
 }
+
+static void RawPictureFixPadding( picture_t *picture )
+{
+    int i;
+
+    for ( i = 0; i < picture->i_planes; i++ )
+    {
+        picture->p[i].i_pitch = picture->p[i].i_visible_pitch + 4 - (picture->p[i].i_visible_pitch % 4);
+    }
+}
-- 
1.8.3.2




More information about the vlc-devel mailing list