Skip to content

Commit c0e5ea2

Browse files
authored
Fix regression in PR#3707 for multi-thread decoding (#3734)
* Fix regression in PR#3707 for multi-thread decoding The variable iSeqNum introduced in PR#3707 should be common within the decoder, however each decoding thread in the same decoder had its own one. Due to this issue, multi-thread decoding failed. This patch fixes that. * Fix segfault caused in WelsDecodeInitAccessUnitStart() ... if CWelsDecoder::InitDecoderCtx() is not called.
1 parent c59550a commit c0e5ea2

File tree

4 files changed

+13
-21
lines changed

4 files changed

+13
-21
lines changed

codec/decoder/core/inc/decoder_context.h

+1
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ typedef struct TagWelsDecoderContext {
432432
#endif
433433
bool bNewSeqBegin;
434434
bool bNextNewSeqBegin;
435+
int32_t *pStreamSeqNum;
435436
int32_t iSeqNum;
436437

437438
//for Parse only

codec/decoder/core/src/decoder_core.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -2261,9 +2261,15 @@ int32_t WelsDecodeInitAccessUnitStart (PWelsDecoderContext pCtx, SBufferInfo* pD
22612261
pCtx->bAuReadyFlag = false;
22622262
pCtx->pLastDecPicInfo->bLastHasMmco5 = false;
22632263
bool bTmpNewSeqBegin = CheckNewSeqBeginAndUpdateActiveLayerSps (pCtx);
2264-
if (bTmpNewSeqBegin)
2265-
pCtx->iSeqNum++;
2264+
if (bTmpNewSeqBegin) {
2265+
if (pCtx->pStreamSeqNum)
2266+
(*pCtx->pStreamSeqNum)++;
2267+
else
2268+
pCtx->iSeqNum++;
2269+
}
22662270
pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || bTmpNewSeqBegin;
2271+
if (pCtx->pStreamSeqNum)
2272+
pCtx->iSeqNum = *pCtx->pStreamSeqNum;
22672273
iErr = WelsDecodeAccessUnitStart (pCtx);
22682274
GetVclNalTemporalId (pCtx);
22692275

codec/decoder/plus/inc/welsDecoderExt.h

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class CWelsDecoder : public ISVCDecoder {
138138
SVlcTable m_sVlcTable;
139139
SWelsLastDecPicInfo m_sLastDecPicInfo;
140140
SDecoderStatistics m_sDecoderStatistics;// For real time debugging
141+
int32_t m_iStreamSeqNum;
141142

142143
private:
143144
int32_t InitDecoder (const SDecodingParam* pParam);

codec/decoder/plus/src/welsDecoderExt.cpp

+3-19
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ CWelsDecoder::CWelsDecoder (void)
143143
m_DecCtxActiveCount (0),
144144
m_pDecThrCtx (NULL),
145145
m_pLastDecThrCtx (NULL),
146-
m_iLastBufferedIdx (0) {
146+
m_iLastBufferedIdx (0),
147+
m_iStreamSeqNum (0) {
147148
#ifdef OUTPUT_BIT_STREAM
148149
char chFileName[1024] = { 0 }; //for .264
149150
int iBufUsed = 0;
@@ -417,6 +418,7 @@ int32_t CWelsDecoder::InitDecoderCtx (PWelsDecoderContext& pCtx, const SDecoding
417418
pCtx->pPictInfoList = m_sPictInfoList;
418419
pCtx->pPictReoderingStatus = &m_sReoderingStatus;
419420
pCtx->pCsDecoder = &m_csDecoder;
421+
pCtx->pStreamSeqNum = &m_iStreamSeqNum;
420422
WelsDecoderDefaults (pCtx, &m_pWelsTrace->m_sLogCtx);
421423
WelsDecoderSpsPpsDefaults (pCtx->sSpsPpsCtx);
422424
//check param and update decoder context
@@ -1137,24 +1139,6 @@ DECODING_STATE CWelsDecoder::ReorderPicturesInDisplay(PWelsDecoderContext pDecCo
11371139
m_bIsBaseline = pDecContext->pSps->uiProfileIdc == 66 || pDecContext->pSps->uiProfileIdc == 83;
11381140
if (!m_bIsBaseline) {
11391141
if (pDstInfo->iBufferStatus == 1) {
1140-
if (pDecContext->pSliceHeader->eSliceType == B_SLICE &&
1141-
((pDecContext->iSeqNum == m_sReoderingStatus.iLastWrittenSeqNum) ?
1142-
(pDecContext->pSliceHeader->iPicOrderCntLsb <= m_sReoderingStatus.iLastWrittenPOC + 2) :
1143-
(pDecContext->iSeqNum - m_sReoderingStatus.iLastWrittenSeqNum == 1 && pDecContext->pSliceHeader->iPicOrderCntLsb == 0))) {
1144-
m_sReoderingStatus.iLastWrittenPOC = pDecContext->pSliceHeader->iPicOrderCntLsb;
1145-
m_sReoderingStatus.iLastWrittenSeqNum = pDecContext->iSeqNum;
1146-
//issue #3478, use b-slice type to determine correct picture order as the first priority as POC order is not as reliable as based on b-slice
1147-
ppDst[0] = pDstInfo->pDst[0];
1148-
ppDst[1] = pDstInfo->pDst[1];
1149-
ppDst[2] = pDstInfo->pDst[2];
1150-
#if defined (_DEBUG)
1151-
#ifdef _MOTION_VECTOR_DUMP_
1152-
fprintf (stderr, "Output POC: #%d uiDecodingTimeStamp=%d\n", pDecContext->pSliceHeader->iPicOrderCntLsb,
1153-
pDecContext->uiDecodingTimeStamp);
1154-
#endif
1155-
#endif
1156-
return iRet;
1157-
}
11581142
BufferingReadyPicture(pDecContext, ppDst, pDstInfo);
11591143
if (!m_sReoderingStatus.bHasBSlice && m_sReoderingStatus.iNumOfPicts > 1) {
11601144
ReleaseBufferedReadyPictureNoReorder (pDecContext, ppDst, pDstInfo);

0 commit comments

Comments
 (0)