From bdc3dd4fca4aa628b934e7a0bc5d9d5955cdc2cd Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Tue, 16 Feb 2021 06:54:32 -0500 Subject: MP4: append mdat sections together in metadata parser mp4 files can have multiple 'mdat' chunks. This is common for audiobooks, where there is often a secondary mdat containing the chapter names, but it's also legal to have multiple mdat chunks for a single logical "track" This confuses the mp4 metadata parser, which assumes there is only a single mdat, and always uses the last mdat seen to determine the "filesize" of the data we're trying to decode. Work around this by appending each mdat's size to result in the final "filesize" Change-Id: I3e7a7efb0f05ef965e8d77f79e450c957524a480 --- lib/rbcodec/metadata/mp4.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/rbcodec/metadata/mp4.c b/lib/rbcodec/metadata/mp4.c index 6973d3a314..35f4e3bfda 100644 --- a/lib/rbcodec/metadata/mp4.c +++ b/lib/rbcodec/metadata/mp4.c @@ -758,7 +758,8 @@ static bool read_mp4_container(int fd, struct mp3entry* id3, Ignore them. */ if(size == 0) break; - id3->filesize = size; + /* mdat chunks accumulate! */ + id3->filesize += size; if(id3->samples > 0) { /* We've already seen the moov chunk. */ done = true; -- cgit v1.2.3