shithub: openh264

Download patch

ref: 7c6debbef650c8a39e56673e8b4f26df1adcaa9e
parent: 3e258ea74ea0ca38c5b7e7690997e3e1201ff9fe
author: huili2 <[email protected]>
date: Mon May 19 15:33:30 EDT 2014

add single function for new seq detection

--- a/codec/decoder/core/inc/au_parser.h
+++ b/codec/decoder/core/inc/au_parser.h
@@ -96,6 +96,8 @@
                               const PSps kpSps);
 bool CheckAccessUnitBoundaryExt (PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHeaderExt pCurNalHeaderExt,
                                  PSliceHeader pLastSliceHeader, PSliceHeader pCurSliceHeader);
+bool CheckNextAuNewSeq (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, const PSps kpSps);
+
 /*!
  *************************************************************************************
  * \brief	to parse Sequence Parameter Set (SPS)
--- a/codec/decoder/core/src/au_parser.cpp
+++ b/codec/decoder/core/src/au_parser.cpp
@@ -331,8 +331,8 @@
                                  pCurAu->pNalUnitsList[uiAvailNalNum - 1]->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps)) {
       pCurAu->uiEndPos = uiAvailNalNum - 2;
       pCtx->bAuReadyFlag = true;
+      pCtx->bNextNewSeqBegin = CheckNextAuNewSeq (pCtx, pCurNal, pCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps);
 
-
     }
   }
   break;
@@ -411,7 +411,6 @@
   const SSliceHeader* kpCurSliceHeader = &kpCurNal->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader;
   if (pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != NULL
       && pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != kpSps) {
-    pCtx->bNextNewSeqBegin = true;
     return true; // the active sps changed, new sequence begins, so the current au is ready
   }
 
@@ -456,6 +455,17 @@
     if (kpLastSliceHeader->iDeltaPicOrderCnt[1] != kpCurSliceHeader->iDeltaPicOrderCnt[1])
       return true;
   }
+
+  return false;
+}
+
+bool CheckNextAuNewSeq (PWelsDecoderContext pCtx, const PNalUnit kpCurNal, const PSps kpSps) {
+  const PNalUnitHeaderExt kpCurNalHeaderExt = &kpCurNal->sNalHeaderExt;
+  if (pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != NULL
+      && pCtx->pActiveLayerSps[kpCurNalHeaderExt->uiDependencyId] != kpSps)
+    return true;
+  if (kpCurNalHeaderExt->bIdrFlag)
+    return true;
 
   return false;
 }