Showing the changes to codec/decoder/core/src/decoder_core.cpp (1 of 9 files). Show all
Unified · Split
| @@ -82,7 +82,7 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 81 unmodified lines | |||
| 82 | return -1; | 82 | return -1; |
| 83 | } else if (pCurDq->sLayerInfo.sNalHeaderExt.bIdrFlag | 83 | } else if (pCurDq->sLayerInfo.sNalHeaderExt.bIdrFlag |
| 84 | && (pCtx->iErrorCode == dsErrorFree)) { //complete non-ECed IDR frame done | 84 | && (pCtx->iErrorCode == dsErrorFree)) { //complete non-ECed IDR frame done |
| 85 | pCtx->bDecErrorConedFlag = false; | 85 | pCtx->pDec->bIsComplete = true; |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | pCtx->iTotalNumMbRec = 0; | 88 | pCtx->iTotalNumMbRec = 0; |
| @@ -104,10 +104,12 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 15 unmodified lines | |||
| 104 | pDstInfo->iBufferStatus = 1; | 104 | pDstInfo->iBufferStatus = 1; |
| 105 | 105 | ||
| 106 | if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) //no buffer output if EC is disabled and frame incomplete | 106 | 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 | ||
| 108 | 109 | ||
| 109 | if (!bFrameCompleteFlag) { | 110 | if (pDstInfo->iBufferStatus == 0) { |
| 110 | pCtx->iErrorCode |= dsBitstreamError; | 111 | if (!bFrameCompleteFlag) |
| 112 | pCtx->iErrorCode |= dsBitstreamError; | ||
| 111 | return -1; | 113 | return -1; |
| 112 | } | 114 | } |
| 113 | 115 | ||
| @@ -1780,6 +1782,8 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 1666 unmodified lines | |||
| 1780 | int32_t iPpsId = 0; | 1782 | int32_t iPpsId = 0; |
| 1781 | int32_t iRet = ERR_NONE; | 1783 | int32_t iRet = ERR_NONE; |
| 1782 | 1784 | ||
| 1785 | bool bAllRefComplete = true; // Assume default all ref picutres are complete | ||
| 1786 | |||
| 1783 | const uint8_t kuiTargetLayerDqId = GetTargetDqId (pCtx->uiTargetDqId, pCtx->pParam); | 1787 | const uint8_t kuiTargetLayerDqId = GetTargetDqId (pCtx->uiTargetDqId, pCtx->pParam); |
| 1784 | const uint8_t kuiDependencyIdMax = (kuiTargetLayerDqId & 0x7F) >> 4; | 1788 | const uint8_t kuiDependencyIdMax = (kuiTargetLayerDqId & 0x7F) >> 4; |
| 1785 | int16_t iLastIdD = -1, iLastIdQ = -1; | 1789 | int16_t iLastIdD = -1, iLastIdQ = -1; |
| @@ -1889,6 +1893,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 103 unmodified lines | |||
| 1889 | "referencing pictures lost due frame gaps exist, prev_frame_num: %d, curr_frame_num: %d", pCtx->iPrevFrameNum, | 1893 | "referencing pictures lost due frame gaps exist, prev_frame_num: %d, curr_frame_num: %d", pCtx->iPrevFrameNum, |
| 1890 | pSh->iFrameNum); | 1894 | pSh->iFrameNum); |
| 1891 | 1895 | ||
| 1896 | bAllRefComplete = false; | ||
| 1892 | pCtx->iErrorCode |= dsRefLost; | 1897 | pCtx->iErrorCode |= dsRefLost; |
| 1893 | if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) { | 1898 | if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) { |
| 1894 | #ifdef LONG_TERM_REF | 1899 | #ifdef LONG_TERM_REF |
| @@ -1905,6 +1910,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 10 unmodified lines | |||
| 1905 | if (iCurrIdD == kuiDependencyIdMax && iCurrIdQ == BASE_QUALITY_ID) { | 1910 | if (iCurrIdD == kuiDependencyIdMax && iCurrIdQ == BASE_QUALITY_ID) { |
| 1906 | iRet = InitRefPicList (pCtx, uiNalRefIdc, pSh->iPicOrderCntLsb); | 1911 | iRet = InitRefPicList (pCtx, uiNalRefIdc, pSh->iPicOrderCntLsb); |
| 1907 | if (iRet) { | 1912 | if (iRet) { |
| 1913 | bAllRefComplete = false; // RPLR error, set ref pictures complete flag false | ||
| 1908 | HandleReferenceLost (pCtx, pNalCur); | 1914 | HandleReferenceLost (pCtx, pNalCur); |
| 1909 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, | 1915 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, |
| 1910 | "reference picture introduced by this frame is lost during transmission! uiTId: %d", | 1916 | "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 | |||
| 1922 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, | 1928 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, |
| 1923 | "DecodeCurrentAccessUnit() failed (%d) in frame: %d uiDId: %d uiQId: %d", | 1929 | "DecodeCurrentAccessUnit() failed (%d) in frame: %d uiDId: %d uiQId: %d", |
| 1924 | iRet, pSh->iFrameNum, iCurrIdD, iCurrIdQ); | 1930 | iRet, pSh->iFrameNum, iCurrIdD, iCurrIdQ); |
| 1931 | bAllRefComplete = false; | ||
| 1925 | HandleReferenceLostL0 (pCtx, pNalCur); | 1932 | HandleReferenceLostL0 (pCtx, pNalCur); |
| 1926 | if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) { | 1933 | if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) { |
| 1927 | return iRet; | 1934 | return iRet; |
| @@ -1929,9 +1936,13 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 1 unmodified line | |||
| 1929 | } | 1936 | } |
| 1930 | if (bReconstructSlice) { | 1937 | if (bReconstructSlice) { |
| 1931 | if (WelsDecodeConstructSlice (pCtx, pNalCur)) { | 1938 | if (WelsDecodeConstructSlice (pCtx, pNalCur)) { |
| 1939 | pCtx->pDec->bIsComplete = false; // reconstruction error, directly set the flag false | ||
| 1932 | return -1; | 1940 | return -1; |
| 1933 | } | 1941 | } |
| 1934 | } | 1942 | } |
| 1943 | if (bAllRefComplete && (pCtx->sRefPic.uiRefCount[LIST_0] > 0 || pCtx->eSliceType != I_SLICE)) { | ||
| 1944 | bAllRefComplete &= bCheckRefPicturesComplete (pCtx); | ||
| 1945 | } | ||
| 1935 | } | 1946 | } |
| 1936 | #if defined (_DEBUG) && !defined (CODEC_FOR_TESTBED) | 1947 | #if defined (_DEBUG) && !defined (CODEC_FOR_TESTBED) |
| 1937 | fprintf (stderr, "cur_frame : %d iCurrIdD : %d\n ", | 1948 | fprintf (stderr, "cur_frame : %d iCurrIdD : %d\n ", |
| @@ -1954,6 +1965,12 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 16 unmodified lines | |||
| 1954 | break; | 1965 | break; |
| 1955 | } | 1966 | } |
| 1956 | 1967 | ||
| 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 | |||
| 1957 | // A dq layer decoded here | 1974 | // A dq layer decoded here |
| 1958 | #if defined (_DEBUG) && !defined (CODEC_FOR_TESTBED) | 1975 | #if defined (_DEBUG) && !defined (CODEC_FOR_TESTBED) |
| 1959 | #undef fprintf | 1976 | #undef fprintf |
| @@ -2031,4 +2048,42 @@ bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferIn · 71 unmodified lines | |||
| 2031 | } | 2048 | } |
| 2032 | return ERR_NONE; | 2049 | return ERR_NONE; |
| 2033 | } | 2050 | } |
| 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 | } | ||
| 2034 | } // namespace WelsDec | 2089 | } // namespace WelsDec |