]> git.nihav.org Git - nihav.git/commitdiff
avi: take palette from bitmapinfo extradata if it happens to be there
authorKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 6 Mar 2026 16:34:31 +0000 (17:34 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 6 Mar 2026 16:34:31 +0000 (17:34 +0100)
nihav-commonfmt/src/demuxers/avi.rs

index 3c6a5cc0aaa5598333ff19a532d5cf268e66220a..957b5515f92650dc91b1e010c2917072a7e2ca1e 100644 (file)
@@ -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 {