ref: aa043fa4e5f3d8798199fa710d28e3c36b2b4cfa
parent: a3f129d8cd3369b2e91ecdd69cdbe2e37bbe8192
parent: ba312b0b200d3f2e55731afc334f37db87b187cc
author: volvet <[email protected]>
date: Mon Mar 3 05:26:00 EST 2014
Merge pull request #384 from licaiguo/check-spsid-ppsid add checks for spsid and ppsid
--- a/codec/decoder/core/inc/error_code.h
+++ b/codec/decoder/core/inc/error_code.h
@@ -126,6 +126,8 @@
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,
--- a/codec/decoder/core/src/au_parser.cpp
+++ b/codec/decoder/core/src/au_parser.cpp
@@ -783,12 +783,6 @@
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 @@
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 @@
*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 @@
return ERR_INFO_PPS_ID_OVERFLOW;
}
+ pCtx->bPpsAvailFlags[uiPpsId] = false;
pPps = &pPpsList[uiPpsId];
pPps->iPpsId = uiPpsId;
@@ -1114,7 +1113,7 @@
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;
}
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -459,6 +459,10 @@
}
//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 @@
}
//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;