shithub: openh264

Download patch

ref: 442230a91df7a06f809c325db169d25e831d0a7a
parent: fba745f04e224b8133aa483237f05243ab5e7318
parent: 173413301253eff8f9a5bbb6baaca43422b32ef2
author: HaiboZhu <haibozhu@cisco.com>
date: Wed Feb 4 04:13:18 EST 2015

Merge pull request #1789 from huili2/bugfix_checkspsactive

bug fix for multi-layer active sps check

--- a/codec/decoder/core/src/au_parser.cpp
+++ b/codec/decoder/core/src/au_parser.cpp
@@ -832,18 +832,30 @@
   if (bUseSubsetFlag) {
     if (pSps->iMbWidth > 0  && pSps->iMbHeight > 0 && pCtx->bSubspsAvailFlags[pSps->iSpsId]
         && pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
-      PSps pNextUsedSps =
-        pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiStartPos]->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps;
-      if (pNextUsedSps->iSpsId == pSps->iSpsId)
-        return true;
+      int i = 0, iNum = (int32_t) pCtx->pAccessUnitList->uiAvailUnitsNum;
+      while (i < iNum) {
+        PNalUnit pNalUnit = pCtx->pAccessUnitList->pNalUnitsList[i];
+        if (pNalUnit->sNalData.sVclNal.bSliceHeaderExtFlag) { //ext data
+          PSps pNextUsedSps = pNalUnit->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps;
+          if (pNextUsedSps->iSpsId == pSps->iSpsId)
+            return true;
+        }
+        ++i;
+      }
     }
   } else {
     if (pSps->iMbWidth > 0  && pSps->iMbHeight > 0 && pCtx->bSpsAvailFlags[pSps->iSpsId]
         && pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
-      PSps pNextUsedSps =
-        pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiStartPos]->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps;
-      if (pNextUsedSps->iSpsId == pSps->iSpsId)
-        return true;
+      int i = 0, iNum = (int32_t) pCtx->pAccessUnitList->uiAvailUnitsNum;
+      while (i < iNum) {
+        PNalUnit pNalUnit = pCtx->pAccessUnitList->pNalUnitsList[i];
+        if (!pNalUnit->sNalData.sVclNal.bSliceHeaderExtFlag) { //non-ext data
+          PSps pNextUsedSps = pNalUnit->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pSps;
+          if (pNextUsedSps->iSpsId == pSps->iSpsId)
+            return true;
+        }
+        ++i;
+      }
     }
   }
   return false;