FFmpeg
h2645_sei.c
Go to the documentation of this file.
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 
29 #include "libavutil/display.h"
33 #include "libavutil/pixdesc.h"
34 #include "libavutil/stereo3d.h"
35 
36 #include "atsc_a53.h"
37 #include "avcodec.h"
38 #include "decode.h"
39 #include "dynamic_hdr_vivid.h"
40 #include "get_bits.h"
41 #include "golomb.h"
42 #include "h2645_sei.h"
43 #include "itut35.h"
44 
45 #define IS_H264(codec_id) (CONFIG_H264_SEI && CONFIG_HEVC_SEI ? codec_id == AV_CODEC_ID_H264 : CONFIG_H264_SEI)
46 #define IS_HEVC(codec_id) (CONFIG_H264_SEI && CONFIG_HEVC_SEI ? codec_id == AV_CODEC_ID_HEVC : CONFIG_HEVC_SEI)
47 
48 #if CONFIG_HEVC_SEI
49 static int decode_registered_user_data_dynamic_hdr_plus(HEVCSEIDynamicHDRPlus *s,
50  GetByteContext *gb)
51 {
52  size_t meta_size;
53  int err;
54  AVDynamicHDRPlus *metadata = av_dynamic_hdr_plus_alloc(&meta_size);
55  if (!metadata)
56  return AVERROR(ENOMEM);
57 
58  err = av_dynamic_hdr_plus_from_t35(metadata, gb->buffer,
60  if (err < 0) {
61  av_free(metadata);
62  return err;
63  }
64 
65  av_buffer_unref(&s->info);
66  s->info = av_buffer_create((uint8_t *)metadata, meta_size, NULL, NULL, 0);
67  if (!s->info) {
68  av_free(metadata);
69  return AVERROR(ENOMEM);
70  }
71 
72  return 0;
73 }
74 
75 static int decode_registered_user_data_dynamic_hdr_vivid(HEVCSEIDynamicHDRVivid *s,
76  GetByteContext *gb)
77 {
78  size_t meta_size;
79  int err;
80  AVDynamicHDRVivid *metadata = av_dynamic_hdr_vivid_alloc(&meta_size);
81  if (!metadata)
82  return AVERROR(ENOMEM);
83 
86  if (err < 0) {
87  av_free(metadata);
88  return err;
89  }
90 
91  av_buffer_unref(&s->info);
92  s->info = av_buffer_create((uint8_t *)metadata, meta_size, NULL, NULL, 0);
93  if (!s->info) {
94  av_free(metadata);
95  return AVERROR(ENOMEM);
96  }
97 
98  return 0;
99 }
100 #endif
101 
103 {
104  int flag;
105 
106  if (bytestream2_get_bytes_left(gb) <= 0)
107  return AVERROR_INVALIDDATA;
108 
109  flag = !!(bytestream2_get_byteu(gb) & 0x40); // active_format_flag
110 
111  if (flag) {
112  if (bytestream2_get_bytes_left(gb) <= 0)
113  return AVERROR_INVALIDDATA;
114  h->active_format_description = bytestream2_get_byteu(gb) & 0xF;
115  h->present = 1;
116  }
117 
118  return 0;
119 }
120 
122  GetByteContext *gb)
123 {
124  return ff_parse_a53_cc(&h->buf_ref, gb->buffer,
126 }
127 
129  enum AVCodecID codec_id, void *logctx)
130 {
131  int country_code, provider_code;
132 
133  if (bytestream2_get_bytes_left(gb) < 3)
134  return AVERROR_INVALIDDATA;
135 
136  country_code = bytestream2_get_byteu(gb); // itu_t_t35_country_code
137  if (country_code == 0xFF) {
138  if (bytestream2_get_bytes_left(gb) < 3)
139  return AVERROR_INVALIDDATA;
140 
141  bytestream2_skipu(gb, 1); // itu_t_t35_country_code_extension_byte
142  }
143 
144  if (country_code != ITU_T_T35_COUNTRY_CODE_US &&
145  country_code != ITU_T_T35_COUNTRY_CODE_CN) {
146  av_log(logctx, AV_LOG_VERBOSE,
147  "Unsupported User Data Registered ITU-T T35 SEI message (country_code = %d)\n",
148  country_code);
149  return 0;
150  }
151 
152  /* itu_t_t35_payload_byte follows */
153  provider_code = bytestream2_get_be16u(gb);
154 
155  switch (provider_code) {
157  uint32_t user_identifier;
158 
159  if (bytestream2_get_bytes_left(gb) < 4)
160  return AVERROR_INVALIDDATA;
161 
162  user_identifier = bytestream2_get_be32u(gb);
163  switch (user_identifier) {
164  case MKBETAG('D', 'T', 'G', '1'): // afd_data
165  return decode_registered_user_data_afd(&h->afd, gb);
166  case MKBETAG('G', 'A', '9', '4'): // closed captions
167  return decode_registered_user_data_closed_caption(&h->a53_caption, gb);
168  default:
169  av_log(logctx, AV_LOG_VERBOSE,
170  "Unsupported User Data Registered ITU-T T35 SEI message (atsc user_identifier = 0x%04x)\n",
171  user_identifier);
172  break;
173  }
174  break;
175  }
176 #if CONFIG_HEVC_SEI
178  const uint16_t cuva_provider_oriented_code = 0x0005;
179  uint16_t provider_oriented_code;
180 
181  if (!IS_HEVC(codec_id))
182  goto unsupported_provider_code;
183 
184  if (bytestream2_get_bytes_left(gb) < 2)
185  return AVERROR_INVALIDDATA;
186 
187  provider_oriented_code = bytestream2_get_be16u(gb);
188  if (provider_oriented_code == cuva_provider_oriented_code) {
189  return decode_registered_user_data_dynamic_hdr_vivid(&h->dynamic_hdr_vivid, gb);
190  }
191  break;
192  }
194  // A/341 Amendment - 2094-40
195  const uint16_t smpte2094_40_provider_oriented_code = 0x0001;
196  const uint8_t smpte2094_40_application_identifier = 0x04;
197  uint16_t provider_oriented_code;
198  uint8_t application_identifier;
199 
200  if (!IS_HEVC(codec_id))
201  goto unsupported_provider_code;
202 
203  if (bytestream2_get_bytes_left(gb) < 3)
204  return AVERROR_INVALIDDATA;
205 
206  provider_oriented_code = bytestream2_get_be16u(gb);
207  application_identifier = bytestream2_get_byteu(gb);
208  if (provider_oriented_code == smpte2094_40_provider_oriented_code &&
209  application_identifier == smpte2094_40_application_identifier) {
210  return decode_registered_user_data_dynamic_hdr_plus(&h->dynamic_hdr_plus, gb);
211  }
212  break;
213  }
214  case 0x5890: { // aom_provider_code
215  const uint16_t aom_grain_provider_oriented_code = 0x0001;
216  uint16_t provider_oriented_code;
217 
218  if (!IS_HEVC(codec_id))
219  goto unsupported_provider_code;
220 
221  if (bytestream2_get_bytes_left(gb) < 2)
222  return AVERROR_INVALIDDATA;
223 
224  provider_oriented_code = bytestream2_get_byteu(gb);
225  if (provider_oriented_code == aom_grain_provider_oriented_code) {
226  return ff_aom_parse_film_grain_sets(&h->aom_film_grain,
227  gb->buffer,
229  }
230  break;
231  }
232  unsupported_provider_code:
233 #endif
234  default:
235  av_log(logctx, AV_LOG_VERBOSE,
236  "Unsupported User Data Registered ITU-T T35 SEI message (provider_code = %d)\n",
237  provider_code);
238  break;
239  }
240 
241  return 0;
242 }
243 
245  GetByteContext *gb,
246  enum AVCodecID codec_id)
247 {
248  uint8_t *user_data;
250  AVBufferRef *buf_ref, **tmp;
251 
252  if (size < 16 || size >= INT_MAX - 1)
253  return AVERROR_INVALIDDATA;
254 
255  tmp = av_realloc_array(h->buf_ref, h->nb_buf_ref + 1, sizeof(*h->buf_ref));
256  if (!tmp)
257  return AVERROR(ENOMEM);
258  h->buf_ref = tmp;
259 
260  buf_ref = av_buffer_alloc(size + 1);
261  if (!buf_ref)
262  return AVERROR(ENOMEM);
263  user_data = buf_ref->data;
264 
266  user_data[size] = 0;
267  buf_ref->size = size;
268  h->buf_ref[h->nb_buf_ref++] = buf_ref;
269 
270  if (IS_H264(codec_id)) {
271  int e, build;
272  e = sscanf(user_data + 16, "x264 - core %d", &build);
273  if (e == 1 && build > 0)
274  h->x264_build = build;
275  if (e == 1 && build == 1 && !strncmp(user_data+16, "x264 - core 0000", 16))
276  h->x264_build = 67;
277  }
278 
279  return 0;
280 }
281 
283  GetBitContext *gb)
284 {
285  h->present = !get_bits1(gb); // display_orientation_cancel_flag
286 
287  if (h->present) {
288  h->hflip = get_bits1(gb); // hor_flip
289  h->vflip = get_bits1(gb); // ver_flip
290 
291  h->anticlockwise_rotation = get_bits(gb, 16);
292  // This is followed by display_orientation_repetition_period
293  // and display_orientation_extension_flag for H.264
294  // and by display_orientation_persistence_flag for HEVC.
295  }
296 
297  return 0;
298 }
299 
301  GetBitContext *gb,
302  enum AVCodecID codec_id)
303 {
304  h->arrangement_id = get_ue_golomb_long(gb);
305  h->arrangement_cancel_flag = get_bits1(gb);
306  h->present = !h->arrangement_cancel_flag;
307 
308  if (h->present) {
309  h->arrangement_type = get_bits(gb, 7);
310  h->quincunx_sampling_flag = get_bits1(gb);
311  h->content_interpretation_type = get_bits(gb, 6);
312 
313  // spatial_flipping_flag, frame0_flipped_flag, field_views_flag
314  skip_bits(gb, 3);
315  h->current_frame_is_frame0_flag = get_bits1(gb);
316  // frame0_self_contained_flag, frame1_self_contained_flag
317  skip_bits(gb, 2);
318 
319  if (!h->quincunx_sampling_flag && h->arrangement_type != 5)
320  skip_bits(gb, 16); // frame[01]_grid_position_[xy]
321  skip_bits(gb, 8); // frame_packing_arrangement_reserved_byte
322  if (IS_H264(codec_id))
323  h->arrangement_repetition_period = get_ue_golomb_long(gb);
324  else
325  skip_bits1(gb); // frame_packing_arrangement_persistence_flag
326  }
327  // H.264: frame_packing_arrangement_extension_flag,
328  // HEVC: upsampled_aspect_ratio_flag
329  skip_bits1(gb);
330 
331  return 0;
332 }
333 
335  GetByteContext *gb)
336 {
337  if (bytestream2_get_bytes_left(gb) < 1)
338  return AVERROR_INVALIDDATA;
339 
340  s->present = 1;
341  s->preferred_transfer_characteristics = bytestream2_get_byteu(gb);
342 
343  return 0;
344 }
345 
347  GetByteContext *gb)
348 {
349  static const uint16_t max_ambient_light_value = 50000;
350 
351  if (bytestream2_get_bytes_left(gb) < 8)
352  return AVERROR_INVALIDDATA;
353 
354  s->ambient_illuminance = bytestream2_get_be32u(gb);
355  if (!s->ambient_illuminance)
356  return AVERROR_INVALIDDATA;
357 
358  s->ambient_light_x = bytestream2_get_be16u(gb);
359  if (s->ambient_light_x > max_ambient_light_value)
360  return AVERROR_INVALIDDATA;
361 
362  s->ambient_light_y = bytestream2_get_be16u(gb);
363  if (s->ambient_light_y > max_ambient_light_value)
364  return AVERROR_INVALIDDATA;
365 
366  s->present = 1;
367 
368  return 0;
369 }
370 
372  enum AVCodecID codec_id, GetBitContext *gb)
373 {
374  h->present = !get_bits1(gb); // film_grain_characteristics_cancel_flag
375 
376  if (h->present) {
377  memset(h, 0, sizeof(*h));
378  h->model_id = get_bits(gb, 2);
379  h->separate_colour_description_present_flag = get_bits1(gb);
380  if (h->separate_colour_description_present_flag) {
381  h->bit_depth_luma = get_bits(gb, 3) + 8;
382  h->bit_depth_chroma = get_bits(gb, 3) + 8;
383  h->full_range = get_bits1(gb);
384  h->color_primaries = get_bits(gb, 8);
385  h->transfer_characteristics = get_bits(gb, 8);
386  h->matrix_coeffs = get_bits(gb, 8);
387  }
388  h->blending_mode_id = get_bits(gb, 2);
389  h->log2_scale_factor = get_bits(gb, 4);
390  for (int c = 0; c < 3; c++)
391  h->comp_model_present_flag[c] = get_bits1(gb);
392  for (int c = 0; c < 3; c++) {
393  if (h->comp_model_present_flag[c]) {
394  h->num_intensity_intervals[c] = get_bits(gb, 8) + 1;
395  h->num_model_values[c] = get_bits(gb, 3) + 1;
396  if (h->num_model_values[c] > 6)
397  return AVERROR_INVALIDDATA;
398  for (int i = 0; i < h->num_intensity_intervals[c]; i++) {
399  h->intensity_interval_lower_bound[c][i] = get_bits(gb, 8);
400  h->intensity_interval_upper_bound[c][i] = get_bits(gb, 8);
401  for (int j = 0; j < h->num_model_values[c]; j++)
402  h->comp_model_value[c][i][j] = get_se_golomb_long(gb);
403  }
404  }
405  }
406  if (IS_HEVC(codec_id))
407  h->persistence_flag = get_bits1(gb);
408  else
409  h->repetition_period = get_ue_golomb_long(gb);
410 
411  h->present = 1;
412  }
413 
414  return 0;
415 }
416 
418  GetByteContext *gb)
419 {
420  int i;
421 
422  if (bytestream2_get_bytes_left(gb) < 24)
423  return AVERROR_INVALIDDATA;
424 
425  // Mastering primaries
426  for (i = 0; i < 3; i++) {
427  s->display_primaries[i][0] = bytestream2_get_be16u(gb);
428  s->display_primaries[i][1] = bytestream2_get_be16u(gb);
429  }
430  // White point (x, y)
431  s->white_point[0] = bytestream2_get_be16u(gb);
432  s->white_point[1] = bytestream2_get_be16u(gb);
433 
434  // Max and min luminance of mastering display
435  s->max_luminance = bytestream2_get_be32u(gb);
436  s->min_luminance = bytestream2_get_be32u(gb);
437 
438  // As this SEI message comes before the first frame that references it,
439  // initialize the flag to 2 and decrement on IRAP access unit so it
440  // persists for the coded video sequence (e.g., between two IRAPs)
441  s->present = 2;
442 
443  return 0;
444 }
445 
447  GetByteContext *gb)
448 {
449  if (bytestream2_get_bytes_left(gb) < 4)
450  return AVERROR_INVALIDDATA;
451 
452  // Max and average light levels
453  s->max_content_light_level = bytestream2_get_be16u(gb);
454  s->max_pic_average_light_level = bytestream2_get_be16u(gb);
455  // As this SEI message comes before the first frame that references it,
456  // initialize the flag to 2 and decrement on IRAP access unit so it
457  // persists for the coded video sequence (e.g., between two IRAPs)
458  s->present = 2;
459 
460  return 0;
461 }
462 
464  enum AVCodecID codec_id, GetBitContext *gb,
465  GetByteContext *gbyte, void *logctx)
466 {
467  switch (type) {
469  return decode_registered_user_data(h, gbyte, codec_id, logctx);
471  return decode_unregistered_user_data(&h->unregistered, gbyte, codec_id);
473  return decode_display_orientation(&h->display_orientation, gb);
475  return decode_film_grain_characteristics(&h->film_grain_characteristics, codec_id, gb);
477  return decode_frame_packing_arrangement(&h->frame_packing, gb, codec_id);
479  return decode_alternative_transfer(&h->alternative_transfer, gbyte);
481  return decode_ambient_viewing_environment(&h->ambient_viewing_environment,
482  gbyte);
484  return decode_nal_sei_mastering_display_info(&h->mastering_display,
485  gbyte);
487  return decode_nal_sei_content_light_info(&h->content_light, gbyte);
488  default:
490  }
491 }
492 
494 {
496  src->a53_caption.buf_ref);
497  if (ret < 0)
498  return ret;
499 
500  for (unsigned i = 0; i < dst->unregistered.nb_buf_ref; i++)
502  dst->unregistered.nb_buf_ref = 0;
503 
504  if (src->unregistered.nb_buf_ref) {
506  src->unregistered.nb_buf_ref,
507  sizeof(*dst->unregistered.buf_ref));
508  if (ret < 0)
509  return ret;
510 
511  for (unsigned i = 0; i < src->unregistered.nb_buf_ref; i++) {
512  dst->unregistered.buf_ref[i] = av_buffer_ref(src->unregistered.buf_ref[i]);
513  if (!dst->unregistered.buf_ref[i])
514  return AVERROR(ENOMEM);
515  dst->unregistered.nb_buf_ref++;
516  }
517  }
518 
519  return 0;
520 }
521 
523 {
524  if (IS_H264(codec_id))
525  return type <= SEI_FPA_H264_TYPE_2D &&
527  else
530 }
531 
533  enum AVCodecID codec_id,
534  AVCodecContext *avctx, const H2645VUI *vui,
535  unsigned bit_depth_luma, unsigned bit_depth_chroma,
536  int seed)
537 {
538  H2645SEIFramePacking *fp = &sei->frame_packing;
539  int ret;
540 
541  if (fp->present &&
542  is_frame_packing_type_valid(fp->arrangement_type, codec_id) &&
543  fp->content_interpretation_type > 0 &&
544  fp->content_interpretation_type < 3) {
546 
547  if (!stereo)
548  return AVERROR(ENOMEM);
549 
550  switch (fp->arrangement_type) {
551 #if CONFIG_H264_SEI
553  stereo->type = AV_STEREO3D_CHECKERBOARD;
554  break;
556  stereo->type = AV_STEREO3D_COLUMNS;
557  break;
559  stereo->type = AV_STEREO3D_LINES;
560  break;
561 #endif
563  if (fp->quincunx_sampling_flag)
565  else
566  stereo->type = AV_STEREO3D_SIDEBYSIDE;
567  break;
569  stereo->type = AV_STEREO3D_TOPBOTTOM;
570  break;
573  break;
574 #if CONFIG_H264_SEI
576  stereo->type = AV_STEREO3D_2D;
577  break;
578 #endif
579  }
580 
581  if (fp->content_interpretation_type == 2)
582  stereo->flags = AV_STEREO3D_FLAG_INVERT;
583 
584  if (fp->arrangement_type == SEI_FPA_TYPE_INTERLEAVE_TEMPORAL) {
585  if (fp->current_frame_is_frame0_flag)
586  stereo->view = AV_STEREO3D_VIEW_LEFT;
587  else
588  stereo->view = AV_STEREO3D_VIEW_RIGHT;
589  }
590  }
591 
592  if (sei->display_orientation.present &&
593  (sei->display_orientation.anticlockwise_rotation ||
594  sei->display_orientation.hflip ||
595  sei->display_orientation.vflip)) {
596  H2645SEIDisplayOrientation *o = &sei->display_orientation;
597  double angle = o->anticlockwise_rotation * 360 / (double) (1 << 16);
600  sizeof(int32_t) * 9);
601  if (!rotation)
602  return AVERROR(ENOMEM);
603 
604  /* av_display_rotation_set() expects the angle in the clockwise
605  * direction, hence the first minus.
606  * The below code applies the flips after the rotation, yet
607  * the H.2645 specs require flipping to be applied first.
608  * Because of R O(phi) = O(-phi) R (where R is flipping around
609  * an arbitatry axis and O(phi) is the proper rotation by phi)
610  * we can create display matrices as desired by negating
611  * the degree once for every flip applied. */
612  angle = -angle * (1 - 2 * !!o->hflip) * (1 - 2 * !!o->vflip);
613  av_display_rotation_set((int32_t *)rotation->data, angle);
614  av_display_matrix_flip((int32_t *)rotation->data,
615  o->hflip, o->vflip);
616  }
617 
618  if (sei->a53_caption.buf_ref) {
619  H2645SEIA53Caption *a53 = &sei->a53_caption;
621  if (!sd)
622  av_buffer_unref(&a53->buf_ref);
623  a53->buf_ref = NULL;
625  }
626 
627  for (unsigned i = 0; i < sei->unregistered.nb_buf_ref; i++) {
628  H2645SEIUnregistered *unreg = &sei->unregistered;
629 
630  if (unreg->buf_ref[i]) {
633  unreg->buf_ref[i]);
634  if (!sd)
635  av_buffer_unref(&unreg->buf_ref[i]);
636  unreg->buf_ref[i] = NULL;
637  }
638  }
639  sei->unregistered.nb_buf_ref = 0;
640 
641  if (sei->afd.present) {
643  sizeof(uint8_t));
644 
645  if (sd) {
646  *sd->data = sei->afd.active_format_description;
647  sei->afd.present = 0;
648  }
649  }
650 
651  if (sei->film_grain_characteristics.present) {
652  H2645SEIFilmGrainCharacteristics *fgc = &sei->film_grain_characteristics;
654  AVFilmGrainH274Params *h274;
655 
656  if (!fgp)
657  return AVERROR(ENOMEM);
658 
660  h274 = &fgp->codec.h274;
661 
662  fgp->seed = seed;
663  fgp->width = frame->width;
664  fgp->height = frame->height;
665 
666  /* H.274 mandates film grain be applied to 4:4:4 frames */
667  fgp->subsampling_x = fgp->subsampling_y = 0;
668 
669  h274->model_id = fgc->model_id;
671  fgp->bit_depth_luma = fgc->bit_depth_luma;
673  fgp->color_range = fgc->full_range + 1;
674  fgp->color_primaries = fgc->color_primaries;
676  fgp->color_space = fgc->matrix_coeffs;
677  } else {
678  fgp->bit_depth_luma = bit_depth_luma;
679  fgp->bit_depth_chroma = bit_depth_chroma;
681  fgp->color_range = vui->video_full_range_flag + 1;
683  fgp->color_primaries = vui->colour_primaries;
685  fgp->color_space = vui->matrix_coeffs;
686  }
687  }
688  h274->blending_mode_id = fgc->blending_mode_id;
690 
691 #if FF_API_H274_FILM_GRAIN_VCS
693  h274->bit_depth_luma = fgp->bit_depth_luma;
694  h274->bit_depth_chroma = fgp->bit_depth_chroma;
695  h274->color_range = fgp->color_range;
696  h274->color_primaries = fgp->color_primaries;
697  h274->color_trc = fgp->color_trc;
698  h274->color_space = fgp->color_space;
700 #endif
701 
703  sizeof(h274->component_model_present));
705  sizeof(h274->num_intensity_intervals));
706  memcpy(&h274->num_model_values, &fgc->num_model_values,
707  sizeof(h274->num_model_values));
709  sizeof(h274->intensity_interval_lower_bound));
711  sizeof(h274->intensity_interval_upper_bound));
712  memcpy(&h274->comp_model_value, &fgc->comp_model_value,
713  sizeof(h274->comp_model_value));
714 
715  if (IS_H264(codec_id))
716  fgc->present = !!fgc->repetition_period;
717  else
718  fgc->present = fgc->persistence_flag;
719 
721  }
722 
723 #if CONFIG_HEVC_SEI
724  ret = ff_aom_attach_film_grain_sets(&sei->aom_film_grain, frame);
725  if (ret < 0)
726  return ret;
727 #endif
728 
729  if (sei->ambient_viewing_environment.present) {
731  &sei->ambient_viewing_environment;
732 
733  AVAmbientViewingEnvironment *dst_env =
735  if (!dst_env)
736  return AVERROR(ENOMEM);
737 
738  dst_env->ambient_illuminance = av_make_q(env->ambient_illuminance, 10000);
739  dst_env->ambient_light_x = av_make_q(env->ambient_light_x, 50000);
740  dst_env->ambient_light_y = av_make_q(env->ambient_light_y, 50000);
741  }
742 
743  if (sei->mastering_display.present) {
744  // HEVC uses a g,b,r ordering, which we convert to a more natural r,g,b
745  const int mapping[3] = {2, 0, 1};
746  const int chroma_den = 50000;
747  const int luma_den = 10000;
748  int i;
749  AVMasteringDisplayMetadata *metadata;
750 
751  ret = ff_decode_mastering_display_new(avctx, frame, &metadata);
752  if (ret < 0)
753  return ret;
754 
755  if (metadata) {
756  for (i = 0; i < 3; i++) {
757  const int j = mapping[i];
758  metadata->display_primaries[i][0].num = sei->mastering_display.display_primaries[j][0];
759  metadata->display_primaries[i][0].den = chroma_den;
760  metadata->display_primaries[i][1].num = sei->mastering_display.display_primaries[j][1];
761  metadata->display_primaries[i][1].den = chroma_den;
762  }
763  metadata->white_point[0].num = sei->mastering_display.white_point[0];
764  metadata->white_point[0].den = chroma_den;
765  metadata->white_point[1].num = sei->mastering_display.white_point[1];
766  metadata->white_point[1].den = chroma_den;
767 
768  metadata->max_luminance.num = sei->mastering_display.max_luminance;
769  metadata->max_luminance.den = luma_den;
770  metadata->min_luminance.num = sei->mastering_display.min_luminance;
771  metadata->min_luminance.den = luma_den;
772  metadata->has_luminance = 1;
773  metadata->has_primaries = 1;
774 
775  av_log(avctx, AV_LOG_DEBUG, "Mastering Display Metadata:\n");
776  av_log(avctx, AV_LOG_DEBUG,
777  "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f)\n",
778  av_q2d(metadata->display_primaries[0][0]),
779  av_q2d(metadata->display_primaries[0][1]),
780  av_q2d(metadata->display_primaries[1][0]),
781  av_q2d(metadata->display_primaries[1][1]),
782  av_q2d(metadata->display_primaries[2][0]),
783  av_q2d(metadata->display_primaries[2][1]),
784  av_q2d(metadata->white_point[0]), av_q2d(metadata->white_point[1]));
785  av_log(avctx, AV_LOG_DEBUG,
786  "min_luminance=%f, max_luminance=%f\n",
787  av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance));
788  }
789  }
790 
791  if (sei->content_light.present) {
792  AVContentLightMetadata *metadata;
793 
794  ret = ff_decode_content_light_new(avctx, frame, &metadata);
795  if (ret < 0)
796  return ret;
797 
798  if (metadata) {
799  metadata->MaxCLL = sei->content_light.max_content_light_level;
800  metadata->MaxFALL = sei->content_light.max_pic_average_light_level;
801 
802  av_log(avctx, AV_LOG_DEBUG, "Content Light Level Metadata:\n");
803  av_log(avctx, AV_LOG_DEBUG, "MaxCLL=%d, MaxFALL=%d\n",
804  metadata->MaxCLL, metadata->MaxFALL);
805  }
806  }
807 
808  return 0;
809 }
810 
812 {
813  av_buffer_unref(&s->a53_caption.buf_ref);
814 
815  for (unsigned i = 0; i < s->unregistered.nb_buf_ref; i++)
816  av_buffer_unref(&s->unregistered.buf_ref[i]);
817  s->unregistered.nb_buf_ref = 0;
818  av_freep(&s->unregistered.buf_ref);
819  av_buffer_unref(&s->dynamic_hdr_plus.info);
820  av_buffer_unref(&s->dynamic_hdr_vivid.info);
821 
822  s->ambient_viewing_environment.present = 0;
823  s->mastering_display.present = 0;
824  s->content_light.present = 0;
825  s->aom_film_grain.enable = 0;
826 }
AVMasteringDisplayMetadata::has_primaries
int has_primaries
Flag indicating whether the display primaries (and white point) are set.
Definition: mastering_display_metadata.h:62
FF_ENABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:73
decode_film_grain_characteristics
static int decode_film_grain_characteristics(H2645SEIFilmGrainCharacteristics *h, enum AVCodecID codec_id, GetBitContext *gb)
Definition: h2645_sei.c:371
AVMasteringDisplayMetadata::max_luminance
AVRational max_luminance
Max luminance of mastering display (cd/m^2).
Definition: mastering_display_metadata.h:57
AV_STEREO3D_VIEW_LEFT
@ AV_STEREO3D_VIEW_LEFT
Frame contains only the left view.
Definition: stereo3d.h:153
H2645SEIFilmGrainCharacteristics::persistence_flag
int persistence_flag
Definition: h2645_sei.h:107
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AV_STEREO3D_SIDEBYSIDE_QUINCUNX
@ AV_STEREO3D_SIDEBYSIDE_QUINCUNX
Views are next to each other, but when upscaling apply a checkerboard pattern.
Definition: stereo3d.h:114
SEI_FPA_H264_TYPE_CHECKERBOARD
@ SEI_FPA_H264_TYPE_CHECKERBOARD
Definition: sei.h:148
SEI_FPA_TYPE_INTERLEAVE_TEMPORAL
@ SEI_FPA_TYPE_INTERLEAVE_TEMPORAL
Definition: sei.h:153
H2645SEIAmbientViewingEnvironment::ambient_light_x
uint16_t ambient_light_x
Definition: h2645_sei.h:84
AVFilmGrainParams::bit_depth_luma
int bit_depth_luma
Intended bit depth, or 0 for unknown/unspecified.
Definition: film_grain_params.h:287
H2645SEIFramePacking
Definition: h2645_sei.h:59
av_frame_new_side_data
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, size_t size)
Add a new side data to a frame.
Definition: frame.c:765
GetByteContext
Definition: bytestream.h:33
H2645SEIAFD
Definition: h2645_sei.h:40
AVFilmGrainH274Params::color_range
attribute_deprecated enum AVColorRange color_range
Specifies the video signal characteristics.
Definition: film_grain_params.h:167
AVAmbientViewingEnvironment
Ambient viewing environment metadata as defined by H.274.
Definition: ambient_viewing_environment.h:36
get_se_golomb_long
static int get_se_golomb_long(GetBitContext *gb)
Definition: golomb.h:294
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
H2645SEIFilmGrainCharacteristics::bit_depth_chroma
int bit_depth_chroma
Definition: h2645_sei.h:93
AV_FRAME_DATA_A53_CC
@ AV_FRAME_DATA_A53_CC
ATSC A53 Part 4 Closed Captions.
Definition: frame.h:59
ff_h2645_sei_to_frame
int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei, enum AVCodecID codec_id, AVCodecContext *avctx, const H2645VUI *vui, unsigned bit_depth_luma, unsigned bit_depth_chroma, int seed)
Definition: h2645_sei.c:532
AVMasteringDisplayMetadata::display_primaries
AVRational display_primaries[3][2]
CIE 1931 xy chromaticity coords of color primaries (r, g, b order).
Definition: mastering_display_metadata.h:42
AVMasteringDisplayMetadata::has_luminance
int has_luminance
Flag indicating whether the luminance (min_ and max_) have been set.
Definition: mastering_display_metadata.h:67
bytestream2_skipu
static av_always_inline void bytestream2_skipu(GetByteContext *g, unsigned int size)
Definition: bytestream.h:174
H2645VUI::matrix_coeffs
enum AVColorSpace matrix_coeffs
Definition: h2645_vui.h:41
AVFilmGrainH274Params::blending_mode_id
int blending_mode_id
Specifies the blending mode used to blend the simulated film grain with the decoded images.
Definition: film_grain_params.h:182
AVContentLightMetadata::MaxCLL
unsigned MaxCLL
Max content light level (cd/m^2).
Definition: mastering_display_metadata.h:102
H2645SEIA53Caption::buf_ref
AVBufferRef * buf_ref
Definition: h2645_sei.h:37
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
pixdesc.h
IS_H264
#define IS_H264(codec_id)
Definition: h2645_sei.c:45
AVFrame::width
int width
Definition: frame.h:416
H2645SEIA53Caption
Definition: h2645_sei.h:36
av_display_matrix_flip
void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip)
Flip the input matrix horizontally and/or vertically.
Definition: display.c:66
H2645SEIMasteringDisplay
Definition: h2645_sei.h:110
AVAmbientViewingEnvironment::ambient_light_x
AVRational ambient_light_x
Normalized x chromaticity coordinate of the environmental ambient light in the nominal viewing enviro...
Definition: ambient_viewing_environment.h:47
AVFilmGrainParams::color_space
enum AVColorSpace color_space
Definition: film_grain_params.h:282
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
av_display_rotation_set
void av_display_rotation_set(int32_t matrix[9], double angle)
Initialize a transformation matrix describing a pure clockwise rotation by the specified angle (in de...
Definition: display.c:51
AV_FRAME_DATA_DISPLAYMATRIX
@ AV_FRAME_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: frame.h:85
SEI_FPA_TYPE_TOP_BOTTOM
@ SEI_FPA_TYPE_TOP_BOTTOM
Definition: sei.h:152
H2645VUI::colour_primaries
enum AVColorPrimaries colour_primaries
Definition: h2645_vui.h:39
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
AV_STEREO3D_VIEW_RIGHT
@ AV_STEREO3D_VIEW_RIGHT
Frame contains only the right view.
Definition: stereo3d.h:158
AVFilmGrainParams::color_trc
enum AVColorTransferCharacteristic color_trc
Definition: film_grain_params.h:281
H2645VUI::video_full_range_flag
int video_full_range_flag
Definition: h2645_vui.h:37
AVFilmGrainParams::seed
uint64_t seed
Seed to use for the synthesis process, if the codec allows for it.
Definition: film_grain_params.h:250
H2645SEIDisplayOrientation
Definition: h2645_sei.h:70
H2645VUI::video_signal_type_present_flag
int video_signal_type_present_flag
Definition: h2645_vui.h:35
ff_h2645_sei_message_decode
int ff_h2645_sei_message_decode(H2645SEI *h, enum SEIType type, enum AVCodecID codec_id, GetBitContext *gb, GetByteContext *gbyte, void *logctx)
Decode a single SEI message.
Definition: h2645_sei.c:463
AVContentLightMetadata
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
Definition: mastering_display_metadata.h:98
skip_bits
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:381
golomb.h
exp golomb vlc stuff
AV_STEREO3D_SIDEBYSIDE
@ AV_STEREO3D_SIDEBYSIDE
Views are next to each other.
Definition: stereo3d.h:64
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:335
SEI_FPA_H264_TYPE_INTERLEAVE_COLUMN
@ SEI_FPA_H264_TYPE_INTERLEAVE_COLUMN
Definition: sei.h:149
ITU_T_T35_COUNTRY_CODE_CN
#define ITU_T_T35_COUNTRY_CODE_CN
Definition: itut35.h:22
H2645SEI::a53_caption
H2645SEIA53Caption a53_caption
Definition: h2645_sei.h:125
AV_STEREO3D_2D
@ AV_STEREO3D_2D
Video is not stereoscopic (and metadata has to be there).
Definition: stereo3d.h:52
H2645SEIFilmGrainCharacteristics::intensity_interval_upper_bound
uint8_t intensity_interval_upper_bound[3][256]
Definition: h2645_sei.h:104
GetBitContext
Definition: get_bits.h:108
AVFilmGrainH274Params::bit_depth_chroma
attribute_deprecated int bit_depth_chroma
Specifies the bit depth used for the chroma components.
Definition: film_grain_params.h:159
av_dynamic_hdr_vivid_alloc
AVDynamicHDRVivid * av_dynamic_hdr_vivid_alloc(size_t *size)
Copyright (c) 2021 Limin Wang <lance.lmwang at gmail.com>
Definition: hdr_dynamic_vivid_metadata.c:24
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
SEI_TYPE_AMBIENT_VIEWING_ENVIRONMENT
@ SEI_TYPE_AMBIENT_VIEWING_ENVIRONMENT
Definition: sei.h:107
AVAmbientViewingEnvironment::ambient_illuminance
AVRational ambient_illuminance
Environmental illuminance of the ambient viewing environment in lux.
Definition: ambient_viewing_environment.h:40
AVRational::num
int num
Numerator.
Definition: rational.h:59
ITU_T_T35_PROVIDER_CODE_ATSC
#define ITU_T_T35_PROVIDER_CODE_ATSC
Definition: itut35.h:25
AVFilmGrainH274Params::intensity_interval_upper_bound
uint8_t intensity_interval_upper_bound[3][256]
Specifies the upper bound of each intensity interval for which the set of model values applies for th...
Definition: film_grain_params.h:216
is_frame_packing_type_valid
static int is_frame_packing_type_valid(SEIFpaType type, enum AVCodecID codec_id)
Definition: h2645_sei.c:522
AVFilmGrainParams::bit_depth_chroma
int bit_depth_chroma
Definition: film_grain_params.h:288
AV_STEREO3D_FRAMESEQUENCE
@ AV_STEREO3D_FRAMESEQUENCE
Views are alternated temporally.
Definition: stereo3d.h:89
film_grain_params.h
H2645SEIFilmGrainCharacteristics::intensity_interval_lower_bound
uint8_t intensity_interval_lower_bound[3][256]
Definition: h2645_sei.h:103
AVFilmGrainParams::width
int width
Intended display resolution.
Definition: film_grain_params.h:269
H2645SEIFilmGrainCharacteristics::matrix_coeffs
int matrix_coeffs
Definition: h2645_sei.h:97
H2645SEIDisplayOrientation::anticlockwise_rotation
int anticlockwise_rotation
Definition: h2645_sei.h:72
AV_STEREO3D_LINES
@ AV_STEREO3D_LINES
Views are packed per line, as if interlaced.
Definition: stereo3d.h:126
stereo3d.h
AVMasteringDisplayMetadata::white_point
AVRational white_point[2]
CIE 1931 xy chromaticity coords of white point.
Definition: mastering_display_metadata.h:47
s
#define s(width, name)
Definition: cbs_vp9.c:198
SEI_TYPE_FRAME_PACKING_ARRANGEMENT
@ SEI_TYPE_FRAME_PACKING_ARRANGEMENT
Definition: sei.h:75
av_realloc_array
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:215
SEI_FPA_H264_TYPE_INTERLEAVE_ROW
@ SEI_FPA_H264_TYPE_INTERLEAVE_ROW
Definition: sei.h:150
decode_registered_user_data_closed_caption
static int decode_registered_user_data_closed_caption(H2645SEIA53Caption *h, GetByteContext *gb)
Definition: h2645_sei.c:121
av_q2d
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
decode_nal_sei_content_light_info
static int decode_nal_sei_content_light_info(H2645SEIContentLight *s, GetByteContext *gb)
Definition: h2645_sei.c:446
av_film_grain_params_create_side_data
AVFilmGrainParams * av_film_grain_params_create_side_data(AVFrame *frame)
Allocate a complete AVFilmGrainParams and add it to the frame.
Definition: film_grain_params.c:32
GetByteContext::buffer
const uint8_t * buffer
Definition: bytestream.h:34
H2645SEIAmbientViewingEnvironment
Definition: h2645_sei.h:81
H2645SEIFilmGrainCharacteristics::log2_scale_factor
int log2_scale_factor
Definition: h2645_sei.h:99
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
SEIType
SEIType
Definition: sei.h:29
SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35
@ SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35
Definition: sei.h:34
decode.h
get_bits.h
decode_unregistered_user_data
static int decode_unregistered_user_data(H2645SEIUnregistered *h, GetByteContext *gb, enum AVCodecID codec_id)
Definition: h2645_sei.c:244
codec_id
enum AVCodecID codec_id
Definition: vaapi_decode.c:387
AVFilmGrainH274Params::comp_model_value
int16_t comp_model_value[3][256][6]
Specifies the model values for the component for each intensity interval.
Definition: film_grain_params.h:227
frame
static AVFrame * frame
Definition: demux_decode.c:54
ff_decode_mastering_display_new
int ff_decode_mastering_display_new(const AVCodecContext *avctx, AVFrame *frame, AVMasteringDisplayMetadata **mdm)
Wrapper around av_mastering_display_metadata_create_side_data(), which rejects side data overridden b...
Definition: decode.c:1862
FF_CODEC_PROPERTY_FILM_GRAIN
#define FF_CODEC_PROPERTY_FILM_GRAIN
Definition: avcodec.h:1798
AVStereo3D::flags
int flags
Additional information about the frame packing.
Definition: stereo3d.h:182
H2645SEIDisplayOrientation::hflip
int hflip
Definition: h2645_sei.h:73
AVFilmGrainH274Params::model_id
int model_id
Specifies the film grain simulation mode.
Definition: film_grain_params.h:137
ff_parse_a53_cc
int ff_parse_a53_cc(AVBufferRef **pbuf, const uint8_t *data, int size)
Parse a data array for ATSC A53 Part 4 Closed Captions and store them in an AVBufferRef.
Definition: atsc_a53.c:68
decode_registered_user_data
static int decode_registered_user_data(H2645SEI *h, GetByteContext *gb, enum AVCodecID codec_id, void *logctx)
Definition: h2645_sei.c:128
NULL
#define NULL
Definition: coverity.c:32
H2645SEIFilmGrainCharacteristics::color_primaries
int color_primaries
Definition: h2645_sei.h:95
H2645VUI::colour_description_present_flag
int colour_description_present_flag
Definition: h2645_vui.h:38
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
decode_frame_packing_arrangement
static int decode_frame_packing_arrangement(H2645SEIFramePacking *h, GetBitContext *gb, enum AVCodecID codec_id)
Definition: h2645_sei.c:300
H2645SEIFilmGrainCharacteristics::repetition_period
int repetition_period
Definition: h2645_sei.h:106
H2645SEIFilmGrainCharacteristics::model_id
int model_id
Definition: h2645_sei.h:90
H2645SEIFilmGrainCharacteristics::comp_model_present_flag
int comp_model_present_flag[3]
Definition: h2645_sei.h:100
AVFilmGrainH274Params::color_trc
attribute_deprecated enum AVColorTransferCharacteristic color_trc
Definition: film_grain_params.h:171
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:388
H2645SEI
Definition: h2645_sei.h:124
AVDynamicHDRVivid
This struct represents dynamic metadata for color volume transform - CUVA 005.1:2021 standard.
Definition: hdr_dynamic_vivid_metadata.h:310
H2645VUI
Definition: h2645_vui.h:27
double
double
Definition: af_crystalizer.c:131
av_frame_new_side_data_from_buf
AVFrameSideData * av_frame_new_side_data_from_buf(AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef *buf)
Add a new side data to a frame from an existing AVBufferRef.
Definition: frame.c:756
H2645SEIFilmGrainCharacteristics::num_intensity_intervals
uint16_t num_intensity_intervals[3]
Definition: h2645_sei.h:101
fp
#define fp
Definition: regdef.h:44
AVFilmGrainParams::subsampling_x
int subsampling_x
Intended subsampling ratio, or 0 for luma-only streams.
Definition: film_grain_params.h:274
seed
static unsigned int seed
Definition: videogen.c:78
AV_FRAME_DATA_AFD
@ AV_FRAME_DATA_AFD
Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVAc...
Definition: frame.h:90
sei
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
Definition: cbs_h264_syntax_template.c:824
IS_HEVC
#define IS_HEVC(codec_id)
Definition: h2645_sei.c:46
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
ff_aom_attach_film_grain_sets
int ff_aom_attach_film_grain_sets(const AVFilmGrainAFGS1Params *s, AVFrame *frame)
Definition: aom_film_grain.c:341
AV_FRAME_DATA_SEI_UNREGISTERED
@ AV_FRAME_DATA_SEI_UNREGISTERED
User data unregistered metadata associated with a video frame.
Definition: frame.h:178
decode_alternative_transfer
static int decode_alternative_transfer(H2645SEIAlternativeTransfer *s, GetByteContext *gb)
Definition: h2645_sei.c:334
av_buffer_create
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
Definition: buffer.c:55
bytestream2_get_bytes_left
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
Definition: bytestream.h:158
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:49
H2645SEIFilmGrainCharacteristics::bit_depth_luma
int bit_depth_luma
Definition: h2645_sei.h:92
H2645SEIFilmGrainCharacteristics::num_model_values
uint8_t num_model_values[3]
Definition: h2645_sei.h:102
AV_STEREO3D_CHECKERBOARD
@ AV_STEREO3D_CHECKERBOARD
Views are packed in a checkerboard-like structure per pixel.
Definition: stereo3d.h:101
H2645SEIDisplayOrientation::vflip
int vflip
Definition: h2645_sei.h:73
H2645VUI::transfer_characteristics
enum AVColorTransferCharacteristic transfer_characteristics
Definition: h2645_vui.h:40
AVFilmGrainH274Params::color_primaries
attribute_deprecated enum AVColorPrimaries color_primaries
Definition: film_grain_params.h:169
AVFilmGrainH274Params::component_model_present
int component_model_present[3]
Indicates if the modelling of film grain for a given component is present.
Definition: film_grain_params.h:192
h2645_sei.h
size
int size
Definition: twinvq_data.h:10344
av_make_q
static AVRational av_make_q(int num, int den)
Create an AVRational.
Definition: rational.h:71
MKBETAG
#define MKBETAG(a, b, c, d)
Definition: macros.h:56
AVFrameSideData::data
uint8_t * data
Definition: frame.h:252
AVFilmGrainParams
This structure describes how to handle film grain synthesis in video for specific codecs.
Definition: film_grain_params.h:238
user_data
static int FUNC() user_data(CodedBitstreamContext *ctx, RWContext *rw, MPEG2RawUserData *current)
Definition: cbs_mpeg2_syntax_template.c:59
H2645SEIFilmGrainCharacteristics::blending_mode_id
int blending_mode_id
Definition: h2645_sei.h:98
AVFilmGrainParams::codec
union AVFilmGrainParams::@357 codec
Additional fields may be added both here and in any structure included.
decode_nal_sei_mastering_display_info
static int decode_nal_sei_mastering_display_info(H2645SEIMasteringDisplay *s, GetByteContext *gb)
Definition: h2645_sei.c:417
av_reallocp_array
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate an array through a pointer to a pointer.
Definition: mem.c:223
SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME
@ SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME
Definition: sei.h:96
FF_H2645_SEI_MESSAGE_UNHANDLED
@ FF_H2645_SEI_MESSAGE_UNHANDLED
Definition: h2645_sei.h:142
SEI_FPA_TYPE_SIDE_BY_SIDE
@ SEI_FPA_TYPE_SIDE_BY_SIDE
Definition: sei.h:151
ff_h2645_sei_reset
void ff_h2645_sei_reset(H2645SEI *s)
Definition: h2645_sei.c:811
SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS
@ SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS
Definition: sei.h:106
skip_bits1
static void skip_bits1(GetBitContext *s)
Definition: get_bits.h:413
av_buffer_alloc
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
Definition: buffer.c:77
AVFilmGrainParams::h274
AVFilmGrainH274Params h274
Definition: film_grain_params.h:261
decode_registered_user_data_afd
static int decode_registered_user_data_afd(H2645SEIAFD *h, GetByteContext *gb)
Definition: h2645_sei.c:102
ff_aom_parse_film_grain_sets
int ff_aom_parse_film_grain_sets(AVFilmGrainAFGS1Params *s, const uint8_t *payload, int payload_size)
Definition: aom_film_grain.c:122
AV_STEREO3D_FLAG_INVERT
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
Definition: stereo3d.h:164
ff_parse_itu_t_t35_to_dynamic_hdr_vivid
int ff_parse_itu_t_t35_to_dynamic_hdr_vivid(AVDynamicHDRVivid *s, const uint8_t *data, int size)
Parse the user data registered ITU-T T.35 to AVbuffer (AVDynamicHDRVivid).
Definition: dynamic_hdr_vivid.c:32
AVBufferRef::size
size_t size
Size of data in bytes.
Definition: buffer.h:94
flag
#define flag(name)
Definition: cbs_av1.c:474
SEI_FPA_H264_TYPE_2D
@ SEI_FPA_H264_TYPE_2D
Definition: sei.h:154
H2645SEIFilmGrainCharacteristics::transfer_characteristics
int transfer_characteristics
Definition: h2645_sei.h:96
AVFilmGrainParams::color_primaries
enum AVColorPrimaries color_primaries
Definition: film_grain_params.h:280
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AVCodecContext::properties
unsigned properties
Properties of the stream that gets decoded.
Definition: avcodec.h:1795
HEVCSEIDynamicHDRPlus
Definition: h2645_sei.h:45
av_ambient_viewing_environment_create_side_data
AVAmbientViewingEnvironment * av_ambient_viewing_environment_create_side_data(AVFrame *frame)
Allocate and add an AVAmbientViewingEnvironment structure to an existing AVFrame as side data.
Definition: ambient_viewing_environment.c:37
AVFilmGrainH274Params
This structure describes how to handle film grain synthesis for codecs using the ITU-T H....
Definition: film_grain_params.h:132
AVFilmGrainH274Params::num_intensity_intervals
uint16_t num_intensity_intervals[3]
Specifies the number of intensity intervals for which a specific set of model values has been estimat...
Definition: film_grain_params.h:198
display.h
AV_STEREO3D_TOPBOTTOM
@ AV_STEREO3D_TOPBOTTOM
Views are on top of each other.
Definition: stereo3d.h:76
AVFilmGrainParams::subsampling_y
int subsampling_y
Definition: film_grain_params.h:274
SEI_TYPE_DISPLAY_ORIENTATION
@ SEI_TYPE_DISPLAY_ORIENTATION
Definition: sei.h:77
H2645SEIFilmGrainCharacteristics::present
int present
Definition: h2645_sei.h:89
av_buffer_replace
int av_buffer_replace(AVBufferRef **pdst, const AVBufferRef *src)
Ensure dst refers to the same data as src.
Definition: buffer.c:233
AVMasteringDisplayMetadata
Mastering display metadata capable of representing the color volume of the display used to master the...
Definition: mastering_display_metadata.h:38
ambient_viewing_environment.h
AVFilmGrainH274Params::intensity_interval_lower_bound
uint8_t intensity_interval_lower_bound[3][256]
Specifies the lower ounds of each intensity interval for whichthe set of model values applies for the...
Definition: film_grain_params.h:210
H2645SEIFilmGrainCharacteristics::separate_colour_description_present_flag
int separate_colour_description_present_flag
Definition: h2645_sei.h:91
AVDynamicHDRPlus
This struct represents dynamic metadata for color volume transform - application 4 of SMPTE 2094-40:2...
Definition: hdr_dynamic_metadata.h:243
avcodec.h
AVFilmGrainParams::height
int height
Definition: film_grain_params.h:269
ret
ret
Definition: filter_design.txt:187
H2645SEIUnregistered
Definition: h2645_sei.h:53
AV_STEREO3D_COLUMNS
@ AV_STEREO3D_COLUMNS
Views are packed per column.
Definition: stereo3d.h:138
atsc_a53.h
AVStereo3D::type
enum AVStereo3DType type
How views are packed within the video.
Definition: stereo3d.h:177
ff_decode_content_light_new
int ff_decode_content_light_new(const AVCodecContext *avctx, AVFrame *frame, AVContentLightMetadata **clm)
Wrapper around av_content_light_metadata_create_side_data(), which rejects side data overridden by th...
Definition: decode.c:1874
SEIFpaType
SEIFpaType
frame_packing_arrangement types.
Definition: sei.h:147
H2645SEI::unregistered
H2645SEIUnregistered unregistered
Definition: h2645_sei.h:129
AVCodecContext
main external API structure.
Definition: avcodec.h:445
AVFrame::height
int height
Definition: frame.h:416
AVFilmGrainH274Params::color_space
attribute_deprecated enum AVColorSpace color_space
Definition: film_grain_params.h:173
itut35.h
AV_FILM_GRAIN_PARAMS_H274
@ AV_FILM_GRAIN_PARAMS_H274
The union is valid when interpreted as AVFilmGrainH274Params (codec.h274)
Definition: film_grain_params.h:35
SEI_TYPE_USER_DATA_UNREGISTERED
@ SEI_TYPE_USER_DATA_UNREGISTERED
Definition: sei.h:35
AVRational::den
int den
Denominator.
Definition: rational.h:60
decode_ambient_viewing_environment
static int decode_ambient_viewing_environment(H2645SEIAmbientViewingEnvironment *s, GetByteContext *gb)
Definition: h2645_sei.c:346
AVFilmGrainH274Params::log2_scale_factor
int log2_scale_factor
Specifies a scale factor used in the film grain characterization equations.
Definition: film_grain_params.h:187
hdr_dynamic_metadata.h
HEVCSEIDynamicHDRVivid
Definition: h2645_sei.h:49
AVFilmGrainH274Params::bit_depth_luma
attribute_deprecated int bit_depth_luma
TODO: On this ABI bump, please also re-order the fields in AVFilmGrainParams (see below)
Definition: film_grain_params.h:151
AVMasteringDisplayMetadata::min_luminance
AVRational min_luminance
Min luminance of mastering display (cd/m^2).
Definition: mastering_display_metadata.h:52
FF_CODEC_PROPERTY_CLOSED_CAPTIONS
#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS
Definition: avcodec.h:1797
H2645SEIAmbientViewingEnvironment::ambient_illuminance
uint32_t ambient_illuminance
Definition: h2645_sei.h:83
AVFilmGrainH274Params::num_model_values
uint8_t num_model_values[3]
Specifies the number of model values present for each intensity interval in which the film grain has ...
Definition: film_grain_params.h:204
AVFilmGrainParams::color_range
enum AVColorRange color_range
Intended video signal characteristics.
Definition: film_grain_params.h:279
FF_DISABLE_DEPRECATION_WARNINGS
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:72
H2645SEIAmbientViewingEnvironment::ambient_light_y
uint16_t ambient_light_y
Definition: h2645_sei.h:85
ITU_T_T35_PROVIDER_CODE_CUVA
#define ITU_T_T35_PROVIDER_CODE_CUVA
Definition: itut35.h:26
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
bytestream2_get_bufferu
static av_always_inline unsigned int bytestream2_get_bufferu(GetByteContext *g, uint8_t *dst, unsigned int size)
Definition: bytestream.h:277
mastering_display_metadata.h
get_ue_golomb_long
static unsigned get_ue_golomb_long(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
Definition: golomb.h:104
ITU_T_T35_COUNTRY_CODE_US
#define ITU_T_T35_COUNTRY_CODE_US
Definition: itut35.h:23
ff_h2645_sei_ctx_replace
int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src)
Definition: h2645_sei.c:493
av_stereo3d_create_side_data
AVStereo3D * av_stereo3d_create_side_data(AVFrame *frame)
Allocate a complete AVFrameSideData and add it to the frame.
Definition: stereo3d.c:34
AVFrameSideData
Structure to hold side data for an AVFrame.
Definition: frame.h:250
av_dynamic_hdr_plus_alloc
AVDynamicHDRPlus * av_dynamic_hdr_plus_alloc(size_t *size)
Allocate an AVDynamicHDRPlus structure and set its fields to default values.
Definition: hdr_dynamic_metadata.c:36
dynamic_hdr_vivid.h
AVStereo3D::view
enum AVStereo3DView view
Determines which views are packed.
Definition: stereo3d.h:187
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
ITU_T_T35_PROVIDER_CODE_SMTPE
#define ITU_T_T35_PROVIDER_CODE_SMTPE
Definition: itut35.h:28
AVContentLightMetadata::MaxFALL
unsigned MaxFALL
Max average light level per frame (cd/m^2).
Definition: mastering_display_metadata.h:107
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
av_dynamic_hdr_plus_from_t35
int av_dynamic_hdr_plus_from_t35(AVDynamicHDRPlus *s, const uint8_t *data, size_t size)
Parse the user data registered ITU-T T.35 to AVbuffer (AVDynamicHDRPlus).
Definition: hdr_dynamic_metadata.c:61
H2645SEIFilmGrainCharacteristics::full_range
int full_range
Definition: h2645_sei.h:94
H2645SEIUnregistered::nb_buf_ref
unsigned nb_buf_ref
Definition: h2645_sei.h:55
int32_t
int32_t
Definition: audioconvert.c:56
H2645SEIContentLight
Definition: h2645_sei.h:118
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO
@ SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO
Definition: sei.h:103
h
h
Definition: vp9dsp_template.c:2038
AVStereo3D
Stereo 3D type: this structure describes how two videos are packed within a single video surface,...
Definition: stereo3d.h:173
AVAmbientViewingEnvironment::ambient_light_y
AVRational ambient_light_y
Normalized y chromaticity coordinate of the environmental ambient light in the nominal viewing enviro...
Definition: ambient_viewing_environment.h:54
H2645SEIFilmGrainCharacteristics::comp_model_value
int16_t comp_model_value[3][256][6]
Definition: h2645_sei.h:105
H2645SEIUnregistered::buf_ref
AVBufferRef ** buf_ref
Definition: h2645_sei.h:54
SEI_TYPE_FILM_GRAIN_CHARACTERISTICS
@ SEI_TYPE_FILM_GRAIN_CHARACTERISTICS
Definition: sei.h:49
AVFilmGrainParams::type
enum AVFilmGrainParamsType type
Specifies the codec for which this structure is valid.
Definition: film_grain_params.h:242
H2645SEIAlternativeTransfer
Definition: h2645_sei.h:76
decode_display_orientation
static int decode_display_orientation(H2645SEIDisplayOrientation *h, GetBitContext *gb)
Definition: h2645_sei.c:282
H2645SEIFilmGrainCharacteristics
Definition: h2645_sei.h:88