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
4444
4545 namespace WelsDec {
4646
47−static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag);
48−static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag);
49−static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag);
50−static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag);
47+static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum);
48+static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx);
49+static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum);
50+static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx);
5151
52−static int32_t MMCOBase (PWelsDecoderContext pCtx, PRefBasePicMarking pRefPicBaseMarking);
5352 static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking);
54−static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool bRefBasePic,
53+static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType,
5554 int32_t iShortFrameNum, uint32_t uiLongTermPicNum, int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx);
5655 static int32_t SlidingWindow (PWelsDecoderContext pCtx);
5756
5857 static int32_t AddShortTermToList (PRefPic pRefPic, PPicture pPic);
5958 static int32_t AddLongTermToList (PRefPic pRefPic, PPicture pPic, int32_t iLongTermFrameIdx);
60−static int32_t AssignLongTermIdx (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx);
6159 static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx);
6260
6361 static void SetUnRef (PPicture pRef) {
@@ -67,7 +65,6 @@ static void SetUnRef (PPicture pRef) { · 3 unmodified lines
6765 pRef->iFrameNum = -1;
6866 pRef->iFramePoc = 0;
6967 pRef->iLongTermFrameIdx = -1;
70− pRef->bRefBaseFlag = 0;
7168 pRef->uiQualityId = -1;
7269 pRef->uiTemporalId = -1;
7370 pRef->uiSpatialId = -1;
@@ -114,37 +111,13 @@ int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc) { · 40 unmodified lines
114111 memset (pCtx->sRefPic.pRefList[LIST_0], 0, MAX_REF_PIC_COUNT * sizeof (PPicture));
115112 //short
116113 for (i = 0; i < pCtx->sRefPic.uiShortRefCount[LIST_0]; ++i) {
117− if (kbUseRefBasePicFlag == ppShoreRefList[i]->bRefBaseFlag) {
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− }
114+ pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppShoreRefList[i];
130115 }
131116
132117 //long
133118 j = 0;
134119 for (i = 0; i < pCtx->sRefPic.uiLongRefCount[LIST_0] ; ++i) {
135− if (kbUseRefBasePicFlag == ppLongRefList[i]->bRefBaseFlag) {
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− }
120+ pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppLongRefList[i];
148121 }
149122 pCtx->sRefPic.uiRefCount[LIST_0] = iCount;
150123
@@ -231,7 +204,7 @@ int32_t WelsReorderRefList (PWelsDecoderContext pCtx) { · 80 unmodified lines
231204 return ERR_NONE;
232205 }
233206
234−int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag) {
207+int32_t WelsMarkAsRef (PWelsDecoderContext pCtx) {
235208 PRefPic pRefPic = &pCtx->sRefPic;
236209 PRefPicMarking pRefPicMarking = pCtx->pCurDqLayer->pRefPicMarking;
237210 PRefBasePicMarking pRefPicBaseMarking = pCtx->pCurDqLayer->pRefPicBaseMarking;
@@ -240,14 +213,10 @@ int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag · 2 unmodified lines
240213 uint32_t j;
241214
242215 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− }
246216
247217 pCtx->pDec->bUsedAsRef = true;
248218 pCtx->pDec->uiQualityId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiQualityId;
249219 pCtx->pDec->uiTemporalId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiTemporalId;
250− pCtx->pDec->bRefBaseFlag = kbRefBaseMarkingFlag;
251220
252221 for (j = pCurAU->uiStartPos; j <= pCurAU->uiEndPos; j++) {
253222 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
264233 pCtx->sRefPic.iMaxLongTermFrameIdx = -1;
265234 }
266235 } else {
267− if (pRefPicBaseMarking->bAdaptiveRefBasePicMarkingModeFlag) {
268− iRet = MMCOBase (pCtx, pRefPicBaseMarking);
269− }
270−
271− if (iRet != ERR_NONE) {
272− return iRet;
273− }
274−
275236 if (pRefPicMarking->bAdaptiveRefPicMarkingModeFlag) {
276237 iRet = MMCO (pCtx, pRefPicMarking);
277238 if (pCtx->bLastHasMmco5) {
@@ -293,29 +254,6 @@ int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag · 15 unmodified lines
293254 return iRet;
294255 }
295256
296−static 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−
319257 static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) {
320258 PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps;
321259 int32_t i = 0;
@@ -330,7 +268,7 @@ static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) { · 8 unmodified lines
330268 if (uiMmcoType > MMCO_LONG) {
331269 return ERR_INFO_INVALID_MMCO_OPCODE_BASE;
332270 }
333− iRet = MMCOProcess (pCtx, uiMmcoType, false, iShortFrameNum, uiLongTermPicNum, iLongTermFrameIdx, iMaxLongTermFrameIdx);
271+ iRet = MMCOProcess (pCtx, uiMmcoType, iShortFrameNum, uiLongTermPicNum, iLongTermFrameIdx, iMaxLongTermFrameIdx);
334272 if (iRet != ERR_NONE) {
335273 return iRet;
336274 }
@@ -338,7 +276,7 @@ static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) { · 1 unmodified line
338276
339277 return ERR_NONE;
340278 }
341−static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool bRefBasePic,
279+static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType,
342280 int32_t iShortFrameNum, uint32_t uiLongTermPicNum , int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx) {
343281 PRefPic pRefPic = &pCtx->sRefPic;
344282 PPicture pPic = NULL;
@@ -347,20 +285,17 @@ static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool · 2 unmodified lines
347285
348286 switch (uiMmcoType) {
349287 case MMCO_SHORT2UNUSED:
350− pPic = WelsDelShortFromListSetUnref (pRefPic, iShortFrameNum, (ERemoveFlag) bRefBasePic);
288+ pPic = WelsDelShortFromListSetUnref (pRefPic, iShortFrameNum);
351289 break;
352290 case MMCO_LONG2UNUSED:
353− pPic = WelsDelLongFromListSetUnref (pRefPic, uiLongTermPicNum, (ERemoveFlag) bRefBasePic);
291+ pPic = WelsDelLongFromListSetUnref (pRefPic, uiLongTermPicNum);
354292 break;
355293 case MMCO_SHORT2LONG:
356294 if (iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) {
357295 return ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX;
358296 }
359− pPic = WelsDelShortFromList (pRefPic, iShortFrameNum, REMOVE_TARGET);
360− WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET);
361−
362− WelsDelShortFromList (pRefPic, iShortFrameNum, REMOVE_BASE);
363− WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE);
297+ pPic = WelsDelShortFromList (pRefPic, iShortFrameNum);
298+ WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx);
364299 #ifdef LONG_TERM_REF
365300 pCtx->bCurAuContainLtrMarkSeFlag = true;
366301 pCtx->iFrameNumOfAuMarkedLtr = iShortFrameNum;
@@ -374,7 +309,7 @@ static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool · 7 unmodified lines
374309 pRefPic->iMaxLongTermFrameIdx = iMaxLongTermFrameIdx;
375310 for (i = 0 ; i < pRefPic->uiLongRefCount[LIST_0]; i++) {
376311 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);
378313 }
379314 }
380315 break;
@@ -391,8 +326,7 @@ static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool · 10 unmodified lines
391326 pCtx->iFrameNumOfAuMarkedLtr = pCtx->iFrameNum;
392327 WelsLog (pCtx, WELS_LOG_INFO, "ex_mark_avc():::MMCO_LONG:::LTR marking....iFrameNum: %d\n", pCtx->iFrameNum);
393328 #endif
394− WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET);
395− WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE);
329+ WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx);
396330 iRet = AddLongTermToList (pRefPic, pCtx->pDec, iLongTermFrameIdx);
397331 break;
398332 default :
@@ -409,7 +343,7 @@ static int32_t SlidingWindow (PWelsDecoderContext pCtx) { · 10 unmodified lines
409343
410344 if (pCtx->sRefPic.uiShortRefCount[LIST_0] + pCtx->sRefPic.uiLongRefCount[LIST_0] >= pCtx->pSps->iNumRefFrames) {
411345 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);
413347 if (pPic) {
414348 SetUnRef (pPic);
415349 break;
@@ -421,68 +355,61 @@ static int32_t SlidingWindow (PWelsDecoderContext pCtx) { · 5 unmodified lines
421355 return ERR_NONE;
422356 }
423357
424−static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag) {
358+static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum) {
425359 int32_t i = 0;
426360 int32_t iMoveSize = 0;
427361 PPicture pPic = NULL;
428362
429363 for (i = 0; i < pRefPic->uiShortRefCount[LIST_0]; i++) {
430364 if (pRefPic->pShortRefList[LIST_0][i]->iFrameNum == iFrameNum) {
431− if ((eRemoveFlag == REMOVE_TARGET && !pRefPic->pShortRefList[LIST_0][i]->bRefBaseFlag)
432− || (eRemoveFlag == REMOVE_BASE && pRefPic->pShortRefList[LIST_0][i]->bRefBaseFlag)
433− || (eRemoveFlag == REMOVE_BASE_FIRST)) {
434− iMoveSize = pRefPic->uiShortRefCount[LIST_0] - i - 1;
435− pRefPic->pShortRefList[LIST_0][i]->bUsedAsRef = false;
436− pPic = pRefPic->pShortRefList[LIST_0][i];
437− pRefPic->pShortRefList[LIST_0][i] = NULL;
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;
365+ iMoveSize = pRefPic->uiShortRefCount[LIST_0] - i - 1;
366+ pRefPic->pShortRefList[LIST_0][i]->bUsedAsRef = false;
367+ pPic = pRefPic->pShortRefList[LIST_0][i];
368+ pRefPic->pShortRefList[LIST_0][i] = NULL;
369+ if (iMoveSize > 0) {
370+ memmove (&pRefPic->pShortRefList[LIST_0][i], &pRefPic->pShortRefList[LIST_0][i + 1],
371+ iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage
445372 }
373+ pRefPic->uiShortRefCount[LIST_0]--;
374+ pRefPic->pShortRefList[LIST_0][pRefPic->uiShortRefCount[0]] = NULL;
375+ break;
446376 }
447377 }
448378
449379 return pPic;
450380 }
451381
452−static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag) {
453− PPicture pPic = WelsDelShortFromList (pRefPic, iFrameNum, eRemoveFlag);
382+static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum) {
383+ PPicture pPic = WelsDelShortFromList (pRefPic, iFrameNum);
454384 if (pPic) {
455385 SetUnRef (pPic);
456386 }
457387 return pPic;
458388 }
459389
460−static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag) {
390+static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx) {
461391 PPicture pPic = NULL;
462392 int32_t i = 0;
463393 for (i = 0; i < pRefPic->uiLongRefCount[LIST_0]; i++) {
464394 pPic = pRefPic->pLongRefList[LIST_0][i];
465395 if (pPic->iLongTermFrameIdx == (int32_t)uiLongTermFrameIdx) {
466− if (((eRemoveFlag == REMOVE_TARGET) && ! (pPic->bRefBaseFlag)) || ((eRemoveFlag == REMOVE_BASE)
467− && pPic->bRefBaseFlag)) {
468− int32_t iMoveSize = pRefPic->uiLongRefCount[LIST_0] - i - 1;
469− pPic->bUsedAsRef = false;
470− pPic->bIsLongRef = false;
471− if (iMoveSize > 0) {
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;
396+ int32_t iMoveSize = pRefPic->uiLongRefCount[LIST_0] - i - 1;
397+ pPic->bUsedAsRef = false;
398+ pPic->bIsLongRef = false;
399+ if (iMoveSize > 0) {
400+ memmove (&pRefPic->pLongRefList[LIST_0][i], &pRefPic->pLongRefList[LIST_0][i + 1],
401+ iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage
478402 }
403+ pRefPic->uiLongRefCount[LIST_0]--;
404+ pRefPic->pLongRefList[LIST_0][pRefPic->uiLongRefCount[LIST_0]] = NULL;
405+ return pPic;
479406 }
480407 }
481408 return NULL;
482409 }
483410
484−static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag) {
485− PPicture pPic = WelsDelLongFromList (pRefPic, uiLongTermFrameIdx, eRemoveFlag);
411+static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx) {
412+ PPicture pPic = WelsDelLongFromList (pRefPic, uiLongTermFrameIdx);
486413 if (pPic) {
487414 SetUnRef (pPic);
488415 }
@@ -528,34 +455,11 @@ static int32_t AddLongTermToList (PRefPic pRefPic, PPicture pPic, int32_t iLongT · 39 unmodified lines
528455 return ERR_NONE;
529456 }
530457
531−static 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−
553458 static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx) {
554459 PPicture pPic = NULL;
555460 int32_t i = 0;
556461 int32_t iRet = ERR_NONE;
557− WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET);
558− WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE);
462+ WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx);
559463
560464 for (i = 0; i < pRefPic->uiRefCount[LIST_0]; i++) {
561465 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