summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/MPEG4Writer.cpp
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2010-06-22 11:27:37 -0700
committerJames Dong <jdong@google.com>2010-06-22 11:27:37 -0700
commit58ae9c530247668f8af36e30d228c716c226b3d4 (patch)
tree797e765affac5a32c0a4a431d22afdfcd194eba1 /media/libstagefright/MPEG4Writer.cpp
parent40f388ef8bad7a9ab16db8f90904656cd39c793d (diff)
downloadframeworks_av-58ae9c530247668f8af36e30d228c716c226b3d4.zip
frameworks_av-58ae9c530247668f8af36e30d228c716c226b3d4.tar.gz
frameworks_av-58ae9c530247668f8af36e30d228c716c226b3d4.tar.bz2
Single track optimization
We don't need to do interleave when the total number of tracks to be recorded is one. Metadata-wise, we only need to have one chunk in chunk offset table, and a single entry in the stsc table. Change-Id: I46f0e4b3860620311e7a91b68a9067acaa137bb2
Diffstat (limited to 'media/libstagefright/MPEG4Writer.cpp')
-rw-r--r--media/libstagefright/MPEG4Writer.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index b6bbde7..cd20ec7 100644
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -559,6 +559,11 @@ int64_t MPEG4Writer::getStartTimestampUs() {
return mStartTimestampUs;
}
+size_t MPEG4Writer::numTracks() {
+ Mutex::Autolock autolock(mLock);
+ return mTracks.size();
+}
+
////////////////////////////////////////////////////////////////////////////////
MPEG4Writer::Track::Track(
@@ -979,6 +984,16 @@ void MPEG4Writer::Track::threadEntry() {
mStssTableEntries.push_back(mSampleInfos.size());
}
+ if (mOwner->numTracks() == 1) {
+ off_t offset = is_avc? mOwner->addLengthPrefixedSample_l(copy)
+ : mOwner->addSample_l(copy);
+ if (mChunkOffsets.empty()) {
+ mChunkOffsets.push_back(offset);
+ }
+ copy->release();
+ copy = NULL;
+ continue;
+ }
mChunkSamples.push_back(copy);
if (interleaveDurationUs == 0) {
@@ -1012,7 +1027,10 @@ void MPEG4Writer::Track::threadEntry() {
}
// Last chunk
- if (!mChunkSamples.empty()) {
+ if (mOwner->numTracks() == 1) {
+ StscTableEntry stscEntry(1, mSampleInfos.size(), 1);
+ mStscTableEntries.push_back(stscEntry);
+ } else if (!mChunkSamples.empty()) {
++nChunks;
StscTableEntry stscEntry(nChunks, mChunkSamples.size(), 1);
mStscTableEntries.push_back(stscEntry);