Showing the changes to codec/decoder/core/src/decoder_core.cpp (1 of 1 file). Show all
Unified · Split
| @@ -45,8 +45,6 @@ · 44 unmodified lines | ||
| 45 | 45 | |
| 46 | 46 | namespace WelsDec { |
| 47 | 47 | static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) { |
| 48 | − if (pDstInfo == NULL) //parse only usage | |
| 49 | − return -1; | |
| 50 | 48 | PDqLayer pCurDq = pCtx->pCurDqLayer; |
| 51 | 49 | PPicture pPic = pCtx->pDec; |
| 52 | 50 | |
| @@ -89,6 +87,15 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 36 unmodified lines | ||
| 89 | 87 | |
| 90 | 88 | pCtx->iTotalNumMbRec = 0; |
| 91 | 89 | |
| 90 | + if (pCtx->bParseOnly) { //should exit for parse only to prevent access NULL pDstInfo | |
| 91 | + if (bFrameCompleteFlag) | |
| 92 | + return 0; | |
| 93 | + else { //incomplete frame | |
| 94 | + pCtx->pDec->bIsComplete = false; | |
| 95 | + return -1; | |
| 96 | + } | |
| 97 | + } | |
| 98 | + | |
| 92 | 99 | //////output:::normal path |
| 93 | 100 | pDstInfo->uiOutYuvTimeStamp = pPic->uiTimeStamp; |
| 94 | 101 | ppDst[0] = pPic->pData[0]; |
| @@ -1741,6 +1748,10 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI · 1646 unmodified lines | ||
| 1741 | 1748 | ForceResetCurrentAccessUnit (pCtx->pAccessUnitList); |
| 1742 | 1749 | if (!pCtx->bParseOnly) |
| 1743 | 1750 | pDstInfo->iBufferStatus = 0; |
| 1751 | + pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || pCtx->bNextNewSeqBegin; | |
| 1752 | + pCtx->bNextNewSeqBegin = false; // reset it | |
| 1753 | + if (pCtx->bNewSeqBegin) | |
| 1754 | + ResetActiveSPSForEachLayer (pCtx); | |
| 1744 | 1755 | return iErr; |
| 1745 | 1756 | } |
| 1746 | 1757 | |
| @@ -1758,12 +1769,10 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI · 11 unmodified lines | ||
| 1758 | 1769 | } |
| 1759 | 1770 | } |
| 1760 | 1771 | |
| 1761 | − | |
| 1762 | 1772 | iErr = DecodeCurrentAccessUnit (pCtx, ppDst, pDstInfo); |
| 1763 | 1773 | |
| 1764 | 1774 | if (pCtx->bParseOnly) { |
| 1765 | − if ((dsErrorFree == pCtx->iErrorCode) | |
| 1766 | − && ((uint32_t) pCtx->iTotalNumMbRec == pCtx->pSps->iMbHeight * pCtx->pSps->iMbWidth)) { | |
| 1775 | + if ((dsErrorFree == pCtx->iErrorCode) && (iErr == 0)) { //frame complete, output | |
| 1767 | 1776 | SParserBsInfo* pParser = pCtx->pParserBsInfo; |
| 1768 | 1777 | uint8_t* pDstBuf = pParser->pDstBuff; |
| 1769 | 1778 | SNalUnit* pCurNal = NULL; |
| @@ -1802,14 +1811,12 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI · 32 unmodified lines | ||
| 1802 | 1811 | memcpy (pDstBuf, pNalBs, iNalLen); |
| 1803 | 1812 | pDstBuf += iNalLen; |
| 1804 | 1813 | } |
| 1805 | − pCtx->iTotalNumMbRec = 0; | |
| 1806 | 1814 | } else { //error |
| 1807 | 1815 | pCtx->pParserBsInfo->uiOutBsTimeStamp = 0; |
| 1808 | 1816 | pCtx->pParserBsInfo->iNalNum = 0; |
| 1809 | 1817 | pCtx->pParserBsInfo->iSpsWidthInPixel = 0; |
| 1810 | 1818 | pCtx->pParserBsInfo->iSpsHeightInPixel = 0; |
| 1811 | 1819 | if (dsErrorFree == pCtx->iErrorCode) { //frame not complete |
| 1812 | − pCtx->iTotalNumMbRec = 0; | |
| 1813 | 1820 | pCtx->iErrorCode |= dsFramePending; |
| 1814 | 1821 | } |
| 1815 | 1822 | } |
| @@ -2129,10 +2136,6 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 313 unmodified lines | ||
| 2129 | 2136 | pCtx->pDec->bIsComplete = bAllRefComplete; |
| 2130 | 2137 | if (!pCtx->pDec->bIsComplete) { // Ref pictures ECed, result in ECed |
| 2131 | 2138 | pCtx->iErrorCode |= dsDataErrorConcealed; |
| 2132 | − } else if (pCtx->bParseOnly) { | |
| 2133 | − pCtx->pDec->bIsComplete = (pCtx->iTotalNumMbRec == pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight); | |
| 2134 | − if (!pCtx->pDec->bIsComplete) | |
| 2135 | − return -1; | |
| 2136 | 2139 | } |
| 2137 | 2140 | |
| 2138 | 2141 | // A dq layer decoded here |
| @@ -2144,8 +2147,8 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 5 unmodified lines | ||
| 2144 | 2147 | #endif//#if !CODEC_FOR_TESTBED |
| 2145 | 2148 | |
| 2146 | 2149 | if (dq_cur->uiLayerDqId == kuiTargetLayerDqId) { |
| 2147 | − if (!pCtx->bParseOnly) { | |
| 2148 | − if (!pCtx->bInstantDecFlag) { | |
| 2150 | + if (!pCtx->bInstantDecFlag) { | |
| 2151 | + if (!pCtx->bParseOnly) { | |
| 2149 | 2152 | //Do error concealment here |
| 2150 | 2153 | if ((NeedErrorCon (pCtx)) && (pCtx->eErrorConMethod != ERROR_CON_DISABLE)) { |
| 2151 | 2154 | ImplementErrorCon (pCtx); |
| @@ -2154,11 +2157,12 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 2 unmodified lines | ||
| 2154 | 2157 | pCtx->pDec->iPpsId = pCtx->pPps->iPpsId; |
| 2155 | 2158 | } |
| 2156 | 2159 | } |
| 2157 | − | |
| 2158 | − if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) { | |
| 2159 | − return ERR_NONE; | |
| 2160 | − } | |
| 2161 | 2160 | } |
| 2161 | + | |
| 2162 | + iRet = DecodeFrameConstruction (pCtx, ppDst, pDstInfo); | |
| 2163 | + if (iRet) | |
| 2164 | + return iRet; | |
| 2165 | + | |
| 2162 | 2166 | pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //store latest decoded picture for EC |
| 2163 | 2167 | if (uiNalRefIdc > 0) { |
| 2164 | 2168 | iRet = WelsMarkAsRef (pCtx); |