History

overwriteactivesps

Licai Guo committed 12 years ago

Commit 79ed7441 parent f141bd64 files · +114 −51Browse files

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

Unified · Split

codec/decoder/core/src/au_parser.cpp+63−19
@@ -174,8 +174,6 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 173 unmodified lines
174174
175175 switch (pNalUnitHeader->eNalUnitType) {
176176 case NAL_UNIT_SEI:
177− case NAL_UNIT_SPS:
178− case NAL_UNIT_PPS:
179177 if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
180178 pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1;
181179 pCtx->bAuReadyFlag = true;
@@ -730,6 +728,14 @@ const SLevelLimits* GetLevelLimits (int32_t iLevelIdx, bool bConstraint3) { · 548 unmodified lines
730728 return NULL;
731729 }
732730
731+bool CheckSpsActive (PWelsDecoderContext pCtx, PSps pSps) {
732+ for (int i = 0; i < MAX_LAYER_NUM; i++) {
733+ if (pCtx->pActiveLayerSps[i] == pSps)
734+ return true;
735+ }
736+ return false;
737+}
738+
733739 #define SPS_LOG2_MAX_FRAME_NUM_MINUS4_MAX 12
734740 #define SPS_LOG2_MAX_PIC_ORDER_CNT_LSB_MINUS4_MAX 12
735741 #define SPS_NUM_REF_FRAMES_IN_PIC_ORDER_CNT_CYCLE_MAX 255
@@ -792,15 +798,9 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 56 unmodified lines
792798 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_SPS_ID_OVERFLOW);
793799 }
794800 iSpsId = uiCode;
795−
796− if (kbUseSubsetFlag) {
797− pCtx->bSubspsAvailFlags[iSpsId] = false;
798− } else {
799− pCtx->bSpsAvailFlags[iSpsId] = false;
800− }
801801 pSubsetSps = &sTempSubsetSps;
802802 pSps = &sTempSubsetSps.sSps;
803− memset (pSubsetSps, 0, sizeof(SSubsetSps));
803+ memset (pSubsetSps, 0, sizeof (SSubsetSps));
804804 const SLevelLimits* pSLevelLimits = GetLevelLimits (uiLevelIdc, bConstraintSetFlags[3]);
805805 if (NULL == pSLevelLimits) {
806806 WelsLog (pCtx, WELS_LOG_WARNING, "ParseSps(): level_idx (%d).\n", uiLevelIdc);
@@ -897,7 +897,7 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 90 unmodified lines
897897 WelsLog (pCtx, WELS_LOG_ERROR, "pic_width_in_mbs(%d) exceeds the maximum allowed!\n", pSps->iMbWidth);
898898 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MAX_MB_SIZE);
899899 }
900− if (((uint64_t)pSps->iMbWidth * (uint64_t)pSps->iMbWidth) > (uint64_t)(8 * pSLevelLimits->iMaxFS)) {
900+ if (((uint64_t)pSps->iMbWidth * (uint64_t)pSps->iMbWidth) > (uint64_t) (8 * pSLevelLimits->iMaxFS)) {
901901 WelsLog (pCtx, WELS_LOG_WARNING, " the pic_width_in_mbs exceeds the level limits!\n");
902902 }
903903 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_height_in_map_units_minus1
@@ -978,12 +978,45 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 74 unmodified lines
978978
979979 *pPicWidth = pSps->iMbWidth << 4;
980980 *pPicHeight = pSps->iMbHeight << 4;
981+ PSps pTmpSps = NULL;
981982 if (kbUseSubsetFlag) {
982− memcpy (&pCtx->sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof(SSubsetSps));
983+ pTmpSps = &pCtx->sSubsetSpsBuffer[iSpsId].sSps;
984+ } else {
985+ pTmpSps = &pCtx->sSpsBuffer[iSpsId];
986+ }
987+ if (CheckSpsActive (pCtx, pTmpSps)) {
988+ // we are overwriting the active sps, copy a temp buffer
989+ if (kbUseSubsetFlag) {
990+ if (memcmp (&pCtx->sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps)) != 0) {
991+ if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
992+ memcpy (&pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT], pSubsetSps, sizeof (SSubsetSps));
993+ pCtx->bAuReadyFlag = true;
994+ pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1;
995+ pCtx->iOverwriteFlags |= OVERWRITE_SUBSETSPS;
996+ } else {
997+ memcpy (&pCtx->sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps));
998+ }
999+ }
1000+ } else {
1001+ if (memcmp (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof (SSps)) != 0) {
1002+ if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
1003+ memcpy (&pCtx->sSpsBuffer[MAX_SPS_COUNT], pSps, sizeof (SSps));
1004+ pCtx->iOverwriteFlags |= OVERWRITE_SPS;
1005+ pCtx->bAuReadyFlag = true;
1006+ pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1;
1007+ } else {
1008+ memcpy (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof (SSps));
1009+ }
1010+ }
1011+ }
1012+ }
1013+ // Not overwrite active sps, just copy to final place
1014+ else if (kbUseSubsetFlag) {
1015+ memcpy (&pCtx->sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps));
9831016 pCtx->bSubspsAvailFlags[iSpsId] = true;
9841017 pCtx->bSubspsExistAheadFlag = true;
9851018 } else {
986− memcpy (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof(SSps));
1019+ memcpy (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof (SSps));
9871020 pCtx->bSpsAvailFlags[iSpsId] = true;
9881021 pCtx->bSpsExistAheadFlag = true;
9891022 }
@@ -1018,10 +1051,8 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux) · 28 unmodified lines
10181051 if (uiPpsId >= MAX_PPS_COUNT) {
10191052 return ERR_INFO_PPS_ID_OVERFLOW;
10201053 }
1021−
1022− pCtx->bPpsAvailFlags[uiPpsId] = false;
10231054 pPps = &sTempPps;
1024− memset (pPps, 0, sizeof(SPps));
1055+ memset (pPps, 0, sizeof (SPps));
10251056
10261057 pPps->iPpsId = uiPpsId;
10271058 WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //seq_parameter_set_id
@@ -1102,10 +1133,23 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux) · 74 unmodified lines
11021133 pPps->bConstainedIntraPredFlag = !!uiCode;
11031134 WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //redundant_pic_cnt_present_flag
11041135 pPps->bRedundantPicCntPresentFlag = !!uiCode;
1105−
1106− memcpy (&pCtx->sPpsBuffer[uiPpsId], pPps, sizeof(SPps));
1107− pCtx->bPpsAvailFlags[uiPpsId] = true;
1108−
1136+ if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
1137+ PNalUnit pLastNalUnit = pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum - 1];
1138+ PPps pLastPps = pLastNalUnit->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pPps;
1139+ // the active pps is overwrite, write to a temp place
1140+ if (pLastPps == &pCtx->sPpsBuffer[uiPpsId] && memcmp (&pCtx->sPpsBuffer[uiPpsId], pPps, sizeof (*pPps)) != 0) {
1141+ memcpy (&pCtx->sPpsBuffer[MAX_PPS_COUNT], pPps, sizeof (SPps));
1142+ pCtx->iOverwriteFlags |= OVERWRITE_PPS;
1143+ pCtx->bAuReadyFlag = true;
1144+ pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1;
1145+ } else {
1146+ memcpy (&pCtx->sPpsBuffer[uiPpsId], pPps, sizeof (SPps));
1147+ pCtx->bPpsAvailFlags[uiPpsId] = true;
1148+ }
1149+ } else {
1150+ memcpy (&pCtx->sPpsBuffer[uiPpsId], pPps, sizeof (SPps));
1151+ pCtx->bPpsAvailFlags[uiPpsId] = true;
1152+ }
11091153 return ERR_NONE;
11101154 }
11111155

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