ref: fb48e98b8c7d2ca8df9695a2262d98019ca0dab4
parent: 47aedcf80821507029adf3adbd809aa8ee55f3b0
author: sijchen@cisco.com <sijchen@cisco.com>
date: Mon Jan 30 12:20:14 EST 2017
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/inc/au_parser.h
+++ b/codec/decoder/core/inc/au_parser.h
@@ -193,6 +193,8 @@
*/
int32_t ResetFmoList (PWelsDecoderContext pCtx);
+
+const SLevelLimits* GetLevelLimits (int32_t iLevelIdx, bool bConstraint3);
} // namespace WelsDec
#endif//WELS_ACCESS_UNIT_PARSER_H__
--- 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, const int32_t iSpsId) {
+ pDecoderStatistics->iCurrentActiveSpsId = 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,10 @@
pCtx->pSliceHeader = pSh;
pCtx->iFrameNum = pSh->iFrameNum;
+
+ UpdateDecoderStatisticsForActiveParaset(&(pCtx->sDecoderStatistics),
+ pSps, pPps,
+ (pCurNal->sNalData.sVclNal.bSliceHeaderExtFlag) ? (pCurNal->sNalData.sVclNal.sSliceHeaderExt.pSubsetSps->sSps.iSpsId) : (pSps->iSpsId) );
}
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,8 @@
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) {
+ m_pDecContext->sDecoderStatistics.iStatisticsLogInterval = (* ((unsigned int*)pOption));
} 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 +417,9 @@
m_pDecContext->sDecoderStatistics.uiFreezingNonIDRNum);
}
return cmResultSuccess;
+ } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) {
+ iVal = m_pDecContext->sDecoderStatistics.iStatisticsLogInterval;
+ * ((unsigned int*)pOption) = iVal;
} 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 +630,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,