From 368d7e889ec333937bca3170e098ad07749204c4 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Fri, 6 Mar 2026 17:34:31 +0100 Subject: [PATCH] avi: take palette from bitmapinfo extradata if it happens to be there --- nihav-commonfmt/src/demuxers/avi.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nihav-commonfmt/src/demuxers/avi.rs b/nihav-commonfmt/src/demuxers/avi.rs index 3c6a5cc..957b551 100644 --- a/nihav-commonfmt/src/demuxers/avi.rs +++ b/nihav-commonfmt/src/demuxers/avi.rs @@ -147,6 +147,17 @@ impl AVIStream { self.pal = Some(PalInfo { pal: Arc::new(pal), changed: true }); } } + } else if header.colors > 0 { + if let Some(ref buf) = header.extradata { + let mut pal = [0u8; 1024]; + for (dpal, spal) in pal.chunks_mut(4).take(header.colors).zip(buf.chunks(4)) { + dpal[0] = spal[2]; + dpal[1] = spal[1]; + dpal[2] = spal[0]; + dpal[3] = 0; + } + self.pal = Some(PalInfo { pal: Arc::new(pal), changed: true }); + } } if is_mvi { if let Some(ref mut dta) = edata { -- 2.39.5