Commit a5ce00f7 authored by gbazin's avatar gbazin
Browse files

* modules/demux/avi: pass on video palette.

parent 9471dec2
......@@ -434,15 +434,14 @@ static int Open( vlc_object_t * p_this )
fmt.video.i_width = p_vids->p_bih->biWidth;
fmt.video.i_height = p_vids->p_bih->biHeight;
fmt.video.i_bits_per_pixel = p_vids->p_bih->biBitCount;
fmt.video.i_frame_rate = tk->i_rate;
fmt.video.i_frame_rate_base = tk->i_scale;
fmt.video.i_frame_rate = tk->i_rate;
fmt.video.i_frame_rate_base = tk->i_scale;
fmt.i_extra =
__MIN( p_vids->p_bih->biSize - sizeof( BITMAPINFOHEADER ),
p_vids->i_chunk_size - sizeof(BITMAPINFOHEADER) );
fmt.p_extra = &p_vids->p_bih[1];
msg_Dbg( p_demux, "stream[%d] video(%4.4s) %dx%d %dbpp %ffps",
i,
(char*)&p_vids->p_bih->biCompression,
i, (char*)&p_vids->p_bih->biCompression,
p_vids->p_bih->biWidth,
p_vids->p_bih->biHeight,
p_vids->p_bih->biBitCount,
......@@ -454,6 +453,29 @@ static int Open( vlc_object_t * p_this )
fmt.video.i_height =
(unsigned int)(-(int)p_vids->p_bih->biHeight);
}
/* 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 )
{
int i;
fmt.video.p_palette = calloc( sizeof(video_palette_t), 1 );
fmt.video.p_palette->i_entries = 1;
/* 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);
}
}
break;
case( AVIFOURCC_txts):
......
......@@ -385,8 +385,7 @@ static int AVI_ChunkRead_strf( stream_t *s, avi_chunk_t *p_chk )
AVI_READ4BYTES( p_chk->strf.vids.p_bih->biYPelsPerMeter );
AVI_READ4BYTES( p_chk->strf.vids.p_bih->biClrUsed );
AVI_READ4BYTES( p_chk->strf.vids.p_bih->biClrImportant );
if( p_chk->strf.vids.p_bih->biSize >
p_chk->common.i_chunk_size )
if( 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;
}
......@@ -394,8 +393,7 @@ static int AVI_ChunkRead_strf( stream_t *s, avi_chunk_t *p_chk )
{
memcpy( &p_chk->strf.vids.p_bih[1],
p_buff + 8 + sizeof(BITMAPINFOHEADER), /* 8=fourrc+size */
p_chk->strf.vids.p_bih->biSize -
sizeof(BITMAPINFOHEADER) );
p_chk->common.i_chunk_size -sizeof(BITMAPINFOHEADER) );
}
#ifdef AVI_DEBUG
msg_Dbg( (vlc_object_t*)s,
......
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