shithub: openh264

Download patch

ref: 63100178772d4bb06c6ca0e841e1e7f7d315704d
parent: c72f82e7a7f633e464b38aaf11cfb7c808f5ab46
parent: 209c60702083b8a68625a1a58de24b1b6c221a0d
author: huili2 <[email protected]>
date: Thu Jul 10 13:48:18 EDT 2014

Merge pull request #1139 from huili2/parse_fail_master

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;
     }