Showing the changes to codec/decoder/core/src/decoder_core.cpp (1 of 13 files). Show all
Unified · Split
| @@ -88,21 +88,23 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 87 unmodified lines | ||
| 88 | 88 | |
| 89 | 89 | pCtx->iTotalNumMbRec = 0; |
| 90 | 90 | |
| 91 | − //////output:::normal path | |
| 92 | − ppDst[0] = pPic->pData[0]; | |
| 93 | − ppDst[1] = pPic->pData[1]; | |
| 94 | − ppDst[2] = pPic->pData[2]; | |
| 95 | − | |
| 96 | − pDstInfo->UsrData.sSystemBuffer.iFormat = videoFormatI420; | |
| 97 | − | |
| 98 | − pDstInfo->UsrData.sSystemBuffer.iWidth = kiWidth - (pCtx->sFrameCrop.iLeftOffset + pCtx->sFrameCrop.iRightOffset) * 2; | |
| 99 | − pDstInfo->UsrData.sSystemBuffer.iHeight = kiHeight - (pCtx->sFrameCrop.iTopOffset + pCtx->sFrameCrop.iBottomOffset) * 2; | |
| 100 | − pDstInfo->UsrData.sSystemBuffer.iStride[0] = pPic->iLinesize[0]; | |
| 101 | − pDstInfo->UsrData.sSystemBuffer.iStride[1] = pPic->iLinesize[1]; | |
| 102 | − ppDst[0] = ppDst[0] + pCtx->sFrameCrop.iTopOffset * 2 * pPic->iLinesize[0] + pCtx->sFrameCrop.iLeftOffset * 2; | |
| 103 | − ppDst[1] = ppDst[1] + pCtx->sFrameCrop.iTopOffset * pPic->iLinesize[1] + pCtx->sFrameCrop.iLeftOffset; | |
| 104 | − ppDst[2] = ppDst[2] + pCtx->sFrameCrop.iTopOffset * pPic->iLinesize[1] + pCtx->sFrameCrop.iLeftOffset; | |
| 105 | − pDstInfo->iBufferStatus = 1; | |
| 91 | + if (!pCtx->bParseOnly) { | |
| 92 | + //////output:::normal path | |
| 93 | + ppDst[0] = pPic->pData[0]; | |
| 94 | + ppDst[1] = pPic->pData[1]; | |
| 95 | + ppDst[2] = pPic->pData[2]; | |
| 96 | + | |
| 97 | + pDstInfo->UsrData.sSystemBuffer.iFormat = videoFormatI420; | |
| 98 | + | |
| 99 | + pDstInfo->UsrData.sSystemBuffer.iWidth = kiWidth - (pCtx->sFrameCrop.iLeftOffset + pCtx->sFrameCrop.iRightOffset) * 2; | |
| 100 | + pDstInfo->UsrData.sSystemBuffer.iHeight = kiHeight - (pCtx->sFrameCrop.iTopOffset + pCtx->sFrameCrop.iBottomOffset) * 2; | |
| 101 | + pDstInfo->UsrData.sSystemBuffer.iStride[0] = pPic->iLinesize[0]; | |
| 102 | + pDstInfo->UsrData.sSystemBuffer.iStride[1] = pPic->iLinesize[1]; | |
| 103 | + ppDst[0] = ppDst[0] + pCtx->sFrameCrop.iTopOffset * 2 * pPic->iLinesize[0] + pCtx->sFrameCrop.iLeftOffset * 2; | |
| 104 | + ppDst[1] = ppDst[1] + pCtx->sFrameCrop.iTopOffset * pPic->iLinesize[1] + pCtx->sFrameCrop.iLeftOffset; | |
| 105 | + ppDst[2] = ppDst[2] + pCtx->sFrameCrop.iTopOffset * pPic->iLinesize[1] + pCtx->sFrameCrop.iLeftOffset; | |
| 106 | + pDstInfo->iBufferStatus = 1; | |
| 107 | + } | |
| 106 | 108 | |
| 107 | 109 | bool bOutResChange = (pCtx->iLastImgWidthInPixel != pDstInfo->UsrData.sSystemBuffer.iWidth) |
| 108 | 110 | || (pCtx->iLastImgHeightInPixel != pDstInfo->UsrData.sSystemBuffer.iHeight); |
| @@ -114,7 +116,6 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 5 unmodified lines | ||
| 114 | 116 | else if (pCtx->eErrorConMethod == ERROR_CON_SLICE_COPY_CROSS_IDR_FREEZE_RES_CHANGE && pCtx->iErrorCode && bOutResChange) |
| 115 | 117 | pCtx->bFreezeOutput = true; |
| 116 | 118 | |
| 117 | − | |
| 118 | 119 | if ((pDstInfo->iBufferStatus == 1) && (pCurDq->sLayerInfo.sNalHeaderExt.bIdrFlag)) { |
| 119 | 120 | if (pPic->bIsComplete) |
| 120 | 121 | pCtx->sDecoderStatistics.uiIDRRecvNum++; |
| @@ -331,6 +332,14 @@ int32_t InitBsBuffer (PWelsDecoderContext pCtx) { · 210 unmodified lines | ||
| 331 | 332 | } |
| 332 | 333 | pCtx->sRawData.pStartPos = pCtx->sRawData.pCurPos = pCtx->sRawData.pHead; |
| 333 | 334 | pCtx->sRawData.pEnd = pCtx->sRawData.pHead + pCtx->iMaxBsBufferSizeInByte; |
| 335 | + if (pCtx->bParseOnly) { | |
| 336 | + if ((pCtx->sSavedData.pHead = static_cast<uint8_t*> (WelsMalloc (pCtx->iMaxBsBufferSizeInByte, | |
| 337 | + "pCtx->sSavedData.pHead"))) == NULL) { | |
| 338 | + return ERR_INFO_OUT_OF_MEMORY; | |
| 339 | + } | |
| 340 | + pCtx->sSavedData.pStartPos = pCtx->sSavedData.pCurPos = pCtx->sSavedData.pHead; | |
| 341 | + pCtx->sSavedData.pEnd = pCtx->sSavedData.pHead + pCtx->iMaxBsBufferSizeInByte; | |
| 342 | + } | |
| 334 | 343 | return ERR_NONE; |
| 335 | 344 | } |
| 336 | 345 | |
| @@ -434,6 +443,13 @@ void WelsFreeMemory (PWelsDecoderContext pCtx) { · 97 unmodified lines | ||
| 434 | 443 | pCtx->sRawData.pEnd = NULL; |
| 435 | 444 | pCtx->sRawData.pStartPos = NULL; |
| 436 | 445 | pCtx->sRawData.pCurPos = NULL; |
| 446 | + if (pCtx->sSavedData.pHead) { | |
| 447 | + WelsFree (pCtx->sSavedData.pHead, "pCtx->sSavedData->pHead"); | |
| 448 | + } | |
| 449 | + pCtx->sSavedData.pHead = NULL; | |
| 450 | + pCtx->sSavedData.pEnd = NULL; | |
| 451 | + pCtx->sSavedData.pStartPos = NULL; | |
| 452 | + pCtx->sSavedData.pCurPos = NULL; | |
| 437 | 453 | } |
| 438 | 454 | |
| 439 | 455 | /* |
| @@ -1692,7 +1708,8 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI · 1252 unmodified lines | ||
| 1692 | 1708 | |
| 1693 | 1709 | if (ERR_NONE != iErr) { |
| 1694 | 1710 | ForceResetCurrentAccessUnit (pCtx->pAccessUnitList); |
| 1695 | − pDstInfo->iBufferStatus = 0; | |
| 1711 | + if (!pCtx->bParseOnly) | |
| 1712 | + pDstInfo->iBufferStatus = 0; | |
| 1696 | 1713 | return iErr; |
| 1697 | 1714 | } |
| 1698 | 1715 | |
| @@ -1713,6 +1730,53 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI · 14 unmodified lines | ||
| 1713 | 1730 | |
| 1714 | 1731 | iErr = DecodeCurrentAccessUnit (pCtx, ppDst, pDstInfo); |
| 1715 | 1732 | |
| 1733 | + if (pCtx->bParseOnly) { | |
| 1734 | + if (dsErrorFree == pCtx->iErrorCode) { | |
| 1735 | + SParserBsInfo* pParser = pCtx->pParserBsInfo; | |
| 1736 | + uint8_t* pDstBuf = pParser->pDstBuff; | |
| 1737 | + SNalUnit* pCurNal = NULL; | |
| 1738 | + int32_t iNalLen = 0; | |
| 1739 | + int32_t iIdx = pCurAu->uiStartPos; | |
| 1740 | + int32_t iEndIdx = pCurAu->uiEndPos; | |
| 1741 | + uint8_t* pNalBs = NULL; | |
| 1742 | + | |
| 1743 | + pParser->iNalNum = 0; | |
| 1744 | + pParser->iSpsWidthInPixel = (pCtx->pSps->iMbWidth << 4); | |
| 1745 | + pParser->iSpsHeightInPixel = (pCtx->pSps->iMbHeight << 4); | |
| 1746 | + | |
| 1747 | + if (pCurAu->pNalUnitsList [iIdx]->sNalHeaderExt.bIdrFlag) { //IDR | |
| 1748 | + bool bSubSps = (NAL_UNIT_CODED_SLICE_EXT == pCurAu->pNalUnitsList [iIdx]->sNalHeaderExt.sNalUnitHeader.eNalUnitType); | |
| 1749 | + SSpsBsInfo* pSpsBs = NULL; | |
| 1750 | + SPpsBsInfo* pPpsBs = NULL; | |
| 1751 | + int32_t iSpsId = pCtx->pSps->iSpsId; | |
| 1752 | + int32_t iPpsId = pCtx->pPps->iPpsId; | |
| 1753 | + pCtx->bParamSetsLostFlag = false; | |
| 1754 | + //find required sps, pps and write into dst buff | |
| 1755 | + pSpsBs = bSubSps ? &pCtx->sSubsetSpsBsInfo [iSpsId] : &pCtx->sSpsBsInfo [iSpsId]; | |
| 1756 | + memcpy (pDstBuf, pSpsBs->pSpsBsBuf, pSpsBs->uiSpsBsLen); | |
| 1757 | + pParser->iNalLenInByte [pParser->iNalNum ++] = pSpsBs->uiSpsBsLen; | |
| 1758 | + pDstBuf += pSpsBs->uiSpsBsLen; | |
| 1759 | + pPpsBs = &pCtx->sPpsBsInfo [iPpsId]; | |
| 1760 | + memcpy (pDstBuf, pPpsBs->pPpsBsBuf, pPpsBs->uiPpsBsLen); | |
| 1761 | + pParser->iNalLenInByte [pParser->iNalNum ++] = pPpsBs->uiPpsBsLen; | |
| 1762 | + pDstBuf += pPpsBs->uiPpsBsLen; | |
| 1763 | + } //IDR required SPS, PPS | |
| 1764 | + //then VCL data re-write | |
| 1765 | + while (iIdx <= iEndIdx) { | |
| 1766 | + pCurNal = pCurAu->pNalUnitsList [iIdx ++]; | |
| 1767 | + iNalLen = pCurNal->sNalData.sVclNal.iNalLength; | |
| 1768 | + pNalBs = pCurNal->sNalData.sVclNal.pNalPos; | |
| 1769 | + pParser->iNalLenInByte [pParser->iNalNum ++] = iNalLen; | |
| 1770 | + memcpy (pDstBuf, pNalBs, iNalLen); | |
| 1771 | + pDstBuf += iNalLen; | |
| 1772 | + } | |
| 1773 | + } else { //error | |
| 1774 | + pCtx->pParserBsInfo->iNalNum = 0; | |
| 1775 | + pCtx->pParserBsInfo->iSpsWidthInPixel = 0; | |
| 1776 | + pCtx->pParserBsInfo->iSpsHeightInPixel = 0; | |
| 1777 | + } | |
| 1778 | + } | |
| 1779 | + | |
| 1716 | 1780 | WelsDecodeAccessUnitEnd (pCtx); |
| 1717 | 1781 | |
| 1718 | 1782 | pCtx->bNewSeqBegin = false; |
| @@ -1985,10 +2049,13 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 266 unmodified lines | ||
| 1985 | 2049 | return iRet; |
| 1986 | 2050 | } |
| 1987 | 2051 | } |
| 1988 | − if (bReconstructSlice) { | |
| 1989 | − if (WelsDecodeConstructSlice (pCtx, pNalCur)) { | |
| 1990 | − pCtx->pDec->bIsComplete = false; // reconstruction error, directly set the flag false | |
| 1991 | − return -1; | |
| 2052 | + | |
| 2053 | + if (!pCtx->bParseOnly) { | |
| 2054 | + if (bReconstructSlice) { | |
| 2055 | + if (WelsDecodeConstructSlice (pCtx, pNalCur)) { | |
| 2056 | + pCtx->pDec->bIsComplete = false; // reconstruction error, directly set the flag false | |
| 2057 | + return -1; | |
| 2058 | + } | |
| 1992 | 2059 | } |
| 1993 | 2060 | } |
| 1994 | 2061 | if (bAllRefComplete && (pCtx->sRefPic.uiRefCount[LIST_0] > 0 || pCtx->eSliceType != I_SLICE)) { |
| @@ -2031,20 +2098,21 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 36 unmodified lines | ||
| 2031 | 2098 | #endif//#if !CODEC_FOR_TESTBED |
| 2032 | 2099 | |
| 2033 | 2100 | if (dq_cur->uiLayerDqId == kuiTargetLayerDqId) { |
| 2034 | − if (!pCtx->bInstantDecFlag) { | |
| 2035 | − //Do error concealment here | |
| 2036 | − if ((NeedErrorCon (pCtx)) && (pCtx->eErrorConMethod != ERROR_CON_DISABLE)) { | |
| 2037 | − ImplementErrorCon (pCtx); | |
| 2038 | − pCtx->iTotalNumMbRec = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight; | |
| 2039 | − pCtx->pDec->iSpsId = pCtx->pSps->iSpsId; | |
| 2040 | − pCtx->pDec->iPpsId = pCtx->pPps->iPpsId; | |
| 2101 | + if (!pCtx->bParseOnly) { | |
| 2102 | + if (!pCtx->bInstantDecFlag) { | |
| 2103 | + //Do error concealment here | |
| 2104 | + if ((NeedErrorCon (pCtx)) && (pCtx->eErrorConMethod != ERROR_CON_DISABLE)) { | |
| 2105 | + ImplementErrorCon (pCtx); | |
| 2106 | + pCtx->iTotalNumMbRec = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight; | |
| 2107 | + pCtx->pDec->iSpsId = pCtx->pSps->iSpsId; | |
| 2108 | + pCtx->pDec->iPpsId = pCtx->pPps->iPpsId; | |
| 2109 | + } | |
| 2041 | 2110 | } |
| 2042 | − } | |
| 2043 | 2111 | |
| 2044 | − if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) { | |
| 2045 | − return ERR_NONE; | |
| 2112 | + if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) { | |
| 2113 | + return ERR_NONE; | |
| 2114 | + } | |
| 2046 | 2115 | } |
| 2047 | − | |
| 2048 | 2116 | if (uiNalRefIdc > 0) { |
| 2049 | 2117 | pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //store latest decoded picture for EC |
| 2050 | 2118 | iRet = WelsMarkAsRef (pCtx); |