ref: c2b000431f56ed1b2d3d6743218bf037ca5e330e
parent: 4b8913f3390fd6d1b7276de32248fdd3261ed0aa
author: xiaotiansf <xiaotianshimail@gmail.com>
date: Fri Jan 4 11:20:29 EST 2019
Implemented a generic way to prevent the queued decoded B-frame buffers from being overwritten.
--- a/codec/decoder/core/inc/slice.h
+++ b/codec/decoder/core/inc/slice.h
@@ -123,7 +123,6 @@
int32_t iSpsId;
int32_t iPpsId;
bool bIdrFlag;
- bool bIsRefPic;
/*********************got from other layer for efficency if possible*********************/
SRefPicListReorderSyn pRefPicListReordering; // Reference picture list reordering syntaxs
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -873,8 +873,6 @@
pSliceHeadExt = &kpCurNal->sNalData.sVclNal.sSliceHeaderExt;
- pSliceHead->bIsRefPic = false;
-
if (pSliceHeadExt) {
SRefBasePicMarking sBaseMarking;
const bool kbStoreRefBaseFlag = pSliceHeadExt->bStoreRefBasePicFlag;
@@ -2475,7 +2473,6 @@
dq_cur->pBitStringAux = &pNalCur->sNalData.sVclNal.sSliceBitsRead;
uiNalRefIdc = pNalCur->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc;
- pSh->bIsRefPic = uiNalRefIdc > 0;
iPpsId = pSh->iPpsId;
--- a/codec/decoder/plus/inc/welsDecoderExt.h
+++ b/codec/decoder/plus/inc/welsDecoderExt.h
@@ -112,7 +112,7 @@
typedef struct tagPictInfo {
SBufferInfo sBufferInfo;
int32_t iPOC;
- int32_t iFrameNum;
+ int32_t iPicBuffIdx;
bool bLastGOP;
unsigned char* pData[3];
} SPictInfo, *PPictInfo;
--- a/codec/decoder/plus/src/welsDecoderExt.cpp
+++ b/codec/decoder/plus/src/welsDecoderExt.cpp
@@ -690,6 +690,7 @@
ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];
ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];
m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;
+ m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[m_iPictInfoIndex].iPicBuffIdx]->bAvailableFlag = true;
m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;
m_iMinPOC = sIMinInt32;
--m_iNumOfPicts;
@@ -743,14 +744,8 @@
}
DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SBufferInfo* pDstInfo) {
+ DECODING_STATE iRet = dsErrorFree;
if (pDstInfo->iBufferStatus == 1 && m_pDecContext->pSps->uiProfileIdc != 66) {
- //Non-reference B_FRAME (disposable) must be released and must not be buffered because its buffer could be overwritten by next reference picture.
- if (m_pDecContext->pSliceHeader->eSliceType == B_SLICE && !m_pDecContext->pSliceHeader->bIsRefPic) {
- if (m_pDecContext->pSliceHeader->iPicOrderCntLsb - m_LastWrittenPOC <= 2) {
- m_LastWrittenPOC = m_pDecContext->pSliceHeader->iPicOrderCntLsb;
- return dsErrorFree;
- }
- }
if (m_pDecContext->pSliceHeader->iPicOrderCntLsb == 0) {
if (m_iNumOfPicts > 0) {
m_iLastGOPRemainPicts = m_iNumOfPicts;
@@ -768,7 +763,8 @@
m_sPictInfoList[i].pData[1] = ppDst[1];
m_sPictInfoList[i].pData[2] = ppDst[2];
m_sPictInfoList[i].iPOC = m_pDecContext->pSliceHeader->iPicOrderCntLsb;
- m_sPictInfoList[i].iFrameNum = m_pDecContext->pSliceHeader->iFrameNum;
+ m_sPictInfoList[i].iPicBuffIdx = m_pDecContext->pPicBuff->iCurrentIdx;
+ m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[i].iPicBuffIdx]->bAvailableFlag = false;
m_sPictInfoList[i].bLastGOP = false;
pDstInfo->iBufferStatus = 0;
++m_iNumOfPicts;
@@ -801,6 +797,7 @@
ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];
ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];
m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;
+ m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[m_iPictInfoIndex].iPicBuffIdx]->bAvailableFlag = true;
m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;
m_iMinPOC = sIMinInt32;
--m_iNumOfPicts;
@@ -808,7 +805,7 @@
if (m_iLastGOPRemainPicts == 0) {
m_LastWrittenPOC = sIMinInt32;
}
- return dsErrorFree;
+ return iRet;
}
if (m_iNumOfPicts > 0) {
m_iMinPOC = sIMinInt32;
@@ -837,15 +834,16 @@
ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];
ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];
m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;
+ m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[m_iPictInfoIndex].iPicBuffIdx]->bAvailableFlag = true;
m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;
m_iMinPOC = sIMinInt32;
--m_iNumOfPicts;
- return dsErrorFree;
+ return iRet;
}
}
}
- return dsErrorFree;
+ return iRet;
}
DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc,