Force reset decoder when out of memory error

This commit is contained in:
Haibo Zhu 2015-08-25 01:05:47 -07:00
parent ab4e0df75a
commit 27a9af0b09
4 changed files with 16 additions and 1 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -258,6 +258,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
*/
@ -487,7 +499,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) ||