History

add dec memory check

huili2 committed 11 years ago

Commit 3cb417f1 parent 9ecc67112 files · +196 −141Browse files

Showing the changes to codec/decoder (11 of 12 files). Show all

Unified · Split

11 files
  1. codec/decoder/core/inc/decoder.h +1 −1
  2. codec/decoder/core/inc/decoder_context.h +2 −0
  3. codec/decoder/core/inc/fmo.h +4 −3
  4. codec/decoder/core/inc/memmgr_nal_unit.h +4 −3
  5. codec/decoder/core/src/au_parser.cpp +6 −4
  6. codec/decoder/core/src/decoder.cpp +42 −29
  7. codec/decoder/core/src/decoder_core.cpp +83 −68
  8. codec/decoder/core/src/fmo.cpp +9 −10
  9. codec/decoder/core/src/memmgr_nal_unit.cpp +10 −10
  10. codec/decoder/core/src/pic_queue.cpp +9 −8
  11. codec/decoder/plus/src/welsDecoderExt.cpp +16 −5
codec/decoder/core/inc/decoder.h+1−1
@@ -144,7 +144,7 @@ void UpdateDecStatNoFreezingInfo (PWelsDecoderContext pCtx); · 143 unmodified lines
144144 //update decoder statistics information
145145 void UpdateDecStat (PWelsDecoderContext pCtx, const bool kbOutput);
146146 //Destroy picutre buffer
147−void DestroyPicBuff (PPicBuff* ppPicBuf);
147+void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa);
148148 #ifdef __cplusplus
149149 }
150150 #endif//__cplusplus
codec/decoder/core/inc/decoder_context.h+2−0
@@ -55,6 +55,7 @@ · 54 unmodified lines
5555 #include "mb_cache.h"
5656 #include "expand_pic.h"
5757 #include "mc.h"
58+#include "memory_align.h"
5859
5960 namespace WelsDec {
6061 #define MAX_PRED_MODE_ID_I16x16 3
@@ -449,6 +450,7 @@ typedef struct TagWelsDecoderContext { · 388 unmodified lines
449450 bool bDequantCoeff4x4Init;
450451 bool bSpsLatePps;
451452 bool bUseScalingList;
453+ CMemoryAlign* pMemAlign;
452454 } SWelsDecoderContext, *PWelsDecoderContext;
453455
454456 static inline void ResetActiveSPSForEachLayer (PWelsDecoderContext pCtx) {
codec/decoder/core/inc/fmo.h+4−3
@@ -43,6 +43,7 @@ · 42 unmodified lines
4343 #include "typedefs.h"
4444 #include "wels_const.h"
4545 #include "parameter_sets.h"
46+#include "memory_align.h"
4647
4748 namespace WelsDec {
4849
@@ -73,7 +74,7 @@ uint8_t uiReserved[3]; // reserved padding bytes · 24 unmodified lines
7374 *
7475 * \return 0 - successful; none 0 - failed;
7576 */
76−int32_t InitFmo (PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t kiMbHeight);
77+int32_t InitFmo (PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t kiMbHeight, CMemoryAlign* pMa);
7778
7879 /*!
7980 * \brief Uninitialize Wels Flexible Macroblock Ordering (FMO) list
@@ -84,7 +85,7 @@ int32_t InitFmo (PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t ki · 4 unmodified lines
8485 *
8586 * \return NONE
8687 */
87−void UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail);
88+void UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail, CMemoryAlign* pMa);
8889
8990 /*!
9091 * \brief update/insert FMO parameter unit
@@ -96,7 +97,7 @@ void UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail); · 5 unmodified lines
9697 *
9798 * \return true - update/insert successfully; false - failed;
9899 */
99−bool FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum);
100+bool FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum, CMemoryAlign* pMa);
100101
101102 /*!
102103 * \brief Get successive mb to be processed with given current mb_xy
codec/decoder/core/inc/memmgr_nal_unit.h+4−3
@@ -44,19 +44,20 @@ · 43 unmodified lines
4444 #include "typedefs.h"
4545 #include "wels_common_basis.h"
4646 #include "nalu.h"
47+#include "memory_align.h"
4748
4849 namespace WelsDec {
4950
50−int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize);
51+int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize, CMemoryAlign* pMa);
5152
52−int32_t MemFreeNalList (PAccessUnit* ppAu);
53+int32_t MemFreeNalList (PAccessUnit* ppAu, CMemoryAlign* pMa);
5354
5455 /*
5556 * MemGetNextNal
5657 * Get next NAL Unit for using.
5758 * Need expand NAL Unit list if exceeding count number of available NAL Units withing an Access Unit
5859 */
59−PNalUnit MemGetNextNal (PAccessUnit* ppAu);
60+PNalUnit MemGetNextNal (PAccessUnit* ppAu, CMemoryAlign* pMa);
6061
6162 } // namespace WelsDec
6263
codec/decoder/core/src/au_parser.cpp+6−4
@@ -264,7 +264,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 263 unmodified lines
264264 case NAL_UNIT_CODED_SLICE_IDR: {
265265 PAccessUnit pCurAu = NULL;
266266 uint32_t uiAvailNalNum;
267− pCurNal = MemGetNextNal (&pCtx->pAccessUnitList);
267+ pCurNal = MemGetNextNal (&pCtx->pAccessUnitList, pCtx->pMemAlign);
268268 if (NULL == pCurNal) {
269269 WelsLog (pLogCtx, WELS_LOG_ERROR, "MemGetNextNal() fail due out of memory.");
270270 pCtx->iErrorCode |= dsOutOfMemory;
@@ -1138,7 +1138,9 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 867 unmodified lines
11381138
11391139 //re-write subset SPS to SPS
11401140 SBitStringAux sSubsetSpsBs;
1141− uint8_t* pBsBuf = static_cast<uint8_t*> (WelsMallocz (SPS_PPS_BS_SIZE + 4,
1141+ CMemoryAlign* pMa = pCtx->pMemAlign;
1142+
1143+ uint8_t* pBsBuf = static_cast<uint8_t*> (pMa->WelsMallocz (SPS_PPS_BS_SIZE + 4,
11421144 "Temp buffer for parse only usage.")); //to reserve 4 bytes for UVLC writing buffer
11431145 if (NULL == pBsBuf) {
11441146 pCtx->iErrorCode |= dsOutOfMemory;
@@ -1188,7 +1190,7 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 43 unmodified lines
11881190 RBSP2EBSP (pSpsBs->pSpsBsBuf + 5, sSubsetSpsBs.pStartBuf, iRbspSize);
11891191 pSpsBs->uiSpsBsLen = (uint16_t) (sSubsetSpsBs.pCurBuf - sSubsetSpsBs.pStartBuf + 5);
11901192 if (pBsBuf) {
1191− WelsFree (pBsBuf, "pBsBuf for parse only usage");
1193+ pMa->WelsFree (pBsBuf, "pBsBuf for parse only usage");
11921194 }
11931195 }
11941196 }
@@ -1572,7 +1574,7 @@ int32_t ResetFmoList (PWelsDecoderContext pCtx) { · 377 unmodified lines
15721574 int32_t iCountNum = 0;
15731575 if (NULL != pCtx) {
15741576 // Fixed memory leak due to PPS_ID might not be continuous sometimes, 1/5/2010
1575− UninitFmoList (&pCtx->sFmoList[0], MAX_PPS_COUNT, pCtx->iActiveFmoNum);
1577+ UninitFmoList (&pCtx->sFmoList[0], MAX_PPS_COUNT, pCtx->iActiveFmoNum, pCtx->pMemAlign);
15761578 iCountNum = pCtx->iActiveFmoNum;
15771579 pCtx->iActiveFmoNum = 0;
15781580 }
codec/decoder/core/src/decoder.cpp+42−29
@@ -57,7 +57,7 @@ namespace WelsDec { · 56 unmodified lines
5757
5858 extern PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const int32_t kiPicHeight);
5959
60−extern void FreePicture (PPicture pPic);
60+extern void FreePicture (PPicture pPic, CMemoryAlign* pMa);
6161
6262 static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiSize,
6363 const int32_t kiPicWidth, const int32_t kiPicHeight) {
@@ -67,17 +67,19 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons · 3 unmodified lines
6767 return 1;
6868 }
6969
70− pPicBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff");
70+ CMemoryAlign* pMa = pCtx->pMemAlign;
71+
72+ pPicBuf = (PPicBuff)pMa->WelsMallocz (sizeof (SPicBuff), "PPicBuff");
7173
7274 if (NULL == pPicBuf) {
7375 return 1;
7476 }
7577
76− pPicBuf->ppPic = (PPicture*)WelsMallocz (kiSize * sizeof (PPicture), "PPicture*");
78+ pPicBuf->ppPic = (PPicture*)pMa->WelsMallocz (kiSize * sizeof (PPicture), "PPicture*");
7779
7880 if (NULL == pPicBuf->ppPic) {
7981 pPicBuf->iCapacity = 0;
80− DestroyPicBuff (&pPicBuf);
82+ DestroyPicBuff (&pPicBuf, pMa);
8183 return 1;
8284 }
8385
@@ -86,7 +88,7 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons · 2 unmodified lines
8688 if (NULL == pPic) {
8789 // init capacity first for free memory
8890 pPicBuf->iCapacity = iPicIdx;
89− DestroyPicBuff (&pPicBuf);
91+ DestroyPicBuff (&pPicBuf, pMa);
9092 return 1;
9193 }
9294 pPicBuf->ppPic[iPicIdx] = pPic;
@@ -109,17 +111,18 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 16 unmodified lines
109111 return 1;
110112 }
111113
112− pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff");
114+ CMemoryAlign* pMa = pCtx->pMemAlign;
115+ pPicNewBuf = (PPicBuff)pMa->WelsMallocz (sizeof (SPicBuff), "PPicBuff");
113116
114117 if (NULL == pPicNewBuf) {
115118 return 1;
116119 }
117120
118− pPicNewBuf->ppPic = (PPicture*)WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*");
121+ pPicNewBuf->ppPic = (PPicture*)pMa->WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*");
119122
120123 if (NULL == pPicNewBuf->ppPic) {
121124 pPicNewBuf->iCapacity = 0;
122− DestroyPicBuff (&pPicNewBuf);
125+ DestroyPicBuff (&pPicNewBuf, pMa);
123126 return 1;
124127 }
125128
@@ -129,7 +132,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 3 unmodified lines
129132 if (NULL == pPic) {
130133 // Set maximum capacity as the new malloc memory at the tail
131134 pPicNewBuf->iCapacity = iPicIdx;
132− DestroyPicBuff (&pPicNewBuf);
135+ DestroyPicBuff (&pPicNewBuf, pMa);
133136 return 1;
134137 }
135138 pPicNewBuf->ppPic[iPicIdx] = pPic;
@@ -152,12 +155,12 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 16 unmodified lines
152155 }
153156 // remove old PicBuf
154157 if (pPicOldBuf->ppPic != NULL) {
155− WelsFree (pPicOldBuf->ppPic, "pPicOldBuf->queue");
158+ pMa->WelsFree (pPicOldBuf->ppPic, "pPicOldBuf->queue");
156159 pPicOldBuf->ppPic = NULL;
157160 }
158161 pPicOldBuf->iCapacity = 0;
159162 pPicOldBuf->iCurrentIdx = 0;
160− WelsFree (pPicOldBuf, "pPicOldBuf");
163+ pMa->WelsFree (pPicOldBuf, "pPicOldBuf");
161164 pPicOldBuf = NULL;
162165 return 0;
163166 }
@@ -171,17 +174,19 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 7 unmodified lines
171174 return 1;
172175 }
173176
174− pPicNewBuf = (PPicBuff)WelsMallocz (sizeof (SPicBuff), "PPicBuff");
177+ CMemoryAlign* pMa = pCtx->pMemAlign;
178+
179+ pPicNewBuf = (PPicBuff)pMa->WelsMallocz (sizeof (SPicBuff), "PPicBuff");
175180
176181 if (NULL == pPicNewBuf) {
177182 return 1;
178183 }
179184
180− pPicNewBuf->ppPic = (PPicture*)WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*");
185+ pPicNewBuf->ppPic = (PPicture*)pMa->WelsMallocz (kiNewSize * sizeof (PPicture), "PPicture*");
181186
182187 if (NULL == pPicNewBuf->ppPic) {
183188 pPicNewBuf->iCapacity = 0;
184− DestroyPicBuff (&pPicNewBuf);
189+ DestroyPicBuff (&pPicNewBuf, pMa);
185190 return 1;
186191 }
187192
@@ -207,7 +212,7 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 19 unmodified lines
207212 for (iPicIdx = iDelIdx; iPicIdx < kiOldSize; iPicIdx++) {
208213 if (iPrevPicIdx != iPicIdx) {
209214 if (pPicOldBuf->ppPic[iPicIdx] != NULL) {
210− FreePicture (pPicOldBuf->ppPic[iPicIdx]);
215+ FreePicture (pPicOldBuf->ppPic[iPicIdx], pMa);
211216 pPicOldBuf->ppPic[iPicIdx] = NULL;
212217 }
213218 }
@@ -226,18 +231,18 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 12 unmodified lines
226231 }
227232 // remove old PicBuf
228233 if (pPicOldBuf->ppPic != NULL) {
229− WelsFree (pPicOldBuf->ppPic, "pPicOldBuf->queue");
234+ pMa->WelsFree (pPicOldBuf->ppPic, "pPicOldBuf->queue");
230235 pPicOldBuf->ppPic = NULL;
231236 }
232237 pPicOldBuf->iCapacity = 0;
233238 pPicOldBuf->iCurrentIdx = 0;
234− WelsFree (pPicOldBuf, "pPicOldBuf");
239+ pMa->WelsFree (pPicOldBuf, "pPicOldBuf");
235240 pPicOldBuf = NULL;
236241
237242 return 0;
238243 }
239244
240−void DestroyPicBuff (PPicBuff* ppPicBuf) {
245+void DestroyPicBuff (PPicBuff* ppPicBuf, CMemoryAlign* pMa) {
241246 PPicBuff pPicBuf = NULL;
242247
243248 if (NULL == ppPicBuf || NULL == *ppPicBuf)
@@ -249,20 +254,20 @@ void DestroyPicBuff (PPicBuff* ppPicBuf) { · 5 unmodified lines
249254 while (iPicIdx < pPicBuf->iCapacity) {
250255 PPicture pPic = pPicBuf->ppPic[iPicIdx];
251256 if (pPic != NULL) {
252− FreePicture (pPic);
257+ FreePicture (pPic, pMa);
253258 }
254259 pPic = NULL;
255260 ++ iPicIdx;
256261 }
257262
258− WelsFree (pPicBuf->ppPic, "pPicBuf->queue");
263+ pMa->WelsFree (pPicBuf->ppPic, "pPicBuf->queue");
259264
260265 pPicBuf->ppPic = NULL;
261266 }
262267 pPicBuf->iCapacity = 0;
263268 pPicBuf->iCurrentIdx = 0;
264269
265− WelsFree (pPicBuf, "pPicBuf");
270+ pMa->WelsFree (pPicBuf, "pPicBuf");
266271
267272 pPicBuf = NULL;
268273 *ppPicBuf = NULL;
@@ -270,10 +275,11 @@ void DestroyPicBuff (PPicBuff* ppPicBuf) { · 1 unmodified line
270275 /*
271276 * fill data fields in default for decoder context
272277 */
273−void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx) {
278+void WelsDecoderDefaults (PWelsDecoderContext pCtx, SLogContext* pLogCtx, CMemoryAlign* pMa) {
274279 int32_t iCpuCores = 1;
275280 memset (pCtx, 0, sizeof (SWelsDecoderContext)); // fill zero first
276281 pCtx->sLogCtx = *pLogCtx;
282+ pCtx->pMemAlign = pMa;
277283
278284 pCtx->pArgDec = NULL;
279285
@@ -360,6 +366,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 80 unmodified lines
360366 int32_t iListIdx = 0; //, mb_blocks = 0;
361367 int32_t iPicQueueSize = 0; // adaptive size of picture queue, = (pSps->iNumRefFrames x 2)
362368 bool bNeedChangePicQueue = true;
369+ CMemoryAlign* pMa = pCtx->pMemAlign;
363370
364371 WELS_VERIFY_RETURN_IF (ERR_INFO_INVALID_PARAM, (NULL == pCtx || kiPicWidth <= 0 || kiPicHeight <= 0))
365372
@@ -404,7 +411,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 38 unmodified lines
404411 for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) {
405412 PPicBuff* ppPic = &pCtx->pPicBuff[iListIdx];
406413 if (NULL != ppPic && NULL != *ppPic) {
407− DestroyPicBuff (ppPic);
414+ DestroyPicBuff (ppPic, pMa);
408415 }
409416 }
410417
@@ -425,7 +432,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 14 unmodified lines
425432 pCtx->pDec = NULL; // need prefetch a new pic due to spatial size changed
426433
427434 if (pCtx->pCabacDecEngine == NULL)
428− pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine");
435+ pCtx->pCabacDecEngine = (SWelsCabacDecEngine*) pMa->WelsMallocz (sizeof (SWelsCabacDecEngine), "pCtx->pCabacDecEngine");
429436 WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, (NULL == pCtx->pCabacDecEngine))
430437 return ERR_NONE;
431438 }
@@ -435,6 +442,7 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 3 unmodified lines
435442 */
436443 void WelsFreeMem (PWelsDecoderContext pCtx) {
437444 int32_t iListIdx = 0;
445+ CMemoryAlign* pMa = pCtx->pMemAlign;
438446
439447 /* TODO: free memory blocks introduced in avc */
440448 ResetFmoList (pCtx);
@@ -445,7 +453,7 @@ void WelsFreeMem (PWelsDecoderContext pCtx) { · 4 unmodified lines
445453 for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) {
446454 PPicBuff* pPicBuff = &pCtx->pPicBuff[iListIdx];
447455 if (NULL != pPicBuff && NULL != *pPicBuff) {
448− DestroyPicBuff (pPicBuff);
456+ DestroyPicBuff (pPicBuff, pMa);
449457 }
450458 }
451459
@@ -456,7 +464,7 @@ void WelsFreeMem (PWelsDecoderContext pCtx) { · 4 unmodified lines
456464 pCtx->iLastImgHeightInPixel = 0;
457465 pCtx->bFreezeOutput = true;
458466 pCtx->bHaveGotMemory = false;
459− WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine");
467+ pMa->WelsFree (pCtx->pCabacDecEngine, "pCtx->pCabacDecEngine");
460468 }
461469
462470 /*!
@@ -517,7 +525,9 @@ int32_t DecoderConfigParam (PWelsDecoderContext pCtx, const SDecodingParam* kpPa · 54 unmodified lines
517525 if (NULL == pCtx || NULL == kpParam)
518526 return 1;
519527
520− pCtx->pParam = (SDecodingParam*)WelsMallocz (sizeof (SDecodingParam), "SDecodingParam");
528+ CMemoryAlign* pMa = pCtx->pMemAlign;
529+
530+ pCtx->pParam = (SDecodingParam*)pMa->WelsMallocz (sizeof (SDecodingParam), "SDecodingParam");
521531
522532 if (NULL == pCtx->pParam)
523533 return 1;
@@ -565,7 +575,7 @@ int32_t WelsInitDecoder (PWelsDecoderContext pCtx, const bool bParseOnly, SLogCo · 41 unmodified lines
565575 }
566576
567577 // default
568− WelsDecoderDefaults (pCtx, pLogCtx);
578+ WelsDecoderDefaults (pCtx, pLogCtx, pCtx->pMemAlign);
569579
570580 pCtx->bParseOnly = bParseOnly;
571581 // open decoder
@@ -834,7 +844,10 @@ int32_t SyncPictureResolutionExt (PWelsDecoderContext pCtx, const int32_t kiMbWi · 262 unmodified lines
834844 "SyncPictureResolutionExt()::InitialDqLayersContext--buffer allocated failure.");
835845 pCtx->iErrorCode = dsOutOfMemory;
836846 }
837−
847+#if defined(MEMORY_MONITOR)
848+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "SyncPictureResolutionExt(), overall memory usage: %llu bytes",
849+ static_cast<unsigned long long> (sizeof (SWelsDecoderContext) + pCtx->pMemAlign->WelsGetMemoryUsage()));
850+#endif//MEMORY_MONITOR
838851 return iErr;
839852 }
840853
codec/decoder/core/src/decoder_core.cpp+83−68
@@ -456,27 +456,29 @@ int32_t InitBsBuffer (PWelsDecoderContext pCtx) { · 455 unmodified lines
456456 if (pCtx == NULL)
457457 return ERR_INFO_INVALID_PTR;
458458
459+ CMemoryAlign* pMa = pCtx->pMemAlign;
460+
459461 pCtx->iMaxBsBufferSizeInByte = MIN_ACCESS_UNIT_CAPACITY * MAX_BUFFERED_NUM;
460− if ((pCtx->sRawData.pHead = static_cast<uint8_t*> (WelsMallocz (pCtx->iMaxBsBufferSizeInByte,
462+ if ((pCtx->sRawData.pHead = static_cast<uint8_t*> (pMa->WelsMallocz (pCtx->iMaxBsBufferSizeInByte,
461463 "pCtx->sRawData.pHead"))) == NULL) {
462464 return ERR_INFO_OUT_OF_MEMORY;
463465 }
464466 pCtx->sRawData.pStartPos = pCtx->sRawData.pCurPos = pCtx->sRawData.pHead;
465467 pCtx->sRawData.pEnd = pCtx->sRawData.pHead + pCtx->iMaxBsBufferSizeInByte;
466468 if (pCtx->bParseOnly) {
467− pCtx->pParserBsInfo = static_cast<SParserBsInfo*> (WelsMallocz (sizeof (SParserBsInfo), "pCtx->pParserBsInfo"));
469+ pCtx->pParserBsInfo = static_cast<SParserBsInfo*> (pMa->WelsMallocz (sizeof (SParserBsInfo), "pCtx->pParserBsInfo"));
468470 if (pCtx->pParserBsInfo == NULL) {
469471 return ERR_INFO_OUT_OF_MEMORY;
470472 }
471473 memset (pCtx->pParserBsInfo, 0, sizeof (SParserBsInfo));
472− pCtx->pParserBsInfo->pDstBuff = static_cast<uint8_t*> (WelsMallocz (MAX_ACCESS_UNIT_CAPACITY * sizeof (uint8_t),
474+ pCtx->pParserBsInfo->pDstBuff = static_cast<uint8_t*> (pMa->WelsMallocz (MAX_ACCESS_UNIT_CAPACITY * sizeof (uint8_t),
473475 "pCtx->pParserBsInfo->pDstBuff"));
474476 if (pCtx->pParserBsInfo->pDstBuff == NULL) {
475477 return ERR_INFO_OUT_OF_MEMORY;
476478 }
477479 memset (pCtx->pParserBsInfo->pDstBuff, 0, MAX_ACCESS_UNIT_CAPACITY * sizeof (uint8_t));
478480
479− if ((pCtx->sSavedData.pHead = static_cast<uint8_t*> (WelsMallocz (pCtx->iMaxBsBufferSizeInByte,
481+ if ((pCtx->sSavedData.pHead = static_cast<uint8_t*> (pMa->WelsMallocz (pCtx->iMaxBsBufferSizeInByte,
480482 "pCtx->sSavedData.pHead"))) == NULL) {
481483 return ERR_INFO_OUT_OF_MEMORY;
482484 }
@@ -492,7 +494,8 @@ int32_t ExpandBsBuffer (PWelsDecoderContext pCtx, const int kiSrcLen) { · 9 unmodified lines
492494 int32_t iExpandStepShift = 1;
493495 int32_t iNewBuffLen = WELS_MAX ((kiSrcLen * MAX_BUFFERED_NUM), (pCtx->iMaxBsBufferSizeInByte << iExpandStepShift));
494496 //allocate new bs buffer
495− uint8_t* pNewBsBuff = static_cast<uint8_t*> (WelsMallocz (iNewBuffLen, "pCtx->sRawData.pHead"));
497+ CMemoryAlign* pMa = pCtx->pMemAlign;
498+ uint8_t* pNewBsBuff = static_cast<uint8_t*> (pMa->WelsMallocz (iNewBuffLen, "pCtx->sRawData.pHead"));
496499 if (pNewBsBuff == NULL)
497500 return ERR_INFO_OUT_OF_MEMORY;
498501
@@ -510,7 +513,7 @@ int32_t ExpandBsBuffer (PWelsDecoderContext pCtx, const int kiSrcLen) { · 11 unmodified lines
510513 pCtx->sRawData.pStartPos = pNewBsBuff + (pCtx->sRawData.pStartPos - pCtx->sRawData.pHead);
511514 pCtx->sRawData.pCurPos = pNewBsBuff + (pCtx->sRawData.pCurPos - pCtx->sRawData.pHead);
512515 pCtx->sRawData.pEnd = pNewBsBuff + iNewBuffLen;
513− WelsFree (pCtx->sRawData.pHead, "pCtx->sRawData.pHead");
516+ pMa->WelsFree (pCtx->sRawData.pHead, "pCtx->sRawData.pHead");
514517 pCtx->sRawData.pHead = pNewBsBuff;
515518 return ERR_NONE;
516519 }
@@ -545,7 +548,7 @@ int32_t WelsInitMemory (PWelsDecoderContext pCtx) { · 28 unmodified lines
545548 return ERR_INFO_INVALID_PTR;
546549 }
547550
548− if (MemInitNalList (&pCtx->pAccessUnitList, MAX_NAL_UNIT_NUM_IN_AU) != 0)
551+ if (MemInitNalList (&pCtx->pAccessUnitList, MAX_NAL_UNIT_NUM_IN_AU, pCtx->pMemAlign) != 0)
549552 return ERR_INFO_OUT_OF_MEMORY;
550553
551554 if (InitBsBuffer (pCtx) != 0)
@@ -566,16 +569,18 @@ void WelsFreeMemory (PWelsDecoderContext pCtx) { · 14 unmodified lines
566569 if (pCtx == NULL)
567570 return;
568571
572+ CMemoryAlign* pMa = pCtx->pMemAlign;
573+
569574 if (NULL != pCtx->pParam) {
570− WelsFree (pCtx->pParam, "pCtx->pParam");
575+ pMa->WelsFree (pCtx->pParam, "pCtx->pParam");
571576
572577 pCtx->pParam = NULL;
573578 }
574579
575− MemFreeNalList (&pCtx->pAccessUnitList);
580+ MemFreeNalList (&pCtx->pAccessUnitList, pMa);
576581
577582 if (pCtx->sRawData.pHead) {
578− WelsFree (pCtx->sRawData.pHead, "pCtx->sRawData->pHead");
583+ pMa->WelsFree (pCtx->sRawData.pHead, "pCtx->sRawData->pHead");
579584 }
580585 pCtx->sRawData.pHead = NULL;
581586 pCtx->sRawData.pEnd = NULL;
@@ -583,7 +588,7 @@ void WelsFreeMemory (PWelsDecoderContext pCtx) { · 1 unmodified line
583588 pCtx->sRawData.pCurPos = NULL;
584589 if (pCtx->bParseOnly) {
585590 if (pCtx->sSavedData.pHead) {
586− WelsFree (pCtx->sSavedData.pHead, "pCtx->sSavedData->pHead");
591+ pMa->WelsFree (pCtx->sSavedData.pHead, "pCtx->sSavedData->pHead");
587592 }
588593 pCtx->sSavedData.pHead = NULL;
589594 pCtx->sSavedData.pEnd = NULL;
@@ -591,10 +596,10 @@ void WelsFreeMemory (PWelsDecoderContext pCtx) { · 1 unmodified line
591596 pCtx->sSavedData.pCurPos = NULL;
592597 if (pCtx->pParserBsInfo) {
593598 if (pCtx->pParserBsInfo->pDstBuff) {
594− WelsFree (pCtx->pParserBsInfo->pDstBuff, "pCtx->pParserBsInfo->pDstBuff");
599+ pMa->WelsFree (pCtx->pParserBsInfo->pDstBuff, "pCtx->pParserBsInfo->pDstBuff");
595600 pCtx->pParserBsInfo->pDstBuff = NULL;
596601 }
597− WelsFree (pCtx->pParserBsInfo, "pCtx->pParserBsInfo");
602+ pMa->WelsFree (pCtx->pParserBsInfo, "pCtx->pParserBsInfo");
598603 pCtx->pParserBsInfo = NULL;
599604 }
600605 }
@@ -640,7 +645,8 @@ void DecodeNalHeaderExt (PNalUnit pNal, uint8_t* pSrc) { · 39 unmodified lines
640645 * Parse slice header of bitstream in avc for storing data structure
641646 */
642647 int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, const bool kbExtensionFlag) {
643− PNalUnit const kpCurNal = pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum - 1];
648+ PNalUnit const kpCurNal = pCtx->pAccessUnitList->pNalUnitsList[pCtx->pAccessUnitList->uiAvailUnitsNum -
649+ 1];
644650
645651 PNalUnitHeaderExt pNalHeaderExt = NULL;
646652 PSliceHeader pSliceHead = NULL;
@@ -970,7 +976,7 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 323 unmodified lines
970976 }
971977
972978 bSgChangeCycleInvolved = (pPps->uiNumSliceGroups > 1 && pPps->uiSliceGroupMapType >= 3
973− && pPps->uiSliceGroupMapType <= 5);
979+ && pPps->uiSliceGroupMapType <= 5);
974980 if (kbExtensionFlag && bSgChangeCycleInvolved)
975981 bSgChangeCycleInvolved = (bSgChangeCycleInvolved && (uiQualityId == BASE_QUALITY_ID));
976982 if (bSgChangeCycleInvolved) {
@@ -1030,7 +1036,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 53 unmodified lines
10301036 pos.iRightOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iRightOffset;
10311037 pos.iBottomOffset = pSubsetSps->sSpsSvcExt.sSeqScaledRefLayer.iBottomOffset * (2 - pSps->bFrameMbsOnlyFlag);
10321038 //memcpy(&pSliceHeadExt->sScaledRefLayer, &pos, sizeof(SPosOffset));//confirmed_safe_unsafe_usage
1033− pSliceHeadExt->iScaledRefLayerPicWidthInSampleLuma = (pSliceHead->iMbWidth << 4) - (pos.iLeftOffset + pos.iRightOffset);
1039+ pSliceHeadExt->iScaledRefLayerPicWidthInSampleLuma = (pSliceHead->iMbWidth << 4) -
1040+ (pos.iLeftOffset + pos.iRightOffset);
10341041 pSliceHeadExt->iScaledRefLayerPicHeightInSampleLuma = (pSliceHead->iMbHeight << 4) -
10351042 (pos.iTopOffset + pos.iBottomOffset) / (1 + pSliceHead->bFieldPicFlag);
10361043 }
@@ -1218,68 +1225,75 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 181 unmodified lines
12181225 && kiMaxHeight <= pCtx->iPicHeightReq) // have same dimension memory, skipped
12191226 return ERR_NONE;
12201227
1228+ CMemoryAlign* pMa = pCtx->pMemAlign;
12211229
12221230 UninitialDqLayersContext (pCtx);
12231231
12241232 do {
1225− PDqLayer pDq = (PDqLayer)WelsMallocz (sizeof (SDqLayer), "PDqLayer");
1233+ PDqLayer pDq = (PDqLayer)pMa->WelsMallocz (sizeof (SDqLayer), "PDqLayer");
12261234
12271235 if (pDq == NULL)
12281236 return ERR_INFO_OUT_OF_MEMORY;
12291237
12301238 memset (pDq, 0, sizeof (SDqLayer));
12311239
1232− pCtx->sMb.pMbType[i] = (int16_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int16_t),
1240+ pCtx->sMb.pMbType[i] = (int16_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int16_t),
12331241 "pCtx->sMb.pMbType[]");
1234− pCtx->sMb.pMv[i][0] = (int16_t (*)[16][2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
1242+ pCtx->sMb.pMv[i][0] = (int16_t (*)[16][2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
12351243 int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMv[][]");
1236− pCtx->sMb.pRefIndex[i][0] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
1244+ pCtx->sMb.pRefIndex[i][0] = (int8_t (*)[MB_BLOCK4x4_NUM])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
12371245 sizeof (
12381246 int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]");
1239− pCtx->sMb.pLumaQp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
1247+ pCtx->sMb.pLumaQp[i] = (int8_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
12401248 "pCtx->sMb.pLumaQp[]");
1241− pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i] = (bool*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
1249+ pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i] = (bool*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
1250+ sizeof (
12421251 bool),
12431252 "pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[]");
1244− pCtx->sMb.pTransformSize8x8Flag[i] = (bool*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool),
1253+ pCtx->sMb.pTransformSize8x8Flag[i] = (bool*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool),
12451254 "pCtx->sMb.pTransformSize8x8Flag[]");
1246− pCtx->sMb.pChromaQp[i] = (int8_t (*)[2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 2,
1255+ pCtx->sMb.pChromaQp[i] = (int8_t (*)[2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
1256+ int8_t) * 2,
12471257 "pCtx->sMb.pChromaQp[]");
1248− pCtx->sMb.pMvd[i][0] = (int16_t (*)[16][2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
1258+ pCtx->sMb.pMvd[i][0] = (int16_t (*)[16][2])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
12491259 int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMvd[][]");
1250− pCtx->sMb.pCbfDc[i] = (uint16_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint16_t),
1260+ pCtx->sMb.pCbfDc[i] = (uint16_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint16_t),
12511261 "pCtx->sMb.pCbfDc[]");
1252− pCtx->sMb.pNzc[i] = (int8_t (*)[24])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24,
1262+ pCtx->sMb.pNzc[i] = (int8_t (*)[24])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24,
12531263 "pCtx->sMb.pNzc[]");
1254− pCtx->sMb.pNzcRs[i] = (int8_t (*)[24])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24,
1264+ pCtx->sMb.pNzcRs[i] = (int8_t (*)[24])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24,
12551265 "pCtx->sMb.pNzcRs[]");
1256− pCtx->sMb.pScaledTCoeff[i] = (int16_t (*)[MB_COEFF_LIST_SIZE])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
1266+ pCtx->sMb.pScaledTCoeff[i] = (int16_t (*)[MB_COEFF_LIST_SIZE])pMa->WelsMallocz (pCtx->sMb.iMbWidth *
1267+ pCtx->sMb.iMbHeight *
12571268 sizeof (int16_t) * MB_COEFF_LIST_SIZE, "pCtx->sMb.pScaledTCoeff[]");
1258− pCtx->sMb.pIntraPredMode[i] = (int8_t (*)[8])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
1269+ pCtx->sMb.pIntraPredMode[i] = (int8_t (*)[8])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
12591270 int8_t) * 8,
12601271 "pCtx->sMb.pIntraPredMode[]");
1261− pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
1272+ pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])pMa->WelsMallocz (pCtx->sMb.iMbWidth *
1273+ pCtx->sMb.iMbHeight *
12621274 sizeof (int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pIntra4x4FinalMode[]");
1263− pCtx->sMb.pIntraNxNAvailFlag[i] = (uint8_t (*))WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
1275+ pCtx->sMb.pIntraNxNAvailFlag[i] = (uint8_t (*))pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
1276+ int8_t),
12641277 "pCtx->sMb.pIntraNxNAvailFlag");
1265− pCtx->sMb.pChromaPredMode[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
1278+ pCtx->sMb.pChromaPredMode[i] = (int8_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
12661279 "pCtx->sMb.pChromaPredMode[]");
1267− pCtx->sMb.pCbp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
1280+ pCtx->sMb.pCbp[i] = (int8_t*)pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
12681281 "pCtx->sMb.pCbp[]");
1269− pCtx->sMb.pSubMbType[i] = (int8_t (*)[MB_PARTITION_SIZE])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
1282+ pCtx->sMb.pSubMbType[i] = (int8_t (*)[MB_PARTITION_SIZE])pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
12701283 sizeof (
12711284 int8_t) * MB_PARTITION_SIZE, "pCtx->sMb.pSubMbType[]");
1272− pCtx->sMb.pSliceIdc[i] = (int32_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t),
1285+ pCtx->sMb.pSliceIdc[i] = (int32_t*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t),
12731286 "pCtx->sMb.pSliceIdc[]"); // using int32_t for slice_idc, 4/21/2010
1274− pCtx->sMb.pResidualPredFlag[i] = (int8_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
1287+ pCtx->sMb.pResidualPredFlag[i] = (int8_t*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
12751288 "pCtx->sMb.pResidualPredFlag[]");
1276− //pCtx->sMb.pMotionPredFlag[i] = (uint8_t *) WelsMallocz(pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof(uint8_t), "pCtx->sMb.pMotionPredFlag[]");
1277− pCtx->sMb.pInterPredictionDoneFlag[i] = (int8_t*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
1289+ //pCtx->sMb.pMotionPredFlag[i] = (uint8_t *) pMa->WelsMallocz(pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof(uint8_t), "pCtx->sMb.pMotionPredFlag[]");
1290+ pCtx->sMb.pInterPredictionDoneFlag[i] = (int8_t*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
12781291 int8_t), "pCtx->sMb.pInterPredictionDoneFlag[]");
12791292
1280− pCtx->sMb.pMbCorrectlyDecodedFlag[i] = (bool*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool),
1293+ pCtx->sMb.pMbCorrectlyDecodedFlag[i] = (bool*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
1294+ bool),
12811295 "pCtx->sMb.pMbCorrectlyDecodedFlag[]");
1282− pCtx->sMb.pMbRefConcealedFlag[i] = (bool*) WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool),
1296+ pCtx->sMb.pMbRefConcealedFlag[i] = (bool*) pMa->WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool),
12831297 "pCtx->pMbRefConcealedFlag[]");
12841298
12851299 // check memory block valid due above allocated..
@@ -1322,6 +1336,7 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 36 unmodified lines
13221336
13231337 void UninitialDqLayersContext (PWelsDecoderContext pCtx) {
13241338 int32_t i = 0;
1339+ CMemoryAlign* pMa = pCtx->pMemAlign;
13251340
13261341 do {
13271342 PDqLayer pDq = pCtx->pDqLayersList[i];
@@ -1331,146 +1346,146 @@ void UninitialDqLayersContext (PWelsDecoderContext pCtx) { · 3 unmodified lines
13311346 }
13321347
13331348 if (pCtx->sMb.pMbType[i]) {
1334− WelsFree (pCtx->sMb.pMbType[i], "pCtx->sMb.pMbType[]");
1349+ pMa->WelsFree (pCtx->sMb.pMbType[i], "pCtx->sMb.pMbType[]");
13351350
13361351 pCtx->sMb.pMbType[i] = NULL;
13371352 }
13381353
13391354 if (pCtx->sMb.pMv[i][0]) {
1340− WelsFree (pCtx->sMb.pMv[i][0], "pCtx->sMb.pMv[][]");
1355+ pMa->WelsFree (pCtx->sMb.pMv[i][0], "pCtx->sMb.pMv[][]");
13411356
13421357 pCtx->sMb.pMv[i][0] = NULL;
13431358 }
13441359
13451360 if (pCtx->sMb.pRefIndex[i][0]) {
1346− WelsFree (pCtx->sMb.pRefIndex[i][0], "pCtx->sMb.pRefIndex[][]");
1361+ pMa->WelsFree (pCtx->sMb.pRefIndex[i][0], "pCtx->sMb.pRefIndex[][]");
13471362
13481363 pCtx->sMb.pRefIndex[i][0] = NULL;
13491364 }
13501365
13511366 if (pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i]) {
1352− WelsFree (pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i], "pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[]");
1367+ pMa->WelsFree (pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i], "pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[]");
13531368
13541369 pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i] = NULL;
13551370 }
13561371
13571372 if (pCtx->sMb.pTransformSize8x8Flag[i]) {
1358− WelsFree (pCtx->sMb.pTransformSize8x8Flag[i], "pCtx->sMb.pTransformSize8x8Flag[]");
1373+ pMa->WelsFree (pCtx->sMb.pTransformSize8x8Flag[i], "pCtx->sMb.pTransformSize8x8Flag[]");
13591374
13601375 pCtx->sMb.pTransformSize8x8Flag[i] = NULL;
13611376 }
13621377
13631378 if (pCtx->sMb.pLumaQp[i]) {
1364− WelsFree (pCtx->sMb.pLumaQp[i], "pCtx->sMb.pLumaQp[]");
1379+ pMa->WelsFree (pCtx->sMb.pLumaQp[i], "pCtx->sMb.pLumaQp[]");
13651380
13661381 pCtx->sMb.pLumaQp[i] = NULL;
13671382 }
13681383
13691384 if (pCtx->sMb.pChromaQp[i]) {
1370− WelsFree (pCtx->sMb.pChromaQp[i], "pCtx->sMb.pChromaQp[]");
1385+ pMa->WelsFree (pCtx->sMb.pChromaQp[i], "pCtx->sMb.pChromaQp[]");
13711386
13721387 pCtx->sMb.pChromaQp[i] = NULL;
13731388 }
13741389
13751390 if (pCtx->sMb.pMvd[i][0]) {
1376− WelsFree (pCtx->sMb.pMvd[i][0], "pCtx->sMb.pMvd[][]");
1391+ pMa->WelsFree (pCtx->sMb.pMvd[i][0], "pCtx->sMb.pMvd[][]");
13771392 pCtx->sMb.pMvd[i][0] = NULL;
13781393 }
13791394
13801395 if (pCtx->sMb.pCbfDc[i]) {
1381− WelsFree (pCtx->sMb.pCbfDc[i], "pCtx->sMb.pCbfDc[]");
1396+ pMa->WelsFree (pCtx->sMb.pCbfDc[i], "pCtx->sMb.pCbfDc[]");
13821397 pCtx->sMb.pCbfDc[i] = NULL;
13831398 }
13841399
13851400 if (pCtx->sMb.pNzc[i]) {
1386− WelsFree (pCtx->sMb.pNzc[i], "pCtx->sMb.pNzc[]");
1401+ pMa->WelsFree (pCtx->sMb.pNzc[i], "pCtx->sMb.pNzc[]");
13871402
13881403 pCtx->sMb.pNzc[i] = NULL;
13891404 }
13901405
13911406 if (pCtx->sMb.pNzcRs[i]) {
1392− WelsFree (pCtx->sMb.pNzcRs[i], "pCtx->sMb.pNzcRs[]");
1407+ pMa->WelsFree (pCtx->sMb.pNzcRs[i], "pCtx->sMb.pNzcRs[]");
13931408
13941409 pCtx->sMb.pNzcRs[i] = NULL;
13951410 }
13961411
13971412 if (pCtx->sMb.pScaledTCoeff[i]) {
1398− WelsFree (pCtx->sMb.pScaledTCoeff[i], "pCtx->sMb.pScaledTCoeff[]");
1413+ pMa->WelsFree (pCtx->sMb.pScaledTCoeff[i], "pCtx->sMb.pScaledTCoeff[]");
13991414
14001415 pCtx->sMb.pScaledTCoeff[i] = NULL;
14011416 }
14021417
14031418 if (pCtx->sMb.pIntraPredMode[i]) {
1404− WelsFree (pCtx->sMb.pIntraPredMode[i], "pCtx->sMb.pIntraPredMode[]");
1419+ pMa->WelsFree (pCtx->sMb.pIntraPredMode[i], "pCtx->sMb.pIntraPredMode[]");
14051420
14061421 pCtx->sMb.pIntraPredMode[i] = NULL;
14071422 }
14081423
14091424 if (pCtx->sMb.pIntra4x4FinalMode[i]) {
1410− WelsFree (pCtx->sMb.pIntra4x4FinalMode[i], "pCtx->sMb.pIntra4x4FinalMode[]");
1425+ pMa->WelsFree (pCtx->sMb.pIntra4x4FinalMode[i], "pCtx->sMb.pIntra4x4FinalMode[]");
14111426
14121427 pCtx->sMb.pIntra4x4FinalMode[i] = NULL;
14131428 }
14141429
14151430 if (pCtx->sMb.pIntraNxNAvailFlag[i]) {
1416− WelsFree (pCtx->sMb.pIntraNxNAvailFlag[i], "pCtx->sMb.pIntraNxNAvailFlag");
1431+ pMa->WelsFree (pCtx->sMb.pIntraNxNAvailFlag[i], "pCtx->sMb.pIntraNxNAvailFlag");
14171432
14181433 pCtx->sMb.pIntraNxNAvailFlag[i] = NULL;
14191434 }
14201435
14211436 if (pCtx->sMb.pChromaPredMode[i]) {
1422− WelsFree (pCtx->sMb.pChromaPredMode[i], "pCtx->sMb.pChromaPredMode[]");
1437+ pMa->WelsFree (pCtx->sMb.pChromaPredMode[i], "pCtx->sMb.pChromaPredMode[]");
14231438
14241439 pCtx->sMb.pChromaPredMode[i] = NULL;
14251440 }
14261441
14271442 if (pCtx->sMb.pCbp[i]) {
1428− WelsFree (pCtx->sMb.pCbp[i], "pCtx->sMb.pCbp[]");
1443+ pMa->WelsFree (pCtx->sMb.pCbp[i], "pCtx->sMb.pCbp[]");
14291444
14301445 pCtx->sMb.pCbp[i] = NULL;
14311446 }
14321447
14331448 // if (pCtx->sMb.pMotionPredFlag[i])
14341449 //{
1435− // WelsFree( pCtx->sMb.pMotionPredFlag[i], "pCtx->sMb.pMotionPredFlag[]" );
1450+ // pMa->WelsFree( pCtx->sMb.pMotionPredFlag[i], "pCtx->sMb.pMotionPredFlag[]" );
14361451
14371452 // pCtx->sMb.pMotionPredFlag[i] = NULL;
14381453 //}
14391454
14401455 if (pCtx->sMb.pSubMbType[i]) {
1441− WelsFree (pCtx->sMb.pSubMbType[i], "pCtx->sMb.pSubMbType[]");
1456+ pMa->WelsFree (pCtx->sMb.pSubMbType[i], "pCtx->sMb.pSubMbType[]");
14421457
14431458 pCtx->sMb.pSubMbType[i] = NULL;
14441459 }
14451460
14461461 if (pCtx->sMb.pSliceIdc[i]) {
1447− WelsFree (pCtx->sMb.pSliceIdc[i], "pCtx->sMb.pSliceIdc[]");
1462+ pMa->WelsFree (pCtx->sMb.pSliceIdc[i], "pCtx->sMb.pSliceIdc[]");
14481463
14491464 pCtx->sMb.pSliceIdc[i] = NULL;
14501465 }
14511466
14521467 if (pCtx->sMb.pResidualPredFlag[i]) {
1453− WelsFree (pCtx->sMb.pResidualPredFlag[i], "pCtx->sMb.pResidualPredFlag[]");
1468+ pMa->WelsFree (pCtx->sMb.pResidualPredFlag[i], "pCtx->sMb.pResidualPredFlag[]");
14541469
14551470 pCtx->sMb.pResidualPredFlag[i] = NULL;
14561471 }
14571472
14581473 if (pCtx->sMb.pInterPredictionDoneFlag[i]) {
1459− WelsFree (pCtx->sMb.pInterPredictionDoneFlag[i], "pCtx->sMb.pInterPredictionDoneFlag[]");
1474+ pMa->WelsFree (pCtx->sMb.pInterPredictionDoneFlag[i], "pCtx->sMb.pInterPredictionDoneFlag[]");
14601475
14611476 pCtx->sMb.pInterPredictionDoneFlag[i] = NULL;
14621477 }
14631478
14641479 if (pCtx->sMb.pMbCorrectlyDecodedFlag[i]) {
1465− WelsFree (pCtx->sMb.pMbCorrectlyDecodedFlag[i], "pCtx->sMb.pMbCorrectlyDecodedFlag[]");
1480+ pMa->WelsFree (pCtx->sMb.pMbCorrectlyDecodedFlag[i], "pCtx->sMb.pMbCorrectlyDecodedFlag[]");
14661481 pCtx->sMb.pMbCorrectlyDecodedFlag[i] = NULL;
14671482 }
14681483
14691484 if (pCtx->sMb.pMbRefConcealedFlag[i]) {
1470− WelsFree (pCtx->sMb.pMbRefConcealedFlag[i], "pCtx->sMb.pMbRefConcealedFlag[]");
1485+ pMa->WelsFree (pCtx->sMb.pMbRefConcealedFlag[i], "pCtx->sMb.pMbRefConcealedFlag[]");
14711486 pCtx->sMb.pMbRefConcealedFlag[i] = NULL;
14721487 }
1473− WelsFree (pDq, "pDq");
1488+ pMa->WelsFree (pDq, "pDq");
14741489
14751490 pDq = NULL;
14761491 pCtx->pDqLayersList[i] = NULL;
@@ -2184,7 +2199,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 707 unmodified lines
21842199 pLayerInfo.pSubsetSps = pShExt->pSubsetSps;
21852200
21862201 pCtx->pFmo = &pCtx->sFmoList[iPpsId];
2187− if (!FmoParamUpdate (pCtx->pFmo, pLayerInfo.pSps, pLayerInfo.pPps, &pCtx->iActiveFmoNum)) {
2202+ if (!FmoParamUpdate (pCtx->pFmo, pLayerInfo.pSps, pLayerInfo.pPps, &pCtx->iActiveFmoNum, pCtx->pMemAlign)) {
21882203 pCtx->iErrorCode |= dsBitstreamError;
21892204 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "DecodeCurrentAccessUnit(), FmoParamUpdate failed, eSliceType: %d.",
21902205 pSh->eSliceType);
@@ -2192,7 +2207,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBuf · 1 unmodified line
21922207 }
21932208
21942209 bFreshSliceAvailable = (iCurrIdD != iLastIdD
2195− || iCurrIdQ != iLastIdQ); // do not need condition of (first_mb == 0) due multiple slices might be disorder
2210+ || iCurrIdQ != iLastIdQ); // do not need condition of (first_mb == 0) due multiple slices might be disorder
21962211
21972212 WelsDqLayerDecodeStart (pCtx, pNalCur, pLayerInfo.pSps, pLayerInfo.pPps);
21982213
codec/decoder/core/src/fmo.cpp+9−10
@@ -116,7 +116,7 @@ static inline int32_t FmoGenerateMbAllocMapType1 (PFmo pFmo, PPps pPps, const in · 115 unmodified lines
116116 * \return 0 - successful; none 0 - failed
117117 */
118118 static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const int32_t kiMbWidth,
119− const int32_t kiMbHeight) {
119+ const int32_t kiMbHeight, CMemoryAlign* pMa) {
120120 int32_t iNumMb = 0;
121121 int32_t iErr = 0;
122122 bool bResolutionChanged = false;
@@ -131,9 +131,8 @@ static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const · 8 unmodified lines
131131 if (0 == iNumMb)
132132 return 1;
133133
134−
135− WelsFree (pFmo->pMbAllocMap, "_fmo->pMbAllocMap");
136− pFmo->pMbAllocMap = (uint8_t*)WelsMallocz (iNumMb * sizeof (uint8_t), "_fmo->pMbAllocMap");
134+ pMa->WelsFree (pFmo->pMbAllocMap, "_fmo->pMbAllocMap");
135+ pFmo->pMbAllocMap = (uint8_t*)pMa->WelsMallocz (iNumMb * sizeof (uint8_t), "_fmo->pMbAllocMap");
137136 WELS_VERIFY_RETURN_IF (1, (NULL == pFmo->pMbAllocMap)) // out of memory
138137
139138 pFmo->iCountMbNum = iNumMb;
@@ -186,8 +185,8 @@ static inline int32_t FmoGenerateSliceGroup (PFmo pFmo, const PPps kpPps, const · 46 unmodified lines
186185 *
187186 * \return 0 - successful; none 0 - failed;
188187 */
189−int32_t InitFmo (PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t kiMbHeight) {
190− return FmoGenerateSliceGroup (pFmo, pPps, kiMbWidth, kiMbHeight);
188+int32_t InitFmo (PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t kiMbHeight, CMemoryAlign* pMa) {
189+ return FmoGenerateSliceGroup (pFmo, pPps, kiMbWidth, kiMbHeight, pMa);
191190 }
192191
193192
@@ -200,7 +199,7 @@ int32_t InitFmo (PFmo pFmo, PPps pPps, const int32_t kiMbWidth, const int32_t ki · 6 unmodified lines
200199 *
201200 * \return NONE
202201 */
203−void UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail) {
202+void UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail, CMemoryAlign* pMa) {
204203 PFmo pIter = pFmo;
205204 int32_t i = 0;
206205 int32_t iFreeNodes = 0;
@@ -211,7 +210,7 @@ void UninitFmoList (PFmo pFmo, const int32_t kiCnt, const int32_t kiAvail) { · 4 unmodified lines
211210 while (i < kiCnt) {
212211 if (pIter != NULL && pIter->bActiveFlag) {
213212 if (NULL != pIter->pMbAllocMap) {
214− WelsFree (pIter->pMbAllocMap, "pIter->pMbAllocMap");
213+ pMa->WelsFree (pIter->pMbAllocMap, "pIter->pMbAllocMap");
215214
216215 pIter->pMbAllocMap = NULL;
217216 }
@@ -258,7 +257,7 @@ bool FmoParamSetsChanged (PFmo pFmo, const int32_t kiCountNumMb, const int32_t k · 40 unmodified lines
258257 *
259258 * \return true - update/insert successfully; false - failed;
260259 */
261−bool FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum) {
260+bool FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum, CMemoryAlign* pMa) {
262261 const uint32_t kuiMbWidth = pSps->iMbWidth;
263262 const uint32_t kuiMbHeight = pSps->iMbHeight;
264263
@@ -267,7 +266,7 @@ bool FmoParamUpdate (PFmo pFmo, PSps pSps, PPps pPps, int32_t* pActiveFmoNum) { · 2 unmodified lines
267266 pPps->uiSliceGroupMapType,
268267 pPps->uiNumSliceGroups)) {
269268
270− if (InitFmo (pFmo, pPps, kuiMbWidth, kuiMbHeight)) {
269+ if (InitFmo (pFmo, pPps, kuiMbWidth, kuiMbHeight, pMa)) {
271270 return false;
272271 } else {
273272 if (!pFmo->bActiveFlag && *pActiveFmoNum < MAX_PPS_COUNT) {
codec/decoder/core/src/memmgr_nal_unit.cpp+10−10
@@ -43,7 +43,7 @@ · 42 unmodified lines
4343
4444 namespace WelsDec {
4545
46−int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize) {
46+int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize, CMemoryAlign* pMa) {
4747 uint32_t uiIdx = 0;
4848 uint8_t* pBase = NULL, *pPtr = NULL;
4949 const uint32_t kuiSizeAu = sizeof (SAccessUnit);
@@ -55,10 +55,10 @@ int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize) { · 5 unmodified lines
5555 return 1;
5656
5757 if (*ppAu != NULL) {
58− MemFreeNalList (ppAu);
58+ MemFreeNalList (ppAu, pMa);
5959 }
6060
61− pBase = (uint8_t*)WelsMallocz (kuiCountSize, "Access Unit");
61+ pBase = (uint8_t*)pMa->WelsMallocz (kuiCountSize, "Access Unit");
6262 if (pBase == NULL)
6363 return 1;
6464 pPtr = pBase;
@@ -82,11 +82,11 @@ int32_t MemInitNalList (PAccessUnit* ppAu, const uint32_t kuiSize) { · 17 unmodified lines
8282 return 0;
8383 }
8484
85−int32_t MemFreeNalList (PAccessUnit* ppAu) {
85+int32_t MemFreeNalList (PAccessUnit* ppAu, CMemoryAlign* pMa) {
8686 if (ppAu != NULL) {
8787 PAccessUnit pAu = *ppAu;
8888 if (pAu != NULL) {
89− WelsFree (pAu, "Access Unit");
89+ pMa->WelsFree (pAu, "Access Unit");
9090 *ppAu = NULL;
9191 }
9292 }
@@ -94,14 +94,14 @@ int32_t MemFreeNalList (PAccessUnit* ppAu) { · 1 unmodified line
9494 }
9595
9696
97−int32_t ExpandNalUnitList (PAccessUnit* ppAu, const int32_t kiOrgSize, const int32_t kiExpSize) {
97+int32_t ExpandNalUnitList (PAccessUnit* ppAu, const int32_t kiOrgSize, const int32_t kiExpSize, CMemoryAlign* pMa) {
9898 if (kiExpSize <= kiOrgSize)
9999 return 1;
100100 else {
101101 PAccessUnit pTmp = NULL;
102102 int32_t iIdx = 0;
103103
104− if (MemInitNalList (&pTmp, kiExpSize)) // request new list with expanding
104+ if (MemInitNalList (&pTmp, kiExpSize, pMa)) // request new list with expanding
105105 return 1;
106106
107107 do {
@@ -115,7 +115,7 @@ int32_t ExpandNalUnitList (PAccessUnit* ppAu, const int32_t kiOrgSize, const int · 7 unmodified lines
115115 pTmp->uiEndPos = (*ppAu)->uiEndPos;
116116 pTmp->bCompletedAuFlag = (*ppAu)->bCompletedAuFlag;
117117
118− MemFreeNalList (ppAu); // free old list
118+ MemFreeNalList (ppAu, pMa); // free old list
119119 *ppAu = pTmp;
120120 return 0;
121121 }
@@ -126,13 +126,13 @@ int32_t ExpandNalUnitList (PAccessUnit* ppAu, const int32_t kiOrgSize, const int · 4 unmodified lines
126126 * Get next NAL Unit for using.
127127 * Need expand NAL Unit list if exceeding count number of available NAL Units withing an Access Unit
128128 */
129−PNalUnit MemGetNextNal (PAccessUnit* ppAu) {
129+PNalUnit MemGetNextNal (PAccessUnit* ppAu, CMemoryAlign* pMa) {
130130 PAccessUnit pAu = *ppAu;
131131 PNalUnit pNu = NULL;
132132
133133 if (pAu->uiAvailUnitsNum >= pAu->uiCountUnitsNum) { // need expand list
134134 const uint32_t kuiExpandingSize = pAu->uiCountUnitsNum + (MAX_NAL_UNIT_NUM_IN_AU >> 1);
135− if (ExpandNalUnitList (ppAu, pAu->uiCountUnitsNum, kuiExpandingSize))
135+ if (ExpandNalUnitList (ppAu, pAu->uiCountUnitsNum, kuiExpandingSize, pMa))
136136 return NULL; // out of memory
137137 pAu = *ppAu;
138138 }
codec/decoder/core/src/pic_queue.cpp+9−8
@@ -44,7 +44,7 @@ · 43 unmodified lines
4444
4545 namespace WelsDec {
4646
47−void FreePicture (PPicture pPic);
47+void FreePicture (PPicture pPic, CMemoryAlign* pMa);
4848
4949
5050 ///////////////////////////////////Recycled queue management for pictures///////////////////////////////////
@@ -68,8 +68,9 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const · 17 unmodified lines
6868 int32_t iPicChromaHeight = 0;
6969 int32_t iLumaSize = 0;
7070 int32_t iChromaSize = 0;
71+ CMemoryAlign* pMa = pCtx->pMemAlign;
7172
72− pPic = (PPicture) WelsMallocz (sizeof (SPicture), "PPicture");
73+ pPic = (PPicture) pMa->WelsMallocz (sizeof (SPicture), "PPicture");
7374 WELS_VERIFY_RETURN_IF (NULL, NULL == pPic);
7475
7576 memset (pPic, 0, sizeof (SPicture));
@@ -88,9 +89,9 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const · 12 unmodified lines
8889 pPic->iLinesize[0] = iPicWidth;
8990 pPic->iLinesize[1] = pPic->iLinesize[2] = iPicChromaWidth;
9091 } else {
91− pPic->pBuffer[0] = static_cast<uint8_t*> (WelsMallocz (iLumaSize /* luma */
92− + (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]"));
93− WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pBuffer[0], FreePicture (pPic));
92+ pPic->pBuffer[0] = static_cast<uint8_t*> (pMa->WelsMallocz (iLumaSize /* luma */
93+ + (iChromaSize << 1) /* Cb,Cr */, "_pic->buffer[0]"));
94+ WELS_VERIFY_RETURN_PROC_IF (NULL, NULL == pPic->pBuffer[0], FreePicture (pPic, pMa));
9495
9596 memset (pPic->pBuffer[0], 128, (iLumaSize + (iChromaSize << 1)));
9697 pPic->iLinesize[0] = iPicWidth;
@@ -110,14 +111,14 @@ PPicture AllocPicture (PWelsDecoderContext pCtx, const int32_t kiPicWidth, const · 13 unmodified lines
110111 return pPic;
111112 }
112113
113−void FreePicture (PPicture pPic) {
114+void FreePicture (PPicture pPic, CMemoryAlign* pMa) {
114115 if (NULL != pPic) {
115116
116117 if (pPic->pBuffer[0]) {
117− WelsFree (pPic->pBuffer[0], "pPic->pBuffer[0]");
118+ pMa->WelsFree (pPic->pBuffer[0], "pPic->pBuffer[0]");
118119 }
119120
120− WelsFree (pPic, "pPic");
121+ pMa->WelsFree (pPic, "pPic");
121122
122123 pPic = NULL;
123124 }
codec/decoder/plus/src/welsDecoderExt.cpp+16−5
@@ -219,11 +219,19 @@ void CWelsDecoder::UninitDecoder (void) { · 218 unmodified lines
219219 if (NULL == m_pDecContext)
220220 return;
221221
222− WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::uninit_decoder(), openh264 codec version = %s.",
222+ WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO, "CWelsDecoder::UninitDecoder(), openh264 codec version = %s.",
223223 VERSION_NUMBER);
224224
225225 WelsEndDecoder (m_pDecContext);
226226
227+ if (m_pDecContext->pMemAlign != NULL) {
228+ WelsLog (&m_pWelsTrace->m_sLogCtx, WELS_LOG_INFO,
229+ "CWelsDecoder::UninitDecoder(), verify memory usage (%d bytes) after free..",
230+ m_pDecContext->pMemAlign->WelsGetMemoryUsage());
231+ delete m_pDecContext->pMemAlign;
232+ m_pDecContext->pMemAlign = NULL;
233+ }
234+
227235 if (NULL != m_pDecContext) {
228236 WelsFree (m_pDecContext, "m_pDecContext");
229237
@@ -243,6 +251,9 @@ int32_t CWelsDecoder::InitDecoder (const bool bParseOnly) { · 13 unmodified lines
243251 m_pDecContext = (PWelsDecoderContext)WelsMallocz (sizeof (SWelsDecoderContext), "m_pDecContext");
244252 if (NULL == m_pDecContext)
245253 return cmMallocMemeError;
254+ int32_t iCacheLineSize = 16; // on chip cache line size in byte
255+ m_pDecContext->pMemAlign = new CMemoryAlign (iCacheLineSize);
256+ WELS_VERIFY_RETURN_PROC_IF (1, (NULL == m_pDecContext->pMemAlign), UninitDecoder())
246257
247258 return WelsInitDecoder (m_pDecContext, bParseOnly, &m_pWelsTrace->m_sLogCtx);
248259 }
@@ -409,10 +420,10 @@ DECODING_STATE CWelsDecoder::DecodeFrameNoDelay (const unsigned char* kpSrc, · 160 unmodified lines
409420 //ppTmpDst[2] = ppDst[2];
410421 iRet |= DecodeFrame2 (NULL, 0, ppDst, pDstInfo);
411422 //if ((pDstInfo->iBufferStatus == 0) && (sTmpBufferInfo.iBufferStatus == 1)) {
412− //memcpy (pDstInfo, &sTmpBufferInfo, sizeof (SBufferInfo));
413− //ppDst[0] = ppTmpDst[0];
414− //ppDst[1] = ppTmpDst[1];
415− //ppDst[2] = ppTmpDst[2];
423+ //memcpy (pDstInfo, &sTmpBufferInfo, sizeof (SBufferInfo));
424+ //ppDst[0] = ppTmpDst[0];
425+ //ppDst[1] = ppTmpDst[1];
426+ //ppDst[2] = ppTmpDst[2];
416427 //}
417428
418429 return (DECODING_STATE) iRet;

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