Bug 1041346 - Don't limit number of samples stagefright mp4 demuxer can output. r=kentuckyfriedtakahe
authorChris Pearce <cpearce@mozilla.com>
Mon, 21 Jul 2014 14:00:32 +1200
changeset 216033 771dea9531b4e23a5c36d550e190a3362f9b0045
parent 216020 4bafe35cfb6581bd57e6fec7330694f790208fba
child 216034 463dfcb4901a3c575bf9f5e1efc43db35a2e9216
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskentuckyfriedtakahe
bugs1041346
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1041346 - Don't limit number of samples stagefright mp4 demuxer can output. r=kentuckyfriedtakahe
media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
--- a/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/frameworks/av/media/libstagefright/MPEG4Extractor.cpp
@@ -93,18 +93,16 @@ private:
     uint32_t mCurrentSampleInfoOffsetsAllocSize;
     uint64_t* mCurrentSampleInfoOffsets;
 
     bool mIsAVC;
     size_t mNALLengthSize;
 
     bool mStarted;
 
-    MediaBufferGroup *mGroup;
-
     MediaBuffer *mBuffer;
 
     bool mWantsNALFragments;
 
     uint8_t *mSrcBuffer;
 
     size_t parseNALSize(const uint8_t *data) const;
     status_t parseChunk(off64_t *offset);
@@ -2387,17 +2385,16 @@ MPEG4Source::MPEG4Source(
       mCurrentTime(0),
       mCurrentSampleInfoAllocSize(0),
       mCurrentSampleInfoSizes(NULL),
       mCurrentSampleInfoOffsetsAllocSize(0),
       mCurrentSampleInfoOffsets(NULL),
       mIsAVC(false),
       mNALLengthSize(0),
       mStarted(false),
-      mGroup(NULL),
       mBuffer(NULL),
       mWantsNALFragments(false),
       mSrcBuffer(NULL) {
 
     mFormat->findInt32(kKeyCryptoMode, &mCryptoMode);
     mDefaultIVSize = 0;
     mFormat->findInt32(kKeyCryptoDefaultIVSize, &mDefaultIVSize);
     uint32_t keytype;
@@ -2454,23 +2451,19 @@ status_t MPEG4Source::start(MetaData *pa
     int32_t val;
     if (params && params->findInt32(kKeyWantsNALFragments, &val)
         && val != 0) {
         mWantsNALFragments = true;
     } else {
         mWantsNALFragments = false;
     }
 
-    mGroup = new MediaBufferGroup;
-
     int32_t max_size;
     CHECK(mFormat->findInt32(kKeyMaxInputSize, &max_size));
 
-    mGroup->add_buffer(new MediaBuffer(max_size));
-
     mSrcBuffer = new uint8_t[max_size];
 
     mStarted = true;
 
     return OK;
 }
 
 status_t MPEG4Source::stop() {
@@ -2481,19 +2474,16 @@ status_t MPEG4Source::stop() {
     if (mBuffer != NULL) {
         mBuffer->release();
         mBuffer = NULL;
     }
 
     delete[] mSrcBuffer;
     mSrcBuffer = NULL;
 
-    delete mGroup;
-    mGroup = NULL;
-
     mStarted = false;
     mCurrentSampleIndex = 0;
 
     return OK;
 }
 
 status_t MPEG4Source::parseChunk(off64_t *offset) {
     uint32_t hdr[2];
@@ -3164,22 +3154,20 @@ status_t MPEG4Source::read(
             mSampleTable->getMetaDataForSample(
                     mCurrentSampleIndex, &offset, &size, &cts, &duration,
                     &isSyncSample);
 
         if (err != OK) {
             return err;
         }
 
-        err = mGroup->acquire_buffer(&mBuffer);
-
-        if (err != OK) {
-            CHECK(mBuffer == NULL);
-            return err;
-        }
+        int32_t max_size;
+        CHECK(mFormat->findInt32(kKeyMaxInputSize, &max_size));
+        mBuffer = new MediaBuffer(max_size);
+        assert(mBuffer);
     }
 
     if (!mIsAVC || mWantsNALFragments) {
         if (newBuffer) {
             ssize_t num_bytes_read =
                 mDataSource->readAt(offset, (uint8_t *)mBuffer->data(), size);
 
             if (num_bytes_read < (ssize_t)size) {
@@ -3434,23 +3422,20 @@ status_t MPEG4Source::fragmentedRead(
         const Sample *smpl = &mCurrentSamples[mCurrentSampleIndex];
         offset = smpl->offset;
         size = smpl->size;
         cts = mCurrentTime + smpl->ctsOffset;
         duration = smpl->duration;
         mCurrentTime += smpl->duration;
         isSyncSample = (mCurrentSampleIndex == 0); // XXX
 
-        status_t err = mGroup->acquire_buffer(&mBuffer);
-
-        if (err != OK) {
-            CHECK(mBuffer == NULL);
-            ALOGV("acquire_buffer returned %d", err);
-            return err;
-        }
+        int32_t max_size;
+        CHECK(mFormat->findInt32(kKeyMaxInputSize, &max_size));
+        mBuffer = new MediaBuffer(max_size);
+        assert(mBuffer);
     }
 
     const Sample *smpl = &mCurrentSamples[mCurrentSampleIndex];
     const sp<MetaData> bufmeta = mBuffer->meta_data();
     bufmeta->clear();
     if (smpl->encryptedsizes.size()) {
         // store clear/encrypted lengths in metadata
         bufmeta->setData(kKeyPlainSizes, 0,