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
This commit is contained in:
Solomon Peachy 2021-02-16 06:54:32 -05:00
parent 8c76c1b1c2
commit bdc3dd4fca

View file

@ -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;