History

Add picture bIsComplete flag to reflect the status of decoder Modify the output error status and add some some judgement

Haibo Zhu committed 12 years ago

Commit 9d182ee1 parent 614e8989 files · +113 −59Browse files

Showing the changes to codec/decoder/core/src/decoder_core.cpp (1 of 9 files). Show all

Unified · Split

codec/decoder/core/src/decoder_core.cpp+59−4
@@ -82,7 +82,7 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 81 unmodified lines
8282 return -1;
8383 } else if (pCurDq->sLayerInfo.sNalHeaderExt.bIdrFlag
8484 && (pCtx->iErrorCode == dsErrorFree)) { //complete non-ECed IDR frame done
85− pCtx->bDecErrorConedFlag = false;
85+ pCtx->pDec->bIsComplete = true;
8686 }
8787
8888 pCtx->iTotalNumMbRec = 0;
@@ -104,10 +104,12 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 15 unmodified lines
104104 pDstInfo->iBufferStatus = 1;
105105
106106 if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) //no buffer output if EC is disabled and frame incomplete
107− pDstInfo->iBufferStatus = (int32_t) bFrameCompleteFlag;
107+ pDstInfo->iBufferStatus = (int32_t) (bFrameCompleteFlag
108+ && pPic->bIsComplete); // When EC disable, ECed picture not output
108109
109− if (!bFrameCompleteFlag) {
110− pCtx->iErrorCode |= dsBitstreamError;
110+ if (pDstInfo->iBufferStatus == 0) {
111+ if (!bFrameCompleteFlag)
112+ pCtx->iErrorCode |= dsBitstreamError;
111113 return -1;
112114 }
113115
@@ -1780,6 +1782,8 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 1666 unmodified lines
17801782 int32_t iPpsId = 0;
17811783 int32_t iRet = ERR_NONE;
17821784
1785+ bool bAllRefComplete = true; // Assume default all ref picutres are complete
1786+
17831787 const uint8_t kuiTargetLayerDqId = GetTargetDqId (pCtx->uiTargetDqId, pCtx->pParam);
17841788 const uint8_t kuiDependencyIdMax = (kuiTargetLayerDqId & 0x7F) >> 4;
17851789 int16_t iLastIdD = -1, iLastIdQ = -1;
@@ -1889,6 +1893,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 103 unmodified lines
18891893 "referencing pictures lost due frame gaps exist, prev_frame_num: %d, curr_frame_num: %d", pCtx->iPrevFrameNum,
18901894 pSh->iFrameNum);
18911895
1896+ bAllRefComplete = false;
18921897 pCtx->iErrorCode |= dsRefLost;
18931898 if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) {
18941899 #ifdef LONG_TERM_REF
@@ -1905,6 +1910,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 10 unmodified lines
19051910 if (iCurrIdD == kuiDependencyIdMax && iCurrIdQ == BASE_QUALITY_ID) {
19061911 iRet = InitRefPicList (pCtx, uiNalRefIdc, pSh->iPicOrderCntLsb);
19071912 if (iRet) {
1913+ bAllRefComplete = false; // RPLR error, set ref pictures complete flag false
19081914 HandleReferenceLost (pCtx, pNalCur);
19091915 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
19101916 "reference picture introduced by this frame is lost during transmission! uiTId: %d",
@@ -1922,6 +1928,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 11 unmodified lines
19221928 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
19231929 "DecodeCurrentAccessUnit() failed (%d) in frame: %d uiDId: %d uiQId: %d",
19241930 iRet, pSh->iFrameNum, iCurrIdD, iCurrIdQ);
1931+ bAllRefComplete = false;
19251932 HandleReferenceLostL0 (pCtx, pNalCur);
19261933 if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) {
19271934 return iRet;
@@ -1929,9 +1936,13 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 1 unmodified line
19291936 }
19301937 if (bReconstructSlice) {
19311938 if (WelsDecodeConstructSlice (pCtx, pNalCur)) {
1939+ pCtx->pDec->bIsComplete = false; // reconstruction error, directly set the flag false
19321940 return -1;
19331941 }
19341942 }
1943+ if (bAllRefComplete && (pCtx->sRefPic.uiRefCount[LIST_0] > 0 || pCtx->eSliceType != I_SLICE)) {
1944+ bAllRefComplete &= bCheckRefPicturesComplete (pCtx);
1945+ }
19351946 }
19361947 #if defined (_DEBUG) && !defined (CODEC_FOR_TESTBED)
19371948 fprintf (stderr, "cur_frame : %d iCurrIdD : %d\n ",
@@ -1954,6 +1965,12 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 16 unmodified lines
19541965 break;
19551966 }
19561967
1968+ // Set the current dec picture complete flag. The flag will be reset when current picture need do ErrorCon.
1969+ pCtx->pDec->bIsComplete = bAllRefComplete;
1970+ if (!pCtx->pDec->bIsComplete) { // Ref pictures ECed, result in ECed
1971+ pCtx->iErrorCode |= dsDataErrorConcealed;
1972+ }
1973+
19571974 // A dq layer decoded here
19581975 #if defined (_DEBUG) && !defined (CODEC_FOR_TESTBED)
19591976 #undef fprintf
@@ -2031,4 +2048,42 @@ bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferIn · 71 unmodified lines
20312048 }
20322049 return ERR_NONE;
20332050 }
2051+
2052+bool bCheckRefPicturesComplete (PWelsDecoderContext pCtx) {
2053+ // Multi Reference, RefIdx may differ
2054+ bool bAllRefComplete = true;
2055+ int32_t iRealMbIdx;
2056+ for (int32_t iMbIdx = 0; bAllRefComplete
2057+ && iMbIdx < pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer.iTotalMbInCurSlice; iMbIdx++) {
2058+ iRealMbIdx = pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iFirstMbInSlice + iMbIdx;
2059+ switch (pCtx->pCurDqLayer->pMbType[iRealMbIdx]) {
2060+ case MB_TYPE_SKIP:
2061+ case MB_TYPE_16x16:
2062+ bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
2063+ break;
2064+
2065+ case MB_TYPE_16x8:
2066+ bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
2067+ bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][8] ]->bIsComplete;
2068+ break;
2069+
2070+ case MB_TYPE_8x16:
2071+ bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
2072+ bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][2] ]->bIsComplete;
2073+ break;
2074+
2075+ case MB_TYPE_8x8:
2076+ case MB_TYPE_8x8_REF0:
2077+ bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
2078+ bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][2] ]->bIsComplete;
2079+ bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][8] ]->bIsComplete;
2080+ bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][10] ]->bIsComplete;
2081+ break;
2082+
2083+ default:
2084+ break;
2085+ }
2086+ }
2087+ return bAllRefComplete;
2088+}
20342089 } // namespace WelsDec

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t