FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/h2645_sei.c
Date: 2025-08-19 23:55:23
Exec Total Coverage
Lines: 269 509 52.8%
Functions: 16 21 76.2%
Branches: 125 309 40.5%

Line Branch Exec Source
1 /*
2 * Common H.264 and HEVC Supplementary Enhancement Information messages
3 *
4 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
5 * Copyright (C) 2012 - 2013 Guillaume Martres
6 * Copyright (C) 2012 - 2013 Gildas Cocherel
7 * Copyright (C) 2013 Vittorio Giovara
8 *
9 * This file is part of FFmpeg.
10 *
11 * FFmpeg is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * FFmpeg is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with FFmpeg; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25
26 #include "config_components.h"
27
28 #include "libavutil/ambient_viewing_environment.h"
29 #include "libavutil/buffer.h"
30 #include "libavutil/display.h"
31 #include "libavutil/hdr_dynamic_metadata.h"
32 #include "libavutil/film_grain_params.h"
33 #include "libavutil/mastering_display_metadata.h"
34 #include "libavutil/mem.h"
35 #include "libavutil/refstruct.h"
36 #include "libavutil/stereo3d.h"
37
38 #include "atsc_a53.h"
39 #include "avcodec.h"
40 #include "decode.h"
41 #include "dynamic_hdr_vivid.h"
42 #include "get_bits.h"
43 #include "golomb.h"
44 #include "h2645_sei.h"
45 #include "itut35.h"
46
47 #define IS_H264(codec_id) (CONFIG_H264_SEI && (CONFIG_HEVC_SEI || CONFIG_VVC_SEI ) ? codec_id == AV_CODEC_ID_H264 : CONFIG_H264_SEI)
48 #define IS_HEVC(codec_id) (CONFIG_HEVC_SEI && (CONFIG_H264_SEI || CONFIG_VVC_SEI ) ? codec_id == AV_CODEC_ID_HEVC : CONFIG_HEVC_SEI)
49 #define IS_VVC(codec_id) (CONFIG_VVC_SEI && (CONFIG_H264_SEI || CONFIG_HEVC_SEI) ? codec_id == AV_CODEC_ID_VVC : CONFIG_VVC_SEI )
50
51 #if CONFIG_HEVC_SEI
52 11 static int decode_registered_user_data_dynamic_hdr_plus(HEVCSEIDynamicHDRPlus *s,
53 GetByteContext *gb)
54 {
55 size_t meta_size;
56 int err;
57 11 AVDynamicHDRPlus *metadata = av_dynamic_hdr_plus_alloc(&meta_size);
58
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!metadata)
59 return AVERROR(ENOMEM);
60
61 11 err = av_dynamic_hdr_plus_from_t35(metadata, gb->buffer,
62 11 bytestream2_get_bytes_left(gb));
63
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (err < 0) {
64 av_free(metadata);
65 return err;
66 }
67
68 11 av_buffer_unref(&s->info);
69 11 s->info = av_buffer_create((uint8_t *)metadata, meta_size, NULL, NULL, 0);
70
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!s->info) {
71 av_free(metadata);
72 return AVERROR(ENOMEM);
73 }
74
75 11 return 0;
76 }
77
78 3 static int decode_registered_user_data_dynamic_hdr_vivid(HEVCSEIDynamicHDRVivid *s,
79 GetByteContext *gb)
80 {
81 size_t meta_size;
82 int err;
83 3 AVDynamicHDRVivid *metadata = av_dynamic_hdr_vivid_alloc(&meta_size);
84
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!metadata)
85 return AVERROR(ENOMEM);
86
87 3 err = ff_parse_itu_t_t35_to_dynamic_hdr_vivid(metadata,
88 gb->buffer, bytestream2_get_bytes_left(gb));
89
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (err < 0) {
90 av_free(metadata);
91 return err;
92 }
93
94 3 av_buffer_unref(&s->info);
95 3 s->info = av_buffer_create((uint8_t *)metadata, meta_size, NULL, NULL, 0);
96
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!s->info) {
97 av_free(metadata);
98 return AVERROR(ENOMEM);
99 }
100
101 3 return 0;
102 }
103 #endif
104
105 static int decode_registered_user_data_lcevc(HEVCSEILCEVC *s,
106 GetByteContext *gb)
107 {
108 int size = bytestream2_get_bytes_left(gb);
109
110 av_buffer_unref(&s->info);
111 s->info = av_buffer_alloc(size);
112 if (!s->info)
113 return AVERROR(ENOMEM);
114
115 bytestream2_get_bufferu(gb, s->info->data, size);
116 return 0;
117 }
118
119 1169 static int decode_registered_user_data_afd(H2645SEIAFD *h, GetByteContext *gb)
120 {
121 int flag;
122
123
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1169 times.
1169 if (bytestream2_get_bytes_left(gb) <= 0)
124 return AVERROR_INVALIDDATA;
125
126 1169 flag = !!(bytestream2_get_byteu(gb) & 0x40); // active_format_flag
127
128
1/2
✓ Branch 0 taken 1169 times.
✗ Branch 1 not taken.
1169 if (flag) {
129
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1169 times.
1169 if (bytestream2_get_bytes_left(gb) <= 0)
130 return AVERROR_INVALIDDATA;
131 1169 h->active_format_description = bytestream2_get_byteu(gb) & 0xF;
132 1169 h->present = 1;
133 }
134
135 1169 return 0;
136 }
137
138 6 static int decode_registered_user_data_closed_caption(H2645SEIA53Caption *h,
139 GetByteContext *gb)
140 {
141 6 return ff_parse_a53_cc(&h->buf_ref, gb->buffer,
142 bytestream2_get_bytes_left(gb));
143 }
144
145 1189 static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb,
146 enum AVCodecID codec_id, void *logctx)
147 {
148 int country_code, provider_code;
149
150
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1189 times.
1189 if (bytestream2_get_bytes_left(gb) < 3)
151 return AVERROR_INVALIDDATA;
152
153 1189 country_code = bytestream2_get_byteu(gb); // itu_t_t35_country_code
154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1189 times.
1189 if (country_code == 0xFF) {
155 if (bytestream2_get_bytes_left(gb) < 3)
156 return AVERROR_INVALIDDATA;
157
158 bytestream2_skipu(gb, 1); // itu_t_t35_country_code_extension_byte
159 }
160
161 /* itu_t_t35_payload_byte follows */
162 1189 provider_code = bytestream2_get_be16u(gb);
163
164
4/4
✓ Branch 0 taken 1186 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1175 times.
✓ Branch 3 taken 11 times.
1189 if (country_code == ITU_T_T35_COUNTRY_CODE_US && provider_code == ITU_T_T35_PROVIDER_CODE_ATSC) {
165 uint32_t user_identifier;
166
167
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1175 times.
1175 if (bytestream2_get_bytes_left(gb) < 4)
168 return AVERROR_INVALIDDATA;
169
170 1175 user_identifier = bytestream2_get_be32u(gb);
171
2/3
✓ Branch 0 taken 1169 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
1175 switch (user_identifier) {
172 1169 case MKBETAG('D', 'T', 'G', '1'): // afd_data
173 1169 return decode_registered_user_data_afd(&h->afd, gb);
174 6 case MKBETAG('G', 'A', '9', '4'): // closed captions
175 6 return decode_registered_user_data_closed_caption(&h->a53_caption, gb);
176 default:
177 av_log(logctx, AV_LOG_VERBOSE,
178 "Unsupported User Data Registered ITU-T T35 SEI message (atsc user_identifier = 0x%04x)\n",
179 user_identifier);
180 break;
181 }
182
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 } else if (country_code == ITU_T_T35_COUNTRY_CODE_UK && provider_code == ITU_T_T35_PROVIDER_CODE_VNOVA) {
183 if (bytestream2_get_bytes_left(gb) < 2)
184 return AVERROR_INVALIDDATA;
185
186 bytestream2_skipu(gb, 1); // user_data_type_code
187 return decode_registered_user_data_lcevc(&h->lcevc, gb);
188 }
189 #if CONFIG_HEVC_SEI
190
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
14 else if (country_code == ITU_T_T35_COUNTRY_CODE_CN && provider_code == ITU_T_T35_PROVIDER_CODE_HDR_VIVID) {
191 3 const uint16_t cuva_provider_oriented_code = 0x0005;
192 uint16_t provider_oriented_code;
193
194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!IS_HEVC(codec_id))
195 goto unsupported_provider_code;
196
197
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
3 if (bytestream2_get_bytes_left(gb) < 2)
198 return AVERROR_INVALIDDATA;
199
200 3 provider_oriented_code = bytestream2_get_be16u(gb);
201
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (provider_oriented_code == cuva_provider_oriented_code) {
202 3 return decode_registered_user_data_dynamic_hdr_vivid(&h->dynamic_hdr_vivid, gb);
203 }
204
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 } else if(country_code == ITU_T_T35_COUNTRY_CODE_US && provider_code == ITU_T_T35_PROVIDER_CODE_SAMSUNG) {
205 // A/341 Amendment - 2094-40
206 11 const uint16_t smpte2094_40_provider_oriented_code = 0x0001;
207 11 const uint8_t smpte2094_40_application_identifier = 0x04;
208 uint16_t provider_oriented_code;
209 uint8_t application_identifier;
210
211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!IS_HEVC(codec_id))
212 goto unsupported_provider_code;
213
214
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
11 if (bytestream2_get_bytes_left(gb) < 3)
215 return AVERROR_INVALIDDATA;
216
217 11 provider_oriented_code = bytestream2_get_be16u(gb);
218 11 application_identifier = bytestream2_get_byteu(gb);
219
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 if (provider_oriented_code == smpte2094_40_provider_oriented_code &&
220 application_identifier == smpte2094_40_application_identifier) {
221 11 return decode_registered_user_data_dynamic_hdr_plus(&h->dynamic_hdr_plus, gb);
222 }
223 } else if (country_code == ITU_T_T35_COUNTRY_CODE_US && provider_code == ITU_T_T35_PROVIDER_CODE_AOM) {
224 const uint16_t aom_grain_provider_oriented_code = 0x0001;
225 uint16_t provider_oriented_code;
226
227 if (!IS_HEVC(codec_id))
228 goto unsupported_provider_code;
229
230 if (bytestream2_get_bytes_left(gb) < 2)
231 return AVERROR_INVALIDDATA;
232
233 provider_oriented_code = bytestream2_get_byteu(gb);
234 if (provider_oriented_code == aom_grain_provider_oriented_code) {
235 return ff_aom_parse_film_grain_sets(&h->aom_film_grain,
236 gb->buffer,
237 bytestream2_get_bytes_left(gb));
238 }
239 }
240 #endif
241 else {
242 unsupported_provider_code:
243 av_log(logctx, AV_LOG_VERBOSE,
244 "Unsupported User Data Registered ITU-T T35 SEI message (country_code = %d, provider_code = %d)\n",
245 country_code, provider_code);
246 }
247
248 return 0;
249 }
250
251 625 static int decode_unregistered_user_data(H2645SEIUnregistered *h,
252 GetByteContext *gb,
253 enum AVCodecID codec_id)
254 {
255 uint8_t *user_data;
256 625 int size = bytestream2_get_bytes_left(gb);
257 AVBufferRef *buf_ref, **tmp;
258
259
2/4
✓ Branch 0 taken 625 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 625 times.
625 if (size < 16 || size >= INT_MAX - 1)
260 return AVERROR_INVALIDDATA;
261
262 625 tmp = av_realloc_array(h->buf_ref, h->nb_buf_ref + 1, sizeof(*h->buf_ref));
263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625 times.
625 if (!tmp)
264 return AVERROR(ENOMEM);
265 625 h->buf_ref = tmp;
266
267 625 buf_ref = av_buffer_alloc(size + 1);
268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625 times.
625 if (!buf_ref)
269 return AVERROR(ENOMEM);
270 625 user_data = buf_ref->data;
271
272 625 bytestream2_get_bufferu(gb, user_data, size);
273 625 user_data[size] = 0;
274 625 buf_ref->size = size;
275 625 h->buf_ref[h->nb_buf_ref++] = buf_ref;
276
277
2/2
✓ Branch 0 taken 591 times.
✓ Branch 1 taken 34 times.
625 if (IS_H264(codec_id)) {
278 int e, build;
279 591 e = sscanf(user_data + 16, "x264 - core %d", &build);
280
4/4
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 430 times.
✓ Branch 2 taken 158 times.
✓ Branch 3 taken 3 times.
591 if (e == 1 && build > 0)
281 158 h->x264_build = build;
282
3/6
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 430 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 161 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
591 if (e == 1 && build == 1 && !strncmp(user_data+16, "x264 - core 0000", 16))
283 h->x264_build = 67;
284 }
285
286 625 return 0;
287 }
288
289 2 static int decode_display_orientation(H2645SEIDisplayOrientation *h,
290 GetBitContext *gb)
291 {
292 2 h->present = !get_bits1(gb); // display_orientation_cancel_flag
293
294
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if (h->present) {
295 2 h->hflip = get_bits1(gb); // hor_flip
296 2 h->vflip = get_bits1(gb); // ver_flip
297
298 2 h->anticlockwise_rotation = get_bits(gb, 16);
299 // This is followed by display_orientation_repetition_period
300 // and display_orientation_extension_flag for H.264
301 // and by display_orientation_persistence_flag for HEVC.
302 }
303
304 2 return 0;
305 }
306
307 static int decode_frame_packing_arrangement(H2645SEIFramePacking *h,
308 GetBitContext *gb,
309 enum AVCodecID codec_id)
310 {
311 h->arrangement_id = get_ue_golomb_long(gb);
312 h->arrangement_cancel_flag = get_bits1(gb);
313 h->present = !h->arrangement_cancel_flag;
314
315 if (h->present) {
316 h->arrangement_type = get_bits(gb, 7);
317 h->quincunx_sampling_flag = get_bits1(gb);
318 h->content_interpretation_type = get_bits(gb, 6);
319
320 // spatial_flipping_flag, frame0_flipped_flag, field_views_flag
321 skip_bits(gb, 3);
322 h->current_frame_is_frame0_flag = get_bits1(gb);
323 // frame0_self_contained_flag, frame1_self_contained_flag
324 skip_bits(gb, 2);
325
326 if (!h->quincunx_sampling_flag && h->arrangement_type != 5)
327 skip_bits(gb, 16); // frame[01]_grid_position_[xy]
328 skip_bits(gb, 8); // frame_packing_arrangement_reserved_byte
329 if (IS_H264(codec_id))
330 h->arrangement_repetition_period = get_ue_golomb_long(gb);
331 else
332 skip_bits1(gb); // frame_packing_arrangement_persistence_flag
333 }
334 // H.264: frame_packing_arrangement_extension_flag,
335 // HEVC: upsampled_aspect_ratio_flag
336 skip_bits1(gb);
337
338 return 0;
339 }
340
341 static int decode_alternative_transfer(H2645SEIAlternativeTransfer *s,
342 GetByteContext *gb)
343 {
344 if (bytestream2_get_bytes_left(gb) < 1)
345 return AVERROR_INVALIDDATA;
346
347 s->present = 1;
348 s->preferred_transfer_characteristics = bytestream2_get_byteu(gb);
349
350 return 0;
351 }
352
353 9 static int decode_ambient_viewing_environment(H2645SEIAmbientViewingEnvironment *s,
354 GetByteContext *gb)
355 {
356 static const uint16_t max_ambient_light_value = 50000;
357
358
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
9 if (bytestream2_get_bytes_left(gb) < 8)
359 return AVERROR_INVALIDDATA;
360
361 9 s->ambient_illuminance = bytestream2_get_be32u(gb);
362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (!s->ambient_illuminance)
363 return AVERROR_INVALIDDATA;
364
365 9 s->ambient_light_x = bytestream2_get_be16u(gb);
366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (s->ambient_light_x > max_ambient_light_value)
367 return AVERROR_INVALIDDATA;
368
369 9 s->ambient_light_y = bytestream2_get_be16u(gb);
370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (s->ambient_light_y > max_ambient_light_value)
371 return AVERROR_INVALIDDATA;
372
373 9 s->present = 1;
374
375 9 return 0;
376 }
377
378 static int decode_film_grain_characteristics(H2645SEIFilmGrainCharacteristics *h,
379 enum AVCodecID codec_id, GetBitContext *gb)
380 {
381 h->present = !get_bits1(gb); // film_grain_characteristics_cancel_flag
382
383 if (h->present) {
384 memset(h, 0, sizeof(*h));
385 h->model_id = get_bits(gb, 2);
386 h->separate_colour_description_present_flag = get_bits1(gb);
387 if (h->separate_colour_description_present_flag) {
388 h->bit_depth_luma = get_bits(gb, 3) + 8;
389 h->bit_depth_chroma = get_bits(gb, 3) + 8;
390 h->full_range = get_bits1(gb);
391 h->color_primaries = get_bits(gb, 8);
392 h->transfer_characteristics = get_bits(gb, 8);
393 h->matrix_coeffs = get_bits(gb, 8);
394 }
395 h->blending_mode_id = get_bits(gb, 2);
396 h->log2_scale_factor = get_bits(gb, 4);
397 for (int c = 0; c < 3; c++)
398 h->comp_model_present_flag[c] = get_bits1(gb);
399 for (int c = 0; c < 3; c++) {
400 if (h->comp_model_present_flag[c]) {
401 h->num_intensity_intervals[c] = get_bits(gb, 8) + 1;
402 h->num_model_values[c] = get_bits(gb, 3) + 1;
403 if (h->num_model_values[c] > 6)
404 return AVERROR_INVALIDDATA;
405 for (int i = 0; i < h->num_intensity_intervals[c]; i++) {
406 h->intensity_interval_lower_bound[c][i] = get_bits(gb, 8);
407 h->intensity_interval_upper_bound[c][i] = get_bits(gb, 8);
408 for (int j = 0; j < h->num_model_values[c]; j++)
409 h->comp_model_value[c][i][j] = get_se_golomb_long(gb);
410 }
411 }
412 }
413 if (!IS_H264(codec_id))
414 h->persistence_flag = get_bits1(gb);
415 else
416 h->repetition_period = get_ue_golomb_long(gb);
417
418 h->present = 1;
419 }
420
421 return 0;
422 }
423
424 23 static int decode_nal_sei_mastering_display_info(H2645SEIMasteringDisplay *s,
425 GetByteContext *gb)
426 {
427 int i;
428
429
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
23 if (bytestream2_get_bytes_left(gb) < 24)
430 return AVERROR_INVALIDDATA;
431
432 // Mastering primaries
433
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 23 times.
92 for (i = 0; i < 3; i++) {
434 69 s->display_primaries[i][0] = bytestream2_get_be16u(gb);
435 69 s->display_primaries[i][1] = bytestream2_get_be16u(gb);
436 }
437 // White point (x, y)
438 23 s->white_point[0] = bytestream2_get_be16u(gb);
439 23 s->white_point[1] = bytestream2_get_be16u(gb);
440
441 // Max and min luminance of mastering display
442 23 s->max_luminance = bytestream2_get_be32u(gb);
443 23 s->min_luminance = bytestream2_get_be32u(gb);
444
445 // As this SEI message comes before the first frame that references it,
446 // initialize the flag to 2 and decrement on IRAP access unit so it
447 // persists for the coded video sequence (e.g., between two IRAPs)
448 23 s->present = 2;
449
450 23 return 0;
451 }
452
453 14 static int decode_nal_sei_content_light_info(H2645SEIContentLight *s,
454 GetByteContext *gb)
455 {
456
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
14 if (bytestream2_get_bytes_left(gb) < 4)
457 return AVERROR_INVALIDDATA;
458
459 // Max and average light levels
460 14 s->max_content_light_level = bytestream2_get_be16u(gb);
461 14 s->max_pic_average_light_level = bytestream2_get_be16u(gb);
462 // As this SEI message comes before the first frame that references it,
463 // initialize the flag to 2 and decrement on IRAP access unit so it
464 // persists for the coded video sequence (e.g., between two IRAPs)
465 14 s->present = 2;
466
467 14 return 0;
468 }
469
470 2245 int ff_h2645_sei_message_decode(H2645SEI *h, enum SEIType type,
471 enum AVCodecID codec_id, GetBitContext *gb,
472 GetByteContext *gbyte, void *logctx)
473 {
474
7/10
✓ Branch 0 taken 1189 times.
✓ Branch 1 taken 625 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 23 times.
✓ Branch 8 taken 14 times.
✓ Branch 9 taken 383 times.
2245 switch (type) {
475 1189 case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
476 1189 return decode_registered_user_data(h, gbyte, codec_id, logctx);
477 625 case SEI_TYPE_USER_DATA_UNREGISTERED:
478 625 return decode_unregistered_user_data(&h->unregistered, gbyte, codec_id);
479 2 case SEI_TYPE_DISPLAY_ORIENTATION:
480 2 return decode_display_orientation(&h->display_orientation, gb);
481 case SEI_TYPE_FILM_GRAIN_CHARACTERISTICS:
482 av_refstruct_unref(&h->film_grain_characteristics);
483 h->film_grain_characteristics = av_refstruct_allocz(sizeof(*h->film_grain_characteristics));
484 if (!h->film_grain_characteristics)
485 return AVERROR(ENOMEM);
486 return decode_film_grain_characteristics(h->film_grain_characteristics, codec_id, gb);
487 case SEI_TYPE_FRAME_PACKING_ARRANGEMENT:
488 return decode_frame_packing_arrangement(&h->frame_packing, gb, codec_id);
489 case SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS:
490 return decode_alternative_transfer(&h->alternative_transfer, gbyte);
491 9 case SEI_TYPE_AMBIENT_VIEWING_ENVIRONMENT:
492 9 return decode_ambient_viewing_environment(&h->ambient_viewing_environment,
493 gbyte);
494 23 case SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME:
495 23 return decode_nal_sei_mastering_display_info(&h->mastering_display,
496 gbyte);
497 14 case SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
498 14 return decode_nal_sei_content_light_info(&h->content_light, gbyte);
499 383 default:
500 383 return FF_H2645_SEI_MESSAGE_UNHANDLED;
501 }
502 }
503
504 1062 int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src)
505 {
506 1062 int ret = av_buffer_replace(&dst->a53_caption.buf_ref,
507 1062 src->a53_caption.buf_ref);
508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1062 times.
1062 if (ret < 0)
509 return ret;
510
511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1062 times.
1062 for (unsigned i = 0; i < dst->unregistered.nb_buf_ref; i++)
512 av_buffer_unref(&dst->unregistered.buf_ref[i]);
513 1062 dst->unregistered.nb_buf_ref = 0;
514
515 1062 ret = av_buffer_replace(&dst->lcevc.info, src->lcevc.info);
516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1062 times.
1062 if (ret < 0)
517 return ret;
518
519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1062 times.
1062 if (src->unregistered.nb_buf_ref) {
520 ret = av_reallocp_array(&dst->unregistered.buf_ref,
521 src->unregistered.nb_buf_ref,
522 sizeof(*dst->unregistered.buf_ref));
523 if (ret < 0)
524 return ret;
525
526 for (unsigned i = 0; i < src->unregistered.nb_buf_ref; i++) {
527 dst->unregistered.buf_ref[i] = av_buffer_ref(src->unregistered.buf_ref[i]);
528 if (!dst->unregistered.buf_ref[i])
529 return AVERROR(ENOMEM);
530 dst->unregistered.nb_buf_ref++;
531 }
532 }
533
534
2/2
✓ Branch 0 taken 8496 times.
✓ Branch 1 taken 1062 times.
9558 for (unsigned i = 0; i < FF_ARRAY_ELEMS(dst->aom_film_grain.sets); i++) {
535 8496 ret = av_buffer_replace(&dst->aom_film_grain.sets[i],
536 8496 src->aom_film_grain.sets[i]);
537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8496 times.
8496 if (ret < 0)
538 return ret;
539 }
540 1062 dst->aom_film_grain.enable = src->aom_film_grain.enable;
541
542 1062 dst->mastering_display = src->mastering_display;
543 1062 dst->content_light = src->content_light;
544
545 1062 av_refstruct_replace(&dst->film_grain_characteristics,
546 1062 src->film_grain_characteristics);
547
548 1062 return 0;
549 }
550
551 static int is_frame_packing_type_valid(SEIFpaType type, enum AVCodecID codec_id)
552 {
553 if (IS_H264(codec_id))
554 return type <= SEI_FPA_H264_TYPE_2D &&
555 type >= SEI_FPA_H264_TYPE_CHECKERBOARD;
556 else
557 return type <= SEI_FPA_TYPE_INTERLEAVE_TEMPORAL &&
558 type >= SEI_FPA_TYPE_SIDE_BY_SIDE;
559 }
560
561 36614 static int h2645_sei_to_side_data(AVCodecContext *avctx, H2645SEI *sei,
562 AVFrameSideData ***sd, int *nb_sd)
563 {
564 int ret;
565
566
2/2
✓ Branch 0 taken 313 times.
✓ Branch 1 taken 36614 times.
36927 for (unsigned i = 0; i < sei->unregistered.nb_buf_ref; i++) {
567 313 H2645SEIUnregistered *unreg = &sei->unregistered;
568
569
1/2
✓ Branch 0 taken 313 times.
✗ Branch 1 not taken.
313 if (unreg->buf_ref[i]) {
570 AVFrameSideData *entry =
571 313 av_frame_side_data_add(sd, nb_sd, AV_FRAME_DATA_SEI_UNREGISTERED,
572 313 &unreg->buf_ref[i], 0);
573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 313 times.
313 if (!entry)
574 av_buffer_unref(&unreg->buf_ref[i]);
575 }
576 }
577 36614 sei->unregistered.nb_buf_ref = 0;
578
579
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 36604 times.
36614 if (sei->ambient_viewing_environment.present) {
580 10 H2645SEIAmbientViewingEnvironment *env = &sei->ambient_viewing_environment;
581 AVBufferRef *buf;
582 size_t size;
583
584 AVAmbientViewingEnvironment *dst_env =
585 10 av_ambient_viewing_environment_alloc(&size);
586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (!dst_env)
587 return AVERROR(ENOMEM);
588
589 10 buf = av_buffer_create((uint8_t *)dst_env, size, NULL, NULL, 0);
590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (!buf) {
591 av_free(dst_env);
592 return AVERROR(ENOMEM);
593 }
594
595 10 ret = ff_frame_new_side_data_from_buf_ext(avctx, sd, nb_sd,
596 AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT, &buf);
597
598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (ret < 0)
599 return ret;
600
601 10 dst_env->ambient_illuminance = av_make_q(env->ambient_illuminance, 10000);
602 10 dst_env->ambient_light_x = av_make_q(env->ambient_light_x, 50000);
603 10 dst_env->ambient_light_y = av_make_q(env->ambient_light_y, 50000);
604 }
605
606
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 36579 times.
36614 if (sei->mastering_display.present) {
607 // HEVC uses a g,b,r ordering, which we convert to a more natural r,g,b
608 35 const int mapping[3] = {2, 0, 1};
609 35 const int chroma_den = 50000;
610 35 const int luma_den = 10000;
611 int i;
612 AVMasteringDisplayMetadata *metadata;
613
614 35 ret = ff_decode_mastering_display_new_ext(avctx, sd, nb_sd, &metadata);
615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if (ret < 0)
616 return ret;
617
618
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 10 times.
35 if (metadata) {
619 25 metadata->has_luminance = 1;
620 25 metadata->has_primaries = 1;
621
622
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 25 times.
100 for (i = 0; i < 3; i++) {
623 75 const int j = mapping[i];
624 75 metadata->display_primaries[i][0].num = sei->mastering_display.display_primaries[j][0];
625 75 metadata->display_primaries[i][0].den = chroma_den;
626
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
150 metadata->has_primaries &= sei->mastering_display.display_primaries[j][0] >= 5 &&
627
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 sei->mastering_display.display_primaries[j][0] <= 37000;
628
629 75 metadata->display_primaries[i][1].num = sei->mastering_display.display_primaries[j][1];
630 75 metadata->display_primaries[i][1].den = chroma_den;
631
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
150 metadata->has_primaries &= sei->mastering_display.display_primaries[j][1] >= 5 &&
632
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 sei->mastering_display.display_primaries[j][1] <= 42000;
633 }
634 25 metadata->white_point[0].num = sei->mastering_display.white_point[0];
635 25 metadata->white_point[0].den = chroma_den;
636
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
50 metadata->has_primaries &= sei->mastering_display.white_point[0] >= 5 &&
637
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 sei->mastering_display.white_point[0] <= 37000;
638
639 25 metadata->white_point[1].num = sei->mastering_display.white_point[1];
640 25 metadata->white_point[1].den = chroma_den;
641
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
50 metadata->has_primaries &= sei->mastering_display.white_point[1] >= 5 &&
642
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 sei->mastering_display.white_point[1] <= 42000;
643
644 25 metadata->max_luminance.num = sei->mastering_display.max_luminance;
645 25 metadata->max_luminance.den = luma_den;
646
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
50 metadata->has_luminance &= sei->mastering_display.max_luminance >= 50000 &&
647
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 sei->mastering_display.max_luminance <= 100000000;
648
649 25 metadata->min_luminance.num = sei->mastering_display.min_luminance;
650 25 metadata->min_luminance.den = luma_den;
651
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
50 metadata->has_luminance &= sei->mastering_display.min_luminance <= 50000 &&
652 25 sei->mastering_display.min_luminance <
653
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 sei->mastering_display.max_luminance;
654
655 /* Real (blu-ray) releases in the wild come with minimum luminance
656 * values of 0.000 cd/m2, so permit this edge case */
657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if (avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT)
658 metadata->has_luminance &= sei->mastering_display.min_luminance >= 1;
659
660
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
25 if (metadata->has_luminance || metadata->has_primaries)
661 25 av_log(avctx, AV_LOG_DEBUG, "Mastering Display Metadata:\n");
662
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if (metadata->has_primaries) {
663 25 av_log(avctx, AV_LOG_DEBUG,
664 "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f)\n",
665 25 av_q2d(metadata->display_primaries[0][0]),
666 25 av_q2d(metadata->display_primaries[0][1]),
667 25 av_q2d(metadata->display_primaries[1][0]),
668 25 av_q2d(metadata->display_primaries[1][1]),
669 25 av_q2d(metadata->display_primaries[2][0]),
670 25 av_q2d(metadata->display_primaries[2][1]),
671 25 av_q2d(metadata->white_point[0]), av_q2d(metadata->white_point[1]));
672 }
673
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1 times.
25 if (metadata->has_luminance) {
674 24 av_log(avctx, AV_LOG_DEBUG,
675 "min_luminance=%f, max_luminance=%f\n",
676 24 av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance));
677 }
678 }
679 }
680
681
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 36606 times.
36614 if (sei->content_light.present) {
682 AVContentLightMetadata *metadata;
683
684 8 ret = ff_decode_content_light_new_ext(avctx, sd, nb_sd, &metadata);
685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (ret < 0)
686 return ret;
687
688
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if (metadata) {
689 8 metadata->MaxCLL = sei->content_light.max_content_light_level;
690 8 metadata->MaxFALL = sei->content_light.max_pic_average_light_level;
691
692 8 av_log(avctx, AV_LOG_DEBUG, "Content Light Level Metadata:\n");
693 8 av_log(avctx, AV_LOG_DEBUG, "MaxCLL=%d, MaxFALL=%d\n",
694 8 metadata->MaxCLL, metadata->MaxFALL);
695 }
696 }
697
698 36614 return 0;
699 }
700
701 36342 int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei,
702 enum AVCodecID codec_id,
703 AVCodecContext *avctx, const H2645VUI *vui,
704 unsigned bit_depth_luma, unsigned bit_depth_chroma,
705 int seed)
706 {
707 36342 H2645SEIFramePacking *fp = &sei->frame_packing;
708 int ret;
709
710
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36342 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36342 if (fp->present &&
711 is_frame_packing_type_valid(fp->arrangement_type, codec_id) &&
712 fp->content_interpretation_type > 0 &&
713 fp->content_interpretation_type < 3) {
714 AVStereo3D *stereo = av_stereo3d_create_side_data(frame);
715
716 if (!stereo)
717 return AVERROR(ENOMEM);
718
719 switch (fp->arrangement_type) {
720 #if CONFIG_H264_SEI
721 case SEI_FPA_H264_TYPE_CHECKERBOARD:
722 stereo->type = AV_STEREO3D_CHECKERBOARD;
723 break;
724 case SEI_FPA_H264_TYPE_INTERLEAVE_COLUMN:
725 stereo->type = AV_STEREO3D_COLUMNS;
726 break;
727 case SEI_FPA_H264_TYPE_INTERLEAVE_ROW:
728 stereo->type = AV_STEREO3D_LINES;
729 break;
730 #endif
731 case SEI_FPA_TYPE_SIDE_BY_SIDE:
732 if (fp->quincunx_sampling_flag)
733 stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
734 else
735 stereo->type = AV_STEREO3D_SIDEBYSIDE;
736 break;
737 case SEI_FPA_TYPE_TOP_BOTTOM:
738 stereo->type = AV_STEREO3D_TOPBOTTOM;
739 break;
740 case SEI_FPA_TYPE_INTERLEAVE_TEMPORAL:
741 stereo->type = AV_STEREO3D_FRAMESEQUENCE;
742 break;
743 #if CONFIG_H264_SEI
744 case SEI_FPA_H264_TYPE_2D:
745 stereo->type = AV_STEREO3D_2D;
746 break;
747 #endif
748 }
749
750 if (fp->content_interpretation_type == 2)
751 stereo->flags = AV_STEREO3D_FLAG_INVERT;
752
753 if (fp->arrangement_type == SEI_FPA_TYPE_INTERLEAVE_TEMPORAL) {
754 if (fp->current_frame_is_frame0_flag)
755 stereo->view = AV_STEREO3D_VIEW_LEFT;
756 else
757 stereo->view = AV_STEREO3D_VIEW_RIGHT;
758 }
759 }
760
761
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 36341 times.
36342 if (sei->display_orientation.present &&
762
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 (sei->display_orientation.anticlockwise_rotation ||
763
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 sei->display_orientation.hflip ||
764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 sei->display_orientation.vflip)) {
765 H2645SEIDisplayOrientation *o = &sei->display_orientation;
766 double angle = o->anticlockwise_rotation * 360 / (double) (1 << 16);
767 AVFrameSideData *rotation = av_frame_new_side_data(frame,
768 AV_FRAME_DATA_DISPLAYMATRIX,
769 sizeof(int32_t) * 9);
770 if (!rotation)
771 return AVERROR(ENOMEM);
772
773 /* av_display_rotation_set() expects the angle in the clockwise
774 * direction, hence the first minus.
775 * The below code applies the flips after the rotation, yet
776 * the H.2645 specs require flipping to be applied first.
777 * Because of R O(phi) = O(-phi) R (where R is flipping around
778 * an arbitatry axis and O(phi) is the proper rotation by phi)
779 * we can create display matrices as desired by negating
780 * the degree once for every flip applied. */
781 angle = -angle * (1 - 2 * !!o->hflip) * (1 - 2 * !!o->vflip);
782 av_display_rotation_set((int32_t *)rotation->data, angle);
783 av_display_matrix_flip((int32_t *)rotation->data,
784 o->hflip, o->vflip);
785 }
786
787
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 36341 times.
36342 if (sei->a53_caption.buf_ref) {
788 1 H2645SEIA53Caption *a53 = &sei->a53_caption;
789 1 AVFrameSideData *sd = av_frame_new_side_data_from_buf(frame, AV_FRAME_DATA_A53_CC, a53->buf_ref);
790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!sd)
791 av_buffer_unref(&a53->buf_ref);
792 1 a53->buf_ref = NULL;
793 #if FF_API_CODEC_PROPS
794 FF_DISABLE_DEPRECATION_WARNINGS
795 1 avctx->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS;
796 FF_ENABLE_DEPRECATION_WARNINGS
797 #endif
798 }
799
800 36342 ret = h2645_sei_to_side_data(avctx, sei, &frame->side_data, &frame->nb_side_data);
801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36342 times.
36342 if (ret < 0)
802 return ret;
803
804
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 36018 times.
36342 if (sei->afd.present) {
805 324 AVFrameSideData *sd = av_frame_new_side_data(frame, AV_FRAME_DATA_AFD,
806 sizeof(uint8_t));
807
808
1/2
✓ Branch 0 taken 324 times.
✗ Branch 1 not taken.
324 if (sd) {
809 324 *sd->data = sei->afd.active_format_description;
810 324 sei->afd.present = 0;
811 }
812 }
813
814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36342 times.
36342 if (sei->lcevc.info) {
815 HEVCSEILCEVC *lcevc = &sei->lcevc;
816 ret = ff_frame_new_side_data_from_buf(avctx, frame, AV_FRAME_DATA_LCEVC, &lcevc->info);
817 if (ret < 0)
818 return ret;
819 }
820
821
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36342 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36342 if (sei->film_grain_characteristics && sei->film_grain_characteristics->present) {
822 H2645SEIFilmGrainCharacteristics *fgc = sei->film_grain_characteristics;
823 AVFilmGrainParams *fgp = av_film_grain_params_create_side_data(frame);
824 AVFilmGrainH274Params *h274;
825
826 if (!fgp)
827 return AVERROR(ENOMEM);
828
829 fgp->type = AV_FILM_GRAIN_PARAMS_H274;
830 h274 = &fgp->codec.h274;
831
832 fgp->seed = seed;
833 fgp->width = frame->width;
834 fgp->height = frame->height;
835
836 /* H.274 mandates film grain be applied to 4:4:4 frames */
837 fgp->subsampling_x = fgp->subsampling_y = 0;
838
839 h274->model_id = fgc->model_id;
840 if (IS_VVC(codec_id) || fgc->separate_colour_description_present_flag) {
841 fgp->bit_depth_luma = fgc->bit_depth_luma;
842 fgp->bit_depth_chroma = fgc->bit_depth_chroma;
843 fgp->color_range = fgc->full_range + 1;
844 fgp->color_primaries = fgc->color_primaries;
845 fgp->color_trc = fgc->transfer_characteristics;
846 fgp->color_space = fgc->matrix_coeffs;
847 } else {
848 fgp->bit_depth_luma = bit_depth_luma;
849 fgp->bit_depth_chroma = bit_depth_chroma;
850 if (vui->video_signal_type_present_flag)
851 fgp->color_range = vui->video_full_range_flag + 1;
852 if (vui->colour_description_present_flag) {
853 fgp->color_primaries = vui->colour_primaries;
854 fgp->color_trc = vui->transfer_characteristics;
855 fgp->color_space = vui->matrix_coeffs;
856 }
857 }
858 h274->blending_mode_id = fgc->blending_mode_id;
859 h274->log2_scale_factor = fgc->log2_scale_factor;
860
861 memcpy(&h274->component_model_present, &fgc->comp_model_present_flag,
862 sizeof(h274->component_model_present));
863 memcpy(&h274->num_intensity_intervals, &fgc->num_intensity_intervals,
864 sizeof(h274->num_intensity_intervals));
865 memcpy(&h274->num_model_values, &fgc->num_model_values,
866 sizeof(h274->num_model_values));
867 memcpy(&h274->intensity_interval_lower_bound, &fgc->intensity_interval_lower_bound,
868 sizeof(h274->intensity_interval_lower_bound));
869 memcpy(&h274->intensity_interval_upper_bound, &fgc->intensity_interval_upper_bound,
870 sizeof(h274->intensity_interval_upper_bound));
871 memcpy(&h274->comp_model_value, &fgc->comp_model_value,
872 sizeof(h274->comp_model_value));
873
874 if (IS_H264(codec_id))
875 fgc->present = !!fgc->repetition_period;
876 else
877 fgc->present = fgc->persistence_flag;
878
879 #if FF_API_CODEC_PROPS
880 FF_DISABLE_DEPRECATION_WARNINGS
881 avctx->properties |= FF_CODEC_PROPERTY_FILM_GRAIN;
882 FF_ENABLE_DEPRECATION_WARNINGS
883 #endif
884 }
885
886 #if CONFIG_HEVC_SEI
887 36342 ret = ff_aom_attach_film_grain_sets(&sei->aom_film_grain, frame);
888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36342 times.
36342 if (ret < 0)
889 return ret;
890 #endif
891
892 36342 return 0;
893 }
894
895 272 int ff_h2645_sei_to_context(AVCodecContext *avctx, H2645SEI *sei)
896 {
897 272 return h2645_sei_to_side_data(avctx, sei, &avctx->decoded_side_data,
898 &avctx->nb_decoded_side_data);
899 }
900
901 75412 void ff_h2645_sei_reset(H2645SEI *s)
902 {
903 75412 av_buffer_unref(&s->a53_caption.buf_ref);
904
905
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 75412 times.
75724 for (unsigned i = 0; i < s->unregistered.nb_buf_ref; i++)
906 312 av_buffer_unref(&s->unregistered.buf_ref[i]);
907 75412 s->unregistered.nb_buf_ref = 0;
908 75412 av_freep(&s->unregistered.buf_ref);
909 75412 av_buffer_unref(&s->dynamic_hdr_plus.info);
910 75412 av_buffer_unref(&s->dynamic_hdr_vivid.info);
911 75412 av_buffer_unref(&s->lcevc.info);
912
913 75412 s->ambient_viewing_environment.present = 0;
914 75412 s->mastering_display.present = 0;
915 75412 s->content_light.present = 0;
916
917 75412 av_refstruct_unref(&s->film_grain_characteristics);
918 75412 ff_aom_uninit_film_grain_params(&s->aom_film_grain);
919 75412 }
920