| @@ -44,21 +44,15 @@ int ff_evc_get_temporal_id(const uint8_t *bits, int bits_size, void *logctx) · 43 unmodified lines |
| 44 | } | 44 | } |
| 45 | | 45 | |
| 46 | // @see ISO_IEC_23094-1 (7.3.2.6 Slice layer RBSP syntax) | 46 | // @see ISO_IEC_23094-1 (7.3.2.6 Slice layer RBSP syntax) |
| 47 | int ff_evc_parse_slice_header(EVCParserSliceHeader *sh, const EVCParamSets *ps, | 47 | int ff_evc_parse_slice_header(GetBitContext *gb, EVCParserSliceHeader *sh, |
| 48 | enum EVCNALUnitType nalu_type, const uint8_t *bs, int bs_size) | 48 | const EVCParamSets *ps, enum EVCNALUnitType nalu_type) |
| 49 | { | 49 | { |
| 50 | GetBitContext gb; | | |
| 51 | const EVCParserPPS *pps; | 50 | const EVCParserPPS *pps; |
| 52 | const EVCParserSPS *sps; | 51 | const EVCParserSPS *sps; |
| 53 | | | |
| 54 | int num_tiles_in_slice = 0; | 52 | int num_tiles_in_slice = 0; |
| 55 | int slice_pic_parameter_set_id; | 53 | int slice_pic_parameter_set_id; |
| 56 | int ret; | | |
| 57 | | | |
| 58 | if ((ret = init_get_bits8(&gb, bs, bs_size)) < 0) | | |
| 59 | return ret; | | |
| 60 | | 54 | |
| 61 | slice_pic_parameter_set_id = get_ue_golomb(&gb); | 55 | slice_pic_parameter_set_id = get_ue_golomb(gb); |
| 62 | | 56 | |
| 63 | if (slice_pic_parameter_set_id < 0 || slice_pic_parameter_set_id >= EVC_MAX_PPS_COUNT) | 57 | if (slice_pic_parameter_set_id < 0 || slice_pic_parameter_set_id >= EVC_MAX_PPS_COUNT) |
| 64 | return AVERROR_INVALIDDATA; | 58 | return AVERROR_INVALIDDATA; |
| @@ -75,47 +69,47 @@ int ff_evc_parse_slice_header(EVCParserSliceHeader *sh, const EVCParamSets *ps, · 10 unmodified lines |
| 75 | sh->slice_pic_parameter_set_id = slice_pic_parameter_set_id; | 69 | sh->slice_pic_parameter_set_id = slice_pic_parameter_set_id; |
| 76 | | 70 | |
| 77 | if (!pps->single_tile_in_pic_flag) { | 71 | if (!pps->single_tile_in_pic_flag) { |
| 78 | sh->single_tile_in_slice_flag = get_bits1(&gb); | 72 | sh->single_tile_in_slice_flag = get_bits1(gb); |
| 79 | sh->first_tile_id = get_bits(&gb, pps->tile_id_len_minus1 + 1); | 73 | sh->first_tile_id = get_bits(gb, pps->tile_id_len_minus1 + 1); |
| 80 | } else | 74 | } else |
| 81 | sh->single_tile_in_slice_flag = 1; | 75 | sh->single_tile_in_slice_flag = 1; |
| 82 | | 76 | |
| 83 | if (!sh->single_tile_in_slice_flag) { | 77 | if (!sh->single_tile_in_slice_flag) { |
| 84 | if (pps->arbitrary_slice_present_flag) | 78 | if (pps->arbitrary_slice_present_flag) |
| 85 | sh->arbitrary_slice_flag = get_bits1(&gb); | 79 | sh->arbitrary_slice_flag = get_bits1(gb); |
| 86 | | 80 | |
| 87 | if (!sh->arbitrary_slice_flag) | 81 | if (!sh->arbitrary_slice_flag) |
| 88 | sh->last_tile_id = get_bits(&gb, pps->tile_id_len_minus1 + 1); | 82 | sh->last_tile_id = get_bits(gb, pps->tile_id_len_minus1 + 1); |
| 89 | else { | 83 | else { |
| 90 | sh->num_remaining_tiles_in_slice_minus1 = get_ue_golomb(&gb); | 84 | sh->num_remaining_tiles_in_slice_minus1 = get_ue_golomb(gb); |
| 91 | num_tiles_in_slice = sh->num_remaining_tiles_in_slice_minus1 + 2; | 85 | num_tiles_in_slice = sh->num_remaining_tiles_in_slice_minus1 + 2; |
| 92 | for (int i = 0; i < num_tiles_in_slice - 1; ++i) | 86 | for (int i = 0; i < num_tiles_in_slice - 1; ++i) |
| 93 | sh->delta_tile_id_minus1[i] = get_ue_golomb(&gb); | 87 | sh->delta_tile_id_minus1[i] = get_ue_golomb(gb); |
| 94 | } | 88 | } |
| 95 | } | 89 | } |
| 96 | | 90 | |
| 97 | sh->slice_type = get_ue_golomb(&gb); | 91 | sh->slice_type = get_ue_golomb(gb); |
| 98 | | 92 | |
| 99 | if (nalu_type == EVC_IDR_NUT) | 93 | if (nalu_type == EVC_IDR_NUT) |
| 100 | sh->no_output_of_prior_pics_flag = get_bits1(&gb); | 94 | sh->no_output_of_prior_pics_flag = get_bits1(gb); |
| 101 | | 95 | |
| 102 | if (sps->sps_mmvd_flag && ((sh->slice_type == EVC_SLICE_TYPE_B) || (sh->slice_type == EVC_SLICE_TYPE_P))) | 96 | if (sps->sps_mmvd_flag && ((sh->slice_type == EVC_SLICE_TYPE_B) || (sh->slice_type == EVC_SLICE_TYPE_P))) |
| 103 | sh->mmvd_group_enable_flag = get_bits1(&gb); | 97 | sh->mmvd_group_enable_flag = get_bits1(gb); |
| 104 | else | 98 | else |
| 105 | sh->mmvd_group_enable_flag = 0; | 99 | sh->mmvd_group_enable_flag = 0; |
| 106 | | 100 | |
| 107 | if (sps->sps_alf_flag) { | 101 | if (sps->sps_alf_flag) { |
| 108 | int ChromaArrayType = sps->chroma_format_idc; | 102 | int ChromaArrayType = sps->chroma_format_idc; |
| 109 | | 103 | |
| 110 | sh->slice_alf_enabled_flag = get_bits1(&gb); | 104 | sh->slice_alf_enabled_flag = get_bits1(gb); |
| 111 | | 105 | |
| 112 | if (sh->slice_alf_enabled_flag) { | 106 | if (sh->slice_alf_enabled_flag) { |
| 113 | sh->slice_alf_luma_aps_id = get_bits(&gb, 5); | 107 | sh->slice_alf_luma_aps_id = get_bits(gb, 5); |
| 114 | sh->slice_alf_map_flag = get_bits1(&gb); | 108 | sh->slice_alf_map_flag = get_bits1(gb); |
| 115 | sh->slice_alf_chroma_idc = get_bits(&gb, 2); | 109 | sh->slice_alf_chroma_idc = get_bits(gb, 2); |
| 116 | | 110 | |
| 117 | if ((ChromaArrayType == 1 || ChromaArrayType == 2) && sh->slice_alf_chroma_idc > 0) | 111 | if ((ChromaArrayType == 1 || ChromaArrayType == 2) && sh->slice_alf_chroma_idc > 0) |
| 118 | sh->slice_alf_chroma_aps_id = get_bits(&gb, 5); | 112 | sh->slice_alf_chroma_aps_id = get_bits(gb, 5); |
| 119 | } | 113 | } |
| 120 | if (ChromaArrayType == 3) { | 114 | if (ChromaArrayType == 3) { |
| 121 | int sliceChromaAlfEnabledFlag = 0; | 115 | int sliceChromaAlfEnabledFlag = 0; |
| @@ -136,23 +130,23 @@ int ff_evc_parse_slice_header(EVCParserSliceHeader *sh, const EVCParamSets *ps, · 14 unmodified lines |
| 136 | } | 130 | } |
| 137 | | 131 | |
| 138 | if (!sh->slice_alf_enabled_flag) | 132 | if (!sh->slice_alf_enabled_flag) |
| 139 | sh->slice_alf_chroma_idc = get_bits(&gb, 2); | 133 | sh->slice_alf_chroma_idc = get_bits(gb, 2); |
| 140 | | 134 | |
| 141 | if (sliceChromaAlfEnabledFlag) { | 135 | if (sliceChromaAlfEnabledFlag) { |
| 142 | sh->slice_alf_chroma_aps_id = get_bits(&gb, 5); | 136 | sh->slice_alf_chroma_aps_id = get_bits(gb, 5); |
| 143 | sh->slice_alf_chroma_map_flag = get_bits1(&gb); | 137 | sh->slice_alf_chroma_map_flag = get_bits1(gb); |
| 144 | } | 138 | } |
| 145 | | 139 | |
| 146 | if (sliceChroma2AlfEnabledFlag) { | 140 | if (sliceChroma2AlfEnabledFlag) { |
| 147 | sh->slice_alf_chroma2_aps_id = get_bits(&gb, 5); | 141 | sh->slice_alf_chroma2_aps_id = get_bits(gb, 5); |
| 148 | sh->slice_alf_chroma2_map_flag = get_bits1(&gb); | 142 | sh->slice_alf_chroma2_map_flag = get_bits1(gb); |
| 149 | } | 143 | } |
| 150 | } | 144 | } |
| 151 | } | 145 | } |
| 152 | | 146 | |
| 153 | if (nalu_type != EVC_IDR_NUT) { | 147 | if (nalu_type != EVC_IDR_NUT) { |
| 154 | if (sps->sps_pocs_flag) | 148 | if (sps->sps_pocs_flag) |
| 155 | sh->slice_pic_order_cnt_lsb = get_bits(&gb, sps->log2_max_pic_order_cnt_lsb_minus4 + 4); | 149 | sh->slice_pic_order_cnt_lsb = get_bits(gb, sps->log2_max_pic_order_cnt_lsb_minus4 + 4); |
| 156 | } | 150 | } |
| 157 | | 151 | |
| 158 | // @note | 152 | // @note |