Showing the changes to codec/encoder/plus/src/welsEncoderExt.cpp (1 of 2 files). Show all
Unified · Split
| @@ -559,7 +559,7 @@ void CWelsH264SVCEncoder::UpdateStatistics (const int64_t kiCurrentFrameTs, EVid · 558 unmodified lines | ||
| 559 | 559 | pStatistics->uiSkippedFrameCount += (kbCurrentFrameSkipped ? 1 : 0); |
| 560 | 560 | int32_t iProcessedFrameCount = pStatistics->uiInputFrameCount - pStatistics->uiSkippedFrameCount; |
| 561 | 561 | if (!kbCurrentFrameSkipped && iProcessedFrameCount != 0) { |
| 562 | − pStatistics->fAverageFrameSpeedInMs += (kiCurrentFrameMs - pStatistics->fAverageFrameSpeedInMs)/iProcessedFrameCount; | |
| 562 | + pStatistics->fAverageFrameSpeedInMs += (kiCurrentFrameMs - pStatistics->fAverageFrameSpeedInMs) / iProcessedFrameCount; | |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | // rate control related |
| @@ -586,7 +586,7 @@ void CWelsH264SVCEncoder::UpdateStatistics (const int64_t kiCurrentFrameTs, EVid · 20 unmodified lines | ||
| 586 | 586 | |
| 587 | 587 | const int32_t kiDeltaFrames = static_cast<int32_t> (pStatistics->uiInputFrameCount - |
| 588 | 588 | m_pEncContext->iLastStatisticsFrameCount); |
| 589 | − if (kiDeltaFrames > m_pEncContext->pSvcParam->fMaxFrameRate) { | |
| 589 | + if (kiDeltaFrames > (m_pEncContext->pSvcParam->fMaxFrameRate * 2)) { | |
| 590 | 590 | const int64_t kiTimeDiff = kiCurrentFrameTs - pStatistics->iStatisticsTs; |
| 591 | 591 | if (kiTimeDiff) { |
| 592 | 592 | pStatistics->fLatestFrameRate = static_cast<float> ((pStatistics->uiInputFrameCount - |
| @@ -596,6 +596,14 @@ void CWelsH264SVCEncoder::UpdateStatistics (const int64_t kiCurrentFrameTs, EVid · 3 unmodified lines | ||
| 596 | 596 | m_pEncContext->iLastStatisticsBytes) * 8 * 1000 / kiTimeDiff); |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | + if (m_pEncContext->pSvcParam->iRCMode == RC_QUALITY_MODE || m_pEncContext->pSvcParam->iRCMode == RC_BITRATE_MODE) { | |
| 600 | + if (WELS_ABS (pStatistics->fLatestFrameRate - m_pEncContext->pSvcParam->fMaxFrameRate) > 5) { | |
| 601 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, | |
| 602 | + "Actual Input Framerate %f is different from framerate in setting %f, suggest to use other rate control modes", | |
| 603 | + pStatistics->fLatestFrameRate, m_pEncContext->pSvcParam->fMaxFrameRate); | |
| 604 | + } | |
| 605 | + } | |
| 606 | + | |
| 599 | 607 | // update variables |
| 600 | 608 | pStatistics->iStatisticsTs = kiCurrentFrameTs; |
| 601 | 609 | m_pEncContext->iLastStatisticsBytes = m_pEncContext->iTotalEncodedBytes; |
| @@ -607,6 +615,13 @@ void CWelsH264SVCEncoder::UpdateStatistics (const int64_t kiCurrentFrameTs, EVid · 5 unmodified lines | ||
| 607 | 615 | if (m_pEncContext->iStatisticsLogInterval > 0) { |
| 608 | 616 | const int64_t kiTimeDiff = kiCurrentFrameTs - m_pEncContext->iLastStatisticsLogTs; |
| 609 | 617 | if ((kiTimeDiff > m_pEncContext->iStatisticsLogInterval) || (0 == pStatistics->uiInputFrameCount % 300)) { |
| 618 | + | |
| 619 | + if (WELS_ABS (pStatistics->fAverageFrameRate - m_pEncContext->pSvcParam->fMaxFrameRate) > 30) { | |
| 620 | + WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, | |
| 621 | + "Actual Input Framerate %f is quite different from framerate in setting %f, please check setting or timestamp unit (ms)", | |
| 622 | + pStatistics->fAverageFrameRate, m_pEncContext->pSvcParam->fMaxFrameRate); | |
| 623 | + } | |
| 624 | + | |
| 610 | 625 | WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, |
| 611 | 626 | "EncoderStatistics: %dx%d, SpeedInMs: %f, fAverageFrameRate=%f, " |
| 612 | 627 | "LastFrameRate=%f, LatestBitRate=%d, LastFrameQP=%d, uiInputFrameCount=%d, uiSkippedFrameCount=%d, " |