ref: 4ebeb4bb70e4c3e39375e6875bc8bab0861533d7
parent: b455c035f76776ec2fbc0f67f69744e8ba071c7f
parent: 586893ca4bf51575c2f725e0b6900a846443f15b
author: dongzha <dongzha@cisco.com>
date: Fri Dec 26 04:30:43 EST 2014
Merge pull request #1673 from HaiboZhu/Debug_Crash_NoAU_SPS_Update Add SPS/SubSPS/PPS update when AU number==0 and iOverwriteFlags==true
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -562,10 +562,17 @@
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_PPS_ID);
}
- if (pCtx->iOverwriteFlags & OVERWRITE_PPS)
- pPps = &pCtx->sPpsBuffer[MAX_PPS_COUNT];
- else
+ if (pCtx->iOverwriteFlags & OVERWRITE_PPS) {
+ if (pCtx->pAccessUnitList->uiAvailUnitsNum > 1 || pCtx->iTotalNumMbRec > 0) {
+ pPps = &pCtx->sPpsBuffer[MAX_PPS_COUNT];
+ } else {
+ memcpy (&pCtx->sPpsBuffer[pCtx->sPpsBuffer[MAX_PPS_COUNT].iPpsId], &pCtx->sPpsBuffer[MAX_PPS_COUNT], sizeof (SPps));
+ pCtx->iOverwriteFlags ^= OVERWRITE_PPS;
+ pPps = &pCtx->sPpsBuffer[iPpsId];
+ }
+ } else {
pPps = &pCtx->sPpsBuffer[iPpsId];
+ }
if (pPps->uiNumSliceGroups == 0) {
WelsLog (pLogCtx, WELS_LOG_WARNING, "Invalid PPS referenced");
@@ -574,10 +581,19 @@
}
if (kbExtensionFlag) {
- if (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS)
- pSubsetSps = &pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT];
- else
- pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId];
+ if (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS) {
+ if (pCtx->pAccessUnitList->uiAvailUnitsNum > 1 || pCtx->iTotalNumMbRec > 0) {
+ pSubsetSps = &pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT];
+ } else {
+ memcpy (&pCtx->sSubsetSpsBuffer[pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT].sSps.iSpsId],
+ &pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT], sizeof (SSubsetSps));
+ pCtx->iOverwriteFlags ^= OVERWRITE_SUBSETSPS;
+ pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId];
+ ResetActiveSPSForEachLayer (pCtx);
+ }
+ } else {
+ pSubsetSps = &pCtx->sSubsetSpsBuffer[pPps->iSpsId];
+ }
pSps = &pSubsetSps->sSps;
if (pCtx->bSubspsAvailFlags[pPps->iSpsId] == false) {
WelsLog (pLogCtx, WELS_LOG_ERROR, "SPS id is invalid!");
@@ -590,10 +606,18 @@
pCtx->iErrorCode |= dsNoParamSets;
return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID);
}
- if (pCtx->iOverwriteFlags & OVERWRITE_SPS)
- pSps = &pCtx->sSpsBuffer[MAX_SPS_COUNT];
- else
+ if (pCtx->iOverwriteFlags & OVERWRITE_SPS) {
+ if (pCtx->pAccessUnitList->uiAvailUnitsNum > 1 || pCtx->iTotalNumMbRec > 0) {
+ pSps = &pCtx->sSpsBuffer[MAX_SPS_COUNT];
+ } else {
+ memcpy (&pCtx->sSpsBuffer[pCtx->sSpsBuffer[MAX_SPS_COUNT].iSpsId], &pCtx->sSpsBuffer[MAX_SPS_COUNT], sizeof (SSps));
+ pCtx->iOverwriteFlags ^= OVERWRITE_SPS;
+ pSps = &pCtx->sSpsBuffer[pPps->iSpsId];
+ ResetActiveSPSForEachLayer (pCtx);
+ }
+ } else {
pSps = &pCtx->sSpsBuffer[pPps->iSpsId];
+ }
}
pSliceHead->iPpsId = iPpsId;
pSliceHead->iSpsId = pPps->iSpsId;