- if !self.macbinary {
- self.read_root(strmgr)?;
- } else {
- let ver = self.src.read_byte()?;
- validate!(ver == 0);
- self.src.read_skip(64)?;
- let tag = self.src.read_tag()?;
- validate!(&tag == b"MooV");
- self.src.read_skip(14)?;
- let data_length = self.src.read_u32be()?;
- validate!(data_length > 8);
- let rsrc_length = self.src.read_u32be()?;
- validate!(rsrc_length > 0);
- self.src.read_skip(31)?;
- let ver = self.src.read_byte()?;
- validate!(ver == 0x81);
- let ver = self.src.read_byte()?;
- validate!(ver == 0x81);
- //xxx: maybe check header CRC
-
- let rsrc_start = 0x80 + ((data_length + 0x7F) & !0x7F);
- self.src.seek(SeekFrom::Start(rsrc_start.into()))?;
- let rsrc_off = self.src.read_u32be()?;
- let rsrc_map_off = self.src.read_u32be()?;
- let rsrc_size = self.src.read_u32be()?;
- let _rsrc_map_size = self.src.read_u32be()?;
- validate!(rsrc_off >= 0x10);
- validate!(rsrc_map_off >= rsrc_off + rsrc_size);
- self.src.seek(SeekFrom::Current(i64::from(rsrc_off - 16)))?;
- // I'm too lazy to parse resource map, so let's just iterate over resources for movie header
- let end_pos = u64::from(rsrc_start + rsrc_off + rsrc_size);
- let mut peek_buf = [0u8; 8];
- while self.src.tell() < end_pos {
- let cur_size = self.src.read_u32be()?;
- validate!(self.src.tell() + u64::from(cur_size) <= end_pos);
- if cur_size > 8 {
- let rsize = self.src.peek_u32be()?;
- if rsize == cur_size {
- self.src.peek_buf(&mut peek_buf)?;
- if &peek_buf[4..] == b"moov" {
- self.src.read_skip(8)?;
- self.read_moov(strmgr, rsize.into())?;
- self.mdat_pos = 8;
- break;
+ let mut data_start = 0;
+ match self.demux_mode {
+ DemuxMode::Normal => self.read_root(strmgr)?,
+ DemuxMode::MacBin => {
+ let ver = self.src.read_byte()?;
+ validate!(ver == 0);
+ self.src.read_skip(64)?;
+ let tag = self.src.read_tag()?;
+ validate!(&tag == b"MooV");
+ self.src.read_skip(14)?;
+ let data_length = self.src.read_u32be()?;
+ validate!(data_length > 8);
+ let rsrc_length = self.src.read_u32be()?;
+ validate!(rsrc_length > 0);
+ self.src.read_skip(31)?;
+ let ver = self.src.read_byte()?;
+ validate!(ver == 0x81);
+ let ver = self.src.read_byte()?;
+ validate!(ver == 0x81);
+ //xxx: maybe check header CRC
+
+ let rsrc_start = 0x80 + ((data_length + 0x7F) & !0x7F);
+ self.src.seek(SeekFrom::Start(rsrc_start.into()))?;
+ let rsrc_off = self.src.read_u32be()?;
+ let rsrc_map_off = self.src.read_u32be()?;
+ let rsrc_size = self.src.read_u32be()?;
+ let _rsrc_map_size = self.src.read_u32be()?;
+ validate!(rsrc_off >= 0x10);
+ validate!(rsrc_map_off >= rsrc_off + rsrc_size);
+ self.src.seek(SeekFrom::Current(i64::from(rsrc_off - 16)))?;
+ // I'm too lazy to parse resource map, so let's just iterate over resources for movie header
+ let end_pos = u64::from(rsrc_start + rsrc_off + rsrc_size);
+ let mut peek_buf = [0u8; 8];
+ while self.src.tell() < end_pos {
+ let cur_size = self.src.read_u32be()?;
+ validate!(self.src.tell() + u64::from(cur_size) <= end_pos);
+ if cur_size > 8 {
+ let rsize = self.src.peek_u32be()?;
+ if rsize == cur_size {
+ self.src.peek_buf(&mut peek_buf)?;
+ if &peek_buf[4..] == b"moov" {
+ self.src.read_skip(8)?;
+ self.read_moov(strmgr, rsize.into())?;
+ self.mdat_pos = 8;
+ break;
+ }