FFmpeg coverage


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