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
147 pCtx->iImgHeightInPixel = 0; // alloc picture data when picture size is available147 pCtx->iImgHeightInPixel = 0; // alloc picture data when picture size is available
148 pCtx->iLastImgWidthInPixel = 0;148 pCtx->iLastImgWidthInPixel = 0;
149 pCtx->iLastImgHeightInPixel = 0;149 pCtx->iLastImgHeightInPixel = 0;
150 pCtx->bFreezeOutput = false;150 pCtx->bFreezeOutput = true;
151 151
152 pCtx->iFrameNum = -1;152 pCtx->iFrameNum = -1;
153 pCtx->iPrevFrameNum = -1;153 pCtx->iPrevFrameNum = -1;
@@ -165,6 +165,7 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 11 unmodified lines
165 pCtx->bAvcBasedFlag = true;165 pCtx->bAvcBasedFlag = true;
166 pCtx->eErrorConMethod = ERROR_CON_SLICE_COPY_CROSS_IDR_FREEZE_RES_CHANGE;166 pCtx->eErrorConMethod = ERROR_CON_SLICE_COPY_CROSS_IDR_FREEZE_RES_CHANGE;
167 pCtx->pPreviousDecodedPictureInDpb = NULL;167 pCtx->pPreviousDecodedPictureInDpb = NULL;
168 pCtx->sDecoderStatistics.iAvgLumaQp = -1;
168 169
169}170}
170 171
@@ -275,7 +276,7 @@ void WelsFreeMem (PWelsDecoderContext pCtx) { · 104 unmodified lines
275 pCtx->iImgHeightInPixel = 0;276 pCtx->iImgHeightInPixel = 0;
276 pCtx->iLastImgWidthInPixel = 0;277 pCtx->iLastImgWidthInPixel = 0;
277 pCtx->iLastImgHeightInPixel = 0;278 pCtx->iLastImgHeightInPixel = 0;
278 pCtx->bFreezeOutput = false;279 pCtx->bFreezeOutput = true;
279 pCtx->bHaveGotMemory = false;280 pCtx->bHaveGotMemory = false;
280 WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine");281 WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine");
281}282}
@@ -777,4 +778,62 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 495 unmodified lines
777 WelsBlockFuncInit (&pCtx->sBlockFunc, pCtx->uiCpuFlag);778 WelsBlockFuncInit (&pCtx->sBlockFunc, pCtx->uiCpuFlag);
778}779}
779 780
781//reset decoder number related statistics info
782void 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
793void 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
801void 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
831void 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
780} // namespace WelsDec839} // 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