Showing the changes to codec/decoder/core/src/au_parser.cpp (1 of 4 files). Show all
Unified · Split
| @@ -174,8 +174,6 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 173 unmodified lines | ||
| 174 | 174 | |
| 175 | 175 | switch (pNalUnitHeader->eNalUnitType) { |
| 176 | 176 | case NAL_UNIT_SEI: |
| 177 | − case NAL_UNIT_SPS: | |
| 178 | − case NAL_UNIT_PPS: | |
| 179 | 177 | if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) { |
| 180 | 178 | pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1; |
| 181 | 179 | pCtx->bAuReadyFlag = true; |
| @@ -730,6 +728,14 @@ const SLevelLimits* GetLevelLimits (int32_t iLevelIdx, bool bConstraint3) { · 548 unmodified lines | ||
| 730 | 728 | return NULL; |
| 731 | 729 | } |
| 732 | 730 | |
| 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 | + | |
| 733 | 739 | #define SPS_LOG2_MAX_FRAME_NUM_MINUS4_MAX 12 |
| 734 | 740 | #define SPS_LOG2_MAX_PIC_ORDER_CNT_LSB_MINUS4_MAX 12 |
| 735 | 741 | #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 | ||
| 792 | 798 | return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_SPS_ID_OVERFLOW); |
| 793 | 799 | } |
| 794 | 800 | iSpsId = uiCode; |
| 795 | − | |
| 796 | − if (kbUseSubsetFlag) { | |
| 797 | − pCtx->bSubspsAvailFlags[iSpsId] = false; | |
| 798 | − } else { | |
| 799 | − pCtx->bSpsAvailFlags[iSpsId] = false; | |
| 800 | − } | |
| 801 | 801 | pSubsetSps = &sTempSubsetSps; |
| 802 | 802 | pSps = &sTempSubsetSps.sSps; |
| 803 | − memset (pSubsetSps, 0, sizeof(SSubsetSps)); | |
| 803 | + memset (pSubsetSps, 0, sizeof (SSubsetSps)); | |
| 804 | 804 | const SLevelLimits* pSLevelLimits = GetLevelLimits (uiLevelIdc, bConstraintSetFlags[3]); |
| 805 | 805 | if (NULL == pSLevelLimits) { |
| 806 | 806 | 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 | ||
| 897 | 897 | WelsLog (pCtx, WELS_LOG_ERROR, "pic_width_in_mbs(%d) exceeds the maximum allowed!\n", pSps->iMbWidth); |
| 898 | 898 | return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MAX_MB_SIZE); |
| 899 | 899 | } |
| 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)) { | |
| 901 | 901 | WelsLog (pCtx, WELS_LOG_WARNING, " the pic_width_in_mbs exceeds the level limits!\n"); |
| 902 | 902 | } |
| 903 | 903 | 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 | ||
| 978 | 978 | |
| 979 | 979 | *pPicWidth = pSps->iMbWidth << 4; |
| 980 | 980 | *pPicHeight = pSps->iMbHeight << 4; |
| 981 | + PSps pTmpSps = NULL; | |
| 981 | 982 | 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)); | |
| 983 | 1016 | pCtx->bSubspsAvailFlags[iSpsId] = true; |
| 984 | 1017 | pCtx->bSubspsExistAheadFlag = true; |
| 985 | 1018 | } else { |
| 986 | − memcpy (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof(SSps)); | |
| 1019 | + memcpy (&pCtx->sSpsBuffer[iSpsId], pSps, sizeof (SSps)); | |
| 987 | 1020 | pCtx->bSpsAvailFlags[iSpsId] = true; |
| 988 | 1021 | pCtx->bSpsExistAheadFlag = true; |
| 989 | 1022 | } |
| @@ -1018,10 +1051,8 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux) · 28 unmodified lines | ||
| 1018 | 1051 | if (uiPpsId >= MAX_PPS_COUNT) { |
| 1019 | 1052 | return ERR_INFO_PPS_ID_OVERFLOW; |
| 1020 | 1053 | } |
| 1021 | − | |
| 1022 | − pCtx->bPpsAvailFlags[uiPpsId] = false; | |
| 1023 | 1054 | pPps = &sTempPps; |
| 1024 | − memset (pPps, 0, sizeof(SPps)); | |
| 1055 | + memset (pPps, 0, sizeof (SPps)); | |
| 1025 | 1056 | |
| 1026 | 1057 | pPps->iPpsId = uiPpsId; |
| 1027 | 1058 | 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 | ||
| 1102 | 1133 | pPps->bConstainedIntraPredFlag = !!uiCode; |
| 1103 | 1134 | WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //redundant_pic_cnt_present_flag |
| 1104 | 1135 | 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 | + } | |
| 1109 | 1153 | return ERR_NONE; |
| 1110 | 1154 | } |
| 1111 | 1155 | |