History

add safety check for bit-reading for headers

Licai Guo committed 12 years ago

Commit a3c38b51 parent e79769f7 files · +676 −488Browse files

Showing the changes to codec/decoder/core/src/au_parser.cpp (1 of 7 files). Show all

Unified · Split

codec/decoder/core/src/au_parser.cpp+169−91
@@ -363,7 +363,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 362 unmodified lines
363 363
364 364
365bool CheckAccessUnitBoundaryExt (PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHeaderExt pCurNalHeaderExt,365bool CheckAccessUnitBoundaryExt (PNalUnitHeaderExt pLastNalHdrExt, PNalUnitHeaderExt pCurNalHeaderExt,
366 PSliceHeader pLastSliceHeader, PSliceHeader pCurSliceHeader) {366 PSliceHeader pLastSliceHeader, PSliceHeader pCurSliceHeader) {
367 const PSps kpSps = pCurSliceHeader->pSps;367 const PSps kpSps = pCurSliceHeader->pSps;
368 368
369 //Sub-clause 7.1.4.1.1 temporal_id369 //Sub-clause 7.1.4.1.1 temporal_id
@@ -559,13 +559,16 @@ int32_t ParseNonVclNal (PWelsDecoderContext pCtx, uint8_t* pRbsp, const int32_t · 189 unmodified lines
559 return iErr;559 return iErr;
560}560}
561 561
562void ParseRefBasePicMarking (PBitStringAux pBs, PRefBasePicMarking pRefBasePicMarking) {562int32_t ParseRefBasePicMarking (PBitStringAux pBs, PRefBasePicMarking pRefBasePicMarking) {
563 const bool kbAdaptiveMarkingModeFlag = !!BsGetOneBit (pBs);563 uint32_t uiCode;
564 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //adaptive_ref_base_pic_marking_mode_flag
565 const bool kbAdaptiveMarkingModeFlag = !!uiCode;
564 pRefBasePicMarking->bAdaptiveRefBasePicMarkingModeFlag = kbAdaptiveMarkingModeFlag;566 pRefBasePicMarking->bAdaptiveRefBasePicMarkingModeFlag = kbAdaptiveMarkingModeFlag;
565 if (kbAdaptiveMarkingModeFlag) {567 if (kbAdaptiveMarkingModeFlag) {
566 int32_t iIdx = 0;568 int32_t iIdx = 0;
567 do {569 do {
568 const uint32_t kuiMmco = BsGetUe (pBs);570 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //MMCO_base
571 const uint32_t kuiMmco = uiCode;
569 572
570 pRefBasePicMarking->mmco_base[iIdx].uiMmcoType = kuiMmco;573 pRefBasePicMarking->mmco_base[iIdx].uiMmcoType = kuiMmco;
571 574
@@ -573,31 +576,39 @@ void ParseRefBasePicMarking (PBitStringAux pBs, PRefBasePicMarking pRefBasePicMa · 1 unmodified line
573 break;576 break;
574 577
575 if (kuiMmco == MMCO_SHORT2UNUSED) {578 if (kuiMmco == MMCO_SHORT2UNUSED) {
576 pRefBasePicMarking->mmco_base[iIdx].uiDiffOfPicNums = 1 + BsGetUe (pBs);579 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //difference_of_base_pic_nums_minus1
580 pRefBasePicMarking->mmco_base[iIdx].uiDiffOfPicNums = 1 + uiCode;
577 pRefBasePicMarking->mmco_base[iIdx].iShortFrameNum = 0;581 pRefBasePicMarking->mmco_base[iIdx].iShortFrameNum = 0;
578 } else if (kuiMmco == MMCO_LONG2UNUSED) {582 } else if (kuiMmco == MMCO_LONG2UNUSED) {
579 pRefBasePicMarking->mmco_base[iIdx].uiLongTermPicNum = BsGetUe (pBs);583 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //long_term_base_pic_num
584 pRefBasePicMarking->mmco_base[iIdx].uiLongTermPicNum = uiCode;
580 }585 }
581 ++ iIdx;586 ++ iIdx;
582 } while (iIdx < MAX_MMCO_COUNT);587 } while (iIdx < MAX_MMCO_COUNT);
583 }588 }
589 return ERR_NONE;
584}590}
585 591
586void ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs) {592int32_t ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs) {
587 PNalUnit pCurNal = &pCtx->sPrefixNal;593 PNalUnit pCurNal = &pCtx->sPrefixNal;
594 uint32_t uiCode;
588 595
589 if (pCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc != 0) {596 if (pCurNal->sNalHeaderExt.sNalUnitHeader.uiNalRefIdc != 0) {
590 PNalUnitHeaderExt head_ext = &pCurNal->sNalHeaderExt;597 PNalUnitHeaderExt head_ext = &pCurNal->sNalHeaderExt;
591 PPrefixNalUnit sPrefixNal = &pCurNal->sNalData.sPrefixNal;598 PPrefixNalUnit sPrefixNal = &pCurNal->sNalData.sPrefixNal;
592 sPrefixNal->bStoreRefBasePicFlag = !!BsGetOneBit (pBs);599 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //store_ref_base_pic_flag
600 sPrefixNal->bStoreRefBasePicFlag = !!uiCode;
593 if ((head_ext->bUseRefBasePicFlag || sPrefixNal->bStoreRefBasePicFlag) && !head_ext->bIdrFlag) {601 if ((head_ext->bUseRefBasePicFlag || sPrefixNal->bStoreRefBasePicFlag) && !head_ext->bIdrFlag) {
594 ParseRefBasePicMarking (pBs, &sPrefixNal->sRefPicBaseMarking);602 WELS_READ_VERIFY (ParseRefBasePicMarking (pBs, &sPrefixNal->sRefPicBaseMarking));
595 }603 }
596 sPrefixNal->bPrefixNalUnitAdditionalExtFlag = !!BsGetOneBit (pBs);604 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //additional_prefix_nal_unit_extension_flag
605 sPrefixNal->bPrefixNalUnitAdditionalExtFlag = uiCode;
597 if (sPrefixNal->bPrefixNalUnitAdditionalExtFlag) {606 if (sPrefixNal->bPrefixNalUnitAdditionalExtFlag) {
598 sPrefixNal->bPrefixNalUnitExtFlag = !!BsGetOneBit (pBs);607 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //additional_prefix_nal_unit_extension_data_flag
608 sPrefixNal->bPrefixNalUnitExtFlag = !!uiCode;
599 }609 }
600 }610 }
611 return ERR_NONE;
601}612}
602 613
603#define SUBSET_SPS_SEQ_SCALED_REF_LAYER_LEFT_OFFSET_MIN -32768614#define SUBSET_SPS_SEQ_SCALED_REF_LAYER_LEFT_OFFSET_MIN -32768
@@ -615,11 +626,15 @@ void ParsePrefixNalUnit (PWelsDecoderContext pCtx, PBitStringAux pBs) { · 11 unmodified lines
615int32_t DecodeSpsSvcExt (PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStringAux pBs) {626int32_t DecodeSpsSvcExt (PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStringAux pBs) {
616 PSpsSvcExt pExt = NULL;627 PSpsSvcExt pExt = NULL;
617 uint8_t uiChromaArrayType = 1;628 uint8_t uiChromaArrayType = 1;
629 uint32_t uiCode;
630 int32_t iCode;
618 631
619 pExt = &pSpsExt->sSpsSvcExt;632 pExt = &pSpsExt->sSpsSvcExt;
620 633
621 pExt->bInterLayerDeblockingFilterCtrlPresentFlag = !!BsGetOneBit (pBs);634 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //inter_layer_deblocking_filter_control_present_flag
622 pExt->uiExtendedSpatialScalability = BsGetBits (pBs, 2);635 pExt->bInterLayerDeblockingFilterCtrlPresentFlag = !!uiCode;
636 WELS_READ_VERIFY (BsGetBits (pBs, 2, &uiCode)); //extended_spatial_scalability_idc
637 pExt->uiExtendedSpatialScalability = uiCode;
623 if (pExt->uiExtendedSpatialScalability > 2) {638 if (pExt->uiExtendedSpatialScalability > 2) {
624 WelsLog (pCtx, WELS_LOG_WARNING, "DecodeSpsSvcExt():extended_spatial_scalability (%d) != 0, ESS not supported!\n",639 WelsLog (pCtx, WELS_LOG_WARNING, "DecodeSpsSvcExt():extended_spatial_scalability (%d) != 0, ESS not supported!\n",
625 pExt->uiExtendedSpatialScalability);640 pExt->uiExtendedSpatialScalability);
@@ -631,8 +646,10 @@ int32_t DecodeSpsSvcExt (PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStrin · 5 unmodified lines
631 pExt->uiChromaPhaseYPlus1 = 1;646 pExt->uiChromaPhaseYPlus1 = 1;
632 uiChromaArrayType = pSpsExt->sSps.uiChromaArrayType;647 uiChromaArrayType = pSpsExt->sSps.uiChromaArrayType;
633 648
634 pExt->uiChromaPhaseXPlus1Flag = BsGetOneBit (pBs);649 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //chroma_phase_x_plus1_flag
635 pExt->uiChromaPhaseYPlus1 = BsGetBits (pBs, 2);650 pExt->uiChromaPhaseXPlus1Flag = uiCode;
651 WELS_READ_VERIFY (BsGetBits (pBs, 2, &uiCode)); //chroma_phase_y_plus1
652 pExt->uiChromaPhaseYPlus1 = uiCode;
636 653
637 pExt->uiSeqRefLayerChromaPhaseXPlus1Flag = pExt->uiChromaPhaseXPlus1Flag;654 pExt->uiSeqRefLayerChromaPhaseXPlus1Flag = pExt->uiChromaPhaseXPlus1Flag;
638 pExt->uiSeqRefLayerChromaPhaseYPlus1 = pExt->uiChromaPhaseYPlus1;655 pExt->uiSeqRefLayerChromaPhaseYPlus1 = pExt->uiChromaPhaseYPlus1;
@@ -640,28 +657,38 @@ int32_t DecodeSpsSvcExt (PWelsDecoderContext pCtx, PSubsetSps pSpsExt, PBitStrin · 1 unmodified line
640 657
641 if (pExt->uiExtendedSpatialScalability == 1) {658 if (pExt->uiExtendedSpatialScalability == 1) {
642 SPosOffset* const kpPos = &pExt->sSeqScaledRefLayer;659 SPosOffset* const kpPos = &pExt->sSeqScaledRefLayer;
643 pExt->uiSeqRefLayerChromaPhaseXPlus1Flag = BsGetOneBit (pBs);660 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //seq_ref_layer_chroma_phase_x_plus1_flag
644 pExt->uiSeqRefLayerChromaPhaseYPlus1 = BsGetBits (pBs, 2);661 pExt->uiSeqRefLayerChromaPhaseXPlus1Flag = uiCode;
662 WELS_READ_VERIFY (BsGetBits (pBs, 2, &uiCode)); //seq_ref_layer_chroma_phase_y_plus1
663 pExt->uiSeqRefLayerChromaPhaseYPlus1 = uiCode;
645 664
646 kpPos->iLeftOffset = BsGetSe (pBs);665 WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //seq_scaled_ref_layer_left_offset
666 kpPos->iLeftOffset = iCode;
647 WELS_CHECK_SE_BOTH_WARNING (kpPos->iLeftOffset, SUBSET_SPS_SEQ_SCALED_REF_LAYER_LEFT_OFFSET_MIN,667 WELS_CHECK_SE_BOTH_WARNING (kpPos->iLeftOffset, SUBSET_SPS_SEQ_SCALED_REF_LAYER_LEFT_OFFSET_MIN,
648 SUBSET_SPS_SEQ_SCALED_REF_LAYER_LEFT_OFFSET_MAX, "seq_scaled_ref_layer_left_offset");668 SUBSET_SPS_SEQ_SCALED_REF_LAYER_LEFT_OFFSET_MAX, "seq_scaled_ref_layer_left_offset");
649 kpPos->iTopOffset = BsGetSe (pBs);669 WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //seq_scaled_ref_layer_top_offset
670 kpPos->iTopOffset = iCode;
650 WELS_CHECK_SE_BOTH_WARNING (kpPos->iTopOffset, SUBSET_SPS_SEQ_SCALED_REF_LAYER_TOP_OFFSET_MIN,671 WELS_CHECK_SE_BOTH_WARNING (kpPos->iTopOffset, SUBSET_SPS_SEQ_SCALED_REF_LAYER_TOP_OFFSET_MIN,
651 SUBSET_SPS_SEQ_SCALED_REF_LAYER_TOP_OFFSET_MAX, "seq_scaled_ref_layer_top_offset");672 SUBSET_SPS_SEQ_SCALED_REF_LAYER_TOP_OFFSET_MAX, "seq_scaled_ref_layer_top_offset");
652 kpPos->iRightOffset = BsGetSe (pBs);673 WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //seq_scaled_ref_layer_right_offset
674 kpPos->iRightOffset = iCode;
653 WELS_CHECK_SE_BOTH_WARNING (kpPos->iRightOffset, SUBSET_SPS_SEQ_SCALED_REF_LAYER_RIGHT_OFFSET_MIN,675 WELS_CHECK_SE_BOTH_WARNING (kpPos->iRightOffset, SUBSET_SPS_SEQ_SCALED_REF_LAYER_RIGHT_OFFSET_MIN,
654 SUBSET_SPS_SEQ_SCALED_REF_LAYER_RIGHT_OFFSET_MAX, "seq_scaled_ref_layer_right_offset");676 SUBSET_SPS_SEQ_SCALED_REF_LAYER_RIGHT_OFFSET_MAX, "seq_scaled_ref_layer_right_offset");
655 kpPos->iBottomOffset = BsGetSe (pBs);677 WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //seq_scaled_ref_layer_bottom_offset
678 kpPos->iBottomOffset = iCode;
656 WELS_CHECK_SE_BOTH_WARNING (kpPos->iBottomOffset, SUBSET_SPS_SEQ_SCALED_REF_LAYER_BOTTOM_OFFSET_MIN,679 WELS_CHECK_SE_BOTH_WARNING (kpPos->iBottomOffset, SUBSET_SPS_SEQ_SCALED_REF_LAYER_BOTTOM_OFFSET_MIN,
657 SUBSET_SPS_SEQ_SCALED_REF_LAYER_BOTTOM_OFFSET_MAX, "seq_scaled_ref_layer_bottom_offset");680 SUBSET_SPS_SEQ_SCALED_REF_LAYER_BOTTOM_OFFSET_MAX, "seq_scaled_ref_layer_bottom_offset");
658 }681 }
659 682
660 pExt->bSeqTCoeffLevelPredFlag = !!BsGetOneBit (pBs);683 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //seq_tcoeff_level_prediction_flag
684 pExt->bSeqTCoeffLevelPredFlag = !!uiCode;
661 pExt->bAdaptiveTCoeffLevelPredFlag = false;685 pExt->bAdaptiveTCoeffLevelPredFlag = false;
662 if (pExt->bSeqTCoeffLevelPredFlag)686 if (pExt->bSeqTCoeffLevelPredFlag) {
663 pExt->bAdaptiveTCoeffLevelPredFlag = !!BsGetOneBit (pBs);687 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //adaptive_tcoeff_level_prediction_flag
664 pExt->bSliceHeaderRestrictionFlag = !!BsGetOneBit (pBs);688 pExt->bAdaptiveTCoeffLevelPredFlag = !!uiCode;
689 }
690 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //slice_header_restriction_flag
691 pExt->bSliceHeaderRestrictionFlag = !!uiCode;
665 692
666 693
667 694
@@ -689,7 +716,7 @@ static const SLevelLimits g_kSLevelLimits[17] = { · 21 unmodified lines
689 {2073600, 36864, 184320, 240000, 240000, -2048, 2047, 2, 16} /* level 5.2 */716 {2073600, 36864, 184320, 240000, 240000, -2048, 2047, 2, 16} /* level 5.2 */
690};717};
691 718
692const SLevelLimits *GetLevelLimits(int32_t iLevelIdx, bool bConstraint3) {719const SLevelLimits* GetLevelLimits (int32_t iLevelIdx, bool bConstraint3) {
693 switch (iLevelIdx) {720 switch (iLevelIdx) {
694 case 10:721 case 10:
695 return &g_kSLevelLimits[0];722 return &g_kSLevelLimits[0];
@@ -765,7 +792,8 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 69 unmodified lines
765 ProfileIdc uiProfileIdc;792 ProfileIdc uiProfileIdc;
766 uint8_t uiLevelIdc;793 uint8_t uiLevelIdc;
767 int32_t iSpsId;794 int32_t iSpsId;
768 uint32_t uiTmp;795 uint32_t uiCode;
796 int32_t iCode;
769 bool bConstraintSetFlags[6] = { false };797 bool bConstraintSetFlags[6] = { false };
770 const bool kbUseSubsetFlag = IS_SUBSET_SPS_NAL (pNalHead->eNalUnitType);798 const bool kbUseSubsetFlag = IS_SUBSET_SPS_NAL (pNalHead->eNalUnitType);
771 799
@@ -787,16 +815,25 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 15 unmodified lines
787#endif //MOSAIC_AVOID_BASED_ON_SPS_PPS_ID815#endif //MOSAIC_AVOID_BASED_ON_SPS_PPS_ID
788 }816 }
789 817
790 uiProfileIdc = BsGetBits (pBs, 8);818 WELS_READ_VERIFY (BsGetBits (pBs, 8, &uiCode)); //profile_idc
791 bConstraintSetFlags[0] = !!BsGetOneBit (pBs); // constraint_set0_flag819 uiProfileIdc = uiCode;
792 bConstraintSetFlags[1] = !!BsGetOneBit (pBs); // constraint_set1_flag820 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set0_flag
793 bConstraintSetFlags[2] = !!BsGetOneBit (pBs); // constraint_set2_flag821 bConstraintSetFlags[0] = !!uiCode;
794 bConstraintSetFlags[3] = !!BsGetOneBit (pBs); // constraint_set3_flag822 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set1_flag
795 bConstraintSetFlags[4] = !!BsGetOneBit (pBs); // constraint_set4_flag823 bConstraintSetFlags[1] = !!uiCode;
796 bConstraintSetFlags[5] = !!BsGetOneBit (pBs); // constraint_set5_flag824 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set2_flag
797 BsGetBits (pBs, 2); // reserved_zero_2bits, equal to 0825 bConstraintSetFlags[2] = !!uiCode;
798 uiLevelIdc = BsGetBits (pBs, 8); // level_idc826 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set3_flag
799 iSpsId = BsGetUe (pBs); // seq_parameter_set_id827 bConstraintSetFlags[3] = !!uiCode;
828 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set4_flag
829 bConstraintSetFlags[4] = !!uiCode;
830 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //constraint_set5_flag
831 bConstraintSetFlags[5] = !!uiCode;
832 WELS_READ_VERIFY (BsGetBits (pBs, 2, &uiCode)); // reserved_zero_2bits, equal to 0
833 WELS_READ_VERIFY (BsGetBits (pBs, 8, &uiCode)); // level_idc
834 uiLevelIdc = uiCode;
835 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //seq_parameter_set_id
836 iSpsId = uiCode;
800 if (iSpsId >= MAX_SPS_COUNT || iSpsId < 0) { // Modified to check invalid negative iSpsId, 12/1/2009837 if (iSpsId >= MAX_SPS_COUNT || iSpsId < 0) { // Modified to check invalid negative iSpsId, 12/1/2009
801 WelsLog (pCtx, WELS_LOG_WARNING, " iSpsId is out of range! \n");838 WelsLog (pCtx, WELS_LOG_WARNING, " iSpsId is out of range! \n");
802 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_SPS_ID_OVERFLOW);839 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_SPS_ID_OVERFLOW);
@@ -846,25 +883,30 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 43 unmodified lines
846 PRO_HIGH422 == uiProfileIdc || PRO_HIGH444 == uiProfileIdc ||883 PRO_HIGH422 == uiProfileIdc || PRO_HIGH444 == uiProfileIdc ||
847 PRO_CAVLC444 == uiProfileIdc || 44 == uiProfileIdc) {884 PRO_CAVLC444 == uiProfileIdc || 44 == uiProfileIdc) {
848 885
849 pSps->uiChromaFormatIdc = BsGetUe (pBs);886 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //chroma_format_idc
887 pSps->uiChromaFormatIdc = uiCode;
850 if (pSps->uiChromaFormatIdc != 1) {888 if (pSps->uiChromaFormatIdc != 1) {
851 WelsLog (pCtx, WELS_LOG_WARNING, "ParseSps(): chroma_format_idc (%d) = 1 supported.\n", pSps->uiChromaFormatIdc);889 WelsLog (pCtx, WELS_LOG_WARNING, "ParseSps(): chroma_format_idc (%d) = 1 supported.\n", pSps->uiChromaFormatIdc);
852 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);890 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
853 }891 }
854 pSps->uiChromaArrayType = pSps->uiChromaFormatIdc;892 pSps->uiChromaArrayType = pSps->uiChromaFormatIdc;
855 pSps->uiBitDepthLuma = 8 + BsGetUe (pBs);893 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //bit_depth_luma_minus8
894 pSps->uiBitDepthLuma = 8 + uiCode;
856 if (pSps->uiBitDepthLuma != 8) {895 if (pSps->uiBitDepthLuma != 8) {
857 WelsLog (pCtx, WELS_LOG_WARNING, "ParseSps(): bit_depth_luma (%d) Only 8 bit supported.\n", pSps->uiBitDepthLuma);896 WelsLog (pCtx, WELS_LOG_WARNING, "ParseSps(): bit_depth_luma (%d) Only 8 bit supported.\n", pSps->uiBitDepthLuma);
858 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);897 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
859 }898 }
860 899
861 pSps->uiBitDepthChroma = 8 + BsGetUe (pBs);900 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //bit_depth_chroma_minus8
901 pSps->uiBitDepthChroma = 8 + uiCode;
862 if (pSps->uiBitDepthChroma != 8) {902 if (pSps->uiBitDepthChroma != 8) {
863 WelsLog (pCtx, WELS_LOG_WARNING, "ParseSps(): bit_depth_chroma (%d). Only 8 bit supported.\n", pSps->uiBitDepthChroma);903 WelsLog (pCtx, WELS_LOG_WARNING, "ParseSps(): bit_depth_chroma (%d). Only 8 bit supported.\n", pSps->uiBitDepthChroma);
864 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);904 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
865 }905 }
866 pSps->bQpPrimeYZeroTransfBypassFlag = !!BsGetOneBit (pBs);906 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //qpprime_y_zero_transform_bypass_flag
867 pSps->bSeqScalingMatrixPresentFlag = !!BsGetOneBit (pBs);907 pSps->bQpPrimeYZeroTransfBypassFlag = !!uiCode;
908 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //seq_scaling_matrix_present_flag
909 pSps->bSeqScalingMatrixPresentFlag = !!uiCode;
868 910
869 if (pSps->bSeqScalingMatrixPresentFlag) { // For high profile, it is not used in current application. FIXME911 if (pSps->bSeqScalingMatrixPresentFlag) { // For high profile, it is not used in current application. FIXME
870 WelsLog (pCtx, WELS_LOG_WARNING, "ParseSps(): seq_scaling_matrix_present_flag (%d). Feature not supported.\n",912 WelsLog (pCtx, WELS_LOG_WARNING, "ParseSps(): seq_scaling_matrix_present_flag (%d). Feature not supported.\n",
@@ -872,54 +914,62 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 1 unmodified line
872 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);914 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
873 }915 }
874 }916 }
875 uiTmp = BsGetUe (pBs);917 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //log2_max_frame_num_minus4
876 WELS_CHECK_SE_UPPER_ERROR (uiTmp, SPS_LOG2_MAX_FRAME_NUM_MINUS4_MAX, "log2_max_frame_num_minus4",918 WELS_CHECK_SE_UPPER_ERROR (uiCode, SPS_LOG2_MAX_FRAME_NUM_MINUS4_MAX, "log2_max_frame_num_minus4",
877 GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_LOG2_MAX_FRAME_NUM_MINUS4));919 GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_LOG2_MAX_FRAME_NUM_MINUS4));
878 pSps->uiLog2MaxFrameNum = LOG2_MAX_FRAME_NUM_OFFSET + uiTmp; // log2_max_frame_num_minus4920 pSps->uiLog2MaxFrameNum = LOG2_MAX_FRAME_NUM_OFFSET + uiCode;
879 pSps->uiPocType = BsGetUe (pBs); // pic_order_cnt_type921 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_order_cnt_type
922 pSps->uiPocType = uiCode;
880 923
881 if (0 == pSps->uiPocType) {924 if (0 == pSps->uiPocType) {
882 uiTmp = BsGetUe (pBs);925 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //log2_max_pic_order_cnt_lsb_minus4
883 // log2_max_pic_order_cnt_lsb_minus4 should be in range 0 to 12, inclusive. (sec. 7.4.3)926 // log2_max_pic_order_cnt_lsb_minus4 should be in range 0 to 12, inclusive. (sec. 7.4.3)
884 WELS_CHECK_SE_UPPER_ERROR (uiTmp, SPS_LOG2_MAX_PIC_ORDER_CNT_LSB_MINUS4_MAX, "log2_max_pic_order_cnt_lsb_minus4",927 WELS_CHECK_SE_UPPER_ERROR (uiCode, SPS_LOG2_MAX_PIC_ORDER_CNT_LSB_MINUS4_MAX, "log2_max_pic_order_cnt_lsb_minus4",
885 GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_LOG2_MAX_PIC_ORDER_CNT_LSB_MINUS4));928 GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_LOG2_MAX_PIC_ORDER_CNT_LSB_MINUS4));
886 pSps->iLog2MaxPocLsb = LOG2_MAX_PIC_ORDER_CNT_LSB_OFFSET + uiTmp; // log2_max_pic_order_cnt_lsb_minus4929 pSps->iLog2MaxPocLsb = LOG2_MAX_PIC_ORDER_CNT_LSB_OFFSET + uiCode; // log2_max_pic_order_cnt_lsb_minus4
887 930
888 } else if (1 == pSps->uiPocType) {931 } else if (1 == pSps->uiPocType) {
889 int32_t i;932 int32_t i;
890 pSps->bDeltaPicOrderAlwaysZeroFlag = !!BsGetOneBit (pBs); // bDeltaPicOrderAlwaysZeroFlag933 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //delta_pic_order_always_zero_flag
891 pSps->iOffsetForNonRefPic = BsGetSe (pBs); // iOffsetForNonRefPic934 pSps->bDeltaPicOrderAlwaysZeroFlag = !!uiCode;
892 pSps->iOffsetForTopToBottomField = BsGetSe (pBs); // iOffsetForTopToBottomField935 WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //offset_for_non_ref_pic
893 uiTmp = BsGetUe (pBs);936 pSps->iOffsetForNonRefPic = iCode;
894 WELS_CHECK_SE_UPPER_ERROR (uiTmp, SPS_NUM_REF_FRAMES_IN_PIC_ORDER_CNT_CYCLE_MAX,937 WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //offset_for_top_to_bottom_field
938 pSps->iOffsetForTopToBottomField = iCode;
939 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //num_ref_frames_in_pic_order_cnt_cycle
940 WELS_CHECK_SE_UPPER_ERROR (uiCode, SPS_NUM_REF_FRAMES_IN_PIC_ORDER_CNT_CYCLE_MAX,
895 "num_ref_frames_in_pic_order_cnt_cycle", GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS,941 "num_ref_frames_in_pic_order_cnt_cycle", GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS,
896 ERR_INFO_INVALID_NUM_REF_FRAME_IN_PIC_ORDER_CNT_CYCLE));942 ERR_INFO_INVALID_NUM_REF_FRAME_IN_PIC_ORDER_CNT_CYCLE));
897 pSps->iNumRefFramesInPocCycle = uiTmp; // num_ref_frames_in_pic_order_cnt_cycle943 pSps->iNumRefFramesInPocCycle = uiCode;
898 for (i = 0; i < pSps->iNumRefFramesInPocCycle; i++)944 for (i = 0; i < pSps->iNumRefFramesInPocCycle; i++) {
899 pSps->iOffsetForRefFrame[ i ] = BsGetSe (pBs); // iOffsetForRefFrame[ i ]945 WELS_READ_VERIFY (BsGetSe (pBs, &iCode)); //offset_for_ref_frame[ i ]
946 pSps->iOffsetForRefFrame[ i ] = iCode;
947 }
900 }948 }
901 if (pSps->uiPocType > 2) {949 if (pSps->uiPocType > 2) {
902 WelsLog (pCtx, WELS_LOG_WARNING, " illegal pic_order_cnt_type: %d ! \n", pSps->uiPocType);950 WelsLog (pCtx, WELS_LOG_WARNING, " illegal pic_order_cnt_type: %d ! \n", pSps->uiPocType);
903 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_POC_TYPE);951 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_POC_TYPE);
904 }952 }
905 953
906 pSps->iNumRefFrames = BsGetUe (pBs); // max_num_ref_frames954 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //max_num_ref_frames
907 pSps->bGapsInFrameNumValueAllowedFlag = !!BsGetOneBit (pBs); // bGapsInFrameNumValueAllowedFlag955 pSps->iNumRefFrames = uiCode;
908 uiTmp = BsGetUe (pBs); // pic_width_in_mbs_minus1956 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //gaps_in_frame_num_value_allowed_flag
909 if (uiTmp == 0xffffffff) {957 pSps->bGapsInFrameNumValueAllowedFlag = !!uiCode;
958 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_width_in_mbs_minus1
959 if (uiCode == 0xffffffff) {
910 WelsLog (pCtx, WELS_LOG_ERROR, " pic_width_in_mbs read error!\n");960 WelsLog (pCtx, WELS_LOG_ERROR, " pic_width_in_mbs read error!\n");
911 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MB_SIZE_INFO);961 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MB_SIZE_INFO);
912 }962 }
913 pSps->iMbWidth = PIC_WIDTH_IN_MBS_OFFSET + uiTmp;963 pSps->iMbWidth = PIC_WIDTH_IN_MBS_OFFSET + uiCode;
914 if ((uint64_t) (pSps->iMbWidth * pSps->iMbWidth) > (8 * pSLevelLimits->iMaxFS)) {964 if ((uint64_t) (pSps->iMbWidth * pSps->iMbWidth) > (8 * pSLevelLimits->iMaxFS)) {
915 WelsLog (pCtx, WELS_LOG_WARNING, " the pic_width_in_mbs exceeds the level limits!\n");965 WelsLog (pCtx, WELS_LOG_WARNING, " the pic_width_in_mbs exceeds the level limits!\n");
916 }966 }
917 uiTmp = BsGetUe (pBs); // pic_height_in_map_units_minus1967 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //pic_height_in_map_units_minus1
918 if (uiTmp == 0xffffffff) {968 if (uiCode == 0xffffffff) {
919 WelsLog (pCtx, WELS_LOG_ERROR, " pic_height_in_mbs read error!\n");969 WelsLog (pCtx, WELS_LOG_ERROR, " pic_height_in_mbs read error!\n");
920 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MB_SIZE_INFO);970 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_MB_SIZE_INFO);
921 }971 }
922 pSps->iMbHeight = PIC_HEIGHT_IN_MAP_UNITS_OFFSET + uiTmp;972 pSps->iMbHeight = PIC_HEIGHT_IN_MAP_UNITS_OFFSET + uiCode;
923 if ((uint64_t) (pSps->iMbHeight * pSps->iMbHeight) > (8 * pSLevelLimits->iMaxFS)) {973 if ((uint64_t) (pSps->iMbHeight * pSps->iMbHeight) > (8 * pSLevelLimits->iMaxFS)) {
924 WelsLog (pCtx, WELS_LOG_WARNING, " the pic_height_in_mbs exceeds the level limits!\n");974 WelsLog (pCtx, WELS_LOG_WARNING, " the pic_height_in_mbs exceeds the level limits!\n");
925 }975 }
@@ -937,21 +987,28 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 11 unmodified lines
937 if ((uint32_t)pSps->iNumRefFrames > uiMaxDpbFrames) {987 if ((uint32_t)pSps->iNumRefFrames > uiMaxDpbFrames) {
938 WelsLog (pCtx, WELS_LOG_WARNING, " max_num_ref_frames exceeds level limits!\n");988 WelsLog (pCtx, WELS_LOG_WARNING, " max_num_ref_frames exceeds level limits!\n");
939 }989 }
940 pSps->bFrameMbsOnlyFlag = !!BsGetOneBit (pBs); // frame_mbs_only_flag990 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //frame_mbs_only_flag
991 pSps->bFrameMbsOnlyFlag = !!uiCode;
941 if (!pSps->bFrameMbsOnlyFlag) {992 if (!pSps->bFrameMbsOnlyFlag) {
942 WelsLog (pCtx, WELS_LOG_WARNING, "ParseSps(): frame_mbs_only_flag (%d) not supported.\n", pSps->bFrameMbsOnlyFlag);993 WelsLog (pCtx, WELS_LOG_WARNING, "ParseSps(): frame_mbs_only_flag (%d) not supported.\n", pSps->bFrameMbsOnlyFlag);
943 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_MBAFF);994 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_MBAFF);
944 }995 }
945 pSps->bDirect8x8InferenceFlag = !!BsGetOneBit (pBs); // direct_8x8_inference_flag996 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //direct_8x8_inference_flag
946 pSps->bFrameCroppingFlag = !!BsGetOneBit (pBs); // frame_cropping_flag997 pSps->bDirect8x8InferenceFlag = !!uiCode;
998 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //frame_cropping_flag
999 pSps->bFrameCroppingFlag = !!uiCode;
947 if (pSps->bFrameCroppingFlag) {1000 if (pSps->bFrameCroppingFlag) {
948 pSps->sFrameCrop.iLeftOffset = BsGetUe (pBs); // frame_crop_left_offset1001 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //frame_crop_left_offset
949 pSps->sFrameCrop.iRightOffset = BsGetUe (pBs); // frame_crop_right_offset1002 pSps->sFrameCrop.iLeftOffset = uiCode;
1003 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //frame_crop_right_offset
1004 pSps->sFrameCrop.iRightOffset = uiCode;
950 if ((pSps->sFrameCrop.iLeftOffset + pSps->sFrameCrop.iRightOffset) > ((int32_t)pSps->iMbWidth * 16 / 2)) {1005 if ((pSps->sFrameCrop.iLeftOffset + pSps->sFrameCrop.iRightOffset) > ((int32_t)pSps->iMbWidth * 16 / 2)) {
951 WelsLog (pCtx, WELS_LOG_WARNING, "frame_crop_left_offset + frame_crop_right_offset exceeds limits!\n");1006 WelsLog (pCtx, WELS_LOG_WARNING, "frame_crop_left_offset + frame_crop_right_offset exceeds limits!\n");
952 }1007 }
953 pSps->sFrameCrop.iTopOffset = BsGetUe (pBs); // frame_crop_top_offset1008 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //frame_crop_top_offset
954 pSps->sFrameCrop.iBottomOffset = BsGetUe (pBs); // frame_crop_bottom_offset1009 pSps->sFrameCrop.iTopOffset = uiCode;
1010 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //frame_crop_bottom_offset
1011 pSps->sFrameCrop.iBottomOffset = uiCode;
955 if ((pSps->sFrameCrop.iTopOffset + pSps->sFrameCrop.iBottomOffset) > ((int32_t)pSps->iMbHeight * 16 / 2)) {1012 if ((pSps->sFrameCrop.iTopOffset + pSps->sFrameCrop.iBottomOffset) > ((int32_t)pSps->iMbHeight * 16 / 2)) {
956 WelsLog (pCtx, WELS_LOG_WARNING, "frame_crop_top_offset + frame_crop_right_offset exceeds limits!\n");1013 WelsLog (pCtx, WELS_LOG_WARNING, "frame_crop_top_offset + frame_crop_right_offset exceeds limits!\n");
957 }1014 }
@@ -961,7 +1018,8 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 3 unmodified lines
961 pSps->sFrameCrop.iTopOffset = 0; // frame_crop_top_offset1018 pSps->sFrameCrop.iTopOffset = 0; // frame_crop_top_offset
962 pSps->sFrameCrop.iBottomOffset = 0; // frame_crop_bottom_offset1019 pSps->sFrameCrop.iBottomOffset = 0; // frame_crop_bottom_offset
963 }1020 }
964 pSps->bVuiParamPresentFlag = !!BsGetOneBit (pBs); // vui_parameters_present_flag1021 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //vui_parameters_present_flag
1022 pSps->bVuiParamPresentFlag = !!uiCode;
965 1023
966 // Check if SPS SVC extension applicated1024 // Check if SPS SVC extension applicated
967 if (kbUseSubsetFlag && (PRO_SCALABLE_BASELINE == uiProfileIdc || PRO_SCALABLE_HIGH == uiProfileIdc)) {1025 if (kbUseSubsetFlag && (PRO_SCALABLE_BASELINE == uiProfileIdc || PRO_SCALABLE_HIGH == uiProfileIdc)) {
@@ -969,7 +1027,8 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 1 unmodified line
969 return -1;1027 return -1;
970 }1028 }
971 1029
972 pSubsetSps->bSvcVuiParamPresentFlag = !!BsGetOneBit (pBs);1030 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //svc_vui_parameters_present_flag
1031 pSubsetSps->bSvcVuiParamPresentFlag = !!uiCode;
973 if (pSubsetSps->bSvcVuiParamPresentFlag) {1032 if (pSubsetSps->bSvcVuiParamPresentFlag) {
974 }1033 }
975 }1034 }
@@ -1005,8 +1064,11 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux) · 29 unmodified lines
1005 PPps pPps = NULL;1064 PPps pPps = NULL;
1006 uint32_t uiPpsId = 0;1065 uint32_t uiPpsId = 0;
1007 uint32_t iTmp;1066 uint32_t iTmp;
1067 uint32_t uiCode;
1068 int32_t iCode;
1008 1069
1009 uiPpsId = BsGetUe (pBsAux);1070 WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //pic_parameter_set_id
1071 uiPpsId = uiCode;
1010 if (uiPpsId >= MAX_PPS_COUNT) {1072 if (uiPpsId >= MAX_PPS_COUNT) {
1011 return ERR_INFO_PPS_ID_OVERFLOW;1073 return ERR_INFO_PPS_ID_OVERFLOW;
1012 }1074 }
@@ -1019,23 +1081,28 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux) · 6 unmodified lines
1019 1081
1020 1082
1021 pPps->iPpsId = uiPpsId;1083 pPps->iPpsId = uiPpsId;
1022 pPps->iSpsId = BsGetUe (pBsAux);1084 WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //seq_parameter_set_id
1085 pPps->iSpsId = uiCode;
1023 1086
1024 if (pPps->iSpsId >= MAX_SPS_COUNT) {1087 if (pPps->iSpsId >= MAX_SPS_COUNT) {
1025 return ERR_INFO_SPS_ID_OVERFLOW;1088 return ERR_INFO_SPS_ID_OVERFLOW;
1026 }1089 }
1027 1090
1028 pPps->bEntropyCodingModeFlag = !!BsGetOneBit (pBsAux);1091 WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //entropy_coding_mode_flag
1029 pPps->bPicOrderPresentFlag = !!BsGetOneBit (pBsAux);1092 pPps->bEntropyCodingModeFlag = !!uiCode;
1093 WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //bottom_field_pic_order_in_frame_present_flag
1094 pPps->bPicOrderPresentFlag = !!uiCode;
1030 1095
1031 pPps->uiNumSliceGroups = NUM_SLICE_GROUPS_OFFSET + BsGetUe (pBsAux);1096 WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //num_slice_groups_minus1
1097 pPps->uiNumSliceGroups = NUM_SLICE_GROUPS_OFFSET + uiCode;
1032 1098
1033 if (pPps->uiNumSliceGroups > MAX_SLICEGROUP_IDS) {1099 if (pPps->uiNumSliceGroups > MAX_SLICEGROUP_IDS) {
1034 return ERR_INFO_INVALID_SLICEGROUP;1100 return ERR_INFO_INVALID_SLICEGROUP;
1035 }1101 }
1036 1102
1037 if (pPps->uiNumSliceGroups > 1) {1103 if (pPps->uiNumSliceGroups > 1) {
1038 pPps->uiSliceGroupMapType = BsGetUe (pBsAux);1104 WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //slice_group_map_type
1105 pPps->uiSliceGroupMapType = uiCode;
1039 if (pPps->uiSliceGroupMapType > 1) {1106 if (pPps->uiSliceGroupMapType > 1) {
1040 WelsLog (pCtx, WELS_LOG_WARNING, "ParsePps(): slice_group_map_type (%d): support only 0,1.\n",1107 WelsLog (pCtx, WELS_LOG_WARNING, "ParsePps(): slice_group_map_type (%d): support only 0,1.\n",
1041 pPps->uiSliceGroupMapType);1108 pPps->uiSliceGroupMapType);
@@ -1045,7 +1112,8 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux) · 3 unmodified lines
1045 switch (pPps->uiSliceGroupMapType) {1112 switch (pPps->uiSliceGroupMapType) {
1046 case 0:1113 case 0:
1047 for (iTmp = 0; iTmp < pPps->uiNumSliceGroups; iTmp++) {1114 for (iTmp = 0; iTmp < pPps->uiNumSliceGroups; iTmp++) {
1048 pPps->uiRunLength[iTmp] = RUN_LENGTH_OFFSET + BsGetUe (pBsAux);1115 WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //run_length_minus1[ iGroup ]
1116 pPps->uiRunLength[iTmp] = RUN_LENGTH_OFFSET + uiCode;
1049 }1117 }
1050 break;1118 break;
1051 default:1119 default:
@@ -1053,34 +1121,44 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux) · 1 unmodified line
1053 }1121 }
1054 }1122 }
1055 1123
1056 pPps->uiNumRefIdxL0Active = NUM_REF_IDX_L0_DEFAULT_ACTIVE_OFFSET + BsGetUe (pBsAux);1124 WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //num_ref_idx_l0_default_active_minus1
1057 pPps->uiNumRefIdxL1Active = NUM_REF_IDX_L1_DEFAULT_ACTIVE_OFFSET + BsGetUe (pBsAux);1125 pPps->uiNumRefIdxL0Active = NUM_REF_IDX_L0_DEFAULT_ACTIVE_OFFSET + uiCode;
1126 WELS_READ_VERIFY (BsGetUe (pBsAux, &uiCode)); //num_ref_idx_l1_default_active_minus1
1127 pPps->uiNumRefIdxL1Active = NUM_REF_IDX_L1_DEFAULT_ACTIVE_OFFSET + uiCode;
1058 1128
1059 if (pPps->uiNumRefIdxL0Active > MAX_REF_PIC_COUNT ||1129 if (pPps->uiNumRefIdxL0Active > MAX_REF_PIC_COUNT ||
1060 pPps->uiNumRefIdxL1Active > MAX_REF_PIC_COUNT) {1130 pPps->uiNumRefIdxL1Active > MAX_REF_PIC_COUNT) {
1061 return ERR_INFO_REF_COUNT_OVERFLOW;1131 return ERR_INFO_REF_COUNT_OVERFLOW;
1062 }1132 }
1063 1133
1064 pPps->bWeightedPredFlag = !!BsGetOneBit (pBsAux);1134 WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //weighted_pred_flag
1065 pPps->uiWeightedBipredIdc = BsGetBits (pBsAux, 2);1135 pPps->bWeightedPredFlag = !!uiCode;
1136 WELS_READ_VERIFY (BsGetBits (pBsAux, 2, &uiCode)); //weighted_bipred_idc
1137 pPps->uiWeightedBipredIdc = uiCode;
1066 if (pPps->bWeightedPredFlag || pPps->uiWeightedBipredIdc != 0) {1138 if (pPps->bWeightedPredFlag || pPps->uiWeightedBipredIdc != 0) {
1067 WelsLog (pCtx, WELS_LOG_WARNING, "ParsePps(): weighted_pred_flag (%d) weighted_bipred_idc (%d) neither supported.\n",1139 WelsLog (pCtx, WELS_LOG_WARNING, "ParsePps(): weighted_pred_flag (%d) weighted_bipred_idc (%d) neither supported.\n",
1068 pPps->bWeightedPredFlag, pPps->uiWeightedBipredIdc);1140 pPps->bWeightedPredFlag, pPps->uiWeightedBipredIdc);
1069 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_WP);1141 return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_WP);
1070 }1142 }
1071 1143
1072 pPps->iPicInitQp = PIC_INIT_QP_OFFSET + BsGetSe (pBsAux);1144 WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode)); //pic_init_qp_minus26
1145 pPps->iPicInitQp = PIC_INIT_QP_OFFSET + iCode;
1073 WELS_CHECK_SE_BOTH_ERROR (pPps->iPicInitQp, PPS_PIC_INIT_QP_QS_MIN, PPS_PIC_INIT_QP_QS_MAX, "pic_init_qp_minus26 + 26",1146 WELS_CHECK_SE_BOTH_ERROR (pPps->iPicInitQp, PPS_PIC_INIT_QP_QS_MIN, PPS_PIC_INIT_QP_QS_MAX, "pic_init_qp_minus26 + 26",
1074 GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_PIC_INIT_QP));1147 GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_PIC_INIT_QP));
1075 pPps->iPicInitQs = PIC_INIT_QS_OFFSET + BsGetSe (pBsAux);1148 WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode)); //pic_init_qs_minus26
1149 pPps->iPicInitQs = PIC_INIT_QS_OFFSET + iCode;
1076 WELS_CHECK_SE_BOTH_ERROR (pPps->iPicInitQs, PPS_PIC_INIT_QP_QS_MIN, PPS_PIC_INIT_QP_QS_MAX, "pic_init_qs_minus26 + 26",1150 WELS_CHECK_SE_BOTH_ERROR (pPps->iPicInitQs, PPS_PIC_INIT_QP_QS_MIN, PPS_PIC_INIT_QP_QS_MAX, "pic_init_qs_minus26 + 26",
1077 GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_PIC_INIT_QS));1151 GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_PIC_INIT_QS));
1078 pPps->iChromaQpIndexOffset = BsGetSe (pBsAux);1152 WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode)); //chroma_qp_index_offset
1153 pPps->iChromaQpIndexOffset = iCode;
1079 WELS_CHECK_SE_BOTH_ERROR (pPps->iChromaQpIndexOffset, PPS_CHROMA_QP_INDEX_OFFSET_MIN, PPS_CHROMA_QP_INDEX_OFFSET_MAX,1154 WELS_CHECK_SE_BOTH_ERROR (pPps->iChromaQpIndexOffset, PPS_CHROMA_QP_INDEX_OFFSET_MIN, PPS_CHROMA_QP_INDEX_OFFSET_MAX,
1080 "chroma_qp_index_offset", GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_CHROMA_QP_INDEX_OFFSET));1155 "chroma_qp_index_offset", GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_CHROMA_QP_INDEX_OFFSET));
1081 pPps->bDeblockingFilterControlPresentFlag = !!BsGetOneBit (pBsAux);1156 WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //deblocking_filter_control_present_flag
1082 pPps->bConstainedIntraPredFlag = !!BsGetOneBit (pBsAux);1157 pPps->bDeblockingFilterControlPresentFlag = !!uiCode;
1083 pPps->bRedundantPicCntPresentFlag = !!BsGetOneBit (pBsAux);1158 WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //constrained_intra_pred_flag
1159 pPps->bConstainedIntraPredFlag = !!uiCode;
1160 WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //redundant_pic_cnt_present_flag
1161 pPps->bRedundantPicCntPresentFlag = !!uiCode;
1084 1162
1085 1163
1086#ifdef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID1164#ifdef MOSAIC_AVOID_BASED_ON_SPS_PPS_ID

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