WelsReorderRefList2 is the test code
| 479 | |
| 480 | //WelsReorderRefList2 is the test code |
| 481 | int32_t WelsReorderRefList2 (PWelsDecoderContext pCtx) { |
| 482 | |
| 483 | if (pCtx->eSliceType == I_SLICE || pCtx->eSliceType == SI_SLICE) { |
| 484 | return ERR_NONE; |
| 485 | } |
| 486 | |
| 487 | PRefPicListReorderSyn pRefPicListReorderSyn = pCtx->pCurDqLayer->pRefPicListReordering; |
| 488 | PSliceHeader pSliceHeader = &pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader; |
| 489 | |
| 490 | PPicture* ppShoreRefList = pCtx->sRefPic.pShortRefList[LIST_0]; |
| 491 | int32_t iShortRefCount = pCtx->sRefPic.uiShortRefCount[LIST_0]; |
| 492 | PPicture* ppLongRefList = pCtx->sRefPic.pLongRefList[LIST_0]; |
| 493 | int32_t iLongRefCount = pCtx->sRefPic.uiLongRefCount[LIST_0]; |
| 494 | int32_t i = 0; |
| 495 | int32_t j = 0; |
| 496 | int32_t k = 0; |
| 497 | int32_t iMaxRefIdx = pCtx->iPicQueueNumber; |
| 498 | if (iMaxRefIdx > MAX_REF_PIC_COUNT) { |
| 499 | iMaxRefIdx = MAX_REF_PIC_COUNT; |
| 500 | } |
| 501 | const int32_t iCurFrameNum = pSliceHeader->iFrameNum; |
| 502 | const int32_t iMaxPicNum = 1 << pSliceHeader->pSps->uiLog2MaxFrameNum; |
| 503 | int32_t iListCount = 1; |
| 504 | if (pCtx->eSliceType == B_SLICE) iListCount = 2; |
| 505 | for (int32_t listIdx = 0; listIdx < iListCount; ++listIdx) { |
| 506 | PPicture* ppRefList = pCtx->sRefPic.pRefList[listIdx]; |
| 507 | int32_t iCount = 0; |
| 508 | int32_t iRefCount = pSliceHeader->uiRefCount[listIdx]; |
| 509 | int32_t iAbsDiffPicNum = -1; |
| 510 | |
| 511 | if (pRefPicListReorderSyn->bRefPicListReorderingFlag[listIdx]) { |
| 512 | int32_t iPredFrameNum = iCurFrameNum; |
| 513 | for (i = 0; pRefPicListReorderSyn->sReorderingSyn[listIdx][i].uiReorderingOfPicNumsIdc != 3; i++) { |
| 514 | if (iCount >= iMaxRefIdx) |
| 515 | break; |
| 516 | |
| 517 | for (j = iRefCount; j > iCount; j--) |
| 518 | ppRefList[j] = ppRefList[j - 1]; |
| 519 | |
| 520 | uint16_t uiReorderingOfPicNumsIdc = |
| 521 | pRefPicListReorderSyn->sReorderingSyn[listIdx][i].uiReorderingOfPicNumsIdc; |
| 522 | |
| 523 | if (uiReorderingOfPicNumsIdc < 2) { // reorder short references |
| 524 | iAbsDiffPicNum = (int32_t) (pRefPicListReorderSyn->sReorderingSyn[listIdx][i].uiAbsDiffPicNumMinus1 + 1); |
| 525 | if (uiReorderingOfPicNumsIdc == 0) { |
| 526 | if (iPredFrameNum - iAbsDiffPicNum < 0) |
| 527 | iPredFrameNum -= (iAbsDiffPicNum - iMaxPicNum); |
| 528 | else |
| 529 | iPredFrameNum -= iAbsDiffPicNum; |
| 530 | } else { |
| 531 | if (iPredFrameNum + iAbsDiffPicNum >= iMaxPicNum) |
| 532 | iPredFrameNum += (iAbsDiffPicNum - iMaxPicNum); |
| 533 | else |
| 534 | iPredFrameNum += iAbsDiffPicNum; |
| 535 | } |
| 536 | |
| 537 | if (iPredFrameNum > iCurFrameNum) { |
| 538 | iPredFrameNum -= iMaxPicNum; |