Loading media/libstagefright/SampleTable.cpp +126 −23 Original line number Original line Diff line number Diff line Loading @@ -123,7 +123,7 @@ SampleTable::SampleTable(const sp<DataSource> &source) mNumSampleSizes(0), mNumSampleSizes(0), mHasTimeToSample(false), mHasTimeToSample(false), mTimeToSampleCount(0), mTimeToSampleCount(0), mTimeToSample(), mTimeToSample(NULL), mSampleTimeEntries(NULL), mSampleTimeEntries(NULL), mCompositionTimeDeltaEntries(NULL), mCompositionTimeDeltaEntries(NULL), mNumCompositionTimeDeltaEntries(0), mNumCompositionTimeDeltaEntries(0), Loading @@ -132,7 +132,8 @@ SampleTable::SampleTable(const sp<DataSource> &source) mNumSyncSamples(0), mNumSyncSamples(0), mSyncSamples(NULL), mSyncSamples(NULL), mLastSyncSampleIndex(0), mLastSyncSampleIndex(0), mSampleToChunkEntries(NULL) { mSampleToChunkEntries(NULL), mTotalSize(0) { mSampleIterator = new SampleIterator(this); mSampleIterator = new SampleIterator(this); } } Loading @@ -143,6 +144,9 @@ SampleTable::~SampleTable() { delete[] mSyncSamples; delete[] mSyncSamples; mSyncSamples = NULL; mSyncSamples = NULL; delete[] mTimeToSample; mTimeToSample = NULL; delete mCompositionDeltaLookup; delete mCompositionDeltaLookup; mCompositionDeltaLookup = NULL; mCompositionDeltaLookup = NULL; Loading Loading @@ -233,13 +237,43 @@ status_t SampleTable::setSampleToChunkParams( return ERROR_MALFORMED; return ERROR_MALFORMED; } } if (SIZE_MAX / sizeof(SampleToChunkEntry) <= (size_t)mNumSampleToChunkOffsets) if ((uint64_t)SIZE_MAX / sizeof(SampleToChunkEntry) <= (uint64_t)mNumSampleToChunkOffsets) { ALOGE("Sample-to-chunk table size too large."); return ERROR_OUT_OF_RANGE; return ERROR_OUT_OF_RANGE; } mTotalSize += (uint64_t)mNumSampleToChunkOffsets * sizeof(SampleToChunkEntry); if (mTotalSize > kMaxTotalSize) { ALOGE("Sample-to-chunk table size would make sample table too large.\n" " Requested sample-to-chunk table size = %llu\n" " Eventual sample table size >= %llu\n" " Allowed sample table size = %llu\n", (unsigned long long)mNumSampleToChunkOffsets * sizeof(SampleToChunkEntry), (unsigned long long)mTotalSize, (unsigned long long)kMaxTotalSize); return ERROR_OUT_OF_RANGE; } mSampleToChunkEntries = mSampleToChunkEntries = new (std::nothrow) SampleToChunkEntry[mNumSampleToChunkOffsets]; new (std::nothrow) SampleToChunkEntry[mNumSampleToChunkOffsets]; if (!mSampleToChunkEntries) if (!mSampleToChunkEntries) { ALOGE("Cannot allocate sample-to-chunk table with %llu entries.", (unsigned long long)mNumSampleToChunkOffsets); return ERROR_OUT_OF_RANGE; return ERROR_OUT_OF_RANGE; } if (mNumSampleToChunkOffsets == 0) { return OK; } if ((off64_t)(SIZE_MAX - 8 - ((mNumSampleToChunkOffsets - 1) * sizeof(SampleToChunkEntry))) < mSampleToChunkOffset) { return ERROR_MALFORMED; } for (uint32_t i = 0; i < mNumSampleToChunkOffsets; ++i) { for (uint32_t i = 0; i < mNumSampleToChunkOffsets; ++i) { uint8_t buffer[12]; uint8_t buffer[12]; Loading @@ -248,8 +282,11 @@ status_t SampleTable::setSampleToChunkParams( != (ssize_t)sizeof(buffer)) { != (ssize_t)sizeof(buffer)) { return ERROR_IO; return ERROR_IO; } } // chunk index is 1 based in the spec. CHECK(U32_AT(buffer) >= 1); // chunk index is 1 based in the spec. if (U32_AT(buffer) < 1) { ALOGE("b/23534160"); return ERROR_OUT_OF_RANGE; } // We want the chunk index to be 0-based. // We want the chunk index to be 0-based. mSampleToChunkEntries[i].startChunk = U32_AT(buffer) - 1; mSampleToChunkEntries[i].startChunk = U32_AT(buffer) - 1; Loading Loading @@ -350,20 +387,41 @@ status_t SampleTable::setTimeToSampleParams( // 2) mTimeToSampleCount is the number of entries of the time-to-sample // 2) mTimeToSampleCount is the number of entries of the time-to-sample // table. // table. // 3) We hope that the table size does not exceed UINT32_MAX. // 3) We hope that the table size does not exceed UINT32_MAX. ALOGE(" Error: Time-to-sample table size too large."); ALOGE("Time-to-sample table size too large."); return ERROR_OUT_OF_RANGE; return ERROR_OUT_OF_RANGE; } } // Note: At this point, we know that mTimeToSampleCount * 2 will not // Note: At this point, we know that mTimeToSampleCount * 2 will not // overflow because of the above condition. // overflow because of the above condition. if (!mDataSource->getVector(data_offset + 8, &mTimeToSample, mTimeToSampleCount * 2)) { uint64_t allocSize = (uint64_t)mTimeToSampleCount * 2 * sizeof(uint32_t); ALOGE(" Error: Incomplete data read for time-to-sample table."); mTotalSize += allocSize; if (mTotalSize > kMaxTotalSize) { ALOGE("Time-to-sample table size would make sample table too large.\n" " Requested time-to-sample table size = %llu\n" " Eventual sample table size >= %llu\n" " Allowed sample table size = %llu\n", (unsigned long long)allocSize, (unsigned long long)mTotalSize, (unsigned long long)kMaxTotalSize); return ERROR_OUT_OF_RANGE; } mTimeToSample = new (std::nothrow) uint32_t[mTimeToSampleCount * 2]; if (!mTimeToSample) { ALOGE("Cannot allocate time-to-sample table with %llu entries.", (unsigned long long)mTimeToSampleCount); return ERROR_OUT_OF_RANGE; } if (mDataSource->readAt(data_offset + 8, mTimeToSample, (size_t)allocSize) < (ssize_t)allocSize) { ALOGE("Incomplete data read for time-to-sample table."); return ERROR_IO; return ERROR_IO; } } for (size_t i = 0; i < mTimeToSample.size(); ++i) { for (size_t i = 0; i < mTimeToSampleCount * 2; ++i) { mTimeToSample.editItemAt(i) = ntohl(mTimeToSample[i]); mTimeToSample[i] = ntohl(mTimeToSample[i]); } } mHasTimeToSample = true; mHasTimeToSample = true; Loading Loading @@ -398,17 +456,32 @@ status_t SampleTable::setCompositionTimeToSampleParams( mNumCompositionTimeDeltaEntries = numEntries; mNumCompositionTimeDeltaEntries = numEntries; uint64_t allocSize = (uint64_t)numEntries * 2 * sizeof(uint32_t); uint64_t allocSize = (uint64_t)numEntries * 2 * sizeof(uint32_t); if (allocSize > UINT32_MAX) { if (allocSize > SIZE_MAX) { ALOGE("Composition-time-to-sample table size too large."); return ERROR_OUT_OF_RANGE; } mTotalSize += allocSize; if (mTotalSize > kMaxTotalSize) { ALOGE("Composition-time-to-sample table would make sample table too large.\n" " Requested composition-time-to-sample table size = %llu\n" " Eventual sample table size >= %llu\n" " Allowed sample table size = %llu\n", (unsigned long long)allocSize, (unsigned long long)mTotalSize, (unsigned long long)kMaxTotalSize); return ERROR_OUT_OF_RANGE; return ERROR_OUT_OF_RANGE; } } mCompositionTimeDeltaEntries = new (std::nothrow) uint32_t[2 * numEntries]; mCompositionTimeDeltaEntries = new (std::nothrow) uint32_t[2 * numEntries]; if (!mCompositionTimeDeltaEntries) if (!mCompositionTimeDeltaEntries) { ALOGE("Cannot allocate composition-time-to-sample table with %llu " "entries.", (unsigned long long)numEntries); return ERROR_OUT_OF_RANGE; return ERROR_OUT_OF_RANGE; } if (mDataSource->readAt( if (mDataSource->readAt(data_offset + 8, mCompositionTimeDeltaEntries, data_offset + 8, mCompositionTimeDeltaEntries, numEntries * 8) (size_t)allocSize) < (ssize_t)allocSize) { < (ssize_t)numEntries * 8) { delete[] mCompositionTimeDeltaEntries; delete[] mCompositionTimeDeltaEntries; mCompositionTimeDeltaEntries = NULL; mCompositionTimeDeltaEntries = NULL; Loading Loading @@ -449,18 +522,33 @@ status_t SampleTable::setSyncSampleParams(off64_t data_offset, size_t data_size) ALOGV("Table of sync samples is empty or has only a single entry!"); ALOGV("Table of sync samples is empty or has only a single entry!"); } } uint64_t allocSize = mNumSyncSamples * (uint64_t)sizeof(uint32_t); uint64_t allocSize = (uint64_t)mNumSyncSamples * sizeof(uint32_t); if (allocSize > SIZE_MAX) { if (allocSize > SIZE_MAX) { ALOGE("Sync sample table size too large."); return ERROR_OUT_OF_RANGE; } mTotalSize += allocSize; if (mTotalSize > kMaxTotalSize) { ALOGE("Sync sample table size would make sample table too large.\n" " Requested sync sample table size = %llu\n" " Eventual sample table size >= %llu\n" " Allowed sample table size = %llu\n", (unsigned long long)allocSize, (unsigned long long)mTotalSize, (unsigned long long)kMaxTotalSize); return ERROR_OUT_OF_RANGE; return ERROR_OUT_OF_RANGE; } } mSyncSamples = new (std::nothrow) uint32_t[mNumSyncSamples]; mSyncSamples = new (std::nothrow) uint32_t[mNumSyncSamples]; if (!mSyncSamples) if (!mSyncSamples) { ALOGE("Cannot allocate sync sample table with %llu entries.", (unsigned long long)mNumSyncSamples); return ERROR_OUT_OF_RANGE; return ERROR_OUT_OF_RANGE; } size_t size = mNumSyncSamples * sizeof(uint32_t); if (mDataSource->readAt(mSyncSampleOffset + 8, mSyncSamples, if (mDataSource->readAt(mSyncSampleOffset + 8, mSyncSamples, size) (size_t)allocSize) != (ssize_t)allocSize) { != (ssize_t)size) { return ERROR_IO; return ERROR_IO; } } Loading Loading @@ -528,9 +616,24 @@ void SampleTable::buildSampleEntriesTable() { return; return; } } mTotalSize += (uint64_t)mNumSampleSizes * sizeof(SampleTimeEntry); if (mTotalSize > kMaxTotalSize) { ALOGE("Sample entry table size would make sample table too large.\n" " Requested sample entry table size = %llu\n" " Eventual sample table size >= %llu\n" " Allowed sample table size = %llu\n", (unsigned long long)mNumSampleSizes * sizeof(SampleTimeEntry), (unsigned long long)mTotalSize, (unsigned long long)kMaxTotalSize); return; } mSampleTimeEntries = new (std::nothrow) SampleTimeEntry[mNumSampleSizes]; mSampleTimeEntries = new (std::nothrow) SampleTimeEntry[mNumSampleSizes]; if (!mSampleTimeEntries) if (!mSampleTimeEntries) { ALOGE("Cannot allocate sample entry table with %llu entries.", (unsigned long long)mNumSampleSizes); return; return; } uint32_t sampleIndex = 0; uint32_t sampleIndex = 0; uint32_t sampleTime = 0; uint32_t sampleTime = 0; Loading media/libstagefright/include/SampleTable.h +7 −2 Original line number Original line Diff line number Diff line Loading @@ -24,7 +24,6 @@ #include <media/stagefright/MediaErrors.h> #include <media/stagefright/MediaErrors.h> #include <utils/RefBase.h> #include <utils/RefBase.h> #include <utils/threads.h> #include <utils/threads.h> #include <utils/Vector.h> namespace android { namespace android { Loading Loading @@ -96,6 +95,9 @@ private: static const uint32_t kSampleSizeType32; static const uint32_t kSampleSizeType32; static const uint32_t kSampleSizeTypeCompact; static const uint32_t kSampleSizeTypeCompact; // Limit the total size of all internal tables to 200MiB. static const size_t kMaxTotalSize = 200 * (1 << 20); sp<DataSource> mDataSource; sp<DataSource> mDataSource; Mutex mLock; Mutex mLock; Loading @@ -113,7 +115,7 @@ private: bool mHasTimeToSample; bool mHasTimeToSample; uint32_t mTimeToSampleCount; uint32_t mTimeToSampleCount; Vector<uint32_t> mTimeToSample; uint32_t* mTimeToSample; struct SampleTimeEntry { struct SampleTimeEntry { uint32_t mSampleIndex; uint32_t mSampleIndex; Loading @@ -139,6 +141,9 @@ private: }; }; SampleToChunkEntry *mSampleToChunkEntries; SampleToChunkEntry *mSampleToChunkEntries; // Approximate size of all tables combined. uint64_t mTotalSize; friend struct SampleIterator; friend struct SampleIterator; // normally we don't round // normally we don't round Loading Loading
media/libstagefright/SampleTable.cpp +126 −23 Original line number Original line Diff line number Diff line Loading @@ -123,7 +123,7 @@ SampleTable::SampleTable(const sp<DataSource> &source) mNumSampleSizes(0), mNumSampleSizes(0), mHasTimeToSample(false), mHasTimeToSample(false), mTimeToSampleCount(0), mTimeToSampleCount(0), mTimeToSample(), mTimeToSample(NULL), mSampleTimeEntries(NULL), mSampleTimeEntries(NULL), mCompositionTimeDeltaEntries(NULL), mCompositionTimeDeltaEntries(NULL), mNumCompositionTimeDeltaEntries(0), mNumCompositionTimeDeltaEntries(0), Loading @@ -132,7 +132,8 @@ SampleTable::SampleTable(const sp<DataSource> &source) mNumSyncSamples(0), mNumSyncSamples(0), mSyncSamples(NULL), mSyncSamples(NULL), mLastSyncSampleIndex(0), mLastSyncSampleIndex(0), mSampleToChunkEntries(NULL) { mSampleToChunkEntries(NULL), mTotalSize(0) { mSampleIterator = new SampleIterator(this); mSampleIterator = new SampleIterator(this); } } Loading @@ -143,6 +144,9 @@ SampleTable::~SampleTable() { delete[] mSyncSamples; delete[] mSyncSamples; mSyncSamples = NULL; mSyncSamples = NULL; delete[] mTimeToSample; mTimeToSample = NULL; delete mCompositionDeltaLookup; delete mCompositionDeltaLookup; mCompositionDeltaLookup = NULL; mCompositionDeltaLookup = NULL; Loading Loading @@ -233,13 +237,43 @@ status_t SampleTable::setSampleToChunkParams( return ERROR_MALFORMED; return ERROR_MALFORMED; } } if (SIZE_MAX / sizeof(SampleToChunkEntry) <= (size_t)mNumSampleToChunkOffsets) if ((uint64_t)SIZE_MAX / sizeof(SampleToChunkEntry) <= (uint64_t)mNumSampleToChunkOffsets) { ALOGE("Sample-to-chunk table size too large."); return ERROR_OUT_OF_RANGE; return ERROR_OUT_OF_RANGE; } mTotalSize += (uint64_t)mNumSampleToChunkOffsets * sizeof(SampleToChunkEntry); if (mTotalSize > kMaxTotalSize) { ALOGE("Sample-to-chunk table size would make sample table too large.\n" " Requested sample-to-chunk table size = %llu\n" " Eventual sample table size >= %llu\n" " Allowed sample table size = %llu\n", (unsigned long long)mNumSampleToChunkOffsets * sizeof(SampleToChunkEntry), (unsigned long long)mTotalSize, (unsigned long long)kMaxTotalSize); return ERROR_OUT_OF_RANGE; } mSampleToChunkEntries = mSampleToChunkEntries = new (std::nothrow) SampleToChunkEntry[mNumSampleToChunkOffsets]; new (std::nothrow) SampleToChunkEntry[mNumSampleToChunkOffsets]; if (!mSampleToChunkEntries) if (!mSampleToChunkEntries) { ALOGE("Cannot allocate sample-to-chunk table with %llu entries.", (unsigned long long)mNumSampleToChunkOffsets); return ERROR_OUT_OF_RANGE; return ERROR_OUT_OF_RANGE; } if (mNumSampleToChunkOffsets == 0) { return OK; } if ((off64_t)(SIZE_MAX - 8 - ((mNumSampleToChunkOffsets - 1) * sizeof(SampleToChunkEntry))) < mSampleToChunkOffset) { return ERROR_MALFORMED; } for (uint32_t i = 0; i < mNumSampleToChunkOffsets; ++i) { for (uint32_t i = 0; i < mNumSampleToChunkOffsets; ++i) { uint8_t buffer[12]; uint8_t buffer[12]; Loading @@ -248,8 +282,11 @@ status_t SampleTable::setSampleToChunkParams( != (ssize_t)sizeof(buffer)) { != (ssize_t)sizeof(buffer)) { return ERROR_IO; return ERROR_IO; } } // chunk index is 1 based in the spec. CHECK(U32_AT(buffer) >= 1); // chunk index is 1 based in the spec. if (U32_AT(buffer) < 1) { ALOGE("b/23534160"); return ERROR_OUT_OF_RANGE; } // We want the chunk index to be 0-based. // We want the chunk index to be 0-based. mSampleToChunkEntries[i].startChunk = U32_AT(buffer) - 1; mSampleToChunkEntries[i].startChunk = U32_AT(buffer) - 1; Loading Loading @@ -350,20 +387,41 @@ status_t SampleTable::setTimeToSampleParams( // 2) mTimeToSampleCount is the number of entries of the time-to-sample // 2) mTimeToSampleCount is the number of entries of the time-to-sample // table. // table. // 3) We hope that the table size does not exceed UINT32_MAX. // 3) We hope that the table size does not exceed UINT32_MAX. ALOGE(" Error: Time-to-sample table size too large."); ALOGE("Time-to-sample table size too large."); return ERROR_OUT_OF_RANGE; return ERROR_OUT_OF_RANGE; } } // Note: At this point, we know that mTimeToSampleCount * 2 will not // Note: At this point, we know that mTimeToSampleCount * 2 will not // overflow because of the above condition. // overflow because of the above condition. if (!mDataSource->getVector(data_offset + 8, &mTimeToSample, mTimeToSampleCount * 2)) { uint64_t allocSize = (uint64_t)mTimeToSampleCount * 2 * sizeof(uint32_t); ALOGE(" Error: Incomplete data read for time-to-sample table."); mTotalSize += allocSize; if (mTotalSize > kMaxTotalSize) { ALOGE("Time-to-sample table size would make sample table too large.\n" " Requested time-to-sample table size = %llu\n" " Eventual sample table size >= %llu\n" " Allowed sample table size = %llu\n", (unsigned long long)allocSize, (unsigned long long)mTotalSize, (unsigned long long)kMaxTotalSize); return ERROR_OUT_OF_RANGE; } mTimeToSample = new (std::nothrow) uint32_t[mTimeToSampleCount * 2]; if (!mTimeToSample) { ALOGE("Cannot allocate time-to-sample table with %llu entries.", (unsigned long long)mTimeToSampleCount); return ERROR_OUT_OF_RANGE; } if (mDataSource->readAt(data_offset + 8, mTimeToSample, (size_t)allocSize) < (ssize_t)allocSize) { ALOGE("Incomplete data read for time-to-sample table."); return ERROR_IO; return ERROR_IO; } } for (size_t i = 0; i < mTimeToSample.size(); ++i) { for (size_t i = 0; i < mTimeToSampleCount * 2; ++i) { mTimeToSample.editItemAt(i) = ntohl(mTimeToSample[i]); mTimeToSample[i] = ntohl(mTimeToSample[i]); } } mHasTimeToSample = true; mHasTimeToSample = true; Loading Loading @@ -398,17 +456,32 @@ status_t SampleTable::setCompositionTimeToSampleParams( mNumCompositionTimeDeltaEntries = numEntries; mNumCompositionTimeDeltaEntries = numEntries; uint64_t allocSize = (uint64_t)numEntries * 2 * sizeof(uint32_t); uint64_t allocSize = (uint64_t)numEntries * 2 * sizeof(uint32_t); if (allocSize > UINT32_MAX) { if (allocSize > SIZE_MAX) { ALOGE("Composition-time-to-sample table size too large."); return ERROR_OUT_OF_RANGE; } mTotalSize += allocSize; if (mTotalSize > kMaxTotalSize) { ALOGE("Composition-time-to-sample table would make sample table too large.\n" " Requested composition-time-to-sample table size = %llu\n" " Eventual sample table size >= %llu\n" " Allowed sample table size = %llu\n", (unsigned long long)allocSize, (unsigned long long)mTotalSize, (unsigned long long)kMaxTotalSize); return ERROR_OUT_OF_RANGE; return ERROR_OUT_OF_RANGE; } } mCompositionTimeDeltaEntries = new (std::nothrow) uint32_t[2 * numEntries]; mCompositionTimeDeltaEntries = new (std::nothrow) uint32_t[2 * numEntries]; if (!mCompositionTimeDeltaEntries) if (!mCompositionTimeDeltaEntries) { ALOGE("Cannot allocate composition-time-to-sample table with %llu " "entries.", (unsigned long long)numEntries); return ERROR_OUT_OF_RANGE; return ERROR_OUT_OF_RANGE; } if (mDataSource->readAt( if (mDataSource->readAt(data_offset + 8, mCompositionTimeDeltaEntries, data_offset + 8, mCompositionTimeDeltaEntries, numEntries * 8) (size_t)allocSize) < (ssize_t)allocSize) { < (ssize_t)numEntries * 8) { delete[] mCompositionTimeDeltaEntries; delete[] mCompositionTimeDeltaEntries; mCompositionTimeDeltaEntries = NULL; mCompositionTimeDeltaEntries = NULL; Loading Loading @@ -449,18 +522,33 @@ status_t SampleTable::setSyncSampleParams(off64_t data_offset, size_t data_size) ALOGV("Table of sync samples is empty or has only a single entry!"); ALOGV("Table of sync samples is empty or has only a single entry!"); } } uint64_t allocSize = mNumSyncSamples * (uint64_t)sizeof(uint32_t); uint64_t allocSize = (uint64_t)mNumSyncSamples * sizeof(uint32_t); if (allocSize > SIZE_MAX) { if (allocSize > SIZE_MAX) { ALOGE("Sync sample table size too large."); return ERROR_OUT_OF_RANGE; } mTotalSize += allocSize; if (mTotalSize > kMaxTotalSize) { ALOGE("Sync sample table size would make sample table too large.\n" " Requested sync sample table size = %llu\n" " Eventual sample table size >= %llu\n" " Allowed sample table size = %llu\n", (unsigned long long)allocSize, (unsigned long long)mTotalSize, (unsigned long long)kMaxTotalSize); return ERROR_OUT_OF_RANGE; return ERROR_OUT_OF_RANGE; } } mSyncSamples = new (std::nothrow) uint32_t[mNumSyncSamples]; mSyncSamples = new (std::nothrow) uint32_t[mNumSyncSamples]; if (!mSyncSamples) if (!mSyncSamples) { ALOGE("Cannot allocate sync sample table with %llu entries.", (unsigned long long)mNumSyncSamples); return ERROR_OUT_OF_RANGE; return ERROR_OUT_OF_RANGE; } size_t size = mNumSyncSamples * sizeof(uint32_t); if (mDataSource->readAt(mSyncSampleOffset + 8, mSyncSamples, if (mDataSource->readAt(mSyncSampleOffset + 8, mSyncSamples, size) (size_t)allocSize) != (ssize_t)allocSize) { != (ssize_t)size) { return ERROR_IO; return ERROR_IO; } } Loading Loading @@ -528,9 +616,24 @@ void SampleTable::buildSampleEntriesTable() { return; return; } } mTotalSize += (uint64_t)mNumSampleSizes * sizeof(SampleTimeEntry); if (mTotalSize > kMaxTotalSize) { ALOGE("Sample entry table size would make sample table too large.\n" " Requested sample entry table size = %llu\n" " Eventual sample table size >= %llu\n" " Allowed sample table size = %llu\n", (unsigned long long)mNumSampleSizes * sizeof(SampleTimeEntry), (unsigned long long)mTotalSize, (unsigned long long)kMaxTotalSize); return; } mSampleTimeEntries = new (std::nothrow) SampleTimeEntry[mNumSampleSizes]; mSampleTimeEntries = new (std::nothrow) SampleTimeEntry[mNumSampleSizes]; if (!mSampleTimeEntries) if (!mSampleTimeEntries) { ALOGE("Cannot allocate sample entry table with %llu entries.", (unsigned long long)mNumSampleSizes); return; return; } uint32_t sampleIndex = 0; uint32_t sampleIndex = 0; uint32_t sampleTime = 0; uint32_t sampleTime = 0; Loading
media/libstagefright/include/SampleTable.h +7 −2 Original line number Original line Diff line number Diff line Loading @@ -24,7 +24,6 @@ #include <media/stagefright/MediaErrors.h> #include <media/stagefright/MediaErrors.h> #include <utils/RefBase.h> #include <utils/RefBase.h> #include <utils/threads.h> #include <utils/threads.h> #include <utils/Vector.h> namespace android { namespace android { Loading Loading @@ -96,6 +95,9 @@ private: static const uint32_t kSampleSizeType32; static const uint32_t kSampleSizeType32; static const uint32_t kSampleSizeTypeCompact; static const uint32_t kSampleSizeTypeCompact; // Limit the total size of all internal tables to 200MiB. static const size_t kMaxTotalSize = 200 * (1 << 20); sp<DataSource> mDataSource; sp<DataSource> mDataSource; Mutex mLock; Mutex mLock; Loading @@ -113,7 +115,7 @@ private: bool mHasTimeToSample; bool mHasTimeToSample; uint32_t mTimeToSampleCount; uint32_t mTimeToSampleCount; Vector<uint32_t> mTimeToSample; uint32_t* mTimeToSample; struct SampleTimeEntry { struct SampleTimeEntry { uint32_t mSampleIndex; uint32_t mSampleIndex; Loading @@ -139,6 +141,9 @@ private: }; }; SampleToChunkEntry *mSampleToChunkEntries; SampleToChunkEntry *mSampleToChunkEntries; // Approximate size of all tables combined. uint64_t mTotalSize; friend struct SampleIterator; friend struct SampleIterator; // normally we don't round // normally we don't round Loading