shithub: openh264

Download patch

ref: 78ab4000c086c07d6841365541fd86d12ca98e4d
parent: 050c683a274236b5858ae21075a84b8912b3c10b
parent: 20f28cd2f293f3b3fdfc494766f24987a4a8eb0e
author: HaiboZhu <[email protected]>
date: Wed Apr 8 06:29:54 EDT 2015

Merge pull request #1890 from huili2/parseonly_bugfix_for_multi_in

bug fix for parseonly multi-data in

--- a/codec/decoder/core/inc/decoder_context.h
+++ b/codec/decoder/core/inc/decoder_context.h
@@ -367,6 +367,7 @@
 //for Parse only
   bool bParseOnly;
   bool bFramePending;
+  bool bFrameFinish;
   int32_t iNalNum;
   int32_t iNalLenInByte[MAX_NAL_UNITS_IN_LAYER];
   SSpsBsInfo sSpsBsInfo [MAX_SPS_COUNT];
--- a/codec/decoder/core/src/decoder.cpp
+++ b/codec/decoder/core/src/decoder.cpp
@@ -487,6 +487,7 @@
   pCtx->bNewSeqBegin = true;
   pCtx->bPrintFrameErrorTraceFlag = true;
   pCtx->iIgnoredErrorInfoPacketCount = 0;
+  pCtx->bFrameFinish = true;
   return iRet;
 }
 
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -74,7 +74,6 @@
 
   if (pCtx->bParseOnly) { //should exit for parse only to prevent access NULL pDstInfo
     PAccessUnit pCurAu = pCtx->pAccessUnitList;
-    static bool bFirstIDR = true;
     if (dsErrorFree == pCtx->iErrorCode) { //correct decoding, add to data buffer
       SParserBsInfo* pParser = pCtx->pParserBsInfo;
       SNalUnit* pCurNal = NULL;
@@ -94,7 +93,7 @@
       pParser->iSpsHeightInPixel = (pCtx->pSps->iMbHeight << 4);
 
       if (pCurAu->pNalUnitsList [iIdx]->sNalHeaderExt.bIdrFlag) { //IDR
-        if (bFirstIDR) { //add required sps/pps
+        if (pCtx->bFrameFinish) { //add required sps/pps
           bool bSubSps = (NAL_UNIT_CODED_SLICE_EXT == pCurAu->pNalUnitsList [iIdx]->sNalHeaderExt.sNalUnitHeader.eNalUnitType);
           SSpsBsInfo* pSpsBs = NULL;
           SPpsBsInfo* pPpsBs = NULL;
@@ -111,10 +110,10 @@
           memcpy (pDstBuf, pPpsBs->pPpsBsBuf, pPpsBs->uiPpsBsLen);
           pParser->iNalLenInByte [pParser->iNalNum ++] = pPpsBs->uiPpsBsLen;
           pDstBuf += pPpsBs->uiPpsBsLen;
-          bFirstIDR = false;
+          pCtx->bFrameFinish = false;
         }
       } else { //IDR required SPS, PPS
-        bFirstIDR = true;
+        pCtx->bFrameFinish = true;
       }
       //then VCL data re-write
       while (iIdx <= iEndIdx) {
@@ -2364,6 +2363,7 @@
       }
     } else if (pCtx->bParseOnly) { //clear parse only internal data status
       pCtx->pParserBsInfo->iNalNum = 0;
+      pCtx->bFrameFinish = true; //clear frame pending status here!
     } else {
       if (DecodeFrameConstruction (pCtx, ppDst, pDstInfo)) {
         pCtx->pDec = NULL;