shithub: openh264

Download patch

ref: d28970d625e62a581aa2be6640a71772c2196bea
parent: 7c9597c36d2f1781a5f1545640b786e91b5e90a4
author: dong zhang <[email protected]>
date: Mon Mar 2 09:43:21 EST 2015

modify decoder log

--- a/codec/api/svc/codec_app_def.h
+++ b/codec/api/svc/codec_app_def.h
@@ -659,7 +659,12 @@
   uiFreezingIDRNum;               ///< number of freezing IDR with error (partly received), under resolution change
   unsigned int uiFreezingNonIDRNum;            ///< number of freezing non-IDR with error
   int iAvgLumaQp;                              ///< average luma QP. default: -1, no correct frame outputted
-
+  int iSpsReportErrorNum;             ///< number of Sps Invalid report
+  int iSubSpsReportErrorNum;          ///< number of SubSps Invalid report
+  int iPpsReportErrorNum;             ///< number of Pps Invalid report
+  int			iSpsNoExistNalNum;          ///< number of Sps NoExist Nal
+  int			iSubSpsNoExistNalNum;       ///< number of SubSps NoExist Nal
+  int			iPpsNoExistNalNum;          ///< number of Pps NoExist Nal
 } SDecoderStatistics; // in building, coming soon
 
 #endif//WELS_VIDEO_CODEC_APPLICATION_DEFINITION_H__
--- a/codec/decoder/core/inc/decoder_context.h
+++ b/codec/decoder/core/inc/decoder_context.h
@@ -335,9 +335,20 @@
 bool				bSubspsExistAheadFlag;// whether does Subset SPS NAL exist ahead of sequence?
 bool				bPpsExistAheadFlag;	// whether does PPS NAL exist ahead of sequence?
 
+int32_t			iSpsErrorIgnored;
+int32_t			iSubSpsErrorIgnored;
+int32_t			iPpsErrorIgnored;
+  
 bool				bSpsAvailFlags[MAX_SPS_COUNT];
 bool				bSubspsAvailFlags[MAX_SPS_COUNT];
 bool				bPpsAvailFlags[MAX_PPS_COUNT];
+int32_t     iPPSLastInvalidId;
+int32_t     iPPSInvalidNum;
+int32_t     iSPSLastInvalidId;
+int32_t     iSPSInvalidNum;
+int32_t     iSubSPSLastInvalidId;
+int32_t     iSubSPSInvalidNum;
+  
 bool				bReferenceLostAtT0Flag;
 int32_t     iTotalNumMbRec; //record current number of decoded MB
 #ifdef LONG_TERM_REF
--- a/codec/decoder/core/inc/wels_const.h
+++ b/codec/decoder/core/inc/wels_const.h
@@ -77,7 +77,6 @@
 #define MAX_BUFFERED_NUM 3 //mamixum stored number of AU|packet to prevent overwrite
 #define MAX_ACCESS_UNIT_CAPACITY 7077888 //Maximum AU size in bytes for level 5.2 for single frame
 #define MAX_MACROBLOCK_CAPACITY 5000 //Maximal legal MB capacity, 15000 bits is enough
