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/au_parser.cpp (1 of 29 files). Show all

Unified · Split

codec/decoder/core/src/au_parser.cpp+60−58
@@ -148,48 +148,50 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 147 unmodified lines
148148 ++ (*pConsumedBytes);
149149
150150 if (! (IS_SEI_NAL (pNalUnitHeader->eNalUnitType) || IS_SPS_NAL (pNalUnitHeader->eNalUnitType)
151− || IS_AU_DELIMITER_NAL (pNalUnitHeader->eNalUnitType) || pCtx->bSpsExistAheadFlag)) {
152− if (pCtx->bPrintFrameErrorTraceFlag && pCtx->iSpsErrorIgnored == 0) {
151+ || IS_AU_DELIMITER_NAL (pNalUnitHeader->eNalUnitType) || pCtx->sSpsPpsCtx.bSpsExistAheadFlag)) {
152+ if (pCtx->bPrintFrameErrorTraceFlag && pCtx->sSpsPpsCtx.iSpsErrorIgnored == 0) {
153153 WelsLog (pLogCtx, WELS_LOG_WARNING,
154154 "parse_nal(), no exist Sequence Parameter Sets ahead of sequence when try to decode NAL(type:%d).",
155155 pNalUnitHeader->eNalUnitType);
156156 } else {
157− pCtx->iSpsErrorIgnored++;
157+ pCtx->sSpsPpsCtx.iSpsErrorIgnored++;
158158 }
159− pCtx->sDecoderStatistics.iSpsNoExistNalNum++;
159+ pCtx->pDecoderStatistics->iSpsNoExistNalNum++;
160160 pCtx->iErrorCode = dsNoParamSets;
161161 return NULL;
162162 }
163− pCtx->iSpsErrorIgnored = 0;
163+ pCtx->sSpsPpsCtx.iSpsErrorIgnored = 0;
164164 if (! (IS_SEI_NAL (pNalUnitHeader->eNalUnitType) || IS_PARAM_SETS_NALS (pNalUnitHeader->eNalUnitType)
165− || IS_AU_DELIMITER_NAL (pNalUnitHeader->eNalUnitType) || pCtx->bPpsExistAheadFlag)) {
166− if (pCtx->bPrintFrameErrorTraceFlag && pCtx->iPpsErrorIgnored == 0) {
165+ || IS_AU_DELIMITER_NAL (pNalUnitHeader->eNalUnitType) || pCtx->sSpsPpsCtx.bPpsExistAheadFlag)) {
166+ if (pCtx->bPrintFrameErrorTraceFlag && pCtx->sSpsPpsCtx.iPpsErrorIgnored == 0) {
167167 WelsLog (pLogCtx, WELS_LOG_WARNING,
168168 "parse_nal(), no exist Picture Parameter Sets ahead of sequence when try to decode NAL(type:%d).",
169169 pNalUnitHeader->eNalUnitType);
170170 } else {
171− pCtx->iPpsErrorIgnored++;
171+ pCtx->sSpsPpsCtx.iPpsErrorIgnored++;
172172 }
173− pCtx->sDecoderStatistics.iPpsNoExistNalNum++;
173+ pCtx->pDecoderStatistics->iPpsNoExistNalNum++;
174174 pCtx->iErrorCode = dsNoParamSets;
175175 return NULL;
176176 }
177− pCtx->iPpsErrorIgnored = 0;
178− if ((IS_VCL_NAL_AVC_BASE (pNalUnitHeader->eNalUnitType) && ! (pCtx->bSpsExistAheadFlag || pCtx->bPpsExistAheadFlag)) ||
179− (IS_NEW_INTRODUCED_SVC_NAL (pNalUnitHeader->eNalUnitType) && ! (pCtx->bSpsExistAheadFlag || pCtx->bSubspsExistAheadFlag
180− || pCtx->bPpsExistAheadFlag))) {
181− if (pCtx->bPrintFrameErrorTraceFlag && pCtx->iSubSpsErrorIgnored == 0) {
177+ pCtx->sSpsPpsCtx.iPpsErrorIgnored = 0;
178+ if ((IS_VCL_NAL_AVC_BASE (pNalUnitHeader->eNalUnitType) && ! (pCtx->sSpsPpsCtx.bSpsExistAheadFlag
179+ || pCtx->sSpsPpsCtx.bPpsExistAheadFlag)) ||
180+ (IS_NEW_INTRODUCED_SVC_NAL (pNalUnitHeader->eNalUnitType) && ! (pCtx->sSpsPpsCtx.bSpsExistAheadFlag
181+ || pCtx->sSpsPpsCtx.bSubspsExistAheadFlag
182+ || pCtx->sSpsPpsCtx.bPpsExistAheadFlag))) {
183+ if (pCtx->bPrintFrameErrorTraceFlag && pCtx->sSpsPpsCtx.iSubSpsErrorIgnored == 0) {
182184 WelsLog (pLogCtx, WELS_LOG_WARNING,
183185 "ParseNalHeader(), no exist Parameter Sets ahead of sequence when try to decode slice(type:%d).",
184186 pNalUnitHeader->eNalUnitType);
185187 } else {
186− pCtx->iSubSpsErrorIgnored++;
188+ pCtx->sSpsPpsCtx.iSubSpsErrorIgnored++;
187189 }
188− pCtx->sDecoderStatistics.iSubSpsNoExistNalNum++;
190+ pCtx->pDecoderStatistics->iSubSpsNoExistNalNum++;
189191 pCtx->iErrorCode |= dsNoParamSets;
190192 return NULL;
191193 }
192− pCtx->iSubSpsErrorIgnored = 0;
194+ pCtx->sSpsPpsCtx.iSubSpsErrorIgnored = 0;
193195
194196 switch (pNalUnitHeader->eNalUnitType) {
195197 case NAL_UNIT_AU_DELIMITER:
@@ -201,7 +203,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 5 unmodified lines
201203 break;
202204
203205 case NAL_UNIT_PREFIX:
204− pCurNal = &pCtx->sPrefixNal;
206+ pCurNal = &pCtx->sSpsPpsCtx.sPrefixNal;
205207 pCurNal->uiTimeStamp = pCtx->uiTimeStamp;
206208
207209 if (iNalSize < NAL_UNIT_HEADER_EXT_SIZE) {
@@ -365,9 +367,9 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 157 unmodified lines
365367 memcpy (pSavedData->pCurPos + iStartDeltaByte, pSrcNal, iActualLen);
366368 pSavedData->pCurPos += iStartDeltaByte + iActualLen;
367369 }
368− if (NAL_UNIT_PREFIX == pCtx->sPrefixNal.sNalHeaderExt.sNalUnitHeader.eNalUnitType) {
369− if (pCtx->sPrefixNal.sNalData.sPrefixNal.bPrefixNalCorrectFlag) {
370− PrefetchNalHeaderExtSyntax (pCtx, pCurNal, &pCtx->sPrefixNal);
370+ if (NAL_UNIT_PREFIX == pCtx->sSpsPpsCtx.sPrefixNal.sNalHeaderExt.sNalUnitHeader.eNalUnitType) {
371+ if (pCtx->sSpsPpsCtx.sPrefixNal.sNalData.sPrefixNal.bPrefixNalCorrectFlag) {
372+ PrefetchNalHeaderExtSyntax (pCtx, pCurNal, &pCtx->sSpsPpsCtx.sPrefixNal);
371373 }
372374 }
373375
@@ -496,8 +498,8 @@ bool CheckAccessUnitBoundary (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, · 122 unmodified lines
496498 const PNalUnitHeaderExt kpCurNalHeaderExt = &kpCurNal->sNalHeaderExt;
497499 const SSliceHeader* kpLastSliceHeader = &kpLastNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader;
498500 const SSliceHeader* kpCurSliceHeader = &kpCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader;
499− if (pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != NULL
500− && pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != kpSps) {
501+ if (pCtx->sSpsPpsCtx.pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != NULL
502+ && pCtx->sSpsPpsCtx.pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != kpSps) {
501503 return true; // the active sps changed, new sequence begins, so the current au is ready
502504 }
503505
@@ -548,8 +550,8 @@ bool CheckAccessUnitBoundary (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, · 44 unmodified lines
548550
549551 bool CheckNextAuNewSeq (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, const PSps kpSps) {
550552 const PNalUnitHeaderExt kpCurNalHeaderExt = &kpCurNal->sNalHeaderExt;
551− if (pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != NULL
552− && pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != kpSps)
553+ if (pCtx->sSpsPpsCtx.pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != NULL
554+ && pCtx->sSpsPpsCtx.pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != kpSps)
553555 return true;
554556 if (kpCurNalHeaderExt->bIdrFlag)
555557 return true;
@@ -620,7 +622,7 @@ int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t · 64 unmodified lines
620622 return iErr;
621623 }
622624 }
623− iErr = ParsePps (pCtx, &pCtx->sPpsBuffer[0], pBs, pSrcNal, kSrcNalLen);
625+ iErr = ParsePps (pCtx, &pCtx->sSpsPpsCtx.sPpsBuffer[0], pBs, pSrcNal, kSrcNalLen);
624626 if (ERR_NONE != iErr) { // modified for pps invalid, 12/1/2009
625627 if (pCtx->pParam->eEcActiveIdc == ERROR_CON_DISABLE)
626628 pCtx->iErrorCode |= dsNoParamSets;
@@ -629,7 +631,7 @@ int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t · 2 unmodified lines
629631 return iErr;
630632 }
631633
632− pCtx->bPpsExistAheadFlag = true;
634+ pCtx->sSpsPpsCtx.bPpsExistAheadFlag = true;
633635
634636 break;
635637
@@ -683,7 +685,7 @@ int32_t ParseRefBasePicMarking (PBitStringAux pBs, PRefBasePicMarking pRefBasePi · 47 unmodified lines
683685 }
684686
685687 int32_t ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs) {
686− PNalUnit pCurNal = &pCtx->sPrefixNal;
688+ PNalUnit pCurNal = &pCtx->sSpsPpsCtx.sPrefixNal;
687689 uint32_t uiCode;
688690
689691 if (pCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc != 0) {
@@ -834,12 +836,12 @@ const SLevelLimits* GetLevelLimits (int32_t iLevelIdx, bool bConstraint3) { · 144 unmodified lines
834836
835837 bool CheckSpsActive (PWelsDecoderContext pCtx, PSps pSps, bool bUseSubsetFlag) {
836838 for (int i = 0; i < MAX_LAYER_NUM; i++) {
837− if (pCtx->pActiveLayerSps[i] == pSps)
839+ if (pCtx->sSpsPpsCtx.pActiveLayerSps[i] == pSps)
838840 return true;
839841 }
840842 // Pre-active, will be used soon
841843 if (bUseSubsetFlag) {
842− if (pSps->iMbWidth > 0 && pSps->iMbHeight > 0 && pCtx->bSubspsAvailFlags[pSps->iSpsId]) {
844+ if (pSps->iMbWidth > 0 && pSps->iMbHeight > 0 && pCtx->sSpsPpsCtx.bSubspsAvailFlags[pSps->iSpsId]) {
843845 if (pCtx->iTotalNumMbRec > 0) {
844846 return true;
845847 }
@@ -857,7 +859,7 @@ bool CheckSpsActive (PWelsDecoderContext pCtx, PSps pSps, bool bUseSubsetFlag) { · 11 unmodified lines
857859 }
858860 }
859861 } else {
860− if (pSps->iMbWidth > 0 && pSps->iMbHeight > 0 && pCtx->bSpsAvailFlags[pSps->iSpsId]) {
862+ if (pSps->iMbWidth > 0 && pSps->iMbHeight > 0 && pCtx->sSpsPpsCtx.bSpsAvailFlags[pSps->iSpsId]) {
861863 if (pCtx->iTotalNumMbRec > 0) {
862864 return true;
863865 }
@@ -1251,57 +1253,57 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 387 unmodified lines
12511253
12521254
12531255 if (PRO_SCALABLE_BASELINE == uiProfileIdc || PRO_SCALABLE_HIGH == uiProfileIdc)
1254− pCtx->bAvcBasedFlag = false;
1256+ pCtx->sSpsPpsCtx.bAvcBasedFlag = false;
12551257
12561258 *pPicWidth = pSps->iMbWidth << 4;
12571259 *pPicHeight = pSps->iMbHeight << 4;
12581260 PSps pTmpSps = NULL;
12591261 if (kbUseSubsetFlag) {
1260− pTmpSps = &pCtx->sSubsetSpsBuffer[iSpsId].sSps;
1262+ pTmpSps = &pCtx->sSpsPpsCtx.sSubsetSpsBuffer[iSpsId].sSps;
12611263 } else {
1262− pTmpSps = &pCtx->sSpsBuffer[iSpsId];
1264+ pTmpSps = &pCtx->sSpsPpsCtx.sSpsBuffer[iSpsId];
12631265 }
12641266 if (CheckSpsActive (pCtx, pTmpSps, kbUseSubsetFlag)) {
12651267 // we are overwriting the active sps, copy a temp buffer
12661268 if (kbUseSubsetFlag) {
1267− if (memcmp (&pCtx->sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps)) != 0) {
1269+ if (memcmp (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps)) != 0) {
12681270 if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
1269− memcpy (&pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT], pSubsetSps, sizeof (SSubsetSps));
1271+ memcpy (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[MAX_SPS_COUNT], pSubsetSps, sizeof (SSubsetSps));
12701272 pCtx->bAuReadyFlag = true;
12711273 pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1;
1272− pCtx->iOverwriteFlags |= OVERWRITE_SUBSETSPS;
1274+ pCtx->sSpsPpsCtx.iOverwriteFlags |= OVERWRITE_SUBSETSPS;
12731275 } else if ((pCtx->pSps != NULL) && (pCtx->pSps->iSpsId == pSubsetSps->sSps.iSpsId)) {
1274− memcpy (&pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT], pSubsetSps, sizeof (SSubsetSps));
1275− pCtx->iOverwriteFlags |= OVERWRITE_SUBSETSPS;
1276+ memcpy (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[MAX_SPS_COUNT], pSubsetSps, sizeof (SSubsetSps));
1277+ pCtx->sSpsPpsCtx.iOverwriteFlags |= OVERWRITE_SUBSETSPS;
12761278 } else {
1277− memcpy (&pCtx->sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps));
1279+ memcpy (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps));
12781280 }
12791281 }
12801282 } else {
1281− if (memcmp (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof (SSps)) != 0) {
1283+ if (memcmp (&pCtx->sSpsPpsCtx.sSpsBuffer[iSpsId], pSps, sizeof (SSps)) != 0) {
12821284 if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
1283− memcpy (&pCtx->sSpsBuffer[MAX_SPS_COUNT], pSps, sizeof (SSps));
1284− pCtx->iOverwriteFlags |= OVERWRITE_SPS;
1285+ memcpy (&pCtx->sSpsPpsCtx.sSpsBuffer[MAX_SPS_COUNT], pSps, sizeof (SSps));
1286+ pCtx->sSpsPpsCtx.iOverwriteFlags |= OVERWRITE_SPS;
12851287 pCtx->bAuReadyFlag = true;
12861288 pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1;
12871289 } else if ((pCtx->pSps != NULL) && (pCtx->pSps->iSpsId == pSps->iSpsId)) {
1288− memcpy (&pCtx->sSpsBuffer[MAX_SPS_COUNT], pSps, sizeof (SSps));
1289− pCtx->iOverwriteFlags |= OVERWRITE_SPS;
1290+ memcpy (&pCtx->sSpsPpsCtx.sSpsBuffer[MAX_SPS_COUNT], pSps, sizeof (SSps));
1291+ pCtx->sSpsPpsCtx.iOverwriteFlags |= OVERWRITE_SPS;
12901292 } else {
1291− memcpy (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof (SSps));
1293+ memcpy (&pCtx->sSpsPpsCtx.sSpsBuffer[iSpsId], pSps, sizeof (SSps));
12921294 }
12931295 }
12941296 }
12951297 }
12961298 // Not overwrite active sps, just copy to final place
12971299 else if (kbUseSubsetFlag) {
1298− memcpy (&pCtx->sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps));
1299− pCtx->bSubspsAvailFlags[iSpsId] = true;
1300− pCtx->bSubspsExistAheadFlag = true;
1300+ memcpy (&pCtx->sSpsPpsCtx.sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps));
1301+ pCtx->sSpsPpsCtx.bSubspsAvailFlags[iSpsId] = true;
1302+ pCtx->sSpsPpsCtx.bSubspsExistAheadFlag = true;
13011303 } else {
1302− memcpy (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof (SSps));
1303− pCtx->bSpsAvailFlags[iSpsId] = true;
1304− pCtx->bSpsExistAheadFlag = true;
1304+ memcpy (&pCtx->sSpsPpsCtx.sSpsBuffer[iSpsId], pSps, sizeof (SSps));
1305+ pCtx->sSpsPpsCtx.bSpsAvailFlags[iSpsId] = true;
1306+ pCtx->sSpsPpsCtx.bSpsExistAheadFlag = true;
13051307 }
13061308 return ERR_NONE;
13071309 }
@@ -1421,8 +1423,8 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, · 113 unmodified lines
14211423 WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //pic_scaling_matrix_present_flag
14221424 pPps->bPicScalingMatrixPresentFlag = !!uiCode;
14231425 if (pPps->bPicScalingMatrixPresentFlag) {
1424− if (pCtx->bSpsAvailFlags[pPps->iSpsId]) {
1425− WELS_READ_VERIFY (ParseScalingList (&pCtx->sSpsBuffer[pPps->iSpsId], pBsAux, 1, pPps->bTransform8x8ModeFlag,
1426+ if (pCtx->sSpsPpsCtx.bSpsAvailFlags[pPps->iSpsId]) {
1427+ WELS_READ_VERIFY (ParseScalingList (&pCtx->sSpsPpsCtx.sSpsBuffer[pPps->iSpsId], pBsAux, 1, pPps->bTransform8x8ModeFlag,
14261428 pPps->bPicScalingListPresentFlag, pPps->iScalingList4x4, pPps->iScalingList8x8));
14271429 } else {
14281430 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
@@ -1440,16 +1442,16 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, · 11 unmodified lines
14401442
14411443 if (pCtx->pPps != NULL && pCtx->pPps->iPpsId == pPps->iPpsId) {
14421444 if (memcmp (pCtx->pPps, pPps, sizeof (*pPps)) != 0) {
1443− memcpy (&pCtx->sPpsBuffer[MAX_PPS_COUNT], pPps, sizeof (SPps));
1444− pCtx->iOverwriteFlags |= OVERWRITE_PPS;
1445+ memcpy (&pCtx->sSpsPpsCtx.sPpsBuffer[MAX_PPS_COUNT], pPps, sizeof (SPps));
1446+ pCtx->sSpsPpsCtx.iOverwriteFlags |= OVERWRITE_PPS;
14451447 if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
14461448 pCtx->bAuReadyFlag = true;
14471449 pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1;
14481450 }
14491451 }
14501452 } else {
1451− memcpy (&pCtx->sPpsBuffer[uiPpsId], pPps, sizeof (SPps));
1452− pCtx->bPpsAvailFlags[uiPpsId] = true;
1453+ memcpy (&pCtx->sSpsPpsCtx.sPpsBuffer[uiPpsId], pPps, sizeof (SPps));
1454+ pCtx->sSpsPpsCtx.bPpsAvailFlags[uiPpsId] = true;
14531455 }
14541456 if (pCtx->pParam->bParseOnly) {
14551457 if (kSrcNalLen >= SPS_PPS_BS_SIZE - 4) { //pps bs exceeds

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