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