shithub: openh264

Download patch

ref: 73647654a1619809aa11b6261fda94405c3d0bf1
parent: 1d357ef65360f0ea72a3d3ddd9f1af3cc6373511
parent: 9461ae8388df869acfeeaa4fc26b260711a9959b
author: huili2 <[email protected]>
date: Thu Jan 10 09:17:11 EST 2019

Merge pull request #3085 from xiaotiansf/Bugzilla

Bugzilla 1479656, 1485229 and 1486223 fixes without mixing with other…

--- 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;