From: Kostya Shishkov Date: Sat, 12 Dec 2020 16:53:11 +0000 (+0100) Subject: mov: parse mdhd chunk X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=079fff1d531162a4a5f90a28ad9a37929bcd97a1;p=nihav.git mov: parse mdhd chunk --- diff --git a/nihav-commonfmt/src/demuxers/mov.rs b/nihav-commonfmt/src/demuxers/mov.rs index 847d494..4d36c05 100644 --- a/nihav-commonfmt/src/demuxers/mov.rs +++ b/nihav-commonfmt/src/demuxers/mov.rs @@ -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 { + 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 { const KNOWN_HDLR_SIZE: u64 = 24; validate!(size >= KNOWN_HDLR_SIZE);