History

make error consistence for memory fail

huili2 committed 9 years ago

Commit 4c74cc81 parent 3c2caa46 files · +56 −35Browse files

Showing the changes to codec/decoder/core/src/decoder_core.cpp (1 of 6 files). Show all

Unified · Split

codec/decoder/core/src/decoder_core.cpp+20−8
@@ -106,7 +106,7 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 105 unmodified lines
106106 pSpsBs = bSubSps ? &pCtx->sSubsetSpsBsInfo [iSpsId] : &pCtx->sSpsBsInfo [iSpsId];
107107 pPpsBs = &pCtx->sPpsBsInfo [iPpsId];
108108 if (pDstBuf - pParser->pDstBuff + pSpsBs->uiSpsBsLen + pPpsBs->uiPpsBsLen >= MAX_ACCESS_UNIT_CAPACITY) {
109− WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
109+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
110110 "DecodeFrameConstruction(): sps pps size: (%d %d) too large. Failed to parse. \n", pSpsBs->uiSpsBsLen,
111111 pPpsBs->uiPpsBsLen);
112112 pCtx->iErrorCode |= dsOutOfMemory;
@@ -130,7 +130,7 @@ static inline int32_t DecodeFrameConstruction (PWelsDecoderContext pCtx, uint8_t · 17 unmodified lines
130130 pNalBs = pCurNal->sNalData.sVclNal.pNalPos;
131131 pParser->iNalLenInByte [pParser->iNalNum ++] = iNalLen;
132132 if (pDstBuf - pParser->pDstBuff + iNalLen >= MAX_ACCESS_UNIT_CAPACITY) {
133− WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
133+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR,
134134 "DecodeFrameConstruction(): composed output size (%ld) exceeds (%d). Failed to parse. \n",
135135 (long) (pDstBuf - pParser->pDstBuff + iNalLen), MAX_ACCESS_UNIT_CAPACITY);
136136 pCtx->iErrorCode |= dsOutOfMemory;
@@ -517,8 +517,11 @@ int32_t ExpandBsBuffer (PWelsDecoderContext pCtx, const int kiSrcLen) { · 380 unmodified lines
517517
518518 //Realloc sRawData
519519 uint8_t* pNewBsBuff = static_cast<uint8_t*> (pMa->WelsMallocz (iNewBuffLen, "pCtx->sRawData.pHead"));
520− if (pNewBsBuff == NULL)
520+ if (pNewBsBuff == NULL) {
521+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "ExpandBsBuffer() Failed for malloc pNewBsBuff (%d)", iNewBuffLen);
522+ pCtx->iErrorCode |= dsOutOfMemory;
521523 return ERR_INFO_OUT_OF_MEMORY;
524+ }
522525
523526 //Calculate and set the bs start and end position
524527 for (uint32_t i = 0; i <= pCtx->pAccessUnitList->uiActualUnitsNum; i++) {
@@ -539,8 +542,11 @@ int32_t ExpandBsBuffer (PWelsDecoderContext pCtx, const int kiSrcLen) { · 14 unmodified lines
539542 if (pCtx->pParam->bParseOnly) {
540543 //Realloc sSavedData
541544 uint8_t* pNewSavedBsBuff = static_cast<uint8_t*> (pMa->WelsMallocz (iNewBuffLen, "pCtx->sSavedData.pHead"));
542− if (pNewSavedBsBuff == NULL)
545+ if (pNewSavedBsBuff == NULL) {
546+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "ExpandBsBuffer() Failed for malloc pNewSavedBsBuff (%d)", iNewBuffLen);
547+ pCtx->iErrorCode |= dsOutOfMemory;
543548 return ERR_INFO_OUT_OF_MEMORY;
549+ }
544550
545551 //Copy current buffer status to new buffer
546552 memcpy (pNewSavedBsBuff, pCtx->sSavedData.pHead, pCtx->iMaxBsBufferSizeInByte);
@@ -2250,10 +2256,16 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 1703 unmodified lines
22502256 pLayerInfo.pSubsetSps = pShExt->pSubsetSps;
22512257
22522258 pCtx->pFmo = &pCtx->sFmoList[iPpsId];
2253− if (!FmoParamUpdate (pCtx->pFmo, pLayerInfo.pSps, pLayerInfo.pPps, &pCtx->iActiveFmoNum, pCtx->pMemAlign)) {
2254− pCtx->iErrorCode |= dsBitstreamError;
2255− WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "DecodeCurrentAccessUnit(), FmoParamUpdate failed, eSliceType: %d.",
2256− pSh->eSliceType);
2259+ iRet = FmoParamUpdate (pCtx->pFmo, pLayerInfo.pSps, pLayerInfo.pPps, &pCtx->iActiveFmoNum, pCtx->pMemAlign);
2260+ if (ERR_NONE != iRet) {
2261+ if (iRet == ERR_INFO_OUT_OF_MEMORY) {
2262+ pCtx->iErrorCode |= dsOutOfMemory;
2263+ WelsLog (&(pCtx->sLogCtx), WELS_LOG_ERROR, "DecodeCurrentAccessUnit(), Fmo param alloc failed");
2264+ } else {
2265+ pCtx->iErrorCode |= dsBitstreamError;
2266+ WelsLog(&(pCtx->sLogCtx), WELS_LOG_WARNING, "DecodeCurrentAccessUnit(), FmoParamUpdate failed, eSliceType: %d.",
2267+ pSh->eSliceType);
2268+ }
22572269 return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_FMO_INIT_FAIL);
22582270 }
22592271

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