]> git.nihav.org Git - nihav.git/blobdiff - nihav-acorn/src/demuxers/armovie.rs
rawvideo: support packed RGB a bit better
[nihav.git] / nihav-acorn / src / demuxers / armovie.rs
index 64d222f36593210ee6c6f162608b0d879ae883d9..4b2b3f6c53a3295557eee3e749204351eb9880d2 100644 (file)
@@ -13,6 +13,9 @@ const VIDEO_CODECS: &[(i32, &str)] = &[
     (122, "escape122"),
     (124, "escape124"),
     (130, "escape130"),
+    (600, "msvideo1"),
+    (601, "msvideo1"),
+    (602, "cinepak"),
     (800, "linepack"),
     (802, "movie16_3"),
 ];
@@ -26,7 +29,7 @@ impl<'a> ReadString for ByteReader<'a> {
         let mut res = Vec::new();
         loop {
             let c = self.read_byte()?;
-            if c == b'\n' {
+            if c == b'\n' || c == 0 {
                 break;
             }
             res.push(c);
@@ -218,7 +221,7 @@ impl<'a> RawDemuxCore<'a> for ARMovieDemuxer<'a> {
         let width = parse_int(&width)?;
         let height              = self.src.read_string()?;
         let height = parse_int(&height)?;
-        validate!((video_codec <= 0) ^ (width > 0 && height > 0));
+        validate!((video_codec <= 0) || (width > 0 && height > 0));
         let width  = width as usize;
         let height = height as usize;
         let vformat             = self.src.read_string()?;
@@ -278,7 +281,13 @@ impl<'a> RawDemuxCore<'a> for ARMovieDemuxer<'a> {
             let mut edata = vec![video_codec as u8, (video_codec >> 8) as u8];
             edata.extend_from_slice(&vformat);
 
-            let vci = NACodecTypeInfo::Video(NAVideoInfo::new(width, height, false, YUV420_FORMAT));
+            let fmt = match video_codec {
+                    600 => PAL8_FORMAT,
+                    601 => RGB565_FORMAT,
+                    _ => YUV420_FORMAT,
+                };
+
+            let vci = NACodecTypeInfo::Video(NAVideoInfo::new(width, height, false, fmt));
             let vinfo = NACodecInfo::new(codec_name, vci, Some(edata));
             let ret = strmgr.add_stream(NAStream::new(StreamType::Video, stream_id, vinfo, tb_num, tb_den, (frm_per_chunk * num_chunks) as u64));
             if ret.is_some() {