From 0d9dc164b091428c4d23637c4996c430bbc09f2c Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Fri, 24 Feb 2023 18:25:02 +0100 Subject: [PATCH] realmedia: parse the original RealAudio files with even shorter v3 header --- nihav-realmedia/src/demuxers/realmedia.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/nihav-realmedia/src/demuxers/realmedia.rs b/nihav-realmedia/src/demuxers/realmedia.rs index 45c117a..14183c9 100644 --- a/nihav-realmedia/src/demuxers/realmedia.rs +++ b/nihav-realmedia/src/demuxers/realmedia.rs @@ -846,10 +846,15 @@ fn parse_aformat3(src: &mut ByteReader) -> DemuxerResult { skip_ra_metadata(src)?; - let _can_copy = src.read_byte()?; - let fcc_len = src.read_byte()?; - validate!(fcc_len == 4); - let fcc = src.read_u32be()?; + // the original RealAudio has no such fields + let fcc = if src.tell() != start + u64::from(header_len) + 2 { + let _can_copy = src.read_byte()?; + let fcc_len = src.read_byte()?; + validate!(fcc_len == 0 || fcc_len == 4); + src.read_u32be()? + } else { + read_u32be(b"lpcJ")? + }; let end = src.tell(); validate!(end - start <= (header_len as u64) + 2); -- 2.39.5