Skip to content

Commit

Permalink
handle meta atom as a full box when parsing mp4
Browse files Browse the repository at this point in the history
Issues: #5698, #5694
PiperOrigin-RevId: 241762106
  • Loading branch information
marcbaechinger authored and ojw28 committed Apr 5, 2019
1 parent 95f65e5 commit b10f402
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
* Use full BCP 47 language tags in `Format`.
* Take byte offset into account when unsynchronizing an id3 frame
([#5673](https://github.com/google/ExoPlayer/issues/5673)).
* Handle meta atom as a full box when parsing mp4
([#5698](https://github.com/google/ExoPlayer/issues/5698),
[#5694](https://github.com/google/ExoPlayer/issues/5694)).

### 2.9.6 ###

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ private boolean readAtomHeader(ExtractorInput input) throws IOException, Interru
if (atomSize == atomHeaderBytesRead) {
processAtomEnded(endPosition);
} else {
if (atomType == Atom.TYPE_meta) {
maybeSkipRemainingMetaAtomHeaderBytes(input);
}
// Start reading the first child atom.
enterReadingAtomHeaderState();
}
Expand Down Expand Up @@ -643,6 +646,32 @@ private void updateSampleIndices(long timeUs) {
}
}

/**
* Possibly skips the version and flags fields (1+3 byte) of a full meta atom of the {@code
* input}.
*
* <p>Atoms of type {@link Atom#TYPE_meta} are defined to be full atoms which have four additional
* bytes for a version and a flags field (see 4.2 'Object Structure' in ISO/IEC 14496-12:2005).
* QuickTime do not have such a full box structure. Since some of these files are encoded wrongly,
* we can't rely on the file type though. Instead we must check the 8 bytes after the common
* header bytes ourselves.
*/
private void maybeSkipRemainingMetaAtomHeaderBytes(ExtractorInput input)
throws IOException, InterruptedException {
scratch.reset(8);
// Peek the next 8 bytes which can be either
// (iso) [1 byte version + 3 bytes flags][4 byte size of next atom]
// (qt) [4 byte size of next atom ][4 byte hdlr atom type ]
// In case of (iso) we need to skip the next 4 bytes.
input.peekFully(scratch.data, 0, 8);
scratch.skipBytes(4);
if (scratch.readInt() == Atom.TYPE_hdlr) {
input.resetPeekPosition();
} else {
input.skipFully(4);
}
}

/**
* For each sample of each track, calculates accumulated size of all samples which need to be read
* before this sample can be used.
Expand Down

0 comments on commit b10f402

Please sign in to comment.