Fix thumbnail track skipping
Thumbnail tracks are identified by 'tref' box with a 'thmb'
type reference in it. We can't skip a track as soon as a 'tref'
box appears, need to actually parse it and look for 'thmb'.
bug: 77556099
Test: playback of audio files in bug, playback of image sequence
file (bird_burst.heic) with thumbnail reference.
Change-Id: I7d6ec8af218de2f0cba258f8eaaac9b62f9cb020
diff --git a/media/extractors/mp4/MPEG4Extractor.cpp b/media/extractors/mp4/MPEG4Extractor.cpp
index 07ef0e3..99f32d5 100644
--- a/media/extractors/mp4/MPEG4Extractor.cpp
+++ b/media/extractors/mp4/MPEG4Extractor.cpp
@@ -1123,19 +1123,33 @@
case FOURCC('t', 'r', 'e', 'f'):
{
- *offset += chunk_size;
-
- if (mLastTrack == NULL) {
+ off64_t stop_offset = *offset + chunk_size;
+ *offset = data_offset;
+ while (*offset < stop_offset) {
+ status_t err = parseChunk(offset, depth + 1);
+ if (err != OK) {
+ return err;
+ }
+ }
+ if (*offset != stop_offset) {
return ERROR_MALFORMED;
}
+ break;
+ }
- // Skip thumbnail track for now since we don't have an
- // API to retrieve it yet.
- // The thumbnail track can't be accessed by negative index or time,
- // because each timed sample has its own corresponding thumbnail
- // in the thumbnail track. We'll need a dedicated API to retrieve
- // thumbnail at time instead.
- mLastTrack->skipTrack = true;
+ case FOURCC('t', 'h', 'm', 'b'):
+ {
+ *offset += chunk_size;
+
+ if (mLastTrack != NULL) {
+ // Skip thumbnail track for now since we don't have an
+ // API to retrieve it yet.
+ // The thumbnail track can't be accessed by negative index or time,
+ // because each timed sample has its own corresponding thumbnail
+ // in the thumbnail track. We'll need a dedicated API to retrieve
+ // thumbnail at time instead.
+ mLastTrack->skipTrack = true;
+ }
break;
}
@@ -2353,7 +2367,9 @@
// This means that the file should have moov box.
// It could be any iso files (mp4, heifs, etc.)
mHasMoovBox = true;
- ALOGV("identified HEIF image with other tracks");
+ if (mIsHeif) {
+ ALOGV("identified HEIF image with other tracks");
+ }
}
}