diff --git a/codec/decoder/core/inc/error_code.h b/codec/decoder/core/inc/error_code.h index 16f85f90..2ce2b0eb 100644 --- a/codec/decoder/core/inc/error_code.h +++ b/codec/decoder/core/inc/error_code.h @@ -92,6 +92,7 @@ ERR_INFO_WRITE_FAULT, ERR_INFO_READ_FAULT, ERR_INFO_READ_OVERFLOW, ERR_INFO_READ_LEADING_ZERO, +ERR_INFO_UNINIT, /* Error from H.264 syntax elements parser: 1001-10000 */ ERR_INFO_NO_PREFIX_CODE = ERR_INFO_SYNTAX_BASE, // No start prefix code indication ERR_INFO_NO_PARAM_SETS, // No SPS and/ PPS before sequence header diff --git a/codec/decoder/core/src/decoder_core.cpp b/codec/decoder/core/src/decoder_core.cpp index 6fd07e1e..841d4730 100644 --- a/codec/decoder/core/src/decoder_core.cpp +++ b/codec/decoder/core/src/decoder_core.cpp @@ -2152,6 +2152,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "DecodeCurrentAccessUnit()::::::PrefetchPic ERROR, pSps->iNumRefFrames:%d.", pCtx->pSps->iNumRefFrames); + // The error code here need to be separated from the dsOutOfMemory pCtx->iErrorCode |= dsOutOfMemory; return ERR_INFO_REF_COUNT_OVERFLOW; } diff --git a/codec/decoder/plus/inc/welsDecoderExt.h b/codec/decoder/plus/inc/welsDecoderExt.h index b40a6655..1abc2dd7 100644 --- a/codec/decoder/plus/inc/welsDecoderExt.h +++ b/codec/decoder/plus/inc/welsDecoderExt.h @@ -111,6 +111,7 @@ welsCodecTrace* m_pWelsTrace; int32_t InitDecoder (const bool); void UninitDecoder (void); +int32_t ResetDecoder(); #ifdef OUTPUT_BIT_STREAM WelsFileHandle* m_pFBS; diff --git a/codec/decoder/plus/src/welsDecoderExt.cpp b/codec/decoder/plus/src/welsDecoderExt.cpp index 34382bfe..0d7db281 100644 --- a/codec/decoder/plus/src/welsDecoderExt.cpp +++ b/codec/decoder/plus/src/welsDecoderExt.cpp @@ -259,6 +259,18 @@ int32_t CWelsDecoder::InitDecoder (const bool bParseOnly) { return WelsInitDecoder (m_pDecContext, bParseOnly, &m_pWelsTrace->m_sLogCtx); } +int32_t CWelsDecoder::ResetDecoder() { + // TBC: need to be modified when context and trace point are null + if (m_pDecContext != NULL && m_pWelsTrace != NULL) { + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "ResetDecoder(), context error code is %d", + m_pDecContext->iErrorCode); + return InitDecoder (m_pDecContext->bParseOnly); + } else if (m_pWelsTrace != NULL) { + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "ResetDecoder() failed as decoder context null"); + } + return ERR_INFO_UNINIT; +} + /* * Set Option */ @@ -488,7 +500,7 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, eNalType = m_pDecContext->sCurNalHead.eNalUnitType; if (m_pDecContext->iErrorCode & dsOutOfMemory) { - ForceResetParaSetStatusAndAUList (m_pDecContext); + ResetDecoder(); } //for AVC bitstream (excluding AVC with temporal scalability, including TP), as long as error occur, SHOULD notify upper layer key frame loss. if ((IS_PARAM_SETS_NALS (eNalType) || NAL_UNIT_CODED_SLICE_IDR == eNalType) ||