shithub: openh264

Download patch

ref: 3c4279cdd8a9a7c96e2bad95f3ae178aa9910e50
parent: 195d13612ce421c0263416e52299464b4c048cc4
author: huili2 <[email protected]>
date: Wed Oct 22 22:36:08 EDT 2014

fix crash bug of sps/pps

--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -543,7 +543,10 @@
     return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_PPS_ID);
   }
 
-  pPps    = &pCtx->sPpsBuffer[iPpsId];
+  if (pCtx->iOverwriteFlags & OVERWRITE_PPS)
+    pPps    = &pCtx->sPpsBuffer[MAX_PPS_COUNT];
+  else
+    pPps    = &pCtx->sPpsBuffer[iPpsId];
 
   if (pPps->uiNumSliceGroups == 0) {
     WelsLog (pLogCtx, WELS_LOG_WARNING, "Invalid PPS referenced");
@@ -552,7 +555,10 @@
   }
 
   if (kbExtensionFlag) {
-    pSubsetSps	= &pCtx->sSubsetSpsBuffer[pPps->iSpsId];
+    if (pCtx->iOverwriteFlags & OVERWRITE_SUBSETSPS)
+      pSubsetSps	= &pCtx->sSubsetSpsBuffer[MAX_SPS_COUNT];
+    else
+      pSubsetSps	= &pCtx->sSubsetSpsBuffer[pPps->iSpsId];
     pSps		= &pSubsetSps->sSps;
     if (pCtx->bSubspsAvailFlags[pPps->iSpsId] == false) {
       WelsLog (pLogCtx, WELS_LOG_ERROR, "SPS id is invalid!");
@@ -565,7 +571,10 @@
       pCtx->iErrorCode |= dsNoParamSets;
       return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SPS_ID);
     }
-    pSps		= &pCtx->sSpsBuffer[pPps->iSpsId];
+    if (pCtx->iOverwriteFlags & OVERWRITE_SPS)
+      pSps		= &pCtx->sSpsBuffer[MAX_SPS_COUNT];
+    else
+      pSps		= &pCtx->sSpsBuffer[pPps->iSpsId];
   }
   pSliceHead->iPpsId = iPpsId;
   pSliceHead->iSpsId = pPps->iSpsId;