shithub: openh264

Download patch

ref: 209c60702083b8a68625a1a58de24b1b6c221a0d
parent: 0cafc565becf6e6b02abbdf0865960b65f8e3b21
author: huili2 <huili2@cisco.com>
date: Wed Jul 9 18:07:30 EDT 2014

add return info for all cases

--- a/codec/decoder/core/src/au_parser.cpp
+++ b/codec/decoder/core/src/au_parser.cpp
@@ -131,6 +131,7 @@
 
   pNalUnitHeader->uiForbiddenZeroBit	= (uint8_t) (pNal[0] >> 7);			// uiForbiddenZeroBit
   if (pNalUnitHeader->uiForbiddenZeroBit) { //2010.4.14
+    pCtx->iErrorCode |= dsBitstreamError;
     return NULL; //uiForbiddenZeroBit should always equal to 0
   }
 
@@ -186,8 +187,6 @@
     pCurNal = &pCtx->sPrefixNal;
 
     if (iNalSize < NAL_UNIT_HEADER_EXT_SIZE) {
-      pCtx->iErrorCode |= dsBitstreamError;
-
       PAccessUnit pCurAu	   = pCtx->pAccessUnitList;
       uint32_t uiAvailNalNum = pCurAu->uiAvailUnitsNum;
 
@@ -198,6 +197,7 @@
         }
       }
       pCurNal->sNalData.sPrefixNal.bPrefixNalCorrectFlag = false;
+      pCtx->iErrorCode |= dsBitstreamError;
       return NULL;
     }
 
@@ -216,7 +216,7 @@
         }
       }
       pCurNal->sNalData.sPrefixNal.bPrefixNalCorrectFlag = false;
-      pCtx->iErrorCode |= dsInvalidArgument;
+      pCtx->iErrorCode |= dsBitstreamError;
       return NULL;
     }
 
@@ -260,8 +260,6 @@
 
     if (pNalUnitHeader->eNalUnitType == NAL_UNIT_CODED_SLICE_EXT) {
       if (iNalSize < NAL_UNIT_HEADER_EXT_SIZE) {
-        pCtx->iErrorCode |= dsBitstreamError;
-
         ForceClearCurrentNal (pCurAu);
 
         if (uiAvailNalNum > 1) {
@@ -268,6 +266,7 @@
           pCurAu->uiEndPos = uiAvailNalNum - 2;
           pCtx->bAuReadyFlag = true;
         }
+        pCtx->iErrorCode |= dsBitstreamError;
         return NULL;
       }
 
@@ -281,7 +280,6 @@
           WelsLog (pLogCtx, WELS_LOG_WARNING, "ParseNalHeader():bUseRefBasePicFlag (%d) != 0, MGS not supported!\n",
                    pCurNal->sNalHeaderExt.bUseRefBasePicFlag);
 
-        pCtx->iErrorCode |= dsInvalidArgument;
         ForceClearCurrentNal (pCurAu);
 
         if (uiAvailNalNum > 1) {
@@ -288,6 +286,7 @@
           pCurAu->uiEndPos = uiAvailNalNum - 2;
           pCtx->bAuReadyFlag = true;
         }
+        pCtx->iErrorCode |= dsBitstreamError;
         return NULL;
       }
       pNal            += NAL_UNIT_HEADER_EXT_SIZE;
@@ -321,6 +320,7 @@
         pCurAu->uiEndPos = uiAvailNalNum - 2;
         pCtx->bAuReadyFlag = true;
       }
+      pCtx->iErrorCode |= dsBitstreamError;
       return NULL;
     }
 
--- a/codec/decoder/core/src/decoder.cpp
+++ b/codec/decoder/core/src/decoder.cpp
@@ -433,6 +433,7 @@
 
     if (NULL == DetectStartCodePrefix (kpBsBuf, &iOffset,
                                        kiBsLen)) {  //CAN'T find the 00 00 01 start prefix from the source buffer
+      pCtx->iErrorCode |= dsBitstreamError;
       return dsBitstreamError;
     }