History

remove store_ref_base_pic_flag related codes in reference picture management

Licai Guo committed 12 years ago

Commit 5303eaa1 parent c89a6914 files · +50 −166Browse files

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

Unified · Split

codec/decoder/core/src/manage_dec_ref.cpp+43−139
@@ -44,20 +44,18 @@ · 43 unmodified lines
44 44
45namespace WelsDec {45namespace WelsDec {
46 46
47static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag);47static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum);
48static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag);48static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx);
49static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag);49static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum);
50static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag);50static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx);
51 51
52static int32_t MMCOBase (PWelsDecoderContext pCtx, PRefBasePicMarking pRefPicBaseMarking);
53static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking);52static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking);
54static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool bRefBasePic,53static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType,
55 int32_t iShortFrameNum, uint32_t uiLongTermPicNum, int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx);54 int32_t iShortFrameNum, uint32_t uiLongTermPicNum, int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx);
56static int32_t SlidingWindow (PWelsDecoderContext pCtx);55static int32_t SlidingWindow (PWelsDecoderContext pCtx);
57 56
58static int32_t AddShortTermToList (PRefPic pRefPic, PPicture pPic);57static int32_t AddShortTermToList (PRefPic pRefPic, PPicture pPic);
59static int32_t AddLongTermToList (PRefPic pRefPic, PPicture pPic, int32_t iLongTermFrameIdx);58static int32_t AddLongTermToList (PRefPic pRefPic, PPicture pPic, int32_t iLongTermFrameIdx);
60static int32_t AssignLongTermIdx (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx);
61static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx);59static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx);
62 60
63static void SetUnRef (PPicture pRef) {61static void SetUnRef (PPicture pRef) {
@@ -67,7 +65,6 @@ static void SetUnRef (PPicture pRef) { · 3 unmodified lines
67 pRef->iFrameNum = -1;65 pRef->iFrameNum = -1;
68 pRef->iFramePoc = 0;66 pRef->iFramePoc = 0;
69 pRef->iLongTermFrameIdx = -1;67 pRef->iLongTermFrameIdx = -1;
70 pRef->bRefBaseFlag = 0;
71 pRef->uiQualityId = -1;68 pRef->uiQualityId = -1;
72 pRef->uiTemporalId = -1;69 pRef->uiTemporalId = -1;
73 pRef->uiSpatialId = -1;70 pRef->uiSpatialId = -1;
@@ -114,37 +111,13 @@ int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc) { · 40 unmodified lines
114 memset (pCtx->sRefPic.pRefList[LIST_0], 0, MAX_REF_PIC_COUNT * sizeof (PPicture));111 memset (pCtx->sRefPic.pRefList[LIST_0], 0, MAX_REF_PIC_COUNT * sizeof (PPicture));
115 //short112 //short
116 for (i = 0; i < pCtx->sRefPic.uiShortRefCount[LIST_0]; ++i) {113 for (i = 0; i < pCtx->sRefPic.uiShortRefCount[LIST_0]; ++i) {
117 if (kbUseRefBasePicFlag == ppShoreRefList[i]->bRefBaseFlag) {114 pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppShoreRefList[i];
118 pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppShoreRefList[i];
119 } else {
120 for (j = 0; j < pCtx->sRefPic.uiShortRefCount[LIST_0]; ++j) {
121 if (ppShoreRefList[j]->iFrameNum == ppShoreRefList[i]->iFrameNum
122 && ppShoreRefList[j]->bRefBaseFlag == kbUseRefBasePicFlag) {
123 break;
124 }
125 }
126 if (j == pCtx->sRefPic.uiShortRefCount[LIST_0]) {
127 pCtx->sRefPic.pRefList[LIST_0][iCount++] = ppShoreRefList[i];
128 }
129 }
130 }115 }
131 116
132 //long117 //long
133 j = 0;118 j = 0;
134 for (i = 0; i < pCtx->sRefPic.uiLongRefCount[LIST_0] ; ++i) {119 for (i = 0; i < pCtx->sRefPic.uiLongRefCount[LIST_0] ; ++i) {
135 if (kbUseRefBasePicFlag == ppLongRefList[i]->bRefBaseFlag) {120 pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppLongRefList[i];
136 pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppLongRefList[i];
137 } else {
138 for (j = 0; j < pCtx->sRefPic.uiLongRefCount[LIST_0]; ++j) {
139 if (ppLongRefList[j]->iLongTermFrameIdx == ppLongRefList[i]->iLongTermFrameIdx
140 && ppLongRefList[j]->bRefBaseFlag == kbUseRefBasePicFlag) {
141 break;
142 }
143 }
144 if (j == pCtx->sRefPic.uiLongRefCount[LIST_0]) {
145 pCtx->sRefPic.pRefList[LIST_0][iCount++] = ppLongRefList[i];
146 }
147 }
148 }121 }
149 pCtx->sRefPic.uiRefCount[LIST_0] = iCount;122 pCtx->sRefPic.uiRefCount[LIST_0] = iCount;
150 123
@@ -231,7 +204,7 @@ int32_t WelsReorderRefList (PWelsDecoderContext pCtx) { · 80 unmodified lines
231 return ERR_NONE;204 return ERR_NONE;
232}205}
233 206
234int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag) {207int32_t WelsMarkAsRef (PWelsDecoderContext pCtx) {
235 PRefPic pRefPic = &pCtx->sRefPic;208 PRefPic pRefPic = &pCtx->sRefPic;
236 PRefPicMarking pRefPicMarking = pCtx->pCurDqLayer->pRefPicMarking;209 PRefPicMarking pRefPicMarking = pCtx->pCurDqLayer->pRefPicMarking;
237 PRefBasePicMarking pRefPicBaseMarking = pCtx->pCurDqLayer->pRefPicBaseMarking;210 PRefBasePicMarking pRefPicBaseMarking = pCtx->pCurDqLayer->pRefPicBaseMarking;
@@ -240,14 +213,10 @@ int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag · 2 unmodified lines
240 uint32_t j;213 uint32_t j;
241 214
242 int32_t iRet = ERR_NONE;215 int32_t iRet = ERR_NONE;
243 if (pCtx->pCurDqLayer->bStoreRefBasePicFlag && (pCtx->pSps->iNumRefFrames < 2)) {
244 return ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH;
245 }
246 216
247 pCtx->pDec->bUsedAsRef = true;217 pCtx->pDec->bUsedAsRef = true;
248 pCtx->pDec->uiQualityId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiQualityId;218 pCtx->pDec->uiQualityId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiQualityId;
249 pCtx->pDec->uiTemporalId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiTemporalId;219 pCtx->pDec->uiTemporalId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiTemporalId;
250 pCtx->pDec->bRefBaseFlag = kbRefBaseMarkingFlag;
251 220
252 for (j = pCurAU->uiStartPos; j <= pCurAU->uiEndPos; j++) {221 for (j = pCurAU->uiStartPos; j <= pCurAU->uiEndPos; j++) {
253 if (pCurAU->pNalUnitsList[j]->sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR222 if (pCurAU->pNalUnitsList[j]->sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR
@@ -264,14 +233,6 @@ int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag · 10 unmodified lines
264 pCtx->sRefPic.iMaxLongTermFrameIdx = -1;233 pCtx->sRefPic.iMaxLongTermFrameIdx = -1;
265 }234 }
266 } else {235 } else {
267 if (pRefPicBaseMarking->bAdaptiveRefBasePicMarkingModeFlag) {
268 iRet = MMCOBase (pCtx, pRefPicBaseMarking);
269 }
270
271 if (iRet != ERR_NONE) {
272 return iRet;
273 }
274
275 if (pRefPicMarking->bAdaptiveRefPicMarkingModeFlag) {236 if (pRefPicMarking->bAdaptiveRefPicMarkingModeFlag) {
276 iRet = MMCO (pCtx, pRefPicMarking);237 iRet = MMCO (pCtx, pRefPicMarking);
277 if (pCtx->bLastHasMmco5) {238 if (pCtx->bLastHasMmco5) {
@@ -293,29 +254,6 @@ int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag · 15 unmodified lines
293 return iRet;254 return iRet;
294}255}
295 256
296static int32_t MMCOBase (PWelsDecoderContext pCtx, PRefBasePicMarking pRefPicBaseMarking) {
297 PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps;
298 int32_t i = 0;
299 int32_t iRet = ERR_NONE;
300
301 for (i = 0 ; pRefPicBaseMarking->mmco_base[i].uiMmcoType != MMCO_END; i++) {
302 uint32_t uiMmcoType = pRefPicBaseMarking->mmco_base[i].uiMmcoType;
303 int32_t iShortFrameNum = (pCtx->iFrameNum - pRefPicBaseMarking->mmco_base[i].uiDiffOfPicNums) & ((
304 1 << pSps->uiLog2MaxFrameNum) - 1);
305 uint32_t uiLongTermPicNum = pRefPicBaseMarking->mmco_base[i].uiLongTermPicNum;
306 if (uiMmcoType > MMCO_LONG2UNUSED) {
307 return ERR_INFO_INVALID_MMCO_OPCODE_BASE;
308 }
309 iRet = MMCOProcess (pCtx, uiMmcoType, true, iShortFrameNum, uiLongTermPicNum, 0, 0);
310
311 if (iRet != ERR_NONE) {
312 return iRet;
313 }
314 }
315
316 return ERR_NONE;
317}
318
319static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) {257static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) {
320 PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps;258 PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps;
321 int32_t i = 0;259 int32_t i = 0;
@@ -330,7 +268,7 @@ static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) { · 8 unmodified lines
330 if (uiMmcoType > MMCO_LONG) {268 if (uiMmcoType > MMCO_LONG) {
331 return ERR_INFO_INVALID_MMCO_OPCODE_BASE;269 return ERR_INFO_INVALID_MMCO_OPCODE_BASE;
332 }270 }
333 iRet = MMCOProcess (pCtx, uiMmcoType, false, iShortFrameNum, uiLongTermPicNum, iLongTermFrameIdx, iMaxLongTermFrameIdx);271 iRet = MMCOProcess (pCtx, uiMmcoType, iShortFrameNum, uiLongTermPicNum, iLongTermFrameIdx, iMaxLongTermFrameIdx);
334 if (iRet != ERR_NONE) {272 if (iRet != ERR_NONE) {
335 return iRet;273 return iRet;
336 }274 }
@@ -338,7 +276,7 @@ static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) { · 1 unmodified line
338 276
339 return ERR_NONE;277 return ERR_NONE;
340}278}
341static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool bRefBasePic,279static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType,
342 int32_t iShortFrameNum, uint32_t uiLongTermPicNum , int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx) {280 int32_t iShortFrameNum, uint32_t uiLongTermPicNum , int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx) {
343 PRefPic pRefPic = &pCtx->sRefPic;281 PRefPic pRefPic = &pCtx->sRefPic;
344 PPicture pPic = NULL;282 PPicture pPic = NULL;
@@ -347,20 +285,17 @@ static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool · 2 unmodified lines
347 285
348 switch (uiMmcoType) {286 switch (uiMmcoType) {
349 case MMCO_SHORT2UNUSED:287 case MMCO_SHORT2UNUSED:
350 pPic = WelsDelShortFromListSetUnref (pRefPic, iShortFrameNum, (ERemoveFlag) bRefBasePic);288 pPic = WelsDelShortFromListSetUnref (pRefPic, iShortFrameNum);
351 break;289 break;
352 case MMCO_LONG2UNUSED:290 case MMCO_LONG2UNUSED:
353 pPic = WelsDelLongFromListSetUnref (pRefPic, uiLongTermPicNum, (ERemoveFlag) bRefBasePic);291 pPic = WelsDelLongFromListSetUnref (pRefPic, uiLongTermPicNum);
354 break;292 break;
355 case MMCO_SHORT2LONG:293 case MMCO_SHORT2LONG:
356 if (iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) {294 if (iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) {
357 return ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX;295 return ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX;
358 }296 }
359 pPic = WelsDelShortFromList (pRefPic, iShortFrameNum, REMOVE_TARGET);297 pPic = WelsDelShortFromList (pRefPic, iShortFrameNum);
360 WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET);298 WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx);
361
362 WelsDelShortFromList (pRefPic, iShortFrameNum, REMOVE_BASE);
363 WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE);
364#ifdef LONG_TERM_REF299#ifdef LONG_TERM_REF
365 pCtx->bCurAuContainLtrMarkSeFlag = true;300 pCtx->bCurAuContainLtrMarkSeFlag = true;
366 pCtx->iFrameNumOfAuMarkedLtr = iShortFrameNum;301 pCtx->iFrameNumOfAuMarkedLtr = iShortFrameNum;
@@ -374,7 +309,7 @@ static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool · 7 unmodified lines
374 pRefPic->iMaxLongTermFrameIdx = iMaxLongTermFrameIdx;309 pRefPic->iMaxLongTermFrameIdx = iMaxLongTermFrameIdx;
375 for (i = 0 ; i < pRefPic->uiLongRefCount[LIST_0]; i++) {310 for (i = 0 ; i < pRefPic->uiLongRefCount[LIST_0]; i++) {
376 if (pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) {311 if (pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) {
377 WelsDelLongFromListSetUnref (pRefPic, pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx, REMOVE_BASE_FIRST);312 WelsDelLongFromListSetUnref (pRefPic, pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx);
378 }313 }
379 }314 }
380 break;315 break;
@@ -391,8 +326,7 @@ static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool · 10 unmodified lines
391 pCtx->iFrameNumOfAuMarkedLtr = pCtx->iFrameNum;326 pCtx->iFrameNumOfAuMarkedLtr = pCtx->iFrameNum;
392 WelsLog (pCtx, WELS_LOG_INFO, "ex_mark_avc():::MMCO_LONG:::LTR marking....iFrameNum: %d\n", pCtx->iFrameNum);327 WelsLog (pCtx, WELS_LOG_INFO, "ex_mark_avc():::MMCO_LONG:::LTR marking....iFrameNum: %d\n", pCtx->iFrameNum);
393#endif328#endif
394 WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET);329 WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx);
395 WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE);
396 iRet = AddLongTermToList (pRefPic, pCtx->pDec, iLongTermFrameIdx);330 iRet = AddLongTermToList (pRefPic, pCtx->pDec, iLongTermFrameIdx);
397 break;331 break;
398 default :332 default :
@@ -409,7 +343,7 @@ static int32_t SlidingWindow (PWelsDecoderContext pCtx) { · 10 unmodified lines
409 343
410 if (pCtx->sRefPic.uiShortRefCount[LIST_0] + pCtx->sRefPic.uiLongRefCount[LIST_0] >= pCtx->pSps->iNumRefFrames) {344 if (pCtx->sRefPic.uiShortRefCount[LIST_0] + pCtx->sRefPic.uiLongRefCount[LIST_0] >= pCtx->pSps->iNumRefFrames) {
411 for (i = pRefPic->uiShortRefCount[LIST_0] - 1; i >= 0; i--) {345 for (i = pRefPic->uiShortRefCount[LIST_0] - 1; i >= 0; i--) {
412 pPic = WelsDelShortFromList (pRefPic, pRefPic->pShortRefList[LIST_0][i]->iFrameNum, REMOVE_BASE_FIRST);346 pPic = WelsDelShortFromList (pRefPic, pRefPic->pShortRefList[LIST_0][i]->iFrameNum);
413 if (pPic) {347 if (pPic) {
414 SetUnRef (pPic);348 SetUnRef (pPic);
415 break;349 break;
@@ -421,68 +355,61 @@ static int32_t SlidingWindow (PWelsDecoderContext pCtx) { · 5 unmodified lines
421 return ERR_NONE;355 return ERR_NONE;
422}356}
423 357
424static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag) {358static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum) {
425 int32_t i = 0;359 int32_t i = 0;
426 int32_t iMoveSize = 0;360 int32_t iMoveSize = 0;
427 PPicture pPic = NULL;361 PPicture pPic = NULL;
428 362
429 for (i = 0; i < pRefPic->uiShortRefCount[LIST_0]; i++) {363 for (i = 0; i < pRefPic->uiShortRefCount[LIST_0]; i++) {
430 if (pRefPic->pShortRefList[LIST_0][i]->iFrameNum == iFrameNum) {364 if (pRefPic->pShortRefList[LIST_0][i]->iFrameNum == iFrameNum) {
431 if ((eRemoveFlag == REMOVE_TARGET && !pRefPic->pShortRefList[LIST_0][i]->bRefBaseFlag)365 iMoveSize = pRefPic->uiShortRefCount[LIST_0] - i - 1;
432 || (eRemoveFlag == REMOVE_BASE && pRefPic->pShortRefList[LIST_0][i]->bRefBaseFlag)366 pRefPic->pShortRefList[LIST_0][i]->bUsedAsRef = false;
433 || (eRemoveFlag == REMOVE_BASE_FIRST)) {367 pPic = pRefPic->pShortRefList[LIST_0][i];
434 iMoveSize = pRefPic->uiShortRefCount[LIST_0] - i - 1;368 pRefPic->pShortRefList[LIST_0][i] = NULL;
435 pRefPic->pShortRefList[LIST_0][i]->bUsedAsRef = false;369 if (iMoveSize > 0) {
436 pPic = pRefPic->pShortRefList[LIST_0][i];370 memmove (&pRefPic->pShortRefList[LIST_0][i], &pRefPic->pShortRefList[LIST_0][i + 1],
437 pRefPic->pShortRefList[LIST_0][i] = NULL;371 iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage
438 if (iMoveSize > 0) {
439 memmove (&pRefPic->pShortRefList[LIST_0][i], &pRefPic->pShortRefList[LIST_0][i + 1],
440 iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage
441 }
442 pRefPic->uiShortRefCount[LIST_0]--;
443 pRefPic->pShortRefList[LIST_0][pRefPic->uiShortRefCount[0]] = NULL;
444 break;
445 }372 }
373 pRefPic->uiShortRefCount[LIST_0]--;
374 pRefPic->pShortRefList[LIST_0][pRefPic->uiShortRefCount[0]] = NULL;
375 break;
446 }376 }
447 }377 }
448 378
449 return pPic;379 return pPic;
450}380}
451 381
452static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag) {382static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum) {
453 PPicture pPic = WelsDelShortFromList (pRefPic, iFrameNum, eRemoveFlag);383 PPicture pPic = WelsDelShortFromList (pRefPic, iFrameNum);
454 if (pPic) {384 if (pPic) {
455 SetUnRef (pPic);385 SetUnRef (pPic);
456 }386 }
457 return pPic;387 return pPic;
458}388}
459 389
460static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag) {390static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx) {
461 PPicture pPic = NULL;391 PPicture pPic = NULL;
462 int32_t i = 0;392 int32_t i = 0;
463 for (i = 0; i < pRefPic->uiLongRefCount[LIST_0]; i++) {393 for (i = 0; i < pRefPic->uiLongRefCount[LIST_0]; i++) {
464 pPic = pRefPic->pLongRefList[LIST_0][i];394 pPic = pRefPic->pLongRefList[LIST_0][i];
465 if (pPic->iLongTermFrameIdx == (int32_t)uiLongTermFrameIdx) {395 if (pPic->iLongTermFrameIdx == (int32_t)uiLongTermFrameIdx) {
466 if (((eRemoveFlag == REMOVE_TARGET) && ! (pPic->bRefBaseFlag)) || ((eRemoveFlag == REMOVE_BASE)396 int32_t iMoveSize = pRefPic->uiLongRefCount[LIST_0] - i - 1;
467 && pPic->bRefBaseFlag)) {397 pPic->bUsedAsRef = false;
468 int32_t iMoveSize = pRefPic->uiLongRefCount[LIST_0] - i - 1;398 pPic->bIsLongRef = false;
469 pPic->bUsedAsRef = false;399 if (iMoveSize > 0) {
470 pPic->bIsLongRef = false;400 memmove (&pRefPic->pLongRefList[LIST_0][i], &pRefPic->pLongRefList[LIST_0][i + 1],
471 if (iMoveSize > 0) {401 iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage
472 memmove (&pRefPic->pLongRefList[LIST_0][i], &pRefPic->pLongRefList[LIST_0][i + 1],
473 iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage
474 }
475 pRefPic->uiLongRefCount[LIST_0]--;
476 pRefPic->pLongRefList[LIST_0][pRefPic->uiLongRefCount[LIST_0]] = NULL;
477 return pPic;
478 }402 }
403 pRefPic->uiLongRefCount[LIST_0]--;
404 pRefPic->pLongRefList[LIST_0][pRefPic->uiLongRefCount[LIST_0]] = NULL;
405 return pPic;
479 }406 }
480 }407 }
481 return NULL;408 return NULL;
482}409}
483 410
484static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag) {411static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx) {
485 PPicture pPic = WelsDelLongFromList (pRefPic, uiLongTermFrameIdx, eRemoveFlag);412 PPicture pPic = WelsDelLongFromList (pRefPic, uiLongTermFrameIdx);
486 if (pPic) {413 if (pPic) {
487 SetUnRef (pPic);414 SetUnRef (pPic);
488 }415 }
@@ -528,34 +455,11 @@ static int32_t AddLongTermToList (PRefPic pRefPic, PPicture pPic, int32_t iLongT · 39 unmodified lines
528 return ERR_NONE;455 return ERR_NONE;
529}456}
530 457
531static int32_t AssignLongTermIdx (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx) {
532 PPicture pPic = NULL;
533 int32_t iRet = ERR_NONE;
534 WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET);
535 WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE);
536
537 pPic = WelsDelShortFromList (pRefPic, iFrameNum, REMOVE_TARGET);
538 if (pPic) {
539 iRet = AddLongTermToList (pRefPic, pPic, iLongTermFrameIdx);
540 } else {
541 return ERR_INFO_INVALID_REF_MARKING;
542 }
543
544 pPic = NULL;
545 pPic = WelsDelShortFromList (pRefPic, iFrameNum, REMOVE_BASE);
546 if (pPic) {
547 iRet = AddLongTermToList (pRefPic, pPic, iLongTermFrameIdx);
548 }
549
550 return iRet;
551}
552
553static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx) {458static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx) {
554 PPicture pPic = NULL;459 PPicture pPic = NULL;
555 int32_t i = 0;460 int32_t i = 0;
556 int32_t iRet = ERR_NONE;461 int32_t iRet = ERR_NONE;
557 WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET);462 WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx);
558 WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE);
559 463
560 for (i = 0; i < pRefPic->uiRefCount[LIST_0]; i++) {464 for (i = 0; i < pRefPic->uiRefCount[LIST_0]; i++) {
561 pPic = pRefPic->pRefList[LIST_0][i];465 pPic = pRefPic->pRefList[LIST_0][i];

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