diff --git a/codec/decoder/core/inc/error_code.h b/codec/decoder/core/inc/error_code.h index ebf46f7e..ab859be6 100644 --- a/codec/decoder/core/inc/error_code.h +++ b/codec/decoder/core/inc/error_code.h @@ -126,6 +126,8 @@ enum { ERR_INFO_INVALID_NUM_REF_FRAME_IN_PIC_ORDER_CNT_CYCLE, ERR_INFO_INVALID_DBLOCKING_IDC, ERR_INFO_INVALID_MB_TYPE, + ERR_INFO_INVALID_SPS_ID, + ERR_INFO_INVALID_PPS_ID, ERR_INFO_INVALID_SUB_MB_TYPE, ERR_INFO_UNAVAILABLE_TOP_BLOCK_FOR_INTRA, ERR_INFO_UNAVAILABLE_LEFT_BLOCK_FOR_INTRA, diff --git a/codec/decoder/core/src/au_parser.cpp b/codec/decoder/core/src/au_parser.cpp index 8decc91f..0bbdf337 100644 --- a/codec/decoder/core/src/au_parser.cpp +++ b/codec/decoder/core/src/au_parser.cpp @@ -783,12 +783,6 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW pCtx->bSubspsExistAheadFlag = true; } else { // Sps pCtx->bSpsExistAheadFlag = true; - - // added for EC, 10/28/2009 - // for safe - memset (&pCtx->bSpsAvailFlags[0], 0, sizeof (pCtx->bSpsAvailFlags)); - memset (&pCtx->bSubspsAvailFlags[0], 0, sizeof (pCtx->bSubspsAvailFlags)); - memset (&pCtx->bPpsAvailFlags[0], 0, sizeof (pCtx->bPpsAvailFlags)); } WELS_READ_VERIFY (BsGetBits (pBs, 8, &uiCode)); //profile_idc @@ -818,10 +812,10 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW if (kbUseSubsetFlag) { pSubsetSps = &pCtx->sSubsetSpsBuffer[iSpsId]; pSps = &pSubsetSps->sSps; - pCtx->bSubspsAvailFlags[iSpsId] = true; // added for EC, 10/28/2009 + pCtx->bSubspsAvailFlags[iSpsId] = false; } else { pSps = &pCtx->sSpsBuffer[iSpsId]; - pCtx->bSpsAvailFlags[iSpsId] = true; // added for EC, 10/28/2009 + pCtx->bSpsAvailFlags[iSpsId] = false; } const SLevelLimits* pSLevelLimits = GetLevelLimits (uiLevelIdc, bConstraintSetFlags[3]); if (NULL == pSLevelLimits) { @@ -1000,7 +994,11 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW *pPicWidth = pSps->iMbWidth << 4; *pPicHeight = pSps->iMbHeight << 4; - + if (kbUseSubsetFlag) { + pCtx->bSubspsAvailFlags[iSpsId] = true; + } else { + pCtx->bSpsAvailFlags[iSpsId] = true; + } return 0; } @@ -1032,6 +1030,7 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux) return ERR_INFO_PPS_ID_OVERFLOW; } + pCtx->bPpsAvailFlags[uiPpsId] = false; pPps = &pPpsList[uiPpsId]; pPps->iPpsId = uiPpsId; @@ -1114,7 +1113,7 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux) WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //redundant_pic_cnt_present_flag pPps->bRedundantPicCntPresentFlag = !!uiCode; - pCtx->bPpsAvailFlags[uiPpsId] = true; // added for EC, 10/28/2009 + pCtx->bPpsAvailFlags[uiPpsId] = true; return ERR_NONE; } diff --git a/codec/decoder/core/src/decoder_core.cpp b/codec/decoder/core/src/decoder_core.cpp index 09683bc9..97c7e298 100644 --- a/codec/decoder/core/src/decoder_core.cpp +++ b/codec/decoder/core/src/decoder_core.cpp @@ -459,6 +459,10 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co } //add check PPS available here + if (pCtx->bPpsAvailFlags[iPpsId] == false) { + WelsLog (pCtx, WELS_LOG_ERROR, "PPS id is invalid!\n"); + return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_PPS_ID); + } pPps = &pCtx->sPpsBuffer[iPpsId]; @@ -473,11 +477,18 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co } //add check SPS available here - if (kbExtensionFlag) { pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId]; pSps = &pSubsetSps->sSps; + if (pCtx->bSubspsAvailFlags[pPps->iSpsId] == false) { + WelsLog (pCtx, WELS_LOG_ERROR, "SPS id is invalid!\n"); + return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID); + } } else { + if (pCtx->bSpsAvailFlags[pPps->iSpsId] == false) { + WelsLog (pCtx, WELS_LOG_ERROR, "SPS id is invalid!\n"); + return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID); + } pSps = &pCtx->sSpsBuffer[pPps->iSpsId]; } pCtx->pSps = pSps;