ref: ecc8ae6ebba6bb22d19ee905e22fc7fbeb25f2c7
parent: 065c3a776922dadda280e7ef88d339f3d57d8fcc
author: dong zhang <dongzha@cisco.com>
date: Mon Dec 8 10:00:29 EST 2014
fix decodestatus uiEcRatio calc bug
--- a/codec/decoder/core/inc/decoder_context.h
+++ b/codec/decoder/core/inc/decoder_context.h
@@ -400,6 +400,8 @@
PWelsCabacDecEngine pCabacDecEngine;
double dDecTime;
SDecoderStatistics sDecoderStatistics;// For real time debugging
+int32_t iMbEcedNum;
+int32_t iMbNum;
int32_t iECMVs[16][2];
PPicture pECRefPic[16];
unsigned long long uiTimeStamp;
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -1683,7 +1683,8 @@
int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
int32_t iErr;
PAccessUnit pCurAu = pCtx->pAccessUnitList;
-
+ pCtx->iMbEcedNum = 0;
+ pCtx->iMbNum = 0;
pCtx->bAuReadyFlag = false;
pCtx->bLastHasMmco5 = false;
bool bTmpNewSeqBegin = CheckNewSeqBeginAndUpdateActiveLayerSps (pCtx);
--- a/codec/decoder/core/src/error_concealment.cpp
+++ b/codec/decoder/core/src/error_concealment.cpp
@@ -82,6 +82,8 @@
uint32_t uiHeightInPixelY = (pCtx->pSps->iMbHeight) << 4;
int32_t iStrideY = pDstPic->iLinesize[0];
int32_t iStrideUV = pDstPic->iLinesize[1];
+ pCtx->iMbNum = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight;
+ pCtx->iMbEcedNum = pCtx->iMbNum;
if ((pCtx->eErrorConMethod == ERROR_CON_FRAME_COPY) && (pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag))
pSrcPic = NULL; //no cross IDR method, should fill in data instead of copy
if (pSrcPic == NULL) { //no ref pic, assign specific data to picture
@@ -105,10 +107,10 @@
if ((pCtx->eErrorConMethod == ERROR_CON_SLICE_COPY) && (pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag))
pSrcPic = NULL; //no cross IDR method, should fill in data instead of copy
- int32_t iMbNum = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight;
+ pCtx->iMbNum = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight;
//uint8_t *pDstData[3], *pSrcData[3];
bool* pMbCorrectlyDecodedFlag = pCtx->pCurDqLayer->pMbCorrectlyDecodedFlag;
- int32_t iMbEcedNum = 0;
+ pCtx->iMbEcedNum = 0;
//Do slice copy late
int32_t iMbXyIndex;
uint8_t* pSrcData, *pDstData;
@@ -118,7 +120,7 @@
for (int32_t iMbX = 0; iMbX < iMbWidth; ++iMbX) {
iMbXyIndex = iMbY * iMbWidth + iMbX;
if (!pMbCorrectlyDecodedFlag[iMbXyIndex]) {
- iMbEcedNum++;
+ pCtx->iMbEcedNum++;
if (pSrcPic != NULL) {
iSrcStride = pSrcPic->iLinesize[0];
//Y component
@@ -156,10 +158,6 @@
} //!pMbCorrectlyDecodedFlag[iMbXyIndex]
} //iMbX
} //iMbY
-
- if (!pCtx->bFreezeOutput)
- pCtx->sDecoderStatistics.uiAvgEcRatio = (pCtx->sDecoderStatistics.uiAvgEcRatio * pCtx->sDecoderStatistics.uiEcFrameNum)
- + ((iMbEcedNum * 100) / iMbNum) ;
}
//Do error concealment using slice MV copy method
@@ -368,9 +366,9 @@
PPicture pDstPic = pCtx->pDec;
PPicture pSrcPic = pCtx->pPreviousDecodedPictureInDpb;
- int32_t iMbNum = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight;
+ pCtx->iMbNum = pCtx->pSps->iMbWidth * pCtx->pSps->iMbHeight;
bool* pMbCorrectlyDecodedFlag = pCtx->pCurDqLayer->pMbCorrectlyDecodedFlag;
- int32_t iMbEcedNum = 0;
+ pCtx->iMbEcedNum = 0;
int32_t iMbXyIndex;
uint8_t* pDstData;
uint32_t iDstStride = pDstPic->iLinesize[0];
@@ -395,7 +393,7 @@
for (int32_t iMbX = 0; iMbX < iMbWidth; ++iMbX) {
iMbXyIndex = iMbY * iMbWidth + iMbX;
if (!pMbCorrectlyDecodedFlag[iMbXyIndex]) {
- iMbEcedNum++;
+ pCtx->iMbEcedNum++;
if (pSrcPic != NULL) {
DoMbECMvCopy (pCtx, pDstPic, pSrcPic, iMbXyIndex, iMbX, iMbY, &sMCRefMem);
} else { //pSrcPic == NULL
@@ -422,10 +420,6 @@
} //!pMbCorrectlyDecodedFlag[iMbXyIndex]
} //iMbX
} //iMbY
-
- if (!pCtx->bFreezeOutput)
- pCtx->sDecoderStatistics.uiAvgEcRatio = (pCtx->sDecoderStatistics.uiAvgEcRatio * pCtx->sDecoderStatistics.uiEcFrameNum)
- + ((iMbEcedNum * 100) / iMbNum) ;
}
//Mark erroneous frame as Ref Pic into DPB
--- a/codec/decoder/plus/src/welsDecoderExt.cpp
+++ b/codec/decoder/plus/src/welsDecoderExt.cpp
@@ -385,6 +385,8 @@
const int kiSrcLen,
unsigned char** ppDst,
SBufferInfo* pDstInfo) {
+ m_pDecContext->iMbEcedNum = 0;
+ m_pDecContext->iMbNum = 0;
if (CheckBsBuffer (m_pDecContext, kiSrcLen)) {
return dsOutOfMemory;
}
@@ -464,11 +466,7 @@
if ((m_pDecContext->eErrorConMethod != ERROR_CON_DISABLE) && (pDstInfo->iBufferStatus == 1)) {
//TODO after dec status updated
m_pDecContext->iErrorCode |= dsDataErrorConcealed;
- if (m_pDecContext->eErrorConMethod == ERROR_CON_FRAME_COPY)
- m_pDecContext->sDecoderStatistics.uiAvgEcRatio = (m_pDecContext->sDecoderStatistics.uiAvgEcRatio *
- m_pDecContext->sDecoderStatistics.uiEcFrameNum) + 100;
-
//
if ((m_pDecContext->sDecoderStatistics.uiWidth != (unsigned int) pDstInfo->UsrData.sSystemBuffer.iWidth)
|| (m_pDecContext->sDecoderStatistics.uiHeight != (unsigned int) pDstInfo->UsrData.sSystemBuffer.iHeight)) {
@@ -482,6 +480,7 @@
ResetDecStatNums (&m_pDecContext->sDecoderStatistics);
m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
}
+ m_pDecContext->sDecoderStatistics.uiAvgEcRatio = m_pDecContext->iMbEcedNum == 0 ? (m_pDecContext->sDecoderStatistics.uiAvgEcRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) :((m_pDecContext->sDecoderStatistics.uiAvgEcRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) + ((m_pDecContext->iMbEcedNum * 100) / m_pDecContext->iMbNum));
m_pDecContext->sDecoderStatistics.uiEcFrameNum++;
m_pDecContext->sDecoderStatistics.uiAvgEcRatio = m_pDecContext->sDecoderStatistics.uiAvgEcRatio /
m_pDecContext->sDecoderStatistics.uiEcFrameNum;