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
192 192
193 int32_t iPrevPicIdx = -1;193 int32_t iPrevPicIdx = -1;
194 for (iPrevPicIdx = 0; iPrevPicIdx < kiOldSize; ++iPrevPicIdx) {194 for (iPrevPicIdx = 0; iPrevPicIdx < kiOldSize; ++iPrevPicIdx) {
195 if (pCtx->pPreviousDecodedPictureInDpb == pPicOldBuf->ppPic[iPrevPicIdx]) {195 if (pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb == pPicOldBuf->ppPic[iPrevPicIdx]) {
196 break;196 break;
197 }197 }
198 }198 }
@@ -308,7 +308,7 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 109 unmodified lines
308 pCtx->bFreezeOutput = true;308 pCtx->bFreezeOutput = true;
309 309
310 pCtx->iFrameNum = -1;310 pCtx->iFrameNum = -1;
311 pCtx->iPrevFrameNum = -1;311 pCtx->pLastDecPicInfo->iPrevFrameNum = -1;
312 pCtx->iErrorCode = ERR_NONE;312 pCtx->iErrorCode = ERR_NONE;
313 313
314 pCtx->pDec = NULL;314 pCtx->pDec = NULL;
@@ -321,31 +321,62 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 6 unmodified lines
321 321
322 pCtx->pPicBuff = NULL;322 pCtx->pPicBuff = NULL;
323 323
324 pCtx->bAvcBasedFlag = true;324 pCtx->sSpsPpsCtx.bAvcBasedFlag = true;
325 pCtx->pPreviousDecodedPictureInDpb = NULL;325 pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = NULL;
326 pCtx->sDecoderStatistics.iAvgLumaQp = -1;326 pCtx->pDecoderStatistics->iAvgLumaQp = -1;
327 pCtx->sDecoderStatistics.iStatisticsLogInterval = 1000;327 pCtx->pDecoderStatistics->iStatisticsLogInterval = 1000;
328 pCtx->bUseScalingList = false;328 pCtx->bUseScalingList = false;
329 pCtx->iSpsErrorIgnored = 0;329 pCtx->sSpsPpsCtx.iSpsErrorIgnored = 0;
330 pCtx->iSubSpsErrorIgnored = 0;330 pCtx->sSpsPpsCtx.iSubSpsErrorIgnored = 0;
331 pCtx->iPpsErrorIgnored = 0;331 pCtx->sSpsPpsCtx.iPpsErrorIgnored = 0;
332 pCtx->iPPSInvalidNum = 0;332 pCtx->sSpsPpsCtx.iPPSInvalidNum = 0;
333 pCtx->iPPSLastInvalidId = -1;333 pCtx->sSpsPpsCtx.iPPSLastInvalidId = -1;
334 pCtx->iSPSInvalidNum = 0;334 pCtx->sSpsPpsCtx.iSPSInvalidNum = 0;
335 pCtx->iSPSLastInvalidId = -1;335 pCtx->sSpsPpsCtx.iSPSLastInvalidId = -1;
336 pCtx->iSubSPSInvalidNum = 0;336 pCtx->sSpsPpsCtx.iSubSPSInvalidNum = 0;
337 pCtx->iSubSPSLastInvalidId = -1;337 pCtx->sSpsPpsCtx.iSubSPSLastInvalidId = -1;
338 pCtx->iFeedbackNalRefIdc = -1; //initialize338 pCtx->iFeedbackNalRefIdc = -1; //initialize
339 pCtx->iPrevPicOrderCntMsb = 0;339 pCtx->pLastDecPicInfo->iPrevPicOrderCntMsb = 0;
340 pCtx->iPrevPicOrderCntLsb = 0;340 pCtx->pLastDecPicInfo->iPrevPicOrderCntLsb = 0;
341 341
342}342}
343 343
344/*
345* fill data fields in SPS and PPS default for decoder context
346*/
347void 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*/
367void 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
344/*376/*
345 * destory_mb_blocks377 * destory_mb_blocks
346 */378 */
347 379
348
349/*380/*
350 * get size of reference picture list in target layer incoming, = (iNumRefFrames381 * get size of reference picture list in target layer incoming, = (iNumRefFrames
351 */382 */
@@ -429,7 +460,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 77 unmodified lines
429 }460 }
430 461
431 462
432 pCtx->pPreviousDecodedPictureInDpb = NULL;463 pCtx->pLastDecPicInfo->pPreviousDecodedPictureInDpb = NULL;
433 464
434 // currently only active for LIST_0 due to have no B frames465 // currently only active for LIST_0 due to have no B frames
435 iErr = CreatePicBuff (pCtx, &pCtx->pPicBuff, iPicQueueSize, kiPicWidth, kiPicHeight);466 iErr = CreatePicBuff (pCtx, &pCtx->pPicBuff, iPicQueueSize, kiPicWidth, kiPicHeight);
@@ -500,7 +531,7 @@ int32_t WelsOpenDecoder (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 64 unmodified lines
500 InitDecFuncs (pCtx, pCtx->uiCpuFlag);531 InitDecFuncs (pCtx, pCtx->uiCpuFlag);
501 532
502 // vlc tables533 // vlc tables
503 InitVlcTable (&pCtx->sVlcTable);534 InitVlcTable (pCtx->pVlcTable);
504 535
505 // static memory536 // static memory
506 iRet = WelsInitStaticMemory (pCtx);537 iRet = WelsInitStaticMemory (pCtx);
@@ -1088,7 +1119,7 @@ void UpdateDecStatFreezingInfo (const bool kbIdrFlag, SDecoderStatistics* pDecSt · 581 unmodified lines
1088void UpdateDecStatNoFreezingInfo (PWelsDecoderContext pCtx) {1119void UpdateDecStatNoFreezingInfo (PWelsDecoderContext pCtx) {
1089 PDqLayer pCurDq = pCtx->pCurDqLayer;1120 PDqLayer pCurDq = pCtx->pCurDqLayer;
1090 PPicture pPic = pCtx->pDec;1121 PPicture pPic = pCtx->pDec;
1091 SDecoderStatistics* pDecStat = &pCtx->sDecoderStatistics;1122 SDecoderStatistics* pDecStat = pCtx->pDecoderStatistics;
1092 1123
1093 if (pDecStat->iAvgLumaQp == -1) //first correct frame received1124 if (pDecStat->iAvgLumaQp == -1) //first correct frame received
1094 pDecStat->iAvgLumaQp = 0;1125 pDecStat->iAvgLumaQp = 0;
@@ -1130,7 +1161,7 @@ void UpdateDecStatNoFreezingInfo (PWelsDecoderContext pCtx) { · 35 unmodified lines
1130//update decoder statistics information1161//update decoder statistics information
1131void UpdateDecStat (PWelsDecoderContext pCtx, const bool kbOutput) {1162void UpdateDecStat (PWelsDecoderContext pCtx, const bool kbOutput) {
1132 if (pCtx->bFreezeOutput)1163 if (pCtx->bFreezeOutput)
1133 UpdateDecStatFreezingInfo (pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag, &pCtx->sDecoderStatistics);1164 UpdateDecStatFreezingInfo (pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.bIdrFlag, pCtx->pDecoderStatistics);
1134 else if (kbOutput)1165 else if (kbOutput)
1135 UpdateDecStatNoFreezingInfo (pCtx);1166 UpdateDecStatNoFreezingInfo (pCtx);
1136}1167}

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