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

Commit 949d857e authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Determine frame rate from trex box if stsz box is empty

Bug: 28591845
Change-Id: I7deaa78815c5b1a3f8dac8604f0f236c6a4dc0c5
parent 0277976e
Loading
Loading
Loading
Loading
+24 −7
Original line number Diff line number Diff line
@@ -1560,6 +1560,22 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
            // Calculate average frame rate.
            if (!strncasecmp("video/", mime, 6)) {
                size_t nSamples = mLastTrack->sampleTable->countSamples();
                if (nSamples == 0) {
                    int32_t trackId;
                    if (mLastTrack->meta->findInt32(kKeyTrackID, &trackId)) {
                        for (size_t i = 0; i < mTrex.size(); i++) {
                            Trex *t = &mTrex.editItemAt(i);
                            if (t->track_ID == (uint32_t) trackId) {
                                if (t->default_sample_duration > 0) {
                                    int32_t frameRate =
                                            mLastTrack->timescale / t->default_sample_duration;
                                    mLastTrack->meta->setInt32(kKeyFrameRate, frameRate);
                                }
                                break;
                            }
                        }
                    }
                } else {
                    int64_t durationUs;
                    if (mLastTrack->meta->findInt64(kKeyDuration, &durationUs)) {
                        if (durationUs > 0) {
@@ -1569,6 +1585,7 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
                        }
                    }
                }
            }

            break;
        }
@@ -2929,7 +2946,7 @@ sp<IMediaSource> MPEG4Extractor::getTrack(size_t index) {
    int32_t trackId;
    if (track->meta->findInt32(kKeyTrackID, &trackId)) {
        for (size_t i = 0; i < mTrex.size(); i++) {
            Trex *t = &mTrex.editItemAt(index);
            Trex *t = &mTrex.editItemAt(i);
            if (t->track_ID == (uint32_t) trackId) {
                trex = t;
                break;