From 62379cdcd0f60f1f28bb4fb50bd99120db987b3c Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Thu, 13 Jan 2022 18:29:11 +0100 Subject: [PATCH] ignore MusicMatch tag --- src/demux.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/demux.rs b/src/demux.rs index bf8a072..0786275 100644 --- a/src/demux.rs +++ b/src/demux.rs @@ -370,6 +370,27 @@ pub fn detect_tags(br: &mut ByteReader) -> (bool, u64, Option) { end = Some(off - size); } } + // check for MusicMatch tag + let ret = if let Some(endpos) = end { + br.seek(SeekFrom::Start(endpos - 0x30)) + } else { + br.seek(SeekFrom::End(-0x30)) + }; + if ret.is_ok() && br.tell() > (0x2000 - 0x30) { + let mut buf = [0; 19]; + br.peek_buf(&mut buf).unwrap(); + if &buf == b"Brava Software Inc." { + br.seek(SeekFrom::Current(-20)).unwrap(); + let mut mm_start = u64::from(br.read_u32le().unwrap()); + if mm_start > 4 && mm_start + 0x2000 <= br.tell() { + let diff = (br.tell() - mm_start) & 3; + if diff != 0 { + mm_start -= 4 - diff; + } + end = Some(mm_start); + } + } + } (is_raw, start, end) } -- 2.39.5