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 | * request memory blocks for decoder avc part | 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 | const int32_t kiPicWidth = kiMbWidth << 4; | 363 | const int32_t kiPicWidth = kiMbWidth << 4; |
| 363 | const int32_t kiPicHeight = kiMbHeight << 4; | 364 | const int32_t kiPicHeight = kiMbHeight << 4; |
| 364 | int32_t iErr = ERR_NONE; | 365 | int32_t iErr = ERR_NONE; |
| 365 | 366 | ||
| 366 | int32_t iListIdx = 0; //, mb_blocks = 0; | 367 | int32_t iListIdx = 0; //, mb_blocks = 0; |
| 367 | int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) | 368 | int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2) |
| 369 | bReallocFlag = false; | ||
| 368 | bool bNeedChangePicQueue = true; | 370 | bool bNeedChangePicQueue = true; |
| 369 | CMemoryAlign* pMa = pCtx->pMemAlign; | 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 | if (pCtx->pCabacDecEngine == NULL) | 436 | if (pCtx->pCabacDecEngine == NULL) |
| 435 | pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) pMa->WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine"); | 437 | pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) pMa->WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine"); |
| 436 | WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, (NULL == pCtx->pCabacDecEngine)) | 438 | WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, (NULL == pCtx->pCabacDecEngine)) |
| 439 | |||
| 440 | bReallocFlag = true; // memory re-allocation successfully finished | ||
| 437 | return ERR_NONE; | 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 | const int32_t kiPicWidth = kiMbWidth << 4; | 840 | const int32_t kiPicWidth = kiMbWidth << 4; |
| 837 | const int32_t kiPicHeight = kiMbHeight << 4; | 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 | if (ERR_NONE != iErr) { | 845 | if (ERR_NONE != iErr) { |
| 841 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, | 846 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, |
| 842 | "SyncPictureResolutionExt()::WelsRequestMem--buffer allocated failure."); | 847 | "SyncPictureResolutionExt()::WelsRequestMem--buffer allocated failure."); |
| @@ -851,8 +856,10 @@ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWi · 8 unmodified lines | |||
| 851 | pCtx->iErrorCode = dsOutOfMemory; | 856 | pCtx->iErrorCode = dsOutOfMemory; |
| 852 | } | 857 | } |
| 853 | #if defined(MEMORY_MONITOR) | 858 | #if defined(MEMORY_MONITOR) |
| 854 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "SyncPictureResolutionExt(), overall memory usage: %llu bytes", | 859 | if (bReallocFlag) { |
| 855 | static_cast<unsigned long long> (sizeof (SWelsDecoderContext) + pCtx->pMemAlign->WelsGetMemoryUsage())); | 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 | #endif//MEMORY_MONITOR | 863 | #endif//MEMORY_MONITOR |
| 857 | return iErr; | 864 | return iErr; |
| 858 | } | 865 | } |