]> git.nihav.org Git - nihav.git/commitdiff
mov: parse mdhd chunk
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 12 Dec 2020 16:53:11 +0000 (17:53 +0100)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sat, 12 Dec 2020 17:02:07 +0000 (18:02 +0100)
nihav-commonfmt/src/demuxers/mov.rs

index 847d494877711700b13769dfc6c07bf6a8b89ba6..4d36c058713ffe337bbf342aa55b92eca45daf47 100644 (file)
@@ -343,11 +343,29 @@ fn read_mdia(track: &mut Track, br: &mut ByteReader, size: u64) -> DemuxerResult
 }
 
 const MDIA_CHUNK_HANDLERS: &[TrackChunkHandler] = &[
-    TrackChunkHandler { ctype: mktag!(b"mdhd"), parse: skip_chunk },
+    TrackChunkHandler { ctype: mktag!(b"mdhd"), parse: read_mdhd },
     TrackChunkHandler { ctype: mktag!(b"hdlr"), parse: read_hdlr },
     TrackChunkHandler { ctype: mktag!(b"minf"), parse: read_minf },
 ];
 
+fn read_mdhd(track: &mut Track, br: &mut ByteReader, size: u64) -> DemuxerResult<u64> {
+    const KNOWN_MDHD_SIZE: u64 = 24;
+    validate!(size >= KNOWN_MDHD_SIZE);
+    let version             = br.read_byte()?;
+    validate!(version == 0);
+    let flags               = br.read_u24be()?;
+    validate!(flags == 0);
+    let _ctime              = br.read_u32be()?;
+    let _mtime              = br.read_u32be()?;
+    track.tb_den            = br.read_u32be()?;
+    validate!(track.tb_den != 0);
+    track.duration          = br.read_u32be()?;
+    let _language           = br.read_u16be()?;
+    let _quality            = br.read_u16be()?;
+
+    Ok(KNOWN_MDHD_SIZE)
+}
+
 fn read_hdlr(track: &mut Track, br: &mut ByteReader, size: u64) -> DemuxerResult<u64> {
     const KNOWN_HDLR_SIZE: u64 = 24;
     validate!(size >= KNOWN_HDLR_SIZE);