Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15033bd2 authored by Chong Zhang's avatar Chong Zhang
Browse files

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
parent fcf9a4c7
Loading
Loading
Loading
Loading
+27 −11
Original line number Diff line number Diff line
@@ -1123,12 +1123,25 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {

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

        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,
@@ -1136,6 +1149,7 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
                // in the thumbnail track. We'll need a dedicated API to retrieve
                // thumbnail at time instead.
                mLastTrack->skipTrack = true;
            }

            break;
        }
@@ -2353,9 +2367,11 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
                    // This means that the file should have moov box.
                    // It could be any iso files (mp4, heifs, etc.)
                    mHasMoovBox = true;
                    if (mIsHeif) {
                        ALOGV("identified HEIF image with other tracks");
                    }
                }
            }

            *offset = stop_offset;