[Encoder] Fixing for large number of slices
Unified · Split
| @@ -42,6 +42,7 @@ · 41 unmodified lines | ||
| 42 | 42 | |
| 43 | 43 | #include <math.h> |
| 44 | 44 | #include <assert.h> |
| 45 | +#include <string.h> | |
| 45 | 46 | #include "typedefs.h" |
| 46 | 47 | |
| 47 | 48 | |
| @@ -273,8 +274,36 @@ static inline bool WELS_POWER2_IF (uint32_t v) { · 225 unmodified lines | ||
| 273 | 274 | #endif |
| 274 | 275 | |
| 275 | 276 | inline bool CheckInRangeCloseOpen (const int16_t kiCurrent, const int16_t kiMin, const int16_t kiMax) { |
| 276 | −return ((kiCurrent >= kiMin) && (kiCurrent < kiMax)); | |
| 277 | + return ((kiCurrent >= kiMin) && (kiCurrent < kiMax)); | |
| 277 | 278 | } |
| 278 | 279 | |
| 280 | +static inline void WelsSetMemUint32_c (uint32_t* pDst, uint32_t iValue, int32_t iSizeOfData) { | |
| 281 | + for (int i = 0; i < iSizeOfData; i++) { | |
| 282 | + pDst[i] = iValue; | |
| 283 | + } | |
| 284 | +} | |
| 285 | + | |
| 286 | +static inline void WelsSetMemUint16_c (uint16_t* pDst, uint16_t iValue, int32_t iSizeOfData) { | |
| 287 | + for (int i = 0; i < iSizeOfData; i++) { | |
| 288 | + pDst[i] = iValue; | |
| 289 | + } | |
| 290 | +} | |
| 291 | + | |
| 292 | +inline void WelsSetMemMultiplebytes_c (void* pDst, uint32_t iValue, int32_t iSizeOfData, int32_t iDataLengthOfData) { | |
| 293 | + assert (4 == iDataLengthOfData || 2 == iDataLengthOfData || 1 == iDataLengthOfData); | |
| 294 | + | |
| 295 | + // TODO: consider add assembly for these functions | |
| 296 | + if (0 != iValue) { | |
| 297 | + if (4 == iDataLengthOfData) { | |
| 298 | + WelsSetMemUint32_c (static_cast<uint32_t*> (pDst), static_cast<uint32_t> (iValue), iSizeOfData); | |
| 299 | + } else if (2 == iDataLengthOfData) { | |
| 300 | + WelsSetMemUint16_c (static_cast<uint16_t*> (pDst), static_cast<uint16_t> (iValue), iSizeOfData); | |
| 301 | + } else { | |
| 302 | + memset (static_cast<uint8_t*> (pDst), static_cast<uint8_t> (iValue), iSizeOfData); | |
| 303 | + } | |
| 304 | + } else { | |
| 305 | + memset (static_cast<uint8_t*> (pDst), 0, iSizeOfData * iDataLengthOfData); | |
| 306 | + } | |
| 307 | +} | |
| 279 | 308 | |
| 280 | 309 | #endif//WELS_MACRO_UTILIZATIONS_H__ |
| @@ -68,12 +68,12 @@ SMVUnitXY sP16x16Mv; · 67 unmodified lines | ||
| 68 | 68 | |
| 69 | 69 | uint8_t uiLumaQp; // uiLumaQp: pPps->iInitialQp + sSliceHeader->delta_qp + mb->dquant. |
| 70 | 70 | uint8_t uiChromaQp; |
| 71 | −uint8_t uiSliceIdc; // AVC: pFirstMbInSlice?; SVC: (pFirstMbInSlice << 7) | ((uiDependencyId << 4) | uiQualityId); | |
| 71 | +uint16_t uiSliceIdc; // 2^16=65536 > MaxFS(36864) of level 5.1; AVC: pFirstMbInSlice?; SVC: (pFirstMbInSlice << 7) | ((uiDependencyId << 4) | uiQualityId); | |
| 72 | 72 | uint32_t uiChromPredMode; |
| 73 | 73 | int32_t iLumaDQp; |
| 74 | 74 | SMVUnitXY sMvd[4]; |
| 75 | 75 | int32_t iCbpDc; |
| 76 | −uint8_t reserved_filling_bytes[1]; // filling bytes reserved to make structure aligned with 4 bytes, higher cache hit on less structure size by 2 cache lines( 2 * 64 bytes) once hit | |
| 76 | +//uint8_t reserved_filling_bytes[1]; // not deleting this line for further changes of this structure. filling bytes reserved to make structure aligned with 4 bytes, higher cache hit on less structure size by 2 cache lines( 2 * 64 bytes) once hit | |
| 77 | 77 | } SMB, *PMb; |
| 78 | 78 | |
| 79 | 79 | } |
| @@ -80,7 +80,7 @@ int16_t iMbWidth; /* width of picture size in mb */ · 79 unmodified lines | ||
| 80 | 80 | int16_t iMbHeight; /* height of picture size in mb */ |
| 81 | 81 | int16_t iSliceNumInFrame; /* count number of slices in frame; */ |
| 82 | 82 | int32_t iMbNumInFrame; /* count number of MBs in frame */ |
| 83 | −uint8_t* pOverallMbMap; /* overall MB map in frame, store virtual slice idc; */ | |
| 83 | +uint16_t* pOverallMbMap; /* overall MB map in frame, store virtual slice idc; */ | |
| 84 | 84 | int16_t* pFirstMbInSlice; /* first MB address top-left based in every slice respectively; */ |
| 85 | 85 | int32_t* pCountMbNumInSlice; /* count number of MBs in every slice respectively; */ |
| 86 | 86 | uint32_t uiSliceSizeConstraint;/*in byte*/ |
| @@ -140,7 +140,7 @@ void UninitSlicePEncCtx (SSliceCtx* pSliceCtx, CMemoryAlign* pMa); · 53 unmodified lines | ||
| 140 | 140 | * |
| 141 | 141 | * \return uiSliceIdc - successful; (uint8_t)(-1) - failed; |
| 142 | 142 | */ |
| 143 | −uint8_t WelsMbToSliceIdc (SSliceCtx* pSliceCtx, const int16_t kiMbXY); | |
| 143 | +uint16_t WelsMbToSliceIdc (SSliceCtx* pSliceCtx, const int16_t kiMbXY); | |
| 144 | 144 | |
| 145 | 145 | /*! |
| 146 | 146 | * \brief Get first mb in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO) |
| @@ -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 | } |
| @@ -73,7 +73,7 @@ namespace WelsEnc { · 72 unmodified lines | ||
| 73 | 73 | void UpdateMbListNeighborParallel (SSliceCtx* pSliceCtx, |
| 74 | 74 | SMB* pMbList, |
| 75 | 75 | const int32_t uiSliceIdc) { |
| 76 | − const uint8_t* kpMbMap = pSliceCtx->pOverallMbMap; | |
| 76 | + const uint16_t* kpMbMap = pSliceCtx->pOverallMbMap; | |
| 77 | 77 | const int32_t kiMbWidth = pSliceCtx->iMbWidth; |
| 78 | 78 | int32_t iIdx = pSliceCtx->pFirstMbInSlice[uiSliceIdc]; |
| 79 | 79 | const int32_t kiEndMbInSlice = iIdx + pSliceCtx->pCountMbNumInSlice[uiSliceIdc] - 1; |
| @@ -78,7 +78,8 @@ int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SSliceConfig* kpM · 77 unmodified lines | ||
| 78 | 78 | const int16_t kiFirstMb = uiSliceIdx * kiMbWidth; |
| 79 | 79 | pSliceSeg->pCountMbNumInSlice[uiSliceIdx] = kiMbWidth; |
| 80 | 80 | pSliceSeg->pFirstMbInSlice[uiSliceIdx] = kiFirstMb; |
| 81 | − memset (pSliceSeg->pOverallMbMap + kiFirstMb, (uint8_t)uiSliceIdx, kiMbWidth * sizeof (uint8_t)); | |
| 81 | + WelsSetMemMultiplebytes_c(pSliceSeg->pOverallMbMap + kiFirstMb, uiSliceIdx, | |
| 82 | + kiMbWidth, sizeof(uint16_t)); | |
| 82 | 83 | ++ uiSliceIdx; |
| 83 | 84 | } |
| 84 | 85 | |
| @@ -89,7 +90,7 @@ int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SSliceConfig* kpM · 4 unmodified lines | ||
| 89 | 90 | const int32_t* kpSlicesAssignList = (int32_t*) & (kpMso->sSliceArgument.uiSliceMbNum[0]); |
| 90 | 91 | const int32_t kiCountNumMbInFrame = pSliceSeg->iMbNumInFrame; |
| 91 | 92 | const int32_t kiCountSliceNumInFrame = pSliceSeg->iSliceNumInFrame; |
| 92 | − int32_t iSliceIdx = 0; | |
| 93 | + uint16_t iSliceIdx = 0; | |
| 93 | 94 | int16_t iMbIdx = 0; |
| 94 | 95 | |
| 95 | 96 | do { |
| @@ -392,7 +393,7 @@ int32_t InitSliceSegment (SSliceCtx* pSliceSeg, · 296 unmodified lines | ||
| 392 | 393 | } |
| 393 | 394 | |
| 394 | 395 | if (SM_SINGLE_SLICE == uiSliceMode) { |
| 395 | − pSliceSeg->pOverallMbMap = (uint8_t*)pMa->WelsMalloc (kiCountMbNum * sizeof (uint8_t), "pSliceSeg->pOverallMbMap"); | |
| 396 | + pSliceSeg->pOverallMbMap = (uint16_t*)pMa->WelsMalloc (kiCountMbNum * sizeof (uint16_t), "pSliceSeg->pOverallMbMap"); | |
| 396 | 397 | |
| 397 | 398 | WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pOverallMbMap) |
| 398 | 399 | pSliceSeg->iSliceNumInFrame = 1; |
| @@ -419,11 +420,12 @@ int32_t InitSliceSegment (SSliceCtx* pSliceSeg, · 20 unmodified lines | ||
| 419 | 420 | && uiSliceMode != SM_DYN_SLICE && uiSliceMode != SM_AUTO_SLICE) |
| 420 | 421 | return 1; |
| 421 | 422 | |
| 422 | − pSliceSeg->pOverallMbMap = (uint8_t*)pMa->WelsMalloc (kiCountMbNum * sizeof (uint8_t), "pSliceSeg->pOverallMbMap"); | |
| 423 | + pSliceSeg->pOverallMbMap = (uint16_t*)pMa->WelsMalloc (kiCountMbNum * sizeof (uint16_t), "pSliceSeg->pOverallMbMap"); | |
| 423 | 424 | |
| 424 | 425 | WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pOverallMbMap) |
| 425 | 426 | |
| 426 | − memset (pSliceSeg->pOverallMbMap, 0, kiCountMbNum * sizeof (uint8_t)); | |
| 427 | + WelsSetMemMultiplebytes_c(pSliceSeg->pOverallMbMap, 0, kiCountMbNum, sizeof(uint16_t)); | |
| 428 | + | |
| 427 | 429 | //SM_DYN_SLICE: init, set pSliceSeg->iSliceNumInFrame = 1; |
| 428 | 430 | pSliceSeg->iSliceNumInFrame = GetInitialSliceNum (kiMbWidth, kiMbHeight, pMso); |
| 429 | 431 | |
| @@ -550,10 +552,10 @@ void UninitSlicePEncCtx (SSliceCtx* pSliceCtx, CMemoryAlign* pMa) { · 120 unmodified lines | ||
| 550 | 552 | * |
| 551 | 553 | * \return uiSliceIdc - successful; -1 - failed; |
| 552 | 554 | */ |
| 553 | −uint8_t WelsMbToSliceIdc (SSliceCtx* pSliceCtx, const int16_t kiMbXY) { | |
| 555 | +uint16_t WelsMbToSliceIdc (SSliceCtx* pSliceCtx, const int16_t kiMbXY) { | |
| 554 | 556 | if (NULL != pSliceCtx && kiMbXY < pSliceCtx->iMbNumInFrame && kiMbXY >= 0) |
| 555 | 557 | return pSliceCtx->pOverallMbMap[ kiMbXY ]; |
| 556 | − return (uint8_t) (-1); | |
| 558 | + return (uint16_t) (-1); | |
| 557 | 559 | } |
| 558 | 560 | |
| 559 | 561 | /*! |
| @@ -688,7 +690,8 @@ int32_t DynamicAdjustSlicePEncCtxAll (SSliceCtx* pSliceCtx, · 128 unmodified lines | ||
| 688 | 690 | pSliceCtx->pFirstMbInSlice[iSliceIdx] = iFirstMbIdx; |
| 689 | 691 | pSliceCtx->pCountMbNumInSlice[iSliceIdx] = kiSliceRun; |
| 690 | 692 | |
| 691 | − memset (pSliceCtx->pOverallMbMap + iFirstMbIdx, (uint8_t)iSliceIdx, kiSliceRun * sizeof (uint8_t)); | |
| 693 | + WelsSetMemMultiplebytes_c(pSliceCtx->pOverallMbMap + iFirstMbIdx, iSliceIdx, | |
| 694 | + kiSliceRun, sizeof(uint16_t)); | |
| 692 | 695 | |
| 693 | 696 | iFirstMbIdx += kiSliceRun; |
| 694 | 697 | |
| @@ -776,7 +776,7 @@ void UpdateMbNeighbourInfoForNextSlice (SSliceCtx* pSliceCtx, · 775 unmodified lines | ||
| 776 | 776 | bool bLeftTop; |
| 777 | 777 | bool bRightTop; |
| 778 | 778 | int32_t iLeftXY, iTopXY, iLeftTopXY, iRightTopXY; |
| 779 | − const uint8_t kuiSliceIdc = WelsMbToSliceIdc (pSliceCtx, kiMbXY); | |
| 779 | + const uint16_t kuiSliceIdc = WelsMbToSliceIdc (pSliceCtx, kiMbXY); | |
| 780 | 780 | |
| 781 | 781 | pMb->uiSliceIdc = kuiSliceIdc; |
| 782 | 782 | iLeftXY = kiMbXY - 1; |
| @@ -814,9 +814,9 @@ void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSlic · 31 unmodified lines | ||
| 814 | 814 | int32_t iFirstMbIdxOfNextSlice, const int32_t kiLastMbIdxInPartition) { |
| 815 | 815 | SDqLayer* pCurLayer = pEncCtx->pCurDqLayer; |
| 816 | 816 | int32_t iCurMbIdx = pCurMb->iMbXY; |
| 817 | − int32_t iCurSliceIdc = pSliceCtx->pOverallMbMap[ iCurMbIdx ]; | |
| 817 | + uint16_t iCurSliceIdc = pSliceCtx->pOverallMbMap[ iCurMbIdx ]; | |
| 818 | 818 | const int32_t kiSliceIdxStep = pEncCtx->iActiveThreadsNum; |
| 819 | − int32_t iNextSliceIdc = iCurSliceIdc + kiSliceIdxStep; | |
| 819 | + uint16_t iNextSliceIdc = iCurSliceIdc + kiSliceIdxStep; | |
| 820 | 820 | SSlice* pNextSlice = NULL; |
| 821 | 821 | |
| 822 | 822 | SMB* pMbList = pCurLayer->sMbDataP; |
| @@ -839,9 +839,8 @@ void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSlic · 16 unmodified lines | ||
| 839 | 839 | sizeof (SSliceHeaderExt)); // confirmed_safe_unsafe_usage |
| 840 | 840 | |
| 841 | 841 | pSliceCtx->pFirstMbInSlice[iNextSliceIdc] = iFirstMbIdxOfNextSlice; |
| 842 | − | |
| 843 | − memset (pSliceCtx->pOverallMbMap + iFirstMbIdxOfNextSlice, (uint8_t)iNextSliceIdc, | |
| 844 | − (kiLastMbIdxInPartition - iFirstMbIdxOfNextSlice + 1)*sizeof (uint8_t)); | |
| 842 | + WelsSetMemMultiplebytes_c (pSliceCtx->pOverallMbMap + iFirstMbIdxOfNextSlice, iNextSliceIdc, | |
| 843 | + (kiLastMbIdxInPartition - iFirstMbIdxOfNextSlice + 1), sizeof(uint16_t)); | |
| 845 | 844 | |
| 846 | 845 | //DYNAMIC_SLICING_ONE_THREAD: update pMbList slice_neighbor_info |
| 847 | 846 | UpdateMbNeighbourInfoForNextSlice (pSliceCtx, pMbList, iFirstMbIdxOfNextSlice, kiLastMbIdxInPartition); |
| @@ -875,6 +874,10 @@ bool DynSlcJudgeSliceBoundaryStepBack (void* pCtx, void* pSlice, SSliceCtx* pSli · 27 unmodified lines | ||
| 875 | 874 | && JUMPPACKETSIZE_JUDGE (uiLen, iCurMbIdx, pSliceCtx->uiSliceSizeConstraint)) /*jump_avoiding_pack_exceed*/ |
| 876 | 875 | && kbCurMbNotLastMbOfCurPartition) { //decide to add new pSlice |
| 877 | 876 | |
| 877 | + WelsLog (&pEncCtx->sLogCtx, WELS_LOG_DETAIL, | |
| 878 | + "DynSlcJudgeSliceBoundaryStepBack: AddSliceBoundary: iCurMbIdx=%d, uiLen=%d, uiSliceIdx=%d", iCurMbIdx, uiLen, | |
| 879 | + pCurSlice->uiSliceIdx); | |
| 880 | + | |
| 878 | 881 | if (pEncCtx->pSvcParam->iMultipleThreadIdc > 1) { |
| 879 | 882 | WelsMutexLock (&pEncCtx->pSliceThreading->mutexSliceNumUpdate); |
| 880 | 883 | //lock the acessing to this variable: pSliceCtx->iSliceNumInFrame |
| @@ -718,7 +718,7 @@ int32_t RequestScreenBlockFeatureStorage (CMemoryAlign* pMa, const int32_t kiFra · 717 unmodified lines | ||
| 718 | 718 | pScreenBlockFeatureStorage->iIs16x16 = !bIsBlock8x8; |
| 719 | 719 | pScreenBlockFeatureStorage->uiFeatureStrategyIndex = kiFeatureStrategyIndex; |
| 720 | 720 | pScreenBlockFeatureStorage->iActualListSize = kiListSize; |
| 721 | − memset (pScreenBlockFeatureStorage->uiSadCostThreshold, UINT_MAX, BLOCK_SIZE_ALL * sizeof (uint32_t)); | |
| 721 | + WelsSetMemMultiplebytes_c (pScreenBlockFeatureStorage->uiSadCostThreshold, UINT_MAX, BLOCK_SIZE_ALL, sizeof(uint32_t)); | |
| 722 | 722 | pScreenBlockFeatureStorage->bRefBlockFeatureCalculated = false; |
| 723 | 723 | |
| 724 | 724 | return ENC_RETURN_SUCCESS; |