Showing the changes to libavcodec (2 of 2 files). Show all
Unified · Split
| @@ -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); |
| @@ -79,12 +79,29 @@ typedef struct HEVCSEITimeCode { · 78 unmodified lines | |||
| 79 | int32_t time_offset_value[3]; | 79 | int32_t time_offset_value[3]; |
| 80 | } HEVCSEITimeCode; | 80 | } HEVCSEITimeCode; |
| 81 | 81 | ||
| 82 | typedef struct HEVCSEITDRDI { | ||
| 83 | uint8_t prec_ref_display_width; | ||
| 84 | uint8_t ref_viewing_distance_flag; | ||
| 85 | uint8_t prec_ref_viewing_dist; | ||
| 86 | uint8_t num_ref_displays; | ||
| 87 | uint16_t left_view_id[31]; | ||
| 88 | uint16_t right_view_id[31]; | ||
| 89 | uint8_t exponent_ref_display_width[31]; | ||
| 90 | uint8_t mantissa_ref_display_width[31]; | ||
| 91 | uint8_t exponent_ref_viewing_distance[31]; | ||
| 92 | uint8_t mantissa_ref_viewing_distance[31]; | ||
| 93 | uint8_t additional_shift_present_flag[31]; | ||
| 94 | int16_t num_sample_shift[31]; | ||
| 95 | uint8_t three_dimensional_reference_displays_extension_flag; | ||
| 96 | } HEVCSEITDRDI; | ||
| 97 | |||
| 82 | typedef struct HEVCSEI { | 98 | typedef struct HEVCSEI { |
| 83 | H2645SEI common; | 99 | H2645SEI common; |
| 84 | HEVCSEIPictureHash picture_hash; | 100 | HEVCSEIPictureHash picture_hash; |
| 85 | HEVCSEIPictureTiming picture_timing; | 101 | HEVCSEIPictureTiming picture_timing; |
| 86 | int active_seq_parameter_set_id; | 102 | int active_seq_parameter_set_id; |
| 87 | HEVCSEITimeCode timecode; | 103 | HEVCSEITimeCode timecode; |
| 104 | HEVCSEITDRDI tdrdi; | ||
| 88 | } HEVCSEI; | 105 | } HEVCSEI; |
| 89 | 106 | ||
| 90 | struct HEVCParamSets; | 107 | struct HEVCParamSets; |