Merge pull request #2307 from huili2/fix_decstat

fix iAvgLumaQp in decStat
This commit is contained in:
HaiboZhu 2015-12-14 10:26:16 +08:00
commit ee01b3afaf
3 changed files with 18 additions and 7 deletions

View File

@ -1017,10 +1017,15 @@ void UpdateDecStatNoFreezingInfo (PWelsDecoderContext pCtx) {
//update QP info
int32_t iTotalQp = 0;
const int32_t kiMbNum = pCurDq->iMbWidth * pCurDq->iMbHeight;
int32_t iCorrectMbNum = 0;
for (int32_t iMb = 0; iMb < kiMbNum; ++iMb) {
iCorrectMbNum += (int32_t) pCurDq->pMbCorrectlyDecodedFlag[iMb];
iTotalQp += pCurDq->pLumaQp[iMb] * pCurDq->pMbCorrectlyDecodedFlag[iMb];
}
iTotalQp /= kiMbNum;
if (iCorrectMbNum == 0) //non MB is correct, should remain QP statistic info
iTotalQp = pDecStat->iAvgLumaQp;
else
iTotalQp /= iCorrectMbNum;
if (pDecStat->uiDecodedFrameCount + 1 == 0) { //maximum uint32_t reached
ResetDecStatNums (pDecStat);
pDecStat->iAvgLumaQp = iTotalQp;

View File

@ -403,11 +403,13 @@ long CWelsDecoder::GetOption (DECODER_OPTION eOptID, void* pOption) {
memcpy (pDecoderStatistics, &m_pDecContext->sDecoderStatistics, sizeof (SDecoderStatistics));
pDecoderStatistics->fAverageFrameSpeedInMs = (float) (m_pDecContext->dDecTime) /
(m_pDecContext->sDecoderStatistics.uiDecodedFrameCount);
pDecoderStatistics->fActualAverageFrameSpeedInMs = (float) (m_pDecContext->dDecTime) /
(m_pDecContext->sDecoderStatistics.uiDecodedFrameCount + m_pDecContext->sDecoderStatistics.uiFreezingIDRNum +
m_pDecContext->sDecoderStatistics.uiFreezingNonIDRNum);
if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount != 0) { //not original status
pDecoderStatistics->fAverageFrameSpeedInMs = (float) (m_pDecContext->dDecTime) /
(m_pDecContext->sDecoderStatistics.uiDecodedFrameCount);
pDecoderStatistics->fActualAverageFrameSpeedInMs = (float) (m_pDecContext->dDecTime) /
(m_pDecContext->sDecoderStatistics.uiDecodedFrameCount + m_pDecContext->sDecoderStatistics.uiFreezingIDRNum +
m_pDecContext->sDecoderStatistics.uiFreezingNonIDRNum);
}
return cmResultSuccess;
}

View File

@ -105,7 +105,7 @@ void DecoderInterfaceTest::ValidInit() {
m_sDecParam.eEcActiveIdc = (ERROR_CON_IDC) (rand() & 7);
m_sDecParam.sVideoProperty.size = sizeof (SVideoProperty);
m_sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_DEFAULT;
m_pData[0] = m_pData[1] = m_pData[2] = NULL;
m_szBuffer[0] = m_szBuffer[1] = m_szBuffer[2] = 0;
m_szBuffer[3] = 1;
@ -502,6 +502,10 @@ void DecoderInterfaceTest::TestGetDecStatistics() {
int32_t iError = 0;
ValidInit();
//GetOption before decoding
m_pDec->GetOption (DECODER_OPTION_GET_STATISTICS, &sDecStatic);
EXPECT_EQ (0u, sDecStatic.uiDecodedFrameCount);
EXPECT_TRUE (-1 == sDecStatic.iAvgLumaQp);
// setoption not support,
eRet = (CM_RETURN)m_pDec->SetOption (DECODER_OPTION_GET_STATISTICS, NULL);
EXPECT_EQ (eRet, cmInitParaError);