It also fix SetUnRef crashing which should only loop for LIST_1 if ref pic is B_SLICE.
Showing the changes to codec/decoder/plus/src/welsDecoderExt.cpp (1 of 8 files). Show all
Unified · Split
| @@ -73,8 +73,6 @@ extern "C" { · 72 unmodified lines | |||
| 73 | 73 | ||
| 74 | #define _PICTURE_REORDERING_ 1 | 74 | #define _PICTURE_REORDERING_ 1 |
| 75 | 75 | ||
| 76 | static int32_t sIMinInt32 = -0x7FFFFFFF; | ||
| 77 | |||
| 78 | namespace WelsDec { | 76 | namespace WelsDec { |
| 79 | 77 | ||
| 80 | ////////////////////////////////////////////////////////////////////// | 78 | ////////////////////////////////////////////////////////////////////// |
| @@ -92,13 +90,7 @@ namespace WelsDec { · 11 unmodified lines | |||
| 92 | ***************************************************************************/ | 90 | ***************************************************************************/ |
| 93 | CWelsDecoder::CWelsDecoder (void) | 91 | CWelsDecoder::CWelsDecoder (void) |
| 94 | : m_pDecContext (NULL), | 92 | : m_pDecContext (NULL), |
| 95 | m_pWelsTrace (NULL), | 93 | m_pWelsTrace (NULL) { |
| 96 | m_iPictInfoIndex (0), | ||
| 97 | m_iMinPOC (sIMinInt32), | ||
| 98 | m_iNumOfPicts (0), | ||
| 99 | m_iLastGOPRemainPicts (0), | ||
| 100 | m_LastWrittenPOC (sIMinInt32), | ||
| 101 | m_iLargestBufferedPicIndex (0) { | ||
| 102 | #ifdef OUTPUT_BIT_STREAM | 94 | #ifdef OUTPUT_BIT_STREAM |
| 103 | char chFileName[1024] = { 0 }; //for .264 | 95 | char chFileName[1024] = { 0 }; //for .264 |
| 104 | int iBufUsed = 0; | 96 | int iBufUsed = 0; |
| @@ -120,10 +112,7 @@ CWelsDecoder::CWelsDecoder (void) · 15 unmodified lines | |||
| 120 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::CWelsDecoder() entry"); | 112 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::CWelsDecoder() entry"); |
| 121 | } | 113 | } |
| 122 | 114 | ||
| 123 | for (int32_t i = 0; i < 16; ++i) { | 115 | ResetReorderingPictureBuffers (&m_sReoderingStatus, m_sPictInfoList, true); |
| 124 | m_sPictInfoList[i].bLastGOP = false; | ||
| 125 | m_sPictInfoList[i].iPOC = sIMinInt32; | ||
| 126 | } | ||
| 127 | 116 | ||
| 128 | #ifdef OUTPUT_BIT_STREAM | 117 | #ifdef OUTPUT_BIT_STREAM |
| 129 | SWelsTime sCurTime; | 118 | SWelsTime sCurTime; |
| @@ -274,6 +263,8 @@ int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) { · 144 unmodified lines | |||
| 274 | m_pDecContext->pLastDecPicInfo = &m_sLastDecPicInfo; | 263 | m_pDecContext->pLastDecPicInfo = &m_sLastDecPicInfo; |
| 275 | m_pDecContext->pDecoderStatistics = &m_sDecoderStatistics; | 264 | m_pDecContext->pDecoderStatistics = &m_sDecoderStatistics; |
| 276 | m_pDecContext->pVlcTable = &m_sVlcTable; | 265 | m_pDecContext->pVlcTable = &m_sVlcTable; |
| 266 | m_pDecContext->pPictInfoList = m_sPictInfoList; | ||
| 267 | m_pDecContext->pPictReoderingStatus = &m_sReoderingStatus; | ||
| 277 | WelsDecoderDefaults (m_pDecContext, &m_pWelsTrace->m_sLogCtx); | 268 | WelsDecoderDefaults (m_pDecContext, &m_pWelsTrace->m_sLogCtx); |
| 278 | WelsDecoderSpsPpsDefaults (m_pDecContext->sSpsPpsCtx); | 269 | WelsDecoderSpsPpsDefaults (m_pDecContext->sSpsPpsCtx); |
| 279 | 270 | ||
| @@ -304,7 +295,7 @@ int32_t CWelsDecoder::ResetDecoder() { · 24 unmodified lines | |||
| 304 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "ResetDecoder() failed as decoder context null"); | 295 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "ResetDecoder() failed as decoder context null"); |
| 305 | } | 296 | } |
| 306 | #ifdef _PICTURE_REORDERING_ | 297 | #ifdef _PICTURE_REORDERING_ |
| 307 | ResetReorderingPictureBuffers(); | 298 | ResetReorderingPictureBuffers (&m_sReoderingStatus, m_sPictInfoList, false); |
| 308 | #endif | 299 | #endif |
| 309 | return ERR_INFO_UNINIT; | 300 | return ERR_INFO_UNINIT; |
| 310 | } | 301 | } |
| @@ -483,7 +474,7 @@ long CWelsDecoder::GetOption (DECODER_OPTION eOptID, void* pOption) { · 172 unmodified lines | |||
| 483 | return cmResultSuccess; | 474 | return cmResultSuccess; |
| 484 | } else if (DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER == eOptID) { | 475 | } else if (DECODER_OPTION_NUM_OF_FRAMES_REMAINING_IN_BUFFER == eOptID) { |
| 485 | if (m_pDecContext->pSps && m_pDecContext->pSps->uiProfileIdc != 66) { | 476 | if (m_pDecContext->pSps && m_pDecContext->pSps->uiProfileIdc != 66) { |
| 486 | * ((int*)pOption) = m_iNumOfPicts > 0 ? m_iNumOfPicts : 0; | 477 | * ((int*)pOption) = m_sReoderingStatus.iNumOfPicts > 0 ? m_sReoderingStatus.iNumOfPicts : 0; |
| 487 | } else { | 478 | } else { |
| 488 | * ((int*)pOption) = 0; | 479 | * ((int*)pOption) = 0; |
| 489 | } | 480 | } |
| @@ -688,36 +679,36 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 198 unmodified lines | |||
| 688 | 679 | ||
| 689 | DECODING_STATE CWelsDecoder::FlushFrame (unsigned char** ppDst, | 680 | DECODING_STATE CWelsDecoder::FlushFrame (unsigned char** ppDst, |
| 690 | SBufferInfo* pDstInfo) { | 681 | SBufferInfo* pDstInfo) { |
| 691 | if (m_pDecContext->bEndOfStreamFlag && m_iNumOfPicts > 0) { | 682 | if (m_pDecContext->bEndOfStreamFlag && m_sReoderingStatus.iNumOfPicts > 0) { |
| 692 | m_iMinPOC = sIMinInt32; | 683 | m_sReoderingStatus.iMinPOC = IMinInt32; |
| 693 | for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) { | 684 | for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { |
| 694 | if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32) { | 685 | if (m_sReoderingStatus.iMinPOC == IMinInt32 && m_sPictInfoList[i].iPOC > IMinInt32) { |
| 695 | m_iMinPOC = m_sPictInfoList[i].iPOC; | 686 | m_sReoderingStatus.iMinPOC = m_sPictInfoList[i].iPOC; |
| 696 | m_iPictInfoIndex = i; | 687 | m_sReoderingStatus.iPictInfoIndex = i; |
| 697 | } | 688 | } |
| 698 | if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC) { | 689 | if (m_sPictInfoList[i].iPOC > IMinInt32 && m_sPictInfoList[i].iPOC < m_sReoderingStatus.iMinPOC) { |
| 699 | m_iMinPOC = m_sPictInfoList[i].iPOC; | 690 | m_sReoderingStatus.iMinPOC = m_sPictInfoList[i].iPOC; |
| 700 | m_iPictInfoIndex = i; | 691 | m_sReoderingStatus.iPictInfoIndex = i; |
| 701 | } | 692 | } |
| 702 | } | 693 | } |
| 703 | } | 694 | } |
| 704 | if (m_iMinPOC > sIMinInt32) { | 695 | if (m_sReoderingStatus.iMinPOC > IMinInt32) { |
| 705 | m_LastWrittenPOC = m_iMinPOC; | 696 | m_sReoderingStatus.iLastWrittenPOC = m_sReoderingStatus.iMinPOC; |
| 706 | #if defined (_DEBUG) | 697 | #if defined (_DEBUG) |
| 707 | #ifdef _MOTION_VECTOR_DUMP_ | 698 | #ifdef _MOTION_VECTOR_DUMP_ |
| 708 | fprintf (stderr, "Output POC: #%d\n", m_LastWrittenPOC); | 699 | fprintf (stderr, "Output POC: #%d\n", m_sReoderingStatus.iLastWrittenPOC); |
| 709 | #endif | 700 | #endif |
| 710 | #endif | 701 | #endif |
| 711 | memcpy (pDstInfo, &m_sPictInfoList[m_iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo)); | 702 | memcpy (pDstInfo, &m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo)); |
| 712 | ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0]; | 703 | ppDst[0] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[0]; |
| 713 | ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1]; | 704 | ppDst[1] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[1]; |
| 714 | ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2]; | 705 | ppDst[2] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[2]; |
| 715 | m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32; | 706 | m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC = IMinInt32; |
| 716 | if (m_sPictInfoList[m_iPictInfoIndex].iPicBuffIdx < m_pDecContext->pPicBuff->iCapacity) | 707 | if (m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx < m_pDecContext->pPicBuff->iCapacity) |
| 717 | m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[m_iPictInfoIndex].iPicBuffIdx]->bAvailableFlag = true; | 708 | m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx]->bAvailableFlag = true; |
| 718 | m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false; | 709 | m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP = false; |
| 719 | m_iMinPOC = sIMinInt32; | 710 | m_sReoderingStatus.iMinPOC = IMinInt32; |
| 720 | --m_iNumOfPicts; | 711 | --m_sReoderingStatus.iNumOfPicts; |
| 721 | } | 712 | } |
| 722 | return dsErrorFree; | 713 | return dsErrorFree; |
| 723 | } | 714 | } |
| @@ -775,36 +766,36 @@ DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SB · 51 unmodified lines | |||
| 775 | ++m_pDecContext->uiDecodingTimeStamp; | 766 | ++m_pDecContext->uiDecodingTimeStamp; |
| 776 | if (m_pDecContext->pSps->uiProfileIdc != 66 && m_pDecContext->pSps->uiProfileIdc != 83) { | 767 | if (m_pDecContext->pSps->uiProfileIdc != 66 && m_pDecContext->pSps->uiProfileIdc != 83) { |
| 777 | /*if (m_pDecContext->pSliceHeader->iPicOrderCntLsb == 0) { | 768 | /*if (m_pDecContext->pSliceHeader->iPicOrderCntLsb == 0) { |
| 778 | m_LastWrittenPOC = 0; | 769 | m_sReoderingStatus.iLastWrittenPOC = 0; |
| 779 | return dsErrorFree; | 770 | return dsErrorFree; |
| 780 | } | 771 | } |
| 781 | if (m_iNumOfPicts == 0 && m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb->bNewSeqBegin | 772 | if (m_sReoderingStatus.iNumOfPicts == 0 && m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb->bNewSeqBegin |
| 782 | && m_pDecContext->eSliceType != I_SLICE) { | 773 | && m_pDecContext->eSliceType != I_SLICE) { |
| 783 | m_LastWrittenPOC = m_pDecContext->pSliceHeader->iPicOrderCntLsb; | 774 | m_sReoderingStatus.iLastWrittenPOC = m_pDecContext->pSliceHeader->iPicOrderCntLsb; |
| 784 | return dsErrorFree; | 775 | return dsErrorFree; |
| 785 | }*/ | 776 | }*/ |
| 786 | if (m_iNumOfPicts && m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb | 777 | if (m_sReoderingStatus.iNumOfPicts && m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb |
| 787 | && m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb->bNewSeqBegin) { | 778 | && m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb->bNewSeqBegin) { |
| 788 | m_iLastGOPRemainPicts = m_iNumOfPicts; | 779 | m_sReoderingStatus.iLastGOPRemainPicts = m_sReoderingStatus.iNumOfPicts; |
| 789 | for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) { | 780 | for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { |
| 790 | if (m_sPictInfoList[i].iPOC > sIMinInt32) { | 781 | if (m_sPictInfoList[i].iPOC > IMinInt32) { |
| 791 | m_sPictInfoList[i].bLastGOP = true; | 782 | m_sPictInfoList[i].bLastGOP = true; |
| 792 | } | 783 | } |
| 793 | } | 784 | } |
| 794 | } else { | 785 | } else { |
| 795 | if (m_iNumOfPicts > 0) { | 786 | if (m_sReoderingStatus.iNumOfPicts > 0) { |
| 796 | //This can happen when decoder moves to next GOP without being able to decoder first picture PicOrderCntLsb = 0 | 787 | //This can happen when decoder moves to next GOP without being able to decoder first picture PicOrderCntLsb = 0 |
| 797 | bool hasGOPChanged = false; | 788 | bool hasGOPChanged = false; |
| 798 | for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) { | 789 | for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { |
| 799 | if (m_sPictInfoList[i].iPOC == m_pDecContext->pSliceHeader->iPicOrderCntLsb) { | 790 | if (m_sPictInfoList[i].iPOC == m_pDecContext->pSliceHeader->iPicOrderCntLsb) { |
| 800 | hasGOPChanged = true; | 791 | hasGOPChanged = true; |
| 801 | break; | 792 | break; |
| 802 | } | 793 | } |
| 803 | } | 794 | } |
| 804 | if (hasGOPChanged) { | 795 | if (hasGOPChanged) { |
| 805 | m_iLastGOPRemainPicts = m_iNumOfPicts; | 796 | m_sReoderingStatus.iLastGOPRemainPicts = m_sReoderingStatus.iNumOfPicts; |
| 806 | for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) { | 797 | for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { |
| 807 | if (m_sPictInfoList[i].iPOC > sIMinInt32) { | 798 | if (m_sPictInfoList[i].iPOC > IMinInt32) { |
| 808 | m_sPictInfoList[i].bLastGOP = true; | 799 | m_sPictInfoList[i].bLastGOP = true; |
| 809 | } | 800 | } |
| 810 | } | 801 | } |
| @@ -812,7 +803,7 @@ DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SB · 1 unmodified line | |||
| 812 | } | 803 | } |
| 813 | } | 804 | } |
| 814 | for (int32_t i = 0; i < 16; ++i) { | 805 | for (int32_t i = 0; i < 16; ++i) { |
| 815 | if (m_sPictInfoList[i].iPOC == sIMinInt32) { | 806 | if (m_sPictInfoList[i].iPOC == IMinInt32) { |
| 816 | memcpy (&m_sPictInfoList[i].sBufferInfo, pDstInfo, sizeof (SBufferInfo)); | 807 | memcpy (&m_sPictInfoList[i].sBufferInfo, pDstInfo, sizeof (SBufferInfo)); |
| 817 | m_sPictInfoList[i].pData[0] = ppDst[0]; | 808 | m_sPictInfoList[i].pData[0] = ppDst[0]; |
| 818 | m_sPictInfoList[i].pData[1] = ppDst[1]; | 809 | m_sPictInfoList[i].pData[1] = ppDst[1]; |
| @@ -823,79 +814,81 @@ DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SB · 4 unmodified lines | |||
| 823 | m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[i].iPicBuffIdx]->bAvailableFlag = false; | 814 | m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[i].iPicBuffIdx]->bAvailableFlag = false; |
| 824 | m_sPictInfoList[i].bLastGOP = false; | 815 | m_sPictInfoList[i].bLastGOP = false; |
| 825 | pDstInfo->iBufferStatus = 0; | 816 | pDstInfo->iBufferStatus = 0; |
| 826 | ++m_iNumOfPicts; | 817 | ++m_sReoderingStatus.iNumOfPicts; |
| 827 | if (i > m_iLargestBufferedPicIndex) { | 818 | if (i > m_sReoderingStatus.iLargestBufferedPicIndex) { |
| 828 | m_iLargestBufferedPicIndex = i; | 819 | m_sReoderingStatus.iLargestBufferedPicIndex = i; |
| 829 | } | 820 | } |
| 830 | break; | 821 | break; |
| 831 | } | 822 | } |
| 832 | } | 823 | } |
| 833 | if (m_iLastGOPRemainPicts > 0) { | 824 | if (m_sReoderingStatus.iLastGOPRemainPicts > 0) { |
| 834 | m_iMinPOC = sIMinInt32; | 825 | m_sReoderingStatus.iMinPOC = IMinInt32; |
| 835 | for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) { | 826 | for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { |
| 836 | if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].bLastGOP) { | 827 | if (m_sReoderingStatus.iMinPOC == IMinInt32 && m_sPictInfoList[i].iPOC > IMinInt32 && m_sPictInfoList[i].bLastGOP) { |
| 837 | m_iMinPOC = m_sPictInfoList[i].iPOC; | 828 | m_sReoderingStatus.iMinPOC = m_sPictInfoList[i].iPOC; |
| 838 | m_iPictInfoIndex = i; | 829 | m_sReoderingStatus.iPictInfoIndex = i; |
| 839 | } | 830 | } |
| 840 | if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC && m_sPictInfoList[i].bLastGOP) { | 831 | if (m_sPictInfoList[i].iPOC > IMinInt32 && m_sPictInfoList[i].iPOC < m_sReoderingStatus.iMinPOC |
| 841 | m_iMinPOC = m_sPictInfoList[i].iPOC; | 832 | && m_sPictInfoList[i].bLastGOP) { |
| 842 | m_iPictInfoIndex = i; | 833 | m_sReoderingStatus.iMinPOC = m_sPictInfoList[i].iPOC; |
| 834 | m_sReoderingStatus.iPictInfoIndex = i; | ||
| 843 | } | 835 | } |
| 844 | } | 836 | } |
| 845 | m_LastWrittenPOC = m_iMinPOC; | 837 | m_sReoderingStatus.iLastWrittenPOC = m_sReoderingStatus.iMinPOC; |
| 846 | #if defined (_DEBUG) | 838 | #if defined (_DEBUG) |
| 847 | #ifdef _MOTION_VECTOR_DUMP_ | 839 | #ifdef _MOTION_VECTOR_DUMP_ |
| 848 | fprintf (stderr, "Output POC: #%d\n", m_LastWrittenPOC); | 840 | fprintf (stderr, "Output POC: #%d\n", m_sReoderingStatus.iLastWrittenPOC); |
| 849 | #endif | 841 | #endif |
| 850 | #endif | 842 | #endif |
| 851 | memcpy (pDstInfo, &m_sPictInfoList[m_iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo)); | 843 | memcpy (pDstInfo, &m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo)); |
| 852 | ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0]; | 844 | ppDst[0] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[0]; |
| 853 | ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1]; | 845 | ppDst[1] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[1]; |
| 854 | ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2]; | 846 | ppDst[2] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[2]; |
| 855 | m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32; | 847 | m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC = IMinInt32; |
| 856 | if (m_sPictInfoList[m_iPictInfoIndex].iPicBuffIdx < m_pDecContext->pPicBuff->iCapacity) | 848 | if (m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx < m_pDecContext->pPicBuff->iCapacity) |
| 857 | m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[m_iPictInfoIndex].iPicBuffIdx]->bAvailableFlag = true; | 849 | m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx]->bAvailableFlag = true; |
| 858 | m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false; | 850 | m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP = false; |
| 859 | m_iMinPOC = sIMinInt32; | 851 | m_sReoderingStatus.iMinPOC = IMinInt32; |
| 860 | --m_iNumOfPicts; | 852 | --m_sReoderingStatus.iNumOfPicts; |
| 861 | --m_iLastGOPRemainPicts; | 853 | --m_sReoderingStatus.iLastGOPRemainPicts; |
| 862 | if (m_iLastGOPRemainPicts == 0) { | 854 | if (m_sReoderingStatus.iLastGOPRemainPicts == 0) { |
| 863 | m_LastWrittenPOC = sIMinInt32; | 855 | m_sReoderingStatus.iLastWrittenPOC = IMinInt32; |
| 864 | } | 856 | } |
| 865 | return iRet; | 857 | return iRet; |
| 866 | } | 858 | } |
| 867 | if (m_iNumOfPicts > 0) { | 859 | if (m_sReoderingStatus.iNumOfPicts > 0) { |
| 868 | m_iMinPOC = sIMinInt32; | 860 | m_sReoderingStatus.iMinPOC = IMinInt32; |
| 869 | for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) { | 861 | for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) { |
| 870 | if (m_iMinPOC == sIMinInt32 && m_sPictInfoList[i].iPOC > sIMinInt32) { | 862 | if (m_sReoderingStatus.iMinPOC == IMinInt32 && m_sPictInfoList[i].iPOC > IMinInt32) { |
| 871 | m_iMinPOC = m_sPictInfoList[i].iPOC; | 863 | m_sReoderingStatus.iMinPOC = m_sPictInfoList[i].iPOC; |
| 872 | m_iPictInfoIndex = i; | 864 | m_sReoderingStatus.iPictInfoIndex = i; |
| 873 | } | 865 | } |
| 874 | if (m_sPictInfoList[i].iPOC > sIMinInt32 && m_sPictInfoList[i].iPOC < m_iMinPOC) { | 866 | if (m_sPictInfoList[i].iPOC > IMinInt32 && m_sPictInfoList[i].iPOC < m_sReoderingStatus.iMinPOC) { |
| 875 | m_iMinPOC = m_sPictInfoList[i].iPOC; | 867 | m_sReoderingStatus.iMinPOC = m_sPictInfoList[i].iPOC; |
| 876 | m_iPictInfoIndex = i; | 868 | m_sReoderingStatus.iPictInfoIndex = i; |
| 877 | } | 869 | } |
| 878 | } | 870 | } |
| 879 | } | 871 | } |
| 880 | if (m_iMinPOC > sIMinInt32) { | 872 | if (m_sReoderingStatus.iMinPOC > IMinInt32) { |
| 881 | if ((m_LastWrittenPOC > sIMinInt32 && m_iMinPOC - m_LastWrittenPOC <= 1) | 873 | if ((m_sReoderingStatus.iLastWrittenPOC > IMinInt32 |
| 882 | || m_iMinPOC < m_pDecContext->pSliceHeader->iPicOrderCntLsb) { | 874 | && m_sReoderingStatus.iMinPOC - m_sReoderingStatus.iLastWrittenPOC <= 1) |
| 883 | m_LastWrittenPOC = m_iMinPOC; | 875 | || m_sReoderingStatus.iMinPOC < m_pDecContext->pSliceHeader->iPicOrderCntLsb) { |
| 876 | m_sReoderingStatus.iLastWrittenPOC = m_sReoderingStatus.iMinPOC; | ||
| 884 | #if defined (_DEBUG) | 877 | #if defined (_DEBUG) |
| 885 | #ifdef _MOTION_VECTOR_DUMP_ | 878 | #ifdef _MOTION_VECTOR_DUMP_ |
| 886 | fprintf (stderr, "Output POC: #%d\n", m_LastWrittenPOC); | 879 | fprintf (stderr, "Output POC: #%d\n", m_sReoderingStatus.iLastWrittenPOC); |
| 887 | #endif | 880 | #endif |
| 888 | #endif | 881 | #endif |
| 889 | memcpy (pDstInfo, &m_sPictInfoList[m_iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo)); | 882 | memcpy (pDstInfo, &m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].sBufferInfo, sizeof (SBufferInfo)); |
| 890 | ppDst[0] = m_sPictInfoList[m_iPictInfoIndex].pData[0]; | 883 | ppDst[0] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[0]; |
| 891 | ppDst[1] = m_sPictInfoList[m_iPictInfoIndex].pData[1]; | 884 | ppDst[1] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[1]; |
| 892 | ppDst[2] = m_sPictInfoList[m_iPictInfoIndex].pData[2]; | 885 | ppDst[2] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[2]; |
| 893 | m_sPictInfoList[m_iPictInfoIndex].iPOC = sIMinInt32; | 886 | m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC = IMinInt32; |
| 894 | if (m_sPictInfoList[m_iPictInfoIndex].iPicBuffIdx < m_pDecContext->pPicBuff->iCapacity) | 887 | if (m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx < m_pDecContext->pPicBuff->iCapacity) |
| 895 | m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[m_iPictInfoIndex].iPicBuffIdx]->bAvailableFlag = true; | 888 | m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx]->bAvailableFlag = true; |
| 896 | m_sPictInfoList[m_iPictInfoIndex].bLastGOP = false; | 889 | m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP = false; |
| 897 | m_iMinPOC = sIMinInt32; | 890 | m_sReoderingStatus.iMinPOC = IMinInt32; |
| 898 | --m_iNumOfPicts; | 891 | --m_sReoderingStatus.iNumOfPicts; |
| 899 | return iRet; | 892 | return iRet; |
| 900 | } | 893 | } |
| 901 | } | 894 | } |
| @@ -1026,19 +1019,6 @@ DECODING_STATE CWelsDecoder::DecodeFrameEx (const unsigned char* kpSrc, · 124 unmodified lines | |||
| 1026 | return state; | 1019 | return state; |
| 1027 | } | 1020 | } |
| 1028 | 1021 | ||
| 1029 | void CWelsDecoder::ResetReorderingPictureBuffers() { | ||
| 1030 | m_iPictInfoIndex = 0; | ||
| 1031 | m_iMinPOC = sIMinInt32; | ||
| 1032 | m_iNumOfPicts = 0; | ||
| 1033 | m_iLastGOPRemainPicts = 0; | ||
| 1034 | m_LastWrittenPOC = sIMinInt32; | ||
| 1035 | m_iLargestBufferedPicIndex = 0; | ||
| 1036 | for (int32_t i = 0; i < 16; ++i) { | ||
| 1037 | m_sPictInfoList[i].bLastGOP = false; | ||
| 1038 | m_sPictInfoList[i].iPOC = sIMinInt32; | ||
| 1039 | } | ||
| 1040 | } | ||
| 1041 | |||
| 1042 | } // namespace WelsDec | 1022 | } // namespace WelsDec |
| 1043 | 1023 | ||
| 1044 | 1024 | ||