diff options
author | James Dong <jdong@google.com> | 2010-08-19 10:52:39 -0700 |
---|---|---|
committer | James Dong <jdong@google.com> | 2010-08-19 18:04:27 -0700 |
commit | 4f86a980fee1880dca61b828599fa6d76755a485 (patch) | |
tree | 735b8bd0e66173dc90abf256fa68aeef1b60ee22 /media/libstagefright/MPEG4Writer.cpp | |
parent | 690f546b0ee548dbfe997df36418e5302ec2d786 (diff) | |
download | frameworks_av-4f86a980fee1880dca61b828599fa6d76755a485.zip frameworks_av-4f86a980fee1880dca61b828599fa6d76755a485.tar.gz frameworks_av-4f86a980fee1880dca61b828599fa6d76755a485.tar.bz2 |
Don't drop a late frame which may lead to missing I frames in the MP4 file
Change-Id: I8fef1454264230c1369561670236eb0a19ae4e76
Diffstat (limited to 'media/libstagefright/MPEG4Writer.cpp')
-rw-r--r-- | media/libstagefright/MPEG4Writer.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp index 0d0a998..568037e 100644 --- a/media/libstagefright/MPEG4Writer.cpp +++ b/media/libstagefright/MPEG4Writer.cpp @@ -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 } } |