History

add dec status for freezing

huili2 committed 11 years ago

Commit 504cabf1 parent 82b70b38 files · +116 −43Browse files

Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 8 files). Show all

Unified · Split

codec/decoder/core/src/decoder.cpp+61−2
@@ -147,7 +147,7 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 146 unmodified lines
147147 pCtx->iImgHeightInPixel = 0; // alloc picture data when picture size is available
148148 pCtx->iLastImgWidthInPixel = 0;
149149 pCtx->iLastImgHeightInPixel = 0;
150− pCtx->bFreezeOutput = false;
150+ pCtx->bFreezeOutput = true;
151151
152152 pCtx->iFrameNum = -1;
153153 pCtx->iPrevFrameNum = -1;
@@ -165,6 +165,7 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 11 unmodified lines
165165 pCtx->bAvcBasedFlag = true;
166166 pCtx->eErrorConMethod = ERROR_CON_SLICE_COPY_CROSS_IDR_FREEZE_RES_CHANGE;
167167 pCtx->pPreviousDecodedPictureInDpb = NULL;
168+ pCtx->sDecoderStatistics.iAvgLumaQp = -1;
168169
169170 }
170171
@@ -275,7 +276,7 @@ void WelsFreeMem (PWelsDecoderContext pCtx) { · 104 unmodified lines
275276 pCtx->iImgHeightInPixel = 0;
276277 pCtx->iLastImgWidthInPixel = 0;
277278 pCtx->iLastImgHeightInPixel = 0;
278− pCtx->bFreezeOutput = false;
279+ pCtx->bFreezeOutput = true;
279280 pCtx->bHaveGotMemory = false;
280281 WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine");
281282 }
@@ -777,4 +778,62 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 495 unmodified lines
777778 WelsBlockFuncInit (&pCtx->sBlockFunc, pCtx->uiCpuFlag);
778779 }
779780
781+//reset decoder number related statistics info
782+void ResetDecStatNums (SDecoderStatistics* pDecStat) {
783+ uint32_t uiWidth = pDecStat->uiWidth;
784+ uint32_t uiHeight = pDecStat->uiHeight;
785+ int32_t iAvgLumaQp = pDecStat->iAvgLumaQp;
786+ memset (pDecStat, 0, sizeof (SDecoderStatistics));
787+ pDecStat->uiWidth = uiWidth;
788+ pDecStat->uiHeight = uiHeight;
789+ pDecStat->iAvgLumaQp = iAvgLumaQp;
790+}
791+
792+//update information when freezing occurs, including IDR/non-IDR number
793+void UpdateDecStatFreezingInfo (const bool kbIdrFlag, SDecoderStatistics* pDecStat) {
794+ if (kbIdrFlag)
795+ pDecStat->uiFreezingIDRNum++;
796+ else
797+ pDecStat->uiFreezingNonIDRNum++;
798+}
799+
800+//update information when no freezing occurs, including QP, correct IDR number, ECed IDR number
801+void UpdateDecStatNoFreezingInfo (PWelsDecoderContext pCtx) {
802+ PDqLayer pCurDq = pCtx->pCurDqLayer;
803+ PPicture pPic = pCtx->pDec;
804+ SDecoderStatistics* pDecStat = &pCtx->sDecoderStatistics;
805+
806+ if (pDecStat->iAvgLumaQp == -1) //first correct frame received
807+ pDecStat->iAvgLumaQp = 0;
808+
809+ //update QP info
810+ int32_t iTotalQp = 0;
811+ const int32_t kiMbNum = pCurDq->iMbWidth * pCurDq->iMbHeight;
812+ for (int32_t iMb = 0; iMb < kiMbNum; ++iMb) {
813+ iTotalQp += pCurDq->pLumaQp[iMb] * pCurDq->pMbCorrectlyDecodedFlag[iMb];
814+ }
815+ iTotalQp /= kiMbNum;
816+ if (pDecStat->uiDecodedFrameCount + 1 == 0) { //maximum uint32_t reached
817+ ResetDecStatNums (pDecStat);
818+ pDecStat->iAvgLumaQp = iTotalQp;
819+ } else
820+ pDecStat->iAvgLumaQp = (uint64_t) (pDecStat->iAvgLumaQp * pDecStat->uiDecodedFrameCount + iTotalQp) /
821+ (pDecStat->uiDecodedFrameCount + 1);
822+
823+ //update IDR number
824+ if (pCurDq->sLayerInfo.sNalHeaderExt.bIdrFlag) {
825+ pDecStat->uiIDRCorrectNum += (pPic->bIsComplete);
826+ pDecStat->uiEcIDRNum += (!pPic->bIsComplete);
827+ }
828+}
829+
830+//update decoder statistics information
831+void UpdateDecStat (PWelsDecoderContext pCtx, const bool kbOutput) {
832+ if (pCtx->bFreezeOutput)
833+ UpdateDecStatFreezingInfo (pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag, &pCtx->sDecoderStatistics);
834+ else if (kbOutput)
835+ UpdateDecStatNoFreezingInfo (pCtx);
836+}
837+
838+
780839 } // namespace WelsDec

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t