Commit f3205789 authored by Laurent Aimar's avatar Laurent Aimar

Fixed AVI palette support.

parent 61146f7e
......@@ -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->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++ )
for( int i = 0; i < fmt.video.p_palette->i_entries; i++ )
{
((uint32_t *)&fmt.video.p_palette->palette[0][0])[i] =
GetDWLE((uint32_t*)fmt.p_extra + i);
for( int j = 0; j < 4; j++ )
fmt.video.p_palette->palette[i][j] = p_pal[4*i+j];
}
}
}
break;
......
......@@ -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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment