ref: d557578be323707cf3eaf68662d6ff3b790bf5d1
parent: f404ce2e569666ebc132b2c4e56f25fb2c3c4dbf
author: Sijia Chen <[email protected]>
date: Tue Jan 27 05:12:51 EST 2015
fix statistics: updating should be independent with log interval
--- a/codec/api/svc/codec_app_def.h
+++ b/codec/api/svc/codec_app_def.h
@@ -432,7 +432,8 @@
ECOMPLEXITY_MODE iComplexityMode;
unsigned int uiIntraPeriod; ///< period of Intra frame
int iNumRefFrame; ///< number of reference frame used
- EParameterSetStrategy eSpsPpsIdStrategy; ///< different stategy in adjust ID in SPS/PPS: 0- constant ID, 1-additional ID, 6-mapping and additional
+ EParameterSetStrategy
+ eSpsPpsIdStrategy; ///< different stategy in adjust ID in SPS/PPS: 0- constant ID, 1-additional ID, 6-mapping and additional
bool bPrefixNalAddingCtrl; ///< false:not use Prefix NAL; true: use Prefix NAL
bool bEnableSSEI; ///< false:not use SSEI; true: use SSEI -- TODO: planning to remove the interface of SSEI
bool bSimulcastAVC; ///< (when encoding more than 1 spatial layer) false: use SVC syntax for higher layers; true: use Simulcast AVC -- coming soon
@@ -631,6 +632,8 @@
unsigned int uiIDRReqNum; ///< number of IDR requests
unsigned int uiIDRSentNum; ///< number of actual IDRs sent
unsigned int uiLTRSentNum; ///< number of LTR sent/marked
+
+ long long iStatisticsTs; ///< Timestamp of updating the statistics
} SEncoderStatistics; // in building, coming soon
/**
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -583,24 +583,31 @@
pStatistics->uiLTRSentNum ++;
}
- m_pEncContext->iTotalEncodedBits += (kiCurrentFrameSize<<3);
+ m_pEncContext->iTotalEncodedBits += (kiCurrentFrameSize << 3);
- if (m_pEncContext->iStatisticsLogInterval > 0) {
- int64_t iTimeDiff = kiCurrentFrameTs - m_pEncContext->iLastStatisticsLogTs;
- if ((iTimeDiff > m_pEncContext->iStatisticsLogInterval) || (0 == pStatistics->uiInputFrameCount % 300)) {
- if (iTimeDiff) {
- pStatistics->fLatestFrameRate = static_cast<float> ((pStatistics->uiInputFrameCount -
- m_pEncContext->iLastStatisticsFrameCount) * 1000 /
- iTimeDiff);
- pStatistics->uiBitRate = static_cast<unsigned int> ((m_pEncContext->iTotalEncodedBits -
- m_pEncContext->iLastStatisticsBits) * 1000 / iTimeDiff);
- }
+ const int32_t kiDeltaFrames = static_cast<int32_t> (pStatistics->uiInputFrameCount -
+ m_pEncContext->iLastStatisticsFrameCount);
+ if (kiDeltaFrames > m_pEncContext->pSvcParam->fMaxFrameRate) {
+ const int64_t kiTimeDiff = kiCurrentFrameTs - pStatistics->iStatisticsTs;
+ if (kiTimeDiff) {
+ pStatistics->fLatestFrameRate = static_cast<float> ((pStatistics->uiInputFrameCount -
+ m_pEncContext->iLastStatisticsFrameCount) * 1000 /
+ kiTimeDiff);
+ pStatistics->uiBitRate = static_cast<unsigned int> ((m_pEncContext->iTotalEncodedBits -
+ m_pEncContext->iLastStatisticsBits) * 1000 / kiTimeDiff);
+ }
- // update variables
- m_pEncContext->iLastStatisticsLogTs = kiCurrentFrameTs;
- m_pEncContext->iLastStatisticsBits = m_pEncContext->iTotalEncodedBits;
- m_pEncContext->iLastStatisticsFrameCount = pStatistics->uiInputFrameCount;
+ // update variables
+ pStatistics->iStatisticsTs = kiCurrentFrameTs;
+ m_pEncContext->iLastStatisticsBits = m_pEncContext->iTotalEncodedBits;
+ m_pEncContext->iLastStatisticsFrameCount = pStatistics->uiInputFrameCount;
+ //TODO: the following statistics will be calculated and added later
+ //pStatistics->uiLTRSentNum
+ }
+ if (m_pEncContext->iStatisticsLogInterval > 0) {
+ const int64_t kiTimeDiff = kiCurrentFrameTs - m_pEncContext->iLastStatisticsLogTs;
+ if ((kiTimeDiff > m_pEncContext->iStatisticsLogInterval) || (0 == pStatistics->uiInputFrameCount % 300)) {
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
"EncoderStatistics: %dx%d, SpeedInMs: %f, fAverageFrameRate=%f, \
LastFrameRate=%f, LatestBitRate=%d, LastFrameQP=%d, uiInputFrameCount=%d, uiSkippedFrameCount=%d, \
@@ -610,8 +617,7 @@
pStatistics->fLatestFrameRate, pStatistics->uiBitRate, pStatistics->uiAverageFrameQP,
pStatistics->uiInputFrameCount, pStatistics->uiSkippedFrameCount,
pStatistics->uiResolutionChangeTimes, pStatistics->uiIDRReqNum, pStatistics->uiIDRSentNum);
- //TODO: the following statistics will be calculated and added later
- //pStatistics->uiLTRSentNum
+ m_pEncContext->iLastStatisticsLogTs = kiCurrentFrameTs;
}
}