Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 165a485a authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "ACodec: submit extra output metadata buffers if in low latency mode"...

Merge "ACodec: submit extra output metadata buffers if in low latency mode" am: e53a2243 am: e89d5e4a

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/1434677

Change-Id: Ia2adfd7354bca96663147143625034619f81887b
parents 6afee2b1 e89d5e4a
Loading
Loading
Loading
Loading
+37 −2
Original line number Diff line number Diff line
@@ -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);
@@ -302,6 +309,8 @@ private:

    void getMoreInputDataIfPossible();

    bool mPendingExtraOutputMetadataBufferRequest;

    DISALLOW_EVIL_CONSTRUCTORS(BaseState);
};

@@ -555,6 +564,7 @@ ACodec::ACodec()
      mShutdownInProgress(false),
      mExplicitShutdown(false),
      mIsLegacyVP9Decoder(false),
      mIsLowLatency(false),
      mEncoderDelay(0),
      mEncoderPadding(0),
      mRotationDegrees(0),
@@ -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;
}

@@ -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(
@@ -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;
    }
@@ -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");
@@ -7351,6 +7383,9 @@ void ACodec::ExecutingState::submitOutputMetaBuffers() {
                break;
        }
    }
    if (mCodec->mIsLowLatency) {
        maybePostExtraOutputMetadataBufferRequest();
    }

    // *** NOTE: THE FOLLOWING WORKAROUND WILL BE REMOVED ***
    mCodec->signalSubmitOutputMetadataBufferIfEOS_workaround();
+2 −0
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@ private:
        kWhatReleaseCodecInstance    = 'relC',
        kWhatForceStateTransition    = 'fstt',
        kWhatCheckIfStuck            = 'Cstk',
        kWhatSubmitExtraOutputMetadataBuffer = 'sbxo',
    };

    enum {
@@ -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.