Loading media/libstagefright/ACodec.cpp +37 −2 Original line number Diff line number Diff line Loading @@ -279,6 +279,13 @@ protected: void postFillThisBuffer(BufferInfo *info); void maybePostExtraOutputMetadataBufferRequest() { if (!mPendingExtraOutputMetadataBufferRequest) { (new AMessage(kWhatSubmitExtraOutputMetadataBuffer, mCodec))->post(); mPendingExtraOutputMetadataBufferRequest = true; } } private: // Handles an OMX message. Returns true iff message was handled. bool onOMXMessage(const sp<AMessage> &msg); Loading @@ -302,6 +309,8 @@ private: void getMoreInputDataIfPossible(); bool mPendingExtraOutputMetadataBufferRequest; DISALLOW_EVIL_CONSTRUCTORS(BaseState); }; Loading Loading @@ -555,6 +564,7 @@ ACodec::ACodec() mShutdownInProgress(false), mExplicitShutdown(false), mIsLegacyVP9Decoder(false), mIsLowLatency(false), mEncoderDelay(0), mEncoderPadding(0), mRotationDegrees(0), Loading Loading @@ -2415,6 +2425,7 @@ status_t ACodec::setLowLatency(int32_t lowLatency) { if (err != OK) { ALOGE("decoder can not set low-latency to %d (err %d)", lowLatency, err); } mIsLowLatency = (lowLatency && err == OK); return err; } Loading Loading @@ -5748,7 +5759,8 @@ status_t ACodec::requestIDRFrame() { ACodec::BaseState::BaseState(ACodec *codec, const sp<AState> &parentState) : AState(parentState), mCodec(codec) { mCodec(codec), mPendingExtraOutputMetadataBufferRequest(false) { } ACodec::BaseState::PortMode ACodec::BaseState::getPortMode( Loading Loading @@ -5849,6 +5861,21 @@ bool ACodec::BaseState::onMessageReceived(const sp<AMessage> &msg) { break; } case kWhatSubmitExtraOutputMetadataBuffer: { mPendingExtraOutputMetadataBufferRequest = false; if (getPortMode(kPortIndexOutput) == RESUBMIT_BUFFERS && mCodec->mIsLowLatency) { // Decoders often need more than one output buffer to be // submitted before processing a single input buffer. // For low latency codecs, we don't want to wait for more input // to be queued to get those output buffers submitted. if (mCodec->submitOutputMetadataBuffer() == OK && mCodec->mMetadataBuffersToSubmit > 0) { maybePostExtraOutputMetadataBufferRequest(); } } break; } default: return false; } Loading Loading @@ -6205,7 +6232,12 @@ void ACodec::BaseState::onInputBufferFilled(const sp<AMessage> &msg) { (outputMode == FREE_BUFFERS ? "FREE" : outputMode == KEEP_BUFFERS ? "KEEP" : "RESUBMIT")); if (outputMode == RESUBMIT_BUFFERS) { mCodec->submitOutputMetadataBuffer(); status_t err = mCodec->submitOutputMetadataBuffer(); if (mCodec->mIsLowLatency && err == OK && mCodec->mMetadataBuffersToSubmit > 0) { maybePostExtraOutputMetadataBufferRequest(); } } } info->checkReadFence("onInputBufferFilled"); Loading Loading @@ -7351,6 +7383,9 @@ void ACodec::ExecutingState::submitOutputMetaBuffers() { break; } } if (mCodec->mIsLowLatency) { maybePostExtraOutputMetadataBufferRequest(); } // *** NOTE: THE FOLLOWING WORKAROUND WILL BE REMOVED *** mCodec->signalSubmitOutputMetadataBufferIfEOS_workaround(); Loading media/libstagefright/include/media/stagefright/ACodec.h +2 −0 Original line number Diff line number Diff line Loading @@ -147,6 +147,7 @@ private: kWhatReleaseCodecInstance = 'relC', kWhatForceStateTransition = 'fstt', kWhatCheckIfStuck = 'Cstk', kWhatSubmitExtraOutputMetadataBuffer = 'sbxo', }; enum { Loading Loading @@ -272,6 +273,7 @@ private: bool mShutdownInProgress; bool mExplicitShutdown; bool mIsLegacyVP9Decoder; bool mIsLowLatency; // If "mKeepComponentAllocated" we only transition back to Loaded state // and do not release the component instance. Loading Loading
media/libstagefright/ACodec.cpp +37 −2 Original line number Diff line number Diff line Loading @@ -279,6 +279,13 @@ protected: void postFillThisBuffer(BufferInfo *info); void maybePostExtraOutputMetadataBufferRequest() { if (!mPendingExtraOutputMetadataBufferRequest) { (new AMessage(kWhatSubmitExtraOutputMetadataBuffer, mCodec))->post(); mPendingExtraOutputMetadataBufferRequest = true; } } private: // Handles an OMX message. Returns true iff message was handled. bool onOMXMessage(const sp<AMessage> &msg); Loading @@ -302,6 +309,8 @@ private: void getMoreInputDataIfPossible(); bool mPendingExtraOutputMetadataBufferRequest; DISALLOW_EVIL_CONSTRUCTORS(BaseState); }; Loading Loading @@ -555,6 +564,7 @@ ACodec::ACodec() mShutdownInProgress(false), mExplicitShutdown(false), mIsLegacyVP9Decoder(false), mIsLowLatency(false), mEncoderDelay(0), mEncoderPadding(0), mRotationDegrees(0), Loading Loading @@ -2415,6 +2425,7 @@ status_t ACodec::setLowLatency(int32_t lowLatency) { if (err != OK) { ALOGE("decoder can not set low-latency to %d (err %d)", lowLatency, err); } mIsLowLatency = (lowLatency && err == OK); return err; } Loading Loading @@ -5748,7 +5759,8 @@ status_t ACodec::requestIDRFrame() { ACodec::BaseState::BaseState(ACodec *codec, const sp<AState> &parentState) : AState(parentState), mCodec(codec) { mCodec(codec), mPendingExtraOutputMetadataBufferRequest(false) { } ACodec::BaseState::PortMode ACodec::BaseState::getPortMode( Loading Loading @@ -5849,6 +5861,21 @@ bool ACodec::BaseState::onMessageReceived(const sp<AMessage> &msg) { break; } case kWhatSubmitExtraOutputMetadataBuffer: { mPendingExtraOutputMetadataBufferRequest = false; if (getPortMode(kPortIndexOutput) == RESUBMIT_BUFFERS && mCodec->mIsLowLatency) { // Decoders often need more than one output buffer to be // submitted before processing a single input buffer. // For low latency codecs, we don't want to wait for more input // to be queued to get those output buffers submitted. if (mCodec->submitOutputMetadataBuffer() == OK && mCodec->mMetadataBuffersToSubmit > 0) { maybePostExtraOutputMetadataBufferRequest(); } } break; } default: return false; } Loading Loading @@ -6205,7 +6232,12 @@ void ACodec::BaseState::onInputBufferFilled(const sp<AMessage> &msg) { (outputMode == FREE_BUFFERS ? "FREE" : outputMode == KEEP_BUFFERS ? "KEEP" : "RESUBMIT")); if (outputMode == RESUBMIT_BUFFERS) { mCodec->submitOutputMetadataBuffer(); status_t err = mCodec->submitOutputMetadataBuffer(); if (mCodec->mIsLowLatency && err == OK && mCodec->mMetadataBuffersToSubmit > 0) { maybePostExtraOutputMetadataBufferRequest(); } } } info->checkReadFence("onInputBufferFilled"); Loading Loading @@ -7351,6 +7383,9 @@ void ACodec::ExecutingState::submitOutputMetaBuffers() { break; } } if (mCodec->mIsLowLatency) { maybePostExtraOutputMetadataBufferRequest(); } // *** NOTE: THE FOLLOWING WORKAROUND WILL BE REMOVED *** mCodec->signalSubmitOutputMetadataBufferIfEOS_workaround(); Loading
media/libstagefright/include/media/stagefright/ACodec.h +2 −0 Original line number Diff line number Diff line Loading @@ -147,6 +147,7 @@ private: kWhatReleaseCodecInstance = 'relC', kWhatForceStateTransition = 'fstt', kWhatCheckIfStuck = 'Cstk', kWhatSubmitExtraOutputMetadataBuffer = 'sbxo', }; enum { Loading Loading @@ -272,6 +273,7 @@ private: bool mShutdownInProgress; bool mExplicitShutdown; bool mIsLegacyVP9Decoder; bool mIsLowLatency; // If "mKeepComponentAllocated" we only transition back to Loaded state // and do not release the component instance. Loading