History

re-structure SWelsDecoderContext and others and prepare for the support of multi-threading support.

xiaotiansf committed 7 years ago

Commit 2f5ecec1 parent 9ed97c729 files · +2285 −1568Browse files

Showing the changes to codec/decoder/plus/src/welsDecoderExt.cpp (1 of 29 files). Show all

Unified · Split

codec/decoder/plus/src/welsDecoderExt.cpp+50−38
@@ -257,6 +257,10 @@ int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) { · 256 unmodified lines
257257 VERSION_NUMBER, (int32_t)pParam->bParseOnly);
258258
259259 //reset decoder context
260+ memset (&m_sDecoderStatistics, 0, sizeof (SDecoderStatistics));
261+ memset (&m_sLastDecPicInfo, 0, sizeof (SWelsLastDecPicInfo));
262+ memset (&m_sVlcTable, 0, sizeof (SVlcTable));
263+ WelsDecoderLastDecPicInfoDefaults (m_sLastDecPicInfo);
260264 if (m_pDecContext) //free
261265 UninitDecoder();
262266 m_pDecContext = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext");
@@ -267,7 +271,11 @@ int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) { · 4 unmodified lines
267271 WELS_VERIFY_RETURN_PROC_IF (cmMallocMemeError, (NULL == m_pDecContext->pMemAlign), UninitDecoder())
268272
269273 //fill in default value into context
274+ m_pDecContext->pLastDecPicInfo = &m_sLastDecPicInfo;
275+ m_pDecContext->pDecoderStatistics = &m_sDecoderStatistics;
276+ m_pDecContext->pVlcTable = &m_sVlcTable;
270277 WelsDecoderDefaults (m_pDecContext, &m_pWelsTrace->m_sLogCtx);
278+ WelsDecoderSpsPpsDefaults (m_pDecContext->sSpsPpsCtx);
271279
272280 //check param and update decoder context
273281 m_pDecContext->pParam = (SDecodingParam*)m_pDecContext->pMemAlign->WelsMallocz (sizeof (SDecodingParam),
@@ -364,7 +372,7 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { · 90 unmodified lines
364372 return cmInitParaError;
365373 } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) {
366374 if (pOption) {
367− m_pDecContext->sDecoderStatistics.iStatisticsLogInterval = (* ((unsigned int*)pOption));
375+ m_pDecContext->pDecoderStatistics->iStatisticsLogInterval = (* ((unsigned int*)pOption));
368376 return cmResultSuccess;
369377 }
370378 } else if (eOptID == DECODER_OPTION_GET_SAR_INFO) {
@@ -432,19 +440,19 @@ long CWelsDecoder::GetOption (DECODER_OPTION eOptID, void* pOption) { · 61 unmodified lines
432440 } else if (DECODER_OPTION_GET_STATISTICS == eOptID) { // get decoder statistics info for real time debugging
433441 SDecoderStatistics* pDecoderStatistics = (static_cast<SDecoderStatistics*> (pOption));
434442
435− memcpy (pDecoderStatistics, &m_pDecContext->sDecoderStatistics, sizeof (SDecoderStatistics));
443+ memcpy (pDecoderStatistics, m_pDecContext->pDecoderStatistics, sizeof (SDecoderStatistics));
436444
437− if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount != 0) { //not original status
445+ if (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount != 0) { //not original status
438446 pDecoderStatistics->fAverageFrameSpeedInMs = (float) (m_pDecContext->dDecTime) /
439− (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount);
447+ (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount);
440448 pDecoderStatistics->fActualAverageFrameSpeedInMs = (float) (m_pDecContext->dDecTime) /
441− (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount + m_pDecContext->sDecoderStatistics.uiFreezingIDRNum +
442− m_pDecContext->sDecoderStatistics.uiFreezingNonIDRNum);
449+ (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount + m_pDecContext->pDecoderStatistics->uiFreezingIDRNum +
450+ m_pDecContext->pDecoderStatistics->uiFreezingNonIDRNum);
443451 }
444452 return cmResultSuccess;
445453 } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) {
446454 if (pOption) {
447− iVal = m_pDecContext->sDecoderStatistics.iStatisticsLogInterval;
455+ iVal = m_pDecContext->pDecoderStatistics->iStatisticsLogInterval;
448456 * ((unsigned int*)pOption) = iVal;
449457 return cmResultSuccess;
450458 }
@@ -626,30 +634,30 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 175 unmodified lines
626634 //TODO after dec status updated
627635 m_pDecContext->iErrorCode |= dsDataErrorConcealed;
628636
629− m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
630− if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t
631− ResetDecStatNums (&m_pDecContext->sDecoderStatistics);
632− m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
637+ m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++;
638+ if (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount == 0) { //exceed max value of uint32_t
639+ ResetDecStatNums (m_pDecContext->pDecoderStatistics);
640+ m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++;
633641 }
634642 int32_t iMbConcealedNum = m_pDecContext->iMbEcedNum + m_pDecContext->iMbEcedPropNum;
635− m_pDecContext->sDecoderStatistics.uiAvgEcRatio = m_pDecContext->iMbNum == 0 ?
636− (m_pDecContext->sDecoderStatistics.uiAvgEcRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) : ((
637− m_pDecContext->sDecoderStatistics.uiAvgEcRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) + ((
643+ m_pDecContext->pDecoderStatistics->uiAvgEcRatio = m_pDecContext->iMbNum == 0 ?
644+ (m_pDecContext->pDecoderStatistics->uiAvgEcRatio * m_pDecContext->pDecoderStatistics->uiEcFrameNum) : ((
645+ m_pDecContext->pDecoderStatistics->uiAvgEcRatio * m_pDecContext->pDecoderStatistics->uiEcFrameNum) + ((
638646 iMbConcealedNum * 100) / m_pDecContext->iMbNum));
639− m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio = m_pDecContext->iMbNum == 0 ?
640− (m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) : ((
641− m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio * m_pDecContext->sDecoderStatistics.uiEcFrameNum) + ((
647+ m_pDecContext->pDecoderStatistics->uiAvgEcPropRatio = m_pDecContext->iMbNum == 0 ?
648+ (m_pDecContext->pDecoderStatistics->uiAvgEcPropRatio * m_pDecContext->pDecoderStatistics->uiEcFrameNum) : ((
649+ m_pDecContext->pDecoderStatistics->uiAvgEcPropRatio * m_pDecContext->pDecoderStatistics->uiEcFrameNum) + ((
642650 m_pDecContext->iMbEcedPropNum * 100) / m_pDecContext->iMbNum));
643− m_pDecContext->sDecoderStatistics.uiEcFrameNum += (iMbConcealedNum == 0 ? 0 : 1);
644− m_pDecContext->sDecoderStatistics.uiAvgEcRatio = m_pDecContext->sDecoderStatistics.uiEcFrameNum == 0 ? 0 :
645− m_pDecContext->sDecoderStatistics.uiAvgEcRatio / m_pDecContext->sDecoderStatistics.uiEcFrameNum;
646− m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio = m_pDecContext->sDecoderStatistics.uiEcFrameNum == 0 ? 0 :
647− m_pDecContext->sDecoderStatistics.uiAvgEcPropRatio / m_pDecContext->sDecoderStatistics.uiEcFrameNum;
651+ m_pDecContext->pDecoderStatistics->uiEcFrameNum += (iMbConcealedNum == 0 ? 0 : 1);
652+ m_pDecContext->pDecoderStatistics->uiAvgEcRatio = m_pDecContext->pDecoderStatistics->uiEcFrameNum == 0 ? 0 :
653+ m_pDecContext->pDecoderStatistics->uiAvgEcRatio / m_pDecContext->pDecoderStatistics->uiEcFrameNum;
654+ m_pDecContext->pDecoderStatistics->uiAvgEcPropRatio = m_pDecContext->pDecoderStatistics->uiEcFrameNum == 0 ? 0 :
655+ m_pDecContext->pDecoderStatistics->uiAvgEcPropRatio / m_pDecContext->pDecoderStatistics->uiEcFrameNum;
648656 }
649657 iEnd = WelsTime();
650658 m_pDecContext->dDecTime += (iEnd - iStart) / 1e3;
651659
652− OutputStatisticsLog (m_pDecContext->sDecoderStatistics);
660+ OutputStatisticsLog (*m_pDecContext->pDecoderStatistics);
653661
654662 #ifdef _PICTURE_REORDERING_
655663 ReorderPicturesInDisplay (ppDst, pDstInfo);
@@ -661,13 +669,13 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 5 unmodified lines
661669
662670 if (pDstInfo->iBufferStatus == 1) {
663671
664− m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
665− if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t
666− ResetDecStatNums (&m_pDecContext->sDecoderStatistics);
667− m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
672+ m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++;
673+ if (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount == 0) { //exceed max value of uint32_t
674+ ResetDecStatNums (m_pDecContext->pDecoderStatistics);
675+ m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++;
668676 }
669677
670− OutputStatisticsLog (m_pDecContext->sDecoderStatistics);
678+ OutputStatisticsLog (*m_pDecContext->pDecoderStatistics);
671679 }
672680 iEnd = WelsTime();
673681 m_pDecContext->dDecTime += (iEnd - iStart) / 1e3;
@@ -761,19 +769,22 @@ void CWelsDecoder::OutputStatisticsLog (SDecoderStatistics& sDecoderStatistics) · 87 unmodified lines
761769
762770 DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SBufferInfo* pDstInfo) {
763771 DECODING_STATE iRet = dsErrorFree;
764− if (pDstInfo->iBufferStatus == 1 && m_pDecContext->pSps->uiProfileIdc != 66
765− && m_pDecContext->pSps->uiProfileIdc != 83) {
772+ if (pDstInfo->iBufferStatus == 0) {
773+ return iRet;
774+ }
775+ ++m_pDecContext->uiDecodingTimeStamp;
776+ if (m_pDecContext->pSps->uiProfileIdc != 66 && m_pDecContext->pSps->uiProfileIdc != 83) {
766777 /*if (m_pDecContext->pSliceHeader->iPicOrderCntLsb == 0) {
767778 m_LastWrittenPOC = 0;
768779 return dsErrorFree;
769780 }
770− if (m_iNumOfPicts == 0 && m_pDecContext->pPreviousDecodedPictureInDpb->bNewSeqBegin
781+ if (m_iNumOfPicts == 0 && m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb->bNewSeqBegin
771782 && m_pDecContext->eSliceType != I_SLICE) {
772783 m_LastWrittenPOC = m_pDecContext->pSliceHeader->iPicOrderCntLsb;
773784 return dsErrorFree;
774785 }*/
775− if (m_iNumOfPicts && m_pDecContext->pPreviousDecodedPictureInDpb
776− && m_pDecContext->pPreviousDecodedPictureInDpb->bNewSeqBegin) {
786+ if (m_iNumOfPicts && m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb
787+ && m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb->bNewSeqBegin) {
777788 m_iLastGOPRemainPicts = m_iNumOfPicts;
778789 for (int32_t i = 0; i <= m_iLargestBufferedPicIndex; ++i) {
779790 if (m_sPictInfoList[i].iPOC > sIMinInt32) {
@@ -807,7 +818,8 @@ DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (unsigned char** ppDst, SB · 27 unmodified lines
807818 m_sPictInfoList[i].pData[1] = ppDst[1];
808819 m_sPictInfoList[i].pData[2] = ppDst[2];
809820 m_sPictInfoList[i].iPOC = m_pDecContext->pSliceHeader->iPicOrderCntLsb;
810− m_sPictInfoList[i].iPicBuffIdx = m_pDecContext->pPicBuff->iCurrentIdx;
821+ m_sPictInfoList[i].uiDecodingTimeStamp = m_pDecContext->uiDecodingTimeStamp;
822+ m_sPictInfoList[i].iPicBuffIdx = m_pDecContext->pLastDecPicInfo->pPreviousDecodedPictureInDpb->iPicBuffIdx;
811823 m_pDecContext->pPicBuff->ppPic[m_sPictInfoList[i].iPicBuffIdx]->bAvailableFlag = false;
812824 m_sPictInfoList[i].bLastGOP = false;
813825 pDstInfo->iBufferStatus = 0;
@@ -955,10 +967,10 @@ DECODING_STATE CWelsDecoder::DecodeParser (const unsigned char* kpSrc, · 141 unmodified lines
955967 memcpy (pDstInfo, m_pDecContext->pParserBsInfo, sizeof (SParserBsInfo));
956968
957969 if (m_pDecContext->iErrorCode == ERR_NONE) { //update statistics: decoding frame count
958− m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
959− if (m_pDecContext->sDecoderStatistics.uiDecodedFrameCount == 0) { //exceed max value of uint32_t
960− ResetDecStatNums (&m_pDecContext->sDecoderStatistics);
961− m_pDecContext->sDecoderStatistics.uiDecodedFrameCount++;
970+ m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++;
971+ if (m_pDecContext->pDecoderStatistics->uiDecodedFrameCount == 0) { //exceed max value of uint32_t
972+ ResetDecStatNums (m_pDecContext->pDecoderStatistics);
973+ m_pDecContext->pDecoderStatistics->uiDecodedFrameCount++;
962974 }
963975 }
964976 }

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