History

re-structure SWelsDecoderContext and others and prepare for the support of multi-threading support.

xiaotiansf committed 7 years ago

Commit 2f5ecec1 parent 9ed97c729 files · +2285 −1568Browse files

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

Unified · Split

codec/decoder/core/src/decoder.cpp+53−22
@@ -192,7 +192,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 191 unmodified lines
192192
193193 int32_t iPrevPicIdx = -1;
194194 for (iPrevPicIdx = 0; iPrevPicIdx < kiOldSize; ++iPrevPicIdx) {
195− if (pCtx->pPreviousDecodedPictureInDpb == pPicOldBuf->ppPic[iPrevPicIdx]) {
195+ if (pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb == pPicOldBuf->ppPic[iPrevPicIdx]) {
196196 break;
197197 }
198198 }
@@ -308,7 +308,7 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 109 unmodified lines
308308 pCtx->bFreezeOutput = true;
309309
310310 pCtx->iFrameNum = -1;
311− pCtx->iPrevFrameNum = -1;
311+ pCtx->pLastDecPicInfo->iPrevFrameNum = -1;
312312 pCtx->iErrorCode = ERR_NONE;
313313
314314 pCtx->pDec = NULL;
@@ -321,31 +321,62 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 6 unmodified lines
321321
322322 pCtx->pPicBuff = NULL;
323323
324− pCtx->bAvcBasedFlag = true;
325− pCtx->pPreviousDecodedPictureInDpb = NULL;
326− pCtx->sDecoderStatistics.iAvgLumaQp = -1;
327− pCtx->sDecoderStatistics.iStatisticsLogInterval = 1000;
324+ pCtx->sSpsPpsCtx.bAvcBasedFlag = true;
325+ pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = NULL;
326+ pCtx->pDecoderStatistics->iAvgLumaQp = -1;
327+ pCtx->pDecoderStatistics->iStatisticsLogInterval = 1000;
328328 pCtx->bUseScalingList = false;
329− pCtx->iSpsErrorIgnored = 0;
330− pCtx->iSubSpsErrorIgnored = 0;
331− pCtx->iPpsErrorIgnored = 0;
332− pCtx->iPPSInvalidNum = 0;
333− pCtx->iPPSLastInvalidId = -1;
334− pCtx->iSPSInvalidNum = 0;
335− pCtx->iSPSLastInvalidId = -1;
336− pCtx->iSubSPSInvalidNum = 0;
337− pCtx->iSubSPSLastInvalidId = -1;
329+ pCtx->sSpsPpsCtx.iSpsErrorIgnored = 0;
330+ pCtx->sSpsPpsCtx.iSubSpsErrorIgnored = 0;
331+ pCtx->sSpsPpsCtx.iPpsErrorIgnored = 0;
332+ pCtx->sSpsPpsCtx.iPPSInvalidNum = 0;
333+ pCtx->sSpsPpsCtx.iPPSLastInvalidId = -1;
334+ pCtx->sSpsPpsCtx.iSPSInvalidNum = 0;
335+ pCtx->sSpsPpsCtx.iSPSLastInvalidId = -1;
336+ pCtx->sSpsPpsCtx.iSubSPSInvalidNum = 0;
337+ pCtx->sSpsPpsCtx.iSubSPSLastInvalidId = -1;
338338 pCtx->iFeedbackNalRefIdc = -1; //initialize
339− pCtx->iPrevPicOrderCntMsb = 0;
340− pCtx->iPrevPicOrderCntLsb = 0;
339+ pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb = 0;
340+ pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb = 0;
341341
342342 }
343343
344+/*
345+* fill data fields in SPS and PPS default for decoder context
346+*/
347+void WelsDecoderSpsPpsDefaults (SWelsDecoderSpsPpsCTX& sSpsPpsCtx) {
348+ sSpsPpsCtx.bSpsExistAheadFlag = false;
349+ sSpsPpsCtx.bSubspsExistAheadFlag = false;
350+ sSpsPpsCtx.bPpsExistAheadFlag = false;
351+ sSpsPpsCtx.bAvcBasedFlag = true;
352+ sSpsPpsCtx.iSpsErrorIgnored = 0;
353+ sSpsPpsCtx.iSubSpsErrorIgnored = 0;
354+ sSpsPpsCtx.iPpsErrorIgnored = 0;
355+ sSpsPpsCtx.iPPSInvalidNum = 0;
356+ sSpsPpsCtx.iPPSLastInvalidId = -1;
357+ sSpsPpsCtx.iSPSInvalidNum = 0;
358+ sSpsPpsCtx.iSPSLastInvalidId = -1;
359+ sSpsPpsCtx.iSubSPSInvalidNum = 0;
360+ sSpsPpsCtx.iSubSPSLastInvalidId = -1;
361+ sSpsPpsCtx.iSeqId = -1;
362+}
363+
364+/*
365+* fill last decoded picture info
366+*/
367+void WelsDecoderLastDecPicInfoDefaults (SWelsLastDecPicInfo& sLastDecPicInfo) {
368+ sLastDecPicInfo.iPrevPicOrderCntMsb = 0;
369+ sLastDecPicInfo.iPrevPicOrderCntLsb = 0;
370+ sLastDecPicInfo.pPreviousDecodedPictureInDpb = NULL;
371+ sLastDecPicInfo.iPrevFrameNum = -1;
372+ sLastDecPicInfo.bLastHasMmco5 = false;
373+}
374+
375+
344376 /*
345377 * destory_mb_blocks
346378 */
347379
348−
349380 /*
350381 * get size of reference picture list in target layer incoming, = (iNumRefFrames
351382 */
@@ -429,7 +460,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 77 unmodified lines
429460 }
430461
431462
432− pCtx->pPreviousDecodedPictureInDpb = NULL;
463+ pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = NULL;
433464
434465 // currently only active for LIST_0 due to have no B frames
435466 iErr = CreatePicBuff (pCtx, &pCtx->pPicBuff, iPicQueueSize, kiPicWidth, kiPicHeight);
@@ -500,7 +531,7 @@ int32_t WelsOpenDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 64 unmodified lines
500531 InitDecFuncs (pCtx, pCtx->uiCpuFlag);
501532
502533 // vlc tables
503− InitVlcTable (&pCtx->sVlcTable);
534+ InitVlcTable (pCtx->pVlcTable);
504535
505536 // static memory
506537 iRet = WelsInitStaticMemory (pCtx);
@@ -1088,7 +1119,7 @@ void UpdateDecStatFreezingInfo (const bool kbIdrFlag, SDecoderStatistics* pDecSt · 581 unmodified lines
10881119 void UpdateDecStatNoFreezingInfo (PWelsDecoderContext pCtx) {
10891120 PDqLayer pCurDq = pCtx->pCurDqLayer;
10901121 PPicture pPic = pCtx->pDec;
1091− SDecoderStatistics* pDecStat = &pCtx->sDecoderStatistics;
1122+ SDecoderStatistics* pDecStat = pCtx->pDecoderStatistics;
10921123
10931124 if (pDecStat->iAvgLumaQp == -1) //first correct frame received
10941125 pDecStat->iAvgLumaQp = 0;
@@ -1130,7 +1161,7 @@ void UpdateDecStatNoFreezingInfo (PWelsDecoderContext pCtx) { · 35 unmodified lines
11301161 //update decoder statistics information
11311162 void UpdateDecStat (PWelsDecoderContext pCtx, const bool kbOutput) {
11321163 if (pCtx->bFreezeOutput)
1133− UpdateDecStatFreezingInfo (pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag, &pCtx->sDecoderStatistics);
1164+ UpdateDecStatFreezingInfo (pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag, pCtx->pDecoderStatistics);
11341165 else if (kbOutput)
11351166 UpdateDecStatNoFreezingInfo (pCtx);
11361167 }

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