Showing the changes to codec/encoder/core/src/svc_encode_slice.cpp (1 of 4 files). Show all
Unified · Split
| @@ -1061,6 +1061,18 @@ int32_t InitSliceInLayer (sWelsEncCtx* pCtx, · 1060 unmodified lines | |||
| 1061 | return ENC_RETURN_MEMALLOCERR; | 1061 | return ENC_RETURN_MEMALLOCERR; |
| 1062 | } | 1062 | } |
| 1063 | 1063 | ||
| 1064 | pDqLayer->pFirstMbIdxOfSlice = (int32_t*)pMa->WelsMallocz (sizeof (int32_t*) * iMaxSliceNum, "pFirstMbIdxOfSlice"); | ||
| 1065 | if (NULL == pDqLayer->pFirstMbIdxOfSlice) { | ||
| 1066 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->pFirstMbIdxOfSlice is NULL"); | ||
| 1067 | return ENC_RETURN_MEMALLOCERR; | ||
| 1068 | } | ||
| 1069 | |||
| 1070 | pDqLayer->pCountMbNumInSlice = (int32_t*)pMa->WelsMallocz (sizeof (int32_t*) * iMaxSliceNum, "pCountMbNumInSlice"); | ||
| 1071 | if (NULL == pDqLayer->pCountMbNumInSlice) { | ||
| 1072 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->pCountMbNumInSlice is NULL"); | ||
| 1073 | return ENC_RETURN_MEMALLOCERR; | ||
| 1074 | } | ||
| 1075 | |||
| 1064 | InitSliceThreadInfo (pCtx, | 1076 | InitSliceThreadInfo (pCtx, |
| 1065 | pDqLayer, | 1077 | pDqLayer, |
| 1066 | kiDlayerIndex, | 1078 | kiDlayerIndex, |
| @@ -1278,6 +1290,8 @@ int32_t ReallocSliceBuffer (sWelsEncCtx* pCtx) { · 211 unmodified lines | |||
| 1278 | int32_t iSliceIdx = 0; | 1290 | int32_t iSliceIdx = 0; |
| 1279 | const int32_t kiCurDid = pCtx->uiDependencyId; | 1291 | const int32_t kiCurDid = pCtx->uiDependencyId; |
| 1280 | 1292 | ||
| 1293 | int32_t* pFirstMbIdxofSlice = NULL; | ||
| 1294 | int32_t* pCountMbNumInSlice = NULL; | ||
| 1281 | SSlice* pLastCodedSlice = pCurLayer->sSliceThreadInfo.pSliceInThread[0] + (iMaxSliceNumOld - 1); | 1295 | SSlice* pLastCodedSlice = pCurLayer->sSliceThreadInfo.pSliceInThread[0] + (iMaxSliceNumOld - 1); |
| 1282 | SSliceArgument* pSliceArgument = & pCtx->pSvcParam->sSpatialLayers[kiCurDid].sSliceArgument; | 1296 | SSliceArgument* pSliceArgument = & pCtx->pSvcParam->sSpatialLayers[kiCurDid].sSliceArgument; |
| 1283 | iRet = CalculateNewSliceNum (pCurLayer, | 1297 | iRet = CalculateNewSliceNum (pCurLayer, |
| @@ -1307,6 +1321,28 @@ int32_t ReallocSliceBuffer (sWelsEncCtx* pCtx) { · 23 unmodified lines | |||
| 1307 | pMA->WelsFree (pCurLayer->ppSliceInLayer, "ppSliceInLayer"); | 1321 | pMA->WelsFree (pCurLayer->ppSliceInLayer, "ppSliceInLayer"); |
| 1308 | pCurLayer->ppSliceInLayer = ppSlice; | 1322 | pCurLayer->ppSliceInLayer = ppSlice; |
| 1309 | 1323 | ||
| 1324 | // update for pFirstMbIdxInSlice | ||
| 1325 | pFirstMbIdxofSlice = (int32_t*)pMA->WelsMallocz (sizeof (int32_t*) * iMaxSliceNumNew, "pFirstMbIdxofSlice"); | ||
| 1326 | if (NULL == pFirstMbIdxofSlice) { | ||
| 1327 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::ReallocSliceBuffer: pFirstMbIdxofSlice is NULL"); | ||
| 1328 | return ENC_RETURN_MEMALLOCERR; | ||
| 1329 | } | ||
| 1330 | memset (pFirstMbIdxofSlice, 0, sizeof(int32_t) * iMaxSliceNumNew); | ||
| 1331 | memcpy (pFirstMbIdxofSlice, pCurLayer->pFirstMbIdxOfSlice, sizeof (int32_t) * iMaxSliceNumOld); | ||
| 1332 | pMA->WelsFree (pCurLayer->pFirstMbIdxOfSlice, "pFirstMbIdxofSlice"); | ||
| 1333 | pCurLayer->pFirstMbIdxOfSlice = pFirstMbIdxofSlice; | ||
| 1334 | |||
| 1335 | // update for pCountMbNumInSlice | ||
| 1336 | pCountMbNumInSlice = (int32_t*)pMA->WelsMallocz (sizeof (int32_t*) * iMaxSliceNumNew, "pCountMbNumInSlice"); | ||
| 1337 | if (NULL == pCountMbNumInSlice) { | ||
| 1338 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::ReallocSliceBuffer: pCountMbNumInSlice is NULL"); | ||
| 1339 | return ENC_RETURN_MEMALLOCERR; | ||
| 1340 | } | ||
| 1341 | memset (pCountMbNumInSlice, 0, sizeof(int32_t) * iMaxSliceNumNew); | ||
| 1342 | memcpy (pCountMbNumInSlice, pCurLayer->pCountMbNumInSlice, sizeof (int32_t) * iMaxSliceNumOld); | ||
| 1343 | pMA->WelsFree (pCurLayer->pCountMbNumInSlice, "pCountMbNumInSlice"); | ||
| 1344 | pCurLayer->pCountMbNumInSlice = pCountMbNumInSlice; | ||
| 1345 | |||
| 1310 | for (iSliceIdx = 0; iSliceIdx < iMaxSliceNumNew; iSliceIdx++) { | 1346 | for (iSliceIdx = 0; iSliceIdx < iMaxSliceNumNew; iSliceIdx++) { |
| 1311 | pCurLayer->ppSliceInLayer[iSliceIdx] = pCurLayer->sSliceThreadInfo.pSliceInThread[0] + iSliceIdx; | 1347 | pCurLayer->ppSliceInLayer[iSliceIdx] = pCurLayer->sSliceThreadInfo.pSliceInThread[0] + iSliceIdx; |
| 1312 | } | 1348 | } |