diff options
author | Pawit Pornkitprasan <p.pawit@gmail.com> | 2012-06-25 13:31:37 +0400 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.cyanogenmod.com> | 2012-06-25 13:31:37 +0400 |
commit | 9749c35e5710a023abbe9b6e867b839073bc0c06 (patch) | |
tree | f26d90cbc4fbf119feb81eb0c14488750983fd02 /media | |
parent | 893586d4b7a0dbea070404323837ef4f0a7c9b79 (diff) | |
download | frameworks_base-9749c35e5710a023abbe9b6e867b839073bc0c06.zip frameworks_base-9749c35e5710a023abbe9b6e867b839073bc0c06.tar.gz frameworks_base-9749c35e5710a023abbe9b6e867b839073bc0c06.tar.bz2 |
Revert "libstagefright: Fix MPEG4 timestamp"
A lot of applications (e.g. QuickTime, mkvmerge) apparently does not like the 64-bit timestamp and will fail to open the file.
This reverts commit 893586d4b7a0dbea070404323837ef4f0a7c9b79
Diffstat (limited to 'media')
-rwxr-xr-x | media/libstagefright/MPEG4Writer.cpp | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp index e8b8b44..b4c0524 100755 --- a/media/libstagefright/MPEG4Writer.cpp +++ b/media/libstagefright/MPEG4Writer.cpp @@ -47,9 +47,6 @@ static const uint8_t kNalUnitTypeSeqParamSet = 0x07; static const uint8_t kNalUnitTypePicParamSet = 0x08; static const int64_t kInitialDelayTimeUs = 700000LL; -// MPEG4 uses Jan 1, 1904 as epoch, not unix epoch -static const int64_t kTimestampConversion = 2082844800LL; - class MPEG4Writer::Track { public: Track(MPEG4Writer *owner, const sp<MediaSource> &source, size_t trackId); @@ -226,11 +223,11 @@ private: void writeDrefBox(); void writeDinfBox(); void writeDamrBox(); - void writeMdhdBox(int64_t now); + void writeMdhdBox(time_t now); void writeSmhdBox(); void writeVmhdBox(); void writeHdlrBox(); - void writeTkhdBox(int64_t now); + void writeTkhdBox(time_t now); void writeMp4aEsdsBox(); void writeMp4vEsdsBox(); void writeAudioFourCCBox(); @@ -714,14 +711,14 @@ status_t MPEG4Writer::stop() { } void MPEG4Writer::writeMvhdBox(int64_t durationUs) { - int64_t now = time(NULL) + kTimestampConversion; + time_t now = time(NULL); beginBox("mvhd"); - writeInt32(0x01000000); // version=1, flags=0 - writeInt64(now); // creation time - writeInt64(now); // modification time + writeInt32(0); // version=0, flags=0 + writeInt32(now); // creation time + writeInt32(now); // modification time writeInt32(mTimeScale); // mvhd timescale int32_t duration = (durationUs * mTimeScale + 5E5) / 1E6; - writeInt64(duration); + writeInt32(duration); writeInt32(0x10000); // rate: 1.0 writeInt16(0x100); // volume writeInt16(0); // reserved @@ -2366,7 +2363,7 @@ void MPEG4Writer::Track::writeTrackHeader(bool use32BitOffset) { LOGV("%s track time scale: %d", mIsAudio? "Audio": "Video", mTimeScale); - int64_t now = time(NULL) + kTimestampConversion; + time_t now = time(NULL); mOwner->beginBox("trak"); writeTkhdBox(now); mOwner->beginBox("mdia"); @@ -2579,20 +2576,20 @@ void MPEG4Writer::Track::writeMp4vEsdsBox() { mOwner->endBox(); // esds } -void MPEG4Writer::Track::writeTkhdBox(int64_t now) { +void MPEG4Writer::Track::writeTkhdBox(time_t now) { mOwner->beginBox("tkhd"); // Flags = 7 to indicate that the track is enabled, and // part of the presentation - mOwner->writeInt32(0x01000007); // version=1, flags=7 - mOwner->writeInt64(now); // creation time - mOwner->writeInt64(now); // modification time + mOwner->writeInt32(0x07); // version=0, flags=7 + mOwner->writeInt32(now); // creation time + mOwner->writeInt32(now); // modification time mOwner->writeInt32(mTrackId + 1); // track id starts with 1 mOwner->writeInt32(0); // reserved int64_t trakDurationUs = getDurationUs(); int32_t mvhdTimeScale = mOwner->getTimeScale(); int32_t tkhdDuration = (trakDurationUs * mvhdTimeScale + 5E5) / 1E6; - mOwner->writeInt64(tkhdDuration); // in mvhd timescale + mOwner->writeInt32(tkhdDuration); // in mvhd timescale mOwner->writeInt32(0); // reserved mOwner->writeInt32(0); // reserved mOwner->writeInt16(0); // layer @@ -2648,15 +2645,15 @@ void MPEG4Writer::Track::writeHdlrBox() { mOwner->endBox(); } -void MPEG4Writer::Track::writeMdhdBox(int64_t now) { +void MPEG4Writer::Track::writeMdhdBox(time_t now) { int64_t trakDurationUs = getDurationUs(); mOwner->beginBox("mdhd"); - mOwner->writeInt32(0x01000000); // version=1, flags=0 - mOwner->writeInt64(now); // creation time - mOwner->writeInt64(now); // modification time + mOwner->writeInt32(0); // version=0, flags=0 + mOwner->writeInt32(now); // creation time + mOwner->writeInt32(now); // modification time mOwner->writeInt32(mTimeScale); // media timescale int32_t mdhdDuration = (trakDurationUs * mTimeScale + 5E5) / 1E6; - mOwner->writeInt64(mdhdDuration); // use media timescale + mOwner->writeInt32(mdhdDuration); // use media timescale // Language follows the three letter standard ISO-639-2/T // 'e', 'n', 'g' for "English", for instance. // Each character is packed as the difference between its ASCII value and 0x60. |