modify SPS, PPS buffer management and remove a build warning

This commit is contained in:
Licai Guo
2014-02-27 22:28:16 -08:00
parent 3d47b7847d
commit e4b6fc3f9a
3 changed files with 4 additions and 169 deletions

View File

@@ -56,10 +56,6 @@
namespace WelsDec {
#ifndef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
//#define MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
#endif //MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
typedef struct TagDataBuffer {
uint8_t* pHead;
uint8_t* pEnd;
@@ -234,12 +230,6 @@ typedef struct TagWelsDecoderContext {
SPosOffset sFrameCrop;
#ifdef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
int32_t iSpsTotalNum; //the number of SPS in current IDR interval
int32_t iSubspsTotalNum; //the number of subsps in current IDR interval
int32_t iPpsTotalNum; //the number of PPS in current IDR interval.
#endif //MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
SSps sSpsBuffer[MAX_SPS_COUNT];
SPps sPpsBuffer[MAX_PPS_COUNT];
PSliceHeader pSliceHeader;

View File

@@ -322,26 +322,8 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade
if (uiAvailNalNum > 1) {
pCurAu->uiEndPos = uiAvailNalNum - 2;
pCtx->bAuReadyFlag = true;
}
#ifdef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
if (dsNoParamSets & pCtx->iErrorCode) {
if (uiAvailNalNum <= 1) { //no any data to decode and SPS/PPS ID mismatch, SHOULD request IDR
#ifdef LONG_TERM_REF
pCtx->bParamSetsLostFlag = true;
#else
pCtx->bReferenceLostAtT0Flag = true;
#endif
ResetParameterSetsState (pCtx);
}
return NULL;
} else {
return NULL;
}
#else
return NULL;
#endif //MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
}
if ((uiAvailNalNum > 1) &&
@@ -602,7 +584,7 @@ int32_t ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs) {
WELS_READ_VERIFY (ParseRefBasePicMarking (pBs, &sPrefixNal->sRefPicBaseMarking));
}
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //additional_prefix_nal_unit_extension_flag
sPrefixNal->bPrefixNalUnitAdditionalExtFlag = uiCode;
sPrefixNal->bPrefixNalUnitAdditionalExtFlag = !!uiCode;
if (sPrefixNal->bPrefixNalUnitAdditionalExtFlag) {
WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //additional_prefix_nal_unit_extension_data_flag
sPrefixNal->bPrefixNalUnitExtFlag = !!uiCode;
@@ -807,12 +789,6 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
memset (&pCtx->bSpsAvailFlags[0], 0, sizeof (pCtx->bSpsAvailFlags));
memset (&pCtx->bSubspsAvailFlags[0], 0, sizeof (pCtx->bSubspsAvailFlags));
memset (&pCtx->bPpsAvailFlags[0], 0, sizeof (pCtx->bPpsAvailFlags));
#ifdef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
pCtx->iSpsTotalNum = 0;
pCtx->iSubspsTotalNum = 0;
pCtx->iPpsTotalNum = 0;
#endif //MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
}
WELS_READ_VERIFY (BsGetBits (pBs, 8, &uiCode)); //profile_idc
@@ -840,29 +816,12 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW
iSpsId = uiCode;
if (kbUseSubsetFlag) {
#ifdef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
pSubsetSps = &pCtx->sSubsetSpsBuffer[pCtx->iSubspsTotalNum];
pCtx->bSubspsAvailFlags[pCtx->iSubspsTotalNum] = true;
pSubsetSps->sSps.iSpsId = iSpsId;
pSps = &pSubsetSps->sSps;
++pCtx->iSubspsTotalNum;
#else
pSubsetSps = &pCtx->sSubsetSpsBuffer[iSpsId];
pSps = &pSubsetSps->sSps;
pCtx->bSubspsAvailFlags[iSpsId] = true; // added for EC, 10/28/2009
#endif //MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
} else {
#ifdef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
pSps = &pCtx->sSpsBuffer[pCtx->iSpsTotalNum];
pCtx->bSpsAvailFlags[pCtx->iSpsTotalNum] = true;
pSps->iSpsId = iSpsId;
++pCtx->iSpsTotalNum;
#else
pSps = &pCtx->sSpsBuffer[iSpsId];
pCtx->bSpsAvailFlags[iSpsId] = true; // added for EC, 10/28/2009
#endif //MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
}
const SLevelLimits* pSLevelLimits = GetLevelLimits (uiLevelIdc, bConstraintSetFlags[3]);
if (NULL == pSLevelLimits) {
@@ -1073,12 +1032,7 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux)
return ERR_INFO_PPS_ID_OVERFLOW;
}
#ifdef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
pPps = &pPpsList[pCtx->iPpsTotalNum];
#else
pPps = &pPpsList[uiPpsId];
#endif //MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
pPps->iPpsId = uiPpsId;
WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //seq_parameter_set_id
@@ -1160,13 +1114,7 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux)
WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //redundant_pic_cnt_present_flag
pPps->bRedundantPicCntPresentFlag = !!uiCode;
#ifdef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
pCtx->bPpsAvailFlags[pCtx->iPpsTotalNum] = true;
++pCtx->iPpsTotalNum;
#else
pCtx->bPpsAvailFlags[uiPpsId] = true; // added for EC, 10/28/2009
#endif //MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
return ERR_NONE;
}

