shithub: openh264

Download patch

ref: 5e6ef1741270e6fb93a0f482bb443ff2810e696e
parent: c27c02bc0abc5cf0d975d715c848db1c189cea1e
author: huili2 <[email protected]>
date: Tue Apr 29 15:07:32 EDT 2014

fix new sequence&EC order, and prefix parse bug

--- a/codec/decoder/core/inc/nal_prefix.h
+++ b/codec/decoder/core/inc/nal_prefix.h
@@ -78,6 +78,7 @@
   bool		bStoreRefBasePicFlag;
   bool		bPrefixNalUnitAdditionalExtFlag;
   bool		bPrefixNalUnitExtFlag;
+  bool          bPrefixNalCorrectFlag;
 } SPrefixNalUnit, *PPrefixNalUnit;
 
 } // namespace WelsDec
--- a/codec/decoder/core/src/au_parser.cpp
+++ b/codec/decoder/core/src/au_parser.cpp
@@ -188,12 +188,14 @@
 
       PAccessUnit pCurAu	   = pCtx->pAccessUnitList;
       uint32_t uiAvailNalNum = pCurAu->uiAvailUnitsNum;
-      ForceClearCurrentNal (pCurAu);
 
-      if (uiAvailNalNum > 1) {
-        pCurAu->uiEndPos = uiAvailNalNum - 2;
-        pCtx->bAuReadyFlag = true;
+      if (uiAvailNalNum > 0) {
+        pCurAu->uiEndPos = uiAvailNalNum - 1;
+        if (pCtx->iErrorConMethod == ERROR_CON_DISABLE) {
+          pCtx->bAuReadyFlag = true;
+        }
       }
+      pCurNal->sNalData.sPrefixNal.bPrefixNalCorrectFlag = false;
       return NULL;
     }
 
@@ -204,12 +206,14 @@
                pCurNal->sNalHeaderExt.uiQualityId, pCurNal->sNalHeaderExt.bUseRefBasePicFlag);
       PAccessUnit pCurAu	   = pCtx->pAccessUnitList;
       uint32_t uiAvailNalNum = pCurAu->uiAvailUnitsNum;
-      ForceClearCurrentNal (pCurAu);
 
-      if (uiAvailNalNum > 1) {
-        pCurAu->uiEndPos = uiAvailNalNum - 2;
-        pCtx->bAuReadyFlag = true;
+      if (uiAvailNalNum > 0) {
+        pCurAu->uiEndPos = uiAvailNalNum - 1;
+        if (pCtx->iErrorConMethod == ERROR_CON_DISABLE) {
+          pCtx->bAuReadyFlag = true;
+        }
       }
+      pCurNal->sNalData.sPrefixNal.bPrefixNalCorrectFlag = false;
       pCtx->iErrorCode |= dsInvalidArgument;
       return NULL;
     }
@@ -229,6 +233,7 @@
     InitBits (pBs, pNal, iBitSize);
 
     ParsePrefixNalUnit (pCtx, pBs);
+    pCurNal->sNalData.sPrefixNal.bPrefixNalCorrectFlag = true;
 
     break;
   case NAL_UNIT_CODED_SLICE_EXT:
@@ -291,7 +296,9 @@
 
 
       if (NAL_UNIT_PREFIX == pCtx->sPrefixNal.sNalHeaderExt.sNalUnitHeader.eNalUnitType) {
-        PrefetchNalHeaderExtSyntax (pCtx, pCurNal, &pCtx->sPrefixNal);
+        if (pCtx->sPrefixNal.sNalData.sPrefixNal.bPrefixNalCorrectFlag) {
+          PrefetchNalHeaderExtSyntax (pCtx, pCurNal, &pCtx->sPrefixNal);
+        }
       }
 
       pCurNal->sNalHeaderExt.bIdrFlag = (NAL_UNIT_CODED_SLICE_IDR == pNalUnitHeader->eNalUnitType) ? true :
--- a/codec/decoder/core/src/decoder.cpp
+++ b/codec/decoder/core/src/decoder.cpp
@@ -481,8 +481,6 @@
                 return pCtx->iErrorCode;
               }
             }
-            //Do error concealment here
-            ImplementErrorCon (pCtx);
           }
           if (iRet) {
             iRet = 0;
@@ -536,8 +534,6 @@
         ResetParameterSetsState (pCtx);
         return pCtx->iErrorCode;
       }
-      //Do error concealment here
-      ImplementErrorCon (pCtx);
     }
     if (iRet) {
       iRet = 0;
@@ -573,7 +569,6 @@
         ResetParameterSetsState (pCtx);
         return pCtx->iErrorCode;
       }
-      ImplementErrorCon (pCtx);
     }
   }
 
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -1591,6 +1591,9 @@
   iErr = DecodeCurrentAccessUnit (pCtx, ppDst, iStride, &iWidth, &iHeight, pDstInfo);
 
   WelsDecodeAccessUnitEnd (pCtx);
+  //Do error concealment here
+  ImplementErrorCon (pCtx);
+
   pCtx->bNewSeqBegin = false;
   WriteBackActiveParameters(pCtx);
   pCtx->bNewSeqBegin = pCtx->bNewSeqBegin || pCtx->bNextNewSeqBegin;