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

Commit a54aa363 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "Fix for 65483665 (lmp-mr1-dev)" into lmp-mr1-dev

* changes:
  RESTRICT AUTOMERGE SimpleSoftOMXComponent: change CHECK to error notification.
  RESTRICT AUTOMERGE SoftHEVC: Handle error in reInitDecoder()
parents c5e5b382 e0faa7bb
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -4373,6 +4373,12 @@ void ACodec::BaseState::onInputBufferFilled(const sp<AMessage> &msg) {
        case RESUBMIT_BUFFERS:
        {
            if (buffer != NULL && !mCodec->mPortEOS[kPortIndexInput]) {
                // Do not send empty input buffer w/o EOS to the component.
                if (buffer->size() == 0 && !eos) {
                    postFillThisBuffer(info);
                    break;
                }

                int64_t timeUs;
                CHECK(buffer->meta()->findInt64("timeUs", &timeUs));

+33 −4
Original line number Diff line number Diff line
@@ -69,12 +69,14 @@ SoftHEVC::SoftHEVC(
            kProfileLevels, ARRAY_SIZE(kProfileLevels),
            320 /* width */, 240 /* height */, callbacks,
            appData, component),
      mCodecCtx(NULL),
      mMemRecords(NULL),
      mFlushOutBuffer(NULL),
      mOmxColorFormat(OMX_COLOR_FormatYUV420Planar),
      mIvColorFormat(IV_YUV_420P),
      mNewWidth(mWidth),
      mNewHeight(mHeight),
      mSignalledError(false),
      mChangingResolution(false) {
    const size_t kMinCompressionRatio = 4 /* compressionRatio (for Level 4+) */;
    const size_t kMaxOutputBufferSize = 2048 * 2048 * 3 / 2;
@@ -249,6 +251,7 @@ status_t SoftHEVC::initDecoder() {
    WORD32 i4_level;

    mNumCores = GetCPUCoreCount();
    mCodecCtx = NULL;

    /* Initialize number of ref and reorder modes (for HEVC) */
    u4_num_reorder_frames = 16;
@@ -463,7 +466,7 @@ status_t SoftHEVC::reInitDecoder() {
void SoftHEVC::onReset() {
    ALOGD("onReset called");
    SoftVideoDecoderOMXComponent::onReset();

    mSignalledError = false;
    resetDecoder();
    resetPlugin();
}
@@ -473,7 +476,12 @@ OMX_ERRORTYPE SoftHEVC::internalSetParameter(OMX_INDEXTYPE index, const OMX_PTR
    const uint32_t oldHeight = mHeight;
    OMX_ERRORTYPE ret = SoftVideoDecoderOMXComponent::internalSetParameter(index, params);
    if (mWidth != oldWidth || mHeight != oldHeight) {
        reInitDecoder();
        status_t ret = reInitDecoder();
        if (ret != OK) {
            notify(OMX_EventError, OMX_ErrorUnsupportedSetting, ret, NULL);
            mSignalledError = true;
            return OMX_ErrorUnsupportedSetting;
        }
    }
    return ret;
}
@@ -523,6 +531,11 @@ void SoftHEVC::setDecodeArgs(ivd_video_decode_ip_t *ps_dec_ip,
    return;
}
void SoftHEVC::onPortFlushCompleted(OMX_U32 portIndex) {

    if (NULL == mCodecCtx) {
        return;
    }

    /* Once the output buffers are flushed, ignore any buffers that are held in decoder */
    if (kOutputPortIndex == portIndex) {
        setFlushMode();
@@ -548,6 +561,11 @@ void SoftHEVC::onPortFlushCompleted(OMX_U32 portIndex) {
void SoftHEVC::onQueueFilled(OMX_U32 portIndex) {
    UNUSED(portIndex);

    if (mSignalledError) {
        notify(OMX_EventError, OMX_ErrorUnsupportedSetting, UNKNOWN_ERROR, NULL);
        return;
    }

    if (mOutputPortSettingsChange != NONE) {
        return;
    }
@@ -609,7 +627,13 @@ void SoftHEVC::onQueueFilled(OMX_U32 portIndex) {
            bool portWillReset = false;
            handlePortSettingsChange(&portWillReset, mNewWidth, mNewHeight);

            CHECK_EQ(reInitDecoder(), (status_t)OK);
            status_t ret = reInitDecoder();
            if (ret != OK) {
                notify(OMX_EventError, OMX_ErrorUnsupportedSetting, ret, NULL);
                mSignalledError = true;
                return;
            }

            return;
        }

@@ -675,7 +699,12 @@ void SoftHEVC::onQueueFilled(OMX_U32 portIndex) {
                bool portWillReset = false;
                handlePortSettingsChange(&portWillReset, s_dec_op.u4_pic_wd, s_dec_op.u4_pic_ht);

                CHECK_EQ(reInitDecoder(), (status_t)OK);
                status_t ret = reInitDecoder();
                if (ret != OK) {
                    notify(OMX_EventError, OMX_ErrorUnsupportedSetting, ret, NULL);
                    mSignalledError = true;
                    return;
                }

                setDecodeArgs(&s_dec_ip, &s_dec_op, inHeader, outHeader, timeStampIx);

+1 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ private:
    bool mInitNeeded;
    uint32_t mNewWidth;
    uint32_t mNewHeight;
    bool mSignalledError;
    // The input stream has changed to a different resolution, which is still supported by the
    // codec. So the codec is switching to decode the new resolution.
    bool mChangingResolution;
+20 −13
Original line number Diff line number Diff line
@@ -103,19 +103,25 @@ void SoftMPEG4::onQueueFilled(OMX_U32 /* portIndex */) {
    while (!inQueue.empty() && outQueue.size() == kNumOutputBuffers) {
        BufferInfo *inInfo = *inQueue.begin();
        OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader;
        if (inHeader == NULL) {
            inQueue.erase(inQueue.begin());
            inInfo->mOwnedByUs = false;
            continue;
        }

        PortInfo *port = editPortInfo(1);

        OMX_BUFFERHEADERTYPE *outHeader =
            port->mBuffers.editItemAt(mNumSamplesOutput & 1).mHeader;

        if ((inHeader->nFlags & OMX_BUFFERFLAG_EOS) && inHeader->nFilledLen == 0) {
        if (inHeader->nFilledLen == 0) {
            inQueue.erase(inQueue.begin());
            inInfo->mOwnedByUs = false;
            notifyEmptyBufferDone(inHeader);

            ++mInputBufferCount;

            if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) {
                outHeader->nFilledLen = 0;
                outHeader->nFlags = OMX_BUFFERFLAG_EOS;

@@ -131,6 +137,7 @@ void SoftMPEG4::onQueueFilled(OMX_U32 /* portIndex */) {

                notifyFillBufferDone(outHeader);
                outHeader = NULL;
            }
            return;
        }

+9 −1
Original line number Diff line number Diff line
@@ -525,7 +525,15 @@ void SimpleSoftOMXComponent::onPortFlush(
    CHECK_LT(portIndex, mPorts.size());

    PortInfo *port = &mPorts.editItemAt(portIndex);
    CHECK_EQ((int)port->mTransition, (int)PortInfo::NONE);
    // Ideally, the port should not in transitioning state when flushing.
    // However, in error handling case, e.g., the client can't allocate buffers
    // when it tries to re-enable the port, the port will be stuck in ENABLING.
    // The client will then transition the component from Executing to Idle,
    // which leads to flushing ports. At this time, it should be ok to notify
    // the client of the error and still clear all buffers on the port.
    if (port->mTransition != PortInfo::NONE) {
        notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
    }

    for (size_t i = 0; i < port->mBuffers.size(); ++i) {
        BufferInfo *buffer = &port->mBuffers.editItemAt(i);