History

Fix a few test cases in UT for thread decoding.

xiaotiansf committed 7 years ago

Commit ffba9641 parent e7f5f6a2 files · +27 −21Browse files

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

Unified · Split

codec/decoder/core/src/decoder_core.cpp+22−18
@@ -2495,6 +2495,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 2494 unmodified lines
24952495 pLastThreadCtx->iPicBuffIdx);
24962496 }
24972497 }
2498+ int32_t iThreadCount = GetThreadCount (pCtx);
24982499 int32_t iPpsId = 0;
24992500 int32_t iRet = ERR_NONE;
25002501
@@ -2542,7 +2543,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 41 unmodified lines
25422543 }
25432544 }
25442545 bool isNewFrame = true;
2545− if (GetThreadCount (pCtx) > 1) {
2546+ if (iThreadCount > 1) {
25462547 isNewFrame = pCtx->pDec == NULL;
25472548 }
25482549 if (pCtx->pDec == NULL) {
@@ -2578,7 +2579,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 29 unmodified lines
25782579 if (pThreadCtx != NULL) {
25792580 pCtx->pDec->bIsUngroupedMultiSlice = false;
25802581 pThreadCtx->pDec = pCtx->pDec;
2581− if (GetThreadCount (pCtx) > 1) ++pCtx->pDec->iRefCount;
2582+ if (iThreadCount > 1) ++pCtx->pDec->iRefCount;
25822583 uint32_t uiMbHeight = (pCtx->pDec->iHeightInPixel + 15) >> 4;
25832584 for (uint32_t i = 0; i < uiMbHeight; ++i) {
25842585 RESET_EVENT (&pCtx->pDec->pReadyEvent[i]);
@@ -2729,7 +2730,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 144 unmodified lines
27292730 if (pSh->eSliceType == B_SLICE && !pSh->iDirectSpatialMvPredFlag)
27302731 ComputeColocatedTemporalScaling (pCtx);
27312732
2732− if (GetThreadCount (pCtx) > 1) {
2733+ if (iThreadCount > 1) {
27332734 memset (&pCtx->lastReadyHeightOffset[0][0], -1, LIST_A * MAX_REF_PIC_COUNT * sizeof (int16_t));
27342735 SET_EVENT (&pThreadCtx->sSliceDecodeStart);
27352736 iRet = WelsDecodeAndConstructSlice (pCtx);
@@ -2751,14 +2752,14 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 15 unmodified lines
27512752 }
27522753 }
27532754
2754− if (GetThreadCount (pCtx) <= 1 && bReconstructSlice) {
2755+ if (iThreadCount <= 1 && bReconstructSlice) {
27552756 if ((iRet = WelsDecodeConstructSlice (pCtx, pNalCur)) != ERR_NONE) {
27562757 pCtx->pDec->bIsComplete = false; // reconstruction error, directly set the flag false
27572758 return iRet;
27582759 }
27592760 }
27602761 if (bAllRefComplete && pCtx->eSliceType != I_SLICE) {
2761− if (GetThreadCount (pCtx) <= 1) {
2762+ if (iThreadCount <= 1) {
27622763 if (pCtx->sRefPic.uiRefCount[LIST_0] > 0) {
27632764 bAllRefComplete &= CheckRefPicturesComplete (pCtx);
27642765 } else {
@@ -2815,18 +2816,22 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 50 unmodified lines
28152816 }
28162817 }
28172818
2818− if (GetThreadCount (pCtx) > 1 && pCtx->uiDecodingTimeStamp > 1 && pCtx->pLastDecPicInfo->uiDecodingTimeStamp > 0) {
2819− while (pCtx->uiDecodingTimeStamp > pCtx->pLastDecPicInfo->uiDecodingTimeStamp + 1) {
2820− WelsSleep (1);
2819+ if (iThreadCount >= 1) {
2820+ int32_t id = pThreadCtx->sThreadInfo.uiThrNum;
2821+ for (int32_t i = 0; i < iThreadCount; ++i) {
2822+ if (i != id) {
2823+ if (pThreadCtx[i - id].sSliceDecodeStart.isSignaled) {
2824+ while (pThreadCtx[i - id].pCtx->uiDecodingTimeStamp < pCtx->uiDecodingTimeStamp) {
2825+ WelsSleep (1);
2826+ }
2827+ }
2828+ }
28212829 }
2822− }
2823−
2824− if (GetThreadCount (pCtx) >= 1) {
28252830 pCtx->pLastDecPicInfo->uiDecodingTimeStamp = pCtx->uiDecodingTimeStamp;
28262831 }
28272832 iRet = DecodeFrameConstruction (pCtx, ppDst, pDstInfo);
28282833 if (iRet) {
2829− if (GetThreadCount (pCtx) > 1) {
2834+ if (iThreadCount > 1) {
28302835 SET_EVENT (&pThreadCtx->sSliceDecodeFinsh);
28312836 }
28322837 return iRet;
@@ -2834,7 +2839,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 1 unmodified line
28342839
28352840 pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = pCtx->pDec; //store latest decoded picture for EC
28362841 pCtx->bUsedAsRef = pCtx->uiNalRefIdc > 0;
2837− if (GetThreadCount (pCtx) <= 1) {
2842+ if (iThreadCount <= 1) {
28382843 if (pCtx->bUsedAsRef) {
28392844 for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
28402845 uint32_t i = 0;
@@ -2857,7 +2862,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 16 unmodified lines
28572862 pCtx->pDec->iLinesize,
28582863 pCtx->sExpandPicFunc.pfExpandLumaPicture, pCtx->sExpandPicFunc.pfExpandChromaPicture);
28592864 }
2860− } else if (GetThreadCount (pCtx) > 1) {
2865+ } else if (iThreadCount > 1) {
28612866 SET_EVENT (&pThreadCtx->sImageReady);
28622867 }
28632868 pCtx->pDec = NULL; //after frame decoding, always set to NULL
@@ -2868,10 +2873,9 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 4 unmodified lines
28682873 pCtx->pLastDecPicInfo->iPrevFrameNum = pSh->iFrameNum;
28692874 if (pCtx->pLastDecPicInfo->bLastHasMmco5)
28702875 pCtx->pLastDecPicInfo->iPrevFrameNum = 0;
2871− if (GetThreadCount (pCtx) > 1) {
2872− int32_t threadCount = pThreadCtx->sThreadInfo.uiThrMaxNum;
2876+ if (iThreadCount > 1) {
28732877 int32_t id = pThreadCtx->sThreadInfo.uiThrNum;
2874− for (int32_t i = 0; i < threadCount; ++i) {
2878+ for (int32_t i = 0; i < iThreadCount; ++i) {
28752879 if (pThreadCtx[i - id].pCtx != NULL) {
28762880 unsigned long long uiTimeStamp = pThreadCtx[i - id].pCtx->uiTimeStamp;
28772881 if (uiTimeStamp > 0 && pThreadCtx[i - id].pCtx->sSpsPpsCtx.iSeqId > pCtx->sSpsPpsCtx.iSeqId) {
@@ -2886,7 +2890,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 8 unmodified lines
28862890 }
28872891 }
28882892 }
2889− if (GetThreadCount (pCtx) > 1) {
2893+ if (iThreadCount > 1) {
28902894 SET_EVENT (&pThreadCtx->sSliceDecodeFinsh);
28912895 }
28922896 return ERR_NONE;

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