diff options
author | Andreas Huber <andih@google.com> | 2012-08-07 14:24:00 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2012-08-07 14:24:00 -0700 |
commit | 51d7547944967d1157b7fe18e1fb8f7ee6810412 (patch) | |
tree | 5c5d6cb884a163c7ea1f23899776f856fefbd1fa /media/libstagefright/codecs/mp3dec/SoftMP3.cpp | |
parent | e671207115fac3914134c61b336d5fa0242c68ca (diff) | |
download | frameworks_av-51d7547944967d1157b7fe18e1fb8f7ee6810412.zip frameworks_av-51d7547944967d1157b7fe18e1fb8f7ee6810412.tar.gz frameworks_av-51d7547944967d1157b7fe18e1fb8f7ee6810412.tar.bz2 |
Only emit padding at the end of the stream in the aac and mp3 decoders
if we actually discarded content at the beginning of the stream.
Change-Id: I1e79835bb3a02350060a137b94f85f2c90f4a12b
Diffstat (limited to 'media/libstagefright/codecs/mp3dec/SoftMP3.cpp')
-rw-r--r-- | media/libstagefright/codecs/mp3dec/SoftMP3.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/media/libstagefright/codecs/mp3dec/SoftMP3.cpp b/media/libstagefright/codecs/mp3dec/SoftMP3.cpp index 8f2a3aa..fb1135c 100644 --- a/media/libstagefright/codecs/mp3dec/SoftMP3.cpp +++ b/media/libstagefright/codecs/mp3dec/SoftMP3.cpp @@ -191,10 +191,19 @@ void SoftMP3::onQueueFilled(OMX_U32 portIndex) { inInfo->mOwnedByUs = false; notifyEmptyBufferDone(inHeader); - // pad the end of the stream with 529 samples, since that many samples - // were trimmed off the beginning when decoding started - outHeader->nFilledLen = kPVMP3DecoderDelay * mNumChannels * sizeof(int16_t); - memset(outHeader->pBuffer, 0, outHeader->nFilledLen); + if (!mIsFirst) { + // pad the end of the stream with 529 samples, since that many samples + // were trimmed off the beginning when decoding started + outHeader->nFilledLen = + kPVMP3DecoderDelay * mNumChannels * sizeof(int16_t); + + memset(outHeader->pBuffer, 0, outHeader->nFilledLen); + } else { + // Since we never discarded frames from the start, we won't have + // to add any padding at the end either. + outHeader->nFilledLen = 0; + } + outHeader->nFlags = OMX_BUFFERFLAG_EOS; outQueue.erase(outQueue.begin()); @@ -260,8 +269,11 @@ void SoftMP3::onQueueFilled(OMX_U32 portIndex) { // The decoder delay is 529 samples, so trim that many samples off // the start of the first output buffer. This essentially makes this // decoder have zero delay, which the rest of the pipeline assumes. - outHeader->nOffset = kPVMP3DecoderDelay * mNumChannels * sizeof(int16_t); - outHeader->nFilledLen = mConfig->outputFrameSize * sizeof(int16_t) - outHeader->nOffset; + outHeader->nOffset = + kPVMP3DecoderDelay * mNumChannels * sizeof(int16_t); + + outHeader->nFilledLen = + mConfig->outputFrameSize * sizeof(int16_t) - outHeader->nOffset; } else { outHeader->nOffset = 0; outHeader->nFilledLen = mConfig->outputFrameSize * sizeof(int16_t); |