History

B-frame decoding support for Main and High Profile with two test cases.

xiaotianshi2 committed 8 years ago

Commit 657d2171 parent e3e838355 files · +17936 −13825Browse files

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

Unified · Split

codec/decoder/core/src/decoder.cpp+29−23
@@ -302,12 +302,13 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 301 unmodified lines
302302
303303 pCtx->pDec = NULL;
304304
305+ pCtx->pTempDec = NULL;
306+
305307 WelsResetRefPic (pCtx);
306308
307309 pCtx->iActiveFmoNum = 0;
308310
309− pCtx->pPicBuff[LIST_0] = NULL;
310− pCtx->pPicBuff[LIST_1] = NULL;
311+ pCtx->pPicBuff = NULL;
311312
312313 pCtx->bAvcBasedFlag = true;
313314 pCtx->pPreviousDecodedPictureInDpb = NULL;
@@ -324,6 +325,8 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 10 unmodified lines
324325 pCtx->iSubSPSInvalidNum = 0;
325326 pCtx->iSubSPSLastInvalidId = -1;
326327 pCtx->iFeedbackNalRefIdc = -1; //initialize
328+ pCtx->iPrevPicOrderCntMsb = 0;
329+ pCtx->iPrevPicOrderCntLsb = 0;
327330
328331 }
329332
@@ -363,7 +366,6 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 33 unmodified lines
363366 const int32_t kiPicHeight = kiMbHeight << 4;
364367 int32_t iErr = ERR_NONE;
365368
366− int32_t iListIdx = 0; //, mb_blocks = 0;
367369 int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2)
368370 bReallocFlag = false;
369371 bool bNeedChangePicQueue = true;
@@ -375,8 +377,8 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 5 unmodified lines
375377 // get picture queue size currently
376378 iPicQueueSize = GetTargetRefListSize (pCtx); // adaptive size of picture queue, = (pSps->iNumRefFrames x 2)
377379 pCtx->iPicQueueNumber = iPicQueueSize;
378− if (pCtx->pPicBuff[LIST_0] != NULL
379− && pCtx->pPicBuff[LIST_0]->iCapacity ==
380+ if (pCtx->pPicBuff != NULL
381+ && pCtx->pPicBuff->iCapacity ==
380382 iPicQueueSize) // comparing current picture queue size requested and previous allocation picture queue
381383 bNeedChangePicQueue = false;
382384 // HD based pic buffer need consider memory size consumed when switch from 720p to other lower size
@@ -387,39 +389,39 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 4 unmodified lines
387389 WelsResetRefPic (pCtx); // added to sync update ref list due to pictures are free
388390
389391 if (pCtx->bHaveGotMemory && (kiPicWidth == pCtx->iImgWidthInPixel && kiPicHeight == pCtx->iImgHeightInPixel)
390− && pCtx->pPicBuff[LIST_0] != NULL && pCtx->pPicBuff[LIST_0]->iCapacity != iPicQueueSize) {
392+ && pCtx->pPicBuff != NULL && pCtx->pPicBuff->iCapacity != iPicQueueSize) {
391393 // currently only active for LIST_0 due to have no B frames
394+ // Actually just need one memory allocation for the PicBuff. While it needs two pointer list (LIST_0 and LIST_1).
392395 WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO,
393396 "WelsRequestMem(): memory re-alloc for no resolution change (size = %d * %d), ref list size change from %d to %d",
394− kiPicWidth, kiPicHeight, pCtx->pPicBuff[LIST_0]->iCapacity, iPicQueueSize);
395− if (pCtx->pPicBuff[LIST_0]->iCapacity < iPicQueueSize) {
396− iErr = IncreasePicBuff (pCtx, &pCtx->pPicBuff[LIST_0], pCtx->pPicBuff[LIST_0]->iCapacity, kiPicWidth, kiPicHeight,
397+ kiPicWidth, kiPicHeight, pCtx->pPicBuff->iCapacity, iPicQueueSize);
398+ if (pCtx->pPicBuff->iCapacity < iPicQueueSize) {
399+ iErr = IncreasePicBuff (pCtx, &pCtx->pPicBuff, pCtx->pPicBuff->iCapacity, kiPicWidth, kiPicHeight,
397400 iPicQueueSize);
398401 } else {
399− iErr = DecreasePicBuff (pCtx, &pCtx->pPicBuff[LIST_0], pCtx->pPicBuff[LIST_0]->iCapacity, kiPicWidth, kiPicHeight,
402+ iErr = DecreasePicBuff (pCtx, &pCtx->pPicBuff, pCtx->pPicBuff->iCapacity, kiPicWidth, kiPicHeight,
400403 iPicQueueSize);
401404 }
402405 } else {
403406 if (pCtx->bHaveGotMemory)
404407 WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO,
405408 "WelsRequestMem(): memory re-alloc for resolution change, size change from %d * %d to %d * %d, ref list size change from %d to %d",
406− pCtx->iImgWidthInPixel, pCtx->iImgHeightInPixel, kiPicWidth, kiPicHeight, pCtx->pPicBuff[LIST_0]->iCapacity,
409+ pCtx->iImgWidthInPixel, pCtx->iImgHeightInPixel, kiPicWidth, kiPicHeight, pCtx->pPicBuff->iCapacity,
407410 iPicQueueSize);
408411 else
409412 WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "WelsRequestMem(): memory alloc size = %d * %d, ref list size = %d",
410413 kiPicWidth, kiPicHeight, iPicQueueSize);
411414 // for Recycled_Pic_Queue
412− for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) {
413− PPicBuff* ppPic = &pCtx->pPicBuff[iListIdx];
414− if (NULL != ppPic && NULL != *ppPic) {
415− DestroyPicBuff (ppPic, pMa);
416− }
415+ PPicBuff* ppPic = &pCtx->pPicBuff;
416+ if (NULL != ppPic && NULL != *ppPic) {
417+ DestroyPicBuff (ppPic, pMa);
417418 }
418419
420+
419421 pCtx->pPreviousDecodedPictureInDpb = NULL;
420422
421423 // currently only active for LIST_0 due to have no B frames
422− iErr = CreatePicBuff (pCtx, &pCtx->pPicBuff[LIST_0], iPicQueueSize, kiPicWidth, kiPicHeight);
424+ iErr = CreatePicBuff (pCtx, &pCtx->pPicBuff, iPicQueueSize, kiPicWidth, kiPicHeight);
423425 }
424426
425427 if (iErr != ERR_NONE)
@@ -444,7 +446,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 18 unmodified lines
444446 * free memory dynamically allocated during decoder
445447 */
446448 void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) {
447− int32_t iListIdx = 0;
449+
448450 CMemoryAlign* pMa = pCtx->pMemAlign;
449451
450452 //free dq layer memory
@@ -455,11 +457,15 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { · 4 unmodified lines
455457
456458 //free ref-pic list & picture memory
457459 WelsResetRefPic (pCtx);
458− for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) {
459− PPicBuff* pPicBuff = &pCtx->pPicBuff[iListIdx];
460− if (NULL != pPicBuff && NULL != *pPicBuff) {
461− DestroyPicBuff (pPicBuff, pMa);
462− }
460+
461+ PPicBuff* pPicBuff = &pCtx->pPicBuff;
462+ if (NULL != pPicBuff && NULL != *pPicBuff) {
463+ DestroyPicBuff (pPicBuff, pMa);
464+ }
465+
466+ if (pCtx->pTempDec) {
467+ FreePicture (pCtx->pTempDec, pCtx->pMemAlign);
468+ pCtx->pTempDec = NULL;
463469 }
464470
465471 // added for safe memory

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