add checks for spsid and ppsid

This commit is contained in:
Licai Guo 2014-03-02 17:09:23 -08:00
parent d767e216a8
commit ba312b0b20
3 changed files with 23 additions and 11 deletions

View File

@ -126,6 +126,8 @@ enum {
ERR_INFO_INVALID_NUM_REF_FRAME_IN_PIC_ORDER_CNT_CYCLE, ERR_INFO_INVALID_NUM_REF_FRAME_IN_PIC_ORDER_CNT_CYCLE,
ERR_INFO_INVALID_DBLOCKING_IDC, ERR_INFO_INVALID_DBLOCKING_IDC,
ERR_INFO_INVALID_MB_TYPE, ERR_INFO_INVALID_MB_TYPE,
ERR_INFO_INVALID_SPS_ID,
ERR_INFO_INVALID_PPS_ID,
ERR_INFO_INVALID_SUB_MB_TYPE, ERR_INFO_INVALID_SUB_MB_TYPE,
ERR_INFO_UNAVAILABLE_TOP_BLOCK_FOR_INTRA, ERR_INFO_UNAVAILABLE_TOP_BLOCK_FOR_INTRA,
ERR_INFO_UNAVAILABLE_LEFT_BLOCK_FOR_INTRA, ERR_INFO_UNAVAILABLE_LEFT_BLOCK_FOR_INTRA,

View File

@ -783,12 +783,6 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
pCtx->bSubspsExistAheadFlag = true; pCtx->bSubspsExistAheadFlag = true;
} else { // Sps } else { // Sps
pCtx->bSpsExistAheadFlag = true; 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 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) { if (kbUseSubsetFlag) {
pSubsetSps = &pCtx->sSubsetSpsBuffer[iSpsId]; pSubsetSps = &pCtx->sSubsetSpsBuffer[iSpsId];
pSps = &pSubsetSps->sSps; pSps = &pSubsetSps->sSps;
pCtx->bSubspsAvailFlags[iSpsId] = true; // added for EC, 10/28/2009 pCtx->bSubspsAvailFlags[iSpsId] = false;
} else { } else {
pSps = &pCtx->sSpsBuffer[iSpsId]; 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]); const SLevelLimits* pSLevelLimits = GetLevelLimits (uiLevelIdc, bConstraintSetFlags[3]);
if (NULL == pSLevelLimits) { if (NULL == pSLevelLimits) {
@ -1000,7 +994,11 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
*pPicWidth = pSps->iMbWidth << 4; *pPicWidth = pSps->iMbWidth << 4;
*pPicHeight = pSps->iMbHeight << 4; *pPicHeight = pSps->iMbHeight << 4;
if (kbUseSubsetFlag) {
pCtx->bSubspsAvailFlags[iSpsId] = true;
} else {
pCtx->bSpsAvailFlags[iSpsId] = true;
}
return 0; return 0;
} }
@ -1032,6 +1030,7 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux)
return ERR_INFO_PPS_ID_OVERFLOW; return ERR_INFO_PPS_ID_OVERFLOW;
} }
pCtx->bPpsAvailFlags[uiPpsId] = false;
pPps = &pPpsList[uiPpsId]; pPps = &pPpsList[uiPpsId];
pPps->iPpsId = 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 WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //redundant_pic_cnt_present_flag
pPps->bRedundantPicCntPresentFlag = !!uiCode; pPps->bRedundantPicCntPresentFlag = !!uiCode;
pCtx->bPpsAvailFlags[uiPpsId] = true; // added for EC, 10/28/2009 pCtx->bPpsAvailFlags[uiPpsId] = true;
return ERR_NONE; return ERR_NONE;
} }

View File

@ -459,6 +459,10 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
} }
//add check PPS available here //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]; pPps = &pCtx->sPpsBuffer[iPpsId];
@ -473,11 +477,18 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
} }
//add check SPS available here //add check SPS available here
if (kbExtensionFlag) { if (kbExtensionFlag) {
pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId]; pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId];
pSps = &pSubsetSps->sSps; 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 { } 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]; pSps = &pCtx->sSpsBuffer[pPps->iSpsId];
} }
pCtx->pSps = pSps; pCtx->pSps = pSps;