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
73 73
74#define _PICTURE_REORDERING_ 174#define _PICTURE_REORDERING_ 1
75 75
76static int32_t sIMinInt32 = -0x7FFFFFFF;
77
76namespace WelsDec {78namespace WelsDec {
77 79
78//////////////////////////////////////////////////////////////////////80//////////////////////////////////////////////////////////////////////
@@ -92,10 +94,11 @@ CWelsDecoder::CWelsDecoder (void) · 13 unmodified lines
92 : m_pDecContext (NULL),94 : m_pDecContext (NULL),
93 m_pWelsTrace (NULL),95 m_pWelsTrace (NULL),
94 m_iPictInfoIndex (0),96 m_iPictInfoIndex (0),
95 m_iMinPOC (-1),97 m_iMinPOC (sIMinInt32),
96 m_iNumOfPicts (0),98 m_iNumOfPicts (0),
97 m_iLastGOPRemainPicts (0),99 m_iLastGOPRemainPicts (0),
98 m_LastWrittenPOC (0) {100 m_LastWrittenPOC (sIMinInt32),
101 m_iLargestBufferedPicIndex (0) {
99#ifdef OUTPUT_BIT_STREAM102#ifdef OUTPUT_BIT_STREAM
100 char chFileName[1024] = { 0 }; //for .264103 char chFileName[1024] = { 0 }; //for .264
101 int iBufUsed = 0;104 int iBufUsed = 0;
@@ -117,9 +120,9 @@ CWelsDecoder::CWelsDecoder (void) · 15 unmodified lines
117 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::CWelsDecoder() entry");120 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::CWelsDecoder() entry");
118 }121 }
119 122
120 for (int32_t i = 0; i < 10; ++i) {123 for (int32_t i = 0; i < 16; ++i) {
121 m_sPictInfoList[i].bLastGOP = false;124 m_sPictInfoList[i].bLastGOP = false;
122 m_sPictInfoList[i].iPOC = -1;125 m_sPictInfoList[i].iPOC = sIMinInt32;
123 }126 }
124 127
125#ifdef OUTPUT_BIT_STREAM128#ifdef OUTPUT_BIT_STREAM
@@ -661,19 +664,19 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 535 unmodified lines
661DECODING_STATE CWelsDecoder::FlushFrame (unsigned char** ppDst,664DECODING_STATE CWelsDecoder::FlushFrame (unsigned char** ppDst,
662 SBufferInfo* pDstInfo) {665 SBufferInfo* pDstInfo) {
663 if (m_pDecContext->bEndOfStreamFlag && m_iNumOfPicts > 0) {666 if (m_pDecContext->bEndOfStreamFlag && m_iNumOfPicts > 0) {
664 m_iMinPOC = -1;667 m_iMinPOC = sIMinInt32;
665 for (int32_t i = 0; i < 10; ++i) {668 for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
666 if (m_iMinPOC == -1 && m_sPictInfoList[i].iPOC >= 0) {669 if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32) {
667 m_iMinPOC = m_sPictInfoList[i].iPOC;670 m_iMinPOC = m_sPictInfoList[i].iPOC;
668 m_iPictInfoIndex = i;671 m_iPictInfoIndex = i;
669 }672 }
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) {
671 m_iMinPOC = m_sPictInfoList[i].iPOC;674 m_iMinPOC = m_sPictInfoList[i].iPOC;
672 m_iPictInfoIndex = i;675 m_iPictInfoIndex = i;
673 }676 }
674 }677 }
675 }678 }
676 if (m_iMinPOC >= 0) {679 if (m_iMinPOC > sIMinInt32) {
677 m_LastWrittenPOC = m_iMinPOC;680 m_LastWrittenPOC = m_iMinPOC;
678#if defined (_DEBUG)681#if defined (_DEBUG)
679#ifdef _MOTION_VECTOR_DUMP_682#ifdef _MOTION_VECTOR_DUMP_
@@ -684,9 +687,9 @@ DECODING_STATE CWelsDecoder::FlushFrame (unsigned char** ppDst, · 4 unmodified lines
684 ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];687 ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];
685 ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];688 ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];
686 ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];689 ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];
687 m_sPictInfoList[m_iPictInfoIndex].iPOC = -1;690 m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;
688 m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;691 m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;
689 m_iMinPOC = -1;692 m_iMinPOC = sIMinInt32;
690 --m_iNumOfPicts;693 --m_iNumOfPicts;
691 }694 }
692 return dsErrorFree;695 return dsErrorFree;
@@ -743,15 +746,15 @@ DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SB · 50 unmodified lines
743 if (m_pDecContext->pSliceHeader->iPicOrderCntLsb == 0) {746 if (m_pDecContext->pSliceHeader->iPicOrderCntLsb == 0) {
744 if (m_iNumOfPicts > 0) {747 if (m_iNumOfPicts > 0) {
745 m_iLastGOPRemainPicts = m_iNumOfPicts;748 m_iLastGOPRemainPicts = m_iNumOfPicts;
746 for (int32_t i = 0; i < 10; ++i) {749 for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
747 if (m_sPictInfoList[i].iPOC >= 0) {750 if (m_sPictInfoList[i].iPOC > sIMinInt32) {
748 m_sPictInfoList[i].bLastGOP = true;751 m_sPictInfoList[i].bLastGOP = true;
749 }752 }
750 }753 }
751 }754 }
752 }755 }
753 for (int32_t i = 0; i < 10; ++i) {756 for (int32_t i = 0; i < 16; ++i) {
754 if (m_sPictInfoList[i].iPOC == -1) {757 if (m_sPictInfoList[i].iPOC == sIMinInt32) {
755 memcpy (&m_sPictInfoList[i].sBufferInfo, pDstInfo, sizeof (SBufferInfo));758 memcpy (&m_sPictInfoList[i].sBufferInfo, pDstInfo, sizeof (SBufferInfo));
756 m_sPictInfoList[i].pData[0] = ppDst[0];759 m_sPictInfoList[i].pData[0] = ppDst[0];
757 m_sPictInfoList[i].pData[1] = ppDst[1];760 m_sPictInfoList[i].pData[1] = ppDst[1];
@@ -761,17 +764,20 @@ DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SB · 3 unmodified lines
761 m_sPictInfoList[i].bLastGOP = false;764 m_sPictInfoList[i].bLastGOP = false;
762 pDstInfo->iBufferStatus = 0;765 pDstInfo->iBufferStatus = 0;
763 ++m_iNumOfPicts;766 ++m_iNumOfPicts;
767 if (i > m_iLargestBufferedPicIndex) {
768 m_iLargestBufferedPicIndex = i;
769 }
764 break;770 break;
765 }771 }
766 }772 }
767 if (m_iLastGOPRemainPicts > 0) {773 if (m_iLastGOPRemainPicts > 0) {
768 m_iMinPOC = -1;774 m_iMinPOC = sIMinInt32;
769 for (int32_t i = 0; i < 10; ++i) {775 for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
770 if (m_iMinPOC == -1 && m_sPictInfoList[i].iPOC >= 0 && m_sPictInfoList[i].bLastGOP) {776 if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].bLastGOP) {
771 m_iMinPOC = m_sPictInfoList[i].iPOC;777 m_iMinPOC = m_sPictInfoList[i].iPOC;
772 m_iPictInfoIndex = i;778 m_iPictInfoIndex = i;
773 }779 }
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) {
775 m_iMinPOC = m_sPictInfoList[i].iPOC;781 m_iMinPOC = m_sPictInfoList[i].iPOC;
776 m_iPictInfoIndex = i;782 m_iPictInfoIndex = i;
777 }783 }
@@ -786,31 +792,32 @@ DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SB · 8 unmodified lines
786 ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];792 ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];
787 ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];793 ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];
788 ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];794 ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];
789 m_sPictInfoList[m_iPictInfoIndex].iPOC = -1;795 m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;
790 m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;796 m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;
791 m_iMinPOC = -1;797 m_iMinPOC = sIMinInt32;
792 --m_iNumOfPicts;798 --m_iNumOfPicts;
793 --m_iLastGOPRemainPicts;799 --m_iLastGOPRemainPicts;
794 if (m_iLastGOPRemainPicts == 0) {800 if (m_iLastGOPRemainPicts == 0) {
795 m_LastWrittenPOC = 0;801 m_LastWrittenPOC = sIMinInt32;
796 }802 }
797 return dsErrorFree;803 return dsErrorFree;
798 }804 }
799 if (m_iNumOfPicts > 0) {805 if (m_iNumOfPicts > 0) {
800 m_iMinPOC = -1;806 m_iMinPOC = sIMinInt32;
801 for (int32_t i = 0; i < 10; ++i) {807 for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
802 if (m_iMinPOC == -1 && m_sPictInfoList[i].iPOC >= 0) {808 if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32) {
803 m_iMinPOC = m_sPictInfoList[i].iPOC;809 m_iMinPOC = m_sPictInfoList[i].iPOC;
804 m_iPictInfoIndex = i;810 m_iPictInfoIndex = i;
805 }811 }
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) {
807 m_iMinPOC = m_sPictInfoList[i].iPOC;813 m_iMinPOC = m_sPictInfoList[i].iPOC;
808 m_iPictInfoIndex = i;814 m_iPictInfoIndex = i;
809 }815 }
810 }816 }
811 }817 }
812 if (m_iMinPOC >= 0) {818 if (m_iMinPOC > sIMinInt32) {
813 if (m_iMinPOC - m_LastWrittenPOC <= 1 || m_iMinPOC < m_pDecContext->pSliceHeader->iPicOrderCntLsb) {819 if ((m_LastWrittenPOC > sIMinInt32 && m_iMinPOC - m_LastWrittenPOC <= 1)
820 || m_iMinPOC < m_pDecContext->pSliceHeader->iPicOrderCntLsb) {
814 m_LastWrittenPOC = m_iMinPOC;821 m_LastWrittenPOC = m_iMinPOC;
815#if defined (_DEBUG)822#if defined (_DEBUG)
816#ifdef _MOTION_VECTOR_DUMP_823#ifdef _MOTION_VECTOR_DUMP_
@@ -821,9 +828,9 @@ DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SB · 4 unmodified lines
821 ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];828 ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0];
822 ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];829 ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1];
823 ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];830 ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2];
824 m_sPictInfoList[m_iPictInfoIndex].iPOC = -1;831 m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32;
825 m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;832 m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false;
826 m_iMinPOC = -1;833 m_iMinPOC = sIMinInt32;
827 --m_iNumOfPicts;834 --m_iNumOfPicts;
828 return dsErrorFree;835 return dsErrorFree;
829 }836 }

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