Showing the changes to codec/encoder/plus/src/welsEncoderExt.cpp (1 of 6 files). Show all
Unified · Split
| @@ -431,7 +431,7 @@ int CWelsH264SVCEncoder ::EncodeFrameInternal (const SSourcePicture* pSrcPic, S · 430 unmodified lines | ||
| 431 | 431 | return cmUnkonwReason; |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | − UpdateStatistics (pSrcPic->uiTimeStamp, pBsInfo->eFrameType, kiCurrentFrameMs); | |
| 434 | + UpdateStatistics (pSrcPic->uiTimeStamp, pBsInfo->eFrameType, pBsInfo->iFrameSizeInBytes, kiCurrentFrameMs); | |
| 435 | 435 | |
| 436 | 436 | ///////////////////for test |
| 437 | 437 | #ifdef OUTPUT_BIT_STREAM |
| @@ -504,6 +504,8 @@ int CWelsH264SVCEncoder::ForceIntraFrame (bool bIDR) { · 66 unmodified lines | ||
| 504 | 504 | |
| 505 | 505 | ForceCodingIDR (m_pEncContext); |
| 506 | 506 | |
| 507 | + m_pEncContext->sEncoderStatistics.uiIDRReqNum++; | |
| 508 | + | |
| 507 | 509 | return 0; |
| 508 | 510 | } |
| 509 | 511 | void CWelsH264SVCEncoder::CheckProfileSetting (int32_t iLayer, EProfileIdc uiProfileIdc) { |
| @@ -594,7 +596,7 @@ void CWelsH264SVCEncoder::TraceParamInfo (SEncParamExt* pParam) { · 84 unmodified lines | ||
| 594 | 596 | } |
| 595 | 597 | |
| 596 | 598 | void CWelsH264SVCEncoder::UpdateStatistics (const int64_t kiCurrentFrameTs, EVideoFrameType eFrameType, |
| 597 | − const int64_t kiCurrentFrameMs) { | |
| 599 | + const int32_t kiCurrentFrameSize, const int64_t kiCurrentFrameMs) { | |
| 598 | 600 | SEncoderStatistics* pStatistics = & (m_pEncContext->sEncoderStatistics); |
| 599 | 601 | |
| 600 | 602 | int32_t iMaxDid = m_pEncContext->pSvcParam->iSpatialLayerNum - 1; |
| @@ -633,20 +635,33 @@ void CWelsH264SVCEncoder::UpdateStatistics (const int64_t kiCurrentFrameTs, EVid · 32 unmodified lines | ||
| 633 | 635 | if (m_pEncContext->pLtr->bLTRMarkingFlag) { |
| 634 | 636 | pStatistics->uiLTRSentNum ++; |
| 635 | 637 | } |
| 636 | − //TODO: update uiIDRReqNum in forceIDR | |
| 638 | + | |
| 639 | + m_pEncContext->iTotalEncodedBits += kiCurrentFrameSize; | |
| 637 | 640 | |
| 638 | 641 | if (m_pEncContext->iStatisticsLogInterval > 0) { |
| 639 | − if (WELS_ABS (kiCurrentFrameTs - m_pEncContext->iLastStatisticsLogTs) > m_pEncContext->iStatisticsLogInterval) { | |
| 642 | + int64_t iTimeDiff = kiCurrentFrameTs - m_pEncContext->iLastStatisticsLogTs; | |
| 643 | + if (iTimeDiff > m_pEncContext->iStatisticsLogInterval) { | |
| 644 | + pStatistics->fLatestFrameRate = (pStatistics->uiInputFrameCount - m_pEncContext->iLastStatisticsFrameCount) * 1000 / | |
| 645 | + iTimeDiff; | |
| 646 | + pStatistics->uiBitRate = static_cast<unsigned int> ((m_pEncContext->iTotalEncodedBits - | |
| 647 | + m_pEncContext->iLastStatisticsBits) * 1000 / iTimeDiff); | |
| 648 | + | |
| 649 | + // update variables | |
| 650 | + m_pEncContext->iLastStatisticsLogTs = kiCurrentFrameTs; | |
| 651 | + m_pEncContext->iLastStatisticsBits = m_pEncContext->iTotalEncodedBits; | |
| 652 | + m_pEncContext->iLastStatisticsFrameCount = pStatistics->uiInputFrameCount; | |
| 653 | + | |
| 640 | 654 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |
| 641 | − "EncoderStatistics: %dx%d, SpeedInMs: %f, AverFrameRate=%f, LastFrameRate=NA, LatestBitRate=NA, uiInputFrameCount=%d, uiSkippedFrameCount=%d, uiResolutionChangeTimes=%d, uIDRReqNum=%d, uIDRSentNum=%d, uLTRSentNum=NA", | |
| 655 | + "EncoderStatistics: %dx%d, SpeedInMs: %f, fAverageFrameRate=%f, \ | |
| 656 | + LastFrameRate=%f, LatestBitRate=%d, uiInputFrameCount=%d, uiSkippedFrameCount=%d, \ | |
| 657 | + uiResolutionChangeTimes=%d, uIDRReqNum=%d, uIDRSentNum=%d, uLTRSentNum=NA", | |
| 642 | 658 | pStatistics->uiWidth, pStatistics->uiHeight, |
| 643 | 659 | pStatistics->fAverageFrameSpeedInMs, pStatistics->fAverageFrameRate, |
| 660 | + pStatistics->fLatestFrameRate, pStatistics->uiBitRate, | |
| 644 | 661 | pStatistics->uiInputFrameCount, pStatistics->uiSkippedFrameCount, |
| 645 | − pStatistics->uiResolutionChangeTimes, pStatistics->uiIDRSentNum, pStatistics->uiLTRSentNum); | |
| 662 | + pStatistics->uiResolutionChangeTimes, pStatistics->uiIDRReqNum, pStatistics->uiIDRSentNum); | |
| 646 | 663 | //TODO: the following statistics will be calculated and added later |
| 647 | − //pStatistics->fLatestFrameRate, pStatistics->uiBitRate, | |
| 648 | − //pStatistics->uiIDRReqNum, | |
| 649 | − m_pEncContext->iLastStatisticsLogTs = kiCurrentFrameTs; | |
| 664 | + //pStatistics->uiLTRSentNum | |
| 650 | 665 | } |
| 651 | 666 | } |
| 652 | 667 | |