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

Commit 3540760d authored by James Dong's avatar James Dong Committed by Android Git Automerger
Browse files

am 0ea4ed3b: Don\'t drop a late frame which may lead to missing I frames in the MP4 file

Merge commit '0ea4ed3b' into gingerbread-plus-aosp

* commit '0ea4ed3b':
  Don't drop a late frame which may lead to missing I frames in the MP4 file
parents 177a7ad8 0ea4ed3b
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -1524,10 +1524,24 @@ status_t MPEG4Writer::Track::threadEntry() {
        CHECK(timestampUs >= 0);
        if (mNumSamples > 1) {
            if (timestampUs <= lastTimestampUs) {
                LOGW("Drop a frame, since it arrives too late!");
                LOGW("Frame arrives too late!");
#if 0
                // Drop the late frame.
                copy->release();
                copy = NULL;
                continue;
#else
                // Don't drop the late frame, since dropping a frame may cause
                // problems later during playback

                // The idea here is to avoid having two or more samples with the
                // same timestamp in the output file.
                if (mTimeScale >= 1000000LL) {
                    timestampUs += 1;
                } else {
                    timestampUs += (1000000LL + (mTimeScale >> 1)) / mTimeScale;
                }
#endif
            }
        }