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

Gal Vinograd bl3nderb at aol.com
Sat Oct 26 02:01:08 CEST 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
---
 modules/codec/rawvideo.c | 2 +-
 src/misc/picture.c       | 5 +----
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/modules/codec/rawvideo.c b/modules/codec/rawvideo.c
index f2db545..bd27956 100644
--- a/modules/codec/rawvideo.c
+++ b/modules/codec/rawvideo.c
@@ -298,7 +298,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;
diff --git a/src/misc/picture.c b/src/misc/picture.c
index 3e1fb68..99704ab 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -160,19 +160,16 @@ int picture_Setup( picture_t *p_picture, vlc_fourcc_t i_chroma,
        Which is respected if you have
        V % lcm( p_dsc->p[0..planes].w.i_den * 16) == 0
     */
-    int i_modulo_w = 1;
     int i_modulo_h = 1;
     unsigned int i_ratio_h  = 1;
     for( unsigned i = 0; i < p_dsc->plane_count; i++ )
     {
-        i_modulo_w = LCM( i_modulo_w, 16 * p_dsc->p[i].w.den );
         i_modulo_h = LCM( i_modulo_h, 16 * p_dsc->p[i].h.den );
         if( i_ratio_h < p_dsc->p[i].h.den )
             i_ratio_h = p_dsc->p[i].h.den;
     }
     i_modulo_h = LCM( i_modulo_h, 32 );
 
-    const int i_width_aligned  = ( i_width  + i_modulo_w - 1 ) / i_modulo_w * i_modulo_w;
     const int i_height_aligned = ( i_height + i_modulo_h - 1 ) / i_modulo_h * i_modulo_h;
     const int i_height_extra   = 2 * i_ratio_h; /* This one is a hack for some ASM functions */
     for( unsigned i = 0; i < p_dsc->plane_count; i++ )
@@ -181,8 +178,8 @@ int picture_Setup( picture_t *p_picture, vlc_fourcc_t i_chroma,
 
         p->i_lines         = (i_height_aligned + i_height_extra ) * p_dsc->p[i].h.num / p_dsc->p[i].h.den;
         p->i_visible_lines = i_height * p_dsc->p[i].h.num / p_dsc->p[i].h.den;
-        p->i_pitch         = i_width_aligned * p_dsc->p[i].w.num / p_dsc->p[i].w.den * p_dsc->pixel_size;
         p->i_visible_pitch = i_width * p_dsc->p[i].w.num / p_dsc->p[i].w.den * p_dsc->pixel_size;
+        p->i_pitch         = p->i_visible_pitch  + 4 - (p->i_visible_pitch % 4);
         p->i_pixel_pitch   = p_dsc->pixel_size;
 
         assert( (p->i_pitch % 16) == 0 );
-- 
1.8.3.2




More information about the vlc-devel mailing list