FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/h2645_sei.c
Date: 2026-04-30 13:16:32
Exec Total Coverage
Lines: 291 536 54.3%
Functions: 17 21 81.0%
Branches: 125 303 41.3%

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