History

add log for ref pic buffer memory alloc

huili2 committed 11 years ago

Commit 14eeaf21 parent e041bc61 file · +41 −28Browse files

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

Unified · Split

codec/decoder/core/src/decoder.cpp+41−28
@@ -95,11 +95,11 @@ static int32_t CreatePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, cons · 94 unmodified lines
9595 }
9696
9797 static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiOldSize,
98− const int32_t kiPicWidth, const int32_t kiPicHeight, const int32_t kiNewSize) {
98+ const int32_t kiPicWidth, const int32_t kiPicHeight, const int32_t kiNewSize) {
9999 PPicBuff pPicOldBuf = *ppPicBuf;
100100 PPicBuff pPicNewBuf = NULL;
101101 int32_t iPicIdx = 0;
102− if (kiOldSize<=0 || kiNewSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {
102+ if (kiOldSize <= 0 || kiNewSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {
103103 return 1;
104104 }
105105
@@ -115,7 +115,7 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 9 unmodified lines
115115 return 1;
116116 }
117117 // copy old PicBuf to new PicBuf
118− memcpy(pPicNewBuf->ppPic, pPicOldBuf->ppPic, kiOldSize * sizeof(PPicture));
118+ memcpy (pPicNewBuf->ppPic, pPicOldBuf->ppPic, kiOldSize * sizeof (PPicture));
119119 // initialize context in queue
120120 pPicNewBuf->iCapacity = kiNewSize;
121121 pPicNewBuf->iCurrentIdx = pPicOldBuf->iCurrentIdx;
@@ -143,11 +143,11 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 21 unmodified lines
143143 }
144144
145145 static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiOldSize,
146− const int32_t kiPicWidth, const int32_t kiPicHeight, const int32_t kiNewSize) {
146+ const int32_t kiPicWidth, const int32_t kiPicHeight, const int32_t kiNewSize) {
147147 PPicBuff pPicOldBuf = *ppPicBuf;
148148 PPicBuff pPicNewBuf = NULL;
149149 int32_t iPicIdx = 0;
150− if (kiOldSize<=0 || kiNewSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {
150+ if (kiOldSize <= 0 || kiNewSize <= 0 || kiPicWidth <= 0 || kiPicHeight <= 0) {
151151 return 1;
152152 }
153153
@@ -165,29 +165,29 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 11 unmodified lines
165165
166166 int32_t iPrevPicIdx = -1;
167167 for (iPrevPicIdx = 0; iPrevPicIdx < kiOldSize; ++iPrevPicIdx) {
168− if(pCtx->pPreviousDecodedPictureInDpb == pPicOldBuf->ppPic[iPrevPicIdx]) {
168+ if (pCtx->pPreviousDecodedPictureInDpb == pPicOldBuf->ppPic[iPrevPicIdx]) {
169169 break;
170170 }
171171 }
172172 int32_t iDelIdx;
173− if(iPrevPicIdx < kiOldSize && iPrevPicIdx >= kiNewSize) {
174− // found pPreviousDecodedPictureInDpb,
173+ if (iPrevPicIdx < kiOldSize && iPrevPicIdx >= kiNewSize) {
174+ // found pPreviousDecodedPictureInDpb,
175175 pPicNewBuf->ppPic[0] = pPicOldBuf->ppPic[iPrevPicIdx];
176176 pPicNewBuf->iCurrentIdx = 0;
177− memcpy(pPicNewBuf->ppPic + 1, pPicOldBuf->ppPic, (kiNewSize - 1) * sizeof(PPicture));
177+ memcpy (pPicNewBuf->ppPic + 1, pPicOldBuf->ppPic, (kiNewSize - 1) * sizeof (PPicture));
178178 iDelIdx = kiNewSize - 1;
179179 } else {
180− memcpy(pPicNewBuf->ppPic, pPicOldBuf->ppPic, kiNewSize * sizeof(PPicture));
181− pPicNewBuf->iCurrentIdx = iPrevPicIdx < kiNewSize? iPrevPicIdx : 0;
180+ memcpy (pPicNewBuf->ppPic, pPicOldBuf->ppPic, kiNewSize * sizeof (PPicture));
181+ pPicNewBuf->iCurrentIdx = iPrevPicIdx < kiNewSize ? iPrevPicIdx : 0;
182182 iDelIdx = kiNewSize;
183183 }
184184
185− for(iPicIdx = iDelIdx; iPicIdx < kiOldSize; iPicIdx++) {
186− if(iPrevPicIdx != iPicIdx) {
185+ for (iPicIdx = iDelIdx; iPicIdx < kiOldSize; iPicIdx++) {
186+ if (iPrevPicIdx != iPicIdx) {
187187 if (pPicOldBuf->ppPic[iPicIdx] != NULL) {
188188 FreePicture (pPicOldBuf->ppPic[iPicIdx]);
189189 pPicOldBuf->ppPic[iPicIdx] = NULL;
190− }
190+ }
191191 }
192192 }
193193
@@ -338,27 +338,40 @@ int32_t WelsRequestMem (PWelsDecoderContext pCtx, const int32_t kiMbWidth, const · 144 unmodified lines
338338 // sync update pRefList
339339 WelsResetRefPic (pCtx); // added to sync update ref list due to pictures are free
340340
341− if(pCtx->bHaveGotMemory && (kiPicWidth == pCtx->iImgWidthInPixel && kiPicHeight == pCtx->iImgHeightInPixel)
342− && pCtx->pPicBuff[LIST_0] != NULL && pCtx->pPicBuff[LIST_0]->iCapacity != iPicQueueSize) {
343− // currently only active for LIST_0 due to have no B frames
341+ if (pCtx->bHaveGotMemory && (kiPicWidth == pCtx->iImgWidthInPixel && kiPicHeight == pCtx->iImgHeightInPixel)
342+ && pCtx->pPicBuff[LIST_0] != NULL && pCtx->pPicBuff[LIST_0]->iCapacity != iPicQueueSize) {
343+ // currently only active for LIST_0 due to have no B frames
344+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO,
345+ "WelsRequestMem(): memory re-alloc for no resolution change (size = %d * %d), ref list size change from %d to %d",
346+ kiPicWidth, kiPicHeight, pCtx->pPicBuff[LIST_0]->iCapacity, iPicQueueSize);
344347 if (pCtx->pPicBuff[LIST_0]->iCapacity < iPicQueueSize) {
345− iErr = IncreasePicBuff (pCtx, &pCtx->pPicBuff[LIST_0], pCtx->pPicBuff[LIST_0]->iCapacity, kiPicWidth, kiPicHeight, iPicQueueSize);
348+ iErr = IncreasePicBuff (pCtx, &pCtx->pPicBuff[LIST_0], pCtx->pPicBuff[LIST_0]->iCapacity, kiPicWidth, kiPicHeight,
349+ iPicQueueSize);
346350 } else {
347− iErr = DecreasePicBuff (pCtx, &pCtx->pPicBuff[LIST_0], pCtx->pPicBuff[LIST_0]->iCapacity, kiPicWidth, kiPicHeight, iPicQueueSize);
351+ iErr = DecreasePicBuff (pCtx, &pCtx->pPicBuff[LIST_0], pCtx->pPicBuff[LIST_0]->iCapacity, kiPicWidth, kiPicHeight,
352+ iPicQueueSize);
348353 }
349354 } else {
350− // for Recycled_Pic_Queue
351− for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) {
352− PPicBuff* ppPic = &pCtx->pPicBuff[iListIdx];
353− if (NULL != ppPic && NULL != *ppPic) {
354− DestroyPicBuff (ppPic);
355− }
355+ if (pCtx->bHaveGotMemory)
356+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO,
357+ "WelsRequestMem(): memory re-alloc for resolution change, size change from %d * %d to %d * %d, ref list size change from %d to %d",
358+ pCtx->iImgWidthInPixel, pCtx->iImgHeightInPixel, kiPicWidth, kiPicHeight, pCtx->pPicBuff[LIST_0]->iCapacity,
359+ iPicQueueSize);
360+ else
361+ WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, "WelsRequestMem(): memory alloc size = %d * %d, ref list size = %d",
362+ kiPicWidth, kiPicHeight, iPicQueueSize);
363+ // for Recycled_Pic_Queue
364+ for (iListIdx = LIST_0; iListIdx < LIST_A; ++ iListIdx) {
365+ PPicBuff* ppPic = &pCtx->pPicBuff[iListIdx];
366+ if (NULL != ppPic && NULL != *ppPic) {
367+ DestroyPicBuff (ppPic);
356368 }
369+ }
357370
358− pCtx->pPreviousDecodedPictureInDpb = NULL;
371+ pCtx->pPreviousDecodedPictureInDpb = NULL;
359372
360− // currently only active for LIST_0 due to have no B frames
361− iErr = CreatePicBuff (pCtx, &pCtx->pPicBuff[LIST_0], iPicQueueSize, kiPicWidth, kiPicHeight);
373+ // currently only active for LIST_0 due to have no B frames
374+ iErr = CreatePicBuff (pCtx, &pCtx->pPicBuff[LIST_0], iPicQueueSize, kiPicWidth, kiPicHeight);
362375 }
363376
364377 if (iErr != ERR_NONE)

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