Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 8 files). Show all
Unified · Split
| @@ -597,7 +597,7 @@ static void InitMbInfo (sWelsEncCtx* pEnc, SMB* pList, SDqLayer* pLayer, con · 596 unmodified lines | ||
| 597 | 597 | bool bLeftTop; |
| 598 | 598 | bool bRightTop; |
| 599 | 599 | int32_t iLeftXY, iTopXY, iLeftTopXY, iRightTopXY; |
| 600 | − uint8_t uiSliceIdc; | |
| 600 | + uint16_t uiSliceIdc; | |
| 601 | 601 | |
| 602 | 602 | pList[iIdx].iMbX = pEnc->pStrideTab->pMbIndexX[kiDlayerId][iIdx]; |
| 603 | 603 | pList[iIdx].iMbY = pEnc->pStrideTab->pMbIndexY[kiDlayerId][iIdx]; |
| @@ -2272,7 +2272,7 @@ void DynslcUpdateMbNeighbourInfoListForAllSlices (SSliceCtx* pSliceCtx, SMB* pMb · 1668 unmodified lines | ||
| 2272 | 2272 | bool bTop; |
| 2273 | 2273 | bool bLeftTop; |
| 2274 | 2274 | bool bRightTop; |
| 2275 | − int32_t uiSliceIdc; | |
| 2275 | + uint16_t uiSliceIdc; | |
| 2276 | 2276 | int32_t iLeftXY, iTopXY, iLeftTopXY, iRightTopXY; |
| 2277 | 2277 | |
| 2278 | 2278 | uiSliceIdc = WelsMbToSliceIdc (pSliceCtx, kiMbXY); |
| @@ -2347,7 +2347,8 @@ void UpdateSlicepEncCtxWithPartition (SSliceCtx* pSliceCtx, int32_t iPartitionNu · 68 unmodified lines | ||
| 2347 | 2347 | } |
| 2348 | 2348 | pSliceCtx->pFirstMbInSlice[i] = iFirstMbIdx; |
| 2349 | 2349 | |
| 2350 | − memset (pSliceCtx->pOverallMbMap + iFirstMbIdx, (uint8_t)i, pSliceCtx->pCountMbNumInSlice[i]*sizeof (uint8_t)); | |
| 2350 | + WelsSetMemMultiplebytes_c(pSliceCtx->pOverallMbMap + iFirstMbIdx, i, | |
| 2351 | + pSliceCtx->pCountMbNumInSlice[i], sizeof(uint16_t)); | |
| 2351 | 2352 | |
| 2352 | 2353 | // for next partition(or pSlice) |
| 2353 | 2354 | iFirstMbIdx += pSliceCtx->pCountMbNumInSlice[i]; |
| @@ -3924,15 +3925,19 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 1570 unmodified lines | ||
| 3924 | 3925 | iMaxSliceNum *= SLICE_NUM_EXPAND_COEF; |
| 3925 | 3926 | |
| 3926 | 3927 | SWelsNalRaw* pNalList = (SWelsNalRaw*)pMA->WelsMalloc (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList"); |
| 3927 | − if (NULL == pNalList) | |
| 3928 | + if (NULL == pNalList) { | |
| 3929 | + WelsLog (&(pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::DynSliceRealloc: pNalList is NULL"); | |
| 3928 | 3930 | return ENC_RETURN_MEMALLOCERR; |
| 3931 | + } | |
| 3929 | 3932 | memcpy (pNalList, pCtx->pOut->sNalList, sizeof (SWelsNalRaw) * pCtx->pOut->iCountNals); |
| 3930 | 3933 | pMA->WelsFree (pCtx->pOut->sNalList, "pOut->sNalList"); |
| 3931 | 3934 | pCtx->pOut->sNalList = pNalList; |
| 3932 | 3935 | |
| 3933 | 3936 | int32_t* pNalLen = (int32_t*)pMA->WelsMalloc (iCountNals * sizeof (int32_t), "pOut->pNalLen"); |
| 3934 | − if (NULL == pNalLen) | |
| 3937 | + if (NULL == pNalLen) { | |
| 3938 | + WelsLog (&(pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::DynSliceRealloc: pNalLen is NULL"); | |
| 3935 | 3939 | return ENC_RETURN_MEMALLOCERR; |
| 3940 | + } | |
| 3936 | 3941 | memcpy (pNalLen, pCtx->pOut->pNalLen, sizeof (int32_t) * pCtx->pOut->iCountNals); |
| 3937 | 3942 | pMA->WelsFree (pCtx->pOut->pNalLen, "pOut->pNalLen"); |
| 3938 | 3943 | pCtx->pOut->pNalLen = pNalLen; |
| @@ -3948,8 +3953,10 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 9 unmodified lines | ||
| 3948 | 3953 | } |
| 3949 | 3954 | |
| 3950 | 3955 | SSlice* pSlice = (SSlice*)pMA->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "Slice"); |
| 3951 | − if (NULL == pSlice) | |
| 3956 | + if (NULL == pSlice) { | |
| 3957 | + WelsLog (&(pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::DynSliceRealloc: pSlice is NULL"); | |
| 3952 | 3958 | return ENC_RETURN_MEMALLOCERR; |
| 3959 | + } | |
| 3953 | 3960 | memcpy (pSlice, pCurLayer->sLayerInfo.pSliceInLayer, sizeof (SSlice) * iMaxSliceNumOld); |
| 3954 | 3961 | int32_t uiSliceIdx; |
| 3955 | 3962 | uiSliceIdx = iMaxSliceNumOld; |
| @@ -3963,8 +3970,11 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 7 unmodified lines | ||
| 3963 | 3970 | pSliceIdx->pSliceBsa = &pCtx->pSliceBs[uiSliceIdx].sBsWrite; |
| 3964 | 3971 | else |
| 3965 | 3972 | pSliceIdx->pSliceBsa = &pCtx->pOut->sBsWrite; |
| 3966 | − if (AllocMbCacheAligned (&pSliceIdx->sMbCacheInfo, pMA)) | |
| 3973 | + if (AllocMbCacheAligned (&pSliceIdx->sMbCacheInfo, pMA)) { | |
| 3974 | + WelsLog (&(pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::DynSliceRealloc: realloc MbCache not successful at slice_idx=%d (max-slice=%d)", | |
| 3975 | + uiSliceIdx, iMaxSliceNum); | |
| 3967 | 3976 | return ENC_RETURN_MEMALLOCERR; |
| 3977 | + } | |
| 3968 | 3978 | |
| 3969 | 3979 | pSliceIdx->bSliceHeaderExtFlag = pBaseSlice->bSliceHeaderExtFlag; |
| 3970 | 3980 | pSHExt->sSliceHeader.iPpsId = pBaseSHExt->sSliceHeader.iPpsId; |
| @@ -3983,8 +3993,10 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 12 unmodified lines | ||
| 3983 | 3993 | pCurLayer->sLayerInfo.pSliceInLayer = pSlice; |
| 3984 | 3994 | |
| 3985 | 3995 | int16_t* pFirstMbInSlice = (int16_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int16_t), "pSliceSeg->pFirstMbInSlice"); |
| 3986 | − if (NULL == pFirstMbInSlice) | |
| 3996 | + if (NULL == pFirstMbInSlice) { | |
| 3997 | + WelsLog (&(pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::DynSliceRealloc: pFirstMbInSlice is NULL"); | |
| 3987 | 3998 | return ENC_RETURN_MEMALLOCERR; |
| 3999 | + } | |
| 3988 | 4000 | memset (pFirstMbInSlice, 0, sizeof (int16_t) * iMaxSliceNum); |
| 3989 | 4001 | memcpy (pFirstMbInSlice, pCurLayer->pSliceEncCtx->pFirstMbInSlice, sizeof (int16_t) * iMaxSliceNumOld); |
| 3990 | 4002 | pMA->WelsFree (pCurLayer->pSliceEncCtx->pFirstMbInSlice, "pSliceSeg->pFirstMbInSlice"); |
| @@ -3992,8 +4004,10 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 1 unmodified line | ||
| 3992 | 4004 | |
| 3993 | 4005 | int32_t* pCountMbNumInSlice = (int32_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int32_t), |
| 3994 | 4006 | "pSliceSeg->pCountMbNumInSlice"); |
| 3995 | − if (NULL == pCountMbNumInSlice) | |
| 4007 | + if (NULL == pCountMbNumInSlice) { | |
| 4008 | + WelsLog (&(pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::DynSliceRealloc: realloc pCountMbNumInSlice not successful"); | |
| 3996 | 4009 | return ENC_RETURN_MEMALLOCERR; |
| 4010 | + } | |
| 3997 | 4011 | memcpy (pCountMbNumInSlice, pCurLayer->pSliceEncCtx->pCountMbNumInSlice, sizeof (int32_t) * iMaxSliceNumOld); |
| 3998 | 4012 | uiSliceIdx = iMaxSliceNumOld; |
| 3999 | 4013 | while (uiSliceIdx < iMaxSliceNum) { |
| @@ -4004,8 +4018,10 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 4 unmodified lines | ||
| 4004 | 4018 | pCurLayer->pSliceEncCtx->pCountMbNumInSlice = pCountMbNumInSlice; |
| 4005 | 4019 | |
| 4006 | 4020 | SRCSlicing* pSlcingOverRc = (SRCSlicing*)pMA->WelsMalloc (iMaxSliceNum * sizeof (SRCSlicing), "SlicingOverRC"); |
| 4007 | − if (NULL == pSlcingOverRc) | |
| 4021 | + if (NULL == pSlcingOverRc) { | |
| 4022 | + WelsLog (&(pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::DynSliceRealloc: realloc pSlcingOverRc not successful"); | |
| 4008 | 4023 | return ENC_RETURN_MEMALLOCERR; |
| 4024 | + } | |
| 4009 | 4025 | memcpy (pSlcingOverRc, pCtx->pWelsSvcRc->pSlicingOverRc, sizeof (SRCSlicing) * iMaxSliceNumOld); |
| 4010 | 4026 | uiSliceIdx = iMaxSliceNumOld; |
| 4011 | 4027 | SRCSlicing* pSORC = &pSlcingOverRc[uiSliceIdx]; |
| @@ -4069,9 +4085,13 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, · 57 unmodified lines | ||
| 4069 | 4085 | |
| 4070 | 4086 | if (iSliceIdx >= (pSliceCtx->iMaxSliceNumConstraint - kiSliceIdxStep)) { // insufficient memory in pSliceInLayer[] |
| 4071 | 4087 | if (pCtx->iActiveThreadsNum == 1) { |
| 4072 | − if (DynSliceRealloc (pCtx, pFrameBSInfo, pLayerBsInfo)) //only single thread support re-alloc now | |
| 4088 | + //only single thread support re-alloc now | |
| 4089 | + if (DynSliceRealloc (pCtx, pFrameBSInfo, pLayerBsInfo)) { | |
| 4090 | + WelsLog (&(pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::WelsCodeOnePicPartition: DynSliceRealloc not successful"); | |
| 4073 | 4091 | return ENC_RETURN_MEMALLOCERR; |
| 4092 | + } | |
| 4074 | 4093 | } else if (iSliceIdx >= pSliceCtx->iMaxSliceNumConstraint) { |
| 4094 | + WelsLog (&(pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::WelsCodeOnePicPartition: iSliceIdx(%d) over iMaxSliceNumConstraint(%d)", iSliceIdx, pSliceCtx->iMaxSliceNumConstraint); | |
| 4075 | 4095 | return ENC_RETURN_MEMALLOCERR; |
| 4076 | 4096 | } |
| 4077 | 4097 | } |