shithub: openh264

Download patch

ref: 585b61626c801437cefc832f09cc637e19732ed1
parent: d15afbbee0b13b12b9fe9f8e29245feb28ba1e0f
author: Sijia Chen <[email protected]>
date: Tue May 26 10:49:46 EDT 2015

add some warning traces in case the setting of frame rate has problem

--- a/codec/console/enc/src/welsenc.cpp
+++ b/codec/console/enc/src/welsenc.cpp
@@ -626,7 +626,7 @@
 int FillSpecificParameters (SEncParamExt& sParam) {
   /* Test for temporal, spatial, SNR scalability */
   sParam.iUsageType = CAMERA_VIDEO_REAL_TIME;
-  sParam.fMaxFrameRate	= 30.0f;		// input frame rate
+  sParam.fMaxFrameRate	= 60.0f;		// input frame rate
   sParam.iPicWidth		= 1280;			// width of picture in samples
   sParam.iPicHeight	= 720;			// height of picture in samples
   sParam.iTargetBitrate = 2500000;		// target bitrate desired
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -559,7 +559,7 @@
   pStatistics->uiSkippedFrameCount += (kbCurrentFrameSkipped ? 1 : 0);
   int32_t iProcessedFrameCount = pStatistics->uiInputFrameCount - pStatistics->uiSkippedFrameCount;
   if (!kbCurrentFrameSkipped && iProcessedFrameCount != 0) {
-    pStatistics->fAverageFrameSpeedInMs += (kiCurrentFrameMs - pStatistics->fAverageFrameSpeedInMs)/iProcessedFrameCount;
+    pStatistics->fAverageFrameSpeedInMs += (kiCurrentFrameMs - pStatistics->fAverageFrameSpeedInMs) / iProcessedFrameCount;
   }
 
   // rate control related
@@ -586,7 +586,7 @@
 
   const int32_t kiDeltaFrames = static_cast<int32_t> (pStatistics->uiInputFrameCount -
                                 m_pEncContext->iLastStatisticsFrameCount);
-  if (kiDeltaFrames > m_pEncContext->pSvcParam->fMaxFrameRate) {
+  if (kiDeltaFrames > (m_pEncContext->pSvcParam->fMaxFrameRate * 2)) {
     const int64_t kiTimeDiff = kiCurrentFrameTs - pStatistics->iStatisticsTs;
     if (kiTimeDiff) {
       pStatistics->fLatestFrameRate = static_cast<float> ((pStatistics->uiInputFrameCount -
@@ -596,6 +596,14 @@
                                m_pEncContext->iLastStatisticsBytes) * 8 * 1000 / kiTimeDiff);
     }
 
+    if (m_pEncContext->pSvcParam->iRCMode == RC_QUALITY_MODE || m_pEncContext->pSvcParam->iRCMode == RC_BITRATE_MODE) {
+      if (WELS_ABS (pStatistics->fLatestFrameRate - m_pEncContext->pSvcParam->fMaxFrameRate) > 5) {
+        WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING,
+                 "Actual Input Framerate %f is different from framerate in setting %f, suggest to use other rate control modes",
+                 pStatistics->fLatestFrameRate, m_pEncContext->pSvcParam->fMaxFrameRate);
+      }
+    }
+
     // update variables
     pStatistics->iStatisticsTs = kiCurrentFrameTs;
     m_pEncContext->iLastStatisticsBytes = m_pEncContext->iTotalEncodedBytes;
@@ -607,6 +615,13 @@
   if (m_pEncContext->iStatisticsLogInterval > 0) {
     const int64_t kiTimeDiff = kiCurrentFrameTs - m_pEncContext->iLastStatisticsLogTs;
     if ((kiTimeDiff > m_pEncContext->iStatisticsLogInterval) || (0 == pStatistics->uiInputFrameCount % 300)) {
+
+      if (WELS_ABS (pStatistics->fAverageFrameRate - m_pEncContext->pSvcParam->fMaxFrameRate) > 30) {
+        WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING,
+                 "Actual Input Framerate %f is quite different from framerate in setting %f, please check setting or timestamp unit (ms)",
+                 pStatistics->fAverageFrameRate, m_pEncContext->pSvcParam->fMaxFrameRate);
+      }
+
       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, "