shithub: openh264

Download patch

ref: 155a91406c795b525f20977422b3a8ccdbc94bc5
parent: e041bc6938261a2b4066c538ec838bb086acb7f9
parent: e47a3638af7ca9862b68558d1434ec96ef264b54
author: huili2 <[email protected]>
date: Tue Dec 9 12:11:06 EST 2014

Merge pull request #1599 from HaiboZhu/Debug_Add_subSPS_check

Add subSPS pre-active check in CheckActiveSPS

--- a/codec/decoder/core/src/au_parser.cpp
+++ b/codec/decoder/core/src/au_parser.cpp
@@ -786,18 +786,28 @@
   return NULL;
 }
 
-bool CheckSpsActive (PWelsDecoderContext pCtx, PSps pSps) {
+bool CheckSpsActive (PWelsDecoderContext pCtx, PSps pSps, bool bUseSubsetFlag) {
   for (int i = 0; i < MAX_LAYER_NUM; i++) {
     if (pCtx->pActiveLayerSps[i] == pSps)
       return true;
   }
   // Pre-active, will be used soon
-  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;
+  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;
+    }
+  } 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;
+    }
   }
   return false;
 }
@@ -1127,7 +1137,7 @@
   } else {
     pTmpSps = &pCtx->sSpsBuffer[iSpsId];
   }
-  if (CheckSpsActive (pCtx, pTmpSps)) {
+  if (CheckSpsActive (pCtx, pTmpSps, kbUseSubsetFlag)) {
     // we are overwriting the active sps, copy a temp buffer
     if (kbUseSubsetFlag) {
       if (memcmp (&pCtx->sSubsetSpsBuffer[iSpsId], pSubsetSps, sizeof (SSubsetSps)) != 0) {