History

Threaded decoding enhancement:

1. Distinguish non-threaded decoding with m_iThreadCount = 0 from one-thread decoding with m_iThreadCount=1. 2. Removed the use of bAvailable of PPicture and replaced by the use of iRefCount to more preciously represent the picture's being-use counts in both threaded and non-threaded mode.

xiaotiansf committed 7 years ago

Commit e7f5f6a1 parent 033c6a014 files · +125 −104Browse files

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

Unified · Split

codec/decoder/plus/src/welsDecoderExt.cpp+53−32
@@ -105,7 +105,9 @@ static DECODING_STATE ConstructAccessUnit (CWelsDecoder* pWelsDecoder, PWelsDec · 104 unmodified lines
105 RESET_EVENT (&pLastThreadCtx->sSliceDecodeStart);105 RESET_EVENT (&pLastThreadCtx->sSliceDecodeStart);
106 }106 }
107 pThrCtx->pDec = NULL;107 pThrCtx->pDec = NULL;
108 RESET_EVENT (&pThrCtx->sSliceDecodeFinsh);108 if (GetThreadCount (pThrCtx->pCtx) > 1) {
109 RESET_EVENT (&pThrCtx->sSliceDecodeFinsh);
110 }
109 iRet |= pWelsDecoder->DecodeFrame2WithCtx (pThrCtx->pCtx, NULL, 0, pThrCtx->ppDst, &pThrCtx->sDstInfo);111 iRet |= pWelsDecoder->DecodeFrame2WithCtx (pThrCtx->pCtx, NULL, 0, pThrCtx->ppDst, &pThrCtx->sDstInfo);
110 112
111 //WelsMutexUnlock (&pWelsDecoder->m_csDecoder);113 //WelsMutexUnlock (&pWelsDecoder->m_csDecoder);
@@ -133,7 +135,8 @@ CWelsDecoder::CWelsDecoder (void) · 21 unmodified lines
133 m_uiDecodeTimeStamp (0),135 m_uiDecodeTimeStamp (0),
134 m_bIsBaseline (false),136 m_bIsBaseline (false),
135 m_iCpuCount (1),137 m_iCpuCount (1),
136 m_iThreadCount (1),138 m_iThreadCount (0),
139 m_iCtxCount (1),
137 m_pPicBuff (NULL),140 m_pPicBuff (NULL),
138 m_bParamSetsLostFlag (false),141 m_bParamSetsLostFlag (false),
139 m_bFreezeOutput (false),142 m_bFreezeOutput (false),
@@ -167,8 +170,9 @@ CWelsDecoder::CWelsDecoder (void) · 27 unmodified lines
167 if (m_iCpuCount > WELS_DEC_MAX_NUM_CPU) {170 if (m_iCpuCount > WELS_DEC_MAX_NUM_CPU) {
168 m_iCpuCount = WELS_DEC_MAX_NUM_CPU;171 m_iCpuCount = WELS_DEC_MAX_NUM_CPU;
169 }172 }
170 m_pDecThrCtx = new SWelsDecoderThreadCTX[m_iThreadCount];173
171 memset (m_pDecThrCtx, 0, sizeof (SWelsDecoderThreadCTX)*m_iThreadCount);174 m_pDecThrCtx = new SWelsDecoderThreadCTX[m_iCtxCount];
175 memset (m_pDecThrCtx, 0, sizeof (SWelsDecoderThreadCTX)*m_iCtxCount);
172 for (int32_t i = 0; i < WELS_DEC_MAX_NUM_CPU; ++i) {176 for (int32_t i = 0; i < WELS_DEC_MAX_NUM_CPU; ++i) {
173 m_pDecThrCtxActive[i] = NULL;177 m_pDecThrCtxActive[i] = NULL;
174 }178 }
@@ -277,7 +281,7 @@ long CWelsDecoder::Uninitialize() { · 102 unmodified lines
277}281}
278 282
279void CWelsDecoder::UninitDecoder (void) {283void CWelsDecoder::UninitDecoder (void) {
280 for (int32_t i = 0; i < m_iThreadCount; ++i) {284 for (int32_t i = 0; i < m_iCtxCount; ++i) {
281 if (m_pDecThrCtx[i].pCtx != NULL) {285 if (m_pDecThrCtx[i].pCtx != NULL) {
282 if (i > 0) {286 if (i > 0) {
283 WelsResetRefPicWithoutUnRef (m_pDecThrCtx[i].pCtx);287 WelsResetRefPicWithoutUnRef (m_pDecThrCtx[i].pCtx);
@@ -288,7 +292,7 @@ void CWelsDecoder::UninitDecoder (void) { · 4 unmodified lines
288}292}
289 293
290void CWelsDecoder::OpenDecoderThreads() {294void CWelsDecoder::OpenDecoderThreads() {
291 if (m_iThreadCount > 1) {295 if (m_iThreadCount >= 1) {
292 m_uiDecodeTimeStamp = 0;296 m_uiDecodeTimeStamp = 0;
293 CREATE_SEMAPHORE (&m_sIsBusy, m_iThreadCount, m_iThreadCount, NULL);297 CREATE_SEMAPHORE (&m_sIsBusy, m_iThreadCount, m_iThreadCount, NULL);
294 WelsMutexInit (&m_csDecoder);298 WelsMutexInit (&m_csDecoder);
@@ -318,7 +322,7 @@ void CWelsDecoder::OpenDecoderThreads() { · 23 unmodified lines
318 }322 }
319}323}
320void CWelsDecoder::CloseDecoderThreads() {324void CWelsDecoder::CloseDecoderThreads() {
321 if (m_iThreadCount > 1) {325 if (m_iThreadCount >= 1) {
322 for (int32_t i = 0; i < m_iThreadCount; i++) { //waiting the completion begun slices326 for (int32_t i = 0; i < m_iThreadCount; i++) { //waiting the completion begun slices
323 WAIT_SEMAPHORE (&m_pDecThrCtx[i].sThreadInfo.sIsIdle, WELS_DEC_THREAD_WAIT_INFINITE);327 WAIT_SEMAPHORE (&m_pDecThrCtx[i].sThreadInfo.sIsIdle, WELS_DEC_THREAD_WAIT_INFINITE);
324 m_pDecThrCtx[i].sThreadInfo.uiCommand = WELS_DEC_THREAD_COMMAND_ABORT;328 m_pDecThrCtx[i].sThreadInfo.uiCommand = WELS_DEC_THREAD_COMMAND_ABORT;
@@ -367,8 +371,8 @@ int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) { · 42 unmodified lines
367 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,371 WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
368 "CWelsDecoder::init_decoder(), openh264 codec version = %s, ParseOnly = %d",372 "CWelsDecoder::init_decoder(), openh264 codec version = %s, ParseOnly = %d",
369 VERSION_NUMBER, (int32_t)pParam->bParseOnly);373 VERSION_NUMBER, (int32_t)pParam->bParseOnly);
370 if (m_iThreadCount > 1 && pParam->bParseOnly) {374 if (m_iThreadCount >= 1 && pParam->bParseOnly) {
371 m_iThreadCount = 1;375 m_iThreadCount = 0;
372 }376 }
373 OpenDecoderThreads();377 OpenDecoderThreads();
374 //reset decoder context378 //reset decoder context
@@ -377,9 +381,9 @@ int32_t CWelsDecoder::InitDecoder (const SDecodingParam* pParam) { · 2 unmodified lines
377 memset (&m_sVlcTable, 0, sizeof (SVlcTable));381 memset (&m_sVlcTable, 0, sizeof (SVlcTable));
378 UninitDecoder();382 UninitDecoder();
379 WelsDecoderLastDecPicInfoDefaults (m_sLastDecPicInfo);383 WelsDecoderLastDecPicInfoDefaults (m_sLastDecPicInfo);
380 for (int32_t i = 0; i < m_iThreadCount; ++i) {384 for (int32_t i = 0; i < m_iCtxCount; ++i) {
381 InitDecoderCtx (m_pDecThrCtx[i].pCtx, pParam);385 InitDecoderCtx (m_pDecThrCtx[i].pCtx, pParam);
382 if (m_iThreadCount > 1) {386 if (m_iThreadCount >= 1) {
383 m_pDecThrCtx[i].pCtx->pThreadCtx = &m_pDecThrCtx[i];387 m_pDecThrCtx[i].pCtx->pThreadCtx = &m_pDecThrCtx[i];
384 }388 }
385 }389 }
@@ -429,7 +433,7 @@ int32_t CWelsDecoder::InitDecoderCtx (PWelsDecoderContext& pCtx, const SDecoding · 43 unmodified lines
429 433
430int32_t CWelsDecoder::ResetDecoder (PWelsDecoderContext& pCtx) {434int32_t CWelsDecoder::ResetDecoder (PWelsDecoderContext& pCtx) {
431 // TBC: need to be modified when context and trace point are null435 // TBC: need to be modified when context and trace point are null
432 if (m_iThreadCount > 1) {436 if (m_iThreadCount >= 1) {
433 ThreadResetDecoder (pCtx);437 ThreadResetDecoder (pCtx);
434 } else {438 } else {
435 if (pCtx != NULL && m_pWelsTrace != NULL) {439 if (pCtx != NULL && m_pWelsTrace != NULL) {
@@ -472,9 +476,8 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { · 36 unmodified lines
472 if (eOptID == DECODER_OPTION_NUM_OF_THREADS) {476 if (eOptID == DECODER_OPTION_NUM_OF_THREADS) {
473 if (pOption != NULL) {477 if (pOption != NULL) {
474 int32_t threadCount = * ((int32_t*)pOption);478 int32_t threadCount = * ((int32_t*)pOption);
475 if (threadCount <= 0) {479 if (threadCount < 0) threadCount = 0;
476 threadCount = 1;480 if (threadCount > m_iCpuCount) {
477 } else if (threadCount > m_iCpuCount) {
478 threadCount = m_iCpuCount;481 threadCount = m_iCpuCount;
479 }482 }
480 if (threadCount > 3) {483 if (threadCount > 3) {
@@ -484,14 +487,15 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { · 3 unmodified lines
484 m_iThreadCount = threadCount;487 m_iThreadCount = threadCount;
485 if (m_pDecThrCtx != NULL) {488 if (m_pDecThrCtx != NULL) {
486 delete [] m_pDecThrCtx;489 delete [] m_pDecThrCtx;
487 m_pDecThrCtx = new SWelsDecoderThreadCTX[m_iThreadCount];490 m_iCtxCount = m_iThreadCount == 0 ? 1 : m_iThreadCount;
488 memset (m_pDecThrCtx, 0, sizeof (SWelsDecoderThreadCTX)*m_iThreadCount);491 m_pDecThrCtx = new SWelsDecoderThreadCTX[m_iCtxCount];
492 memset (m_pDecThrCtx, 0, sizeof (SWelsDecoderThreadCTX)*m_iCtxCount);
489 }493 }
490 }494 }
491 }495 }
492 return cmResultSuccess;496 return cmResultSuccess;
493 }497 }
494 for (int32_t i = 0; i < m_iThreadCount; ++i) {498 for (int32_t i = 0; i < m_iCtxCount; ++i) {
495 PWelsDecoderContext pDecContext = m_pDecThrCtx[i].pCtx;499 PWelsDecoderContext pDecContext = m_pDecThrCtx[i].pCtx;
496 if (pDecContext == NULL && eOptID != DECODER_OPTION_TRACE_LEVEL &&500 if (pDecContext == NULL && eOptID != DECODER_OPTION_TRACE_LEVEL &&
497 eOptID != DECODER_OPTION_TRACE_CALLBACK && eOptID != DECODER_OPTION_TRACE_CALLBACK_CONTEXT)501 eOptID != DECODER_OPTION_TRACE_CALLBACK && eOptID != DECODER_OPTION_TRACE_CALLBACK_CONTEXT)
@@ -502,6 +506,8 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { · 4 unmodified lines
502 506
503 iVal = * ((int*)pOption); // boolean value for whether enabled End Of Stream flag507 iVal = * ((int*)pOption); // boolean value for whether enabled End Of Stream flag
504 508
509 if (pDecContext == NULL) return dsInitialOptExpected;
510
505 pDecContext->bEndOfStreamFlag = iVal ? true : false;511 pDecContext->bEndOfStreamFlag = iVal ? true : false;
506 512
507 return cmResultSuccess;513 return cmResultSuccess;
@@ -509,6 +515,8 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { · 1 unmodified line
509 if (pOption == NULL)515 if (pOption == NULL)
510 return cmInitParaError;516 return cmInitParaError;
511 517
518 if (pDecContext == NULL) return dsInitialOptExpected;
519
512 iVal = * ((int*)pOption); // int value for error concealment idc520 iVal = * ((int*)pOption); // int value for error concealment idc
513 iVal = WELS_CLIP3 (iVal, (int32_t)ERROR_CON_DISABLE, (int32_t)ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE);521 iVal = WELS_CLIP3 (iVal, (int32_t)ERROR_CON_DISABLE, (int32_t)ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE);
514 if ((pDecContext->pParam->bParseOnly) && (iVal != (int32_t)ERROR_CON_DISABLE)) {522 if ((pDecContext->pParam->bParseOnly) && (iVal != (int32_t)ERROR_CON_DISABLE)) {
@@ -550,6 +558,7 @@ long CWelsDecoder::SetOption (DECODER_OPTION eOptID, void* pOption) { · 35 unmodified lines
550 return cmInitParaError;558 return cmInitParaError;
551 } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) {559 } else if (eOptID == DECODER_OPTION_STATISTICS_LOG_INTERVAL) {
552 if (pOption) {560 if (pOption) {
561 if (pDecContext == NULL) return dsInitialOptExpected;
553 pDecContext->pDecoderStatistics->iStatisticsLogInterval = (* ((unsigned int*)pOption));562 pDecContext->pDecoderStatistics->iStatisticsLogInterval = (* ((unsigned int*)pOption));
554 return cmResultSuccess;563 return cmResultSuccess;
555 }564 }
@@ -681,7 +690,7 @@ DECODING_STATE CWelsDecoder::DecodeFrameNoDelay (const unsigned char* kpSrc, · 125 unmodified lines
681 unsigned char** ppDst,690 unsigned char** ppDst,
682 SBufferInfo* pDstInfo) {691 SBufferInfo* pDstInfo) {
683 int iRet = dsErrorFree;692 int iRet = dsErrorFree;
684 if (m_iThreadCount > 1) {693 if (m_iThreadCount >= 1) {
685 iRet = ThreadDecodeFrameInternal (kpSrc, kiSrcLen, ppDst, pDstInfo);694 iRet = ThreadDecodeFrameInternal (kpSrc, kiSrcLen, ppDst, pDstInfo);
686 if (m_sReoderingStatus.iNumOfPicts) {695 if (m_sReoderingStatus.iNumOfPicts) {
687 WAIT_EVENT (&m_sBufferingEvent, WELS_DEC_THREAD_WAIT_INFINITE);696 WAIT_EVENT (&m_sBufferingEvent, WELS_DEC_THREAD_WAIT_INFINITE);
@@ -742,6 +751,9 @@ DECODING_STATE CWelsDecoder::DecodeFrame2WithCtx (PWelsDecoderContext pDecContex · 54 unmodified lines
742 }751 }
743#endif//OUTPUT_BIT_STREAM752#endif//OUTPUT_BIT_STREAM
744 pDecContext->bEndOfStreamFlag = false;753 pDecContext->bEndOfStreamFlag = false;
754 if (GetThreadCount (pDecContext) <= 0) {
755 pDecContext->uiDecodingTimeStamp = ++m_uiDecodeTimeStamp;
756 }
745 } else {757 } else {
746 //For application MODE, the error detection should be added for safe.758 //For application MODE, the error detection should be added for safe.
747 //But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL.759 //But for CONSOLE MODE, when decoding LAST AU, kiSrcLen==0 && kpSrc==NULL.
@@ -752,13 +764,13 @@ DECODING_STATE CWelsDecoder::DecodeFrame2WithCtx (PWelsDecoderContext pDecContex · 4 unmodified lines
752 int64_t iStart, iEnd;764 int64_t iStart, iEnd;
753 iStart = WelsTime();765 iStart = WelsTime();
754 766
755 if (pDecContext->pThreadCtx == NULL) {767 if (GetThreadCount (pDecContext) <= 1) {
756 ppDst[0] = ppDst[1] = ppDst[2] = NULL;768 ppDst[0] = ppDst[1] = ppDst[2] = NULL;
757 }769 }
758 pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding.770 pDecContext->iErrorCode = dsErrorFree; //initialize at the starting of AU decoding.
759 pDecContext->iFeedbackVclNalInAu = FEEDBACK_UNKNOWN_NAL; //initialize771 pDecContext->iFeedbackVclNalInAu = FEEDBACK_UNKNOWN_NAL; //initialize
760 unsigned long long uiInBsTimeStamp = pDstInfo->uiInBsTimeStamp;772 unsigned long long uiInBsTimeStamp = pDstInfo->uiInBsTimeStamp;
761 if (pDecContext->pThreadCtx == NULL) {773 if (GetThreadCount (pDecContext) <= 1) {
762 memset (pDstInfo, 0, sizeof (SBufferInfo));774 memset (pDstInfo, 0, sizeof (SBufferInfo));
763 }775 }
764 pDstInfo->uiInBsTimeStamp = uiInBsTimeStamp;776 pDstInfo->uiInBsTimeStamp = uiInBsTimeStamp;
@@ -856,7 +868,7 @@ DECODING_STATE CWelsDecoder::DecodeFrame2WithCtx (PWelsDecoderContext pDecContex · 91 unmodified lines
856 868
857 OutputStatisticsLog (*pDecContext->pDecoderStatistics);869 OutputStatisticsLog (*pDecContext->pDecoderStatistics);
858 870
859 if (pDecContext->pThreadCtx != NULL) {871 if (GetThreadCount (pDecContext) >= 1) {
860 WAIT_EVENT (&m_sReleaseBufferEvent, WELS_DEC_THREAD_WAIT_INFINITE);872 WAIT_EVENT (&m_sReleaseBufferEvent, WELS_DEC_THREAD_WAIT_INFINITE);
861 RESET_EVENT (&m_sBufferingEvent);873 RESET_EVENT (&m_sBufferingEvent);
862 BufferingReadyPicture (pDecContext, ppDst, pDstInfo);874 BufferingReadyPicture (pDecContext, ppDst, pDstInfo);
@@ -882,7 +894,7 @@ DECODING_STATE CWelsDecoder::DecodeFrame2WithCtx (PWelsDecoderContext pDecContex · 19 unmodified lines
882 iEnd = WelsTime();894 iEnd = WelsTime();
883 pDecContext->dDecTime += (iEnd - iStart) / 1e3;895 pDecContext->dDecTime += (iEnd - iStart) / 1e3;
884 896
885 if (pDecContext->pThreadCtx != NULL) {897 if (GetThreadCount (pDecContext) >= 1) {
886 WAIT_EVENT (&m_sReleaseBufferEvent, WELS_DEC_THREAD_WAIT_INFINITE);898 WAIT_EVENT (&m_sReleaseBufferEvent, WELS_DEC_THREAD_WAIT_INFINITE);
887 RESET_EVENT (&m_sBufferingEvent);899 RESET_EVENT (&m_sBufferingEvent);
888 BufferingReadyPicture (pDecContext, ppDst, pDstInfo);900 BufferingReadyPicture (pDecContext, ppDst, pDstInfo);
@@ -904,7 +916,7 @@ DECODING_STATE CWelsDecoder::DecodeFrame2 (const unsigned char* kpSrc, · 15 unmodified lines
904DECODING_STATE CWelsDecoder::FlushFrame (unsigned char** ppDst,916DECODING_STATE CWelsDecoder::FlushFrame (unsigned char** ppDst,
905 SBufferInfo* pDstInfo) {917 SBufferInfo* pDstInfo) {
906 bool bEndOfStreamFlag = true;918 bool bEndOfStreamFlag = true;
907 for (int32_t j = 0; j < m_iThreadCount; ++j) {919 for (int32_t j = 0; j < m_iCtxCount; ++j) {
908 if (!m_pDecThrCtx[j].pCtx->bEndOfStreamFlag) {920 if (!m_pDecThrCtx[j].pCtx->bEndOfStreamFlag) {
909 bEndOfStreamFlag = false;921 bEndOfStreamFlag = false;
910 }922 }
@@ -934,9 +946,10 @@ DECODING_STATE CWelsDecoder::FlushFrame (unsigned char** ppDst, · 23 unmodified lines
934 ppDst[1] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[1];946 ppDst[1] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[1];
935 ppDst[2] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[2];947 ppDst[2] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[2];
936 m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC = IMinInt32;948 m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC = IMinInt32;
937 PPicBuff pPicBuff = m_iThreadCount == 1 ? m_pDecThrCtx[0].pCtx->pPicBuff : m_pPicBuff;949 PPicBuff pPicBuff = m_iThreadCount <= 1 ? m_pDecThrCtx[0].pCtx->pPicBuff : m_pPicBuff;
938 if (m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx < pPicBuff->iCapacity) {950 if (m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx < pPicBuff->iCapacity) {
939 pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx]->bAvailableFlag = true;951 PPicture pPic = pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx];
952 --pPic->iRefCount;
940 }953 }
941 m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP = false;954 m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP = false;
942 m_sReoderingStatus.iMinPOC = IMinInt32;955 m_sReoderingStatus.iMinPOC = IMinInt32;
@@ -1001,6 +1014,7 @@ void CWelsDecoder::BufferingReadyPicture (PWelsDecoderContext pCtx, unsigned cha · 58 unmodified lines
1001 if (m_sReoderingStatus.iNumOfPicts && pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb1014 if (m_sReoderingStatus.iNumOfPicts && pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb
1002 && pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->bNewSeqBegin) {1015 && pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->bNewSeqBegin) {
1003 m_sReoderingStatus.iLastGOPRemainPicts = m_sReoderingStatus.iNumOfPicts;1016 m_sReoderingStatus.iLastGOPRemainPicts = m_sReoderingStatus.iNumOfPicts;
1017
1004 for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) {1018 for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) {
1005 if (m_sPictInfoList[i].iPOC > IMinInt32) {1019 if (m_sPictInfoList[i].iPOC > IMinInt32) {
1006 m_sPictInfoList[i].bLastGOP = true;1020 m_sPictInfoList[i].bLastGOP = true;
@@ -1036,7 +1050,7 @@ void CWelsDecoder::BufferingReadyPicture (PWelsDecoderContext pCtx, unsigned cha · 29 unmodified lines
1036 m_sPictInfoList[i].iPOC = pCtx->pSliceHeader->iPicOrderCntLsb;1050 m_sPictInfoList[i].iPOC = pCtx->pSliceHeader->iPicOrderCntLsb;
1037 m_sPictInfoList[i].uiDecodingTimeStamp = pCtx->uiDecodingTimeStamp;1051 m_sPictInfoList[i].uiDecodingTimeStamp = pCtx->uiDecodingTimeStamp;
1038 m_sPictInfoList[i].iPicBuffIdx = pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->iPicBuffIdx;1052 m_sPictInfoList[i].iPicBuffIdx = pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->iPicBuffIdx;
1039 pCtx->pPicBuff->ppPic[m_sPictInfoList[i].iPicBuffIdx]->bAvailableFlag = false;1053 if (GetThreadCount (pCtx) <= 1) ++pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb->iRefCount;
1040 m_sPictInfoList[i].bLastGOP = false;1054 m_sPictInfoList[i].bLastGOP = false;
1041 pDstInfo->iBufferStatus = 0;1055 pDstInfo->iBufferStatus = 0;
1042 ++m_sReoderingStatus.iNumOfPicts;1056 ++m_sReoderingStatus.iNumOfPicts;
@@ -1051,6 +1065,9 @@ void CWelsDecoder::BufferingReadyPicture (PWelsDecoderContext pCtx, unsigned cha · 8 unmodified lines
1051void CWelsDecoder::ReleaseBufferedReadyPicture (PWelsDecoderContext pCtx, unsigned char** ppDst,1065void CWelsDecoder::ReleaseBufferedReadyPicture (PWelsDecoderContext pCtx, unsigned char** ppDst,
1052 SBufferInfo* pDstInfo) {1066 SBufferInfo* pDstInfo) {
1053 PPicBuff pPicBuff = pCtx ? pCtx->pPicBuff : m_pPicBuff;1067 PPicBuff pPicBuff = pCtx ? pCtx->pPicBuff : m_pPicBuff;
1068 if (pCtx == NULL && m_iThreadCount <= 1) {
1069 pCtx = m_pDecThrCtx[0].pCtx;
1070 }
1054 if (!m_bIsBaseline && m_sReoderingStatus.iLastGOPRemainPicts > 0) {1071 if (!m_bIsBaseline && m_sReoderingStatus.iLastGOPRemainPicts > 0) {
1055 m_sReoderingStatus.iMinPOC = IMinInt32;1072 m_sReoderingStatus.iMinPOC = IMinInt32;
1056 for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) {1073 for (int32_t i = 0; i <= m_sReoderingStatus.iLargestBufferedPicIndex; ++i) {
@@ -1075,7 +1092,8 @@ void CWelsDecoder::ReleaseBufferedReadyPicture (PWelsDecoderContext pCtx, unsign · 18 unmodified lines
1075 ppDst[1] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[1];1092 ppDst[1] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[1];
1076 ppDst[2] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[2];1093 ppDst[2] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[2];
1077 m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC = IMinInt32;1094 m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC = IMinInt32;
1078 pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx]->bAvailableFlag = true;1095 PPicture pPic = pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx];
1096 --pPic->iRefCount;
1079 m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP = false;1097 m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP = false;
1080 m_sReoderingStatus.iMinPOC = IMinInt32;1098 m_sReoderingStatus.iMinPOC = IMinInt32;
1081 --m_sReoderingStatus.iNumOfPicts;1099 --m_sReoderingStatus.iNumOfPicts;
@@ -1107,7 +1125,8 @@ void CWelsDecoder::ReleaseBufferedReadyPicture (PWelsDecoderContext pCtx, unsign · 25 unmodified lines
1107 ppDst[1] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[1];1125 ppDst[1] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[1];
1108 ppDst[2] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[2];1126 ppDst[2] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[2];
1109 m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC = IMinInt32;1127 m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC = IMinInt32;
1110 pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx]->bAvailableFlag = true;1128 PPicture pPic = pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx];
1129 --pPic->iRefCount;
1111 --m_sReoderingStatus.iNumOfPicts;1130 --m_sReoderingStatus.iNumOfPicts;
1112 }1131 }
1113 return;1132 return;
@@ -1147,7 +1166,8 @@ void CWelsDecoder::ReleaseBufferedReadyPicture (PWelsDecoderContext pCtx, unsign · 33 unmodified lines
1147 ppDst[1] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[1];1166 ppDst[1] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[1];
1148 ppDst[2] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[2];1167 ppDst[2] = m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].pData[2];
1149 m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC = IMinInt32;1168 m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPOC = IMinInt32;
1150 pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx]->bAvailableFlag = true;1169 PPicture pPic = pPicBuff->ppPic[m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].iPicBuffIdx];
1170 --pPic->iRefCount;
1151 m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP = false;1171 m_sPictInfoList[m_sReoderingStatus.iPictInfoIndex].bLastGOP = false;
1152 m_sReoderingStatus.iMinPOC = IMinInt32;1172 m_sReoderingStatus.iMinPOC = IMinInt32;
1153 --m_sReoderingStatus.iNumOfPicts;1173 --m_sReoderingStatus.iNumOfPicts;
@@ -1159,7 +1179,6 @@ DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay (PWelsDecoderContext pDecC · 5 unmodified lines
1159 SBufferInfo* pDstInfo) {1179 SBufferInfo* pDstInfo) {
1160 DECODING_STATE iRet = dsErrorFree;1180 DECODING_STATE iRet = dsErrorFree;
1161 if (pDstInfo->iBufferStatus == 1) {1181 if (pDstInfo->iBufferStatus == 1) {
1162 ++pDecContext->uiDecodingTimeStamp;
1163 m_bIsBaseline = pDecContext->pSps->uiProfileIdc == 66 || pDecContext->pSps->uiProfileIdc == 83;1182 m_bIsBaseline = pDecContext->pSps->uiProfileIdc == 66 || pDecContext->pSps->uiProfileIdc == 83;
1164 if (!m_bIsBaseline) {1183 if (!m_bIsBaseline) {
1165 BufferingReadyPicture (pDecContext, ppDst, pDstInfo);1184 BufferingReadyPicture (pDecContext, ppDst, pDstInfo);
@@ -1364,7 +1383,9 @@ int CWelsDecoder::ThreadDecodeFrameInternal (const unsigned char* kpSrc, const i · 198 unmodified lines
1364 memcpy (&m_pDecThrCtx[signal].sDstInfo, pDstInfo, sizeof (SBufferInfo));1383 memcpy (&m_pDecThrCtx[signal].sDstInfo, pDstInfo, sizeof (SBufferInfo));
1365 1384
1366 ParseAccessUnit (m_pDecThrCtx[signal]);1385 ParseAccessUnit (m_pDecThrCtx[signal]);
1367 m_pLastDecThrCtx = &m_pDecThrCtx[signal];1386 if (m_iThreadCount > 1) {
1387 m_pLastDecThrCtx = &m_pDecThrCtx[signal];
1388 }
1368 m_pDecThrCtx[signal].sThreadInfo.uiCommand = WELS_DEC_THREAD_COMMAND_RUN;1389 m_pDecThrCtx[signal].sThreadInfo.uiCommand = WELS_DEC_THREAD_COMMAND_RUN;
1369 RELEASE_SEMAPHORE (&m_pDecThrCtx[signal].sThreadInfo.sIsActivated);1390 RELEASE_SEMAPHORE (&m_pDecThrCtx[signal].sThreadInfo.sIsActivated);
1370 1391

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