From 2ff38e9175704518cc5ea3cd7d37063760041089 Mon Sep 17 00:00:00 2001 From: Sijia Chen Date: Wed, 10 Jun 2015 11:28:23 +0800 Subject: [PATCH] make two un-error ending of encoding go to a same exit and save the duplicated calling of UpdateSpatialPictures and ForceCodingIDR --- codec/encoder/core/src/encoder_ext.cpp | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/codec/encoder/core/src/encoder_ext.cpp b/codec/encoder/core/src/encoder_ext.cpp index e7f9c011..da333f95 100644 --- a/codec/encoder/core/src/encoder_ext.cpp +++ b/codec/encoder/core/src/encoder_ext.cpp @@ -3859,15 +3859,12 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour pCtx->pFuncList->pMarkPic (pCtx); if (!pCtx->pFuncList->pBuildRefList (pCtx, pCtx->iPOC, 0)) { - pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, iDidIdx); - // Force coding IDR as followed - ForceCodingIDR (pCtx); WelsLog (pLogCtx, WELS_LOG_WARNING, "WelsEncoderEncodeExt(), WelsBuildRefList failed for P frames, pCtx->iNumRef0= %d. ForceCodingIDR!", pCtx->iNumRef0); - pFbi->eFrameType = videoFrameTypeIDR; + eFrameType = videoFrameTypeIDR; pCtx->iEncoderError = ENC_RETURN_CORRECTED; - return ENC_RETURN_CORRECTED; + break; } if (pCtx->eSliceType != I_SLICE) { pCtx->pFuncList->pAfterBuildRefList (pCtx); @@ -4134,13 +4131,10 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour // reference picture list update if (eNalRefIdc != NRI_PRI_LOWEST) { if (!pCtx->pFuncList->pUpdateRefList (pCtx)) { - pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, iDidIdx); - // Force coding IDR as followed - ForceCodingIDR (pCtx); WelsLog (pLogCtx, WELS_LOG_WARNING, "WelsEncoderEncodeExt(), WelsUpdateRefList failed. ForceCodingIDR!"); //the above is to set the next frame to be IDR - pFbi->eFrameType = eFrameType; - return ENC_RETURN_CORRECTED; + pCtx->iEncoderError = ENC_RETURN_CORRECTED; + break; } } @@ -4293,7 +4287,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour if (pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, iDidIdx) != 0) { ForceCodingIDR (pCtx); - WelsLog (pLogCtx, WELS_LOG_WARNING, "WelsEncoderEncodeExt(), Logic Error Found in temporal level. ForceCodingIDR!"); + WelsLog (pLogCtx, WELS_LOG_WARNING, + "WelsEncoderEncodeExt(), Logic Error Found in Preprocess updating. ForceCodingIDR!"); //the above is to set the next frame IDR pFbi->eFrameType = eFrameType; return ENC_RETURN_CORRECTED; @@ -4305,6 +4300,15 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour } } + if (ENC_RETURN_CORRECTED == pCtx->iEncoderError) { + pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, (pSpatialIndexMap + iSpatialIdx)->iDid); + ForceCodingIDR (pCtx); + WelsLog (pLogCtx, WELS_LOG_WARNING, "WelsEncoderEncodeExt(), Logic Error Found in temporal level. ForceCodingIDR!"); + //the above is to set the next frame IDR + pFbi->eFrameType = eFrameType; + return ENC_RETURN_CORRECTED; + } + #if defined(MT_DEBUG) TrackSliceConsumeTime (pCtx, iDidList, iSpatialNum); #endif//MT_DEBUG