History

Fix ossz-buzz reported bug 13185: make the code to be more readable.

xiaotiansf committed 7 years ago

Commit 0fc55021 parent cbc0adb1 file · +19 −15Browse 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+19−15
@@ -165,6 +165,24 @@ static int32_t IncreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 164 unmodified lines
165165 return ERR_NONE;
166166 }
167167
168+static void ResetRefPicReferences (const PWelsDecoderContext& pCtx, const PPicture& inPPic) {
169+ //seach and reset the references of deleted references.
170+ for (int32_t list = LIST_0; list < LIST_A; ++list) {
171+ int32_t refIdx = 0;
172+ PPicture pPic = pCtx->sRefPic.pRefList[list][refIdx];
173+ while (refIdx < MAX_DPB_COUNT && pPic != NULL) {
174+ ++refIdx;
175+ int32_t ref = 0;
176+ while (ref < MAX_DPB_COUNT && *pPic->pRefPic[ref] != NULL) {
177+ if (*pPic->pRefPic[ref] == inPPic) {
178+ *pPic->pRefPic[ref] = NULL;
179+ }
180+ ++ref;
181+ }
182+ }
183+ }
184+}
185+
168186 static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, const int32_t kiOldSize,
169187 const int32_t kiPicWidth, const int32_t kiPicHeight, const int32_t kiNewSize) {
170188 PPicBuff pPicOldBuf = *ppPicBuf;
@@ -212,22 +230,8 @@ static int32_t DecreasePicBuff (PWelsDecoderContext pCtx, PPicBuff* ppPicBuf, co · 41 unmodified lines
212230 for (iPicIdx = iDelIdx; iPicIdx < kiOldSize; iPicIdx++) {
213231 if (iPrevPicIdx != iPicIdx) {
214232 if (pPicOldBuf->ppPic[iPicIdx] != NULL) {
233+ ResetRefPicReferences (pCtx, pPicOldBuf->ppPic[iPicIdx]);
215234 FreePicture (pPicOldBuf->ppPic[iPicIdx], pMa);
216− //seach and reset the references of deleted references.
217− for (int32_t list = LIST_0; list < LIST_A; ++list) {
218− int32_t refIdx = 0;
219− PPicture pPic = pCtx->sRefPic.pRefList[list][refIdx];
220− while (refIdx < MAX_DPB_COUNT && pPic != NULL) {
221− ++refIdx;
222− int32_t ref = 0;
223− while (ref < MAX_DPB_COUNT && *pPic->pRefPic[ref] != NULL) {
224− if (*pPic->pRefPic[ref] == pPicOldBuf->ppPic[iPicIdx]) {
225− *pPic->pRefPic[ref] = NULL;
226− }
227− ++ref;
228− }
229− }
230− }
231235 pPicOldBuf->ppPic[iPicIdx] = NULL;
232236 }
233237 }

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