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

Commit e79df347 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
Merged-In: I49d2fef1d30c94388174a0cc7d00453fd0d5925e
Change-Id: I49d2fef1d30c94388174a0cc7d00453fd0d5925e
parent 4bd71033
Loading
Loading
Loading
Loading
+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;