History

Fix ParseBSubMBTypeCabac. This fixed bug found by @fiona22 for some cases of 8x8 in B-Slice

xiaotianshicomcast committed 8 years ago

Commit 29021a81 parent 26a4ca24 files · +47 −37Browse files

Showing the changes to codec/decoder/plus/src/welsDecoderExt.cpp (1 of 4 files). Show all

Unified · Split

codec/decoder/plus/src/welsDecoderExt.cpp+37−30
@@ -73,6 +73,8 @@ extern "C" { · 72 unmodified lines
7373
7474 #define _PICTURE_REORDERING_ 1
7575
76+static int32_t sIMinInt32 = -0x7FFFFFFF;
77+
7678 namespace WelsDec {
7779
7880 //////////////////////////////////////////////////////////////////////
@@ -92,10 +94,11 @@ CWelsDecoder::CWelsDecoder (void) · 13 unmodified lines
9294 : m_pDecContext (NULL),
9395 m_pWelsTrace (NULL),
9496 m_iPictInfoIndex (0),
95− m_iMinPOC (-1),
97+ m_iMinPOC (sIMinInt32),
9698 m_iNumOfPicts (0),
9799 m_iLastGOPRemainPicts (0),
98− m_LastWrittenPOC (0) {
100+ m_LastWrittenPOC (sIMinInt32),
101+ m_iLargestBufferedPicIndex (0) {
99102 #ifdef OUTPUT_BIT_STREAM
100103 char chFileName[1024] = { 0 }; //for .264
101104 int iBufUsed = 0;
@@ -117,9 +120,9 @@ CWelsDecoder::CWelsDecoder (void) · 15 unmodified lines
117120 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::CWelsDecoder() entry");
118121 }
119122
120− for (int32_t i = 0; i < 10; ++i) {
123+ for (int32_t i = 0; i < 16; ++i) {
121124 m_sPictInfoList[i].bLastGOP = false;
122− m_sPictInfoList[i].iPOC = -1;
125+ m_sPictInfoList[i].iPOC = sIMinInt32;
123126 }
124127
125128 #ifdef OUTPUT_BIT_STREAM
@@ -661,19 +664,19 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 535 unmodified lines
661664 DECODING_STATE CWelsDecoder::FlushFrame (unsigned char** ppDst,
662665 SBufferInfo* pDstInfo) {
663666 if (m_pDecContext->bEndOfStreamFlag && m_iNumOfPicts > 0) {
664− m_iMinPOC = -1;
665− for (int32_t i = 0; i < 10; ++i) {
666− if (m_iMinPOC == -1 && m_sPictInfoList[i].iPOC >= 0) {
667+ m_iMinPOC = sIMinInt32;
668+ for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
669+ if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32) {
667670 m_iMinPOC = m_sPictInfoList[i].iPOC;
668671 m_iPictInfoIndex = i;
669672 }
670− if (m_sPictInfoList[i].iPOC >= 0 && m_sPictInfoList[i].iPOC < m_iMinPOC) {
673+ if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC) {
671674 m_iMinPOC = m_sPictInfoList[i].iPOC;
672675 m_iPictInfoIndex = i;
673676 }
674677 }
675678 }
676− if (m_iMinPOC >= 0) {
679+ if (m_iMinPOC > sIMinInt32) {
677680 m_LastWrittenPOC = m_iMinPOC;
678681 #if defined (_DEBUG)
679682 #ifdef _MOTION_VECTOR_DUMP_
@@ -684,9 +687,9 @@ DECODING_STATE CWelsDecoder::FlushFrame (unsigned char** ppDst, · 4 unmodified lines
684687 ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];
685688 ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];
686689 ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];
687− m_sPictInfoList[m_iPictInfoIndex].iPOC = -1;
690+ m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;
688691 m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;
689− m_iMinPOC = -1;
692+ m_iMinPOC = sIMinInt32;
690693 --m_iNumOfPicts;
691694 }
692695 return dsErrorFree;
@@ -743,15 +746,15 @@ DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SB · 50 unmodified lines
743746 if (m_pDecContext->pSliceHeader->iPicOrderCntLsb == 0) {
744747 if (m_iNumOfPicts > 0) {
745748 m_iLastGOPRemainPicts = m_iNumOfPicts;
746− for (int32_t i = 0; i < 10; ++i) {
747− if (m_sPictInfoList[i].iPOC >= 0) {
749+ for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
750+ if (m_sPictInfoList[i].iPOC > sIMinInt32) {
748751 m_sPictInfoList[i].bLastGOP = true;
749752 }
750753 }
751754 }
752755 }
753− for (int32_t i = 0; i < 10; ++i) {
754− if (m_sPictInfoList[i].iPOC == -1) {
756+ for (int32_t i = 0; i < 16; ++i) {
757+ if (m_sPictInfoList[i].iPOC == sIMinInt32) {
755758 memcpy (&m_sPictInfoList[i].sBufferInfo, pDstInfo, sizeof (SBufferInfo));
756759 m_sPictInfoList[i].pData[0] = ppDst[0];
757760 m_sPictInfoList[i].pData[1] = ppDst[1];
@@ -761,17 +764,20 @@ DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SB · 3 unmodified lines
761764 m_sPictInfoList[i].bLastGOP = false;
762765 pDstInfo->iBufferStatus = 0;
763766 ++m_iNumOfPicts;
767+ if (i > m_iLargestBufferedPicIndex) {
768+ m_iLargestBufferedPicIndex = i;
769+ }
764770 break;
765771 }
766772 }
767773 if (m_iLastGOPRemainPicts > 0) {
768− m_iMinPOC = -1;
769− for (int32_t i = 0; i < 10; ++i) {
770− if (m_iMinPOC == -1 && m_sPictInfoList[i].iPOC >= 0 && m_sPictInfoList[i].bLastGOP) {
774+ m_iMinPOC = sIMinInt32;
775+ for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
776+ if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].bLastGOP) {
771777 m_iMinPOC = m_sPictInfoList[i].iPOC;
772778 m_iPictInfoIndex = i;
773779 }
774− if (m_sPictInfoList[i].iPOC >= 0 && m_sPictInfoList[i].iPOC < m_iMinPOC && m_sPictInfoList[i].bLastGOP) {
780+ if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC && m_sPictInfoList[i].bLastGOP) {
775781 m_iMinPOC = m_sPictInfoList[i].iPOC;
776782 m_iPictInfoIndex = i;
777783 }
@@ -786,31 +792,32 @@ DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SB · 8 unmodified lines
786792 ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];
787793 ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];
788794 ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];
789− m_sPictInfoList[m_iPictInfoIndex].iPOC = -1;
795+ m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;
790796 m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;
791− m_iMinPOC = -1;
797+ m_iMinPOC = sIMinInt32;
792798 --m_iNumOfPicts;
793799 --m_iLastGOPRemainPicts;
794800 if (m_iLastGOPRemainPicts == 0) {
795− m_LastWrittenPOC = 0;
801+ m_LastWrittenPOC = sIMinInt32;
796802 }
797803 return dsErrorFree;
798804 }
799805 if (m_iNumOfPicts > 0) {
800− m_iMinPOC = -1;
801− for (int32_t i = 0; i < 10; ++i) {
802− if (m_iMinPOC == -1 && m_sPictInfoList[i].iPOC >= 0) {
806+ m_iMinPOC = sIMinInt32;
807+ for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
808+ if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32) {
803809 m_iMinPOC = m_sPictInfoList[i].iPOC;
804810 m_iPictInfoIndex = i;
805811 }
806− if (m_sPictInfoList[i].iPOC >= 0 && m_sPictInfoList[i].iPOC < m_iMinPOC) {
812+ if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC) {
807813 m_iMinPOC = m_sPictInfoList[i].iPOC;
808814 m_iPictInfoIndex = i;
809815 }
810816 }
811817 }
812− if (m_iMinPOC >= 0) {
813− if (m_iMinPOC - m_LastWrittenPOC <= 1 || m_iMinPOC < m_pDecContext->pSliceHeader->iPicOrderCntLsb) {
818+ if (m_iMinPOC > sIMinInt32) {
819+ if ((m_LastWrittenPOC > sIMinInt32 && m_iMinPOC - m_LastWrittenPOC <= 1)
820+ || m_iMinPOC < m_pDecContext->pSliceHeader->iPicOrderCntLsb) {
814821 m_LastWrittenPOC = m_iMinPOC;
815822 #if defined (_DEBUG)
816823 #ifdef _MOTION_VECTOR_DUMP_
@@ -821,9 +828,9 @@ DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SB · 4 unmodified lines
821828 ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];
822829 ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];
823830 ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];
824− m_sPictInfoList[m_iPictInfoIndex].iPOC = -1;
831+ m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;
825832 m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;
826− m_iMinPOC = -1;
833+ m_iMinPOC = sIMinInt32;
827834 --m_iNumOfPicts;
828835 return dsErrorFree;
829836 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t