Make sure the decoder's input buffers are large enough to hold the largest input data. Verify that the setting actually sticks.

This commit is contained in:
Andreas Huber
2009-11-23 14:03:32 -08:00
parent e5683369d2
commit 1bceff916a
2 changed files with 20 additions and 10 deletions

View File

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

View File

@@ -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(