ref: 29021a871d0fd74965a1b64102fc14dd3c4c3608
parent: 26a4ca212233f9854d306e39d3f0024108143321
author: xiaotianshicomcast <[email protected]>
date: Wed Jul 25 12:23:24 EDT 2018
Fix ParseBSubMBTypeCabac. This fixed bug found by @fiona22 for some cases of 8x8 in B-Slice
--- a/codec/decoder/core/src/parse_mb_syn_cabac.cpp
+++ b/codec/decoder/core/src/parse_mb_syn_cabac.cpp
@@ -441,6 +441,7 @@
if (uiCode) {
WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, uiCode));
if (uiCode) {
+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + 3, uiCode));
uiSubMbType = 11 + uiCode; /* B_L1_4x4, B_Bi_4x4 */
return ERR_NONE;
}
--- a/codec/decoder/core/src/rec_mb.cpp
+++ b/codec/decoder/core/src/rec_mb.cpp
@@ -222,12 +222,14 @@
if (iRefIdx >= 0) {
pRefPic = pCtx->sRefPic.pRefList[listIdx][iRefIdx];
- pMCRefMem->iSrcLineLuma = pRefPic->iLinesize[0];
- pMCRefMem->iSrcLineChroma = pRefPic->iLinesize[1];
+ if (pRefPic != NULL) {
+ pMCRefMem->iSrcLineLuma = pRefPic->iLinesize[0];
+ pMCRefMem->iSrcLineChroma = pRefPic->iLinesize[1];
- pMCRefMem->pSrcY = pRefPic->pData[0];
- pMCRefMem->pSrcU = pRefPic->pData[1];
- pMCRefMem->pSrcV = pRefPic->pData[2];
+ pMCRefMem->pSrcY = pRefPic->pData[0];
+ pMCRefMem->pSrcU = pRefPic->pData[1];
+ pMCRefMem->pSrcV = pRefPic->pData[2];
+ }
}
}
--- a/codec/decoder/plus/inc/welsDecoderExt.h
+++ b/codec/decoder/plus/inc/welsDecoderExt.h
@@ -120,13 +120,13 @@
private:
PWelsDecoderContext m_pDecContext;
welsCodecTrace* m_pWelsTrace;
- SPictInfo m_sPictInfoList[10];
+ SPictInfo m_sPictInfoList[16];
int32_t m_iPictInfoIndex;
int32_t m_iMinPOC;
int32_t m_iNumOfPicts;
int32_t m_iLastGOPRemainPicts;
-
int32_t m_LastWrittenPOC;
+ int32_t m_iLargestBufferedPicIndex;
int32_t InitDecoder (const SDecodingParam* pParam);
void UninitDecoder (void);
--- a/codec/decoder/plus/src/welsDecoderExt.cpp
+++ b/codec/decoder/plus/src/welsDecoderExt.cpp
@@ -73,6 +73,8 @@
#define _PICTURE_REORDERING_ 1
+static int32_t sIMinInt32 = -0x7FFFFFFF;
+
namespace WelsDec {
//////////////////////////////////////////////////////////////////////
@@ -92,10 +94,11 @@
: m_pDecContext (NULL),
m_pWelsTrace (NULL),
m_iPictInfoIndex (0),
- m_iMinPOC (-1),
+ m_iMinPOC (sIMinInt32),
m_iNumOfPicts (0),
m_iLastGOPRemainPicts (0),
- m_LastWrittenPOC (0) {
+ m_LastWrittenPOC (sIMinInt32),
+ m_iLargestBufferedPicIndex (0) {
#ifdef OUTPUT_BIT_STREAM
char chFileName[1024] = { 0 }; //for .264
int iBufUsed = 0;
@@ -117,9 +120,9 @@
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::CWelsDecoder() entry");
}
- for (int32_t i = 0; i < 10; ++i) {
+ for (int32_t i = 0; i < 16; ++i) {
m_sPictInfoList[i].bLastGOP = false;
- m_sPictInfoList[i].iPOC = -1;
+ m_sPictInfoList[i].iPOC = sIMinInt32;
}
#ifdef OUTPUT_BIT_STREAM
@@ -661,19 +664,19 @@
DECODING_STATE CWelsDecoder::FlushFrame (unsigned char** ppDst,
SBufferInfo* pDstInfo) {
if (m_pDecContext->bEndOfStreamFlag && m_iNumOfPicts > 0) {
- m_iMinPOC = -1;
- for (int32_t i = 0; i < 10; ++i) {
- if (m_iMinPOC == -1 && m_sPictInfoList[i].iPOC >= 0) {
+ m_iMinPOC = sIMinInt32;
+ for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
+ if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32) {
m_iMinPOC = m_sPictInfoList[i].iPOC;
m_iPictInfoIndex = i;
}
- if (m_sPictInfoList[i].iPOC >= 0 && m_sPictInfoList[i].iPOC < m_iMinPOC) {
+ if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC) {
m_iMinPOC = m_sPictInfoList[i].iPOC;
m_iPictInfoIndex = i;
}
}
}
- if (m_iMinPOC >= 0) {
+ if (m_iMinPOC > sIMinInt32) {
m_LastWrittenPOC = m_iMinPOC;
#if defined (_DEBUG)
#ifdef _MOTION_VECTOR_DUMP_
@@ -684,9 +687,9 @@
ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];
ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];
ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];
- m_sPictInfoList[m_iPictInfoIndex].iPOC = -1;
+ m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;
m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;
- m_iMinPOC = -1;
+ m_iMinPOC = sIMinInt32;
--m_iNumOfPicts;
}
return dsErrorFree;
@@ -743,15 +746,15 @@
if (m_pDecContext->pSliceHeader->iPicOrderCntLsb == 0) {
if (m_iNumOfPicts > 0) {
m_iLastGOPRemainPicts = m_iNumOfPicts;
- for (int32_t i = 0; i < 10; ++i) {
- if (m_sPictInfoList[i].iPOC >= 0) {
+ for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
+ if (m_sPictInfoList[i].iPOC > sIMinInt32) {
m_sPictInfoList[i].bLastGOP = true;
}
}
}
}
- for (int32_t i = 0; i < 10; ++i) {
- if (m_sPictInfoList[i].iPOC == -1) {
+ for (int32_t i = 0; i < 16; ++i) {
+ if (m_sPictInfoList[i].iPOC == sIMinInt32) {
memcpy (&m_sPictInfoList[i].sBufferInfo, pDstInfo, sizeof (SBufferInfo));
m_sPictInfoList[i].pData[0] = ppDst[0];
m_sPictInfoList[i].pData[1] = ppDst[1];
@@ -761,17 +764,20 @@
m_sPictInfoList[i].bLastGOP = false;
pDstInfo->iBufferStatus = 0;
++m_iNumOfPicts;
+ if (i > m_iLargestBufferedPicIndex) {
+ m_iLargestBufferedPicIndex = i;
+ }
break;
}
}
if (m_iLastGOPRemainPicts > 0) {
- m_iMinPOC = -1;
- for (int32_t i = 0; i < 10; ++i) {
- if (m_iMinPOC == -1 && m_sPictInfoList[i].iPOC >= 0 && m_sPictInfoList[i].bLastGOP) {
+ m_iMinPOC = sIMinInt32;
+ for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
+ if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].bLastGOP) {
m_iMinPOC = m_sPictInfoList[i].iPOC;
m_iPictInfoIndex = i;
}
- if (m_sPictInfoList[i].iPOC >= 0 && m_sPictInfoList[i].iPOC < m_iMinPOC && m_sPictInfoList[i].bLastGOP) {
+ if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC && m_sPictInfoList[i].bLastGOP) {
m_iMinPOC = m_sPictInfoList[i].iPOC;
m_iPictInfoIndex = i;
}
@@ -786,31 +792,32 @@
ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];
ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];
ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];
- m_sPictInfoList[m_iPictInfoIndex].iPOC = -1;
+ m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;
m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;
- m_iMinPOC = -1;
+ m_iMinPOC = sIMinInt32;
--m_iNumOfPicts;
--m_iLastGOPRemainPicts;
if (m_iLastGOPRemainPicts == 0) {
- m_LastWrittenPOC = 0;
+ m_LastWrittenPOC = sIMinInt32;
}
return dsErrorFree;
}
if (m_iNumOfPicts > 0) {
- m_iMinPOC = -1;
- for (int32_t i = 0; i < 10; ++i) {
- if (m_iMinPOC == -1 && m_sPictInfoList[i].iPOC >= 0) {
+ m_iMinPOC = sIMinInt32;
+ for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
+ if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32) {
m_iMinPOC = m_sPictInfoList[i].iPOC;
m_iPictInfoIndex = i;
}
- if (m_sPictInfoList[i].iPOC >= 0 && m_sPictInfoList[i].iPOC < m_iMinPOC) {
+ if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC) {
m_iMinPOC = m_sPictInfoList[i].iPOC;
m_iPictInfoIndex = i;
}
}
}
- if (m_iMinPOC >= 0) {
- if (m_iMinPOC - m_LastWrittenPOC <= 1 || m_iMinPOC < m_pDecContext->pSliceHeader->iPicOrderCntLsb) {
+ if (m_iMinPOC > sIMinInt32) {
+ if ((m_LastWrittenPOC > sIMinInt32 && m_iMinPOC - m_LastWrittenPOC <= 1)
+ || m_iMinPOC < m_pDecContext->pSliceHeader->iPicOrderCntLsb) {
m_LastWrittenPOC = m_iMinPOC;
#if defined (_DEBUG)
#ifdef _MOTION_VECTOR_DUMP_
@@ -821,9 +828,9 @@
ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];
ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];
ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];
- m_sPictInfoList[m_iPictInfoIndex].iPOC = -1;
+ m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;
m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;
- m_iMinPOC = -1;
+ m_iMinPOC = sIMinInt32;
--m_iNumOfPicts;
return dsErrorFree;
}