shithub: openh264

Download patch

ref: 9461ae8388df869acfeeaa4fc26b260711a9959b
parent: 63a546ee08e62cba076fdfc1178016c029126ca6
author: xiaotiansf <xiaotianshimail@gmail.com>
date: Tue Jan 8 07:32:20 EST 2019

Bugzilla 1479656, 1485229 and 1486223 fixes without mixing with other update.

--- a/codec/decoder/core/src/deblocking.cpp
+++ b/codec/decoder/core/src/deblocking.cpp
@@ -148,13 +148,13 @@
     8,  9,  12, 13, 10, 11, 14, 15
   },
 };
-
+//fix Bugzilla 1486223
 #define TC0_TBL_LOOKUP(tc, iIndexA, pBS, bChroma) \
 {\
-  tc[0] = g_kiTc0Table(iIndexA)[pBS[0]] + bChroma;\
-  tc[1] = g_kiTc0Table(iIndexA)[pBS[1]] + bChroma;\
-  tc[2] = g_kiTc0Table(iIndexA)[pBS[2]] + bChroma;\
-  tc[3] = g_kiTc0Table(iIndexA)[pBS[3]] + bChroma;\
+  tc[0] = g_kiTc0Table(iIndexA)[pBS[0] & 3] + bChroma;\
+  tc[1] = g_kiTc0Table(iIndexA)[pBS[1] & 3] + bChroma;\
+  tc[2] = g_kiTc0Table(iIndexA)[pBS[2] & 3] + bChroma;\
+  tc[3] = g_kiTc0Table(iIndexA)[pBS[3] & 3] + bChroma;\
 }
 
 void inline DeblockingBSInsideMBAvsbase (int8_t* pNnzTab, uint8_t nBS[2][4][4], int32_t iLShiftFactor) {
--- a/codec/decoder/core/src/decode_slice.cpp
+++ b/codec/decoder/core/src/decode_slice.cpp
@@ -210,12 +210,6 @@
   } else {
     if (pCtx->pTempDec == NULL)
       pCtx->pTempDec = AllocPicture (pCtx, pCtx->pSps->iMbWidth << 4, pCtx->pSps->iMbHeight << 4);
-    else {
-      if (pCtx->pTempDec->iLinesize[0] != pCtx->pDec->iLinesize[0]) {
-        FreePicture (pCtx->pTempDec, pCtx->pMemAlign);
-        pCtx->pTempDec = AllocPicture (pCtx, pCtx->pSps->iMbWidth << 4, pCtx->pSps->iMbHeight << 4);
-      }
-    }
     uint8_t*   pTempDstYCbCr[3];
     uint8_t*   pDstYCbCr[3];
     pTempDstYCbCr[0] = pCtx->pTempDec->pData[0] + ((iMbY * iLumaStride + iMbX) << 4);
--- a/codec/decoder/core/src/decoder.cpp
+++ b/codec/decoder/core/src/decoder.cpp
@@ -825,7 +825,11 @@
   int32_t iErr = ERR_NONE;
   const int32_t kiPicWidth    = kiMbWidth << 4;
   const int32_t kiPicHeight   = kiMbHeight << 4;
-
+  //fix Bugzilla Bug1479656 reallocate temp dec picture
+  if (pCtx->pTempDec != NULL) {
+    FreePicture (pCtx->pTempDec, pCtx->pMemAlign);
+    pCtx->pTempDec = AllocPicture (pCtx, pCtx->pSps->iMbWidth << 4, pCtx->pSps->iMbHeight << 4);
+  }
   bool bReallocFlag = false;
   iErr = WelsRequestMem (pCtx, kiMbWidth, kiMbHeight, bReallocFlag); // common memory used
   if (ERR_NONE != iErr) {
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -381,10 +381,13 @@
   if (pCurDqLayer->bUseWeightedBiPredIdc && pSliceHeader->pPps->uiWeightedBipredIdc == 2) {
     int32_t iPoc = pSliceHeader->iPicOrderCntLsb;
 
-    if (pSliceHeader->uiRefCount[0] == 1 && pSliceHeader->uiRefCount[1] == 1
-        && pCtx->sRefPic.pRefList[LIST_0][0]->iFramePoc + pCtx->sRefPic.pRefList[LIST_1][0]->iFramePoc == 2 * iPoc) {
-      pCurDqLayer->bUseWeightedBiPredIdc = false;
-      return;
+    //fix Bugzilla 1485229 check if pointers are NULL
+    if (pCtx->sRefPic.pRefList[LIST_0][0] && pCtx->sRefPic.pRefList[LIST_1][0]) {
+      if (pSliceHeader->uiRefCount[0] == 1 && pSliceHeader->uiRefCount[1] == 1
+          && pCtx->sRefPic.pRefList[LIST_0][0]->iFramePoc + pCtx->sRefPic.pRefList[LIST_1][0]->iFramePoc == 2 * iPoc) {
+        pCurDqLayer->bUseWeightedBiPredIdc = false;
+        return;
+      }
     }
 
     pCurDqLayer->pPredWeightTable->uiLumaLog2WeightDenom = 5;