ref: e4b6fc3f9a0944a1d7ddd95d38a1a1d806ac6b87
parent: 3d47b7847d6e8a6f5c186f87d40058c839234995
author: Licai Guo <guolicai@gmail.com>
date: Thu Feb 27 17:28:16 EST 2014
modify SPS, PPS buffer management and remove a build warning
--- a/codec/decoder/core/inc/decoder_context.h
+++ b/codec/decoder/core/inc/decoder_context.h
@@ -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;
@@ -233,12 +229,6 @@
/* Global memory external */
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];
--- a/codec/decoder/core/src/au_parser.cpp
+++ b/codec/decoder/core/src/au_parser.cpp
@@ -322,26 +322,8 @@
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 @@
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 @@
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 @@
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,13 +1032,8 @@
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
pPps->iSpsId = uiCode;
@@ -1160,13 +1114,7 @@
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;
}
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -371,100 +371,6 @@
}
-#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 @@
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 @@
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 @@
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;