ref: 9ba0a1d977d50e6f5650d03286c40beb89058875
parent: f42c9fae422b062f87fb38223f7f1e3c658d7c8d
parent: cd5928d3976809011076ef94a06db1563b6902a7
author: ruil2 <[email protected]>
date: Wed Nov 12 07:29:13 EST 2014
Merge pull request #1522 from sijchen/after_review [Encoder] 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));
}
@@ -686,6 +687,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);
@@ -736,6 +738,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;