History

re-structure SWelsDecoderContext and others and prepare for the support of multi-threading support.

xiaotiansf committed 7 years ago

Commit 2f5ecec1 parent 9ed97c729 files · +2285 −1568Browse files

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

Unified · Split

codec/decoder/core/src/decoder_core.cpp+121−114
@@ -77,11 +77,11 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 76 unmodified lines
7777
7878
7979 if (pCtx->pParam->eEcActiveIdc == ERROR_CON_DISABLE) {
80− if ((pCtx->sDecoderStatistics.uiWidth != (unsigned int) kiActualWidth)
81− || (pCtx->sDecoderStatistics.uiHeight != (unsigned int) kiActualHeight)) {
82− pCtx->sDecoderStatistics.uiResolutionChangeTimes++;
83− pCtx->sDecoderStatistics.uiWidth = kiActualWidth;
84− pCtx->sDecoderStatistics.uiHeight = kiActualHeight;
80+ if ((pCtx->pDecoderStatistics->uiWidth != (unsigned int) kiActualWidth)
81+ || (pCtx->pDecoderStatistics->uiHeight != (unsigned int) kiActualHeight)) {
82+ pCtx->pDecoderStatistics->uiResolutionChangeTimes++;
83+ pCtx->pDecoderStatistics->uiWidth = kiActualWidth;
84+ pCtx->pDecoderStatistics->uiHeight = kiActualHeight;
8585 }
8686 UpdateDecStatNoFreezingInfo (pCtx);
8787 }
@@ -250,11 +250,11 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 162 unmodified lines
250250 pCtx->iMbNum = pPic->iMbNum;
251251 pCtx->iMbEcedPropNum = pPic->iMbEcedPropNum;
252252 if (pCtx->pParam->eEcActiveIdc != ERROR_CON_DISABLE) {
253− if (pDstInfo->iBufferStatus && ((pCtx->sDecoderStatistics.uiWidth != (unsigned int) kiActualWidth)
254− || (pCtx->sDecoderStatistics.uiHeight != (unsigned int) kiActualHeight))) {
255− pCtx->sDecoderStatistics.uiResolutionChangeTimes++;
256− pCtx->sDecoderStatistics.uiWidth = kiActualWidth;
257− pCtx->sDecoderStatistics.uiHeight = kiActualHeight;
253+ if (pDstInfo->iBufferStatus && ((pCtx->pDecoderStatistics->uiWidth != (unsigned int) kiActualWidth)
254+ || (pCtx->pDecoderStatistics->uiHeight != (unsigned int) kiActualHeight))) {
255+ pCtx->pDecoderStatistics->uiResolutionChangeTimes++;
256+ pCtx->pDecoderStatistics->uiWidth = kiActualWidth;
257+ pCtx->pDecoderStatistics->uiHeight = kiActualHeight;
258258 }
259259 UpdateDecStat (pCtx, pDstInfo->iBufferStatus != 0);
260260 }
@@ -527,8 +527,8 @@ int32_t ParseDecRefPicMarking (PWelsDecoderContext pCtx, PBitStringAux pBs, PSli · 266 unmodified lines
527527 WELS_VERIFY_RETURN_IF (-1, (!bAllowMmco5 || bMmco5Exist));
528528 bMmco5Exist = true;
529529
530− pCtx->iPrevPicOrderCntLsb = 0;
531− pCtx->iPrevPicOrderCntMsb = 0;
530+ pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb = 0;
531+ pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb = 0;
532532 pSh->iPicOrderCntLsb = 0;
533533 if (pCtx->pSliceHeader)
534534 pCtx->pSliceHeader->iPicOrderCntLsb = 0;
@@ -924,22 +924,22 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 389 unmodified lines
924924 iPpsId = uiCode;
925925
926926 //add check PPS available here
927− if (pCtx->bPpsAvailFlags[iPpsId] == false) {
928− pCtx->sDecoderStatistics.iPpsReportErrorNum++;
929− if (pCtx->iPPSLastInvalidId != iPpsId) {
927+ if (pCtx->sSpsPpsCtx.bPpsAvailFlags[iPpsId] == false) {
928+ pCtx->pDecoderStatistics->iPpsReportErrorNum++;
929+ if (pCtx->sSpsPpsCtx.iPPSLastInvalidId != iPpsId) {
930930 WelsLog (pLogCtx, WELS_LOG_ERROR, "PPS id (%d) is invalid, previous id (%d) error ignored (%d)!", iPpsId,
931− pCtx->iPPSLastInvalidId, pCtx->iPPSInvalidNum);
932− pCtx->iPPSLastInvalidId = iPpsId;
933− pCtx->iPPSInvalidNum = 0;
931+ pCtx->sSpsPpsCtx.iPPSLastInvalidId, pCtx->sSpsPpsCtx.iPPSInvalidNum);
932+ pCtx->sSpsPpsCtx.iPPSLastInvalidId = iPpsId;
933+ pCtx->sSpsPpsCtx.iPPSInvalidNum = 0;
934934 } else {
935− pCtx->iPPSInvalidNum++;
935+ pCtx->sSpsPpsCtx.iPPSInvalidNum++;
936936 }
937937 pCtx->iErrorCode |= dsNoParamSets;
938938 return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_PPS_ID);
939939 }
940− pCtx->iPPSLastInvalidId = -1;
940+ pCtx->sSpsPpsCtx.iPPSLastInvalidId = -1;
941941
942− pPps = &pCtx->sPpsBuffer[iPpsId];
942+ pPps = &pCtx->sSpsPpsCtx.sPpsBuffer[iPpsId];
943943
944944 if (pPps->uiNumSliceGroups == 0) {
945945 WelsLog (pLogCtx, WELS_LOG_WARNING, "Invalid PPS referenced");
@@ -948,38 +948,38 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 2 unmodified lines
948948 }
949949
950950 if (kbExtensionFlag) {
951− pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId];
951+ pSubsetSps = &pCtx->sSpsPpsCtx.sSubsetSpsBuffer[pPps->iSpsId];
952952 pSps = &pSubsetSps->sSps;
953− if (pCtx->bSubspsAvailFlags[pPps->iSpsId] == false) {
954− pCtx->sDecoderStatistics.iSubSpsReportErrorNum++;
955− if (pCtx->iSubSPSLastInvalidId != pPps->iSpsId) {
953+ if (pCtx->sSpsPpsCtx.bSubspsAvailFlags[pPps->iSpsId] == false) {
954+ pCtx->pDecoderStatistics->iSubSpsReportErrorNum++;
955+ if (pCtx->sSpsPpsCtx.iSubSPSLastInvalidId != pPps->iSpsId) {
956956 WelsLog (pLogCtx, WELS_LOG_ERROR, "Sub SPS id (%d) is invalid, previous id (%d) error ignored (%d)!", pPps->iSpsId,
957− pCtx->iSubSPSLastInvalidId, pCtx->iSubSPSInvalidNum);
958− pCtx->iSubSPSLastInvalidId = pPps->iSpsId;
959− pCtx->iSubSPSInvalidNum = 0;
957+ pCtx->sSpsPpsCtx.iSubSPSLastInvalidId, pCtx->sSpsPpsCtx.iSubSPSInvalidNum);
958+ pCtx->sSpsPpsCtx.iSubSPSLastInvalidId = pPps->iSpsId;
959+ pCtx->sSpsPpsCtx.iSubSPSInvalidNum = 0;
960960 } else {
961− pCtx->iSubSPSInvalidNum++;
961+ pCtx->sSpsPpsCtx.iSubSPSInvalidNum++;
962962 }
963963 pCtx->iErrorCode |= dsNoParamSets;
964964 return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID);
965965 }
966− pCtx->iSubSPSLastInvalidId = -1;
966+ pCtx->sSpsPpsCtx.iSubSPSLastInvalidId = -1;
967967 } else {
968− if (pCtx->bSpsAvailFlags[pPps->iSpsId] == false) {
969− pCtx->sDecoderStatistics.iSpsReportErrorNum++;
970− if (pCtx->iSPSLastInvalidId != pPps->iSpsId) {
968+ if (pCtx->sSpsPpsCtx.bSpsAvailFlags[pPps->iSpsId] == false) {
969+ pCtx->pDecoderStatistics->iSpsReportErrorNum++;
970+ if (pCtx->sSpsPpsCtx.iSPSLastInvalidId != pPps->iSpsId) {
971971 WelsLog (pLogCtx, WELS_LOG_ERROR, "SPS id (%d) is invalid, previous id (%d) error ignored (%d)!", pPps->iSpsId,
972− pCtx->iSPSLastInvalidId, pCtx->iSPSInvalidNum);
973− pCtx->iSPSLastInvalidId = pPps->iSpsId;
974− pCtx->iSPSInvalidNum = 0;
972+ pCtx->sSpsPpsCtx.iSPSLastInvalidId, pCtx->sSpsPpsCtx.iSPSInvalidNum);
973+ pCtx->sSpsPpsCtx.iSPSLastInvalidId = pPps->iSpsId;
974+ pCtx->sSpsPpsCtx.iSPSInvalidNum = 0;
975975 } else {
976− pCtx->iSPSInvalidNum++;
976+ pCtx->sSpsPpsCtx.iSPSInvalidNum++;
977977 }
978978 pCtx->iErrorCode |= dsNoParamSets;
979979 return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID);
980980 }
981− pCtx->iSPSLastInvalidId = -1;
982− pSps = &pCtx->sSpsBuffer[pPps->iSpsId];
981+ pCtx->sSpsPpsCtx.iSPSLastInvalidId = -1;
982+ pSps = &pCtx->sSpsPpsCtx.sSpsBuffer[pPps->iSpsId];
983983 }
984984 pSliceHead->iPpsId = iPpsId;
985985 pSliceHead->iSpsId = pPps->iSpsId;
@@ -1049,16 +1049,18 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 63 unmodified lines
10491049 //Calculate poc if necessary
10501050 int32_t pocLsb = pSliceHead->iPicOrderCntLsb;
10511051 if (pSliceHead->bIdrFlag || kpCurNal->sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR) {
1052− pCtx->iPrevPicOrderCntMsb = 0;
1053− pCtx->iPrevPicOrderCntLsb = 0;
1052+ pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb = 0;
1053+ pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb = 0;
10541054 }
10551055 int32_t pocMsb;
1056− if (pocLsb < pCtx->iPrevPicOrderCntLsb && pCtx->iPrevPicOrderCntLsb - pocLsb >= iMaxPocLsb / 2)
1057− pocMsb = pCtx->iPrevPicOrderCntMsb + iMaxPocLsb;
1058− else if (pocLsb > pCtx->iPrevPicOrderCntLsb && pocLsb - pCtx->iPrevPicOrderCntLsb > iMaxPocLsb / 2)
1059− pocMsb = pCtx->iPrevPicOrderCntMsb - iMaxPocLsb;
1056+ if (pocLsb < pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb
1057+ && pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb - pocLsb >= iMaxPocLsb / 2)
1058+ pocMsb = pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb + iMaxPocLsb;
1059+ else if (pocLsb > pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb
1060+ && pocLsb - pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb > iMaxPocLsb / 2)
1061+ pocMsb = pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb - iMaxPocLsb;
10601062 else
1061− pocMsb = pCtx->iPrevPicOrderCntMsb;
1063+ pocMsb = pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb;
10621064 pSliceHead->iPicOrderCntLsb = pocMsb + pocLsb;
10631065
10641066 if (pPps->bPicOrderPresentFlag && !pSliceHead->bFieldPicFlag) {
@@ -1066,8 +1068,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 1 unmodified line
10661068 }
10671069
10681070 if (kpCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc != 0) {
1069− pCtx->iPrevPicOrderCntLsb = pocLsb;
1070− pCtx->iPrevPicOrderCntMsb = pocMsb;
1071+ pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb = pocLsb;
1072+ pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb = pocMsb;
10711073 }
10721074 //End of Calculating poc
10731075 } else if (pSps->uiPocType == 1 && !pSps->bDeltaPicOrderAlwaysZeroFlag) {
@@ -1376,7 +1378,7 @@ bool PrefetchNalHeaderExtSyntax (PWelsDecoderContext pCtx, PNalUnit const kppDst · 302 unmodified lines
13761378 pNalHdrExtS = &kpSrc->sNalHeaderExt;
13771379 pShExtD = &kppDst->sNalData.sVclNal.sSliceHeaderExt;
13781380 pPrefixS = &kpSrc->sNalData.sPrefixNal;
1379− pSps = &pCtx->sSpsBuffer[pCtx->sPpsBuffer[pShExtD->sSliceHeader.iPpsId].iSpsId];
1381+ pSps = &pCtx->sSpsPpsCtx.sSpsBuffer[pCtx->sSpsPpsCtx.sPpsBuffer[pShExtD->sSliceHeader.iPpsId].iSpsId];
13801382
13811383 pNalHdrExtD->uiDependencyId = pNalHdrExtS->uiDependencyId;
13821384 pNalHdrExtD->uiQualityId = pNalHdrExtS->uiQualityId;
@@ -1438,7 +1440,7 @@ int32_t UpdateAccessUnit (PWelsDecoderContext pCtx) { · 55 unmodified lines
14381440 if (uiActualIdx ==
14391441 pCurAu->uiActualUnitsNum) { // no found IDR nal within incoming AU, need exit to avoid mosaic issue, 11/19/2009
14401442
1441− pCtx->sDecoderStatistics.uiIDRLostNum++;
1443+ pCtx->pDecoderStatistics->uiIDRLostNum++;
14421444 if (!pCtx->bParamSetsLostFlag)
14431445 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
14441446 "UpdateAccessUnit():::::Key frame lost.....CAN NOT find IDR from current AU.");
@@ -1825,9 +1827,9 @@ void ForceClearCurrentNal (PAccessUnit pAu) { · 380 unmodified lines
18251827 }
18261828
18271829 void ForceResetParaSetStatusAndAUList (PWelsDecoderContext pCtx) {
1828− pCtx->bSpsExistAheadFlag = false;
1829− pCtx->bSubspsExistAheadFlag = false;
1830− pCtx->bPpsExistAheadFlag = false;
1830+ pCtx->sSpsPpsCtx.bSpsExistAheadFlag = false;
1831+ pCtx->sSpsPpsCtx.bSubspsExistAheadFlag = false;
1832+ pCtx->sSpsPpsCtx.bPpsExistAheadFlag = false;
18311833
18321834 // Force clear the AU list
18331835 pCtx->pAccessUnitList->uiAvailUnitsNum = 0;
@@ -2101,14 +2103,14 @@ int32_t WelsDecodeAccessUnitStart (PWelsDecoderContext pCtx) { · 267 unmodified lines
21012103 return iRet;
21022104
21032105 pCtx->pAccessUnitList->uiStartPos = 0;
2104− if (!pCtx->bAvcBasedFlag && !CheckIntegrityNalUnitsList (pCtx)) {
2106+ if (!pCtx->sSpsPpsCtx.bAvcBasedFlag && !CheckIntegrityNalUnitsList (pCtx)) {
21052107 pCtx->iErrorCode |= dsBitstreamError;
21062108 return dsBitstreamError;
21072109 }
21082110
21092111 //check current AU has only one layer or not
21102112 //If YES, can use deblocking based on AVC
2111− if (!pCtx->bAvcBasedFlag) {
2113+ if (!pCtx->sSpsPpsCtx.bAvcBasedFlag) {
21122114 CheckOnlyOneLayerInAu (pCtx);
21132115 }
21142116
@@ -2119,8 +2121,8 @@ void WelsDecodeAccessUnitEnd (PWelsDecoderContext pCtx) { · 4 unmodified lines
21192121 //save previous header info
21202122 PAccessUnit pCurAu = pCtx->pAccessUnitList;
21212123 PNalUnit pCurNal = pCurAu->pNalUnitsList[pCurAu->uiEndPos];
2122− memcpy (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, sizeof (SNalUnitHeaderExt));
2123− memcpy (&pCtx->sLastSliceHeader,
2124+ memcpy (&pCtx->pLastDecPicInfo->sLastNalHdrExt, &pCurNal->sNalHeaderExt, sizeof (SNalUnitHeaderExt));
2125+ memcpy (&pCtx->pLastDecPicInfo->sLastSliceHeader,
21242126 &pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader, sizeof (SSliceHeader));
21252127 // uninitialize context of current access unit and rbsp buffer clean
21262128 ResetCurrentAccessUnit (pCtx);
@@ -2147,7 +2149,7 @@ static bool CheckNewSeqBeginAndUpdateActiveLayerSps (PWelsDecoderContext pCtx) { · 20 unmodified lines
21472149 }
21482150 int iMaxActiveLayer = 0, iMaxCurrentLayer = 0;
21492151 for (int i = MAX_LAYER_NUM - 1; i >= 0; i--) {
2150− if (pCtx->pActiveLayerSps[i] != NULL) {
2152+ if (pCtx->sSpsPpsCtx.pActiveLayerSps[i] != NULL) {
21512153 iMaxActiveLayer = i;
21522154 break;
21532155 }
@@ -2159,37 +2161,39 @@ static bool CheckNewSeqBeginAndUpdateActiveLayerSps (PWelsDecoderContext pCtx) { · 5 unmodified lines
21592161 }
21602162 }
21612163 if ((iMaxCurrentLayer != iMaxActiveLayer)
2162− || (pTmpLayerSps[iMaxCurrentLayer] != pCtx->pActiveLayerSps[iMaxActiveLayer])) {
2164+ || (pTmpLayerSps[iMaxCurrentLayer] != pCtx->sSpsPpsCtx.pActiveLayerSps[iMaxActiveLayer])) {
21632165 bNewSeq = true;
21642166 }
21652167 // fill active sps if the current sps is not null while active layer is null
21662168 if (!bNewSeq) {
21672169 for (int i = 0; i < MAX_LAYER_NUM; i++) {
2168− if (pCtx->pActiveLayerSps[i] == NULL && pTmpLayerSps[i] != NULL) {
2169− pCtx->pActiveLayerSps[i] = pTmpLayerSps[i];
2170+ if (pCtx->sSpsPpsCtx.pActiveLayerSps[i] == NULL && pTmpLayerSps[i] != NULL) {
2171+ pCtx->sSpsPpsCtx.pActiveLayerSps[i] = pTmpLayerSps[i];
21702172 }
21712173 }
21722174 } else {
21732175 // UpdateActiveLayerSps if new sequence start
2174− memcpy (&pCtx->pActiveLayerSps[0], &pTmpLayerSps[0], MAX_LAYER_NUM * sizeof (PSps));
2176+ memcpy (&pCtx->sSpsPpsCtx.pActiveLayerSps[0], &pTmpLayerSps[0], MAX_LAYER_NUM * sizeof (PSps));
21752177 }
21762178 return bNewSeq;
21772179 }
21782180
21792181 static void WriteBackActiveParameters (PWelsDecoderContext pCtx) {
2180− if (pCtx->iOverwriteFlags & OVERWRITE_PPS) {
2181− memcpy (&pCtx->sPpsBuffer[pCtx->sPpsBuffer[MAX_PPS_COUNT].iPpsId], &pCtx->sPpsBuffer[MAX_PPS_COUNT], sizeof (SPps));
2182+ if (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_PPS) {
2183+ memcpy (&pCtx->sSpsPpsCtx.sPpsBuffer[pCtx->sSpsPpsCtx.sPpsBuffer[MAX_PPS_COUNT].iPpsId],
2184+ &pCtx->sSpsPpsCtx.sPpsBuffer[MAX_PPS_COUNT], sizeof (SPps));
21822185 }
2183− if (pCtx->iOverwriteFlags & OVERWRITE_SPS) {
2184− memcpy (&pCtx->sSpsBuffer[pCtx->sSpsBuffer[MAX_SPS_COUNT].iSpsId], &pCtx->sSpsBuffer[MAX_SPS_COUNT], sizeof (SSps));
2186+ if (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_SPS) {
2187+ memcpy (&pCtx->sSpsPpsCtx.sSpsBuffer[pCtx->sSpsPpsCtx.sSpsBuffer[MAX_SPS_COUNT].iSpsId],
2188+ &pCtx->sSpsPpsCtx.sSpsBuffer[MAX_SPS_COUNT], sizeof (SSps));
21852189 pCtx->bNewSeqBegin = true;
21862190 }
2187− if (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS) {
2188− memcpy (&pCtx->sSubsetSpsBuffer[pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT].sSps.iSpsId],
2189− &pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT], sizeof (SSubsetSps));
2191+ if (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_SUBSETSPS) {
2192+ memcpy (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[pCtx->sSpsPpsCtx.sSubsetSpsBuffer[MAX_SPS_COUNT].sSps.iSpsId],
2193+ &pCtx->sSpsPpsCtx.sSubsetSpsBuffer[MAX_SPS_COUNT], sizeof (SSubsetSps));
21902194 pCtx->bNewSeqBegin = true;
21912195 }
2192− pCtx->iOverwriteFlags = OVERWRITE_NONE;
2196+ pCtx->sSpsPpsCtx.iOverwriteFlags = OVERWRITE_NONE;
21932197 }
21942198
21952199 /*
@@ -2223,7 +2227,7 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI · 27 unmodified lines
22232227 int32_t iErr;
22242228 PAccessUnit pCurAu = pCtx->pAccessUnitList;
22252229 pCtx->bAuReadyFlag = false;
2226− pCtx->bLastHasMmco5 = false;
2230+ pCtx->pLastDecPicInfo->bLastHasMmco5 = false;
22272231 bool bTmpNewSeqBegin = CheckNewSeqBeginAndUpdateActiveLayerSps (pCtx);
22282232 pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || bTmpNewSeqBegin;
22292233 iErr = WelsDecodeAccessUnitStart (pCtx);
@@ -2320,8 +2324,7 @@ void WelsDqLayerDecodeStart (PWelsDecoderContext pCtx, PNalUnit pCurNal, PSps pS · 90 unmodified lines
23202324 pCtx->bUsedAsRef = false;
23212325
23222326 pCtx->iFrameNum = pSh->iFrameNum;
2323− UpdateDecoderStatisticsForActiveParaset (& (pCtx->sDecoderStatistics),
2324− pSps, pPps);
2327+ UpdateDecoderStatisticsForActiveParaset (pCtx->pDecoderStatistics, pSps, pPps);
23252328 }
23262329
23272330 int32_t InitRefPicList (PWelsDecoderContext pCtx, const uint8_t kuiNRi, int32_t iPoc) {
@@ -2396,7 +2399,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 68 unmodified lines
23962399 const uint8_t kuiDependencyIdMax = (kuiTargetLayerDqId & 0x7F) >> 4;
23972400 int16_t iLastIdD = -1, iLastIdQ = -1;
23982401 int16_t iCurrIdD = 0, iCurrIdQ = 0;
2399− uint8_t uiNalRefIdc = 0;
2402+ pCtx->uiNalRefIdc = 0;
24002403 bool bFreshSliceAvailable =
24012404 true; // Another fresh slice comingup for given dq layer, for multiple slices in case of header parts of slices sometimes loss over error-prone channels, 8/14/2008
24022405
@@ -2432,6 +2435,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 29 unmodified lines
24322435 pCtx->pDec->bNewSeqBegin = pCtx->bNewSeqBegin; //set flag for start decoding
24332436 }
24342437 pCtx->pDec->uiTimeStamp = pNalCur->uiTimeStamp;
2438+ pCtx->pDec->uiDecodingTimeStamp = pCtx->uiDecodingTimeStamp;
24352439
24362440 if (pCtx->iTotalNumMbRec == 0) { //Picture start to decode
24372441 for (int32_t i = 0; i < LAYER_NUM_EXCHANGEABLE; ++ i)
@@ -2475,7 +2479,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 37 unmodified lines
24752479 pLayerInfo.sSliceInLayer.iLastMbQp = pSh->iSliceQp;
24762480 dq_cur->pBitStringAux = &pNalCur->sNalData.sVclNal.sSliceBitsRead;
24772481
2478− uiNalRefIdc = pNalCur->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc;
2482+ pCtx->uiNalRefIdc = pNalCur->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc;
24792483
24802484 iPpsId = pSh->iPpsId;
24812485
@@ -2515,10 +2519,12 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 33 unmodified lines
25152519 || (dq_cur->sLayerInfo.sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR);
25162520 // Subclause 8.2.5.2 Decoding process for gaps in frame_num
25172521 if (!kbIdrFlag &&
2518− pSh->iFrameNum != pCtx->iPrevFrameNum &&
2519− pSh->iFrameNum != ((pCtx->iPrevFrameNum + 1) & ((1 << dq_cur->sLayerInfo.pSps->uiLog2MaxFrameNum) - 1))) {
2522+ pSh->iFrameNum != pCtx->pLastDecPicInfo->iPrevFrameNum &&
2523+ pSh->iFrameNum != ((pCtx->pLastDecPicInfo->iPrevFrameNum + 1) & ((1 << dq_cur->sLayerInfo.pSps->uiLog2MaxFrameNum) -
2524+ 1))) {
25202525 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
2521− "referencing pictures lost due frame gaps exist, prev_frame_num: %d, curr_frame_num: %d", pCtx->iPrevFrameNum,
2526+ "referencing pictures lost due frame gaps exist, prev_frame_num: %d, curr_frame_num: %d",
2527+ pCtx->pLastDecPicInfo->iPrevFrameNum,
25222528 pSh->iFrameNum);
25232529
25242530 bAllRefComplete = false;
@@ -2535,7 +2541,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 10 unmodified lines
25352541 }
25362542
25372543 if (iCurrIdD == kuiDependencyIdMax && iCurrIdQ == BASE_QUALITY_ID) {
2538− iRet = InitRefPicList (pCtx, uiNalRefIdc, pSh->iPicOrderCntLsb);
2544+ iRet = InitRefPicList (pCtx, pCtx->uiNalRefIdc, pSh->iPicOrderCntLsb);
25392545 if (iRet) {
25402546 pCtx->bRPLRError = true;
25412547 bAllRefComplete = false; // RPLR error, set ref pictures complete flag false
@@ -2636,20 +2642,10 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 94 unmodified lines
26362642 if (iRet)
26372643 return iRet;
26382644
2639− pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //store latest decoded picture for EC
2645+ pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = pCtx->pDec; //store latest decoded picture for EC
26402646 pCtx->bUsedAsRef = false;
2641− if (uiNalRefIdc > 0) {
2647+ if (pCtx->uiNalRefIdc > 0) {
26422648 pCtx->bUsedAsRef = true;
2643− //save MBType, MV and RefIndex for use in B-Slice direct mode
2644− memcpy (pCtx->pDec->pMbType, pCtx->pCurDqLayer->pMbType, pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint32_t));
2645− memcpy (pCtx->pDec->pMv[LIST_0], pCtx->pCurDqLayer->pMv[LIST_0],
2646− pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int16_t) * MV_A * MB_BLOCK4x4_NUM);
2647− memcpy (pCtx->pDec->pMv[LIST_1], pCtx->pCurDqLayer->pMv[LIST_1],
2648− pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int16_t) * MV_A * MB_BLOCK4x4_NUM);
2649− memcpy (pCtx->pDec->pRefIndex[LIST_0], pCtx->pCurDqLayer->pRefIndex[LIST_0],
2650− pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * MB_BLOCK4x4_NUM);
2651− memcpy (pCtx->pDec->pRefIndex[LIST_1], pCtx->pCurDqLayer->pRefIndex[LIST_1],
2652− pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * MB_BLOCK4x4_NUM);
26532649 for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
26542650 uint32_t i = 0;
26552651 while (i < MAX_DPB_COUNT && pCtx->sRefPic.pRefList[listIdx][i]) {
@@ -2676,9 +2672,9 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 20 unmodified lines
26762672
26772673 // need update frame_num due current frame is well decoded
26782674 if (pCurAu->pNalUnitsList[pCurAu->uiStartPos]->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc > 0)
2679− pCtx->iPrevFrameNum = pSh->iFrameNum;
2680− if (pCtx->bLastHasMmco5)
2681− pCtx->iPrevFrameNum = 0;
2675+ pCtx->pLastDecPicInfo->iPrevFrameNum = pSh->iFrameNum;
2676+ if (pCtx->pLastDecPicInfo->bLastHasMmco5)
2677+ pCtx->pLastDecPicInfo->iPrevFrameNum = 0;
26822678 }
26832679
26842680 return ERR_NONE;
@@ -2690,7 +2686,8 @@ bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferIn · 5 unmodified lines
26902686 if (IS_VCL_NAL (pCtx->sCurNalHead.eNalUnitType, 1)) { //VCL data, AU list should have data
26912687 PNalUnit pCurNal = pAu->pNalUnitsList[pAu->uiEndPos];
26922688 bAuBoundaryFlag = (pCtx->iTotalNumMbRec != 0)
2693− && (CheckAccessUnitBoundaryExt (&pCtx->sLastNalHdrExt, &pCurNal->sNalHeaderExt, &pCtx->sLastSliceHeader,
2689+ && (CheckAccessUnitBoundaryExt (&pCtx->pLastDecPicInfo->sLastNalHdrExt, &pCurNal->sNalHeaderExt,
2690+ &pCtx->pLastDecPicInfo->sLastSliceHeader,
26942691 &pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader));
26952692 } else { //non VCL
26962693 if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_AU_DELIMITER) {
@@ -2698,11 +2695,11 @@ bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferIn · 1 unmodified line
26982695 } else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SEI) {
26992696 bAuBoundaryFlag = true;
27002697 } else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SPS) {
2701− bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_SPS);
2698+ bAuBoundaryFlag = !! (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_SPS);
27022699 } else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_SUBSET_SPS) {
2703− bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS);
2700+ bAuBoundaryFlag = !! (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_SUBSETSPS);
27042701 } else if (pCtx->sCurNalHead.eNalUnitType == NAL_UNIT_PPS) {
2705− bAuBoundaryFlag = !! (pCtx->iOverwriteFlags & OVERWRITE_PPS);
2702+ bAuBoundaryFlag = !! (pCtx->sSpsPpsCtx.iOverwriteFlags & OVERWRITE_PPS);
27062703 }
27072704 if (bAuBoundaryFlag && pCtx->pAccessUnitList->uiAvailUnitsNum != 0) { //Construct remaining data first
27082705 ConstructAccessUnit (pCtx, ppDst, pDstInfo);
@@ -2718,8 +2715,8 @@ bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferIn · 9 unmodified lines
27182715 pCtx->pDec->iPpsId = pCtx->pPps->iPpsId;
27192716
27202717 DecodeFrameConstruction (pCtx, ppDst, pDstInfo);
2721− pCtx->pPreviousDecodedPictureInDpb = pCtx->pDec; //save ECed pic for future use
2722− if (pCtx->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) {
2718+ pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = pCtx->pDec; //save ECed pic for future use
2719+ if (pCtx->pLastDecPicInfo->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) {
27232720 if (MarkECFrameAsRef (pCtx) == ERR_INFO_INVALID_PTR) {
27242721 pCtx->iErrorCode |= dsRefListNullPtrs;
27252722 return false;
@@ -2730,7 +2727,8 @@ bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferIn · 4 unmodified lines
27302727 pCtx->bFrameFinish = true; //clear frame pending status here!
27312728 } else {
27322729 if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) {
2733− if ((pCtx->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0) && (pCtx->sLastNalHdrExt.uiTemporalId == 0))
2730+ if ((pCtx->pLastDecPicInfo->sLastNalHdrExt.sNalUnitHeader.uiNalRefIdc > 0)
2731+ && (pCtx->pLastDecPicInfo->sLastNalHdrExt.uiTemporalId == 0))
27342732 pCtx->iErrorCode |= dsNoParamSets;
27352733 else
27362734 pCtx->iErrorCode |= dsBitstreamError;
@@ -2740,9 +2738,9 @@ bool CheckAndFinishLastPic (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferIn · 3 unmodified lines
27402738 }
27412739 pCtx->pDec = NULL;
27422740 if (pAu->pNalUnitsList[pAu->uiStartPos]->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc > 0)
2743− pCtx->iPrevFrameNum = pCtx->sLastSliceHeader.iFrameNum; //save frame_num
2744− if (pCtx->bLastHasMmco5)
2745− pCtx->iPrevFrameNum = 0;
2741+ pCtx->pLastDecPicInfo->iPrevFrameNum = pCtx->pLastDecPicInfo->sLastSliceHeader.iFrameNum; //save frame_num
2742+ if (pCtx->pLastDecPicInfo->bLastHasMmco5)
2743+ pCtx->pLastDecPicInfo->iPrevFrameNum = 0;
27462744 }
27472745 return ERR_NONE;
27482746 }
@@ -2753,28 +2751,37 @@ bool CheckRefPicturesComplete (PWelsDecoderContext pCtx) { · 4 unmodified lines
27532751 int32_t iRealMbIdx = pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iFirstMbInSlice;
27542752 for (int32_t iMbIdx = 0; bAllRefComplete
27552753 && iMbIdx < pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer.iTotalMbInCurSlice; iMbIdx++) {
2756− switch (pCtx->pCurDqLayer->pMbType[iRealMbIdx]) {
2754+ switch (pCtx->pCurDqLayer->pDec->pMbType[iRealMbIdx]) {
27572755 case MB_TYPE_SKIP:
27582756 case MB_TYPE_16x16:
2759− bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
2757+ bAllRefComplete &=
2758+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
27602759 break;
27612760
27622761 case MB_TYPE_16x8:
2763− bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
2764− bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][8] ]->bIsComplete;
2762+ bAllRefComplete &=
2763+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
2764+ bAllRefComplete &=
2765+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][8] ]->bIsComplete;
27652766 break;
27662767
27672768 case MB_TYPE_8x16:
2768− bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
2769− bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][2] ]->bIsComplete;
2769+ bAllRefComplete &=
2770+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
2771+ bAllRefComplete &=
2772+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][2] ]->bIsComplete;
27702773 break;
27712774
27722775 case MB_TYPE_8x8:
27732776 case MB_TYPE_8x8_REF0:
2774− bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
2775− bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][2] ]->bIsComplete;
2776− bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][8] ]->bIsComplete;
2777− bAllRefComplete &= pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pRefIndex[0][iRealMbIdx][10] ]->bIsComplete;
2777+ bAllRefComplete &=
2778+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][0] ]->bIsComplete;
2779+ bAllRefComplete &=
2780+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][2] ]->bIsComplete;
2781+ bAllRefComplete &=
2782+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][8] ]->bIsComplete;
2783+ bAllRefComplete &=
2784+ pCtx->sRefPic.pRefList[ LIST_0 ][ pCtx->pCurDqLayer->pDec->pRefIndex[0][iRealMbIdx][10] ]->bIsComplete;
27782785 break;
27792786
27802787 default:

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