-
 enum {
     BASE_MB = 0,
     NON_AVC_REWRITE_ENHANCE_MB =1,
--- a/codec/decoder/core/src/au_parser.cpp
+++ b/codec/decoder/core/src/au_parser.cpp
@@ -146,36 +146,47 @@
 
   if (! (IS_SEI_NAL (pNalUnitHeader->eNalUnitType) || IS_SPS_NAL (pNalUnitHeader->eNalUnitType)
          || pCtx->bSpsExistAheadFlag)) {
-    if (pCtx->bPrintFrameErrorTraceFlag) {
+    if (pCtx->bPrintFrameErrorTraceFlag && pCtx->iSpsErrorIgnored == 0) {
       WelsLog (pLogCtx, WELS_LOG_WARNING,
                "parse_nal(), no exist Sequence Parameter Sets ahead of sequence when try to decode NAL(type:%d).",
                pNalUnitHeader->eNalUnitType);
+    } else {
+      pCtx->iSpsErrorIgnored++;
     }
+    pCtx->sDecoderStatistics.iSpsNoExistNalNum++;
     pCtx->iErrorCode	= dsNoParamSets;
     return NULL;
   }
+  pCtx->iSpsErrorIgnored = 0;
   if (! (IS_SEI_NAL (pNalUnitHeader->eNalUnitType) || IS_PARAM_SETS_NALS (pNalUnitHeader->eNalUnitType)
          || pCtx->bPpsExistAheadFlag)) {
-    if (pCtx->bPrintFrameErrorTraceFlag) {
+    if (pCtx->bPrintFrameErrorTraceFlag && pCtx->iPpsErrorIgnored == 0) {
       WelsLog (pLogCtx, WELS_LOG_WARNING,
                "parse_nal(), no exist Picture Parameter Sets ahead of sequence when try to decode NAL(type:%d).",
                pNalUnitHeader->eNalUnitType);
+    } else {
+      pCtx->iPpsErrorIgnored++;
     }
+    pCtx->sDecoderStatistics.iPpsNoExistNalNum++;
     pCtx->iErrorCode	= dsNoParamSets;
     return NULL;
   }
+  pCtx->iPpsErrorIgnored = 0;
   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))) {
-    if (pCtx->bPrintFrameErrorTraceFlag) {
+    if (pCtx->bPrintFrameErrorTraceFlag && pCtx->iSubSpsErrorIgnored == 0) {
       WelsLog (pLogCtx, WELS_LOG_WARNING,
                "ParseNalHeader(), no exist Parameter Sets ahead of sequence when try to decode slice(type:%d).",
                pNalUnitHeader->eNalUnitType);
+    } else {
+      pCtx->iSubSpsErrorIgnored++;
     }
+    pCtx->sDecoderStatistics.iSubSpsNoExistNalNum++;
     pCtx->iErrorCode	|= dsNoParamSets;
     return NULL;
   }
-
+  pCtx->iSubSpsErrorIgnored = 0;
 
   switch (pNalUnitHeader->eNalUnitType) {
   case NAL_UNIT_AU_DELIMITER:
--- a/codec/decoder/core/src/decoder.cpp
+++ b/codec/decoder/core/src/decoder.cpp
@@ -311,7 +311,15 @@
   pCtx->sDecoderStatistics.iAvgLumaQp = -1;
   pCtx->bSpsLatePps = false;
   pCtx->bUseScalingList = false;
-
+  pCtx->iSpsErrorIgnored = 0;
+  pCtx->iSubSpsErrorIgnored = 0;
+  pCtx->iPpsErrorIgnored = 0;
+  pCtx->iPPSInvalidNum = 0;
+  pCtx->iPPSLastInvalidId = -1;
+  pCtx->iSPSInvalidNum = 0;
+  pCtx->iSPSLastInvalidId = -1;
+  pCtx->iSubSPSInvalidNum = 0;
+  pCtx->iSubSPSLastInvalidId = -1;
 }
 
 /*
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -566,10 +566,18 @@
 
   //add check PPS available here
   if (pCtx->bPpsAvailFlags[iPpsId] == false) {
-    WelsLog (pLogCtx, WELS_LOG_ERROR, "PPS id is invalid!");
+    pCtx->sDecoderStatistics.iPpsReportErrorNum++;
+    if (pCtx->iPPSLastInvalidId != iPpsId) {
+      WelsLog (pLogCtx, WELS_LOG_ERROR, "PPS id (%d) is invalid, previous id (%d) error ignored (%d)!", iPpsId, pCtx->iPPSLastInvalidId, pCtx->iPPSInvalidNum);
+      pCtx->iPPSLastInvalidId = iPpsId;
+      pCtx->iPPSInvalidNum = 0;
+    } else {
+      pCtx->iPPSInvalidNum++;
+    }
     pCtx->iErrorCode |= dsNoParamSets;
     return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_PPS_ID);
   }
+  pCtx->iPPSLastInvalidId = -1;
 
   pPps    = &pCtx->sPpsBuffer[iPpsId];
 
@@ -583,16 +591,32 @@
     pSubsetSps      = &pCtx->sSubsetSpsBuffer[pPps->iSpsId];
     pSps		= &pSubsetSps->sSps;
     if (pCtx->bSubspsAvailFlags[pPps->iSpsId] == false) {
-      WelsLog (pLogCtx, WELS_LOG_ERROR, "SPS id is invalid!");
+      pCtx->sDecoderStatistics.iSubSpsReportErrorNum++;
+      if (pCtx->iSubSPSLastInvalidId != pPps->iSpsId) {
+        WelsLog (pLogCtx, WELS_LOG_ERROR, "Sub SPS id (%d) is invalid, previous id (%d) error ignored (%d)!", pPps->iSpsId, pCtx->iSubSPSLastInvalidId, pCtx->iSubSPSInvalidNum);
+        pCtx->iSubSPSLastInvalidId = pPps->iSpsId;
+        pCtx->iSubSPSInvalidNum = 0;
+      } else {
+        pCtx->iSubSPSInvalidNum++;
+      }
       pCtx->iErrorCode |= dsNoParamSets;
       return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID);
     }
+    pCtx->iSubSPSLastInvalidId = -1;
   } else {
     if (pCtx->bSpsAvailFlags[pPps->iSpsId] == false) {
-      WelsLog (pLogCtx, WELS_LOG_ERROR, "SPS id is invalid!");
+      pCtx->sDecoderStatistics.iSpsReportErrorNum++;
+      if (pCtx->iSPSLastInvalidId != pPps->iSpsId) {
+        WelsLog (pLogCtx, WELS_LOG_ERROR, "SPS id (%d) is invalid, previous id (%d) error ignored (%d)!", pPps->iSpsId, pCtx->iSPSLastInvalidId, pCtx->iSPSInvalidNum);
+        pCtx->iSPSLastInvalidId = pPps->iSpsId;
+        pCtx->iSPSInvalidNum = 0;
+      } else {
+        pCtx->iSPSInvalidNum++;
+      }
       pCtx->iErrorCode |= dsNoParamSets;
       return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID);
     }
+    pCtx->iSPSLastInvalidId = -1;
     pSps		= &pCtx->sSpsBuffer[pPps->iSpsId];
   }
   pSliceHead->iPpsId = iPpsId;
@@ -2051,7 +2075,7 @@
             pCtx->bRPLRError = true;
             bAllRefComplete = false; // RPLR error, set ref pictures complete flag false
             HandleReferenceLost (pCtx, pNalCur);
-            WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
+            WelsLog (& (pCtx->sLogCtx), WELS_LOG_DEBUG,
                      "reference picture introduced by this frame is lost during transmission! uiTId: %d",
                      pNalCur->sNalHeaderExt.uiTemporalId);
             if (pCtx->eErrorConMethod == ERROR_CON_DISABLE) {