[vlc-devel] [PATCH] Revert "avi: Tidy the palette handling bit."

Rafaël Carré funman at videolan.org
Tue Oct 15 17:18:06 CEST 2013


This reverts commit afc252c4ccfa83f30cf1aad598fea688540098c6.

The extradata was not being extracted in some cases
Closes #9546
---
 modules/demux/avi/avi.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index 8d1fca3..d7b8984 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -537,6 +537,15 @@ static int Open( vlc_object_t * p_this )
                     fmt.video.i_sar_num = ((i_frame_aspect_ratio >> 16) & 0xffff) * fmt.video.i_height;
                     fmt.video.i_sar_den = ((i_frame_aspect_ratio >>  0) & 0xffff) * fmt.video.i_width;
                 }
+                fmt.i_extra =
+                    __MAX( p_vids->p_bih->biSize - sizeof( VLC_BITMAPINFOHEADER ),
+                           p_vids->i_chunk_size - sizeof(VLC_BITMAPINFOHEADER) );
+                if( fmt.i_extra > 0 )
+                {
+                    fmt.p_extra = malloc( fmt.i_extra );
+                    if( !fmt.p_extra ) goto error;
+                    memcpy( fmt.p_extra, &p_vids->p_bih[1], fmt.i_extra );
+                }
 
                 msg_Dbg( p_demux, "stream[%d] video(%4.4s) %"PRIu32"x%"PRIu32" %dbpp %ffps",
                          i, (char*)&p_vids->p_bih->biCompression,
@@ -557,15 +566,10 @@ static int Open( vlc_object_t * p_this )
                  *  to be true for all palettized codecs we support) */
                 if( fmt.video.i_bits_per_pixel > 0 && fmt.video.i_bits_per_pixel <= 8 )
                 {
-                    /* The palette should not be included in biSize, but come
-                     * directly after BITMAPINFORHEADER in the BITMAPINFO structure */
+                    /* The palette is not always included in biSize */
                     fmt.i_extra = p_vids->i_chunk_size - sizeof(VLC_BITMAPINFOHEADER);
-                    if( fmt.i_extra > 0 )
+                    if( fmt.i_extra > 0 && fmt.p_extra )
                     {
-                        fmt.p_extra = malloc( fmt.i_extra );
-                        if( !fmt.p_extra ) goto error;
-                        memcpy( fmt.p_extra, &p_vids->p_bih[1], fmt.i_extra );
-
                         const uint8_t *p_pal = fmt.p_extra;
 
                         fmt.video.p_palette = calloc( 1, sizeof(video_palette_t) );
-- 
1.8.3.2




More information about the vlc-devel mailing list