shithub: openh264

Download patch

ref: 6239fbe131bbcaa71269f02bd28f228a28f7395a
parent: df936ad73bced7b96724b04d77e9c265a6f2b0a0
parent: 042ac9aba1d068f7bd34b65331e8150b7322d67f
author: HaiboZhu <[email protected]>
date: Tue Oct 13 12:42:03 EDT 2015

Merge pull request #2150 from huili2/log_memory_decrease

decrease log output for decoder momery info

--- a/codec/decoder/core/inc/decoder.h
+++ b/codec/decoder/core/inc/decoder.h
@@ -106,7 +106,7 @@
 /*
  *  request memory blocks for decoder avc part
  */
-int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight);
+int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight, bool& bReallocFlag);
 
 
 /*
--- a/codec/decoder/core/src/decoder.cpp
+++ b/codec/decoder/core/src/decoder.cpp
@@ -358,7 +358,8 @@
 /*
  *  request memory blocks for decoder avc part
  */
-int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight) {
+int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const int32_t kiMbHeight,
+                        bool& bReallocFlag) {
   const int32_t kiPicWidth      = kiMbWidth << 4;
   const int32_t kiPicHeight     = kiMbHeight << 4;
   int32_t iErr = ERR_NONE;
@@ -365,6 +366,7 @@
 
   int32_t iListIdx              = 0;    //, mb_blocks   = 0;
   int32_t iPicQueueSize         = 0;    // adaptive size of picture queue, = (pSps->iNumRefFrames x 2)
+  bReallocFlag                  = false;
   bool  bNeedChangePicQueue     = true;
   CMemoryAlign* pMa = pCtx->pMemAlign;
 
@@ -434,6 +436,8 @@
   if (pCtx->pCabacDecEngine == NULL)
     pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) pMa->WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine");
   WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, (NULL == pCtx->pCabacDecEngine))
+
+  bReallocFlag              = true;         // memory re-allocation successfully finished
   return ERR_NONE;
 }
 
@@ -836,7 +840,8 @@
   const int32_t kiPicWidth    = kiMbWidth << 4;
   const int32_t kiPicHeight   = kiMbHeight << 4;
 
-  iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight); // common memory used
+  bool bReallocFlag = false;
+  iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight, bReallocFlag); // common memory used
   if (ERR_NONE != iErr) {
     WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
              "SyncPictureResolutionExt()::WelsRequestMem--buffer allocated failure.");
@@ -851,8 +856,10 @@
     pCtx->iErrorCode = dsOutOfMemory;
   }
 #if defined(MEMORY_MONITOR)
-  WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "SyncPictureResolutionExt(), overall memory usage: %llu bytes",
-           static_cast<unsigned long long> (sizeof (SWelsDecoderContext) + pCtx->pMemAlign->WelsGetMemoryUsage()));
+  if (bReallocFlag) {
+    WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "SyncPictureResolutionExt(), overall memory usage: %llu bytes",
+             static_cast<unsigned long long> (sizeof (SWelsDecoderContext) + pCtx->pMemAlign->WelsGetMemoryUsage()));
+  }
 #endif//MEMORY_MONITOR
   return iErr;
 }