shithub: openh264

Download patch

ref: 0dbdbfb53bccb9a35fe7276254dc622adcd34409
parent: 5f8822644f4f01a19945d928a6832f0ab309d108
parent: 581f8fdf79c3377dfdcc6cefff38a9fe512f5950
author: huili2 <huili2@cisco.com>
date: Wed Jul 9 06:59:56 EDT 2014

Merge pull request #1115 from huili2/dec_log_decrease

decrease dec log size

--- a/codec/decoder/core/inc/decoder_context.h
+++ b/codec/decoder/core/inc/decoder_context.h
@@ -319,6 +319,8 @@
 bool bAuReadyFlag;   // true: one au is ready for decoding; false: default value
 bool bDecErrorConedFlag; //true: current decoder is error coned
 
+bool bPrintFrameErrorTraceFlag; //true: can print info for upper layer
+int32_t iIgnoredErrorInfoPacketCount; //store the packet number with error decoding info
 //trace handle
 void*      pTraceHandle;
 
--- a/codec/decoder/core/src/au_parser.cpp
+++ b/codec/decoder/core/src/au_parser.cpp
@@ -141,23 +141,23 @@
   --iNalSize;
   ++ (*pConsumedBytes);
 
-#ifdef DEBUG_PARSE_INFO
-  WelsLog (pLogCtx, WELS_LOG_INFO, "nal type: %d \n", pNalUnitHeader->eNalUnitType);
-#endif
-
   if (! (IS_SEI_NAL (pNalUnitHeader->eNalUnitType) || IS_SPS_NAL (pNalUnitHeader->eNalUnitType)
          || pCtx->bSpsExistAheadFlag)) {
-    WelsLog (pLogCtx, WELS_LOG_WARNING,
+    if (pCtx->bPrintFrameErrorTraceFlag) {
+      WelsLog (pLogCtx, WELS_LOG_WARNING,
              "parse_nal(), no exist Sequence Parameter Sets ahead of sequence when try to decode NAL(type:%d).\n",
              pNalUnitHeader->eNalUnitType);
+    }
     pCtx->iErrorCode	= dsNoParamSets;
     return NULL;
   }
   if (! (IS_SEI_NAL (pNalUnitHeader->eNalUnitType) || IS_PARAM_SETS_NALS (pNalUnitHeader->eNalUnitType)
          || pCtx->bPpsExistAheadFlag)) {
-    WelsLog (pLogCtx, WELS_LOG_WARNING,
+    if (pCtx->bPrintFrameErrorTraceFlag) {
+      WelsLog (pLogCtx, WELS_LOG_WARNING,
              "parse_nal(), no exist Picture Parameter Sets ahead of sequence when try to decode NAL(type:%d).\n",
              pNalUnitHeader->eNalUnitType);
+    }
     pCtx->iErrorCode	= dsNoParamSets;
     return NULL;
   }
@@ -164,9 +164,11 @@
   if ((IS_VCL_NAL_AVC_BASE (pNalUnitHeader->eNalUnitType) && ! (pCtx->bSpsExistAheadFlag || pCtx->bPpsExistAheadFlag)) ||
       (IS_NEW_INTRODUCED_SVC_NAL (pNalUnitHeader->eNalUnitType) && ! (pCtx->bSpsExistAheadFlag || pCtx->bSubspsExistAheadFlag
           || pCtx->bPpsExistAheadFlag))) {
-    WelsLog (pLogCtx, WELS_LOG_WARNING,
+    if (pCtx->bPrintFrameErrorTraceFlag) {
+      WelsLog (pLogCtx, WELS_LOG_WARNING,
              "ParseNalHeader(), no exist Parameter Sets ahead of sequence when try to decode slice(type:%d).\n",
              pNalUnitHeader->eNalUnitType);
+    }
     pCtx->iErrorCode	|= dsNoParamSets;
     return NULL;
   }
@@ -244,7 +246,7 @@
     uint32_t uiAvailNalNum;
     pCurNal = MemGetNextNal (&pCtx->pAccessUnitList);
     if (NULL == pCurNal) {
-      WelsLog (pLogCtx, WELS_LOG_WARNING, "MemGetNextNal() fail due out of memory.\n");
+      WelsLog (pLogCtx, WELS_LOG_ERROR, "MemGetNextNal() fail due out of memory.\n");
       pCtx->iErrorCode	|= dsOutOfMemory;
       return NULL;
     }
@@ -502,9 +504,6 @@
   case NAL_UNIT_SUBSET_SPS:
     if (iBitSize > 0)
       InitBits (pBs, pRbsp, iBitSize);
-#ifdef DEBUG_PARSE_INFO
-    WelsLog (&(pCtx->sLogCtx), WELS_LOG_INFO, "parsing nal: %d \n", eNalType);
-#endif
     iErr = ParseSps (pCtx, pBs, &iPicWidth, &iPicHeight);
     if (ERR_NONE != iErr) {	// modified for pSps/pSubsetSps invalid, 12/1/2009
       if (pCtx->iErrorConMethod == ERROR_CON_DISABLE)
@@ -517,9 +516,6 @@
   case NAL_UNIT_PPS:
     if (iBitSize > 0)
       InitBits (pBs, pRbsp, iBitSize);
-#ifdef DEBUG_PARSE_INFO
-    WelsLog (&(pCtx->sLogCtx), WELS_LOG_INFO, "parsing nal: %d \n", eNalType);
-#endif
     iErr = ParsePps (pCtx, &pCtx->sPpsBuffer[0], pBs);
     if (ERR_NONE != iErr) {	// modified for pps invalid, 12/1/2009
       if (pCtx->iErrorConMethod == ERROR_CON_DISABLE)
--- a/codec/decoder/core/src/decoder.cpp
+++ b/codec/decoder/core/src/decoder.cpp
@@ -295,6 +295,8 @@
 #endif //LONG_TERM_REF
   pCtx->bNewSeqBegin = true;
   pCtx->bDecErrorConedFlag = false; //default: decoder normal status
+  pCtx->bPrintFrameErrorTraceFlag = true;
+  pCtx->iIgnoredErrorInfoPacketCount = 0;
 }
 
 /*!
@@ -312,6 +314,8 @@
 #else
   pCtx->bReferenceLostAtT0Flag = false;
 #endif
+  pCtx->bNewSeqBegin = false;
+  pCtx->bPrintFrameErrorTraceFlag = false;
 }
 
 /*!
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -63,14 +63,18 @@
 #else
     pCtx->bReferenceLostAtT0Flag = false;	// need initialize it due new seq, 6/4/2010
 #endif //LONG_TERM_REF
-    WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO,
-             "DecodeFrameConstruction()::::output first frame of new sequence, %d x %d, crop_left:%d, crop_right:%d, crop_top:%d, crop_bottom:%d.\n",
+    if (pCtx->iTotalNumMbRec == kiTotalNumMbInCurLayer) {
+      pCtx->bPrintFrameErrorTraceFlag = true;
+      WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO,
+             "DecodeFrameConstruction()::::output first frame of new sequence, %d x %d, crop_left:%d, crop_right:%d, crop_top:%d, crop_bottom:%d, ignored error packet:%d.\n",
              kiWidth, kiHeight, pCtx->sFrameCrop.iLeftOffset, pCtx->sFrameCrop.iRightOffset, pCtx->sFrameCrop.iTopOffset,
-             pCtx->sFrameCrop.iBottomOffset);
+             pCtx->sFrameCrop.iBottomOffset, pCtx->iIgnoredErrorInfoPacketCount);
+      pCtx->iIgnoredErrorInfoPacketCount = 0;
+    }
   }
 
   if (pCtx->iTotalNumMbRec != kiTotalNumMbInCurLayer) {
-    WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
+    WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG,
              "DecodeFrameConstruction():::iTotalNumMbRec:%d, total_num_mb_sps:%d, cur_layer_mb_width:%d, cur_layer_mb_height:%d \n",
              pCtx->iTotalNumMbRec, kiTotalNumMbInCurLayer, pCurDq->iMbWidth, pCurDq->iMbHeight);
     bFrameCompleteFlag = false; //return later after output buffer is done
--- a/codec/decoder/plus/src/welsDecoderExt.cpp
+++ b/codec/decoder/plus/src/welsDecoderExt.cpp
@@ -189,7 +189,7 @@
   }
 
   if (pParam == NULL) {
-    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::Initialize(), invalid input argument.");
+    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_ERROR, "CWelsDecoder::Initialize(), invalid input argument.");
     return cmInitParaError;
   }
 
@@ -211,7 +211,7 @@
   if (NULL == m_pDecContext)
     return;
 
-  WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "into CWelsDecoder::uninit_decoder()..");
+  WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::uninit_decoder()..");
 
   WelsEndDecoder (m_pDecContext);
 
@@ -221,7 +221,6 @@
     m_pDecContext	= NULL;
   }
 
-  WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "left CWelsDecoder::uninit_decoder()..");
 }
 
 // the return value of this function is not suitable, it need report failure info to upper layer.
@@ -233,7 +232,6 @@
 
   WelsInitDecoder (m_pDecContext, &m_pWelsTrace->m_sLogCtx);
 
-  WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::init_decoder().. left");
 }
 
 /*
@@ -411,8 +409,17 @@
       }
     }
 
-    WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "decode failed, failure type:%d \n",
+    if (m_pDecContext->bPrintFrameErrorTraceFlag) {
+      WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "decode failed, failure type:%d \n",
              m_pDecContext->iErrorCode);
+      m_pDecContext->bPrintFrameErrorTraceFlag = false;
+    } else {
+      m_pDecContext->iIgnoredErrorInfoPacketCount ++;
+      if (m_pDecContext->iIgnoredErrorInfoPacketCount == INT_MAX) {
+        WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_WARNING, "continuous error reached INT_MAX! Restart as 0.");
+        m_pDecContext->iIgnoredErrorInfoPacketCount = 0;
+      }
+    }
     return (DECODING_STATE)m_pDecContext->iErrorCode;
   } else { //decoding correct, but may have ECed status
     if (m_pDecContext->bDecErrorConedFlag) {