Showing the changes to codec/encoder/plus/src/welsEncoderExt.cpp (1 of 2 files). Show all
Unified · Split
| @@ -583,24 +583,31 @@ void CWelsH264SVCEncoder::UpdateStatistics (const int64_t kiCurrentFrameTs, EVid · 582 unmodified lines | ||
| 583 | 583 | pStatistics->uiLTRSentNum ++; |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | − m_pEncContext->iTotalEncodedBits += (kiCurrentFrameSize<<3); | |
| 587 | − | |
| 588 | − if (m_pEncContext->iStatisticsLogInterval > 0) { | |
| 589 | − int64_t iTimeDiff = kiCurrentFrameTs - m_pEncContext->iLastStatisticsLogTs; | |
| 590 | − if ((iTimeDiff > m_pEncContext->iStatisticsLogInterval) || (0 == pStatistics->uiInputFrameCount % 300)) { | |
| 591 | − if (iTimeDiff) { | |
| 592 | − pStatistics->fLatestFrameRate = static_cast<float> ((pStatistics->uiInputFrameCount - | |
| 593 | − m_pEncContext->iLastStatisticsFrameCount) * 1000 / | |
| 594 | − iTimeDiff); | |
| 595 | − pStatistics->uiBitRate = static_cast<unsigned int> ((m_pEncContext->iTotalEncodedBits - | |
| 596 | − m_pEncContext->iLastStatisticsBits) * 1000 / iTimeDiff); | |
| 597 | − } | |
| 586 | + m_pEncContext->iTotalEncodedBits += (kiCurrentFrameSize << 3); | |
| 587 | + | |
| 588 | + const int32_t kiDeltaFrames = static_cast<int32_t> (pStatistics->uiInputFrameCount - | |
| 589 | + m_pEncContext->iLastStatisticsFrameCount); | |
| 590 | + if (kiDeltaFrames > m_pEncContext->pSvcParam->fMaxFrameRate) { | |
| 591 | + const int64_t kiTimeDiff = kiCurrentFrameTs - pStatistics->iStatisticsTs; | |
| 592 | + if (kiTimeDiff) { | |
| 593 | + pStatistics->fLatestFrameRate = static_cast<float> ((pStatistics->uiInputFrameCount - | |
| 594 | + m_pEncContext->iLastStatisticsFrameCount) * 1000 / | |
| 595 | + kiTimeDiff); | |
| 596 | + pStatistics->uiBitRate = static_cast<unsigned int> ((m_pEncContext->iTotalEncodedBits - | |
| 597 | + m_pEncContext->iLastStatisticsBits) * 1000 / kiTimeDiff); | |
| 598 | + } | |
| 598 | 599 | |
| 599 | − // update variables | |
| 600 | − m_pEncContext->iLastStatisticsLogTs = kiCurrentFrameTs; | |
| 601 | − m_pEncContext->iLastStatisticsBits = m_pEncContext->iTotalEncodedBits; | |
| 602 | − m_pEncContext->iLastStatisticsFrameCount = pStatistics->uiInputFrameCount; | |
| 600 | + // update variables | |
| 601 | + pStatistics->iStatisticsTs = kiCurrentFrameTs; | |
| 602 | + m_pEncContext->iLastStatisticsBits = m_pEncContext->iTotalEncodedBits; | |
| 603 | + m_pEncContext->iLastStatisticsFrameCount = pStatistics->uiInputFrameCount; | |
| 603 | 604 | |
| 605 | + //TODO: the following statistics will be calculated and added later | |
| 606 | + //pStatistics->uiLTRSentNum | |
| 607 | + } | |
| 608 | + if (m_pEncContext->iStatisticsLogInterval > 0) { | |
| 609 | + const int64_t kiTimeDiff = kiCurrentFrameTs - m_pEncContext->iLastStatisticsLogTs; | |
| 610 | + if ((kiTimeDiff > m_pEncContext->iStatisticsLogInterval) || (0 == pStatistics->uiInputFrameCount % 300)) { | |
| 604 | 611 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |
| 605 | 612 | "EncoderStatistics: %dx%d, SpeedInMs: %f, fAverageFrameRate=%f, \ |
| 606 | 613 | LastFrameRate=%f, LatestBitRate=%d, LastFrameQP=%d, uiInputFrameCount=%d, uiSkippedFrameCount=%d, \ |
| @@ -610,8 +617,7 @@ void CWelsH264SVCEncoder::UpdateStatistics (const int64_t kiCurrentFrameTs, EVid · 3 unmodified lines | ||
| 610 | 617 | pStatistics->fLatestFrameRate, pStatistics->uiBitRate, pStatistics->uiAverageFrameQP, |
| 611 | 618 | pStatistics->uiInputFrameCount, pStatistics->uiSkippedFrameCount, |
| 612 | 619 | pStatistics->uiResolutionChangeTimes, pStatistics->uiIDRReqNum, pStatistics->uiIDRSentNum); |
| 613 | − //TODO: the following statistics will be calculated and added later | |
| 614 | − //pStatistics->uiLTRSentNum | |
| 620 | + m_pEncContext->iLastStatisticsLogTs = kiCurrentFrameTs; | |
| 615 | 621 | } |
| 616 | 622 | } |
| 617 | 623 | |