diff options
Diffstat (limited to 'media/libstagefright/codecs/mp3dec')
-rw-r--r-- | media/libstagefright/codecs/mp3dec/Android.mk | 13 | ||||
-rw-r--r-- | media/libstagefright/codecs/mp3dec/SoftMP3.cpp | 46 | ||||
-rw-r--r-- | media/libstagefright/codecs/mp3dec/SoftMP3.h | 3 |
3 files changed, 47 insertions, 15 deletions
diff --git a/media/libstagefright/codecs/mp3dec/Android.mk b/media/libstagefright/codecs/mp3dec/Android.mk index 948ae29..b3880ee 100644 --- a/media/libstagefright/codecs/mp3dec/Android.mk +++ b/media/libstagefright/codecs/mp3dec/Android.mk @@ -28,19 +28,22 @@ LOCAL_SRC_FILES := \ src/pvmp3_stereo_proc.cpp \ src/pvmp3_reorder.cpp \ -ifeq ($(TARGET_ARCH),arm) -LOCAL_SRC_FILES += \ +LOCAL_SRC_FILES_arm += \ src/asm/pvmp3_polyphase_filter_window_gcc.s \ src/asm/pvmp3_mdct_18_gcc.s \ src/asm/pvmp3_dct_9_gcc.s \ src/asm/pvmp3_dct_16_gcc.s -else -LOCAL_SRC_FILES += \ +LOCAL_SRC_FILES_other_archs := \ src/pvmp3_polyphase_filter_window.cpp \ src/pvmp3_mdct_18.cpp \ src/pvmp3_dct_9.cpp \ src/pvmp3_dct_16.cpp -endif + +LOCAL_SRC_FILES_arm64 := $(LOCAL_SRC_FILES_other_archs) +LOCAL_SRC_FILES_mips := $(LOCAL_SRC_FILES_other_archs) +LOCAL_SRC_FILES_mips64 := $(LOCAL_SRC_FILES_other_archs) +LOCAL_SRC_FILES_x86 := $(LOCAL_SRC_FILES_other_archs) +LOCAL_SRC_FILES_x86_64 := $(LOCAL_SRC_FILES_other_archs) LOCAL_C_INCLUDES := \ frameworks/av/media/libstagefright/include \ diff --git a/media/libstagefright/codecs/mp3dec/SoftMP3.cpp b/media/libstagefright/codecs/mp3dec/SoftMP3.cpp index 9f7dd59..005956d 100644 --- a/media/libstagefright/codecs/mp3dec/SoftMP3.cpp +++ b/media/libstagefright/codecs/mp3dec/SoftMP3.cpp @@ -51,7 +51,9 @@ SoftMP3::SoftMP3( mSignalledError(false), mSawInputEos(false), mSignalledOutputEos(false), - mOutputPortSettingsChange(NONE) { + mOutputPortSettingsChange(NONE), + mLastAnchorTimeUs(-1), + mNextOutBufferTimeUs(0) { initPorts(); initDecoder(); } @@ -112,7 +114,7 @@ void SoftMP3::initPorts() { void SoftMP3::initDecoder() { mConfig->equalizerType = flat; mConfig->crcEnabled = false; - + mConfig->samplingRate = mSamplingRate; uint32_t memRequirements = pvmp3_decoderMemRequirements(); mDecoderBuf = malloc(memRequirements); @@ -239,7 +241,7 @@ void SoftMP3::onQueueFilled(OMX_U32 /* portIndex */) { List<BufferInfo *> &inQueue = getPortQueue(0); List<BufferInfo *> &outQueue = getPortQueue(1); - + int64_t tmpTime = 0; while ((!inQueue.empty() || (mSawInputEos && !mSignalledOutputEos)) && !outQueue.empty()) { BufferInfo *inInfo = NULL; OMX_BUFFERHEADERTYPE *inHeader = NULL; @@ -254,7 +256,20 @@ void SoftMP3::onQueueFilled(OMX_U32 /* portIndex */) { if (inHeader) { if (inHeader->nOffset == 0 && inHeader->nFilledLen) { - mAnchorTimeUs = inHeader->nTimeStamp; + // use new input buffer timestamp as Anchor Time if its + // a) first buffer or + // b) first buffer post seek or + // c) different from last buffer timestamp + //If input buffer timestamp is same as last input buffer timestamp then + //treat this as a erroneous timestamp and ignore new input buffer + //timestamp and use last output buffer timestamp as Anchor Time. + if ((mLastAnchorTimeUs != inHeader->nTimeStamp)) { + mAnchorTimeUs = inHeader->nTimeStamp; + mLastAnchorTimeUs = inHeader->nTimeStamp; + } else { + mAnchorTimeUs = mNextOutBufferTimeUs; + } + mNumFramesOutput = 0; } @@ -275,7 +290,7 @@ void SoftMP3::onQueueFilled(OMX_U32 /* portIndex */) { mConfig->outputFrameSize = kOutputBufferSize / sizeof(int16_t); if ((int32)outHeader->nAllocLen < mConfig->outputFrameSize) { - ALOGE("input buffer too small: got %lu, expected %u", + ALOGE("input buffer too small: got %u, expected %u", outHeader->nAllocLen, mConfig->outputFrameSize); android_errorWriteLog(0x534e4554, "27793371"); notify(OMX_EventError, OMX_ErrorUndefined, OUTPUT_BUFFER_TOO_SMALL, NULL); @@ -294,10 +309,13 @@ void SoftMP3::onQueueFilled(OMX_U32 /* portIndex */) { if (decoderErr != NO_ENOUGH_MAIN_DATA_ERROR && decoderErr != SIDE_INFO_ERROR) { ALOGE("mp3 decoder returned error %d", decoderErr); - - notify(OMX_EventError, OMX_ErrorUndefined, decoderErr, NULL); - mSignalledError = true; - return; + if(decoderErr == SYNCH_LOST_ERROR) { + mConfig->outputFrameSize = kOutputBufferSize / sizeof(int16_t); + } else { + notify(OMX_EventError, OMX_ErrorUndefined, decoderErr, NULL); + mSignalledError = true; + return; + } } if (mConfig->outputFrameSize == 0) { @@ -361,7 +379,7 @@ void SoftMP3::onQueueFilled(OMX_U32 /* portIndex */) { outHeader->nTimeStamp = mAnchorTimeUs + (mNumFramesOutput * 1000000ll) / mSamplingRate; - + tmpTime = outHeader->nTimeStamp; if (inHeader) { CHECK_GE(inHeader->nFilledLen, mConfig->inputBufferUsedLength); @@ -386,6 +404,10 @@ void SoftMP3::onQueueFilled(OMX_U32 /* portIndex */) { notifyFillBufferDone(outHeader); outHeader = NULL; } + + if (tmpTime > 0) { + mNextOutBufferTimeUs = tmpTime; + } } void SoftMP3::onPortFlushCompleted(OMX_U32 portIndex) { @@ -397,6 +419,8 @@ void SoftMP3::onPortFlushCompleted(OMX_U32 portIndex) { mSignalledError = false; mSawInputEos = false; mSignalledOutputEos = false; + mLastAnchorTimeUs = -1; + mNextOutBufferTimeUs = 0; } } @@ -433,6 +457,8 @@ void SoftMP3::onReset() { mSawInputEos = false; mSignalledOutputEos = false; mOutputPortSettingsChange = NONE; + mLastAnchorTimeUs = -1; + mNextOutBufferTimeUs = 0; } } // namespace android diff --git a/media/libstagefright/codecs/mp3dec/SoftMP3.h b/media/libstagefright/codecs/mp3dec/SoftMP3.h index 3bfa6c7..5b6af88 100644 --- a/media/libstagefright/codecs/mp3dec/SoftMP3.h +++ b/media/libstagefright/codecs/mp3dec/SoftMP3.h @@ -70,6 +70,9 @@ private: AWAITING_ENABLED } mOutputPortSettingsChange; + int64_t mLastAnchorTimeUs; + int64_t mNextOutBufferTimeUs; + void initPorts(); void initDecoder(); void *memsetSafe(OMX_BUFFERHEADERTYPE *outHeader, int c, size_t len); |