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
393393 sLastDecPicInfo.pPreviousDecodedPictureInDpb = NULL;
394394 sLastDecPicInfo.iPrevFrameNum = -1;
395395 sLastDecPicInfo.bLastHasMmco5 = false;
396+ sLastDecPicInfo.uiDecodingTimeStamp = 0;
396397 }
397398
398399 /*!
@@ -437,6 +438,9 @@ static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) { · 38 unmodified lines
437438 iNumRefFrames = MAX_REF_PIC_COUNT + 2;
438439 } else {
439440 iNumRefFrames = pCtx->pSps->iNumRefFrames + 2;
441+ if (pCtx->pThreadCtx != NULL) {
442+ iNumRefFrames = MAX_REF_PIC_COUNT + 1;
443+ }
440444 }
441445
442446 #ifdef LONG_TERM_REF
@@ -478,7 +482,9 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 35 unmodified lines
478482 && kiPicHeight == pCtx->iImgHeightInPixel) && (!bNeedChangePicQueue)) // have same scaled buffer
479483
480484 // sync update pRefList
481− WelsResetRefPic (pCtx); // added to sync update ref list due to pictures are free
485+ if (pCtx->pThreadCtx == NULL) {
486+ WelsResetRefPic (pCtx); // added to sync update ref list due to pictures are free
487+ }
482488
483489 if (pCtx->bHaveGotMemory && (kiPicWidth == pCtx->iImgWidthInPixel && kiPicHeight == pCtx->iImgHeightInPixel)
484490 && pCtx->pPicBuff != NULL && pCtx->pPicBuff->iCapacity != iPicQueueSize) {
@@ -554,6 +560,17 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { · 69 unmodified lines
554560 if (NULL != pPicBuff && NULL != *pPicBuff) {
555561 DestroyPicBuff (pCtx, pPicBuff, pMa);
556562 }
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+ }
557574
558575 if (pCtx->pTempDec) {
559576 FreePicture (pCtx->pTempDec, pCtx->pMemAlign);
@@ -796,7 +813,11 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 236 unmodified lines
796813 }
797814 CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo);
798815 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+ }
800821 }
801822 }
802823 DecodeFinishUpdate (pCtx);
@@ -852,9 +873,15 @@ int32_t WelsDecodeBs (PWelsDecoderContext pCtx, const uint8_t* kpBsBuf, const in · 49 unmodified lines
852873 if (IS_PARAM_SETS_NALS (pCtx->sCurNalHead.eNalUnitType)) {
853874 iRet = ParseNonVclNal (pCtx, pNalPayload, iDstIdx - iConsumedBytes, pSrcNal - 3, iSrcIdx + 3);
854875 }
855− CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo);
876+ if (pCtx->pThreadCtx == NULL) {
877+ CheckAndFinishLastPic (pCtx, ppDst, pDstBufInfo);
878+ }
856879 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+ }
858885 }
859886 }
860887 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