shithub: openh264

Download patch

ref: 0292647449cf400ec5176ace4e1c3f3e5d0c93e8
parent: 8eed27a3576a6688db731ff08fbc5620da27c8f9
parent: b86bd5f7f678dc8e27e1e7cd894a54d80a12037d
author: HaiboZhu <haibozhu@cisco.com>
date: Thu Oct 29 10:17:19 EDT 2015

Merge pull request #2195 from sijchen/add_stat_log

[Encoder] Log enhancement for easier debugging

--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -3448,6 +3448,9 @@
   pCtx->bEncCurFrmAsIdrFlag = true;
   pCtx->iCodingIndex = 0;
   pCtx->bCheckWindowStatusRefreshFlag = false;
+
+  WelsLog (&pCtx->sLogCtx, WELS_LOG_INFO, "ForceCodingIDR at InputFrameCount=%d\n",
+           pCtx->sEncoderStatistics.uiInputFrameCount);
   return 0;
 }
 
--- a/codec/encoder/plus/inc/welsEncoderExt.h
+++ b/codec/encoder/plus/inc/welsEncoderExt.h
@@ -99,6 +99,7 @@
  private:
   int InitializeInternal (SWelsSvcCodingParam* argv);
   void TraceParamInfo(SEncParamExt *pParam);
+  void LogStatistics (const int64_t kiCurrentFrameTs);
   void UpdateStatistics(const int64_t kiCurrentFrameTs, EVideoFrameType eFrameType,  const int32_t kiCurrentFrameSize, const int64_t kiCurrentFrameMs);
 
   sWelsEncCtx*      m_pEncContext;
--- a/codec/encoder/plus/src/welsEncoderExt.cpp
+++ b/codec/encoder/plus/src/welsEncoderExt.cpp
@@ -475,8 +475,8 @@
   if (! (m_pEncContext && m_bInitialFlag)) {
     return 1;
   }
-  WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
-           "CWelsH264SVCEncoder::ForceIntraFrame(), bIDR= %d", bIDR);
+  //WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
+  //         "CWelsH264SVCEncoder::ForceIntraFrame(), bIDR= %d", bIDR);
 
   ForceCodingIDR (m_pEncContext);
 
@@ -541,6 +541,21 @@
   }
 }
 
+void CWelsH264SVCEncoder::LogStatistics (const int64_t kiCurrentFrameTs) {
+  SEncoderStatistics* pStatistics = & (m_pEncContext->sEncoderStatistics);
+  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, "
+           "uiResolutionChangeTimes=%d, uIDRReqNum=%d, uIDRSentNum=%d, uLTRSentNum=NA, iTotalEncodedBytes=%" PRId64
+           " at Ts = %" PRId64,
+           pStatistics->uiWidth, pStatistics->uiHeight,
+           pStatistics->fAverageFrameSpeedInMs, pStatistics->fAverageFrameRate,
+           pStatistics->fLatestFrameRate, pStatistics->uiBitRate, pStatistics->uiAverageFrameQP,
+           pStatistics->uiInputFrameCount, pStatistics->uiSkippedFrameCount,
+           pStatistics->uiResolutionChangeTimes, pStatistics->uiIDRReqNum, pStatistics->uiIDRSentNum,
+           m_pEncContext->iTotalEncodedBytes, kiCurrentFrameTs);
+}
+
 void CWelsH264SVCEncoder::UpdateStatistics (const int64_t kiCurrentFrameTs, EVideoFrameType eFrameType,
     const int32_t kiCurrentFrameSize, const int64_t kiCurrentFrameMs) {
   SEncoderStatistics* pStatistics = & (m_pEncContext->sEncoderStatistics);
@@ -624,21 +639,12 @@
     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 fAverageFrameRate = %f is quite different from framerate in setting %f, please check setting or timestamp unit (ms), start_Ts = %" PRId64,
+                 "Actual input framerate fAverageFrameRate = %f is quite different from framerate in setting %f, please check setting or timestamp unit (ms), start_Ts = %"
+                 PRId64,
                  pStatistics->fAverageFrameRate, m_pEncContext->pSvcParam->fMaxFrameRate, m_pEncContext->uiStartTimestamp);
       }
 
-      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, "
-               "uiResolutionChangeTimes=%d, uIDRReqNum=%d, uIDRSentNum=%d, uLTRSentNum=NA, iTotalEncodedBytes=%" PRId64
-               " at Ts = %" PRId64,
-               pStatistics->uiWidth, pStatistics->uiHeight,
-               pStatistics->fAverageFrameSpeedInMs, pStatistics->fAverageFrameRate,
-               pStatistics->fLatestFrameRate, pStatistics->uiBitRate, pStatistics->uiAverageFrameQP,
-               pStatistics->uiInputFrameCount, pStatistics->uiSkippedFrameCount,
-               pStatistics->uiResolutionChangeTimes, pStatistics->uiIDRReqNum, pStatistics->uiIDRSentNum,
-               m_pEncContext->iTotalEncodedBytes, kiCurrentFrameTs);
+      LogStatistics (kiCurrentFrameTs);
       m_pEncContext->iLastStatisticsLogTs = kiCurrentFrameTs;
     }
   }
@@ -772,6 +778,11 @@
     if (WelsEncoderParamAdjust (&m_pEncContext, &sConfig)) {
       return cmInitParaError;
     }
+
+    //LogStatistics
+    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
+             "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, LogStatisticsBeforeNewEncoding");
+    LogStatistics (m_pEncContext->iLastStatisticsLogTs);
   }
   break;
   case ENCODER_OPTION_FRAME_RATE: { // Maximal input frame rate