Commit 4494922c authored by Francois Cartegnie's avatar Francois Cartegnie

demux: avi: handle paletized bitmaps

fruity.avi
parent cb7b1eef
......@@ -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;
}
......
......@@ -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
......
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