modify decoder flowchart for non vcl AU check
Showing the changes to codec/decoder/core/src/decoder_core.cpp (1 of 4 files). Show all
Unified · Split
| @@ -571,17 +571,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 570 unmodified lines | |||
| 571 | return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_PPS_ID); | 571 | return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_PPS_ID); |
| 572 | } | 572 | } |
| 573 | 573 | ||
| 574 | if (pCtx->iOverwriteFlags & OVERWRITE_PPS) { | 574 | pPps = &pCtx->sPpsBuffer[iPpsId]; |
| 575 | if (pCtx->pAccessUnitList->uiAvailUnitsNum > 1 || pCtx->iTotalNumMbRec > 0) { | ||
| 576 | pPps = &pCtx->sPpsBuffer[MAX_PPS_COUNT]; | ||
| 577 | } else { | ||
| 578 | memcpy (&pCtx->sPpsBuffer[pCtx->sPpsBuffer[MAX_PPS_COUNT].iPpsId], &pCtx->sPpsBuffer[MAX_PPS_COUNT], sizeof (SPps)); | ||
| 579 | pCtx->iOverwriteFlags ^= OVERWRITE_PPS; | ||
| 580 | pPps = &pCtx->sPpsBuffer[iPpsId]; | ||
| 581 | } | ||
| 582 | } else { | ||
| 583 | pPps = &pCtx->sPpsBuffer[iPpsId]; | ||
| 584 | } | ||
| 585 | 575 | ||
| 586 | if (pPps->uiNumSliceGroups == 0) { | 576 | if (pPps->uiNumSliceGroups == 0) { |
| 587 | WelsLog (pLogCtx, WELS_LOG_WARNING, "Invalid PPS referenced"); | 577 | WelsLog (pLogCtx, WELS_LOG_WARNING, "Invalid PPS referenced"); |
| @@ -590,19 +580,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 2 unmodified lines | |||
| 590 | } | 580 | } |
| 591 | 581 | ||
| 592 | if (kbExtensionFlag) { | 582 | if (kbExtensionFlag) { |
| 593 | if (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS) { | 583 | pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId]; |
| 594 | if (pCtx->pAccessUnitList->uiAvailUnitsNum > 1 || pCtx->iTotalNumMbRec > 0) { | ||
| 595 | pSubsetSps = &pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT]; | ||
| 596 | } else { | ||
| 597 | memcpy (&pCtx->sSubsetSpsBuffer[pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT].sSps.iSpsId], | ||
| 598 | &pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT], sizeof (SSubsetSps)); | ||
| 599 | pCtx->iOverwriteFlags ^= OVERWRITE_SUBSETSPS; | ||
| 600 | pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId]; | ||
| 601 | ResetActiveSPSForEachLayer (pCtx); | ||
| 602 | } | ||
| 603 | } else { | ||
| 604 | pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId]; | ||
| 605 | } | ||
| 606 | pSps = &pSubsetSps->sSps; | 584 | pSps = &pSubsetSps->sSps; |
| 607 | if (pCtx->bSubspsAvailFlags[pPps->iSpsId] == false) { | 585 | if (pCtx->bSubspsAvailFlags[pPps->iSpsId] == false) { |
| 608 | WelsLog (pLogCtx, WELS_LOG_ERROR, "SPS id is invalid!"); | 586 | WelsLog (pLogCtx, WELS_LOG_ERROR, "SPS id is invalid!"); |
| @@ -615,18 +593,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 6 unmodified lines | |||
| 615 | pCtx->iErrorCode |= dsNoParamSets; | 593 | pCtx->iErrorCode |= dsNoParamSets; |
| 616 | return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID); | 594 | return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID); |
| 617 | } | 595 | } |
| 618 | if (pCtx->iOverwriteFlags & OVERWRITE_SPS) { | 596 | pSps = &pCtx->sSpsBuffer[pPps->iSpsId]; |
| 619 | if (pCtx->pAccessUnitList->uiAvailUnitsNum > 1 || pCtx->iTotalNumMbRec > 0) { | ||
| 620 | pSps = &pCtx->sSpsBuffer[MAX_SPS_COUNT]; | ||
| 621 | } else { | ||
| 622 | memcpy (&pCtx->sSpsBuffer[pCtx->sSpsBuffer[MAX_SPS_COUNT].iSpsId], &pCtx->sSpsBuffer[MAX_SPS_COUNT], sizeof (SSps)); | ||
| 623 | pCtx->iOverwriteFlags ^= OVERWRITE_SPS; | ||
| 624 | pSps = &pCtx->sSpsBuffer[pPps->iSpsId]; | ||
| 625 | ResetActiveSPSForEachLayer (pCtx); | ||
| 626 | } | ||
| 627 | } else { | ||
| 628 | pSps = &pCtx->sSpsBuffer[pPps->iSpsId]; | ||
| 629 | } | ||
| 630 | } | 597 | } |
| 631 | pSliceHead->iPpsId = iPpsId; | 598 | pSliceHead->iPpsId = iPpsId; |
| 632 | pSliceHead->iSpsId = pPps->iSpsId; | 599 | pSliceHead->iSpsId = pPps->iSpsId; |
| @@ -1722,6 +1689,22 @@ static void WriteBackActiveParameters (PWelsDecoderContext pCtx) { · 1089 unmodified lines | |||
| 1722 | } | 1689 | } |
| 1723 | pCtx->iOverwriteFlags = OVERWRITE_NONE; | 1690 | pCtx->iOverwriteFlags = OVERWRITE_NONE; |
| 1724 | } | 1691 | } |
| 1692 | |||
| 1693 | /* | ||
| 1694 | * DecodeFinishUpdate | ||
| 1695 | * decoder finish decoding, update active parameter sets and new seq status | ||
| 1696 | * | ||
| 1697 | */ | ||
| 1698 | |||
| 1699 | void DecodeFinishUpdate (PWelsDecoderContext pCtx) { | ||
| 1700 | pCtx->bNewSeqBegin = false; | ||
| 1701 | WriteBackActiveParameters (pCtx); | ||
| 1702 | pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || pCtx->bNextNewSeqBegin; | ||
| 1703 | pCtx->bNextNewSeqBegin = false; // reset it | ||
| 1704 | if (pCtx->bNewSeqBegin) | ||
| 1705 | ResetActiveSPSForEachLayer (pCtx); | ||
| 1706 | } | ||
| 1707 | |||
| 1725 | /* | 1708 | /* |
| 1726 | * ConstructAccessUnit | 1709 | * ConstructAccessUnit |
| 1727 | * construct an access unit for given input bitstream, maybe partial NAL Unit, one or more Units are involved to | 1710 | * construct an access unit for given input bitstream, maybe partial NAL Unit, one or more Units are involved to |
| @@ -1824,12 +1807,6 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI · 96 unmodified lines | |||
| 1824 | 1807 | ||
| 1825 | WelsDecodeAccessUnitEnd (pCtx); | 1808 | WelsDecodeAccessUnitEnd (pCtx); |
| 1826 | 1809 | ||
| 1827 | pCtx->bNewSeqBegin = false; | ||
| 1828 | WriteBackActiveParameters (pCtx); | ||
| 1829 | pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || pCtx->bNextNewSeqBegin; | ||
| 1830 | pCtx->bNextNewSeqBegin = false; // reset it | ||
| 1831 | if (pCtx->bNewSeqBegin) | ||
| 1832 | ResetActiveSPSForEachLayer (pCtx); | ||
| 1833 | if (ERR_NONE != iErr) { | 1810 | if (ERR_NONE != iErr) { |
| 1834 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "returned error from decoding:[0x%x]", iErr); | 1811 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "returned error from decoding:[0x%x]", iErr); |
| 1835 | return iErr; | 1812 | return iErr; |
| @@ -2195,36 +2172,52 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 359 unmodified lines | |||
| 2195 | 2172 | ||
| 2196 | bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) { | 2173 | bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) { |
| 2197 | PAccessUnit pAu = pCtx->pAccessUnitList; | 2174 | PAccessUnit pAu = pCtx->pAccessUnitList; |
| 2198 | if (pAu->uiAvailUnitsNum == 0) | 2175 | bool bAuBoundaryFlag = false; |
| 2199 | return true; | 2176 | if (IS_VCL_NAL (pCtx->sCurNalHead.eNalUnitType, 1)) { //VCL data, AU list should have data |
| 2200 | PNalUnit pCurNal = pAu->pNalUnitsList[pAu->uiEndPos]; | 2177 | PNalUnit pCurNal = pAu->pNalUnitsList[pAu->uiEndPos]; |
| 2201 | if ((pCtx->iTotalNumMbRec != 0) | 2178 | bAuBoundaryFlag = (pCtx->iTotalNumMbRec != 0) |
| 2202 | && (CheckAccessUnitBoundaryExt (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, &pCtx->sLastSliceHeader, | 2179 | && (CheckAccessUnitBoundaryExt (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, &pCtx->sLastSliceHeader, |
| 2203 | &pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader))) { | 2180 | &pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader)); |
| 2204 | //Do Error Concealment here | 2181 | } else { //non VCL |
| 2205 | if (NeedErrorCon (pCtx)) { //should always be true! | 2182 | if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_AU_DELIMITER) { |
| 2206 | if (pCtx->eErrorConMethod != ERROR_CON_DISABLE) { | 2183 | bAuBoundaryFlag = true; |
| 2207 | ImplementErrorCon (pCtx); | 2184 | } else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SEI) { |
| 2208 | pCtx->iTotalNumMbRec = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight; | 2185 | bAuBoundaryFlag = true; |
| 2209 | pCtx->pDec->iSpsId = pCtx->pSps->iSpsId; | 2186 | } else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SPS) { |
| 2210 | pCtx->pDec->iPpsId = pCtx->pPps->iPpsId; | 2187 | bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_SPS); |
| 2211 | 2188 | } else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SUBSET_SPS) { | |
| 2212 | DecodeFrameConstruction (pCtx, ppDst, pDstInfo); | 2189 | bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS); |
| 2213 | pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //save ECed pic for future use | 2190 | } else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_PPS) { |
| 2214 | if (pCtx->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) { | 2191 | bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_PPS); |
| 2215 | MarkECFrameAsRef (pCtx); | 2192 | } |
| 2216 | } | 2193 | if (bAuBoundaryFlag && pCtx->pAccessUnitList->uiAvailUnitsNum != 0) { //Construct remaining data first |
| 2217 | } else { | 2194 | ConstructAccessUnit (pCtx, ppDst, pDstInfo); |
| 2218 | if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) { | 2195 | } |
| 2219 | pCtx->pDec = NULL; | 2196 | } |
| 2220 | return false; | 2197 | |
| 2221 | } | 2198 | //Do Error Concealment here |
| 2199 | if (bAuBoundaryFlag && (pCtx->iTotalNumMbRec != 0) && NeedErrorCon (pCtx)) { //AU ready but frame not completely reconed | ||
| 2200 | if (pCtx->eErrorConMethod != ERROR_CON_DISABLE) { | ||
| 2201 | ImplementErrorCon (pCtx); | ||
| 2202 | pCtx->iTotalNumMbRec = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight; | ||
| 2203 | pCtx->pDec->iSpsId = pCtx->pSps->iSpsId; | ||
| 2204 | pCtx->pDec->iPpsId = pCtx->pPps->iPpsId; | ||
| 2205 | |||
| 2206 | DecodeFrameConstruction (pCtx, ppDst, pDstInfo); | ||
| 2207 | pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //save ECed pic for future use | ||
| 2208 | if (pCtx->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) { | ||
| 2209 | MarkECFrameAsRef (pCtx); | ||
| 2210 | } | ||
| 2211 | } else { | ||
| 2212 | if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) { | ||
| 2213 | pCtx->pDec = NULL; | ||
| 2214 | return false; | ||
| 2222 | } | 2215 | } |
| 2223 | pCtx->pDec = NULL; | ||
| 2224 | pCtx->iPrevFrameNum = pCtx->sLastSliceHeader.iFrameNum; //save frame_num | ||
| 2225 | if (pCtx->bLastHasMmco5) | ||
| 2226 | pCtx->iPrevFrameNum = 0; | ||
| 2227 | } | 2216 | } |
| 2217 | pCtx->pDec = NULL; | ||
| 2218 | pCtx->iPrevFrameNum = pCtx->sLastSliceHeader.iFrameNum; //save frame_num | ||
| 2219 | if (pCtx->bLastHasMmco5) | ||
| 2220 | pCtx->iPrevFrameNum = 0; | ||
| 2228 | } | 2221 | } |
| 2229 | return ERR_NONE; | 2222 | return ERR_NONE; |
| 2230 | } | 2223 | } |