From d2c6894b56a538aa807e20d3ef421807cd55c009 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Tue, 20 Apr 2010 14:26:00 -0700 Subject: Don't coalesce more than 250ms worth of encoded data into a single codec input buffer. This currently only applies to the component OMX.TI.AAC.decode, it is the only one to support coalescing in the first place. In certain edge cases (encoded audio track contains silence), each buffer would turn out to be an amazing 6(!!!) bytes, we'd spend lots and lots of time streaming network data to fill the codec's buffers of size 6144 bytes with .. silence. Change-Id: I9f449f310fc64ca384bd02e4a783e33cf5b46fcc related-to-bug: 2609049 QA-Impact: streamed (http) playback of aac audio content on Droid. --- media/libstagefright/OMXCodec.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'media/libstagefright/OMXCodec.cpp') diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp index 873c2aa..2c94965 100644 --- a/media/libstagefright/OMXCodec.cpp +++ b/media/libstagefright/OMXCodec.cpp @@ -2004,9 +2004,12 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) { (const uint8_t *)srcBuffer->data() + srcBuffer->range_offset(), srcBuffer->range_length()); + int64_t lastBufferTimeUs; + CHECK(srcBuffer->meta_data()->findInt64(kKeyTime, &lastBufferTimeUs)); + CHECK(timestampUs >= 0); + if (offset == 0) { - CHECK(srcBuffer->meta_data()->findInt64(kKeyTime, ×tampUs)); - CHECK(timestampUs >= 0); + timestampUs = lastBufferTimeUs; } offset += srcBuffer->range_length(); @@ -2019,6 +2022,13 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) { if (!(mQuirks & kSupportsMultipleFramesPerInputBuffer)) { break; } + + int64_t coalescedDurationUs = lastBufferTimeUs - timestampUs; + + if (coalescedDurationUs > 250000ll) { + // Don't coalesce more than 250ms worth of encoded data at once. + break; + } } if (n > 1) { -- cgit v1.1