media: Save the last decode timestamp after all the timestamp adjustments.
Test: Keep taking pictures during video record for 5 mins.
Bug: 33882616
Change-Id: I2865a4842448ab9463391b983051cba243ea1ed6
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index ef288da..954014c 100755
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -2725,9 +2725,11 @@
if (mLastDecodingTimeUs < 0) {
decodingTimeUs = std::max((int64_t)0, decodingTimeUs);
} else {
- // increase decoding time by at least 1 tick
- decodingTimeUs = std::max(
- mLastDecodingTimeUs + divUp(1000000, mTimeScale), decodingTimeUs);
+ // increase decoding time by at least the larger vaule of 1 tick and
+ // 0.1 milliseconds. This needs to take into account the possible
+ // delta adjustment in DurationTicks in below.
+ decodingTimeUs = std::max(mLastDecodingTimeUs +
+ std::max(100, divUp(1000000, mTimeScale)), decodingTimeUs);
}
mLastDecodingTimeUs = decodingTimeUs;