View File

@@ -371,100 +371,6 @@ void DecodeNalHeaderExt (PNalUnit pNal, uint8_t* pSrc) {
}
#ifdef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
int32_t CheckPpsId (PWelsDecoderContext pCtx, PPps* ppPps, uint32_t uiPpsId) {
PPps pPpsList = pCtx->sPpsBuffer;
int32_t iPpsNum = pCtx->iPpsTotalNum;
int32_t i = 0;
if (iPpsNum <= 0) {
pCtx->iErrorCode |= dsNoParamSets;
WelsLog (pCtx, WELS_LOG_WARNING, "CheckPpsId():::::PPS list is empty...NO PPS!!!\n");
return dsNoParamSets;
}
while (i < iPpsNum) {
if (uiPpsId == pPpsList[i].iPpsId) {
*ppPps = &pPpsList[i];
break;
} else {
++i;
}
}
if (i == iPpsNum) {
pCtx->iErrorCode |= dsNoParamSets;
WelsLog (pCtx, WELS_LOG_WARNING, "CheckPpsId()::::::CAN NOT find the matching from the PPS List. iPpsId:%d\n",
uiPpsId);
return dsNoParamSets;
}
return 0;
}
int32_t CheckSpsId (PWelsDecoderContext pCtx, PSubsetSps* ppSubsetSps, PSps* ppSps, int32_t iSpsId,
bool bExtensionFlag) {
PSps pSpsList = pCtx->sSpsBuffer;
PSubsetSps pSubspsList = pCtx->sSubsetSpsBuffer;
int32_t iSpsNum = pCtx->iSpsTotalNum;
int32_t iSubspsNum = pCtx->iSubspsTotalNum;
int32_t i = 0;
if (bExtensionFlag) {
if (iSubspsNum <= 0) {
pCtx->iErrorCode |= dsNoParamSets;
WelsLog (pCtx, WELS_LOG_WARNING, "CheckSpsId()::::SUBSPS list is empty....NO SUBSPS\n");
return dsNoParamSets;
}
while (i < iSubspsNum) {
if (iSpsId == pSubspsList[i].sSps.iSpsId) {
*ppSubsetSps = &pSubspsList[i];
*ppSps = &pSubspsList[i].sSps;
break;
} else {
++i;
}
}
if (i == iSubspsNum) {
pCtx->iErrorCode |= dsNoParamSets;
WelsLog (pCtx, WELS_LOG_WARNING, "CheckSpsId()::::::CAN NOT find the matching from the SUBSPS List. iSpsId:%d\n",
iSpsId);
return dsNoParamSets;
}
} else {
if (iSpsNum <= 0) {
pCtx->iErrorCode |= dsNoParamSets;
WelsLog (pCtx, WELS_LOG_WARNING, "CheckSpsId()::::SPS list is empty....NO SPS\n");
return dsNoParamSets;
}
while (i < iSpsNum) {
if (iSpsId == pSpsList[i].iSpsId) {
*ppSubsetSps = NULL;
*ppSps = &pSpsList[i];
break;
} else {
++i;
}
}
if (i == iSpsNum) {
pCtx->iErrorCode |= dsNoParamSets;
WelsLog (pCtx, WELS_LOG_WARNING, "CheckSpsId()::::::CAN NOT find the matching from the SPS List. iSpsId:%d\n", iSpsId);
return dsNoParamSets;
}
}
return 0;
}
#endif
#define SLICE_HEADER_IDR_PIC_ID_MAX 65535
#define SLICE_HEADER_REDUNDANT_PIC_CNT_MAX 127
#define SLICE_HEADER_ALPHAC0_BETA_OFFSET_MIN -12
@@ -552,13 +458,9 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_PPS_ID_OVERFLOW);
}
#ifdef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
if (CheckPpsId (pCtx, &pPps, iPpsId)) {
return dsNoParamSets;
}
#else
//add check PPS available here
pPps = &pCtx->sPpsBuffer[iPpsId];
#endif //MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
if (pPps->uiNumSliceGroups == 0) {
WelsLog (pCtx, WELS_LOG_WARNING, "non existing PPS referenced\n");
@@ -570,12 +472,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_SPS_ID_OVERFLOW);
}
//add check SPS available here
#ifdef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
if (CheckSpsId (pCtx, &pSubsetSps, &pSps, pPps->iSpsId, kExtensionFlag)) {
return dsNoParamSets;
}
#else
if (kbExtensionFlag) {
pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId];
pSps = &pSubsetSps->sSps;
@@ -583,7 +481,6 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co
pSps = &pCtx->sSpsBuffer[pPps->iSpsId];
}
pCtx->pSps = pSps;
#endif //MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
pSliceHead->iPpsId = iPpsId;
pSliceHead->iSpsId = pPps->iSpsId;
pSliceHead->pPps = pPps;