This function actually zero-initializes the allocated memory, thus make this clear in the function name. This makes the function name match the same behaviour in the encoder.
Showing the changes to codec/decoder/core/src/decoder_core.cpp (1 of 12 files). Show all
Unified · Split
| @@ -322,14 +322,14 @@ int32_t InitBsBuffer (PWelsDecoderContext pCtx) { · 321 unmodified lines | |||
| 322 | return ERR_INFO_INVALID_PTR; | 322 | return ERR_INFO_INVALID_PTR; |
| 323 | 323 | ||
| 324 | pCtx->iMaxBsBufferSizeInByte = MIN_ACCESS_UNIT_CAPACITY * MAX_BUFFERED_NUM; | 324 | pCtx->iMaxBsBufferSizeInByte = MIN_ACCESS_UNIT_CAPACITY * MAX_BUFFERED_NUM; |
| 325 | if ((pCtx->sRawData.pHead = static_cast<uint8_t*> (WelsMalloc (pCtx->iMaxBsBufferSizeInByte, | 325 | if ((pCtx->sRawData.pHead = static_cast<uint8_t*> (WelsMallocz (pCtx->iMaxBsBufferSizeInByte, |
| 326 | "pCtx->sRawData.pHead"))) == NULL) { | 326 | "pCtx->sRawData.pHead"))) == NULL) { |
| 327 | return ERR_INFO_OUT_OF_MEMORY; | 327 | return ERR_INFO_OUT_OF_MEMORY; |
| 328 | } | 328 | } |
| 329 | pCtx->sRawData.pStartPos = pCtx->sRawData.pCurPos = pCtx->sRawData.pHead; | 329 | pCtx->sRawData.pStartPos = pCtx->sRawData.pCurPos = pCtx->sRawData.pHead; |
| 330 | pCtx->sRawData.pEnd = pCtx->sRawData.pHead + pCtx->iMaxBsBufferSizeInByte; | 330 | pCtx->sRawData.pEnd = pCtx->sRawData.pHead + pCtx->iMaxBsBufferSizeInByte; |
| 331 | if (pCtx->bParseOnly) { | 331 | if (pCtx->bParseOnly) { |
| 332 | if ((pCtx->sSavedData.pHead = static_cast<uint8_t*> (WelsMalloc (pCtx->iMaxBsBufferSizeInByte, | 332 | if ((pCtx->sSavedData.pHead = static_cast<uint8_t*> (WelsMallocz (pCtx->iMaxBsBufferSizeInByte, |
| 333 | "pCtx->sSavedData.pHead"))) == NULL) { | 333 | "pCtx->sSavedData.pHead"))) == NULL) { |
| 334 | return ERR_INFO_OUT_OF_MEMORY; | 334 | return ERR_INFO_OUT_OF_MEMORY; |
| 335 | } | 335 | } |
| @@ -345,7 +345,7 @@ int32_t ExpandBsBuffer (PWelsDecoderContext pCtx, const int kiSrcLen) { · 9 unmodified lines | |||
| 345 | int32_t iExpandStepShift = 1; | 345 | int32_t iExpandStepShift = 1; |
| 346 | int32_t iNewBuffLen = WELS_MAX ((kiSrcLen * MAX_BUFFERED_NUM), (pCtx->iMaxBsBufferSizeInByte << iExpandStepShift)); | 346 | int32_t iNewBuffLen = WELS_MAX ((kiSrcLen * MAX_BUFFERED_NUM), (pCtx->iMaxBsBufferSizeInByte << iExpandStepShift)); |
| 347 | //allocate new bs buffer | 347 | //allocate new bs buffer |
| 348 | uint8_t* pNewBsBuff = static_cast<uint8_t*> (WelsMalloc (iNewBuffLen, "pCtx->sRawData.pHead")); | 348 | uint8_t* pNewBsBuff = static_cast<uint8_t*> (WelsMallocz (iNewBuffLen, "pCtx->sRawData.pHead")); |
| 349 | if (pNewBsBuff == NULL) | 349 | if (pNewBsBuff == NULL) |
| 350 | return ERR_INFO_OUT_OF_MEMORY; | 350 | return ERR_INFO_OUT_OF_MEMORY; |
| 351 | 351 | ||
| @@ -1064,56 +1064,56 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 712 unmodified lines | |||
| 1064 | UninitialDqLayersContext (pCtx); | 1064 | UninitialDqLayersContext (pCtx); |
| 1065 | 1065 | ||
| 1066 | do { | 1066 | do { |
| 1067 | PDqLayer pDq = (PDqLayer)WelsMalloc (sizeof (SDqLayer), "PDqLayer"); | 1067 | PDqLayer pDq = (PDqLayer)WelsMallocz (sizeof (SDqLayer), "PDqLayer"); |
| 1068 | 1068 | ||
| 1069 | if (pDq == NULL) | 1069 | if (pDq == NULL) |
| 1070 | return ERR_INFO_OUT_OF_MEMORY; | 1070 | return ERR_INFO_OUT_OF_MEMORY; |
| 1071 | 1071 | ||
| 1072 | memset (pDq, 0, sizeof (SDqLayer)); | 1072 | memset (pDq, 0, sizeof (SDqLayer)); |
| 1073 | 1073 | ||
| 1074 | pCtx->sMb.pMbType[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | 1074 | pCtx->sMb.pMbType[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), |
| 1075 | "pCtx->sMb.pMbType[]"); | 1075 | "pCtx->sMb.pMbType[]"); |
| 1076 | pCtx->sMb.pMv[i][0] = (int16_t (*)[16][2])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | 1076 | pCtx->sMb.pMv[i][0] = (int16_t (*)[16][2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1077 | int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMv[][]"); | 1077 | int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMv[][]"); |
| 1078 | pCtx->sMb.pRefIndex[i][0] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | 1078 | pCtx->sMb.pRefIndex[i][0] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1079 | int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]"); | 1079 | int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]"); |
| 1080 | pCtx->sMb.pLumaQp[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | 1080 | pCtx->sMb.pLumaQp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), |
| 1081 | "pCtx->sMb.pLumaQp[]"); | 1081 | "pCtx->sMb.pLumaQp[]"); |
| 1082 | pCtx->sMb.pChromaQp[i] = (int8_t (*)[2])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 2, | 1082 | pCtx->sMb.pChromaQp[i] = (int8_t (*)[2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 2, |
| 1083 | "pCtx->sMb.pChromaQp[]"); | 1083 | "pCtx->sMb.pChromaQp[]"); |
| 1084 | pCtx->sMb.pMvd[i][0] = (int16_t (*)[16][2])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | 1084 | pCtx->sMb.pMvd[i][0] = (int16_t (*)[16][2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1085 | int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMvd[][]"); | 1085 | int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMvd[][]"); |
| 1086 | pCtx->sMb.pCbfDc[i] = (uint8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint8_t), | 1086 | pCtx->sMb.pCbfDc[i] = (uint8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint8_t), |
| 1087 | "pCtx->sMb.pCbfDc[]"); | 1087 | "pCtx->sMb.pCbfDc[]"); |
| 1088 | pCtx->sMb.pNzc[i] = (int8_t (*)[24])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24, | 1088 | pCtx->sMb.pNzc[i] = (int8_t (*)[24])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24, |
| 1089 | "pCtx->sMb.pNzc[]"); | 1089 | "pCtx->sMb.pNzc[]"); |
| 1090 | pCtx->sMb.pNzcRs[i] = (int8_t (*)[24])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24, | 1090 | pCtx->sMb.pNzcRs[i] = (int8_t (*)[24])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24, |
| 1091 | "pCtx->sMb.pNzcRs[]"); | 1091 | "pCtx->sMb.pNzcRs[]"); |
| 1092 | pCtx->sMb.pScaledTCoeff[i] = (int16_t (*)[MB_COEFF_LIST_SIZE])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * | 1092 | pCtx->sMb.pScaledTCoeff[i] = (int16_t (*)[MB_COEFF_LIST_SIZE])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * |
| 1093 | sizeof (int16_t) * MB_COEFF_LIST_SIZE, "pCtx->sMb.pScaledTCoeff[]"); | 1093 | sizeof (int16_t) * MB_COEFF_LIST_SIZE, "pCtx->sMb.pScaledTCoeff[]"); |
| 1094 | pCtx->sMb.pIntraPredMode[i] = (int8_t (*)[8])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 8, | 1094 | pCtx->sMb.pIntraPredMode[i] = (int8_t (*)[8])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 8, |
| 1095 | "pCtx->sMb.pIntraPredMode[]"); | 1095 | "pCtx->sMb.pIntraPredMode[]"); |
| 1096 | pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * | 1096 | pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * |
| 1097 | sizeof (int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pIntra4x4FinalMode[]"); | 1097 | sizeof (int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pIntra4x4FinalMode[]"); |
| 1098 | pCtx->sMb.pChromaPredMode[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | 1098 | pCtx->sMb.pChromaPredMode[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), |
| 1099 | "pCtx->sMb.pChromaPredMode[]"); | 1099 | "pCtx->sMb.pChromaPredMode[]"); |
| 1100 | pCtx->sMb.pCbp[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | 1100 | pCtx->sMb.pCbp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), |
| 1101 | "pCtx->sMb.pCbp[]"); | 1101 | "pCtx->sMb.pCbp[]"); |
| 1102 | pCtx->sMb.pSubMbType[i] = (int8_t (*)[MB_PARTITION_SIZE])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | 1102 | pCtx->sMb.pSubMbType[i] = (int8_t (*)[MB_PARTITION_SIZE])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1103 | int8_t) * MB_PARTITION_SIZE, "pCtx->sMb.pSubMbType[]"); | 1103 | int8_t) * MB_PARTITION_SIZE, "pCtx->sMb.pSubMbType[]"); |
| 1104 | pCtx->sMb.pSliceIdc[i] = (int32_t*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t), | 1104 | pCtx->sMb.pSliceIdc[i] = (int32_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t), |
| 1105 | "pCtx->sMb.pSliceIdc[]"); // using int32_t for slice_idc, 4/21/2010 | 1105 | "pCtx->sMb.pSliceIdc[]"); // using int32_t for slice_idc, 4/21/2010 |
| 1106 | if (pCtx->sMb.pSliceIdc[i] != NULL) | 1106 | if (pCtx->sMb.pSliceIdc[i] != NULL) |
| 1107 | memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t))); | 1107 | memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t))); |
| 1108 | pCtx->sMb.pResidualPredFlag[i] = (int8_t*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | 1108 | pCtx->sMb.pResidualPredFlag[i] = (int8_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), |
| 1109 | "pCtx->sMb.pResidualPredFlag[]"); | 1109 | "pCtx->sMb.pResidualPredFlag[]"); |
| 1110 | //pCtx->sMb.pMotionPredFlag[i] = (uint8_t *) WelsMalloc(pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof(uint8_t), "pCtx->sMb.pMotionPredFlag[]"); | 1110 | //pCtx->sMb.pMotionPredFlag[i] = (uint8_t *) WelsMallocz(pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof(uint8_t), "pCtx->sMb.pMotionPredFlag[]"); |
| 1111 | pCtx->sMb.pInterPredictionDoneFlag[i] = (int8_t*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | 1111 | pCtx->sMb.pInterPredictionDoneFlag[i] = (int8_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1112 | int8_t), "pCtx->sMb.pInterPredictionDoneFlag[]"); | 1112 | int8_t), "pCtx->sMb.pInterPredictionDoneFlag[]"); |
| 1113 | 1113 | ||
| 1114 | pCtx->sMb.pMbCorrectlyDecodedFlag[i] = (bool*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool), | 1114 | pCtx->sMb.pMbCorrectlyDecodedFlag[i] = (bool*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool), |
| 1115 | "pCtx->sMb.pMbCorrectlyDecodedFlag[]"); | 1115 | "pCtx->sMb.pMbCorrectlyDecodedFlag[]"); |
| 1116 | pCtx->sMb.pMbRefConcealedFlag[i] = (bool*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool), | 1116 | pCtx->sMb.pMbRefConcealedFlag[i] = (bool*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool), |
| 1117 | "pCtx->pMbRefConcealedFlag[]"); | 1117 | "pCtx->pMbRefConcealedFlag[]"); |
| 1118 | 1118 | ||
| 1119 | // check memory block valid due above allocated.. | 1119 | // check memory block valid due above allocated.. |