[vlc-devel] commit: Fixed AVI palette support. (Laurent Aimar )

git version control git at videolan.org
Sun Sep 7 15:03:48 CEST 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun Sep  7 00:23:10 2008 +0200| [f3205789f5f153cb7a756d4033c8a3cace9058c8] | committer: Laurent Aimar 

Fixed AVI palette support.

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

 modules/demux/avi/avi.c    |   25 +++++++++++++------------
 modules/demux/avi/libavi.c |    2 +-
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c
index 9e509f0..bc84ec8 100644
--- a/modules/demux/avi/avi.c
+++ b/modules/demux/avi/avi.c
@@ -568,21 +568,22 @@ static int Open( vlc_object_t * p_this )
                 /* Extract palette from extradata if bpp <= 8
                  * (assumes that extradata contains only palette but appears
                  *  to be true for all palettized codecs we support) */
-                if( fmt.i_extra && fmt.video.i_bits_per_pixel <= 8 &&
-                    fmt.video.i_bits_per_pixel > 0 )
+                if( fmt.video.i_bits_per_pixel > 0 && fmt.video.i_bits_per_pixel <= 8 )
                 {
-                    int i;
+                    /* The palette is not always included in biSize */
+                    fmt.i_extra = p_vids->i_chunk_size - sizeof(BITMAPINFOHEADER);
+                    if( fmt.i_extra > 0 )
+                    {
+                        const uint8_t *p_pal = fmt.p_extra;
 
-                    fmt.video.p_palette = calloc( sizeof(video_palette_t), 1 );
-                    fmt.video.p_palette->i_entries = 1;
+                        fmt.video.p_palette = calloc( sizeof(video_palette_t), 1 );
+                        fmt.video.p_palette->i_entries = __MIN(fmt.i_extra/4, 256);
 
-                    /* Apparently this is necessary. But why ? */
-                    fmt.i_extra =
-                        p_vids->i_chunk_size - sizeof(BITMAPINFOHEADER);
-                    for( i = 0; i < __MIN(fmt.i_extra/4, 256); i++ )
-                    {
-                        ((uint32_t *)&fmt.video.p_palette->palette[0][0])[i] =
-                            GetDWLE((uint32_t*)fmt.p_extra + i);
+                        for( int i = 0; i < fmt.video.p_palette->i_entries; i++ )
+                        {
+                            for( int j = 0; j < 4; j++ )
+                                fmt.video.p_palette->palette[i][j] = p_pal[4*i+j];
+                        }
                     }
                 }
                 break;
diff --git a/modules/demux/avi/libavi.c b/modules/demux/avi/libavi.c
index add6078..2f03219 100644
--- a/modules/demux/avi/libavi.c
+++ b/modules/demux/avi/libavi.c
@@ -398,7 +398,7 @@ static int AVI_ChunkRead_strf( stream_t *s, avi_chunk_t *p_chk )
             {
                 p_chk->strf.vids.p_bih->biSize = p_chk->common.i_chunk_size;
             }
-            if( p_chk->strf.vids.p_bih->biSize - sizeof(BITMAPINFOHEADER) > 0 )
+            if( p_chk->common.i_chunk_size - sizeof(BITMAPINFOHEADER) > 0 )
             {
                 memcpy( &p_chk->strf.vids.p_bih[1],
                         p_buff + 8 + sizeof(BITMAPINFOHEADER), /* 8=fourrc+size */




More information about the vlc-devel mailing list