From 05e80b4c1c52a6dc1f305e26ce67162256d6bcc5 Mon Sep 17 00:00:00 2001
From: James Dong <jdong@google.com>
Date: Tue, 24 Aug 2010 12:28:02 -0700
Subject: Make sure that timestamp does not go backward in MP4 file writer

Change-Id: I90745b9df7f19d61f3ab826bf9d2419fe788554e
---
 media/libstagefright/MPEG4Writer.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'media/libstagefright')

diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index e36d9fe..a15b84e 100644
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -1569,9 +1569,9 @@ status_t MPEG4Writer::Track::threadEntry() {
                 // The idea here is to avoid having two or more samples with the
                 // same timestamp in the output file.
                 if (mTimeScale >= 1000000LL) {
-                    timestampUs += 1;
+                    timestampUs = lastTimestampUs + 1;
                 } else {
-                    timestampUs += (1000000LL + (mTimeScale >> 1)) / mTimeScale;
+                    timestampUs = lastTimestampUs + (1000000LL + (mTimeScale >> 1)) / mTimeScale;
                 }
 #endif
             }
-- 
cgit v1.1