summaryrefslogtreecommitdiffstats
path: root/media/libstagefright
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2011-08-10 11:47:38 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-08-10 11:47:38 -0700
commitd1fe10cdb5d5a6eadc931d17cfda00cf753bc4dc (patch)
treed8d2f0d4025877d6adede84072b4d877e7b2baa7 /media/libstagefright
parentbdbe6939ff336d97f707c7d85be2eca114d3f6a0 (diff)
parent2c8e8508d26c8be816e3cbc2d0d90471ea78c811 (diff)
downloadframeworks_base-d1fe10cdb5d5a6eadc931d17cfda00cf753bc4dc.zip
frameworks_base-d1fe10cdb5d5a6eadc931d17cfda00cf753bc4dc.tar.gz
frameworks_base-d1fe10cdb5d5a6eadc931d17cfda00cf753bc4dc.tar.bz2
Merge "Fix initial 0 duration video sample in the recorded videos"
Diffstat (limited to 'media/libstagefright')
-rwxr-xr-xmedia/libstagefright/MPEG4Writer.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index 8c9ff87..5f58090 100755
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -1172,6 +1172,9 @@ void MPEG4Writer::Track::addOneStssTableEntry(size_t sampleId) {
void MPEG4Writer::Track::addOneSttsTableEntry(
size_t sampleCount, int32_t duration) {
+ if (duration == 0) {
+ LOGW("%d 0-duration samples found: %d", sampleCount);
+ }
SttsTableEntry sttsEntry(sampleCount, duration);
mSttsTableEntries.push_back(sttsEntry);
++mNumSttsTableEntries;
@@ -2001,17 +2004,18 @@ status_t MPEG4Writer::Track::threadEntry() {
mTrackDurationUs = timestampUs;
}
+ // We need to use the time scale based ticks, rather than the
+ // timestamp itself to determine whether we have to use a new
+ // stts entry, since we may have rounding errors.
+ // The calculation is intended to reduce the accumulated
+ // rounding errors.
+ currDurationTicks =
+ ((timestampUs * mTimeScale + 500000LL) / 1000000LL -
+ (lastTimestampUs * mTimeScale + 500000LL) / 1000000LL);
+
mSampleSizes.push_back(sampleSize);
++mNumSamples;
if (mNumSamples > 2) {
- // We need to use the time scale based ticks, rather than the
- // timestamp itself to determine whether we have to use a new
- // stts entry, since we may have rounding errors.
- // The calculation is intended to reduce the accumulated
- // rounding errors.
- currDurationTicks =
- ((timestampUs * mTimeScale + 500000LL) / 1000000LL -
- (lastTimestampUs * mTimeScale + 500000LL) / 1000000LL);
// Force the first sample to have its own stts entry so that
// we can adjust its value later to maintain the A/V sync.