ref: cd5928d3976809011076ef94a06db1563b6902a7
parent: 54c677cdd7717cbdef490ef3c64a89da7d1cc28a
author: Sijia Chen <sijchen@cisco.com>
date: Tue Nov 11 11:12:38 EST 2014
fix a calculation of fAverageFrameRate
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -616,9 +616,11 @@
pStatistics->uiSkippedFrameCount += (kbCurrentFrameSkipped ? 1 : 0);
// rate control related
- if (0 != m_pEncContext->uiStartTimestamp && kiCurrentFrameTs > m_pEncContext->uiStartTimestamp + 800) {
- pStatistics->fAverageFrameRate = (float) (pStatistics->uiInputFrameCount * 1000 /
- (kiCurrentFrameTs - m_pEncContext->uiStartTimestamp));
+ if (0 != m_pEncContext->uiStartTimestamp) {
+ if (kiCurrentFrameTs > m_pEncContext->uiStartTimestamp + 800) {
+ pStatistics->fAverageFrameRate = (static_cast<float> (pStatistics->uiInputFrameCount) * 1000 /
+ (kiCurrentFrameTs - m_pEncContext->uiStartTimestamp));
+ }
} else {
m_pEncContext->uiStartTimestamp = kiCurrentFrameTs;
}
--- a/test/encoder/EncUT_EncoderExt.cpp
+++ b/test/encoder/EncUT_EncoderExt.cpp
@@ -124,6 +124,7 @@
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
EXPECT_EQ (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR));
+ pSrcPic->uiTimeStamp += 30;
iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
EXPECT_NE (sFbi.eFrameType, static_cast<int> (videoFrameTypeIDR));
@@ -687,6 +688,7 @@
// 3, code one frame
PrepareOneSrcFrame();
+ pSrcPic->uiTimeStamp = 30 * pEncoderStatistics->uiInputFrameCount;
iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
iResult = pPtrEnc->GetOption (ENCODER_OPTION_GET_STATISTICS, pEncoderStatistics);
@@ -737,6 +739,14 @@
sEncParamBase.iPicWidth = (sEncParamBase.iPicWidth % 16) + 1; //try 1~16
sEncParamBase.iPicHeight = (sEncParamBase.iPicHeight % 16) + 1; //try 1~16
ChangeResolutionAndCheckStatistics (sEncParamBase, &sEncoderStatistics);
+
+ // try timestamp and frame rate
+ pSrcPic->uiTimeStamp = 1000;
+ iResult = pPtrEnc->EncodeFrame (pSrcPic, &sFbi);
+ EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
+ iResult = pPtrEnc->GetOption (ENCODER_OPTION_GET_STATISTICS, &sEncoderStatistics);
+ EXPECT_EQ (iResult, static_cast<int> (cmResultSuccess));
+ EXPECT_EQ (static_cast<int> (sEncoderStatistics.fAverageFrameRate), sEncoderStatistics.uiInputFrameCount);
// 4, change log interval
int32_t iInterval = 0;