Showing the changes to codec/decoder/core/src/decoder_core.cpp (1 of 7 files). Show all
Unified · Split
| @@ -156,17 +156,20 @@ int32_t ParseRefPicListReordering (PBitStringAux pBs, PSliceHeader pSh) { · 155 unmodified lines | ||
| 156 | 156 | const ESliceType keSt = pSh->eSliceType; |
| 157 | 157 | PRefPicListReorderSyn pRefPicListReordering = &pSh->pRefPicListReordering; |
| 158 | 158 | PSps pSps = pSh->pSps; |
| 159 | + uint32_t uiCode; | |
| 159 | 160 | if (keSt == I_SLICE || keSt == SI_SLICE) |
| 160 | 161 | return ERR_NONE; |
| 161 | 162 | |
| 162 | 163 | // Common syntaxs for P or B slices: list0, list1 followed if B slices used. |
| 163 | 164 | do { |
| 164 | − pRefPicListReordering->bRefPicListReorderingFlag[iList] = !!BsGetOneBit (pBs); | |
| 165 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //ref_pic_list_modification_flag_l0 | |
| 166 | + pRefPicListReordering->bRefPicListReorderingFlag[iList] = !!uiCode; | |
| 165 | 167 | |
| 166 | 168 | if (pRefPicListReordering->bRefPicListReorderingFlag[iList]) { |
| 167 | 169 | int32_t iIdx = 0; |
| 168 | 170 | do { |
| 169 | − const uint32_t kuiIdc = BsGetUe (pBs); | |
| 171 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //modification_of_pic_nums_idc | |
| 172 | + const uint32_t kuiIdc = uiCode; | |
| 170 | 173 | |
| 171 | 174 | //Fixed the referrence list reordering crash issue.(fault kIdc value > 3 case)--- |
| 172 | 175 | if ((iIdx >= MAX_REF_PIC_COUNT) || (kuiIdc > 3)) { |
| @@ -182,12 +185,13 @@ int32_t ParseRefPicListReordering (PBitStringAux pBs, PSliceHeader pSh) { · 9 unmodified lines | ||
| 182 | 185 | if (kuiIdc == 0 || kuiIdc == 1) { |
| 183 | 186 | // abs_diff_pic_num_minus1 should be in range 0 to MaxPicNum-1, MaxPicNum is derived as |
| 184 | 187 | // 2^(4+log2_max_frame_num_minus4) |
| 185 | − uint32_t uiTmp = BsGetUe (pBs); | |
| 186 | − WELS_CHECK_SE_UPPER_ERROR_NOLOG (uiTmp, (1 << pSps->uiLog2MaxFrameNum), "abs_diff_pic_num_minus1", | |
| 188 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //abs_diff_pic_num_minus1 | |
| 189 | + WELS_CHECK_SE_UPPER_ERROR_NOLOG (uiCode, (1 << pSps->uiLog2MaxFrameNum), "abs_diff_pic_num_minus1", | |
| 187 | 190 | GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_REF_REORDERING)); |
| 188 | − pRefPicListReordering->sReorderingSyn[iList][iIdx].uiAbsDiffPicNumMinus1 = uiTmp; // uiAbsDiffPicNumMinus1 | |
| 191 | + pRefPicListReordering->sReorderingSyn[iList][iIdx].uiAbsDiffPicNumMinus1 = uiCode; // uiAbsDiffPicNumMinus1 | |
| 189 | 192 | } else if (kuiIdc == 2) { |
| 190 | − pRefPicListReordering->sReorderingSyn[iList][iIdx].uiLongTermPicNum = BsGetUe (pBs); | |
| 193 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_pic_num | |
| 194 | + pRefPicListReordering->sReorderingSyn[iList][iIdx].uiLongTermPicNum = uiCode; | |
| 191 | 195 | } |
| 192 | 196 | |
| 193 | 197 | ++ iIdx; |
| @@ -205,31 +209,41 @@ int32_t ParseDecRefPicMarking (PWelsDecoderContext pCtx, PBitStringAux pBs, PSli · 11 unmodified lines | ||
| 205 | 209 | const bool kbIdrFlag) { |
| 206 | 210 | PRefPicMarking const kpRefMarking = &pSh->sRefMarking; |
| 207 | 211 | PRefPic pRefPic = &pCtx->sRefPic; |
| 212 | + uint32_t uiCode; | |
| 208 | 213 | if (kbIdrFlag) { |
| 209 | − kpRefMarking->bNoOutputOfPriorPicsFlag = !!BsGetOneBit (pBs); | |
| 210 | − kpRefMarking->bLongTermRefFlag = !!BsGetOneBit (pBs); | |
| 214 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //no_output_of_prior_pics_flag | |
| 215 | + kpRefMarking->bNoOutputOfPriorPicsFlag = !!uiCode; | |
| 216 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //long_term_reference_flag | |
| 217 | + kpRefMarking->bLongTermRefFlag = !!uiCode; | |
| 211 | 218 | } else { |
| 212 | − kpRefMarking->bAdaptiveRefPicMarkingModeFlag = !!BsGetOneBit (pBs); | |
| 219 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //adaptive_ref_pic_marking_mode_flag | |
| 220 | + kpRefMarking->bAdaptiveRefPicMarkingModeFlag = !!uiCode; | |
| 213 | 221 | if (kpRefMarking->bAdaptiveRefPicMarkingModeFlag) { |
| 214 | 222 | int32_t iIdx = 0; |
| 215 | 223 | do { |
| 216 | − const int32_t kiMmco = BsGetUe (pBs); | |
| 224 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //memory_management_control_operation | |
| 225 | + const int32_t kiMmco = uiCode; | |
| 217 | 226 | |
| 218 | 227 | kpRefMarking->sMmcoRef[iIdx].uiMmcoType = kiMmco; |
| 219 | 228 | if (kiMmco == MMCO_END) |
| 220 | 229 | break; |
| 221 | 230 | |
| 222 | 231 | if (kiMmco == MMCO_SHORT2UNUSED || kiMmco == MMCO_SHORT2LONG) { |
| 223 | − kpRefMarking->sMmcoRef[iIdx].iDiffOfPicNum = 1 + BsGetUe (pBs); | |
| 232 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //difference_of_pic_nums_minus1 | |
| 233 | + kpRefMarking->sMmcoRef[iIdx].iDiffOfPicNum = 1 + uiCode; | |
| 224 | 234 | kpRefMarking->sMmcoRef[iIdx].iShortFrameNum = (pSh->iFrameNum - kpRefMarking->sMmcoRef[iIdx].iDiffOfPicNum) & (( |
| 225 | 235 | 1 << pSps->uiLog2MaxFrameNum) - 1); |
| 226 | − } else if (kiMmco == MMCO_LONG2UNUSED) | |
| 227 | − kpRefMarking->sMmcoRef[iIdx].uiLongTermPicNum = BsGetUe (pBs); | |
| 228 | − | |
| 236 | + } else if (kiMmco == MMCO_LONG2UNUSED) { | |
| 237 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_pic_num | |
| 238 | + kpRefMarking->sMmcoRef[iIdx].uiLongTermPicNum = uiCode; | |
| 239 | + } | |
| 229 | 240 | if (kiMmco == MMCO_SHORT2LONG || kiMmco == MMCO_LONG) { |
| 230 | − kpRefMarking->sMmcoRef[iIdx].iLongTermFrameIdx = BsGetUe (pBs); | |
| 231 | − } else if (kiMmco == MMCO_SET_MAX_LONG) | |
| 232 | − kpRefMarking->sMmcoRef[iIdx].iMaxLongTermFrameIdx = -1 + BsGetUe (pBs); | |
| 241 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_frame_idx | |
| 242 | + kpRefMarking->sMmcoRef[iIdx].iLongTermFrameIdx = uiCode; | |
| 243 | + } else if (kiMmco == MMCO_SET_MAX_LONG) { | |
| 244 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //max_long_term_frame_idx_plus1 | |
| 245 | + kpRefMarking->sMmcoRef[iIdx].iMaxLongTermFrameIdx = -1 + uiCode; | |
| 246 | + } | |
| 233 | 247 | ++ iIdx; |
| 234 | 248 | |
| 235 | 249 | } while (iIdx < MAX_MMCO_COUNT); |
| @@ -477,9 +491,10 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 241 unmodified lines | ||
| 477 | 491 | int32_t iRet = ERR_NONE; |
| 478 | 492 | uint8_t uiSliceType = 0; |
| 479 | 493 | uint8_t uiQualityId = BASE_QUALITY_ID; |
| 480 | − uint32_t uiTmp; | |
| 481 | 494 | bool bIdrFlag = false; |
| 482 | 495 | bool bSgChangeCycleInvolved = false; // involved slice group change cycle ? |
| 496 | + uint32_t uiCode; | |
| 497 | + int32_t iCode; | |
| 483 | 498 | |
| 484 | 499 | if (kpCurNal == NULL) { |
| 485 | 500 | return ERR_INFO_OUT_OF_MEMORY; |
| @@ -503,9 +518,11 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 17 unmodified lines | ||
| 503 | 518 | kpCurNal->sNalData.sVclNal.bSliceHeaderExtFlag = kbExtensionFlag; |
| 504 | 519 | |
| 505 | 520 | // first_mb_in_slice |
| 506 | − pSliceHead->iFirstMbInSlice = BsGetUe (pBs); | |
| 521 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //first_mb_in_slice | |
| 522 | + pSliceHead->iFirstMbInSlice = uiCode; | |
| 507 | 523 | |
| 508 | − uiSliceType = BsGetUe (pBs); | |
| 524 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //slice_type | |
| 525 | + uiSliceType = uiCode; | |
| 509 | 526 | if (uiSliceType > 9) { |
| 510 | 527 | WelsLog (pCtx, WELS_LOG_WARNING, "slice type too large (%d) at first_mb(%d)\n", uiSliceType, |
| 511 | 528 | pSliceHead->iFirstMbInSlice); |
| @@ -528,7 +545,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 16 unmodified lines | ||
| 528 | 545 | |
| 529 | 546 | pSliceHead->eSliceType = static_cast <ESliceType> (uiSliceType); |
| 530 | 547 | |
| 531 | − iPpsId = BsGetUe (pBs); | |
| 548 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_parameter_set_id | |
| 549 | + iPpsId = uiCode; | |
| 532 | 550 | |
| 533 | 551 | if (iPpsId >= MAX_PPS_COUNT) { |
| 534 | 552 | WelsLog (pCtx, WELS_LOG_WARNING, "iPpsId out of range\n"); |
| @@ -583,7 +601,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 48 unmodified lines | ||
| 583 | 601 | // check first_mb_in_slice |
| 584 | 602 | WELS_CHECK_SE_UPPER_ERROR ((uint32_t) (pSliceHead->iFirstMbInSlice), pSps->uiTotalMbCount, "first_mb_in_slice", |
| 585 | 603 | GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_FIRST_MB_IN_SLICE)); |
| 586 | − pSliceHead->iFrameNum = BsGetBits (pBs, pSps->uiLog2MaxFrameNum); | |
| 604 | + WELS_READ_VERIFY (BsGetBits (pBs, pSps->uiLog2MaxFrameNum, &uiCode)); //frame_num | |
| 605 | + pSliceHead->iFrameNum = uiCode; | |
| 587 | 606 | |
| 588 | 607 | pSliceHead->bFieldPicFlag = false; |
| 589 | 608 | pSliceHead->bBottomFiledFlag = false; |
| @@ -601,11 +620,11 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 11 unmodified lines | ||
| 601 | 620 | pSliceHead->iFrameNum); |
| 602 | 621 | return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_FRAME_NUM); |
| 603 | 622 | } |
| 604 | − uiTmp = BsGetUe (pBs); | |
| 623 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //idr_pic_id | |
| 605 | 624 | // standard 7.4.3 idr_pic_id should be in range 0 to 65535, inclusive. |
| 606 | − WELS_CHECK_SE_UPPER_ERROR (uiTmp, SLICE_HEADER_IDR_PIC_ID_MAX, "idr_pic_id", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, | |
| 625 | + WELS_CHECK_SE_UPPER_ERROR (uiCode, SLICE_HEADER_IDR_PIC_ID_MAX, "idr_pic_id", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, | |
| 607 | 626 | ERR_INFO_INVALID_IDR_PIC_ID)); |
| 608 | − pSliceHead->uiIdrPicId = uiTmp; /* uiIdrPicId */ | |
| 627 | + pSliceHead->uiIdrPicId = uiCode; /* uiIdrPicId */ | |
| 609 | 628 | #ifdef LONG_TERM_REF |
| 610 | 629 | pCtx->uiCurIdrPicId = pSliceHead->uiIdrPicId; |
| 611 | 630 | #endif |
| @@ -615,23 +634,28 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 3 unmodified lines | ||
| 615 | 634 | pSliceHead->iDeltaPicOrderCnt[0] = |
| 616 | 635 | pSliceHead->iDeltaPicOrderCnt[1] = 0; |
| 617 | 636 | if (pSps->uiPocType == 0) { |
| 618 | − pSliceHead->iPicOrderCntLsb = BsGetBits (pBs, pSps->iLog2MaxPocLsb); | |
| 637 | + WELS_READ_VERIFY (BsGetBits (pBs, pSps->iLog2MaxPocLsb, &uiCode)); //pic_order_cnt_lsb | |
| 638 | + pSliceHead->iPicOrderCntLsb = uiCode; | |
| 619 | 639 | if (pPps->bPicOrderPresentFlag && !pSliceHead->bFieldPicFlag) { |
| 620 | − pSliceHead->iDeltaPicOrderCntBottom = BsGetSe (pBs); | |
| 640 | + WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //delta_pic_order_cnt_bottom | |
| 641 | + pSliceHead->iDeltaPicOrderCntBottom = iCode; | |
| 621 | 642 | } |
| 622 | 643 | } else if (pSps->uiPocType == 1 && !pSps->bDeltaPicOrderAlwaysZeroFlag) { |
| 623 | − pSliceHead->iDeltaPicOrderCnt[0] = BsGetSe (pBs); | |
| 624 | − if (pPps->bPicOrderPresentFlag && !pSliceHead->bFieldPicFlag) | |
| 625 | − pSliceHead->iDeltaPicOrderCnt[1] = BsGetSe (pBs); | |
| 644 | + WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //delta_pic_order_cnt[ 0 ] | |
| 645 | + pSliceHead->iDeltaPicOrderCnt[0] = iCode; | |
| 646 | + if (pPps->bPicOrderPresentFlag && !pSliceHead->bFieldPicFlag) { | |
| 647 | + WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //delta_pic_order_cnt[ 1 ] | |
| 648 | + pSliceHead->iDeltaPicOrderCnt[1] = iCode; | |
| 649 | + } | |
| 626 | 650 | } |
| 627 | 651 | |
| 628 | 652 | pSliceHead->iRedundantPicCnt = 0; |
| 629 | 653 | if (pPps->bRedundantPicCntPresentFlag) { |
| 630 | − uiTmp = BsGetUe (pBs); | |
| 654 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //redundant_pic_cnt | |
| 631 | 655 | // standard section 7.4.3, redundant_pic_cnt should be in range 0 to 127, inclusive. |
| 632 | − WELS_CHECK_SE_UPPER_ERROR (uiTmp, SLICE_HEADER_REDUNDANT_PIC_CNT_MAX, "redundant_pic_cnt", | |
| 656 | + WELS_CHECK_SE_UPPER_ERROR (uiCode, SLICE_HEADER_REDUNDANT_PIC_CNT_MAX, "redundant_pic_cnt", | |
| 633 | 657 | GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_REDUNDANT_PIC_CNT)); |
| 634 | − pSliceHead->iRedundantPicCnt = uiTmp; | |
| 658 | + pSliceHead->iRedundantPicCnt = uiCode; | |
| 635 | 659 | } |
| 636 | 660 | |
| 637 | 661 | //set defaults, might be overriden a few line later |
| @@ -645,9 +669,11 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 7 unmodified lines | ||
| 645 | 669 | WelsLog (pCtx, WELS_LOG_WARNING, "ParseSliceHeaderSyntaxs(): kbBipredFlag = 1 not supported.\n"); |
| 646 | 670 | return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_UNSUPPORTED_BIPRED); |
| 647 | 671 | } |
| 648 | − pSliceHead->bNumRefIdxActiveOverrideFlag = !!BsGetOneBit (pBs); | |
| 672 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //num_ref_idx_active_override_flag | |
| 673 | + pSliceHead->bNumRefIdxActiveOverrideFlag = !!uiCode; | |
| 649 | 674 | if (pSliceHead->bNumRefIdxActiveOverrideFlag) { |
| 650 | − pSliceHead->uiRefCount[0] = 1 + BsGetUe (pBs); | |
| 675 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //num_ref_idx_l0_active_minus1 | |
| 676 | + pSliceHead->uiRefCount[0] = 1 + uiCode; | |
| 651 | 677 | } |
| 652 | 678 | } |
| 653 | 679 | |
| @@ -677,7 +703,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 23 unmodified lines | ||
| 677 | 703 | } |
| 678 | 704 | |
| 679 | 705 | if (kbExtensionFlag && !pSubsetSps->sSpsSvcExt.bSliceHeaderRestrictionFlag) { |
| 680 | − pSliceHeadExt->bStoreRefBasePicFlag = !!BsGetOneBit (pBs); | |
| 706 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //store_ref_base_pic_flag | |
| 707 | + pSliceHeadExt->bStoreRefBasePicFlag = !!uiCode; | |
| 681 | 708 | if ((pNalHeaderExt->bUseRefBasePicFlag || pSliceHeadExt->bStoreRefBasePicFlag) && !bIdrFlag) { |
| 682 | 709 | WelsLog (pCtx, WELS_LOG_WARNING, |
| 683 | 710 | "ParseSliceHeaderSyntaxs(): bUseRefBasePicFlag or bStoreRefBasePicFlag = 1 not supported.\n"); |
| @@ -692,7 +719,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 8 unmodified lines | ||
| 692 | 719 | return GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_UNSUPPORTED_CABAC_EL); |
| 693 | 720 | } |
| 694 | 721 | |
| 695 | − pSliceHead->iSliceQpDelta = BsGetSe (pBs); | |
| 722 | + WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //slice_qp_delta | |
| 723 | + pSliceHead->iSliceQpDelta = iCode; | |
| 696 | 724 | pSliceHead->iSliceQp = pPps->iPicInitQp + pSliceHead->iSliceQpDelta; |
| 697 | 725 | if (pSliceHead->iSliceQp < 0 || pSliceHead->iSliceQp > 51) { |
| 698 | 726 | WelsLog (pCtx, WELS_LOG_WARNING, "QP %d out of range\n", pSliceHead->iSliceQp); |
| @@ -711,7 +739,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 12 unmodified lines | ||
| 711 | 739 | pSliceHead->iSliceAlphaC0Offset = 0; |
| 712 | 740 | pSliceHead->iSliceBetaOffset = 0; |
| 713 | 741 | if (pPps->bDeblockingFilterControlPresentFlag) { |
| 714 | − pSliceHead->uiDisableDeblockingFilterIdc = BsGetUe (pBs); | |
| 742 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //disable_deblocking_filter_idc | |
| 743 | + pSliceHead->uiDisableDeblockingFilterIdc = uiCode; | |
| 715 | 744 | //refer to JVT-X201wcm1.doc G.7.4.3.4--2010.4.20 |
| 716 | 745 | if (pSliceHead->uiDisableDeblockingFilterIdc > 6) { |
| 717 | 746 | WelsLog (pCtx, WELS_LOG_WARNING, "disable_deblock_filter_idc (%d) out of range [0, 6]\n", |
| @@ -719,11 +748,13 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 1 unmodified line | ||
| 719 | 748 | return ERR_INFO_INVALID_DBLOCKING_IDC; |
| 720 | 749 | } |
| 721 | 750 | if (pSliceHead->uiDisableDeblockingFilterIdc != 1) { |
| 722 | − pSliceHead->iSliceAlphaC0Offset = BsGetSe (pBs) * 2; // slice_alpha_c0_offset_div2 | |
| 751 | + WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //slice_alpha_c0_offset_div2 | |
| 752 | + pSliceHead->iSliceAlphaC0Offset = iCode * 2; | |
| 723 | 753 | WELS_CHECK_SE_BOTH_ERROR (pSliceHead->iSliceAlphaC0Offset, SLICE_HEADER_ALPHAC0_BETA_OFFSET_MIN, |
| 724 | 754 | SLICE_HEADER_ALPHAC0_BETA_OFFSET_MAX, "slice_alpha_c0_offset_div2 * 2", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, |
| 725 | 755 | ERR_INFO_INVALID_SLICE_ALPHA_C0_OFFSET_DIV2)); |
| 726 | − pSliceHead->iSliceBetaOffset = BsGetSe (pBs) * 2; // iSliceBetaOffset | |
| 756 | + WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //slice_beta_offset_div2 | |
| 757 | + pSliceHead->iSliceBetaOffset = iCode * 2; | |
| 727 | 758 | WELS_CHECK_SE_BOTH_ERROR (pSliceHead->iSliceBetaOffset, SLICE_HEADER_ALPHAC0_BETA_OFFSET_MIN, |
| 728 | 759 | SLICE_HEADER_ALPHAC0_BETA_OFFSET_MAX, "slice_beta_offset_div2 * 2", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, |
| 729 | 760 | ERR_INFO_INVALID_SLICE_BETA_OFFSET_DIV2)); |
| @@ -738,7 +769,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 8 unmodified lines | ||
| 738 | 769 | if (pPps->uiSliceGroupChangeRate > 0) { |
| 739 | 770 | const int32_t kiNumBits = (int32_t)WELS_CEIL (log (static_cast<double> (1 + pPps->uiPicSizeInMapUnits / |
| 740 | 771 | pPps->uiSliceGroupChangeRate))); |
| 741 | − pSliceHead->iSliceGroupChangeCycle = BsGetBits (pBs, kiNumBits); // For FMO extra types | |
| 772 | + WELS_READ_VERIFY (BsGetBits (pBs, kiNumBits, &uiCode)); //lice_group_change_cycle | |
| 773 | + pSliceHead->iSliceGroupChangeCycle = uiCode; | |
| 742 | 774 | } else |
| 743 | 775 | pSliceHead->iSliceGroupChangeCycle = 0; |
| 744 | 776 | } |
| @@ -751,9 +783,11 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 6 unmodified lines | ||
| 751 | 783 | |
| 752 | 784 | if (!pNalHeaderExt->iNoInterLayerPredFlag && BASE_QUALITY_ID == uiQualityId) { |
| 753 | 785 | //the following should be deleted for CODE_CLEAN |
| 754 | − pSliceHeadExt->uiRefLayerDqId = BsGetUe (pBs); | |
| 786 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //ref_layer_dq_id | |
| 787 | + pSliceHeadExt->uiRefLayerDqId = uiCode; | |
| 755 | 788 | if (pSubsetSps->sSpsSvcExt.bInterLayerDeblockingFilterCtrlPresentFlag) { |
| 756 | − pSliceHeadExt->uiDisableInterLayerDeblockingFilterIdc = BsGetUe (pBs); | |
| 789 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //disable_inter_layer_deblocking_filter_idc | |
| 790 | + pSliceHeadExt->uiDisableInterLayerDeblockingFilterIdc = uiCode; | |
| 757 | 791 | //refer to JVT-X201wcm1.doc G.7.4.3.4--2010.4.20 |
| 758 | 792 | if (pSliceHeadExt->uiDisableInterLayerDeblockingFilterIdc > 6) { |
| 759 | 793 | WelsLog (pCtx, WELS_LOG_WARNING, "disable_inter_layer_deblock_filter_idc (%d) out of range [0, 6]\n", |
| @@ -761,12 +795,14 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 1 unmodified line | ||
| 761 | 795 | return ERR_INFO_INVALID_DBLOCKING_IDC; |
| 762 | 796 | } |
| 763 | 797 | if (pSliceHeadExt->uiDisableInterLayerDeblockingFilterIdc != 1) { |
| 764 | − pSliceHeadExt->iInterLayerSliceAlphaC0Offset = BsGetSe (pBs) << 1; | |
| 798 | + WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //inter_layer_slice_alpha_c0_offset_div2 | |
| 799 | + pSliceHeadExt->iInterLayerSliceAlphaC0Offset = iCode * 2; | |
| 765 | 800 | WELS_CHECK_SE_BOTH_ERROR (pSliceHeadExt->iInterLayerSliceAlphaC0Offset, |
| 766 | 801 | SLICE_HEADER_INTER_LAYER_ALPHAC0_BETA_OFFSET_MIN, SLICE_HEADER_INTER_LAYER_ALPHAC0_BETA_OFFSET_MAX, |
| 767 | 802 | "inter_layer_alpha_c0_offset_div2 * 2", GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, |
| 768 | 803 | ERR_INFO_INVALID_SLICE_ALPHA_C0_OFFSET_DIV2)); |
| 769 | − pSliceHeadExt->iInterLayerSliceBetaOffset = BsGetSe (pBs) << 1; | |
| 804 | + WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //inter_layer_slice_beta_offset_div2 | |
| 805 | + pSliceHeadExt->iInterLayerSliceBetaOffset = iCode * 2; | |
| 770 | 806 | WELS_CHECK_SE_BOTH_ERROR (pSliceHeadExt->iInterLayerSliceBetaOffset, SLICE_HEADER_INTER_LAYER_ALPHAC0_BETA_OFFSET_MIN, |
| 771 | 807 | SLICE_HEADER_INTER_LAYER_ALPHAC0_BETA_OFFSET_MAX, "inter_layer_slice_beta_offset_div2 * 2", |
| 772 | 808 | GENERATE_ERROR_NO (ERR_LEVEL_SLICE_HEADER, ERR_INFO_INVALID_SLICE_BETA_OFFSET_DIV2)); |
| @@ -776,7 +812,8 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 3 unmodified lines | ||
| 776 | 812 | pSliceHeadExt->uiRefLayerChromaPhaseXPlus1Flag = pSubsetSps->sSpsSvcExt.uiSeqRefLayerChromaPhaseXPlus1Flag; |
| 777 | 813 | pSliceHeadExt->uiRefLayerChromaPhaseYPlus1 = pSubsetSps->sSpsSvcExt.uiSeqRefLayerChromaPhaseYPlus1; |
| 778 | 814 | |
| 779 | − pSliceHeadExt->bConstrainedIntraResamplingFlag = !!BsGetOneBit (pBs); | |
| 815 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constrained_intra_resampling_flag | |
| 816 | + pSliceHeadExt->bConstrainedIntraResamplingFlag = !!uiCode; | |
| 780 | 817 | |
| 781 | 818 | { |
| 782 | 819 | SPosOffset pos; |
| @@ -809,32 +846,45 @@ int32_t ParseSliceHeaderSyntaxs (PWelsDecoderContext pCtx, PBitStringAux pBs, co · 26 unmodified lines | ||
| 809 | 846 | pSliceHeadExt->bTCoeffLevelPredFlag = pSubsetSps->sSpsSvcExt.bSeqTCoeffLevelPredFlag; |
| 810 | 847 | |
| 811 | 848 | if (!pNalHeaderExt->iNoInterLayerPredFlag) { |
| 812 | − pSliceHeadExt->bSliceSkipFlag = !!BsGetOneBit (pBs); | |
| 849 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //slice_skip_flag | |
| 850 | + pSliceHeadExt->bSliceSkipFlag = !!uiCode; | |
| 813 | 851 | if (pSliceHeadExt->bSliceSkipFlag) { |
| 814 | − pSliceHeadExt->uiNumMbsInSlice = 1 + BsGetUe (pBs); | |
| 852 | + WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //num_mbs_in_slice_minus1 | |
| 853 | + pSliceHeadExt->uiNumMbsInSlice = 1 + uiCode; | |
| 815 | 854 | } else { |
| 816 | − pSliceHeadExt->bAdaptiveBaseModeFlag = !!BsGetOneBit (pBs); | |
| 855 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //adaptive_base_mode_flag | |
| 856 | + pSliceHeadExt->bAdaptiveBaseModeFlag = !!uiCode; | |
| 817 | 857 | if (!pSliceHeadExt->bAdaptiveBaseModeFlag) { |
| 818 | − pSliceHeadExt->bDefaultBaseModeFlag = !!BsGetOneBit (pBs); | |
| 858 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //default_base_mode_flag | |
| 859 | + pSliceHeadExt->bDefaultBaseModeFlag = !!uiCode; | |
| 819 | 860 | } |
| 820 | 861 | if (!pSliceHeadExt->bDefaultBaseModeFlag) { |
| 821 | − pSliceHeadExt->bAdaptiveMotionPredFlag = !!BsGetOneBit (pBs); | |
| 822 | − if (!pSliceHeadExt->bAdaptiveMotionPredFlag) | |
| 823 | − pSliceHeadExt->bDefaultMotionPredFlag = !!BsGetOneBit (pBs); | |
| 862 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //adaptive_motion_prediction_flag | |
| 863 | + pSliceHeadExt->bAdaptiveMotionPredFlag = !!uiCode; | |
| 864 | + if (!pSliceHeadExt->bAdaptiveMotionPredFlag) { | |
| 865 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //default_motion_prediction_flag | |
| 866 | + pSliceHeadExt->bDefaultMotionPredFlag = !!uiCode; | |
| 867 | + } | |
| 824 | 868 | } |
| 825 | 869 | |
| 826 | − pSliceHeadExt->bAdaptiveResidualPredFlag = !!BsGetOneBit (pBs); | |
| 870 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //adaptive_residual_prediction_flag | |
| 871 | + pSliceHeadExt->bAdaptiveResidualPredFlag = !!uiCode; | |
| 827 | 872 | if (!pSliceHeadExt->bAdaptiveResidualPredFlag) { |
| 828 | − pSliceHeadExt->bDefaultResidualPredFlag = !!BsGetOneBit (pBs); | |
| 873 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //default_residual_prediction_flag | |
| 874 | + pSliceHeadExt->bDefaultResidualPredFlag = !!uiCode; | |
| 829 | 875 | } |
| 830 | 876 | } |
| 831 | − if (pSubsetSps->sSpsSvcExt.bAdaptiveTCoeffLevelPredFlag) | |
| 832 | − pSliceHeadExt->bTCoeffLevelPredFlag = !!BsGetOneBit (pBs); | |
| 877 | + if (pSubsetSps->sSpsSvcExt.bAdaptiveTCoeffLevelPredFlag) { | |
| 878 | + WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //tcoeff_level_prediction_flag | |
| 879 | + pSliceHeadExt->bTCoeffLevelPredFlag = !!uiCode; | |
| 880 | + } | |
| 833 | 881 | } |
| 834 | 882 | |
| 835 | 883 | if (!pSubsetSps->sSpsSvcExt.bSliceHeaderRestrictionFlag) { |
| 836 | − pSliceHeadExt->uiScanIdxStart = BsGetBits (pBs, 4); | |
| 837 | − pSliceHeadExt->uiScanIdxEnd = BsGetBits (pBs, 4); | |
| 884 | + WELS_READ_VERIFY (BsGetBits (pBs, 4, &uiCode)); //scan_idx_start | |
| 885 | + pSliceHeadExt->uiScanIdxStart = uiCode; | |
| 886 | + WELS_READ_VERIFY (BsGetBits (pBs, 4, &uiCode)); //scan_idx_end | |
| 887 | + pSliceHeadExt->uiScanIdxEnd = uiCode; | |
| 838 | 888 | if (pSliceHeadExt->uiScanIdxStart != 0 || pSliceHeadExt->uiScanIdxEnd != 15) { |
| 839 | 889 | WelsLog (pCtx, WELS_LOG_WARNING, "uiScanIdxStart (%d) != 0 and uiScanIdxEnd (%d) !=15 not supported here\n", |
| 840 | 890 | pSliceHeadExt->uiScanIdxStart, pSliceHeadExt->uiScanIdxEnd); |
| @@ -970,84 +1020,84 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 129 unmodified lines | ||
| 970 | 1020 | |
| 971 | 1021 | memset (pDq, 0, sizeof (SDqLayer)); |
| 972 | 1022 | |
| 973 | − do { | |
| 974 | − const int32_t kiHshift = iPlaneIdx ? 1 : 0; | |
| 975 | − const int32_t kiVshift = kiHshift; | |
| 976 | − const int32_t kiStride = WELS_ALIGN ((kiPicStride >> kiHshift), (16 << (1 - kiHshift))); | |
| 977 | − const int32_t kiLine = (kiPicLines + (PADDING_LENGTH << 1)) >> kiVshift; | |
| 978 | − const int32_t kiSize = kiStride * kiLine; | |
| 979 | − | |
| 980 | − pCtx->pCsListXchg[i][iPlaneIdx] = (uint8_t*)WelsMalloc (kiSize * sizeof (uint8_t), "pCtx->pCsListXchg[][]"); | |
| 981 | − | |
| 982 | − WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, (NULL == pCtx->pCsListXchg[i][iPlaneIdx])) | |
| 983 | − pCtx->iCsStride[iPlaneIdx] = kiStride; | |
| 984 | − | |
| 985 | − | |
| 986 | − pCtx->pRsListXchg[i][iPlaneIdx] = (int16_t*)WelsMalloc (kiSize * sizeof (int16_t), "pCtx->pRsListXchg[][]"); | |
| 987 | − | |
| 988 | − WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY , (NULL == pCtx->pRsListXchg[i][iPlaneIdx])) | |
| 989 | − pCtx->iRsStride[iPlaneIdx] = kiStride; | |
| 990 | − | |
| 991 | − ++ iPlaneIdx; | |
| 992 | − } while (iPlaneIdx < 3); | |
| 993 | − | |
| 994 | − | |
| 995 | − pCtx->sMb.pMbType[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | |
| 996 | − "pCtx->sMb.pMbType[]"); | |
| 997 | − pCtx->sMb.pMv[i][0] = (int16_t (*)[16][2])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | |
| 998 | − int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMv[][]"); | |
| 999 | − pCtx->sMb.pRefIndex[i][0] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | |
| 1000 | − int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]"); | |
| 1001 | − pCtx->sMb.pLumaQp[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | |
| 1002 | − "pCtx->sMb.pLumaQp[]"); | |
| 1003 | − pCtx->sMb.pChromaQp[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | |
| 1004 | − "pCtx->sMb.pChromaQp[]"); | |
| 1005 | − pCtx->sMb.pNzc[i] = (int8_t (*)[24])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24, | |
| 1006 | − "pCtx->sMb.pNzc[]"); | |
| 1007 | − pCtx->sMb.pNzcRs[i] = (int8_t (*)[24])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24, | |
| 1008 | − "pCtx->sMb.pNzcRs[]"); | |
| 1009 | − pCtx->sMb.pScaledTCoeff[i] = (int16_t (*)[MB_COEFF_LIST_SIZE])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * | |
| 1010 | − sizeof (int16_t) * MB_COEFF_LIST_SIZE, "pCtx->sMb.pScaledTCoeff[]"); | |
| 1011 | − pCtx->sMb.pIntraPredMode[i] = (int8_t (*)[8])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 8, | |
| 1012 | − "pCtx->sMb.pIntraPredMode[]"); | |
| 1013 | − pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * | |
| 1014 | − sizeof (int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pIntra4x4FinalMode[]"); | |
| 1015 | − pCtx->sMb.pChromaPredMode[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | |
| 1016 | − "pCtx->sMb.pChromaPredMode[]"); | |
| 1017 | − pCtx->sMb.pCbp[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | |
| 1018 | − "pCtx->sMb.pCbp[]"); | |
| 1019 | − pCtx->sMb.pSubMbType[i] = (int8_t (*)[MB_PARTITION_SIZE])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | |
| 1020 | − int8_t) * MB_PARTITION_SIZE, "pCtx->sMb.pSubMbType[]"); | |
| 1021 | − pCtx->sMb.pSliceIdc[i] = (int32_t*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t), | |
| 1022 | − "pCtx->sMb.pSliceIdc[]"); // using int32_t for slice_idc, 4/21/2010 | |
| 1023 | − if (pCtx->sMb.pSliceIdc[i] != NULL) | |
| 1024 | − memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t))); | |
| 1025 | − pCtx->sMb.pResidualPredFlag[i] = (int8_t*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | |
| 1026 | − "pCtx->sMb.pResidualPredFlag[]"); | |
| 1027 | − //pCtx->sMb.pMotionPredFlag[i] = (uint8_t *) WelsMalloc(pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof(uint8_t), "pCtx->sMb.pMotionPredFlag[]"); | |
| 1028 | − pCtx->sMb.pInterPredictionDoneFlag[i] = (int8_t*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | |
| 1029 | − int8_t), "pCtx->sMb.pInterPredictionDoneFlag[]"); | |
| 1030 | − | |
| 1031 | − // check memory block valid due above allocated.. | |
| 1032 | − WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, | |
| 1033 | − ((NULL == pCtx->sMb.pMbType[i]) || | |
| 1034 | − (NULL == pCtx->sMb.pMv[i][0]) || | |
| 1035 | − (NULL == pCtx->sMb.pRefIndex[i][0]) || | |
| 1036 | − (NULL == pCtx->sMb.pLumaQp[i]) || | |
| 1037 | − (NULL == pCtx->sMb.pChromaQp[i]) || | |
| 1038 | − (NULL == pCtx->sMb.pNzc[i]) || | |
| 1039 | − (NULL == pCtx->sMb.pNzcRs[i]) || | |
| 1040 | − (NULL == pCtx->sMb.pScaledTCoeff[i]) || | |
| 1041 | − (NULL == pCtx->sMb.pIntraPredMode[i]) || | |
| 1042 | − (NULL == pCtx->sMb.pIntra4x4FinalMode[i]) || | |
| 1043 | − (NULL == pCtx->sMb.pChromaPredMode[i]) || | |
| 1044 | − (NULL == pCtx->sMb.pCbp[i]) || | |
| 1045 | − (NULL == pCtx->sMb.pSubMbType[i]) || | |
| 1046 | − (NULL == pCtx->sMb.pSliceIdc[i]) || | |
| 1047 | − (NULL == pCtx->sMb.pResidualPredFlag[i]) || | |
| 1048 | − (NULL == pCtx->sMb.pInterPredictionDoneFlag[i]) | |
| 1049 | − ) | |
| 1050 | − ) | |
| 1023 | + do { | |
| 1024 | + const int32_t kiHshift = iPlaneIdx ? 1 : 0; | |
| 1025 | + const int32_t kiVshift = kiHshift; | |
| 1026 | + const int32_t kiStride = WELS_ALIGN ((kiPicStride >> kiHshift), (16 << (1 - kiHshift))); | |
| 1027 | + const int32_t kiLine = (kiPicLines + (PADDING_LENGTH << 1)) >> kiVshift; | |
| 1028 | + const int32_t kiSize = kiStride * kiLine; | |
| 1029 | + | |
| 1030 | + pCtx->pCsListXchg[i][iPlaneIdx] = (uint8_t*)WelsMalloc (kiSize * sizeof (uint8_t), "pCtx->pCsListXchg[][]"); | |
| 1031 | + | |
| 1032 | + WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, (NULL == pCtx->pCsListXchg[i][iPlaneIdx])) | |
| 1033 | + pCtx->iCsStride[iPlaneIdx] = kiStride; | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + pCtx->pRsListXchg[i][iPlaneIdx] = (int16_t*)WelsMalloc (kiSize * sizeof (int16_t), "pCtx->pRsListXchg[][]"); | |
| 1037 | + | |
| 1038 | + WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY , (NULL == pCtx->pRsListXchg[i][iPlaneIdx])) | |
| 1039 | + pCtx->iRsStride[iPlaneIdx] = kiStride; | |
| 1040 | + | |
| 1041 | + ++ iPlaneIdx; | |
| 1042 | + } while (iPlaneIdx < 3); | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + pCtx->sMb.pMbType[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | |
| 1046 | + "pCtx->sMb.pMbType[]"); | |
| 1047 | + pCtx->sMb.pMv[i][0] = (int16_t (*)[16][2])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | |
| 1048 | + int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMv[][]"); | |
| 1049 | + pCtx->sMb.pRefIndex[i][0] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | |
| 1050 | + int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]"); | |
| 1051 | + pCtx->sMb.pLumaQp[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | |
| 1052 | + "pCtx->sMb.pLumaQp[]"); | |
| 1053 | + pCtx->sMb.pChromaQp[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | |
| 1054 | + "pCtx->sMb.pChromaQp[]"); | |
| 1055 | + pCtx->sMb.pNzc[i] = (int8_t (*)[24])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24, | |
| 1056 | + "pCtx->sMb.pNzc[]"); | |
| 1057 | + pCtx->sMb.pNzcRs[i] = (int8_t (*)[24])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24, | |
| 1058 | + "pCtx->sMb.pNzcRs[]"); | |
| 1059 | + pCtx->sMb.pScaledTCoeff[i] = (int16_t (*)[MB_COEFF_LIST_SIZE])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * | |
| 1060 | + sizeof (int16_t) * MB_COEFF_LIST_SIZE, "pCtx->sMb.pScaledTCoeff[]"); | |
| 1061 | + pCtx->sMb.pIntraPredMode[i] = (int8_t (*)[8])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 8, | |
| 1062 | + "pCtx->sMb.pIntraPredMode[]"); | |
| 1063 | + pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * | |
| 1064 | + sizeof (int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pIntra4x4FinalMode[]"); | |
| 1065 | + pCtx->sMb.pChromaPredMode[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | |
| 1066 | + "pCtx->sMb.pChromaPredMode[]"); | |
| 1067 | + pCtx->sMb.pCbp[i] = (int8_t*)WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | |
| 1068 | + "pCtx->sMb.pCbp[]"); | |
| 1069 | + pCtx->sMb.pSubMbType[i] = (int8_t (*)[MB_PARTITION_SIZE])WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | |
| 1070 | + int8_t) * MB_PARTITION_SIZE, "pCtx->sMb.pSubMbType[]"); | |
| 1071 | + pCtx->sMb.pSliceIdc[i] = (int32_t*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t), | |
| 1072 | + "pCtx->sMb.pSliceIdc[]"); // using int32_t for slice_idc, 4/21/2010 | |
| 1073 | + if (pCtx->sMb.pSliceIdc[i] != NULL) | |
| 1074 | + memset (pCtx->sMb.pSliceIdc[i], 0xff, (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int32_t))); | |
| 1075 | + pCtx->sMb.pResidualPredFlag[i] = (int8_t*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | |
| 1076 | + "pCtx->sMb.pResidualPredFlag[]"); | |
| 1077 | + //pCtx->sMb.pMotionPredFlag[i] = (uint8_t *) WelsMalloc(pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof(uint8_t), "pCtx->sMb.pMotionPredFlag[]"); | |
| 1078 | + pCtx->sMb.pInterPredictionDoneFlag[i] = (int8_t*) WelsMalloc (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | |
| 1079 | + int8_t), "pCtx->sMb.pInterPredictionDoneFlag[]"); | |
| 1080 | + | |
| 1081 | + // check memory block valid due above allocated.. | |
| 1082 | + WELS_VERIFY_RETURN_IF (ERR_INFO_OUT_OF_MEMORY, | |
| 1083 | + ((NULL == pCtx->sMb.pMbType[i]) || | |
| 1084 | + (NULL == pCtx->sMb.pMv[i][0]) || | |
| 1085 | + (NULL == pCtx->sMb.pRefIndex[i][0]) || | |
| 1086 | + (NULL == pCtx->sMb.pLumaQp[i]) || | |
| 1087 | + (NULL == pCtx->sMb.pChromaQp[i]) || | |
| 1088 | + (NULL == pCtx->sMb.pNzc[i]) || | |
| 1089 | + (NULL == pCtx->sMb.pNzcRs[i]) || | |
| 1090 | + (NULL == pCtx->sMb.pScaledTCoeff[i]) || | |
| 1091 | + (NULL == pCtx->sMb.pIntraPredMode[i]) || | |
| 1092 | + (NULL == pCtx->sMb.pIntra4x4FinalMode[i]) || | |
| 1093 | + (NULL == pCtx->sMb.pChromaPredMode[i]) || | |
| 1094 | + (NULL == pCtx->sMb.pCbp[i]) || | |
| 1095 | + (NULL == pCtx->sMb.pSubMbType[i]) || | |
| 1096 | + (NULL == pCtx->sMb.pSliceIdc[i]) || | |
| 1097 | + (NULL == pCtx->sMb.pResidualPredFlag[i]) || | |
| 1098 | + (NULL == pCtx->sMb.pInterPredictionDoneFlag[i]) | |
| 1099 | + ) | |
| 1100 | + ) | |
| 1051 | 1101 | |
| 1052 | 1102 | pCtx->pDqLayersList[i] = pDq; |
| 1053 | 1103 | ++ i; |
| @@ -1603,7 +1653,7 @@ int32_t ConstructAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, SBufferI · 549 unmodified lines | ||
| 1603 | 1653 | if (NAL_UNIT_CODED_SLICE_IDR == pCurAu->pNalUnitsList[pCurAu->uiStartPos]->sNalHeaderExt.sNalUnitHeader.eNalUnitType || |
| 1604 | 1654 | pCurAu->pNalUnitsList[pCurAu->uiStartPos]->sNalHeaderExt.bIdrFlag) { |
| 1605 | 1655 | WelsResetRefPic (pCtx); //clear ref pPic when IDR NAL |
| 1606 | − iErr = SyncPictureResolutionExt (pCtx, pCtx->pSps->iMbWidth, pCtx->pSps->iMbHeight); | |
| 1656 | + iErr = SyncPictureResolutionExt (pCtx, pCtx->pSps->iMbWidth, pCtx->pSps->iMbHeight); | |
| 1607 | 1657 | |
| 1608 | 1658 | if (ERR_NONE != iErr) { |
| 1609 | 1659 | WelsLog (pCtx, WELS_LOG_WARNING, "sync picture resolution ext failed, the error is %d", iErr); |
| @@ -1854,7 +1904,7 @@ int32_t DecodeCurrentAccessUnit (PWelsDecoderContext pCtx, uint8_t** ppDst, int3 · 244 unmodified lines | ||
| 1854 | 1904 | |
| 1855 | 1905 | if (!dq_cur->sLayerInfo.pSps->bGapsInFrameNumValueAllowedFlag) { |
| 1856 | 1906 | const bool kbIdrFlag = dq_cur->sLayerInfo.sNalHeaderExt.bIdrFlag |
| 1857 | − || (dq_cur->sLayerInfo.sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR); | |
| 1907 | + || (dq_cur->sLayerInfo.sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR); | |
| 1858 | 1908 | // Subclause 8.2.5.2 Decoding process for gaps in frame_num |
| 1859 | 1909 | if (!kbIdrFlag && |
| 1860 | 1910 | pSh->iFrameNum != pCtx->iPrevFrameNum && |