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 ) ...@@ -568,21 +568,22 @@ static int Open( vlc_object_t * p_this )
/* Extract palette from extradata if bpp <= 8 /* Extract palette from extradata if bpp <= 8
* (assumes that extradata contains only palette but appears * (assumes that extradata contains only palette but appears
* to be true for all palettized codecs we support) */ * to be true for all palettized codecs we support) */
if( fmt.i_extra && fmt.video.i_bits_per_pixel <= 8 && if( fmt.video.i_bits_per_pixel > 0 && fmt.video.i_bits_per_pixel <= 8 )
fmt.video.i_bits_per_pixel > 0 )
{ {
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 = 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 ? */ for( int i = 0; i < fmt.video.p_palette->i_entries; i++ )
fmt.i_extra = {
p_vids->i_chunk_size - sizeof(BITMAPINFOHEADER); for( int j = 0; j < 4; j++ )
for( i = 0; i < __MIN(fmt.i_extra/4, 256); i++ ) fmt.video.p_palette->palette[i][j] = p_pal[4*i+j];
{ }
((uint32_t *)&fmt.video.p_palette->palette[0][0])[i] =
GetDWLE((uint32_t*)fmt.p_extra + i);
} }
} }
break; break;
......
...@@ -398,7 +398,7 @@ static int AVI_ChunkRead_strf( stream_t *s, avi_chunk_t *p_chk ) ...@@ -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; 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], memcpy( &p_chk->strf.vids.p_bih[1],
p_buff + 8 + sizeof(BITMAPINFOHEADER), /* 8=fourrc+size */ 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