| @@ -150,6 +150,59 @@ static int decode_nal_sei_timecode(HEVCSEITimeCode *s, GetBitContext *gb) · 149 unmodified lines |
| 150 | return 0; | 150 | return 0; |
| 151 | } | 151 | } |
| 152 | | 152 | |
| | 153 | static int decode_nal_sei_3d_reference_displays_info(HEVCSEITDRDI *s, GetBitContext *gb) |
| | 154 | { |
| | 155 | s->prec_ref_display_width = get_ue_golomb(gb); |
| | 156 | if (s->prec_ref_display_width > 31) |
| | 157 | return AVERROR_INVALIDDATA; |
| | 158 | s->ref_viewing_distance_flag = get_bits1(gb); |
| | 159 | if (s->ref_viewing_distance_flag) { |
| | 160 | s->prec_ref_viewing_dist = get_ue_golomb(gb); |
| | 161 | if (s->prec_ref_viewing_dist > 31) |
| | 162 | return AVERROR_INVALIDDATA; |
| | 163 | } |
| | 164 | s->num_ref_displays = get_ue_golomb(gb); |
| | 165 | if (s->num_ref_displays > 31) |
| | 166 | return AVERROR_INVALIDDATA; |
| | 167 | s->num_ref_displays += 1; |
| | 168 | |
| | 169 | for (int i = 0; i < s->num_ref_displays; i++) { |
| | 170 | int length; |
| | 171 | s->left_view_id[i] = get_ue_golomb(gb); |
| | 172 | s->right_view_id[i] = get_ue_golomb(gb); |
| | 173 | s->exponent_ref_display_width[i] = get_bits(gb, 6); |
| | 174 | if (s->exponent_ref_display_width[i] > 62) |
| | 175 | return AVERROR_INVALIDDATA; |
| | 176 | else if (!s->exponent_ref_display_width[i]) |
| | 177 | length = FFMAX(0, (int)s->prec_ref_display_width - 30); |
| | 178 | else |
| | 179 | length = FFMAX(0, (int)s->exponent_ref_display_width[i] + |
| | 180 | (int)s->prec_ref_display_width - 31); |
| | 181 | s->mantissa_ref_display_width[i] = get_bits_long(gb, length); |
| | 182 | if (s->ref_viewing_distance_flag) { |
| | 183 | s->exponent_ref_viewing_distance[i] = get_bits(gb, 6); |
| | 184 | if (s->exponent_ref_viewing_distance[i] > 62) |
| | 185 | return AVERROR_INVALIDDATA; |
| | 186 | else if (!s->exponent_ref_viewing_distance[i]) |
| | 187 | length = FFMAX(0, (int)s->prec_ref_viewing_dist - 30); |
| | 188 | else |
| | 189 | length = FFMAX(0, (int)s->exponent_ref_viewing_distance[i] + |
| | 190 | (int)s->prec_ref_viewing_dist - 31); |
| | 191 | s->mantissa_ref_viewing_distance[i] = get_bits_long(gb, length); |
| | 192 | } |
| | 193 | s->additional_shift_present_flag[i] = get_bits1(gb); |
| | 194 | if (s->additional_shift_present_flag[i]) { |
| | 195 | s->num_sample_shift[i] = get_bits(gb, 10); |
| | 196 | if (s->num_sample_shift[i] > 1023) |
| | 197 | return AVERROR_INVALIDDATA; |
| | 198 | s->num_sample_shift[i] -= 512; |
| | 199 | } |
| | 200 | } |
| | 201 | s->three_dimensional_reference_displays_extension_flag = get_bits1(gb); |
| | 202 | |
| | 203 | return 0; |
| | 204 | } |
| | 205 | |
| 153 | static int decode_nal_sei_prefix(GetBitContext *gb, GetByteContext *gbyte, | 206 | static int decode_nal_sei_prefix(GetBitContext *gb, GetByteContext *gbyte, |
| 154 | void *logctx, HEVCSEI *s, | 207 | void *logctx, HEVCSEI *s, |
| 155 | const HEVCParamSets *ps, int type) | 208 | const HEVCParamSets *ps, int type) |
| @@ -163,6 +216,8 @@ static int decode_nal_sei_prefix(GetBitContext *gb, GetByteContext *gbyte, · 7 unmodified lines |
| 163 | return decode_nal_sei_active_parameter_sets(s, gb, logctx); | 216 | return decode_nal_sei_active_parameter_sets(s, gb, logctx); |
| 164 | case SEI_TYPE_TIME_CODE: | 217 | case SEI_TYPE_TIME_CODE: |
| 165 | return decode_nal_sei_timecode(&s->timecode, gb); | 218 | return decode_nal_sei_timecode(&s->timecode, gb); |
| | 219 | case SEI_TYPE_THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO: |
| | 220 | return decode_nal_sei_3d_reference_displays_info(&s->tdrdi, gb); |
| 166 | default: { | 221 | default: { |
| 167 | int ret = ff_h2645_sei_message_decode(&s->common, type, AV_CODEC_ID_HEVC, | 222 | int ret = ff_h2645_sei_message_decode(&s->common, type, AV_CODEC_ID_HEVC, |
| 168 | gb, gbyte, logctx); | 223 | gb, gbyte, logctx); |