History

Add thread decoding support for multi-slice frame. Note: In each call to DecodeFrameNoDelay, iSrcLen must be the byte-size of one coded video frame.

xiaotianshi2 committed 6 years ago

Commit b1ce6991 parent e1b8cd23 files · +29 −8Browse files

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

Unified · Split

codec/decoder/core/src/decoder_core.cpp+19−5
@@ -2338,7 +2338,7 @@ int32_t InitConstructAccessUnit (PWelsDecoderContext pCtx, SBufferInfo* pDstInfo · 2337 unmodified lines
2338 */2338 */
2339int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {2339int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferInfo* pDstInfo) {
2340 int32_t iErr = ERR_NONE;2340 int32_t iErr = ERR_NONE;
2341 if (pCtx->pThreadCtx == NULL) {2341 if (GetThreadCount (pCtx) <= 1) {
2342 iErr = InitConstructAccessUnit (pCtx, pDstInfo);2342 iErr = InitConstructAccessUnit (pCtx, pDstInfo);
2343 if (ERR_NONE != iErr) {2343 if (ERR_NONE != iErr) {
2344 return iErr;2344 return iErr;
@@ -2550,7 +2550,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 205 unmodified lines
2550 isNewFrame = pCtx->pDec == NULL;2550 isNewFrame = pCtx->pDec == NULL;
2551 }2551 }
2552 if (pCtx->pDec == NULL) {2552 if (pCtx->pDec == NULL) {
2553 if (pLastThreadCtx != NULL) {2553 if (pLastThreadCtx != NULL && iIdx == 0) {
2554 pLastThreadCtx->pDec->bUsedAsRef = pLastThreadCtx->pCtx->uiNalRefIdc > 0;2554 pLastThreadCtx->pDec->bUsedAsRef = pLastThreadCtx->pCtx->uiNalRefIdc > 0;
2555 if (pLastThreadCtx->pDec->bUsedAsRef) {2555 if (pLastThreadCtx->pDec->bUsedAsRef) {
2556 for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {2556 for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
@@ -2686,7 +2686,19 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 129 unmodified lines
2686 if (pCtx->bNewSeqBegin) {2686 if (pCtx->bNewSeqBegin) {
2687 iPrevFrameNum = 0;2687 iPrevFrameNum = 0;
2688 } else if (pLastThreadCtx->pDec != NULL) {2688 } else if (pLastThreadCtx->pDec != NULL) {
2689 iPrevFrameNum = pLastThreadCtx->pDec->iFrameNum;2689 if (pLastThreadCtx->pDec->uiTimeStamp == pCtx->uiTimeStamp - 1) {
2690 iPrevFrameNum = pLastThreadCtx->pDec->iFrameNum;
2691 if (iPrevFrameNum == -1) iPrevFrameNum = pLastThreadCtx->pCtx->iFrameNum;
2692 } else {
2693 int32_t id = pThreadCtx->sThreadInfo.uiThrNum;
2694 for (int32_t i = 0; i < iThreadCount; ++i) {
2695 if (pThreadCtx[i - id].pCtx->uiTimeStamp == pCtx->uiTimeStamp - 1) {
2696 if (pThreadCtx[i - id].pDec != NULL) iPrevFrameNum = pThreadCtx[i - id].pDec->iFrameNum;
2697 if (iPrevFrameNum == -1) iPrevFrameNum = pThreadCtx[i - id].pCtx->iFrameNum;
2698 break;
2699 }
2700 }
2701 }
2690 } else {2702 } else {
2691 iPrevFrameNum = pCtx->bNewSeqBegin ? 0 : pLastThreadCtx->pCtx->iFrameNum;2703 iPrevFrameNum = pCtx->bNewSeqBegin ? 0 : pLastThreadCtx->pCtx->iFrameNum;
2692 }2704 }
@@ -2734,8 +2746,10 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 41 unmodified lines
2734 ComputeColocatedTemporalScaling (pCtx);2746 ComputeColocatedTemporalScaling (pCtx);
2735 2747
2736 if (iThreadCount > 1) {2748 if (iThreadCount > 1) {
2737 memset (&pCtx->lastReadyHeightOffset[0][0], -1, LIST_A * MAX_REF_PIC_COUNT * sizeof (int16_t));2749 if (iIdx == 0) {
2738 SET_EVENT (&pThreadCtx->sSliceDecodeStart);2750 memset (&pCtx->lastReadyHeightOffset[0][0], -1, LIST_A * MAX_REF_PIC_COUNT * sizeof (int16_t));
2751 SET_EVENT (&pThreadCtx->sSliceDecodeStart);
2752 }
2739 iRet = WelsDecodeAndConstructSlice (pCtx);2753 iRet = WelsDecodeAndConstructSlice (pCtx);
2740 } else {2754 } else {
2741 iRet = WelsDecodeSlice (pCtx, bFreshSliceAvailable, pNalCur);2755 iRet = WelsDecodeSlice (pCtx, bFreshSliceAvailable, pNalCur);

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