History

Merge pull request #1490 from sijchen/after_review

[Encoder] Fixing for large number of slices

ruil2 committed 12 years ago

Commit 8ed4e832 parents b896faa 54c677c8 files · +87 −32Browse files

Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 8 files). Show all

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+31−11
@@ -597,7 +597,7 @@ static void InitMbInfo (sWelsEncCtx* pEnc, SMB* pList, SDqLayer* pLayer, con · 596 unmodified lines
597597 bool bLeftTop;
598598 bool bRightTop;
599599 int32_t iLeftXY, iTopXY, iLeftTopXY, iRightTopXY;
600− uint8_t uiSliceIdc;
600+ uint16_t uiSliceIdc;
601601
602602 pList[iIdx].iMbX = pEnc->pStrideTab->pMbIndexX[kiDlayerId][iIdx];
603603 pList[iIdx].iMbY = pEnc->pStrideTab->pMbIndexY[kiDlayerId][iIdx];
@@ -2272,7 +2272,7 @@ void DynslcUpdateMbNeighbourInfoListForAllSlices (SSliceCtx* pSliceCtx, SMB* pMb · 1668 unmodified lines
22722272 bool bTop;
22732273 bool bLeftTop;
22742274 bool bRightTop;
2275− int32_t uiSliceIdc;
2275+ uint16_t uiSliceIdc;
22762276 int32_t iLeftXY, iTopXY, iLeftTopXY, iRightTopXY;
22772277
22782278 uiSliceIdc = WelsMbToSliceIdc (pSliceCtx, kiMbXY);
@@ -2347,7 +2347,8 @@ void UpdateSlicepEncCtxWithPartition (SSliceCtx* pSliceCtx, int32_t iPartitionNu · 68 unmodified lines
23472347 }
23482348 pSliceCtx->pFirstMbInSlice[i] = iFirstMbIdx;
23492349
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));
23512352
23522353 // for next partition(or pSlice)
23532354 iFirstMbIdx += pSliceCtx->pCountMbNumInSlice[i];
@@ -3924,15 +3925,19 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 1570 unmodified lines
39243925 iMaxSliceNum *= SLICE_NUM_EXPAND_COEF;
39253926
39263927 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");
39283930 return ENC_RETURN_MEMALLOCERR;
3931+ }
39293932 memcpy (pNalList, pCtx->pOut->sNalList, sizeof (SWelsNalRaw) * pCtx->pOut->iCountNals);
39303933 pMA->WelsFree (pCtx->pOut->sNalList, "pOut->sNalList");
39313934 pCtx->pOut->sNalList = pNalList;
39323935
39333936 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");
39353939 return ENC_RETURN_MEMALLOCERR;
3940+ }
39363941 memcpy (pNalLen, pCtx->pOut->pNalLen, sizeof (int32_t) * pCtx->pOut->iCountNals);
39373942 pMA->WelsFree (pCtx->pOut->pNalLen, "pOut->pNalLen");
39383943 pCtx->pOut->pNalLen = pNalLen;
@@ -3948,8 +3953,10 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 9 unmodified lines
39483953 }
39493954
39503955 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");
39523958 return ENC_RETURN_MEMALLOCERR;
3959+ }
39533960 memcpy (pSlice, pCurLayer->sLayerInfo.pSliceInLayer, sizeof (SSlice) * iMaxSliceNumOld);
39543961 int32_t uiSliceIdx;
39553962 uiSliceIdx = iMaxSliceNumOld;
@@ -3963,8 +3970,11 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 7 unmodified lines
39633970 pSliceIdx->pSliceBsa = &pCtx->pSliceBs[uiSliceIdx].sBsWrite;
39643971 else
39653972 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);
39673976 return ENC_RETURN_MEMALLOCERR;
3977+ }
39683978
39693979 pSliceIdx->bSliceHeaderExtFlag = pBaseSlice->bSliceHeaderExtFlag;
39703980 pSHExt->sSliceHeader.iPpsId = pBaseSHExt->sSliceHeader.iPpsId;
@@ -3983,8 +3993,10 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 12 unmodified lines
39833993 pCurLayer->sLayerInfo.pSliceInLayer = pSlice;
39843994
39853995 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");
39873998 return ENC_RETURN_MEMALLOCERR;
3999+ }
39884000 memset (pFirstMbInSlice, 0, sizeof (int16_t) * iMaxSliceNum);
39894001 memcpy (pFirstMbInSlice, pCurLayer->pSliceEncCtx->pFirstMbInSlice, sizeof (int16_t) * iMaxSliceNumOld);
39904002 pMA->WelsFree (pCurLayer->pSliceEncCtx->pFirstMbInSlice, "pSliceSeg->pFirstMbInSlice");
@@ -3992,8 +4004,10 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 1 unmodified line
39924004
39934005 int32_t* pCountMbNumInSlice = (int32_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int32_t),
39944006 "pSliceSeg->pCountMbNumInSlice");
3995− if (NULL == pCountMbNumInSlice)
4007+ if (NULL == pCountMbNumInSlice) {
4008+ WelsLog (&(pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::DynSliceRealloc: realloc pCountMbNumInSlice not successful");
39964009 return ENC_RETURN_MEMALLOCERR;
4010+ }
39974011 memcpy (pCountMbNumInSlice, pCurLayer->pSliceEncCtx->pCountMbNumInSlice, sizeof (int32_t) * iMaxSliceNumOld);
39984012 uiSliceIdx = iMaxSliceNumOld;
39994013 while (uiSliceIdx < iMaxSliceNum) {
@@ -4004,8 +4018,10 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 4 unmodified lines
40044018 pCurLayer->pSliceEncCtx->pCountMbNumInSlice = pCountMbNumInSlice;
40054019
40064020 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");
40084023 return ENC_RETURN_MEMALLOCERR;
4024+ }
40094025 memcpy (pSlcingOverRc, pCtx->pWelsSvcRc->pSlicingOverRc, sizeof (SRCSlicing) * iMaxSliceNumOld);
40104026 uiSliceIdx = iMaxSliceNumOld;
40114027 SRCSlicing* pSORC = &pSlcingOverRc[uiSliceIdx];
@@ -4069,9 +4085,13 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, · 57 unmodified lines
40694085
40704086 if (iSliceIdx >= (pSliceCtx->iMaxSliceNumConstraint - kiSliceIdxStep)) { // insufficient memory in pSliceInLayer[]
40714087 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");
40734091 return ENC_RETURN_MEMALLOCERR;
4092+ }
40744093 } else if (iSliceIdx >= pSliceCtx->iMaxSliceNumConstraint) {
4094+ WelsLog (&(pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::WelsCodeOnePicPartition: iSliceIdx(%d) over iMaxSliceNumConstraint(%d)", iSliceIdx, pSliceCtx->iMaxSliceNumConstraint);
40754095 return ENC_RETURN_MEMALLOCERR;
40764096 }
40774097 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t