Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 738c4315 authored by Andreas Huber's avatar Andreas Huber
Browse files

Make sure the decoder's input buffers are large enough to hold the largest...

Make sure the decoder's input buffers are large enough to hold the largest input data. Verify that the setting actually sticks.
parent bfa6b2d7
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -635,6 +635,15 @@ status_t MPEG4Extractor::parseChunk(off_t *offset, int depth) {
                return err;
            }

            size_t max_size;
            CHECK_EQ(mLastTrack->sampleTable->getMaxSampleSize(&max_size), OK);

            // Assume that a given buffer only contains at most 10 fragments,
            // each fragment originally prefixed with a 2 byte length will
            // have a 4 byte header (0x00 0x00 0x00 0x01) after conversion,
            // and thus will grow by 2 bytes per fragment.
            mLastTrack->meta->setInt32(kKeyMaxInputSize, max_size + 10 * 2);

            *offset += chunk_size;
            break;
        }
@@ -792,15 +801,10 @@ status_t MPEG4Source::start(MetaData *params) {

    mGroup = new MediaBufferGroup;

    size_t max_size;
    status_t err = mSampleTable->getMaxSampleSize(&max_size);
    CHECK_EQ(err, OK);
    int32_t max_size;
    CHECK(mFormat->findInt32(kKeyMaxInputSize, &max_size));

    // Assume that a given buffer only contains at most 10 fragments,
    // each fragment originally prefixed with a 2 byte length will
    // have a 4 byte header (0x00 0x00 0x00 0x01) after conversion,
    // and thus will grow by 2 bytes per fragment.
    mGroup->add_buffer(new MediaBuffer(max_size + 10 * 2));
    mGroup->add_buffer(new MediaBuffer(max_size));

    mSrcBuffer = new uint8_t[max_size];

+8 −2
Original line number Diff line number Diff line
@@ -462,7 +462,7 @@ sp<OMXCodec> OMXCodec::Create(
    }

    int32_t maxInputSize;
    if (createEncoder && meta->findInt32(kKeyMaxInputSize, &maxInputSize)) {
    if (meta->findInt32(kKeyMaxInputSize, &maxInputSize)) {
        codec->setMinBufferSize(kPortIndexInput, (OMX_U32)maxInputSize);
    }

@@ -487,12 +487,18 @@ void OMXCodec::setMinBufferSize(OMX_U32 portIndex, OMX_U32 size) {

    if (def.nBufferSize < size) {
        def.nBufferSize = size;

    }

    err = mOMX->setParameter(
            mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
    CHECK_EQ(err, OK);

    err = mOMX->getParameter(
            mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
    CHECK_EQ(err, OK);

    // Make sure the setting actually stuck.
    CHECK(def.nBufferSize >= size);
}

status_t OMXCodec::setVideoPortFormatType(