vlc | branch: master | Francois Cartegnie <fcvlc...@free.fr> | Fri Apr 18 20:47:03 2014 +0200| [4494922c3ea07fcb886cc14055a0bc8f4d8e7ae4] | committer: Francois Cartegnie
demux: avi: handle paletized bitmaps fruity.avi > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4494922c3ea07fcb886cc14055a0bc8f4d8e7ae4 --- modules/demux/avi/avi.c | 26 ++++++++++++++++++++++++-- modules/demux/avi/libavi.c | 4 ++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/modules/demux/avi/avi.c b/modules/demux/avi/avi.c index efb7b2e..ceb9519 100644 --- a/modules/demux/avi/avi.c +++ b/modules/demux/avi/avi.c @@ -496,8 +496,11 @@ static int Open( vlc_object_t * p_this ) case 9: /* <- TODO check that */ tk->i_codec = VLC_CODEC_I410; break; - case 8: /* <- TODO check that */ - tk->i_codec = VLC_CODEC_GREY; + case 8: + if ( p_vids->p_bih->biClrUsed ) + tk->i_codec = VLC_CODEC_RGBP; + else + tk->i_codec = VLC_CODEC_GREY; break; } es_format_Init( &fmt, VIDEO_ES, tk->i_codec ); @@ -515,6 +518,25 @@ static int Open( vlc_object_t * p_this ) fmt.video.i_gmask = 0x03e0; fmt.video.i_bmask = 0x001f; break; + case VLC_CODEC_RGBP: + { + const VLC_BITMAPINFO *p_bi = (const VLC_BITMAPINFO *) p_vids->p_bih; + fmt.video.p_palette = malloc( sizeof(video_palette_t) ); + if ( fmt.video.p_palette ) + { + uint32_t entry; + for ( uint32_t i=0; i<p_vids->p_bih->biClrUsed; i++ ) + { + entry = GetDWBE( &p_bi->bmiColors[i] ); + fmt.video.p_palette->palette[i][0] = entry >> 24; + fmt.video.p_palette->palette[i][1] = (entry >> 16) & 0xFF; + fmt.video.p_palette->palette[i][2] = (entry >> 8) & 0xFF; + fmt.video.p_palette->palette[i][3] = entry & 0xFF; + } + fmt.video.p_palette->i_entries = p_vids->p_bih->biClrUsed; + } + } + break; default: break; } diff --git a/modules/demux/avi/libavi.c b/modules/demux/avi/libavi.c index d759770..235a370 100644 --- a/modules/demux/avi/libavi.c +++ b/modules/demux/avi/libavi.c @@ -430,6 +430,10 @@ static int AVI_ChunkRead_strf( stream_t *s, avi_chunk_t *p_chk ) __MAX( i_extrasize / sizeof(uint32_t), p_chk->strf.vids.p_bih->biClrUsed ); } + + /* stay within VLC's limits */ + p_chk->strf.vids.p_bih->biClrUsed = + __MAX( VIDEO_PALETTE_COLORS_MAX, p_chk->strf.vids.p_bih->biClrUsed ); } else p_chk->strf.vids.p_bih->biClrUsed = 0; #ifdef AVI_DEBUG _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits