From: Kostya Shishkov Date: Tue, 14 Dec 2021 11:48:22 +0000 (+0100) Subject: mov: fix an exotic paletted MOV reading X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=0ad1f05e99c19c79acc7f5e8e18a94468af275ac;p=nihav.git mov: fix an exotic paletted MOV reading --- diff --git a/nihav-commonfmt/src/demuxers/mov.rs b/nihav-commonfmt/src/demuxers/mov.rs index 23781a9..aea8ecb 100644 --- a/nihav-commonfmt/src/demuxers/mov.rs +++ b/nihav-commonfmt/src/demuxers/mov.rs @@ -43,10 +43,11 @@ fn read_chunk_header(br: &mut ByteReader) -> DemuxerResult<(u32, u64)> { fn read_palette(br: &mut ByteReader, size: u64, pal: &mut [u8; 1024]) -> DemuxerResult { let _seed = br.read_u32be()?; - let _flags = br.read_u16be()?; + let flags = br.read_u16be()?; let palsize = (br.read_u16be()? as usize) + 1; validate!(palsize <= 256); - validate!((palsize as u64) * 8 + 8 == size); + validate!(flags == 0 || flags == 0x4000 || flags == 0x8000); + validate!((palsize as u64) * 8 + 8 <= size); for i in 0..palsize { let a = br.read_u16be()?; let r = br.read_u16be()?; @@ -55,7 +56,12 @@ fn read_palette(br: &mut ByteReader, size: u64, pal: &mut [u8; 1024]) -> Demuxer pal[i * 4] = (r >> 8) as u8; pal[i * 4 + 1] = (g >> 8) as u8; pal[i * 4 + 2] = (b >> 8) as u8; - pal[i * 4 + 3] = (a >> 8) as u8; + if flags == 0x8000 { + pal[i * 4 + 3] = (a >> 8) as u8; + } + } + if flags == 0x4000 { + br.read_skip(8)?; } Ok(size) }