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