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

Commit e4f2656f authored by xiahong.bao's avatar xiahong.bao Committed by android-build-merger
Browse files

Merge "MPEG4Write mdhd duration overflow after recording for 15 hours" am:...

Merge "MPEG4Write mdhd duration overflow after recording for 15 hours" am: 98d1217d am: 6afe508b
am: 3e383dc9

Change-Id: Ib3552a36d555021bd0ab2f1e68b588efc7f30213
parents cb09e630 3e383dc9
Loading
Loading
Loading
Loading
+15 −6
Original line number Original line Diff line number Diff line
@@ -3288,13 +3288,22 @@ void MPEG4Writer::Track::writeHdlrBox() {


void MPEG4Writer::Track::writeMdhdBox(uint32_t now) {
void MPEG4Writer::Track::writeMdhdBox(uint32_t now) {
    int64_t trakDurationUs = getDurationUs();
    int64_t trakDurationUs = getDurationUs();
    int64_t mdhdDuration = (trakDurationUs * mTimeScale + 5E5) / 1E6;
    mOwner->beginBox("mdhd");
    mOwner->beginBox("mdhd");

    if (mdhdDuration > UINT32_MAX) {
        mOwner->writeInt32((1 << 24));            // version=1, flags=0
        mOwner->writeInt64((int64_t)now);         // creation time
        mOwner->writeInt64((int64_t)now);         // modification time
        mOwner->writeInt32(mTimeScale);           // media timescale
        mOwner->writeInt64(mdhdDuration);         // media timescale
    } else {
        mOwner->writeInt32(0);                      // version=0, flags=0
        mOwner->writeInt32(0);                      // version=0, flags=0
        mOwner->writeInt32(now);                    // creation time
        mOwner->writeInt32(now);                    // creation time
        mOwner->writeInt32(now);                    // modification time
        mOwner->writeInt32(now);                    // modification time
        mOwner->writeInt32(mTimeScale);             // media timescale
        mOwner->writeInt32(mTimeScale);             // media timescale
    int32_t mdhdDuration = (trakDurationUs * mTimeScale + 5E5) / 1E6;
        mOwner->writeInt32((int32_t)mdhdDuration);  // use media timescale
    mOwner->writeInt32(mdhdDuration);  // use media timescale
    }
    // Language follows the three letter standard ISO-639-2/T
    // Language follows the three letter standard ISO-639-2/T
    // 'e', 'n', 'g' for "English", for instance.
    // 'e', 'n', 'g' for "English", for instance.
    // Each character is packed as the difference between its ASCII value and 0x60.
    // Each character is packed as the difference between its ASCII value and 0x60.