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

Function ParseRefPicListReordering

codec/decoder/core/src/decoder_core.cpp:447–499  ·  view source on GitHub ↗

* Predeclared function routines .. */

Source from the content-addressed store, hash-verified

445 * Predeclared function routines ..
446 */
447int32_t ParseRefPicListReordering (PBitStringAux pBs, PSliceHeader pSh) {
448 int32_t iList = 0;
449 const EWelsSliceType keSt = pSh->eSliceType;
450 PRefPicListReorderSyn pRefPicListReordering = &pSh->pRefPicListReordering;
451 PSps pSps = pSh->pSps;
452 uint32_t uiCode;
453 if (keSt == I_SLICE || keSt == SI_SLICE)
454 return ERR_NONE;
455
456 // Common syntaxs for P or B slices: list0, list1 followed if B slices used.
457 do {
458 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //ref_pic_list_modification_flag_l0
459 pRefPicListReordering->bRefPicListReorderingFlag[iList] = !!uiCode;
460
461 if (pRefPicListReordering->bRefPicListReorderingFlag[iList]) {
462 int32_t iIdx = 0;
463 do {
464 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //modification_of_pic_nums_idc
465 const uint32_t kuiIdc = uiCode;
466
467 //Fixed the referrence list reordering crash issue.(fault kIdc value > 3 case)---
468 if (((iIdx >= MAX_REF_PIC_COUNT) && (kuiIdc != 3)) || (kuiIdc > 3)) {
469 return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_REF_REORDERING);
470 }
471 pRefPicListReordering->sReorderingSyn[iList][iIdx].uiReorderingOfPicNumsIdc = kuiIdc;
472 if (kuiIdc == 3)
473 break;
474
475 if (iIdx >= pSh->uiRefCount[iList] || iIdx >= MAX_REF_PIC_COUNT)
476 return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_REF_REORDERING);
477
478 if (kuiIdc == 0 || kuiIdc == 1) {
479 // abs_diff_pic_num_minus1 should be in range 0 to MaxPicNum-1, MaxPicNum is derived as
480 // 2^(4+log2_max_frame_num_minus4)
481 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //abs_diff_pic_num_minus1
482 WELS_CHECK_SE_UPPER_ERROR_NOLOG (uiCode, (uint32_t) (1 << pSps->uiLog2MaxFrameNum), "abs_diff_pic_num_minus1",
483 GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_REF_REORDERING));
484 pRefPicListReordering->sReorderingSyn[iList][iIdx].uiAbsDiffPicNumMinus1 = uiCode; // uiAbsDiffPicNumMinus1
485 } else if (kuiIdc == 2) {
486 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_pic_num
487 pRefPicListReordering->sReorderingSyn[iList][iIdx].uiLongTermPicNum = uiCode;
488 }
489
490 ++ iIdx;
491 } while (true);
492 }
493 if (keSt != B_SLICE)
494 break;
495 ++ iList;
496 } while (iList < LIST_A);
497
498 return ERR_NONE;
499}
500
501int32_t ParseDecRefPicMarking (PWelsDecoderContext pCtx, PBitStringAux pBs, PSliceHeader pSh, PSps pSps,
502 const bool kbIdrFlag) {

Callers 1

ParseSliceHeaderSyntaxsFunction · 0.85

Calls 2

BsGetOneBitFunction · 0.85
BsGetUeFunction · 0.85

Tested by

no test coverage detected