MCPcopy Create free account
hub / github.com/cisco/openh264 / WelsReorderRefList

Function WelsReorderRefList

codec/decoder/core/src/manage_dec_ref.cpp:385–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

383}
384
385int32_t WelsReorderRefList (PWelsDecoderContext pCtx) {
386
387 if (pCtx->eSliceType == I_SLICE || pCtx->eSliceType == SI_SLICE) {
388 return ERR_NONE;
389 }
390
391 PRefPicListReorderSyn pRefPicListReorderSyn = pCtx->pCurDqLayer->pRefPicListReordering;
392 PNalUnitHeaderExt pNalHeaderExt = &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt;
393 PSliceHeader pSliceHeader = &pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader;
394 int32_t ListCount = 1;
395 if (pCtx->eSliceType == B_SLICE) ListCount = 2;
396 for (int32_t listIdx = 0; listIdx < ListCount; ++listIdx) {
397 PPicture pPic = NULL;
398 PPicture* ppRefList = pCtx->sRefPic.pRefList[listIdx];
399 int32_t iMaxRefIdx = pCtx->iPicQueueNumber;
400 if (iMaxRefIdx > MAX_REF_PIC_COUNT) {
401 iMaxRefIdx = MAX_REF_PIC_COUNT;
402 }
403 int32_t iRefCount = pSliceHeader->uiRefCount[listIdx];
404 int32_t iPredFrameNum = pSliceHeader->iFrameNum;
405 int32_t iMaxPicNum = 1 << pSliceHeader->pSps->uiLog2MaxFrameNum;
406 int32_t iAbsDiffPicNum = -1;
407 int32_t iReorderingIndex = 0;
408 int32_t i = 0;
409
410 if (iRefCount <= 0) {
411 pCtx->iErrorCode = dsNoParamSets; //No any reference for decoding, SHOULD request IDR
412 return ERR_INFO_REFERENCE_PIC_LOST;
413 }
414
415 if (pRefPicListReorderSyn->bRefPicListReorderingFlag[listIdx]) {
416 while ((iReorderingIndex <= iMaxRefIdx)
417 && (pRefPicListReorderSyn->sReorderingSyn[listIdx][iReorderingIndex].uiReorderingOfPicNumsIdc != 3)) {
418 uint16_t uiReorderingOfPicNumsIdc =
419 pRefPicListReorderSyn->sReorderingSyn[listIdx][iReorderingIndex].uiReorderingOfPicNumsIdc;
420 if (uiReorderingOfPicNumsIdc < 2) {
421 iAbsDiffPicNum = pRefPicListReorderSyn->sReorderingSyn[listIdx][iReorderingIndex].uiAbsDiffPicNumMinus1 + 1;
422
423 if (uiReorderingOfPicNumsIdc == 0) {
424 iPredFrameNum -= iAbsDiffPicNum;
425 } else {
426 iPredFrameNum += iAbsDiffPicNum;
427 }
428 iPredFrameNum &= iMaxPicNum - 1;
429
430 for (i = iMaxRefIdx - 1; i >= 0; i--) {
431 if (ppRefList[i] != NULL && ppRefList[i]->iFrameNum == iPredFrameNum && !ppRefList[i]->bIsLongRef) {
432 if ((pNalHeaderExt->uiQualityId == ppRefList[i]->uiQualityId)
433 && (pSliceHeader->iSpsId != ppRefList[i]->iSpsId)) { //check;
434 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "WelsReorderRefList()::::BASE LAYER::::iSpsId:%d, ref_sps_id:%d",
435 pSliceHeader->iSpsId, ppRefList[i]->iSpsId);
436 pCtx->iErrorCode = dsNoParamSets; //cross-IDR reference frame selection, SHOULD request IDR.--
437 return ERR_INFO_REFERENCE_PIC_LOST;
438 } else {
439 break;
440 }
441 }
442 }

Callers 1

InitRefPicListFunction · 0.85

Calls 1

WelsLogFunction · 0.85

Tested by

no test coverage detected