History

add dec memory check

huili2 committed 11 years ago

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

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

Unified · Split

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 }

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