Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 55 files). Show all
Unified · Split
| @@ -302,12 +302,13 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 301 unmodified lines | |||
| 302 | 302 | ||
| 303 | pCtx->pDec = NULL; | 303 | pCtx->pDec = NULL; |
| 304 | 304 | ||
| 305 | pCtx->pTempDec = NULL; | ||
| 306 | |||
| 305 | WelsResetRefPic (pCtx); | 307 | WelsResetRefPic (pCtx); |
| 306 | 308 | ||
| 307 | pCtx->iActiveFmoNum = 0; | 309 | pCtx->iActiveFmoNum = 0; |
| 308 | 310 | ||
| 309 | pCtx->pPicBuff[LIST_0] = NULL; | 311 | pCtx->pPicBuff = NULL; |
| 310 | pCtx->pPicBuff[LIST_1] = NULL; | ||
| 311 | 312 | ||
| 312 | pCtx->bAvcBasedFlag = true; | 313 | pCtx->bAvcBasedFlag = true; |
| 313 | pCtx->pPreviousDecodedPictureInDpb = NULL; | 314 | pCtx->pPreviousDecodedPictureInDpb = NULL; |
| @@ -324,6 +325,8 @@ void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) { · 10 unmodified lines | |||
| 324 | pCtx->iSubSPSInvalidNum = 0; | 325 | pCtx->iSubSPSInvalidNum = 0; |
| 325 | pCtx->iSubSPSLastInvalidId = -1; | 326 | pCtx->iSubSPSLastInvalidId = -1; |
| 326 | pCtx->iFeedbackNalRefIdc = -1; //initialize | 327 | pCtx->iFeedbackNalRefIdc = -1; //initialize |
| 328 | pCtx->iPrevPicOrderCntMsb = 0; | ||
| 329 | pCtx->iPrevPicOrderCntLsb = 0; | ||
| 327 | 330 | ||
| 328 | } | 331 | } |
| 329 | 332 | ||
| @@ -363,7 +366,6 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 33 unmodified lines | |||
| 363 | const int32_t kiPicHeight = kiMbHeight << 4; | 366 | const int32_t kiPicHeight = kiMbHeight << 4; |
| 364 | int32_t iErr = ERR_NONE; | 367 | int32_t iErr = ERR_NONE; |
| 365 | 368 | ||
| 366 | int32_t iListIdx = 0; //, mb_blocks = 0; | ||
| 367 | int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) | 369 | int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) |
| 368 | bReallocFlag = false; | 370 | bReallocFlag = false; |
| 369 | bool bNeedChangePicQueue = true; | 371 | bool bNeedChangePicQueue = true; |
| @@ -375,8 +377,8 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 5 unmodified lines | |||
| 375 | // get picture queue size currently | 377 | // get picture queue size currently |
| 376 | iPicQueueSize = GetTargetRefListSize (pCtx); // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) | 378 | iPicQueueSize = GetTargetRefListSize (pCtx); // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) |
| 377 | pCtx->iPicQueueNumber = iPicQueueSize; | 379 | pCtx->iPicQueueNumber = iPicQueueSize; |
| 378 | if (pCtx->pPicBuff[LIST_0] != NULL | 380 | if (pCtx->pPicBuff != NULL |
| 379 | && pCtx->pPicBuff[LIST_0]->iCapacity == | 381 | && pCtx->pPicBuff->iCapacity == |
| 380 | iPicQueueSize) // comparing current picture queue size requested and previous allocation picture queue | 382 | iPicQueueSize) // comparing current picture queue size requested and previous allocation picture queue |
| 381 | bNeedChangePicQueue = false; | 383 | bNeedChangePicQueue = false; |
| 382 | // HD based pic buffer need consider memory size consumed when switch from 720p to other lower size | 384 | // 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 | |||
| 387 | WelsResetRefPic (pCtx); // added to sync update ref list due to pictures are free | 389 | WelsResetRefPic (pCtx); // added to sync update ref list due to pictures are free |
| 388 | 390 | ||
| 389 | if (pCtx->bHaveGotMemory && (kiPicWidth == pCtx->iImgWidthInPixel && kiPicHeight == pCtx->iImgHeightInPixel) | 391 | 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) { |
| 391 | // currently only active for LIST_0 due to have no B frames | 393 | // 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). | ||
| 392 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, | 395 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, |
| 393 | "WelsRequestMem(): memory re-alloc for no resolution change (size = %d * %d), ref list size change from %d to %d", | 396 | "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); | 397 | kiPicWidth, kiPicHeight, pCtx->pPicBuff->iCapacity, iPicQueueSize); |
| 395 | if (pCtx->pPicBuff[LIST_0]->iCapacity < iPicQueueSize) { | 398 | if (pCtx->pPicBuff->iCapacity < iPicQueueSize) { |
| 396 | iErr = IncreasePicBuff (pCtx, &pCtx->pPicBuff[LIST_0], pCtx->pPicBuff[LIST_0]->iCapacity, kiPicWidth, kiPicHeight, | 399 | iErr = IncreasePicBuff (pCtx, &pCtx->pPicBuff, pCtx->pPicBuff->iCapacity, kiPicWidth, kiPicHeight, |
| 397 | iPicQueueSize); | 400 | iPicQueueSize); |
| 398 | } else { | 401 | } 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, |
| 400 | iPicQueueSize); | 403 | iPicQueueSize); |
| 401 | } | 404 | } |
| 402 | } else { | 405 | } else { |
| 403 | if (pCtx->bHaveGotMemory) | 406 | if (pCtx->bHaveGotMemory) |
| 404 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, | 407 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, |
| 405 | "WelsRequestMem(): memory re-alloc for resolution change, size change from %d * %d to %d * %d, ref list size change from %d to %d", | 408 | "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, |
| 407 | iPicQueueSize); | 410 | iPicQueueSize); |
| 408 | else | 411 | else |
| 409 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "WelsRequestMem(): memory alloc size = %d * %d, ref list size = %d", | 412 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "WelsRequestMem(): memory alloc size = %d * %d, ref list size = %d", |
| 410 | kiPicWidth, kiPicHeight, iPicQueueSize); | 413 | kiPicWidth, kiPicHeight, iPicQueueSize); |
| 411 | // for Recycled_Pic_Queue | 414 | // for Recycled_Pic_Queue |
| 412 | for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) { | 415 | PPicBuff* ppPic = &pCtx->pPicBuff; |
| 413 | PPicBuff* ppPic = &pCtx->pPicBuff[iListIdx]; | 416 | if (NULL != ppPic && NULL != *ppPic) { |
| 414 | if (NULL != ppPic && NULL != *ppPic) { | 417 | DestroyPicBuff (ppPic, pMa); |
| 415 | DestroyPicBuff (ppPic, pMa); | ||
| 416 | } | ||
| 417 | } | 418 | } |
| 418 | 419 | ||
| 420 | |||
| 419 | pCtx->pPreviousDecodedPictureInDpb = NULL; | 421 | pCtx->pPreviousDecodedPictureInDpb = NULL; |
| 420 | 422 | ||
| 421 | // currently only active for LIST_0 due to have no B frames | 423 | // 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); |
| 423 | } | 425 | } |
| 424 | 426 | ||
| 425 | if (iErr != ERR_NONE) | 427 | if (iErr != ERR_NONE) |
| @@ -444,7 +446,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 18 unmodified lines | |||
| 444 | * free memory dynamically allocated during decoder | 446 | * free memory dynamically allocated during decoder |
| 445 | */ | 447 | */ |
| 446 | void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { | 448 | void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { |
| 447 | int32_t iListIdx = 0; | 449 | |
| 448 | CMemoryAlign* pMa = pCtx->pMemAlign; | 450 | CMemoryAlign* pMa = pCtx->pMemAlign; |
| 449 | 451 | ||
| 450 | //free dq layer memory | 452 | //free dq layer memory |
| @@ -455,11 +457,15 @@ void WelsFreeDynamicMemory (PWelsDecoderContext pCtx) { · 4 unmodified lines | |||
| 455 | 457 | ||
| 456 | //free ref-pic list & picture memory | 458 | //free ref-pic list & picture memory |
| 457 | WelsResetRefPic (pCtx); | 459 | WelsResetRefPic (pCtx); |
| 458 | for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) { | 460 | |
| 459 | PPicBuff* pPicBuff = &pCtx->pPicBuff[iListIdx]; | 461 | PPicBuff* pPicBuff = &pCtx->pPicBuff; |
| 460 | if (NULL != pPicBuff && NULL != *pPicBuff) { | 462 | if (NULL != pPicBuff && NULL != *pPicBuff) { |
| 461 | DestroyPicBuff (pPicBuff, pMa); | 463 | DestroyPicBuff (pPicBuff, pMa); |
| 462 | } | 464 | } |
| 465 | |||
| 466 | if (pCtx->pTempDec) { | ||
| 467 | FreePicture (pCtx->pTempDec, pCtx->pMemAlign); | ||
| 468 | pCtx->pTempDec = NULL; | ||
| 463 | } | 469 | } |
| 464 | 470 | ||
| 465 | // added for safe memory | 471 | // added for safe memory |