ref: 082449eaceb7dfcee787c7fd00b6459b8cb35492
parent: 2ca99122d4e561fd3890fdbe28063c2f318b4fd9
parent: af774e4a52c5bce1f66018990b3f4e67bc7a1937
author: huili2 <huili2@cisco.com>
date: Wed Feb 15 04:10:19 EST 2017
Merge pull request #2656 from sijchen/dec_stat3 [Decoder] add option to set decoder statistics log interval add variables into decoder statistics and add statistics log
--- a/codec/api/svc/codec_app_def.h
+++ b/codec/api/svc/codec_app_def.h
@@ -163,7 +163,9 @@
DECODER_OPTION_GET_STATISTICS, ///< feedback decoder statistics
DECODER_OPTION_GET_SAR_INFO, ///< feedback decoder Sample Aspect Ratio info in Vui
DECODER_OPTION_PROFILE, ///< get current AU profile info, only is used in GetOption
- DECODER_OPTION_LEVEL ///< get current AU level info,only is used in GetOption
+ DECODER_OPTION_LEVEL, ///< get current AU level info,only is used in GetOption
+ DECODER_OPTION_STATISTICS_LOG_INTERVAL,///< set log output interval
+
} DECODER_OPTION;
/**
@@ -770,6 +772,14 @@
int iSpsNoExistNalNum; ///< number of Sps NoExist Nal
int iSubSpsNoExistNalNum; ///< number of SubSps NoExist Nal
int iPpsNoExistNalNum; ///< number of Pps NoExist Nal
+
+ unsigned int uiProfile; ///< Profile idc in syntax
+ unsigned int uiLevel; ///< level idc according to Annex A-1
+
+ int iCurrentActiveSpsId; ///< current active SPS id
+ int iCurrentActivePpsId; ///< current active PPS id
+
+ unsigned int iStatisticsLogInterval; ///< frame interval of statistics log
} SDecoderStatistics; // in building, coming soon
/**
--- a/codec/decoder/core/src/decoder.cpp
+++ b/codec/decoder/core/src/decoder.cpp
@@ -312,6 +312,7 @@
pCtx->bAvcBasedFlag = true;
pCtx->pPreviousDecodedPictureInDpb = NULL;
pCtx->sDecoderStatistics.iAvgLumaQp = -1;
+ pCtx->sDecoderStatistics.iStatisticsLogInterval = 1000;
pCtx->bUseScalingList = false;
pCtx->iSpsErrorIgnored = 0;
pCtx->iSubSpsErrorIgnored = 0;
@@ -1020,10 +1021,12 @@
uint32_t uiWidth = pDecStat->uiWidth;
uint32_t uiHeight = pDecStat->uiHeight;
int32_t iAvgLumaQp = pDecStat->iAvgLumaQp;
+ uint32_t iLogInterval = pDecStat->iStatisticsLogInterval;
memset (pDecStat, 0, sizeof (SDecoderStatistics));
pDecStat->uiWidth = uiWidth;
pDecStat->uiHeight = uiHeight;
pDecStat->iAvgLumaQp = iAvgLumaQp;
+ pDecStat->iStatisticsLogInterval = iLogInterval;
}
//update information when freezing occurs, including IDR/non-IDR number
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -676,6 +676,15 @@
}
+void UpdateDecoderStatisticsForActiveParaset(SDecoderStatistics* pDecoderStatistics,
+ PSps pSps, PPps pPps) {
+ pDecoderStatistics->iCurrentActiveSpsId = pSps->iSpsId;
+
+ pDecoderStatistics->iCurrentActivePpsId = pPps->iPpsId;
+ pDecoderStatistics->uiProfile = static_cast<unsigned int> (pSps->uiProfileIdc);
+ pDecoderStatistics->uiLevel = pSps->uiLevelIdc;
+}
+
#define SLICE_HEADER_IDR_PIC_ID_MAX 65535
#define SLICE_HEADER_REDUNDANT_PIC_CNT_MAX 127
#define SLICE_HEADER_ALPHAC0_BETA_OFFSET_MIN -12
@@ -2108,6 +2117,9 @@
pCtx->pSliceHeader = pSh;
pCtx->iFrameNum = pSh->iFrameNum;
+
+ UpdateDecoderStatisticsForActiveParaset(&(pCtx->sDecoderStatistics),
+ pSps, pPps);
}
int32_t InitRefPicList (PWelsDecoderContext pCtx, const uint8_t kuiNRi, int32_t iPoc) {
--- a/codec/decoder/plus/inc/welsDecoderExt.h
+++ b/codec/decoder/plus/inc/welsDecoderExt.h
@@ -113,6 +113,8 @@
void UninitDecoder (void);
int32_t ResetDecoder();
+void OutputStatisticsLog (SDecoderStatistics& sDecoderStatistics);
+
#ifdef OUTPUT_BIT_STREAM
WelsFileHandle* m_pFBS;
WelsFileHandle* m_pFBSSize;
--- a/codec/decoder/plus/src/welsDecoderExt.cpp
+++ b/codec/decoder/plus/src/welsDecoderExt.cpp
@@ -346,6 +346,11 @@
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING,
"CWelsDecoder::SetOption():DECODER_OPTION_GET_STATISTICS: this option is get-only!");
return cmInitParaError;
+ } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) {
+ if (pOption) {
+ m_pDecContext->sDecoderStatistics.iStatisticsLogInterval = (* ((unsigned int*)pOption));
+ return cmResultSuccess;
+ }
} else if (eOptID == DECODER_OPTION_GET_SAR_INFO) {
WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING,
"CWelsDecoder::SetOption():DECODER_OPTION_GET_SAR_INFO: this option is get-only!");
@@ -415,6 +420,12 @@
m_pDecContext->sDecoderStatistics.uiFreezingNonIDRNum);
}
return cmResultSuccess;
+ } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) {
+ if (pOption) {
+ iVal = m_pDecContext->sDecoderStatistics.iStatisticsLogInterval;
+ * ((unsigned int*)pOption) = iVal;
+ return cmResultSuccess;
+ }
} else if (DECODER_OPTION_GET_SAR_INFO == eOptID) { //get decoder SAR info in VUI
PVuiSarInfo pVuiSarInfo = (static_cast<PVuiSarInfo> (pOption));
memset (pVuiSarInfo, 0, sizeof (SVuiSarInfo));
@@ -625,7 +636,54 @@
}
iEnd = WelsTime();
m_pDecContext->dDecTime += (iEnd - iStart) / 1e3;
+
+ OutputStatisticsLog(m_pDecContext->sDecoderStatistics);
+
return dsErrorFree;
+}
+
+void CWelsDecoder::OutputStatisticsLog(SDecoderStatistics& sDecoderStatistics) {
+ if ((sDecoderStatistics.uiDecodedFrameCount > 0) && (sDecoderStatistics.iStatisticsLogInterval > 0) && ((sDecoderStatistics.uiDecodedFrameCount % sDecoderStatistics.iStatisticsLogInterval) == 0)) {
+ WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
+ "uiWidth=%d, uiHeight=%d, fAverageFrameSpeedInMs=%.1f, fActualAverageFrameSpeedInMs=%.1f, \
+ uiDecodedFrameCount=%d, uiResolutionChangeTimes=%d, uiIDRCorrectNum=%d, \
+ uiAvgEcRatio=%d, uiAvgEcPropRatio=%d, uiEcIDRNum=%d, uiEcFrameNum=%d, \
+ uiIDRLostNum=%d, uiFreezingIDRNum=%d, uiFreezingNonIDRNum=%d, iAvgLumaQp=%d, \
+ iSpsReportErrorNum=%d, iSubSpsReportErrorNum=%d, iPpsReportErrorNum=%d, iSpsNoExistNalNum=%d, iSubSpsNoExistNalNum=%d, iPpsNoExistNalNum=%d, \
+ uiProfile=%d, uiLevel=%d, \
+ iCurrentActiveSpsId=%d, iCurrentActivePpsId=%d,",
+ sDecoderStatistics.uiWidth,
+ sDecoderStatistics.uiHeight,
+ sDecoderStatistics.fAverageFrameSpeedInMs,
+ sDecoderStatistics.fActualAverageFrameSpeedInMs,
+
+ sDecoderStatistics.uiDecodedFrameCount,
+ sDecoderStatistics.uiResolutionChangeTimes,
+ sDecoderStatistics.uiIDRCorrectNum,
+
+ sDecoderStatistics.uiAvgEcRatio,
+ sDecoderStatistics.uiAvgEcPropRatio,
+ sDecoderStatistics.uiEcIDRNum,
+ sDecoderStatistics.uiEcFrameNum,
+
+ sDecoderStatistics.uiIDRLostNum,
+ sDecoderStatistics.uiFreezingIDRNum,
+ sDecoderStatistics.uiFreezingNonIDRNum,
+ sDecoderStatistics.iAvgLumaQp,
+
+ sDecoderStatistics.iSpsReportErrorNum,
+ sDecoderStatistics.iSubSpsReportErrorNum,
+ sDecoderStatistics.iPpsReportErrorNum,
+ sDecoderStatistics.iSpsNoExistNalNum,
+ sDecoderStatistics.iSubSpsNoExistNalNum,
+ sDecoderStatistics.iPpsNoExistNalNum,
+
+ sDecoderStatistics.uiProfile,
+ sDecoderStatistics.uiLevel,
+
+ sDecoderStatistics.iCurrentActiveSpsId,
+ sDecoderStatistics.iCurrentActivePpsId);
+ }
}
DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc,