Merge "Single track optimization" into gingerbread

This commit is contained in:
James Dong
2010-06-22 14:28:15 -07:00
committed by Android (Google) Code Review
2 changed files with 20 additions and 1 deletions

View File

@@ -81,6 +81,7 @@ private:
void setStartTimestampUs(int64_t timeUs);
int64_t getStartTimestampUs(); // Not const
status_t startTracks();
size_t numTracks();
void lock();
void unlock();

View File

@@ -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);