Merge pull request from licaiguo/tracklayersps

add track sps change for each layer
This commit is contained in:
huili2 2014-04-15 11:05:45 +08:00
commit 77aaf2ea8e
2 changed files with 55 additions and 8 deletions
codec/decoder/core

View File

@ -236,7 +236,6 @@ typedef struct TagWelsDecoderContext {
PAccessUnit pAccessUnitList; // current access unit list to be performed PAccessUnit pAccessUnitList; // current access unit list to be performed
PSps pActiveLayerSps[MAX_LAYER_NUM]; PSps pActiveLayerSps[MAX_LAYER_NUM];
PPps pActiveLayerPps[MAX_LAYER_NUM];
PSps pSps; // used by current AU PSps pSps; // used by current AU
PPps pPps; // used by current AU PPps pPps; // used by current AU
// Memory for pAccessUnitList is dynamically held till decoder destruction. // Memory for pAccessUnitList is dynamically held till decoder destruction.
@ -272,7 +271,7 @@ typedef struct TagWelsDecoderContext {
uint16_t uiCurIdrPicId; uint16_t uiCurIdrPicId;
#endif #endif
bool bNewSeqBegin;
int32_t iErrorConMethod; // int32_t iErrorConMethod; //
PGetIntraPredFunc pGetI16x16LumaPredFunc[7]; //h264_predict_copy_16x16; PGetIntraPredFunc pGetI16x16LumaPredFunc[7]; //h264_predict_copy_16x16;
PGetIntraPredFunc pGetI4x4LumaPredFunc[14]; // h264_predict_4x4_t PGetIntraPredFunc pGetI4x4LumaPredFunc[14]; // h264_predict_4x4_t
@ -311,6 +310,11 @@ typedef struct TagWelsDecoderContext {
} SWelsDecoderContext, *PWelsDecoderContext; } SWelsDecoderContext, *PWelsDecoderContext;
static inline void ResetActiveSPSForEachLayer(PWelsDecoderContext pCtx) {
for(int i = 0; i < MAX_LAYER_NUM; i++) {
pCtx->pActiveLayerSps[i] = NULL;
}
}
//#ifdef __cplusplus //#ifdef __cplusplus
//} //}
//#endif//__cplusplus //#endif//__cplusplus

View File

@ -866,9 +866,9 @@ int32_t UpdateAccessUnit (PWelsDecoderContext pCtx) {
// Added for mosaic avoidance, 11/19/2009 // Added for mosaic avoidance, 11/19/2009
#ifdef LONG_TERM_REF #ifdef LONG_TERM_REF
if (pCtx->bParamSetsLostFlag) if (pCtx->bParamSetsLostFlag || pCtx->bNewSeqBegin)
#else #else
if (pCtx->bReferenceLostAtT0Flag) if (pCtx->bReferenceLostAtT0Flag || pCtx->bNewSeqBegin)
#endif #endif
{ {
uint32_t uiActualIdx = 0; uint32_t uiActualIdx = 0;
@ -1458,8 +1458,51 @@ void WelsDecodeAccessUnitEnd (PWelsDecoderContext pCtx) {
ResetCurrentAccessUnit (pCtx); ResetCurrentAccessUnit (pCtx);
} }
/* CheckNewSeqBeginAndUpdateActiveLayerSps
* return:
* true - the AU to be construct is the start of new sequence; false - not
*/
static bool CheckNewSeqBeginAndUpdateActiveLayerSps(PWelsDecoderContext pCtx) {
bool bNewSeq = false;
PAccessUnit pCurAu = pCtx->pAccessUnitList;
PSps pTmpLayerSps[MAX_LAYER_NUM];
for(int i = 0; i < MAX_LAYER_NUM; i++) {
pTmpLayerSps[i] = NULL;
}
// track the layer sps for the current au
for(int i = pCurAu->uiStartPos; i <= pCurAu->uiEndPos; i++) {
uint32_t uiDid = pCurAu->pNalUnitsList[i]->sNalHeaderExt.uiDependencyId;
pTmpLayerSps[uiDid] = pCurAu->pNalUnitsList[i]->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps;
}
int iMaxActiveLayer, iMaxCurrentLayer;
for(int i = MAX_LAYER_NUM - 1; i >= 0; i--) {
if (pCtx->pActiveLayerSps[i] != NULL) {
iMaxActiveLayer = i;
break;
}
}
for(int i = MAX_LAYER_NUM - 1; i >= 0; i--) {
if (pTmpLayerSps[i] != NULL) {
iMaxCurrentLayer = i;
break;
}
}
if (iMaxCurrentLayer != iMaxActiveLayer) {
bNewSeq = true;
}
// fill active sps if the current sps is not null while active layer is null
if (!bNewSeq) {
for(int i = 0; i < MAX_LAYER_NUM; i++) {
if (pCtx->pActiveLayerSps[i] == NULL && pTmpLayerSps[i] != NULL) {
pCtx->pActiveLayerSps[i] = pTmpLayerSps[i];
}
}
} else {
// UpdateActiveLayerSps if new sequence start
memcpy(&pCtx->pActiveLayerSps[0], &pTmpLayerSps[0], MAX_LAYER_NUM * sizeof(PSps));
}
return bNewSeq;
}
/* /*
* ConstructAccessUnit * ConstructAccessUnit
@ -1483,7 +1526,7 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI
pCtx->bAuReadyFlag = false; pCtx->bAuReadyFlag = false;
pCtx->bLastHasMmco5 = false; pCtx->bLastHasMmco5 = false;
pCtx->bNewSeqBegin = CheckNewSeqBeginAndUpdateActiveLayerSps(pCtx);
iErr = WelsDecodeAccessUnitStart (pCtx); iErr = WelsDecodeAccessUnitStart (pCtx);
GetVclNalTemporalId (pCtx); GetVclNalTemporalId (pCtx);
@ -1512,7 +1555,7 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI
iErr = DecodeCurrentAccessUnit (pCtx, ppDst, iStride, &iWidth, &iHeight, pDstInfo); iErr = DecodeCurrentAccessUnit (pCtx, ppDst, iStride, &iWidth, &iHeight, pDstInfo);
WelsDecodeAccessUnitEnd (pCtx); WelsDecodeAccessUnitEnd (pCtx);
pCtx->bNewSeqBegin = false;
if (ERR_NONE != iErr) { if (ERR_NONE != iErr) {
WelsLog (pCtx, WELS_LOG_INFO, "returned error from decoding:[0x%x]\n", iErr); WelsLog (pCtx, WELS_LOG_INFO, "returned error from decoding:[0x%x]\n", iErr);