History

Mainly update DecodeCurrentAccessUnit and associated functions to do threaded parallel frame decodings.

Add additional function PrefetchLastPicForThread and variables for better control of threaded decoding in the case of multi-slice with one slice group contains one slice.

xiaotiansf committed 7 years ago

Commit b0f95c41 parent 8b881449 files · +279 −89Browse files

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

Unified · Split

codec/decoder/core/src/decoder.cpp+31−4
@@ -393,6 +393,7 @@ void WelsDecoderLastDecPicInfoDefaults (SWelsLastDecPicInfo& sLastDecPicInfo) { · 392 unmodified lines
393 sLastDecPicInfo.pPreviousDecodedPictureInDpb = NULL;393 sLastDecPicInfo.pPreviousDecodedPictureInDpb = NULL;
394 sLastDecPicInfo.iPrevFrameNum = -1;394 sLastDecPicInfo.iPrevFrameNum = -1;
395 sLastDecPicInfo.bLastHasMmco5 = false;395 sLastDecPicInfo.bLastHasMmco5 = false;
396 sLastDecPicInfo.uiDecodingTimeStamp = 0;
396}397}
397 398
398/*!399/*!
@@ -437,6 +438,9 @@ static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) { · 38 unmodified lines
437 iNumRefFrames = MAX_REF_PIC_COUNT + 2;438 iNumRefFrames = MAX_REF_PIC_COUNT + 2;
438 } else {439 } else {
439 iNumRefFrames = pCtx->pSps->iNumRefFrames + 2;440 iNumRefFrames = pCtx->pSps->iNumRefFrames + 2;
441 if (pCtx->pThreadCtx != NULL) {
442 iNumRefFrames = MAX_REF_PIC_COUNT + 1;
443 }
440 }444 }
441 445
442#ifdef LONG_TERM_REF446#ifdef LONG_TERM_REF
@@ -478,7 +482,9 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 35 unmodified lines
478 && kiPicHeight == pCtx->iImgHeightInPixel) && (!bNeedChangePicQueue)) // have same scaled buffer482 && kiPicHeight == pCtx->iImgHeightInPixel) && (!bNeedChangePicQueue)) // have same scaled buffer
479 483
480 // sync update pRefList484 // sync update pRefList
481 WelsResetRefPic (pCtx); // added to sync update ref list due to pictures are free485 if (pCtx->pThreadCtx == NULL) {
486 WelsResetRefPic (pCtx); // added to sync update ref list due to pictures are free
487 }
482 488
483 if (pCtx->bHaveGotMemory && (kiPicWidth == pCtx->iImgWidthInPixel && kiPicHeight == pCtx->iImgHeightInPixel)489 if (pCtx->bHaveGotMemory && (kiPicWidth == pCtx->iImgWidthInPixel && kiPicHeight == pCtx->iImgHeightInPixel)
484 && pCtx->pPicBuff != NULL && pCtx->pPicBuff->iCapacity != iPicQueueSize) {490 && pCtx->pPicBuff != NULL && pCtx->pPicBuff->iCapacity != iPicQueueSize) {
@@ -554,6 +560,17 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { · 69 unmodified lines
554 if (NULL != pPicBuff && NULL != *pPicBuff) {560 if (NULL != pPicBuff && NULL != *pPicBuff) {
555 DestroyPicBuff (pCtx, pPicBuff, pMa);561 DestroyPicBuff (pCtx, pPicBuff, pMa);
556 }562 }
563 if (pCtx->pThreadCtx != NULL) {
564 //prevent from double destruction of PPicBuff
565 PWelsDecoderThreadCTX pThreadCtx = (PWelsDecoderThreadCTX) (pCtx->pThreadCtx);
566 int32_t threadCount = pThreadCtx->sThreadInfo.uiThrMaxNum;
567 int32_t id = pThreadCtx->sThreadInfo.uiThrNum;
568 for (int32_t i = 0; i < threadCount; ++i) {
569 if (pThreadCtx[i - id].pCtx != NULL) {
570 pThreadCtx[i - id].pCtx->pPicBuff = NULL;
571 }
572 }
573 }
557 574
558 if (pCtx->pTempDec) {575 if (pCtx->pTempDec) {
559 FreePicture (pCtx->pTempDec, pCtx->pMemAlign);576 FreePicture (pCtx->pTempDec, pCtx->pMemAlign);
@@ -796,7 +813,11 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 236 unmodified lines
796 }813 }
797 CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo);814 CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo);
798 if (pCtx->bAuReadyFlag && pCtx->pAccessUnitList->uiAvailUnitsNum != 0) {815 if (pCtx->bAuReadyFlag && pCtx->pAccessUnitList->uiAvailUnitsNum != 0) {
799 ConstructAccessUnit (pCtx, ppDst, pDstBufInfo);816 if (pCtx->pThreadCtx == NULL) {
817 ConstructAccessUnit (pCtx, ppDst, pDstBufInfo);
818 } else {
819 pCtx->pAccessUnitList->uiAvailUnitsNum = 1;
820 }
800 }821 }
801 }822 }
802 DecodeFinishUpdate (pCtx);823 DecodeFinishUpdate (pCtx);
@@ -852,9 +873,15 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 49 unmodified lines
852 if (IS_PARAM_SETS_NALS (pCtx->sCurNalHead.eNalUnitType)) {873 if (IS_PARAM_SETS_NALS (pCtx->sCurNalHead.eNalUnitType)) {
853 iRet = ParseNonVclNal (pCtx, pNalPayload, iDstIdx - iConsumedBytes, pSrcNal - 3, iSrcIdx + 3);874 iRet = ParseNonVclNal (pCtx, pNalPayload, iDstIdx - iConsumedBytes, pSrcNal - 3, iSrcIdx + 3);
854 }875 }
855 CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo);876 if (pCtx->pThreadCtx == NULL) {
877 CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo);
878 }
856 if (pCtx->bAuReadyFlag && pCtx->pAccessUnitList->uiAvailUnitsNum != 0) {879 if (pCtx->bAuReadyFlag && pCtx->pAccessUnitList->uiAvailUnitsNum != 0) {
857 ConstructAccessUnit (pCtx, ppDst, pDstBufInfo);880 if (pCtx->pThreadCtx == NULL) {
881 ConstructAccessUnit (pCtx, ppDst, pDstBufInfo);
882 } else {
883 pCtx->pAccessUnitList->uiAvailUnitsNum = 1;
884 }
858 }885 }
859 }886 }
860 DecodeFinishUpdate (pCtx);887 DecodeFinishUpdate (pCtx);

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