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

Commit e0c4cfee authored by Marco Nelissen's avatar Marco Nelissen Committed by Android (Google) Code Review
Browse files

Merge "Determine frame rate from trex box if stsz box is empty" into nyc-dev

parents 823b18ef 949d857e
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;