FFmpeg
hevc_sei.c
Go to the documentation of this file.
1 /*
2  * HEVC Supplementary Enhancement Information messages
3  *
4  * Copyright (C) 2012 - 2013 Guillaume Martres
5  * Copyright (C) 2012 - 2013 Gildas Cocherel
6  * Copyright (C) 2013 Vittorio Giovara
7  *
8  * This file is part of FFmpeg.
9  *
10  * FFmpeg is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * FFmpeg is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with FFmpeg; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  */
24 
25 #include "atsc_a53.h"
26 #include "bytestream.h"
27 #include "dynamic_hdr10_plus.h"
28 #include "dynamic_hdr_vivid.h"
29 #include "golomb.h"
30 #include "hevc_ps.h"
31 #include "hevc_sei.h"
32 
34  GetByteContext *gb)
35 {
36  int cIdx;
37  uint8_t hash_type;
38  //uint16_t picture_crc;
39  //uint32_t picture_checksum;
40  hash_type = bytestream2_get_byte(gb);
41 
42  for (cIdx = 0; cIdx < 3/*((s->sps->chroma_format_idc == 0) ? 1 : 3)*/; cIdx++) {
43  if (hash_type == 0) {
44  s->is_md5 = 1;
45  bytestream2_get_buffer(gb, s->md5[cIdx], sizeof(s->md5[cIdx]));
46  } else if (hash_type == 1) {
47  // picture_crc = get_bits(gb, 16);
48  } else if (hash_type == 2) {
49  // picture_checksum = get_bits_long(gb, 32);
50  }
51  }
52  return 0;
53 }
54 
56  GetByteContext *gb)
57 {
58  int i;
59 
60  if (bytestream2_get_bytes_left(gb) < 24)
61  return AVERROR_INVALIDDATA;
62 
63  // Mastering primaries
64  for (i = 0; i < 3; i++) {
65  s->display_primaries[i][0] = bytestream2_get_be16u(gb);
66  s->display_primaries[i][1] = bytestream2_get_be16u(gb);
67  }
68  // White point (x, y)
69  s->white_point[0] = bytestream2_get_be16u(gb);
70  s->white_point[1] = bytestream2_get_be16u(gb);
71 
72  // Max and min luminance of mastering display
73  s->max_luminance = bytestream2_get_be32u(gb);
74  s->min_luminance = bytestream2_get_be32u(gb);
75 
76  // As this SEI message comes before the first frame that references it,
77  // initialize the flag to 2 and decrement on IRAP access unit so it
78  // persists for the coded video sequence (e.g., between two IRAPs)
79  s->present = 2;
80 
81  return 0;
82 }
83 
85  GetByteContext *gb)
86 {
87  if (bytestream2_get_bytes_left(gb) < 4)
88  return AVERROR_INVALIDDATA;
89 
90  // Max and average light levels
91  s->max_content_light_level = bytestream2_get_be16u(gb);
92  s->max_pic_average_light_level = bytestream2_get_be16u(gb);
93  // As this SEI message comes before the first frame that references it,
94  // initialize the flag to 2 and decrement on IRAP access unit so it
95  // persists for the coded video sequence (e.g., between two IRAPs)
96  s->present = 2;
97 
98  return 0;
99 }
100 
102 {
103  get_ue_golomb_long(gb); // frame_packing_arrangement_id
104  s->present = !get_bits1(gb);
105 
106  if (s->present) {
107  s->arrangement_type = get_bits(gb, 7);
108  s->quincunx_subsampling = get_bits1(gb);
109  s->content_interpretation_type = get_bits(gb, 6);
110 
111  // spatial_flipping_flag, frame0_flipped_flag, field_views_flag
112  skip_bits(gb, 3);
113  s->current_frame_is_frame0_flag = get_bits1(gb);
114  }
115  return 0;
116 }
117 
119 {
120  s->present = !get_bits1(gb);
121 
122  if (s->present) {
123  s->hflip = get_bits1(gb); // hor_flip
124  s->vflip = get_bits1(gb); // ver_flip
125 
126  s->anticlockwise_rotation = get_bits(gb, 16);
127  // skip_bits1(gb); // display_orientation_persistence_flag
128  }
129 
130  return 0;
131 }
132 
134  const HEVCParamSets *ps, void *logctx)
135 {
136  HEVCSEIPictureTiming *h = &s->picture_timing;
137  HEVCSPS *sps;
138 
139  if (!ps->sps_list[s->active_seq_parameter_set_id])
140  return(AVERROR(ENOMEM));
141  sps = (HEVCSPS*)ps->sps_list[s->active_seq_parameter_set_id]->data;
142 
143  if (sps->vui.frame_field_info_present_flag) {
144  int pic_struct = get_bits(gb, 4);
145  h->picture_struct = AV_PICTURE_STRUCTURE_UNKNOWN;
146  if (pic_struct == 2 || pic_struct == 10 || pic_struct == 12) {
147  av_log(logctx, AV_LOG_DEBUG, "BOTTOM Field\n");
148  h->picture_struct = AV_PICTURE_STRUCTURE_BOTTOM_FIELD;
149  } else if (pic_struct == 1 || pic_struct == 9 || pic_struct == 11) {
150  av_log(logctx, AV_LOG_DEBUG, "TOP Field\n");
151  h->picture_struct = AV_PICTURE_STRUCTURE_TOP_FIELD;
152  } else if (pic_struct == 7) {
153  av_log(logctx, AV_LOG_DEBUG, "Frame/Field Doubling\n");
154  h->picture_struct = HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING;
155  } else if (pic_struct == 8) {
156  av_log(logctx, AV_LOG_DEBUG, "Frame/Field Tripling\n");
157  h->picture_struct = HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING;
158  }
159  }
160 
161  return 0;
162 }
163 
165  GetByteContext *gb)
166 {
167  int ret;
168 
169  ret = ff_parse_a53_cc(&s->buf_ref, gb->buffer,
171  if (ret < 0)
172  return ret;
173 
174  return 0;
175 }
176 
178  GetByteContext *gb)
179 {
180  AVBufferRef *buf_ref, **tmp;
182 
183  if (size < 16 || size >= INT_MAX - 1)
184  return AVERROR_INVALIDDATA;
185 
186  tmp = av_realloc_array(s->buf_ref, s->nb_buf_ref + 1, sizeof(*s->buf_ref));
187  if (!tmp)
188  return AVERROR(ENOMEM);
189  s->buf_ref = tmp;
190 
191  buf_ref = av_buffer_alloc(size + 1);
192  if (!buf_ref)
193  return AVERROR(ENOMEM);
194 
195  bytestream2_get_bufferu(gb, buf_ref->data, size);
196  buf_ref->data[size] = 0;
197  buf_ref->size = size;
198  s->buf_ref[s->nb_buf_ref++] = buf_ref;
199 
200  return 0;
201 }
202 
204  GetByteContext *gb)
205 {
206  size_t meta_size;
207  int err;
208  AVDynamicHDRPlus *metadata = av_dynamic_hdr_plus_alloc(&meta_size);
209  if (!metadata)
210  return AVERROR(ENOMEM);
211 
214  if (err < 0) {
215  av_free(metadata);
216  return err;
217  }
218 
219  av_buffer_unref(&s->info);
220  s->info = av_buffer_create((uint8_t *)metadata, meta_size, NULL, NULL, 0);
221  if (!s->info) {
222  av_free(metadata);
223  return AVERROR(ENOMEM);
224  }
225 
226  return 0;
227 }
228 
230  GetByteContext *gb)
231 {
232  size_t meta_size;
233  int err;
234  AVDynamicHDRVivid *metadata = av_dynamic_hdr_vivid_alloc(&meta_size);
235  if (!metadata)
236  return AVERROR(ENOMEM);
237 
240  if (err < 0) {
241  av_free(metadata);
242  return err;
243  }
244 
245  av_buffer_unref(&s->info);
246  s->info = av_buffer_create((uint8_t *)metadata, meta_size, NULL, NULL, 0);
247  if (!s->info) {
248  av_free(metadata);
249  return AVERROR(ENOMEM);
250  }
251 
252  return 0;
253 }
254 
256  void *logctx)
257 {
258  int country_code, provider_code;
259 
260  if (bytestream2_get_bytes_left(gb) < 3)
261  return AVERROR_INVALIDDATA;
262 
263  country_code = bytestream2_get_byteu(gb);
264  if (country_code == 0xFF) {
265  if (bytestream2_get_bytes_left(gb) < 3)
266  return AVERROR_INVALIDDATA;
267 
268  bytestream2_skipu(gb, 1);
269  }
270 
271  if (country_code != 0xB5 && country_code != 0x26) { // usa_country_code and cn_country_code
272  av_log(logctx, AV_LOG_VERBOSE,
273  "Unsupported User Data Registered ITU-T T35 SEI message (country_code = 0x%x)\n",
274  country_code);
275  return 0;
276  }
277 
278  provider_code = bytestream2_get_be16u(gb);
279 
280  switch (provider_code) {
281  case 0x04: { // cuva_provider_code
282  const uint16_t cuva_provider_oriented_code = 0x0005;
283  uint16_t provider_oriented_code;
284 
285  if (bytestream2_get_bytes_left(gb) < 2)
286  return AVERROR_INVALIDDATA;
287 
288  provider_oriented_code = bytestream2_get_be16u(gb);
289  if (provider_oriented_code == cuva_provider_oriented_code) {
290  return decode_registered_user_data_dynamic_hdr_vivid(&s->dynamic_hdr_vivid, gb);
291  }
292  break;
293  }
294  case 0x3C: { // smpte_provider_code
295  // A/341 Amendment - 2094-40
296  const uint16_t smpte2094_40_provider_oriented_code = 0x0001;
297  const uint8_t smpte2094_40_application_identifier = 0x04;
298  uint16_t provider_oriented_code;
299  uint8_t application_identifier;
300 
301  if (bytestream2_get_bytes_left(gb) < 3)
302  return AVERROR_INVALIDDATA;
303 
304  provider_oriented_code = bytestream2_get_be16u(gb);
305  application_identifier = bytestream2_get_byteu(gb);
306  if (provider_oriented_code == smpte2094_40_provider_oriented_code &&
307  application_identifier == smpte2094_40_application_identifier) {
308  return decode_registered_user_data_dynamic_hdr_plus(&s->dynamic_hdr_plus, gb);
309  }
310  break;
311  }
312  case 0x31: { // atsc_provider_code
313  uint32_t user_identifier;
314 
315  if (bytestream2_get_bytes_left(gb) < 4)
316  return AVERROR_INVALIDDATA;
317 
318  user_identifier = bytestream2_get_be32u(gb);
319  switch (user_identifier) {
320  case MKBETAG('G', 'A', '9', '4'):
321  return decode_registered_user_data_closed_caption(&s->a53_caption, gb);
322  default:
323  av_log(logctx, AV_LOG_VERBOSE,
324  "Unsupported User Data Registered ITU-T T35 SEI message (atsc user_identifier = 0x%04x)\n",
325  user_identifier);
326  break;
327  }
328  break;
329  }
330  default:
331  av_log(logctx, AV_LOG_VERBOSE,
332  "Unsupported User Data Registered ITU-T T35 SEI message (provider_code = %d)\n",
333  provider_code);
334  break;
335  }
336 
337  return 0;
338 }
339 
341 {
342  int num_sps_ids_minus1;
343  unsigned active_seq_parameter_set_id;
344 
345  get_bits(gb, 4); // active_video_parameter_set_id
346  get_bits(gb, 1); // self_contained_cvs_flag
347  get_bits(gb, 1); // num_sps_ids_minus1
348  num_sps_ids_minus1 = get_ue_golomb_long(gb); // num_sps_ids_minus1
349 
350  if (num_sps_ids_minus1 < 0 || num_sps_ids_minus1 > 15) {
351  av_log(logctx, AV_LOG_ERROR, "num_sps_ids_minus1 %d invalid\n", num_sps_ids_minus1);
352  return AVERROR_INVALIDDATA;
353  }
354 
355  active_seq_parameter_set_id = get_ue_golomb_long(gb);
356  if (active_seq_parameter_set_id >= HEVC_MAX_SPS_COUNT) {
357  av_log(logctx, AV_LOG_ERROR, "active_parameter_set_id %d invalid\n", active_seq_parameter_set_id);
358  return AVERROR_INVALIDDATA;
359  }
360  s->active_seq_parameter_set_id = active_seq_parameter_set_id;
361 
362  return 0;
363 }
364 
366  GetByteContext *gb)
367 {
368  if (bytestream2_get_bytes_left(gb) < 1)
369  return AVERROR_INVALIDDATA;
370 
371  s->present = 1;
372  s->preferred_transfer_characteristics = bytestream2_get_byteu(gb);
373 
374  return 0;
375 }
376 
378 {
379  s->num_clock_ts = get_bits(gb, 2);
380 
381  for (int i = 0; i < s->num_clock_ts; i++) {
382  s->clock_timestamp_flag[i] = get_bits(gb, 1);
383 
384  if (s->clock_timestamp_flag[i]) {
385  s->units_field_based_flag[i] = get_bits(gb, 1);
386  s->counting_type[i] = get_bits(gb, 5);
387  s->full_timestamp_flag[i] = get_bits(gb, 1);
388  s->discontinuity_flag[i] = get_bits(gb, 1);
389  s->cnt_dropped_flag[i] = get_bits(gb, 1);
390 
391  s->n_frames[i] = get_bits(gb, 9);
392 
393  if (s->full_timestamp_flag[i]) {
394  s->seconds_value[i] = av_clip(get_bits(gb, 6), 0, 59);
395  s->minutes_value[i] = av_clip(get_bits(gb, 6), 0, 59);
396  s->hours_value[i] = av_clip(get_bits(gb, 5), 0, 23);
397  } else {
398  s->seconds_flag[i] = get_bits(gb, 1);
399  if (s->seconds_flag[i]) {
400  s->seconds_value[i] = av_clip(get_bits(gb, 6), 0, 59);
401  s->minutes_flag[i] = get_bits(gb, 1);
402  if (s->minutes_flag[i]) {
403  s->minutes_value[i] = av_clip(get_bits(gb, 6), 0, 59);
404  s->hours_flag[i] = get_bits(gb, 1);
405  if (s->hours_flag[i]) {
406  s->hours_value[i] = av_clip(get_bits(gb, 5), 0, 23);
407  }
408  }
409  }
410  }
411 
412  s->time_offset_length[i] = get_bits(gb, 5);
413  if (s->time_offset_length[i] > 0) {
414  s->time_offset_value[i] = get_bits_long(gb, s->time_offset_length[i]);
415  }
416  }
417  }
418 
419  s->present = 1;
420  return 0;
421 }
422 
424  GetBitContext *gb)
425 {
426  h->present = !get_bits1(gb); // film_grain_characteristics_cancel_flag
427 
428  if (h->present) {
429  memset(h, 0, sizeof(*h));
430  h->model_id = get_bits(gb, 2);
431  h->separate_colour_description_present_flag = get_bits1(gb);
432  if (h->separate_colour_description_present_flag) {
433  h->bit_depth_luma = get_bits(gb, 3) + 8;
434  h->bit_depth_chroma = get_bits(gb, 3) + 8;
435  h->full_range = get_bits1(gb);
436  h->color_primaries = get_bits(gb, 8);
437  h->transfer_characteristics = get_bits(gb, 8);
438  h->matrix_coeffs = get_bits(gb, 8);
439  }
440  h->blending_mode_id = get_bits(gb, 2);
441  h->log2_scale_factor = get_bits(gb, 4);
442  for (int c = 0; c < 3; c++)
443  h->comp_model_present_flag[c] = get_bits1(gb);
444  for (int c = 0; c < 3; c++) {
445  if (h->comp_model_present_flag[c]) {
446  h->num_intensity_intervals[c] = get_bits(gb, 8) + 1;
447  h->num_model_values[c] = get_bits(gb, 3) + 1;
448  if (h->num_model_values[c] > 6)
449  return AVERROR_INVALIDDATA;
450  for (int i = 0; i < h->num_intensity_intervals[c]; i++) {
451  h->intensity_interval_lower_bound[c][i] = get_bits(gb, 8);
452  h->intensity_interval_upper_bound[c][i] = get_bits(gb, 8);
453  for (int j = 0; j < h->num_model_values[c]; j++)
454  h->comp_model_value[c][i][j] = get_se_golomb_long(gb);
455  }
456  }
457  }
458  h->persistence_flag = get_bits1(gb);
459 
460  h->present = 1;
461  }
462 
463  return 0;
464 }
465 
467  void *logctx, HEVCSEI *s,
468  const HEVCParamSets *ps, int type)
469 {
470  switch (type) {
471  case 256: // Mismatched value from HM 8.1
472  return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gbyte);
474  return decode_nal_sei_frame_packing_arrangement(&s->frame_packing, gb);
476  return decode_nal_sei_display_orientation(&s->display_orientation, gb);
477  case SEI_TYPE_PIC_TIMING:
478  return decode_nal_sei_pic_timing(s, gb, ps, logctx);
480  return decode_nal_sei_mastering_display_info(&s->mastering_display, gbyte);
482  return decode_nal_sei_content_light_info(&s->content_light, gbyte);
484  return decode_nal_sei_active_parameter_sets(s, gb, logctx);
486  return decode_nal_sei_user_data_registered_itu_t_t35(s, gbyte, logctx);
488  return decode_nal_sei_user_data_unregistered(&s->unregistered, gbyte);
490  return decode_nal_sei_alternative_transfer(&s->alternative_transfer, gbyte);
491  case SEI_TYPE_TIME_CODE:
492  return decode_nal_sei_timecode(&s->timecode, gb);
494  return decode_film_grain_characteristics(&s->film_grain_characteristics, gb);
495  default:
496  av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
497  return 0;
498  }
499 }
500 
502  void *logctx, HEVCSEI *s, int type)
503 {
504  switch (type) {
506  return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gbyte);
507  default:
508  av_log(logctx, AV_LOG_DEBUG, "Skipped SUFFIX SEI %d\n", type);
509  return 0;
510  }
511 }
512 
513 static int decode_nal_sei_message(GetByteContext *gb, void *logctx, HEVCSEI *s,
514  const HEVCParamSets *ps, int nal_unit_type)
515 {
516  GetByteContext message_gbyte;
517  GetBitContext message_gb;
518  int payload_type = 0;
519  int payload_size = 0;
520  int byte = 0xFF;
521  av_unused int ret;
522  av_log(logctx, AV_LOG_DEBUG, "Decoding SEI\n");
523 
524  while (byte == 0xFF) {
525  if (bytestream2_get_bytes_left(gb) < 2 || payload_type > INT_MAX - 255)
526  return AVERROR_INVALIDDATA;
527  byte = bytestream2_get_byteu(gb);
528  payload_type += byte;
529  }
530  byte = 0xFF;
531  while (byte == 0xFF) {
532  if (bytestream2_get_bytes_left(gb) < 1 + payload_size)
533  return AVERROR_INVALIDDATA;
534  byte = bytestream2_get_byteu(gb);
535  payload_size += byte;
536  }
537  if (bytestream2_get_bytes_left(gb) < payload_size)
538  return AVERROR_INVALIDDATA;
539  bytestream2_init(&message_gbyte, gb->buffer, payload_size);
540  ret = init_get_bits8(&message_gb, gb->buffer, payload_size);
541  av_assert1(ret >= 0);
542  bytestream2_skipu(gb, payload_size);
543  if (nal_unit_type == HEVC_NAL_SEI_PREFIX) {
544  return decode_nal_sei_prefix(&message_gb, &message_gbyte,
545  logctx, s, ps, payload_type);
546  } else { /* nal_unit_type == NAL_SEI_SUFFIX */
547  return decode_nal_sei_suffix(&message_gb, &message_gbyte,
548  logctx, s, payload_type);
549  }
550 }
551 
553  const HEVCParamSets *ps, enum HEVCNALUnitType type)
554 {
555  GetByteContext gbyte;
556  int ret;
557 
558  av_assert1((get_bits_count(gb) % 8) == 0);
559  bytestream2_init(&gbyte, gb->buffer + get_bits_count(gb) / 8,
560  get_bits_left(gb) / 8);
561 
562  do {
563  ret = decode_nal_sei_message(&gbyte, logctx, s, ps, type);
564  if (ret < 0)
565  return ret;
566  } while (bytestream2_get_bytes_left(&gbyte) > 0);
567  return 1;
568 }
569 
571 {
572  av_buffer_unref(&s->a53_caption.buf_ref);
573 
574  for (int i = 0; i < s->unregistered.nb_buf_ref; i++)
575  av_buffer_unref(&s->unregistered.buf_ref[i]);
576  s->unregistered.nb_buf_ref = 0;
577  av_freep(&s->unregistered.buf_ref);
578  av_buffer_unref(&s->dynamic_hdr_plus.info);
579  av_buffer_unref(&s->dynamic_hdr_vivid.info);
580 }
decode_nal_sei_frame_packing_arrangement
static int decode_nal_sei_frame_packing_arrangement(HEVCSEIFramePacking *s, GetBitContext *gb)
Definition: hevc_sei.c:101
SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS
@ SEI_TYPE_ALTERNATIVE_TRANSFER_CHARACTERISTICS
Definition: sei.h:106
av_clip
#define av_clip
Definition: common.h:95
HEVCSEIAlternativeTransfer
Definition: hevc_sei.h:92
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:839
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
HEVCSEIUnregistered
Definition: hevc_sei.h:65
GetByteContext
Definition: bytestream.h:33
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
AV_PICTURE_STRUCTURE_UNKNOWN
@ AV_PICTURE_STRUCTURE_UNKNOWN
Definition: avcodec.h:2783
get_bits_long
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:546
bytestream2_skipu
static av_always_inline void bytestream2_skipu(GetByteContext *g, unsigned int size)
Definition: bytestream.h:174
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:219
av_unused
#define av_unused
Definition: attributes.h:131
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
decode_nal_sei_user_data_unregistered
static int decode_nal_sei_user_data_unregistered(HEVCSEIUnregistered *s, GetByteContext *gb)
Definition: hevc_sei.c:177
decode_nal_sei_decoded_picture_hash
static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s, GetByteContext *gb)
Definition: hevc_sei.c:33
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
SEI_TYPE_USER_DATA_UNREGISTERED
@ SEI_TYPE_USER_DATA_UNREGISTERED
Definition: sei.h:35
HEVC_MAX_SPS_COUNT
@ HEVC_MAX_SPS_COUNT
Definition: hevc.h:112
skip_bits
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:467
HEVCSEITimeCode
Definition: hevc_sei.h:97
golomb.h
exp golomb vlc stuff
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:379
HEVCSEIA53Caption
Definition: hevc_sei.h:61
GetBitContext
Definition: get_bits.h:61
SEI_TYPE_FRAME_PACKING_ARRANGEMENT
@ SEI_TYPE_FRAME_PACKING_ARRANGEMENT
Definition: sei.h:75
decode_nal_sei_prefix
static int decode_nal_sei_prefix(GetBitContext *gb, GetByteContext *gbyte, void *logctx, HEVCSEI *s, const HEVCParamSets *ps, int type)
Definition: hevc_sei.c:466
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
decode_nal_sei_active_parameter_sets
static int decode_nal_sei_active_parameter_sets(HEVCSEI *s, GetBitContext *gb, void *logctx)
Definition: hevc_sei.c:340
ff_hevc_decode_nal_sei
int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s, const HEVCParamSets *ps, enum HEVCNALUnitType type)
Definition: hevc_sei.c:552
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
init_get_bits8
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:667
s
#define s(width, name)
Definition: cbs_vp9.c:256
av_realloc_array
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition: mem.c:225
SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35
@ SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35
Definition: sei.h:34
GetByteContext::buffer
const uint8_t * buffer
Definition: bytestream.h:34
HEVCSEI
Definition: hevc_sei.h:138
HEVCSEIMasteringDisplay
Definition: hevc_sei.h:70
decode_nal_sei_pic_timing
static int decode_nal_sei_pic_timing(HEVCSEI *s, GetBitContext *gb, const HEVCParamSets *ps, void *logctx)
Definition: hevc_sei.c:133
HEVCSEIPictureHash
Definition: hevc_sei.h:38
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO
@ SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO
Definition: sei.h:103
HEVCSEIFramePacking
Definition: hevc_sei.h:43
HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING
@ HEVC_SEI_PIC_STRUCT_FRAME_TRIPLING
Definition: hevc_sei.h:35
if
if(ret)
Definition: filter_design.txt:179
AV_PICTURE_STRUCTURE_BOTTOM_FIELD
@ AV_PICTURE_STRUCTURE_BOTTOM_FIELD
Definition: avcodec.h:2785
GetBitContext::buffer
const uint8_t * buffer
Definition: get_bits.h:62
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
NULL
#define NULL
Definition: coverity.c:32
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
AV_PICTURE_STRUCTURE_TOP_FIELD
@ AV_PICTURE_STRUCTURE_TOP_FIELD
Definition: avcodec.h:2784
HEVCSEIDisplayOrientation
Definition: hevc_sei.h:51
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:498
SEI_TYPE_TIME_CODE
@ SEI_TYPE_TIME_CODE
Definition: sei.h:95
AVDynamicHDRVivid
This struct represents dynamic metadata for color volume transform - CUVA 005.1:2021 standard.
Definition: hdr_dynamic_vivid_metadata.h:249
decode_nal_sei_content_light_info
static int decode_nal_sei_content_light_info(HEVCSEIContentLight *s, GetByteContext *gb)
Definition: hevc_sei.c:84
dynamic_hdr10_plus.h
bytestream2_get_buffer
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
Definition: bytestream.h:267
decode_nal_sei_message
static int decode_nal_sei_message(GetByteContext *gb, void *logctx, HEVCSEI *s, const HEVCParamSets *ps, int nal_unit_type)
Definition: hevc_sei.c:513
decode_nal_sei_alternative_transfer
static int decode_nal_sei_alternative_transfer(HEVCSEIAlternativeTransfer *s, GetByteContext *gb)
Definition: hevc_sei.c:365
SEI_TYPE_FILM_GRAIN_CHARACTERISTICS
@ SEI_TYPE_FILM_GRAIN_CHARACTERISTICS
Definition: sei.h:49
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
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
decode_nal_sei_timecode
static int decode_nal_sei_timecode(HEVCSEITimeCode *s, GetBitContext *gb)
Definition: hevc_sei.c:377
byte
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_WB16 unsigned int_TMPL byte
Definition: bytestream.h:99
size
int size
Definition: twinvq_data.h:10344
MKBETAG
#define MKBETAG(a, b, c, d)
Definition: macros.h:56
HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING
@ HEVC_SEI_PIC_STRUCT_FRAME_DOUBLING
Definition: hevc_sei.h:34
decode_film_grain_characteristics
static int decode_film_grain_characteristics(HEVCSEIFilmGrainCharacteristics *h, GetBitContext *gb)
Definition: hevc_sei.c:423
av_buffer_alloc
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
Definition: buffer.c:77
decode_nal_sei_display_orientation
static int decode_nal_sei_display_orientation(HEVCSEIDisplayOrientation *s, GetBitContext *gb)
Definition: hevc_sei.c:118
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
decode_nal_sei_user_data_registered_itu_t_t35
static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, GetByteContext *gb, void *logctx)
Definition: hevc_sei.c:255
hevc_ps.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
HEVCSEIDynamicHDRPlus
Definition: hevc_sei.h:78
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
HEVCNALUnitType
HEVCNALUnitType
Table 7-1 – NAL unit type codes and NAL unit type classes in T-REC-H.265-201802.
Definition: hevc.h:28
AVDynamicHDRPlus
This struct represents dynamic metadata for color volume transform - application 4 of SMPTE 2094-40:2...
Definition: hdr_dynamic_metadata.h:243
ret
ret
Definition: filter_design.txt:187
ff_hevc_reset_sei
void ff_hevc_reset_sei(HEVCSEI *s)
Reset SEI values that are stored on the Context.
Definition: hevc_sei.c:570
atsc_a53.h
sps
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
Definition: cbs_h264_syntax_template.c:260
decode_nal_sei_mastering_display_info
static int decode_nal_sei_mastering_display_info(HEVCSEIMasteringDisplay *s, GetByteContext *gb)
Definition: hevc_sei.c:55
decode_registered_user_data_dynamic_hdr_plus
static int decode_registered_user_data_dynamic_hdr_plus(HEVCSEIDynamicHDRPlus *s, GetByteContext *gb)
Definition: hevc_sei.c:203
decode_registered_user_data_closed_caption
static int decode_registered_user_data_closed_caption(HEVCSEIA53Caption *s, GetByteContext *gb)
Definition: hevc_sei.c:164
ff_parse_itu_t_t35_to_dynamic_hdr10_plus
int ff_parse_itu_t_t35_to_dynamic_hdr10_plus(AVDynamicHDRPlus *s, const uint8_t *data, int size)
Parse the user data registered ITU-T T.35 to AVbuffer (AVDynamicHDRPlus).
Definition: dynamic_hdr10_plus.c:30
HEVCParamSets::sps_list
AVBufferRef * sps_list[HEVC_MAX_SPS_COUNT]
Definition: hevc_ps.h:329
SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME
@ SEI_TYPE_MASTERING_DISPLAY_COLOUR_VOLUME
Definition: sei.h:96
HEVCSEIDynamicHDRVivid
Definition: hevc_sei.h:82
decode_nal_sei_suffix
static int decode_nal_sei_suffix(GetBitContext *gb, GetByteContext *gbyte, void *logctx, HEVCSEI *s, int type)
Definition: hevc_sei.c:501
SEI_TYPE_ACTIVE_PARAMETER_SETS
@ SEI_TYPE_ACTIVE_PARAMETER_SETS
Definition: sei.h:87
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
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
HEVCSPS
Definition: hevc_ps.h:153
av_dynamic_hdr_plus_alloc
AVDynamicHDRPlus * av_dynamic_hdr_plus_alloc(size_t *size)
Copyright (c) 2018 Mohammad Izadi <moh.izadi at gmail.com>
Definition: hdr_dynamic_metadata.c:24
dynamic_hdr_vivid.h
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
HEVCSEIContentLight
Definition: hevc_sei.h:86
bytestream.h
bytestream2_init
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:137
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
h
h
Definition: vp9dsp_template.c:2038
decode_registered_user_data_dynamic_hdr_vivid
static int decode_registered_user_data_dynamic_hdr_vivid(HEVCSEIDynamicHDRVivid *s, GetByteContext *gb)
Definition: hevc_sei.c:229
SEI_TYPE_PIC_TIMING
@ SEI_TYPE_PIC_TIMING
Definition: sei.h:31
HEVCSEIPictureTiming
Definition: hevc_sei.h:57
SEI_TYPE_DISPLAY_ORIENTATION
@ SEI_TYPE_DISPLAY_ORIENTATION
Definition: sei.h:77
HEVC_NAL_SEI_PREFIX
@ HEVC_NAL_SEI_PREFIX
Definition: hevc.h:68
SEI_TYPE_DECODED_PICTURE_HASH
@ SEI_TYPE_DECODED_PICTURE_HASH
Definition: sei.h:91
HEVCSEIFilmGrainCharacteristics
Definition: hevc_sei.h:117
hevc_sei.h
HEVCParamSets
Definition: hevc_ps.h:327