shithub: openh264

Download patch

ref: 97c9ffc45c1e583527ab4425a3f6a2cb4eb778b1
parent: cd0ffbd45b2c4b1a38aab8d4ab1dde27e01d4d1f
parent: c923dc6cc32124425cf42ca7f295c075bd519c49
author: sijchen <sijchen@cisco.com>
date: Tue Apr 25 14:02:49 EDT 2017

Merge pull request #2720 from shihuade/MultiThread_V11.2_BufferStep

bug fixes: wrong lastcoded slice buffer,and tune reallocate buffer step

--- a/codec/encoder/core/src/svc_encode_slice.cpp
+++ b/codec/encoder/core/src/svc_encode_slice.cpp
@@ -1284,7 +1284,7 @@
     return ENC_RETURN_SUCCESS;
   }
 
-  int32_t iPartitionID     = pLastCodedSlice->iSliceIdx / pCtx->iActiveThreadsNum;
+  int32_t iPartitionID     = pLastCodedSlice->iSliceIdx % pCtx->iActiveThreadsNum;
   int32_t iMBNumInPatition = pCtx->pCurDqLayer->EndMbIdxOfPartition[iPartitionID]
                              - pCtx->pCurDqLayer->FirstMbIdxOfPartition[iPartitionID] + 1;
   int32_t iLeftMBNum       = pCtx->pCurDqLayer->EndMbIdxOfPartition[iPartitionID]
@@ -1292,6 +1292,7 @@
   int32_t iIncreaseSlicNum = (iLeftMBNum * INT_MULTIPLY / iMBNumInPatition) * iMaxSliceNumOld;
 
   iIncreaseSlicNum  = ( 0 == (iIncreaseSlicNum / INT_MULTIPLY) ) ? 1 : (iIncreaseSlicNum / INT_MULTIPLY);
+  iIncreaseSlicNum  = (iIncreaseSlicNum < iMaxSliceNumOld / 2) ? (iMaxSliceNumOld / 2) : iIncreaseSlicNum;
   iMaxSliceNumNew   = iMaxSliceNumOld + iIncreaseSlicNum;
 
   return ENC_RETURN_SUCCESS;
@@ -1302,9 +1303,10 @@
                                  const int32_t kiDlayerIdx,
                                  const int32_t KiSlcBuffIdx) {
   int32_t iMaxSliceNum    = pDqLayer->sSliceBufferInfo[KiSlcBuffIdx].iMaxSliceNum;
+  int32_t iCodedSliceNum  = pDqLayer->sSliceBufferInfo[KiSlcBuffIdx].iCodedSliceNum;
   int32_t iMaxSliceNumNew = 0;
   int32_t iRet            = 0;
-  SSlice* pLastCodedSlice = &pDqLayer->sSliceBufferInfo[KiSlcBuffIdx].pSliceBuffer [iMaxSliceNum - 1];
+  SSlice* pLastCodedSlice = &pDqLayer->sSliceBufferInfo[KiSlcBuffIdx].pSliceBuffer [iCodedSliceNum - 1];
   SSliceArgument* pSliceArgument = & pCtx->pSvcParam->sSpatialLayers[kiDlayerIdx].sSliceArgument;
 
   iRet = CalculateNewSliceNum (pCtx,