diff options
author | Andreas Huber <andih@google.com> | 2009-12-11 11:27:02 -0800 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2009-12-11 11:27:02 -0800 |
commit | 6b91407a918d755454ed396068ff7f67b7088f34 (patch) | |
tree | ff38d37a9acdcf4a0890501402c835b77538cf8a /media/libstagefright/codecs/amrnb/dec | |
parent | 72124cf05cd5b40f2902198aca2797616b813457 (diff) | |
download | frameworks_av-6b91407a918d755454ed396068ff7f67b7088f34.zip frameworks_av-6b91407a918d755454ed396068ff7f67b7088f34.tar.gz frameworks_av-6b91407a918d755454ed396068ff7f67b7088f34.tar.bz2 |
Propagate duration from input to output only if available, support multiple full frames of audio per input buffer in AMR/AAC decoders.
Diffstat (limited to 'media/libstagefright/codecs/amrnb/dec')
-rw-r--r-- | media/libstagefright/codecs/amrnb/dec/AMRNBDecoder.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/media/libstagefright/codecs/amrnb/dec/AMRNBDecoder.cpp b/media/libstagefright/codecs/amrnb/dec/AMRNBDecoder.cpp index 856e29c..fbb6598 100644 --- a/media/libstagefright/codecs/amrnb/dec/AMRNBDecoder.cpp +++ b/media/libstagefright/codecs/amrnb/dec/AMRNBDecoder.cpp @@ -87,7 +87,6 @@ sp<MetaData> AMRNBDecoder::getFormat() { int32_t numChannels; int32_t sampleRate; - int64_t durationUs; CHECK(srcFormat->findInt32(kKeyChannelCount, &numChannels)); CHECK_EQ(numChannels, 1); @@ -95,13 +94,15 @@ sp<MetaData> AMRNBDecoder::getFormat() { CHECK(srcFormat->findInt32(kKeySampleRate, &sampleRate)); CHECK_EQ(sampleRate, kSampleRate); - CHECK(srcFormat->findInt64(kKeyDuration, &durationUs)); - sp<MetaData> meta = new MetaData; meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW); meta->setInt32(kKeyChannelCount, numChannels); meta->setInt32(kKeySampleRate, sampleRate); - meta->setInt64(kKeyDuration, durationUs); + + int64_t durationUs; + if (srcFormat->findInt64(kKeyDuration, &durationUs)) { + meta->setInt64(kKeyDuration, durationUs); + } return meta; } @@ -160,10 +161,16 @@ status_t AMRNBDecoder::read( buffer->set_range(0, kNumSamplesPerFrame * sizeof(int16_t)); - CHECK_EQ(numBytesRead, mInputBuffer->range_length()); + CHECK(numBytesRead <= mInputBuffer->range_length()); - mInputBuffer->release(); - mInputBuffer = NULL; + mInputBuffer->set_range( + mInputBuffer->range_offset() + numBytesRead, + mInputBuffer->range_length() - numBytesRead); + + if (mInputBuffer->range_length() == 0) { + mInputBuffer->release(); + mInputBuffer = NULL; + } buffer->meta_data()->setInt64( kKeyTime, |