Showing the changes to codec/decoder/plus/src/welsDecoderExt.cpp (1 of 29 files). Show all
Unified · Split
| @@ -257,6 +257,10 @@ int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) { · 256 unmodified lines | ||
| 257 | 257 | VERSION_NUMBER, (int32_t)pParam->bParseOnly); |
| 258 | 258 | |
| 259 | 259 | //reset decoder context |
| 260 | + memset (&m_sDecoderStatistics, 0, sizeof (SDecoderStatistics)); | |
| 261 | + memset (&m_sLastDecPicInfo, 0, sizeof (SWelsLastDecPicInfo)); | |
| 262 | + memset (&m_sVlcTable, 0, sizeof (SVlcTable)); | |
| 263 | + WelsDecoderLastDecPicInfoDefaults (m_sLastDecPicInfo); | |
| 260 | 264 | if (m_pDecContext) //free |
| 261 | 265 | UninitDecoder(); |
| 262 | 266 | m_pDecContext = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext"); |
| @@ -267,7 +271,11 @@ int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) { · 4 unmodified lines | ||
| 267 | 271 | WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, (NULL == m_pDecContext->pMemAlign), UninitDecoder()) |
| 268 | 272 | |
| 269 | 273 | //fill in default value into context |
| 274 | + m_pDecContext->pLastDecPicInfo = &m_sLastDecPicInfo; | |
| 275 | + m_pDecContext->pDecoderStatistics = &m_sDecoderStatistics; | |
| 276 | + m_pDecContext->pVlcTable = &m_sVlcTable; | |
| 270 | 277 | WelsDecoderDefaults (m_pDecContext, &m_pWelsTrace->m_sLogCtx); |
| 278 | + WelsDecoderSpsPpsDefaults (m_pDecContext->sSpsPpsCtx); | |
| 271 | 279 | |
| 272 | 280 | //check param and update decoder context |
| 273 | 281 | m_pDecContext->pParam = (SDecodingParam*)m_pDecContext->pMemAlign->WelsMallocz (sizeof (SDecodingParam), |
| @@ -364,7 +372,7 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { · 90 unmodified lines | ||
| 364 | 372 | return cmInitParaError; |
| 365 | 373 | } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) { |
| 366 | 374 | if (pOption) { |
| 367 | − m_pDecContext->sDecoderStatistics.iStatisticsLogInterval = (* ((unsigned int*)pOption)); | |
| 375 | + m_pDecContext->pDecoderStatistics->iStatisticsLogInterval = (* ((unsigned int*)pOption)); | |
| 368 | 376 | return cmResultSuccess; |
| 369 | 377 | } |
| 370 | 378 | } else if (eOptID == DECODER_OPTION_GET_SAR_INFO) { |
| @@ -432,19 +440,19 @@ long CWelsDecoder::GetOption (DECODER_OPTION eOptID, void* pOption) { · 61 unmodified lines | ||
| 432 | 440 | } else if (DECODER_OPTION_GET_STATISTICS == eOptID) { // get decoder statistics info for real time debugging |
| 433 | 441 | SDecoderStatistics* pDecoderStatistics = (static_cast<SDecoderStatistics*> (pOption)); |
| 434 | 442 | |
| 435 | − memcpy (pDecoderStatistics, &m_pDecContext->sDecoderStatistics, sizeof (SDecoderStatistics)); | |
| 443 | + memcpy (pDecoderStatistics, m_pDecContext->pDecoderStatistics, sizeof (SDecoderStatistics)); | |
| 436 | 444 | |
| 437 | − if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount != 0) { //not original status | |
| 445 | + if (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount != 0) { //not original status | |
| 438 | 446 | pDecoderStatistics->fAverageFrameSpeedInMs = (float) (m_pDecContext->dDecTime) / |
| 439 | − (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount); | |
| 447 | + (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount); | |
| 440 | 448 | pDecoderStatistics->fActualAverageFrameSpeedInMs = (float) (m_pDecContext->dDecTime) / |
| 441 | − (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount + m_pDecContext->sDecoderStatistics.uiFreezingIDRNum + | |
| 442 | − m_pDecContext->sDecoderStatistics.uiFreezingNonIDRNum); | |
| 449 | + (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount + m_pDecContext->pDecoderStatistics->uiFreezingIDRNum + | |
| 450 | + m_pDecContext->pDecoderStatistics->uiFreezingNonIDRNum); | |
| 443 | 451 | } |
| 444 | 452 | return cmResultSuccess; |
| 445 | 453 | } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) { |
| 446 | 454 | if (pOption) { |
| 447 | − iVal = m_pDecContext->sDecoderStatistics.iStatisticsLogInterval; | |
| 455 | + iVal = m_pDecContext->pDecoderStatistics->iStatisticsLogInterval; | |
| 448 | 456 | * ((unsigned int*)pOption) = iVal; |
| 449 | 457 | return cmResultSuccess; |
| 450 | 458 | } |
| @@ -626,30 +634,30 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 175 unmodified lines | ||
| 626 | 634 | //TODO after dec status updated |
| 627 | 635 | m_pDecContext->iErrorCode |= dsDataErrorConcealed; |
| 628 | 636 | |
| 629 | − m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++; | |
| 630 | − if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t | |
| 631 | − ResetDecStatNums (&m_pDecContext->sDecoderStatistics); | |
| 632 | − m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++; | |
| 637 | + m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++; | |
| 638 | + if (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount == 0) { //exceed max value of uint32_t | |
| 639 | + ResetDecStatNums (m_pDecContext->pDecoderStatistics); | |
| 640 | + m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++; | |
| 633 | 641 | } |
| 634 | 642 | int32_t iMbConcealedNum = m_pDecContext->iMbEcedNum + m_pDecContext->iMbEcedPropNum; |
| 635 | − m_pDecContext->sDecoderStatistics.uiAvgEcRatio = m_pDecContext->iMbNum == 0 ? | |
| 636 | − (m_pDecContext->sDecoderStatistics.uiAvgEcRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) : (( | |
| 637 | − m_pDecContext->sDecoderStatistics.uiAvgEcRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) + (( | |
| 643 | + m_pDecContext->pDecoderStatistics->uiAvgEcRatio = m_pDecContext->iMbNum == 0 ? | |
| 644 | + (m_pDecContext->pDecoderStatistics->uiAvgEcRatio * m_pDecContext->pDecoderStatistics->uiEcFrameNum) : (( | |
| 645 | + m_pDecContext->pDecoderStatistics->uiAvgEcRatio * m_pDecContext->pDecoderStatistics->uiEcFrameNum) + (( | |
| 638 | 646 | iMbConcealedNum * 100) / m_pDecContext->iMbNum)); |
| 639 | − m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio = m_pDecContext->iMbNum == 0 ? | |
| 640 | − (m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) : (( | |
| 641 | − m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) + (( | |
| 647 | + m_pDecContext->pDecoderStatistics->uiAvgEcPropRatio = m_pDecContext->iMbNum == 0 ? | |
| 648 | + (m_pDecContext->pDecoderStatistics->uiAvgEcPropRatio * m_pDecContext->pDecoderStatistics->uiEcFrameNum) : (( | |
| 649 | + m_pDecContext->pDecoderStatistics->uiAvgEcPropRatio * m_pDecContext->pDecoderStatistics->uiEcFrameNum) + (( | |
| 642 | 650 | m_pDecContext->iMbEcedPropNum * 100) / m_pDecContext->iMbNum)); |
| 643 | − m_pDecContext->sDecoderStatistics.uiEcFrameNum += (iMbConcealedNum == 0 ? 0 : 1); | |
| 644 | − m_pDecContext->sDecoderStatistics.uiAvgEcRatio = m_pDecContext->sDecoderStatistics.uiEcFrameNum == 0 ? 0 : | |
| 645 | − m_pDecContext->sDecoderStatistics.uiAvgEcRatio / m_pDecContext->sDecoderStatistics.uiEcFrameNum; | |
| 646 | − m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio = m_pDecContext->sDecoderStatistics.uiEcFrameNum == 0 ? 0 : | |
| 647 | − m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio / m_pDecContext->sDecoderStatistics.uiEcFrameNum; | |
| 651 | + m_pDecContext->pDecoderStatistics->uiEcFrameNum += (iMbConcealedNum == 0 ? 0 : 1); | |
| 652 | + m_pDecContext->pDecoderStatistics->uiAvgEcRatio = m_pDecContext->pDecoderStatistics->uiEcFrameNum == 0 ? 0 : | |
| 653 | + m_pDecContext->pDecoderStatistics->uiAvgEcRatio / m_pDecContext->pDecoderStatistics->uiEcFrameNum; | |
| 654 | + m_pDecContext->pDecoderStatistics->uiAvgEcPropRatio = m_pDecContext->pDecoderStatistics->uiEcFrameNum == 0 ? 0 : | |
| 655 | + m_pDecContext->pDecoderStatistics->uiAvgEcPropRatio / m_pDecContext->pDecoderStatistics->uiEcFrameNum; | |
| 648 | 656 | } |
| 649 | 657 | iEnd = WelsTime(); |
| 650 | 658 | m_pDecContext->dDecTime += (iEnd - iStart) / 1e3; |
| 651 | 659 | |
| 652 | − OutputStatisticsLog (m_pDecContext->sDecoderStatistics); | |
| 660 | + OutputStatisticsLog (*m_pDecContext->pDecoderStatistics); | |
| 653 | 661 | |
| 654 | 662 | #ifdef _PICTURE_REORDERING_ |
| 655 | 663 | ReorderPicturesInDisplay (ppDst, pDstInfo); |
| @@ -661,13 +669,13 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 5 unmodified lines | ||
| 661 | 669 | |
| 662 | 670 | if (pDstInfo->iBufferStatus == 1) { |
| 663 | 671 | |
| 664 | − m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++; | |
| 665 | − if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t | |
| 666 | − ResetDecStatNums (&m_pDecContext->sDecoderStatistics); | |
| 667 | − m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++; | |
| 672 | + m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++; | |
| 673 | + if (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount == 0) { //exceed max value of uint32_t | |
| 674 | + ResetDecStatNums (m_pDecContext->pDecoderStatistics); | |
| 675 | + m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++; | |
| 668 | 676 | } |
| 669 | 677 | |
| 670 | − OutputStatisticsLog (m_pDecContext->sDecoderStatistics); | |
| 678 | + OutputStatisticsLog (*m_pDecContext->pDecoderStatistics); | |
| 671 | 679 | } |
| 672 | 680 | iEnd = WelsTime(); |
| 673 | 681 | m_pDecContext->dDecTime += (iEnd - iStart) / 1e3; |
| @@ -761,19 +769,22 @@ void CWelsDecoder::OutputStatisticsLog (SDecoderStatistics& sDecoderStatistics) · 87 unmodified lines | ||
| 761 | 769 | |
| 762 | 770 | DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SBufferInfo* pDstInfo) { |
| 763 | 771 | DECODING_STATE iRet = dsErrorFree; |
| 764 | − if (pDstInfo->iBufferStatus == 1 && m_pDecContext->pSps->uiProfileIdc != 66 | |
| 765 | − && m_pDecContext->pSps->uiProfileIdc != 83) { | |
| 772 | + if (pDstInfo->iBufferStatus == 0) { | |
| 773 | + return iRet; | |
| 774 | + } | |
| 775 | + ++m_pDecContext->uiDecodingTimeStamp; | |
| 776 | + if (m_pDecContext->pSps->uiProfileIdc != 66 && m_pDecContext->pSps->uiProfileIdc != 83) { | |
| 766 | 777 | /*if (m_pDecContext->pSliceHeader->iPicOrderCntLsb == 0) { |
| 767 | 778 | m_LastWrittenPOC = 0; |
| 768 | 779 | return dsErrorFree; |
| 769 | 780 | } |
| 770 | − if (m_iNumOfPicts == 0 && m_pDecContext->pPreviousDecodedPictureInDpb->bNewSeqBegin | |
| 781 | + if (m_iNumOfPicts == 0 && m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb->bNewSeqBegin | |
| 771 | 782 | && m_pDecContext->eSliceType != I_SLICE) { |
| 772 | 783 | m_LastWrittenPOC = m_pDecContext->pSliceHeader->iPicOrderCntLsb; |
| 773 | 784 | return dsErrorFree; |
| 774 | 785 | }*/ |
| 775 | − if (m_iNumOfPicts && m_pDecContext->pPreviousDecodedPictureInDpb | |
| 776 | − && m_pDecContext->pPreviousDecodedPictureInDpb->bNewSeqBegin) { | |
| 786 | + if (m_iNumOfPicts && m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb | |
| 787 | + && m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb->bNewSeqBegin) { | |
| 777 | 788 | m_iLastGOPRemainPicts = m_iNumOfPicts; |
| 778 | 789 | for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) { |
| 779 | 790 | if (m_sPictInfoList[i].iPOC > sIMinInt32) { |
| @@ -807,7 +818,8 @@ DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SB · 27 unmodified lines | ||
| 807 | 818 | m_sPictInfoList[i].pData[1] = ppDst[1]; |
| 808 | 819 | m_sPictInfoList[i].pData[2] = ppDst[2]; |
| 809 | 820 | m_sPictInfoList[i].iPOC = m_pDecContext->pSliceHeader->iPicOrderCntLsb; |
| 810 | − m_sPictInfoList[i].iPicBuffIdx = m_pDecContext->pPicBuff->iCurrentIdx; | |
| 821 | + m_sPictInfoList[i].uiDecodingTimeStamp = m_pDecContext->uiDecodingTimeStamp; | |
| 822 | + m_sPictInfoList[i].iPicBuffIdx = m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb->iPicBuffIdx; | |
| 811 | 823 | m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[i].iPicBuffIdx]->bAvailableFlag = false; |
| 812 | 824 | m_sPictInfoList[i].bLastGOP = false; |
| 813 | 825 | pDstInfo->iBufferStatus = 0; |
| @@ -955,10 +967,10 @@ DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc, · 141 unmodified lines | ||
| 955 | 967 | memcpy (pDstInfo, m_pDecContext->pParserBsInfo, sizeof (SParserBsInfo)); |
| 956 | 968 | |
| 957 | 969 | if (m_pDecContext->iErrorCode == ERR_NONE) { //update statistics: decoding frame count |
| 958 | − m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++; | |
| 959 | − if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t | |
| 960 | − ResetDecStatNums (&m_pDecContext->sDecoderStatistics); | |
| 961 | − m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++; | |
| 970 | + m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++; | |
| 971 | + if (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount == 0) { //exceed max value of uint32_t | |
| 972 | + ResetDecStatNums (m_pDecContext->pDecoderStatistics); | |
| 973 | + m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++; | |
| 962 | 974 | } |
| 963 | 975 | } |
| 964 | 976 | } |