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

Commit 169e6aca authored by Harish Mahendrakar's avatar Harish Mahendrakar Committed by Pawin Vongmasa
Browse files

RESTRICT AUTOMERGE SoftHEVC: Handle error in reInitDecoder()

Returning an error instead of calling CHECK_EQ for reInitDecoder failure

Bug: 65483665
Bug: 76181200
Bug: 77312549
Change-Id: I49d2fef1d30c94388174a0cc7d00453fd0d5925e
(cherry picked from commit e79df347)
parent edcb4521
Loading
Loading
Loading
Loading
+33 −4
Original line number Original line Diff line number Diff line
@@ -68,12 +68,14 @@ SoftHEVC::SoftHEVC(
            kProfileLevels, ARRAY_SIZE(kProfileLevels),
            kProfileLevels, ARRAY_SIZE(kProfileLevels),
            320 /* width */, 240 /* height */, callbacks,
            320 /* width */, 240 /* height */, callbacks,
            appData, component),
            appData, component),
      mCodecCtx(NULL),
      mMemRecords(NULL),
      mMemRecords(NULL),
      mFlushOutBuffer(NULL),
      mFlushOutBuffer(NULL),
      mOmxColorFormat(OMX_COLOR_FormatYUV420Planar),
      mOmxColorFormat(OMX_COLOR_FormatYUV420Planar),
      mIvColorFormat(IV_YUV_420P),
      mIvColorFormat(IV_YUV_420P),
      mNewWidth(mWidth),
      mNewWidth(mWidth),
      mNewHeight(mHeight),
      mNewHeight(mHeight),
      mSignalledError(false),
      mChangingResolution(false) {
      mChangingResolution(false) {
    const size_t kMinCompressionRatio = 4 /* compressionRatio (for Level 4+) */;
    const size_t kMinCompressionRatio = 4 /* compressionRatio (for Level 4+) */;
    const size_t kMaxOutputBufferSize = 2048 * 2048 * 3 / 2;
    const size_t kMaxOutputBufferSize = 2048 * 2048 * 3 / 2;
@@ -251,6 +253,7 @@ status_t SoftHEVC::initDecoder() {
    WORD32 i4_level;
    WORD32 i4_level;


    mNumCores = GetCPUCoreCount();
    mNumCores = GetCPUCoreCount();
    mCodecCtx = NULL;


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

    mSignalledError = false;
    resetDecoder();
    resetDecoder();
    resetPlugin();
    resetPlugin();
}
}
@@ -475,7 +478,12 @@ OMX_ERRORTYPE SoftHEVC::internalSetParameter(OMX_INDEXTYPE index, const OMX_PTR
    const uint32_t oldHeight = mHeight;
    const uint32_t oldHeight = mHeight;
    OMX_ERRORTYPE ret = SoftVideoDecoderOMXComponent::internalSetParameter(index, params);
    OMX_ERRORTYPE ret = SoftVideoDecoderOMXComponent::internalSetParameter(index, params);
    if (mWidth != oldWidth || mHeight != oldHeight) {
    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;
    return ret;
}
}
@@ -530,6 +538,11 @@ bool SoftHEVC::setDecodeArgs(ivd_video_decode_ip_t *ps_dec_ip,
    return true;
    return true;
}
}
void SoftHEVC::onPortFlushCompleted(OMX_U32 portIndex) {
void SoftHEVC::onPortFlushCompleted(OMX_U32 portIndex) {

    if (NULL == mCodecCtx) {
        return;
    }

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


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

    if (mOutputPortSettingsChange != NONE) {
    if (mOutputPortSettingsChange != NONE) {
        return;
        return;
    }
    }
@@ -616,7 +634,13 @@ void SoftHEVC::onQueueFilled(OMX_U32 portIndex) {
            bool portWillReset = false;
            bool portWillReset = false;
            handlePortSettingsChange(&portWillReset, mNewWidth, mNewHeight);
            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;
            return;
        }
        }


@@ -686,7 +710,12 @@ void SoftHEVC::onQueueFilled(OMX_U32 portIndex) {
                bool portWillReset = false;
                bool portWillReset = false;
                handlePortSettingsChange(&portWillReset, s_dec_op.u4_pic_wd, s_dec_op.u4_pic_ht);
                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);
                setDecodeArgs(&s_dec_ip, &s_dec_op, inHeader, outHeader, timeStampIx);


+1 −0
Original line number Original line Diff line number Diff line
@@ -98,6 +98,7 @@ private:
    bool mInitNeeded;
    bool mInitNeeded;
    uint32_t mNewWidth;
    uint32_t mNewWidth;
    uint32_t mNewHeight;
    uint32_t mNewHeight;
    bool mSignalledError;
    // The input stream has changed to a different resolution, which is still supported by the
    // 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.
    // codec. So the codec is switching to decode the new resolution.
    bool mChangingResolution;
    bool mChangingResolution;