From: Gildas Bazin Date: Wed, 20 Apr 2005 14:55:46 +0000 (+0000) Subject: * modules/demux/avi: pass on video palette. X-Git-Tag: 0.8.2~449 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=a5ce00f7318ebb8e628838de7d3c9cc586405d33;p=vlc * modules/demux/avi: pass on video palette. --- diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c index 04c3105553..b0e312a104 100644 --- a/modules/demux/avi/avi.c +++ b/modules/demux/avi/avi.c @@ -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): diff --git a/modules/demux/avi/libavi.c b/modules/demux/avi/libavi.c index 4fde68f74f..788945ab56 100644 --- a/modules/demux/avi/libavi.c +++ b/modules/demux/avi/libavi.c @@ -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,