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

Commit f6c1083b authored by Leena Winterrowd's avatar Leena Winterrowd Committed by Steve Kondik
Browse files

stagefright: Correct total duration of HFR clips

HFR leverages the mp4 track timescale parameter which is not
considered when calculating total clip duration. This makes tracks
report the correct duration so that total clip duration is computed
correctly.

Change-Id: I8ff556913317eea15030f9f6920cefa560133872
parent 3dfbe3ae
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1404,6 +1404,8 @@ MPEG4Writer::Track::Track(
      mReachedEOS(false),
      mRotation(0),
      mHFRRatio(1) {
    getCodecSpecificDataFromInputFormatIfPossible();

    const char *mime;
    mMeta->findCString(kKeyMIMEType, &mime);

@@ -2677,7 +2679,7 @@ void MPEG4Writer::Track::bufferChunk(int64_t timestampUs) {
}

int64_t MPEG4Writer::Track::getDurationUs() const {
    return mTrackDurationUs;
    return mTrackDurationUs * mHFRRatio;
}

int64_t MPEG4Writer::Track::getEstimatedTrackSizeBytes() const {
@@ -3020,7 +3022,7 @@ void MPEG4Writer::Track::writeMdhdBox(uint32_t now) {

    int32_t timeScale = mTimeScale / mHFRRatio;
    mOwner->writeInt32(timeScale);    // media timescale
    int32_t mdhdDuration = (trakDurationUs * mTimeScale + 5E5) / 1E6;
    int32_t mdhdDuration = (trakDurationUs * timeScale + 5E5) / 1E6;
    mOwner->writeInt32(mdhdDuration);  // use media timescale
    // Language follows the three letter standard ISO-639-2/T
    // 'e', 'n', 'g' for "English", for instance.