History

use WelsMallocz instead of WelsMalloc to avoid non-null pointer at init

sijchen committed 10 years ago

Commit 36722c51 parent 71aa5331 file · +23 −23Browse files

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

Unified · Split

codec/encoder/core/src/encoder_ext.cpp+23−23
@@ -878,7 +878,7 @@ int32_t InitMbListD (sWelsEncCtx** ppCtx) { · 877 unmodified lines
878878 iOverallMbNum += iMbSize[i];
879879 }
880880
881− (*ppCtx)->ppMbListD = static_cast<SMB**> ((*ppCtx)->pMemAlign->WelsMalloc (iNumDlayer * sizeof (SMB*), "ppMbListD"));
881+ (*ppCtx)->ppMbListD = static_cast<SMB**> ((*ppCtx)->pMemAlign->WelsMallocz (iNumDlayer * sizeof (SMB*), "ppMbListD"));
882882 (*ppCtx)->ppMbListD[0] = NULL;
883883 WELS_VERIFY_RETURN_PROC_IF (1, (*ppCtx)->ppMbListD == NULL, FreeMemorySvc (ppCtx));
884884 (*ppCtx)->ppMbListD[0] = static_cast<SMB*> ((*ppCtx)->pMemAlign->WelsMallocz (iOverallMbNum * sizeof (SMB),
@@ -896,23 +896,23 @@ int32_t InitMbListD (sWelsEncCtx** ppCtx) { · 11 unmodified lines
896896 }
897897
898898 int32_t AllocMbCacheAligned (SMbCache* pMbCache, CMemoryAlign* pMa) {
899− pMbCache->pCoeffLevel = (int16_t*)pMa->WelsMalloc (MB_COEFF_LIST_SIZE * sizeof (int16_t), "pMbCache->pCoeffLevel");
899+ pMbCache->pCoeffLevel = (int16_t*)pMa->WelsMallocz (MB_COEFF_LIST_SIZE * sizeof (int16_t), "pMbCache->pCoeffLevel");
900900 WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pCoeffLevel));
901− pMbCache->pMemPredMb = (uint8_t*)pMa->WelsMalloc (2 * 256 * sizeof (uint8_t), "pMbCache->pMemPredMb");
901+ pMbCache->pMemPredMb = (uint8_t*)pMa->WelsMallocz (2 * 256 * sizeof (uint8_t), "pMbCache->pMemPredMb");
902902 WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pMemPredMb));
903− pMbCache->pSkipMb = (uint8_t*)pMa->WelsMalloc (384 * sizeof (uint8_t), "pMbCache->pSkipMb");
903+ pMbCache->pSkipMb = (uint8_t*)pMa->WelsMallocz (384 * sizeof (uint8_t), "pMbCache->pSkipMb");
904904 WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pSkipMb));
905− pMbCache->pMemPredBlk4 = (uint8_t*)pMa->WelsMalloc (2 * 16 * sizeof (uint8_t), "pMbCache->pMemPredBlk4");
905+ pMbCache->pMemPredBlk4 = (uint8_t*)pMa->WelsMallocz (2 * 16 * sizeof (uint8_t), "pMbCache->pMemPredBlk4");
906906 WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pMemPredBlk4));
907− pMbCache->pBufferInterPredMe = (uint8_t*)pMa->WelsMalloc (4 * 640 * sizeof (uint8_t), "pMbCache->pBufferInterPredMe");
907+ pMbCache->pBufferInterPredMe = (uint8_t*)pMa->WelsMallocz (4 * 640 * sizeof (uint8_t), "pMbCache->pBufferInterPredMe");
908908 WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pBufferInterPredMe));
909− pMbCache->pPrevIntra4x4PredModeFlag = (bool*)pMa->WelsMalloc (16 * sizeof (bool),
909+ pMbCache->pPrevIntra4x4PredModeFlag = (bool*)pMa->WelsMallocz (16 * sizeof (bool),
910910 "pMbCache->pPrevIntra4x4PredModeFlag");
911911 WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pPrevIntra4x4PredModeFlag));
912− pMbCache->pRemIntra4x4PredModeFlag = (int8_t*)pMa->WelsMalloc (16 * sizeof (int8_t),
912+ pMbCache->pRemIntra4x4PredModeFlag = (int8_t*)pMa->WelsMallocz (16 * sizeof (int8_t),
913913 "pMbCache->pRemIntra4x4PredModeFlag");
914914 WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pRemIntra4x4PredModeFlag));
915− pMbCache->pDct = (SDCTCoeff*)pMa->WelsMalloc (sizeof (SDCTCoeff), "pMbCache->pDct");
915+ pMbCache->pDct = (SDCTCoeff*)pMa->WelsMallocz (sizeof (SDCTCoeff), "pMbCache->pDct");
916916 WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pDct));
917917 return 0;
918918 }
@@ -1294,10 +1294,10 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 375 unmodified lines
12941294 // for dynamically malloc for parameter sets memory instead of maximal items for standard to reduce size, 3/18/2010
12951295 const int32_t kiNeededSpsNum = (*ppCtx)->GetNeededSpsNum();
12961296 const int32_t kiNeededSubsetSpsNum = (*ppCtx)->GetNeededSubsetSpsNum();
1297− (*ppCtx)->pSpsArray = (SWelsSPS*)pMa->WelsMalloc (kiNeededSpsNum * sizeof (SWelsSPS), "pSpsArray");
1297+ (*ppCtx)->pSpsArray = (SWelsSPS*)pMa->WelsMallocz (kiNeededSpsNum * sizeof (SWelsSPS), "pSpsArray");
12981298 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSpsArray), FreeMemorySvc (ppCtx))
12991299 if (kiNeededSubsetSpsNum > 0) {
1300− (*ppCtx)->pSubsetArray = (SSubsetSps*)pMa->WelsMalloc (kiNeededSubsetSpsNum * sizeof (SSubsetSps), "pSubsetArray");
1300+ (*ppCtx)->pSubsetArray = (SSubsetSps*)pMa->WelsMallocz (kiNeededSubsetSpsNum * sizeof (SSubsetSps), "pSubsetArray");
13011301 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSubsetArray), FreeMemorySvc (ppCtx))
13021302 } else {
13031303 (*ppCtx)->pSubsetArray = NULL;
@@ -1317,7 +1317,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 13 unmodified lines
13171317
13181318 // PPS
13191319 const int32_t kiNeededPpsNum = (*ppCtx)->GetNeededPpsNum();
1320− (*ppCtx)->pPPSArray = (SWelsPPS*)pMa->WelsMalloc (kiNeededPpsNum * sizeof (SWelsPPS), "pPPSArray");
1320+ (*ppCtx)->pPPSArray = (SWelsPPS*)pMa->WelsMallocz (kiNeededPpsNum * sizeof (SWelsPPS), "pPPSArray");
13211321 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pPPSArray), FreeMemorySvc (ppCtx))
13221322
13231323 // copy from existing if the pointer exists
@@ -1493,7 +1493,7 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers · 169 unmodified lines
14931493 if (kiNumSpatialLayers <= 0 || kiNumSpatialLayers > MAX_DEPENDENCY_LAYER)
14941494 return 1;
14951495
1496− pPtr = (SStrideTables*)pMa->WelsMalloc (sizeof (SStrideTables), "SStrideTables");
1496+ pPtr = (SStrideTables*)pMa->WelsMallocz (sizeof (SStrideTables), "SStrideTables");
14971497 if (NULL == pPtr)
14981498 return 1;
14991499 (*ppCtx)->pStrideTab = pPtr;
@@ -1540,7 +1540,7 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers · 40 unmodified lines
15401540
15411541 iNeedAllocSize = iSizeDec + iSizeEnc + (iUnit2Size << 1);
15421542
1543− pBase = (uint8_t*)pMa->WelsMalloc (iNeedAllocSize, "pBase");
1543+ pBase = (uint8_t*)pMa->WelsMallocz (iNeedAllocSize, "pBase");
15441544 if (NULL == pBase) {
15451545 return 1;
15461546 }
@@ -1639,7 +1639,7 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers · 92 unmodified lines
16391639 iMaxMbWidth = WELS_ALIGN (iMaxMbWidth, 4); // 4 loops for int16_t required introduced as below
16401640 iRowSize = iMaxMbWidth * sizeof (int16_t);
16411641
1642− pTmpRow = (int16_t*)pMa->WelsMalloc (iRowSize, "pTmpRow");
1642+ pTmpRow = (int16_t*)pMa->WelsMallocz (iRowSize, "pTmpRow");
16431643 if (NULL == pTmpRow) {
16441644 return 1;
16451645 }
@@ -1860,12 +1860,12 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 214 unmodified lines
18601860 MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN));
18611861
18621862 // Output
1863− (*ppCtx)->pOut = (SWelsEncoderOutput*)pMa->WelsMalloc (sizeof (SWelsEncoderOutput), "SWelsEncoderOutput");
1863+ (*ppCtx)->pOut = (SWelsEncoderOutput*)pMa->WelsMallocz (sizeof (SWelsEncoderOutput), "SWelsEncoderOutput");
18641864 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut), FreeMemorySvc (ppCtx))
1865− (*ppCtx)->pOut->pBsBuffer = (uint8_t*)pMa->WelsMalloc (iCountBsLen, "pOut->pBsBuffer");
1865+ (*ppCtx)->pOut->pBsBuffer = (uint8_t*)pMa->WelsMallocz (iCountBsLen, "pOut->pBsBuffer");
18661866 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->pBsBuffer), FreeMemorySvc (ppCtx))
18671867 (*ppCtx)->pOut->uiSize = iCountBsLen;
1868− (*ppCtx)->pOut->sNalList = (SWelsNalRaw*)pMa->WelsMalloc (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList");
1868+ (*ppCtx)->pOut->sNalList = (SWelsNalRaw*)pMa->WelsMallocz (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList");
18691869 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->sNalList), FreeMemorySvc (ppCtx))
18701870 (*ppCtx)->pOut->pNalLen = (int32_t*)pMa->WelsMallocz (iCountNals * sizeof (int32_t), "pOut->pNalLen");
18711871 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pOut->pNalLen), FreeMemorySvc (ppCtx))
@@ -1909,7 +1909,7 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 37 unmodified lines
19091909
19101910 (*ppCtx)->iGlobalQp = 26; // global qp in default
19111911
1912− (*ppCtx)->pLtr = (SLTRState*)pMa->WelsMalloc (kiNumDependencyLayers * sizeof (SLTRState), "SLTRState");
1912+ (*ppCtx)->pLtr = (SLTRState*)pMa->WelsMallocz (kiNumDependencyLayers * sizeof (SLTRState), "SLTRState");
19131913 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pLtr), FreeMemorySvc (ppCtx))
19141914 int32_t i = 0;
19151915 for (i = 0; i < kiNumDependencyLayers; i++) {
@@ -2535,7 +2535,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 619 unmodified lines
25352535 }
25362536 memcpy (pCtx->pSvcParam, pCodingParam, sizeof (SWelsSvcCodingParam)); // confirmed_safe_unsafe_usage
25372537
2538− pCtx->pFuncList = (SWelsFuncPtrList*)pCtx->pMemAlign->WelsMalloc (sizeof (SWelsFuncPtrList), "SWelsFuncPtrList");
2538+ pCtx->pFuncList = (SWelsFuncPtrList*)pCtx->pMemAlign->WelsMallocz (sizeof (SWelsFuncPtrList), "SWelsFuncPtrList");
25392539 if (NULL == pCtx->pFuncList) {
25402540 WelsUninitEncoderExt (&pCtx);
25412541 return 1;
@@ -4787,7 +4787,7 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 2245 unmodified lines
47874787 iCountNals += iMaxSliceNum * (pCtx->pSvcParam->iSpatialLayerNum + pCtx->bNeedPrefixNalFlag);
47884788 iMaxSliceNum *= SLICE_NUM_EXPAND_COEF;
47894789
4790− SWelsNalRaw* pNalList = (SWelsNalRaw*)pMA->WelsMalloc (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList");
4790+ SWelsNalRaw* pNalList = (SWelsNalRaw*)pMA->WelsMallocz (iCountNals * sizeof (SWelsNalRaw), "pOut->sNalList");
47914791 if (NULL == pNalList) {
47924792 WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::DynSliceRealloc: pNalList is NULL");
47934793 return ENC_RETURN_MEMALLOCERR;
@@ -4796,7 +4796,7 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 2 unmodified lines
47964796 pMA->WelsFree (pCtx->pOut->sNalList, "pOut->sNalList");
47974797 pCtx->pOut->sNalList = pNalList;
47984798
4799− int32_t* pNalLen = (int32_t*)pMA->WelsMalloc (iCountNals * sizeof (int32_t), "pOut->pNalLen");
4799+ int32_t* pNalLen = (int32_t*)pMA->WelsMallocz (iCountNals * sizeof (int32_t), "pOut->pNalLen");
48004800 if (NULL == pNalLen) {
48014801 WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::DynSliceRealloc: pNalLen is NULL");
48024802 return ENC_RETURN_MEMALLOCERR;
@@ -4858,7 +4858,7 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 55 unmodified lines
48584858
48594859 //deal with rate control variables
48604860 const int32_t kiCurDid = pCtx->uiDependencyId;
4861− SRCSlicing* pSlcingOverRc = (SRCSlicing*)pMA->WelsMalloc (iMaxSliceNum * sizeof (SRCSlicing), "SlicingOverRC");
4861+ SRCSlicing* pSlcingOverRc = (SRCSlicing*)pMA->WelsMallocz (iMaxSliceNum * sizeof (SRCSlicing), "SlicingOverRC");
48624862 if (NULL == pSlcingOverRc) {
48634863 WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
48644864 "CWelsH264SVCEncoder::DynSliceRealloc: realloc pSlcingOverRc not successful");

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