History

Merge pull request #1774 from huili2/dec_flowchart_ec

modify decoder flowchart for non vcl AU check

sijchen committed 11 years ago

Commit 2294b782 parents 9ea4d5b b6e28494 files · +90 −96Browse files

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

Unified · Split

codec/decoder/core/src/decoder_core.cpp+63−70
@@ -571,17 +571,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 570 unmodified lines
571571 return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_PPS_ID);
572572 }
573573
574− if (pCtx->iOverwriteFlags & OVERWRITE_PPS) {
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− }
574+ pPps = &pCtx->sPpsBuffer[iPpsId];
585575
586576 if (pPps->uiNumSliceGroups == 0) {
587577 WelsLog (pLogCtx, WELS_LOG_WARNING, "Invalid PPS referenced");
@@ -590,19 +580,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 2 unmodified lines
590580 }
591581
592582 if (kbExtensionFlag) {
593− if (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS) {
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− }
583+ pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId];
606584 pSps = &pSubsetSps->sSps;
607585 if (pCtx->bSubspsAvailFlags[pPps->iSpsId] == false) {
608586 WelsLog (pLogCtx, WELS_LOG_ERROR, "SPS id is invalid!");
@@ -615,18 +593,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 6 unmodified lines
615593 pCtx->iErrorCode |= dsNoParamSets;
616594 return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID);
617595 }
618− if (pCtx->iOverwriteFlags & OVERWRITE_SPS) {
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− }
596+ pSps = &pCtx->sSpsBuffer[pPps->iSpsId];
630597 }
631598 pSliceHead->iPpsId = iPpsId;
632599 pSliceHead->iSpsId = pPps->iSpsId;
@@ -1722,6 +1689,22 @@ static void WriteBackActiveParameters (PWelsDecoderContext pCtx) { · 1089 unmodified lines
17221689 }
17231690 pCtx->iOverwriteFlags = OVERWRITE_NONE;
17241691 }
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+
17251708 /*
17261709 * ConstructAccessUnit
17271710 * 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
18241807
18251808 WelsDecodeAccessUnitEnd (pCtx);
18261809
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);
18331810 if (ERR_NONE != iErr) {
18341811 WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "returned error from decoding:[0x%x]", iErr);
18351812 return iErr;
@@ -2195,36 +2172,52 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 359 unmodified lines
21952172
21962173 bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
21972174 PAccessUnit pAu = pCtx->pAccessUnitList;
2198− if (pAu->uiAvailUnitsNum == 0)
2199− return true;
2200− PNalUnit pCurNal = pAu->pNalUnitsList[pAu->uiEndPos];
2201− if ((pCtx->iTotalNumMbRec != 0)
2202− && (CheckAccessUnitBoundaryExt (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, &pCtx->sLastSliceHeader,
2203− &pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader))) {
2204− //Do Error Concealment here
2205− if (NeedErrorCon (pCtx)) { //should always be true!
2206− if (pCtx->eErrorConMethod != ERROR_CON_DISABLE) {
2207− ImplementErrorCon (pCtx);
2208− pCtx->iTotalNumMbRec = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight;
2209− pCtx->pDec->iSpsId = pCtx->pSps->iSpsId;
2210− pCtx->pDec->iPpsId = pCtx->pPps->iPpsId;
2211−
2212− DecodeFrameConstruction (pCtx, ppDst, pDstInfo);
2213− pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //save ECed pic for future use
2214− if (pCtx->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) {
2215− MarkECFrameAsRef (pCtx);
2216− }
2217− } else {
2218− if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) {
2219− pCtx->pDec = NULL;
2220− return false;
2221− }
2175+ bool bAuBoundaryFlag = false;
2176+ if (IS_VCL_NAL (pCtx->sCurNalHead.eNalUnitType, 1)) { //VCL data, AU list should have data
2177+ PNalUnit pCurNal = pAu->pNalUnitsList[pAu->uiEndPos];
2178+ bAuBoundaryFlag = (pCtx->iTotalNumMbRec != 0)
2179+ && (CheckAccessUnitBoundaryExt (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, &pCtx->sLastSliceHeader,
2180+ &pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader));
2181+ } else { //non VCL
2182+ if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_AU_DELIMITER) {
2183+ bAuBoundaryFlag = true;
2184+ } else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SEI) {
2185+ bAuBoundaryFlag = true;
2186+ } else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SPS) {
2187+ bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_SPS);
2188+ } else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SUBSET_SPS) {
2189+ bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS);
2190+ } else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_PPS) {
2191+ bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_PPS);
2192+ }
2193+ if (bAuBoundaryFlag && pCtx->pAccessUnitList->uiAvailUnitsNum != 0) { //Construct remaining data first
2194+ ConstructAccessUnit (pCtx, ppDst, pDstInfo);
2195+ }
2196+ }
2197+
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;
22222215 }
2223− pCtx->pDec = NULL;
2224− pCtx->iPrevFrameNum = pCtx->sLastSliceHeader.iFrameNum; //save frame_num
2225− if (pCtx->bLastHasMmco5)
2226− pCtx->iPrevFrameNum = 0;
22272216 }
2217+ pCtx->pDec = NULL;
2218+ pCtx->iPrevFrameNum = pCtx->sLastSliceHeader.iFrameNum; //save frame_num
2219+ if (pCtx->bLastHasMmco5)
2220+ pCtx->iPrevFrameNum = 0;
22282221 }
22292222 return ERR_NONE;
22302223 }

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