Showing the changes to codec/decoder/core/src/decoder.cpp (1 of 2 files). Show all
Unified · Split
| @@ -358,13 +358,15 @@ static inline int32_t GetTargetRefListSize (PWelsDecoderContext pCtx) { · 357 unmodified lines | ||
| 358 | 358 | /* |
| 359 | 359 | * request memory blocks for decoder avc part |
| 360 | 360 | */ |
| 361 | −int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) { | |
| 361 | +int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight, | |
| 362 | + bool& bReallocFlag) { | |
| 362 | 363 | const int32_t kiPicWidth = kiMbWidth << 4; |
| 363 | 364 | const int32_t kiPicHeight = kiMbHeight << 4; |
| 364 | 365 | int32_t iErr = ERR_NONE; |
| 365 | 366 | |
| 366 | 367 | int32_t iListIdx = 0; //, mb_blocks = 0; |
| 367 | 368 | int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) |
| 369 | + bReallocFlag = false; | |
| 368 | 370 | bool bNeedChangePicQueue = true; |
| 369 | 371 | CMemoryAlign* pMa = pCtx->pMemAlign; |
| 370 | 372 | |
| @@ -434,6 +436,8 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 63 unmodified lines | ||
| 434 | 436 | if (pCtx->pCabacDecEngine == NULL) |
| 435 | 437 | pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) pMa->WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine"); |
| 436 | 438 | WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, (NULL == pCtx->pCabacDecEngine)) |
| 439 | + | |
| 440 | + bReallocFlag = true; // memory re-allocation successfully finished | |
| 437 | 441 | return ERR_NONE; |
| 438 | 442 | } |
| 439 | 443 | |
| @@ -836,7 +840,8 @@ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWi · 396 unmodified lines | ||
| 836 | 840 | const int32_t kiPicWidth = kiMbWidth << 4; |
| 837 | 841 | const int32_t kiPicHeight = kiMbHeight << 4; |
| 838 | 842 | |
| 839 | − iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight); // common memory used | |
| 843 | + bool bReallocFlag = false; | |
| 844 | + iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight, bReallocFlag); // common memory used | |
| 840 | 845 | if (ERR_NONE != iErr) { |
| 841 | 846 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, |
| 842 | 847 | "SyncPictureResolutionExt()::WelsRequestMem--buffer allocated failure."); |
| @@ -851,8 +856,10 @@ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWi · 8 unmodified lines | ||
| 851 | 856 | pCtx->iErrorCode = dsOutOfMemory; |
| 852 | 857 | } |
| 853 | 858 | #if defined(MEMORY_MONITOR) |
| 854 | − WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "SyncPictureResolutionExt(), overall memory usage: %llu bytes", | |
| 855 | − static_cast<unsigned long long> (sizeof (SWelsDecoderContext) + pCtx->pMemAlign->WelsGetMemoryUsage())); | |
| 859 | + if (bReallocFlag) { | |
| 860 | + WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "SyncPictureResolutionExt(), overall memory usage: %llu bytes", | |
| 861 | + static_cast<unsigned long long> (sizeof (SWelsDecoderContext) + pCtx->pMemAlign->WelsGetMemoryUsage())); | |
| 862 | + } | |
| 856 | 863 | #endif//MEMORY_MONITOR |
| 857 | 864 | return iErr; |
| 858 | 865 | } |