shithub: openh264

Download patch

ref: 6b503843ec8ae27185180089365dd252e647ac7e
parent: 11e0fc837681a20e57a6ce3d5d5d77cfcca83da0
parent: bc8dfcd1f46cf03bc91971c7e4d56f48230280de
author: huili2 <huili2@cisco.com>
date: Wed Jul 29 05:56:50 EDT 2015

Merge pull request #2054 from HaiboZhu/Bugfix_pps_update_logic

Fix the pps update logic error

--- a/codec/decoder/core/src/au_parser.cpp
+++ b/codec/decoder/core/src/au_parser.cpp
@@ -1395,18 +1395,13 @@
                                   ERR_INFO_INVALID_CHROMA_QP_INDEX_OFFSET));
   }
 
-  if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
-    PNalUnit pLastNalUnit = pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum - 1];
-    PPps pLastPps = pLastNalUnit->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader.pPps;
-    // the active pps is overwrite, write to a temp place
-    if (pLastPps == &pCtx->sPpsBuffer[uiPpsId] && memcmp (&pCtx->sPpsBuffer[uiPpsId], pPps, sizeof (*pPps)) != 0) {
+  if (pCtx->pPps != NULL && pCtx->pPps->iPpsId == pPps->iPpsId) {
+    if (memcmp (pCtx->pPps, pPps, sizeof (*pPps)) != 0) {
       memcpy (&pCtx->sPpsBuffer[MAX_PPS_COUNT], pPps, sizeof (SPps));
       pCtx->iOverwriteFlags |= OVERWRITE_PPS;
       pCtx->bAuReadyFlag = true;
-      pCtx->pAccessUnitList->uiEndPos = pCtx->pAccessUnitList->uiAvailUnitsNum - 1;
-    } else {
-      memcpy (&pCtx->sPpsBuffer[uiPpsId], pPps, sizeof (SPps));
-      pCtx->bPpsAvailFlags[uiPpsId] = true;
+      pCtx->pAccessUnitList->uiEndPos = (pCtx->pAccessUnitList->uiAvailUnitsNum > 0 ? (pCtx->pAccessUnitList->uiAvailUnitsNum
+                                         - 1) : 0);
     }
   } else {
     memcpy (&pCtx->sPpsBuffer[uiPpsId], pPps, sizeof (SPps));