FFmpeg
vvc.c
Go to the documentation of this file.
1 /*
2  * H.266/VVC helper functions for muxers
3  *
4  * Copyright (C) 2022, Thomas Siedel
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include "libavcodec/get_bits.h"
24 #include "libavcodec/golomb.h"
25 #include "libavcodec/vvc.h"
26 #include "libavutil/intreadwrite.h"
27 #include "libavutil/mem.h"
28 #include "avc.h"
29 #include "avio.h"
30 #include "avio_internal.h"
31 #include "vvc.h"
32 
33 typedef struct VVCCNALUnitArray {
35  uint8_t NAL_unit_type;
36  uint16_t num_nalus;
37  uint16_t *nal_unit_length;
38  uint8_t **nal_unit;
40 
41 typedef struct VVCPTLRecord {
53 } VVCPTLRecord;
54 
58  uint16_t ols_idx;
59  uint8_t num_sublayers;
66  uint16_t avg_frame_rate;
67  uint8_t num_of_arrays;
70 
71 typedef struct VVCCProfileTierLevel {
72  uint8_t profile_idc;
73  uint8_t tier_flag;
77 // general_constraint_info
81 // end general_constraint_info
87 
90 {
91  /*
92  * The level indication general_level_idc must indicate a level of
93  * capability equal to or greater than the highest level indicated for the
94  * highest tier in all the parameter sets.
95  */
96  if (vvcc->ptl.general_tier_flag < ptl->tier_flag)
98  else
99  vvcc->ptl.general_level_idc =
101 
102  /*
103  * The tier indication general_tier_flag must indicate a tier equal to or
104  * greater than the highest tier indicated in all the parameter sets.
105  */
106  vvcc->ptl.general_tier_flag =
107  FFMAX(vvcc->ptl.general_tier_flag, ptl->tier_flag);
108 
109  /*
110  * The profile indication general_profile_idc must indicate a profile to
111  * which the stream associated with this configuration record conforms.
112  *
113  * If the sequence parameter sets are marked with different profiles, then
114  * the stream may need examination to determine which profile, if any, the
115  * entire stream conforms to. If the entire stream is not examined, or the
116  * examination reveals that there is no profile to which the entire stream
117  * conforms, then the entire stream must be split into two or more
118  * sub-streams with separate configuration records in which these rules can
119  * be met.
120  *
121  * Note: set the profile to the highest value for the sake of simplicity.
122  */
123  vvcc->ptl.general_profile_idc =
124  FFMAX(vvcc->ptl.general_profile_idc, ptl->profile_idc);
125 
126  /*
127  * Each bit in flags may only be set if all
128  * the parameter sets set that bit.
129  */
131  ptl->ptl_frame_only_constraint_flag;
132  vvcc->ptl.ptl_multilayer_enabled_flag &= ptl->ptl_multilayer_enabled_flag;
133 
134  /*
135  * Constraints Info
136  */
137  if (ptl->gci_present_flag) {
138  vvcc->ptl.num_bytes_constraint_info = 9;
139  memcpy(&vvcc->ptl.general_constraint_info[0],
140  &ptl->gci_general_constraints[0], sizeof(uint8_t) * 9);
141 
142  } else {
143  vvcc->ptl.num_bytes_constraint_info = 1;
144  memset(&vvcc->ptl.general_constraint_info[0], 0, sizeof(uint8_t) * 9);
145  }
146 
147  /*
148  * Each bit in flags may only be set if one of
149  * the parameter sets set that bit.
150  */
151  memset(vvcc->ptl.ptl_sublayer_level_present_flag, 0,
152  sizeof(uint8_t) * vvcc->num_sublayers - 1);
153  memset(vvcc->ptl.sublayer_level_idc, 0,
154  sizeof(uint8_t) * vvcc->num_sublayers - 1);
155 
156  for (int i = vvcc->num_sublayers - 2; i >= 0; i--) {
158  ptl->ptl_sublayer_level_present_flag[i];
160  vvcc->ptl.sublayer_level_idc[i] =
161  FFMAX(vvcc->ptl.sublayer_level_idc[i],
162  ptl->sublayer_level_idc[i]);
163  } else {
164  if (i == vvcc->num_sublayers - 1) {
166  } else {
167  vvcc->ptl.sublayer_level_idc[i] =
168  vvcc->ptl.sublayer_level_idc[i + 1];
169  }
170  }
171  }
172 
173  vvcc->ptl.ptl_num_sub_profiles =
174  FFMAX(vvcc->ptl.ptl_num_sub_profiles, ptl->ptl_num_sub_profiles);
175  if (vvcc->ptl.ptl_num_sub_profiles) {
176  for (int i = 0; i < vvcc->ptl.ptl_num_sub_profiles; i++) {
177  vvcc->ptl.general_sub_profile_idc[i] =
178  ptl->general_sub_profile_idc[i];
179  }
180  }
181 }
182 
185  unsigned int profileTierPresentFlag,
186  unsigned int max_sub_layers_minus1)
187 {
188  VVCCProfileTierLevel general_ptl;
189  int j;
190 
191  if (profileTierPresentFlag) {
192  general_ptl.profile_idc = get_bits(gb, 7);
193  general_ptl.tier_flag = get_bits1(gb);
194  }
195  general_ptl.general_level_idc = get_bits(gb, 8);
196 
197  general_ptl.ptl_frame_only_constraint_flag = get_bits1(gb);
198  general_ptl.ptl_multilayer_enabled_flag = get_bits1(gb);
199  if (profileTierPresentFlag) { // parse constraint info
200  general_ptl.gci_present_flag = get_bits1(gb);
201  if (general_ptl.gci_present_flag) {
202  for (j = 0; j < 8; j++)
203  general_ptl.gci_general_constraints[j] = get_bits(gb, 8);
204  general_ptl.gci_general_constraints[8] = get_bits(gb, 7);
205 
206  general_ptl.gci_num_reserved_bits = get_bits(gb, 8);
207  skip_bits(gb, general_ptl.gci_num_reserved_bits);
208  }
209  while (gb->index % 8 != 0)
210  skip_bits1(gb);
211  }
212 
213  for (int i = max_sub_layers_minus1 - 1; i >= 0; i--)
214  general_ptl.ptl_sublayer_level_present_flag[i] = get_bits1(gb);
215 
216  while (gb->index % 8 != 0)
217  skip_bits1(gb);
218 
219  for (int i = max_sub_layers_minus1 - 1; i >= 0; i--) {
220  if (general_ptl.ptl_sublayer_level_present_flag[i])
221  general_ptl.sublayer_level_idc[i] = get_bits(gb, 8);
222  }
223 
224  if (profileTierPresentFlag) {
225  general_ptl.ptl_num_sub_profiles = get_bits(gb, 8);
226  if (general_ptl.ptl_num_sub_profiles) {
227  for (int i = 0; i < general_ptl.ptl_num_sub_profiles; i++)
228  general_ptl.general_sub_profile_idc[i] = get_bits_long(gb, 32);
229  }
230  }
231 
232  vvcc_update_ptl(vvcc, &general_ptl);
233 }
234 
237 {
238  unsigned int vps_max_layers_minus1;
239  unsigned int vps_max_sublayers_minus1;
240  unsigned int vps_default_ptl_dpb_hrd_max_tid_flag;
241  unsigned int vps_all_independent_layers_flag;
242  unsigned int vps_each_layer_is_an_ols_flag;
243  unsigned int vps_ols_mode_idc;
244 
245  unsigned int vps_pt_present_flag[VVC_MAX_PTLS];
246  unsigned int vps_ptl_max_tid[VVC_MAX_PTLS];
247  unsigned int vps_num_ptls_minus1 = 0;
248 
249  /*
250  * vps_video_parameter_set_id u(4)
251  */
252  skip_bits(gb, 4);
253 
254  vps_max_layers_minus1 = get_bits(gb, 6);
255  vps_max_sublayers_minus1 = get_bits(gb, 3);
256 
257  /*
258  * numTemporalLayers greater than 1 indicates that the stream to which this
259  * configuration record applies is temporally scalable and the contained
260  * number of temporal layers (also referred to as temporal sub-layer or
261  * sub-layer in ISO/IEC 23008-2) is equal to numTemporalLayers. Value 1
262  * indicates that the stream is not temporally scalable. Value 0 indicates
263  * that it is unknown whether the stream is temporally scalable.
264  */
265  vvcc->num_sublayers = FFMAX(vvcc->num_sublayers,
266  vps_max_sublayers_minus1 + 1);
267 
268  if (vps_max_layers_minus1 > 0 && vps_max_sublayers_minus1 > 0)
269  vps_default_ptl_dpb_hrd_max_tid_flag = get_bits1(gb);
270  if (vps_max_layers_minus1 > 0)
271  vps_all_independent_layers_flag = get_bits1(gb);
272  else
273  vps_all_independent_layers_flag = 1;
274 
275  for (int i = 0; i <= vps_max_layers_minus1; i++) {
276  skip_bits(gb, 6); //vps_layer_id[i]
277  if (i > 0 && !vps_all_independent_layers_flag) {
278  if (get_bits1(gb)) { // vps_independent_layer_flag[i]
279  unsigned int vps_max_tid_ref_present_flag = get_bits1(gb);
280  for (int j = 0; j < i; j++) {
281  if (vps_max_tid_ref_present_flag && get_bits1(gb)) // vps_direct_ref_layer_flag[i][j]
282  skip_bits(gb, 3); // vps_max_tid_il_ref_pics_plus1
283  }
284  }
285  }
286  }
287 
288  if (vps_max_layers_minus1 > 0) {
289  if (vps_all_independent_layers_flag)
290  vps_each_layer_is_an_ols_flag = get_bits1(gb);
291  else
292  vps_each_layer_is_an_ols_flag = 0;
293  if (!vps_each_layer_is_an_ols_flag) {
294  if (!vps_all_independent_layers_flag)
295  vps_ols_mode_idc = get_bits(gb, 2);
296  else
297  vps_ols_mode_idc = 2;
298  if (vps_ols_mode_idc == 2) {
299  unsigned int vps_num_output_layer_sets_minus2 = get_bits(gb, 8);
300  for (int i = 1; i <= vps_num_output_layer_sets_minus2 + 1; i++) {
301  for (int j = 0; j <= vps_max_layers_minus1; j++) {
302  skip_bits1(gb); // vps_ols_output_layer_flag[i][j]
303  }
304  }
305  }
306  }
307  vps_num_ptls_minus1 = get_bits(gb, 8);
308  } else {
309  vps_each_layer_is_an_ols_flag = 0;
310  }
311 
312  for (int i = 0; i <= vps_num_ptls_minus1; i++) {
313  if (i > 0)
314  vps_pt_present_flag[i] = get_bits1(gb);
315  else
316  vps_pt_present_flag[i] = 1;
317 
318  if (!vps_default_ptl_dpb_hrd_max_tid_flag)
319  vps_ptl_max_tid[i] = get_bits(gb, 3);
320  else
321  vps_ptl_max_tid[i] = vps_max_sublayers_minus1;
322  }
323 
324  while (gb->index % 8 != 0)
325  skip_bits1(gb);
326 
327  for (int i = 0; i <= vps_num_ptls_minus1; i++)
328  vvcc_parse_ptl(gb, vvcc, vps_pt_present_flag[i], vps_ptl_max_tid[i]);
329 
330  /* nothing useful for vvcc past this point */
331  return 0;
332 }
333 
336 {
337  unsigned int sps_max_sublayers_minus1, sps_log2_ctu_size_minus5;
338  unsigned int sps_subpic_same_size_flag, sps_pic_height_max_in_luma_samples,
339  sps_pic_width_max_in_luma_samples;
340  unsigned int sps_independent_subpics_flag;
341 
342  skip_bits(gb, 8); // sps_seq_parameter_set_id && sps_video_parameter_set_id
343  sps_max_sublayers_minus1 = get_bits(gb, 3);
344 
345  /*
346  * numTemporalLayers greater than 1 indicates that the stream to which this
347  * configuration record applies is temporally scalable and the contained
348  * number of temporal layers (also referred to as temporal sub-layer or
349  * sub-layer in ISO/IEC 23008-2) is equal to numTemporalLayers. Value 1
350  * indicates that the stream is not temporally scalable. Value 0 indicates
351  * that it is unknown whether the stream is temporally scalable.
352  */
353  vvcc->num_sublayers = FFMAX(vvcc->num_sublayers,
354  sps_max_sublayers_minus1 + 1);
355 
356  vvcc->chroma_format_idc = get_bits(gb, 2);
357  sps_log2_ctu_size_minus5 = get_bits(gb, 2);
358 
359  if (get_bits1(gb)) // sps_ptl_dpb_hrd_params_present_flag
360  vvcc_parse_ptl(gb, vvcc, 1, sps_max_sublayers_minus1);
361 
362  skip_bits1(gb); // sps_gdr_enabled_flag
363  if (get_bits(gb, 1)) // sps_ref_pic_resampling_enabled_flag
364  skip_bits1(gb); // sps_res_change_in_clvs_allowed_flag
365 
366  sps_pic_width_max_in_luma_samples = get_ue_golomb_long(gb);
367  vvcc->max_picture_width =
368  FFMAX(vvcc->max_picture_width, sps_pic_width_max_in_luma_samples);
369  sps_pic_height_max_in_luma_samples = get_ue_golomb_long(gb);
370  vvcc->max_picture_height =
371  FFMAX(vvcc->max_picture_height, sps_pic_height_max_in_luma_samples);
372 
373  if (get_bits1(gb)) {
374  get_ue_golomb_long(gb); // sps_conf_win_left_offset
375  get_ue_golomb_long(gb); // sps_conf_win_right_offset
376  get_ue_golomb_long(gb); // sps_conf_win_top_offset
377  get_ue_golomb_long(gb); // sps_conf_win_bottom_offset
378  }
379 
380  if (get_bits1(gb)) { // sps_subpic_info_present_flag
381  const unsigned int sps_num_subpics_minus1 = get_ue_golomb_long(gb);
382  const int ctb_log2_size_y = sps_log2_ctu_size_minus5 + 5;
383  const int ctb_size_y = 1 << ctb_log2_size_y;
384  const int tmp_width_val = AV_CEIL_RSHIFT(sps_pic_width_max_in_luma_samples, ctb_log2_size_y);
385  const int tmp_height_val = AV_CEIL_RSHIFT(sps_pic_height_max_in_luma_samples, ctb_log2_size_y);
386  const int wlen = av_ceil_log2(tmp_width_val);
387  const int hlen = av_ceil_log2(tmp_height_val);
388  if (sps_num_subpics_minus1 > 0) { // sps_num_subpics_minus1
389  sps_independent_subpics_flag = get_bits1(gb);
390  sps_subpic_same_size_flag = get_bits1(gb);
391  }
392  for (int i = 0; sps_num_subpics_minus1 > 0 && i <= sps_num_subpics_minus1; i++) {
393  if (!sps_subpic_same_size_flag || i == 0) {
394  if (i > 0 && sps_pic_width_max_in_luma_samples > ctb_size_y)
395  skip_bits(gb, wlen);
396  if (i > 0 && sps_pic_height_max_in_luma_samples > ctb_size_y)
397  skip_bits(gb, hlen);
398  if (i < sps_num_subpics_minus1 && sps_pic_width_max_in_luma_samples > ctb_size_y)
399  skip_bits(gb, wlen);
400  if (i < sps_num_subpics_minus1 && sps_pic_height_max_in_luma_samples > ctb_size_y)
401  skip_bits(gb, hlen);
402  }
403  if (!sps_independent_subpics_flag) {
404  skip_bits(gb, 2); // sps_subpic_treated_as_pic_flag && sps_loop_filter_across_subpic_enabled_flag
405  }
406  }
407  get_ue_golomb_long(gb); // sps_subpic_id_len_minus1
408  if (get_bits1(gb)) { // sps_subpic_id_mapping_explicitly_signalled_flag
409  if (get_bits1(gb)) // sps_subpic_id_mapping_present_flag
410  for (int i = 0; i <= sps_num_subpics_minus1; i++) {
411  skip_bits1(gb); // sps_subpic_id[i]
412  }
413  }
414  }
416 
417  /* nothing useful for vvcc past this point */
418  return 0;
419 }
420 
423 {
424 
425  // Nothing of importance to parse in PPS
426  /* nothing useful for vvcc past this point */
427  return 0;
428 }
429 
430 static void nal_unit_parse_header(GetBitContext *gb, uint8_t *nal_type)
431 {
432  /*
433  * forbidden_zero_bit u(1)
434  * nuh_reserved_zero_bit u(1)
435  * nuh_layer_id u(6)
436  */
437  skip_bits(gb, 8);
438  *nal_type = get_bits(gb, 5);
439 
440  /*
441  * nuh_temporal_id_plus1 u(3)
442  */
443  skip_bits(gb, 3);
444 }
445 
446 static int vvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
447  uint8_t nal_type, int ps_array_completeness,
449 {
450  int ret;
451  uint8_t index;
452  uint16_t num_nalus;
454 
455  for (index = 0; index < vvcc->num_of_arrays; index++)
456  if (vvcc->array[index].NAL_unit_type == nal_type)
457  break;
458 
459  if (index >= vvcc->num_of_arrays) {
460  uint8_t i;
461 
462  ret =
463  av_reallocp_array(&vvcc->array, index + 1,
464  sizeof(VVCCNALUnitArray));
465  if (ret < 0)
466  return ret;
467 
468  for (i = vvcc->num_of_arrays; i <= index; i++)
469  memset(&vvcc->array[i], 0, sizeof(VVCCNALUnitArray));
470  vvcc->num_of_arrays = index + 1;
471  }
472 
473  array = &vvcc->array[index];
474  num_nalus = array->num_nalus;
475 
476  ret = av_reallocp_array(&array->nal_unit, num_nalus + 1, sizeof(uint8_t *));
477  if (ret < 0)
478  return ret;
479 
480  ret =
481  av_reallocp_array(&array->nal_unit_length, num_nalus + 1,
482  sizeof(uint16_t));
483  if (ret < 0)
484  return ret;
485 
486  array->nal_unit[num_nalus] = nal_buf;
487  array->nal_unit_length[num_nalus] = nal_size;
488  array->NAL_unit_type = nal_type;
489  array->num_nalus++;
490 
491  /*
492  * When the sample entry name is 'vvc1', the following applies:
493  * • The value of array_completeness shall be equal to 1 for arrays of SPS,
494  * and PPS NAL units.
495  * • If a VVC bitstream includes DCI NAL unit(s), the value of
496  * array_completeness shall be equal to 1 for the array of DCI units.
497  * Otherwise, NAL_unit_type shall not indicate DCI NAL units.
498  * • If a VVC bitstream includes VPS NAL unit(s), the value of
499  * array_completeness shall be equal to 1 for the array of VPS NAL units.
500  * Otherwise, NAL_unit_type shall not indicate VPS NAL units.
501  * When the value of array_completeness is equal to 1 for an array of a
502  * particular NAL_unit_type value, NAL units of that NAL_unit_type value
503  * cannot be updated without causing a different sample entry to be used.
504  * When the sample entry name is 'vvi1', the value of array_completeness
505  * of at least one of the following arrays shall be equal to 0:
506  • The array of DCI NAL units, if present.
507  • The array of VPS NAL units, if present.
508  • The array of SPS NAL units
509  • The array of PPS NAL units.
510  */
511  if (nal_type == VVC_VPS_NUT || nal_type == VVC_SPS_NUT ||
512  nal_type == VVC_PPS_NUT || nal_type == VVC_DCI_NUT )
513  array->array_completeness = ps_array_completeness;
514 
515  return 0;
516 }
517 
518 static int vvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
519  int ps_array_completeness,
521 {
522  int ret = 0;
523  GetBitContext gbc;
524  uint8_t nal_type;
525  uint8_t *rbsp_buf;
526  uint32_t rbsp_size;
527 
528  rbsp_buf = ff_nal_unit_extract_rbsp(nal_buf, nal_size, &rbsp_size, 2);
529  if (!rbsp_buf) {
530  ret = AVERROR(ENOMEM);
531  goto end;
532  }
533 
534  ret = init_get_bits8(&gbc, rbsp_buf, rbsp_size);
535  if (ret < 0)
536  goto end;
537 
538  nal_unit_parse_header(&gbc, &nal_type);
539 
540  /*
541  * Note: only 'declarative' SEI messages are allowed in
542  * vvcc. Perhaps the SEI playload type should be checked
543  * and non-declarative SEI messages discarded?
544  */
545  switch (nal_type) {
546  case VVC_OPI_NUT:
547  case VVC_VPS_NUT:
548  case VVC_SPS_NUT:
549  case VVC_PPS_NUT:
550  case VVC_PREFIX_SEI_NUT:
551  case VVC_SUFFIX_SEI_NUT:
552  ret = vvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
553  ps_array_completeness, vvcc);
554  if (ret < 0)
555  goto end;
556  else if (nal_type == VVC_VPS_NUT)
557  ret = vvcc_parse_vps(&gbc, vvcc);
558  else if (nal_type == VVC_SPS_NUT)
559  ret = vvcc_parse_sps(&gbc, vvcc);
560  else if (nal_type == VVC_PPS_NUT)
561  ret = vvcc_parse_pps(&gbc, vvcc);
562  else if (nal_type == VVC_OPI_NUT) {
563  // not yet supported
564  }
565  if (ret < 0)
566  goto end;
567  break;
568  default:
570  goto end;
571  }
572 
573  end:
574  av_free(rbsp_buf);
575  return ret;
576 }
577 
579 {
580  memset(vvcc, 0, sizeof(VVCDecoderConfigurationRecord));
581  vvcc->lengthSizeMinusOne = 3; // 4 bytes
582 
583  vvcc->ptl.num_bytes_constraint_info = 1;
584 
585  vvcc->ptl_present_flag = 1;
586 }
587 
589 {
590  uint8_t i;
591 
592  for (i = 0; i < vvcc->num_of_arrays; i++) {
593  vvcc->array[i].num_nalus = 0;
594  av_freep(&vvcc->array[i].nal_unit);
595  av_freep(&vvcc->array[i].nal_unit_length);
596  }
597 
598  vvcc->num_of_arrays = 0;
599  av_freep(&vvcc->array);
600 }
601 
603 {
604  uint8_t i;
605  uint16_t j, vps_count = 0, sps_count = 0, pps_count = 0;
606  unsigned char *buf = NULL;
607  /*
608  * It's unclear how to properly compute these fields, so
609  * let's always set them to values meaning 'unspecified'.
610  */
611  vvcc->avg_frame_rate = 0;
612  vvcc->constant_frame_rate = 1;
613 
615  "lengthSizeMinusOne: %" PRIu8 "\n",
616  vvcc->lengthSizeMinusOne);
618  "ptl_present_flag: %" PRIu8 "\n",
619  vvcc->ptl_present_flag);
621  "ols_idx: %" PRIu16 "\n", vvcc->ols_idx);
623  "num_sublayers: %" PRIu8 "\n",
624  vvcc->num_sublayers);
626  "constant_frame_rate: %" PRIu8 "\n",
627  vvcc->constant_frame_rate);
629  "chroma_format_idc: %" PRIu8 "\n",
630  vvcc->chroma_format_idc);
631 
633  "bit_depth_minus8: %" PRIu8 "\n",
634  vvcc->bit_depth_minus8);
636  "num_bytes_constraint_info: %" PRIu8 "\n",
639  "general_profile_idc: %" PRIu8 "\n",
640  vvcc->ptl.general_profile_idc);
642  "general_tier_flag: %" PRIu8 "\n",
643  vvcc->ptl.general_tier_flag);
645  "general_level_idc: %" PRIu8 "\n",
646  vvcc->ptl.general_level_idc);
648  "ptl_frame_only_constraint_flag: %" PRIu8 "\n",
651  "ptl_multilayer_enabled_flag: %" PRIu8 "\n",
653  for (i = 0; i < vvcc->ptl.num_bytes_constraint_info; i++) {
655  "general_constraint_info[%d]: %" PRIu8 "\n", i,
656  vvcc->ptl.general_constraint_info[i]);
657  }
658 
659  for (i = 0; i < vvcc->num_sublayers - 1; i++) {
661  "ptl_sublayer_level_present_flag[%" PRIu8 "]: %" PRIu8 "\n", i,
664  "sublayer_level_idc[%" PRIu8 "]: %" PRIu8 "\n", i,
665  vvcc->ptl.sublayer_level_idc[i]);
666  }
667 
669  "num_sub_profiles: %" PRIu8 "\n",
670  vvcc->ptl.ptl_num_sub_profiles);
671 
672  for (i = 0; i < vvcc->ptl.ptl_num_sub_profiles; i++) {
674  "general_sub_profile_idc[%" PRIu8 "]: %" PRIx32 "\n", i,
675  vvcc->ptl.general_sub_profile_idc[i]);
676  }
677 
679  "max_picture_width: %" PRIu16 "\n",
680  vvcc->max_picture_width);
682  "max_picture_height: %" PRIu16 "\n",
683  vvcc->max_picture_height);
685  "avg_frame_rate: %" PRIu16 "\n",
686  vvcc->avg_frame_rate);
687 
689  "num_of_arrays: %" PRIu8 "\n",
690  vvcc->num_of_arrays);
691  for (i = 0; i < vvcc->num_of_arrays; i++) {
693  "array_completeness[%" PRIu8 "]: %" PRIu8 "\n", i,
694  vvcc->array[i].array_completeness);
696  "NAL_unit_type[%" PRIu8 "]: %" PRIu8 "\n", i,
697  vvcc->array[i].NAL_unit_type);
699  "num_nalus[%" PRIu8 "]: %" PRIu16 "\n", i,
700  vvcc->array[i].num_nalus);
701  for (j = 0; j < vvcc->array[i].num_nalus; j++)
703  "nal_unit_length[%" PRIu8 "][%" PRIu16 "]: %"
704  PRIu16 "\n", i, j, vvcc->array[i].nal_unit_length[j]);
705  }
706 
707  /*
708  * We need at least one of each: VPS and SPS.
709  */
710  for (i = 0; i < vvcc->num_of_arrays; i++)
711  switch (vvcc->array[i].NAL_unit_type) {
712  case VVC_VPS_NUT:
713  vps_count += vvcc->array[i].num_nalus;
714  break;
715  case VVC_SPS_NUT:
716  sps_count += vvcc->array[i].num_nalus;
717  break;
718  case VVC_PPS_NUT:
719  pps_count += vvcc->array[i].num_nalus;
720  break;
721  default:
722  break;
723  }
724 
725  if (vps_count > VVC_MAX_VPS_COUNT)
726  return AVERROR_INVALIDDATA;
727  if (!sps_count || sps_count > VVC_MAX_SPS_COUNT)
728  return AVERROR_INVALIDDATA;
729  if (!pps_count || pps_count > VVC_MAX_PPS_COUNT)
730  return AVERROR_INVALIDDATA;
731 
732  /* bit(5) reserved = ‘11111’b;
733  unsigned int (2) LengthSizeMinusOne
734  unsigned int (1) ptl_present_flag */
735  avio_w8(pb, vvcc->lengthSizeMinusOne << 1 | vvcc->ptl_present_flag | 0xf8);
736 
737  if (vvcc->ptl_present_flag) {
738  /*
739  * unsigned int(9) ols_idx;
740  * unsigned int(3) num_sublayers;
741  * unsigned int(2) constant_frame_rate;
742  * unsigned int(2) chroma_format_idc; */
743  avio_wb16(pb,
744  vvcc->ols_idx << 7 | vvcc->num_sublayers << 4 | vvcc->
745  constant_frame_rate << 2 | vvcc->chroma_format_idc);
746 
747  /* unsigned int(3) bit_depth_minus8;
748  bit(5) reserved = ‘11111’b; */
749  avio_w8(pb, vvcc->bit_depth_minus8 << 5 | 0x1f);
750 
751  //VVCPTLRecord
752 
753  /* bit(2) reserved = ‘00’b;
754  unsigned int (6) num_bytes_constraint_info */
755  avio_w8(pb, vvcc->ptl.num_bytes_constraint_info & 0x3f);
756 
757  /* unsigned int (7) general_profile_idc
758  unsigned int (1) general_tier_flag */
759  avio_w8(pb,
760  vvcc->ptl.general_profile_idc << 1 | vvcc->ptl.general_tier_flag);
761 
762  /* unsigned int (8) general_level_idc */
763  avio_w8(pb, vvcc->ptl.general_level_idc);
764 
765  /*
766  * unsigned int (1) ptl_frame_only_constraint_flag
767  * unsigned int (1) ptl_multilayer_enabled_flag
768  * unsigned int (8*num_bytes_constraint_info -2) general_constraint_info */
769  buf =
770  (unsigned char *) malloc(sizeof(unsigned char) *
772  *buf = vvcc->ptl.ptl_frame_only_constraint_flag << vvcc->ptl.
773  num_bytes_constraint_info * 8 - 1 | vvcc->ptl.
774  ptl_multilayer_enabled_flag << vvcc->ptl.num_bytes_constraint_info *
775  8 - 2 | *vvcc->ptl.general_constraint_info >> 2;
776  avio_write(pb, buf, vvcc->ptl.num_bytes_constraint_info);
777  free(buf);
778 
779  if (vvcc->num_sublayers > 1) {
780  uint8_t ptl_sublayer_level_present_flags = 0;
781  for (int i = vvcc->num_sublayers - 2; i >= 0; i--) {
782  ptl_sublayer_level_present_flags =
783  (ptl_sublayer_level_present_flags << 1 | vvcc->ptl.
784  ptl_sublayer_level_present_flag[i]);
785  }
786  avio_w8(pb, ptl_sublayer_level_present_flags);
787  }
788 
789  for (int i = vvcc->num_sublayers - 2; i >= 0; i--) {
791  avio_w8(pb, vvcc->ptl.sublayer_level_idc[i]);
792  }
793 
794  /* unsigned int(8) num_sub_profiles; */
795  avio_w8(pb, vvcc->ptl.ptl_num_sub_profiles);
796 
797  for (int j = 0; j < vvcc->ptl.ptl_num_sub_profiles; j++) {
798  /* unsigned int(32) general_sub_profile_idc[j]; */
799  avio_wb32(pb, vvcc->ptl.general_sub_profile_idc[j]);
800  }
801 
802  //End of VvcPTLRecord
803 
804  /*
805  * unsigned int(16) max_picture_width;*/
806  avio_wb16(pb, vvcc->max_picture_width);
807 
808  /*
809  * unsigned int(16) max_picture_height;*/
810  avio_wb16(pb, vvcc->max_picture_height);
811 
812  /*
813  * unsigned int(16) avg_frame_rate; */
814  avio_wb16(pb, vvcc->avg_frame_rate);
815  }
816 
817  /* unsigned int(8) num_of_arrays; */
818  avio_w8(pb, vvcc->num_of_arrays);
819 
820  for (i = 0; i < vvcc->num_of_arrays; i++) {
821  /*
822  * bit(1) array_completeness;
823  * unsigned int(2) reserved = 0;
824  * unsigned int(5) NAL_unit_type;
825  */
826  avio_w8(pb, vvcc->array[i].array_completeness << 7 |
827  vvcc->array[i].NAL_unit_type & 0x1f);
828  /* unsigned int(16) num_nalus; */
829  if (vvcc->array[i].NAL_unit_type != VVC_DCI_NUT &&
830  vvcc->array[i].NAL_unit_type != VVC_OPI_NUT)
831  avio_wb16(pb, vvcc->array[i].num_nalus);
832  for (j = 0; j < vvcc->array[i].num_nalus; j++) {
833  /* unsigned int(16) nal_unit_length; */
834  avio_wb16(pb, vvcc->array[i].nal_unit_length[j]);
835 
836  /* bit(8*nal_unit_length) nal_unit; */
837  avio_write(pb, vvcc->array[i].nal_unit[j],
838  vvcc->array[i].nal_unit_length[j]);
839  }
840  }
841 
842  return 0;
843 }
844 
845 int ff_vvc_annexb2mp4(AVIOContext *pb, const uint8_t *buf_in,
846  int size, int filter_ps, int *ps_count)
847 {
848  int num_ps = 0, ret = 0;
849  uint8_t *buf, *end, *start = NULL;
850 
851  if (!filter_ps) {
852  ret = ff_avc_parse_nal_units(pb, buf_in, size);
853  goto end;
854  }
855 
856  ret = ff_avc_parse_nal_units_buf(buf_in, &start, &size);
857  if (ret < 0)
858  goto end;
859 
860  ret = 0;
861  buf = start;
862  end = start + size;
863 
864  while (end - buf > 4) {
865  uint32_t len = FFMIN(AV_RB32(buf), end - buf - 4);
866  uint8_t type = (buf[5] >> 3);
867 
868  buf += 4;
869 
870  switch (type) {
871  case VVC_VPS_NUT:
872  case VVC_SPS_NUT:
873  case VVC_PPS_NUT:
874  num_ps++;
875  break;
876  default:
877  ret += 4 + len;
878  avio_wb32(pb, len);
879  avio_write(pb, buf, len);
880  break;
881  }
882 
883  buf += len;
884  }
885 
886  end:
887  av_free(start);
888  if (ps_count)
889  *ps_count = num_ps;
890  return ret;
891 }
892 
893 int ff_vvc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out,
894  int *size, int filter_ps, int *ps_count)
895 {
896  AVIOContext *pb;
897  int ret;
898 
899  ret = avio_open_dyn_buf(&pb);
900  if (ret < 0)
901  return ret;
902 
903  ret = ff_vvc_annexb2mp4(pb, buf_in, *size, filter_ps, ps_count);
904  if (ret < 0) {
905  ffio_free_dyn_buf(&pb);
906  return ret;
907  }
908 
909  *size = avio_close_dyn_buf(pb, buf_out);
910 
911  return 0;
912 }
913 
914 int ff_isom_write_vvcc(AVIOContext *pb, const uint8_t *data,
915  int size, int ps_array_completeness)
916 {
918  uint8_t *buf, *end, *start;
919  int ret;
920 
921  if (size < 6) {
922  /* We can't write a valid vvcc from the provided data */
923  return AVERROR_INVALIDDATA;
924  } else if ((*data & 0xf8) == 0xf8) {
925  /* Data is already vvcc-formatted */
926  avio_write(pb, data, size);
927  return 0;
928  } else if (!(AV_RB24(data) == 1 || AV_RB32(data) == 1)) {
929  /* Not a valid Annex B start code prefix */
930  return AVERROR_INVALIDDATA;
931  }
932 
934  if (ret < 0)
935  return ret;
936 
937  vvcc_init(&vvcc);
938 
939  buf = start;
940  end = start + size;
941 
942  while (end - buf > 4) {
943  uint32_t len = FFMIN(AV_RB32(buf), end - buf - 4);
944  uint8_t type = (buf[5] >> 3);
945 
946  buf += 4;
947 
948  switch (type) {
949  case VVC_OPI_NUT:
950  case VVC_VPS_NUT:
951  case VVC_SPS_NUT:
952  case VVC_PPS_NUT:
953  case VVC_PREFIX_SEI_NUT:
954  case VVC_SUFFIX_SEI_NUT:
955  ret = vvcc_add_nal_unit(buf, len, ps_array_completeness, &vvcc);
956  if (ret < 0)
957  goto end;
958  break;
959  default:
960  break;
961  }
962 
963  buf += len;
964  }
965 
966  ret = vvcc_write(pb, &vvcc);
967 
968  end:
969  vvcc_close(&vvcc);
970  av_free(start);
971  return ret;
972 }
VVC_MAX_SUB_PROFILES
@ VVC_MAX_SUB_PROFILES
Definition: vvc.h:102
VVCCProfileTierLevel::ptl_frame_only_constraint_flag
uint8_t ptl_frame_only_constraint_flag
Definition: vvc.c:75
VVCCNALUnitArray::nal_unit
uint8_t ** nal_unit
Definition: vvc.c:38
VVC_MAX_PTLS
@ VVC_MAX_PTLS
Definition: vvc.h:89
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
H265RawProfileTierLevel::general_level_idc
uint8_t general_level_idc
Definition: cbs_h265.h:60
VVC_DCI_NUT
@ VVC_DCI_NUT
Definition: vvc.h:42
get_bits_long
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:421
ff_vvc_annexb2mp4
int ff_vvc_annexb2mp4(AVIOContext *pb, const uint8_t *buf_in, int size, int filter_ps, int *ps_count)
Writes Annex B formatted H.266/VVC NAL units to the provided AVIOContext.
Definition: vvc.c:845
VVCCProfileTierLevel::ptl_num_sub_profiles
uint8_t ptl_num_sub_profiles
Definition: vvc.c:84
ff_isom_write_vvcc
int ff_isom_write_vvcc(AVIOContext *pb, const uint8_t *data, int size, int ps_array_completeness)
Writes H.266/VVC extradata (parameter sets, declarative SEI NAL units) to the provided AVIOContext.
Definition: vvc.c:914
data
const char data[16]
Definition: mxf.c:148
VVCPTLRecord::ptl_num_sub_profiles
uint8_t ptl_num_sub_profiles
Definition: vvc.c:51
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
VVCPTLRecord::general_profile_idc
uint8_t general_profile_idc
Definition: vvc.c:43
vvcc_close
static void vvcc_close(VVCDecoderConfigurationRecord *vvcc)
Definition: vvc.c:588
VVCPTLRecord::general_constraint_info
uint8_t general_constraint_info[9]
Definition: vvc.c:48
VVCDecoderConfigurationRecord::constant_frame_rate
uint8_t constant_frame_rate
Definition: vvc.c:60
VVCDecoderConfigurationRecord::avg_frame_rate
uint16_t avg_frame_rate
Definition: vvc.c:66
vvcc_parse_sps
static int vvcc_parse_sps(GetBitContext *gb, VVCDecoderConfigurationRecord *vvcc)
Definition: vvc.c:334
VVCCProfileTierLevel::gci_present_flag
uint8_t gci_present_flag
Definition: vvc.c:78
skip_bits
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:381
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:335
av_ceil_log2
#define av_ceil_log2
Definition: common.h:96
VVC_MAX_PPS_COUNT
@ VVC_MAX_PPS_COUNT
Definition: vvc.h:99
GetBitContext
Definition: get_bits.h:108
VVCCNALUnitArray::NAL_unit_type
uint8_t NAL_unit_type
Definition: vvc.c:35
VVCPTLRecord::general_level_idc
uint8_t general_level_idc
Definition: vvc.c:45
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
VVCDecoderConfigurationRecord::array
VVCCNALUnitArray * array
Definition: vvc.c:68
VVCDecoderConfigurationRecord::bit_depth_minus8
uint8_t bit_depth_minus8
Definition: vvc.c:62
VVCCProfileTierLevel::gci_general_constraints
uint8_t gci_general_constraints[9]
Definition: vvc.c:79
avio_close_dyn_buf
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
Definition: aviobuf.c:1407
VVCDecoderConfigurationRecord
Definition: vvc.c:55
VVCCProfileTierLevel::sublayer_level_idc
uint8_t sublayer_level_idc[VVC_MAX_SUBLAYERS - 1]
Definition: vvc.c:83
vvcc_parse_ptl
static void vvcc_parse_ptl(GetBitContext *gb, VVCDecoderConfigurationRecord *vvcc, unsigned int profileTierPresentFlag, unsigned int max_sub_layers_minus1)
Definition: vvc.c:183
AV_LOG_TRACE
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:206
init_get_bits8
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:545
VVCPTLRecord::sublayer_level_idc
uint8_t sublayer_level_idc[VVC_MAX_SUBLAYERS - 1]
Definition: vvc.c:50
ptl
const H265RawProfileTierLevel * ptl
Definition: h265_levels.c:170
avio_open_dyn_buf
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
Definition: aviobuf.c:1362
intreadwrite.h
VVCCNALUnitArray
Definition: vvc.c:33
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:59
VVCDecoderConfigurationRecord::num_of_arrays
uint8_t num_of_arrays
Definition: vvc.c:67
ff_nal_unit_extract_rbsp
uint8_t * ff_nal_unit_extract_rbsp(const uint8_t *src, uint32_t src_len, uint32_t *dst_len, int header_len)
Definition: avc.c:303
VVCCProfileTierLevel::profile_idc
uint8_t profile_idc
Definition: vvc.c:72
vvcc_parse_vps
static int vvcc_parse_vps(GetBitContext *gb, VVCDecoderConfigurationRecord *vvcc)
Definition: vvc.c:235
get_bits.h
VVCCProfileTierLevel::ptl_multilayer_enabled_flag
uint8_t ptl_multilayer_enabled_flag
Definition: vvc.c:76
VVCDecoderConfigurationRecord::chroma_format_idc
uint8_t chroma_format_idc
Definition: vvc.c:61
NULL
#define NULL
Definition: coverity.c:32
VVCCNALUnitArray::nal_unit_length
uint16_t * nal_unit_length
Definition: vvc.c:37
VVC_PREFIX_SEI_NUT
@ VVC_PREFIX_SEI_NUT
Definition: vvc.h:52
VVCCProfileTierLevel
Definition: vvc.c:71
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:388
avc.h
VVCDecoderConfigurationRecord::num_sublayers
uint8_t num_sublayers
Definition: vvc.c:59
ff_avc_parse_nal_units_buf
int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
Definition: avc.c:129
avio_w8
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:179
index
int index
Definition: gxfenc.c:90
AVIOContext
Bytestream IO Context.
Definition: avio.h:160
ff_avc_parse_nal_units
int ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size)
Definition: avc.c:109
VVC_MAX_VPS_COUNT
@ VVC_MAX_VPS_COUNT
Definition: vvc.h:95
VVCCNALUnitArray::num_nalus
uint16_t num_nalus
Definition: vvc.c:36
VVCDecoderConfigurationRecord::ols_idx
uint16_t ols_idx
Definition: vvc.c:58
VVC_VPS_NUT
@ VVC_VPS_NUT
Definition: vvc.h:43
ff_vvc_annexb2mp4_buf
int ff_vvc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out, int *size, int filter_ps, int *ps_count)
Writes Annex B formatted H.266/VVC NAL units to a data buffer.
Definition: vvc.c:893
size
int size
Definition: twinvq_data.h:10344
avio.h
vvcc_parse_pps
static int vvcc_parse_pps(GetBitContext *gb, VVCDecoderConfigurationRecord *vvcc)
Definition: vvc.c:421
AV_RB32
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_RB32
Definition: bytestream.h:96
GetBitContext::index
int index
Definition: get_bits.h:110
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:201
avio_wb32
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:365
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:225
skip_bits1
static void skip_bits1(GetBitContext *s)
Definition: get_bits.h:413
VVC_SPS_NUT
@ VVC_SPS_NUT
Definition: vvc.h:44
vvc.h
VVCCProfileTierLevel::general_level_idc
uint8_t general_level_idc
Definition: vvc.c:74
VVCDecoderConfigurationRecord::lengthSizeMinusOne
uint8_t lengthSizeMinusOne
Definition: vvc.c:56
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
avio_internal.h
VVC_SUFFIX_SEI_NUT
@ VVC_SUFFIX_SEI_NUT
Definition: vvc.h:53
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
VVCPTLRecord
Definition: vvc.c:41
VVCCProfileTierLevel::gci_num_reserved_bits
uint8_t gci_num_reserved_bits
Definition: vvc.c:80
len
int len
Definition: vorbis_enc_data.h:426
VVCDecoderConfigurationRecord::ptl_present_flag
uint8_t ptl_present_flag
Definition: vvc.c:57
VVCCProfileTierLevel::ptl_sublayer_level_present_flag
uint8_t ptl_sublayer_level_present_flag[VVC_MAX_SUBLAYERS - 1]
Definition: vvc.c:82
array
static int array[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:111
ffio_free_dyn_buf
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
Definition: aviobuf.c:1435
ret
ret
Definition: filter_design.txt:187
VVCPTLRecord::general_sub_profile_idc
uint32_t general_sub_profile_idc[VVC_MAX_SUB_PROFILES]
Definition: vvc.c:52
vvcc_update_ptl
static void vvcc_update_ptl(VVCDecoderConfigurationRecord *vvcc, VVCCProfileTierLevel *ptl)
Definition: vvc.c:88
vvcc_array_add_nal_unit
static int vvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, uint8_t nal_type, int ps_array_completeness, VVCDecoderConfigurationRecord *vvcc)
Definition: vvc.c:446
VVC_MAX_SUBLAYERS
@ VVC_MAX_SUBLAYERS
Definition: vvc.h:83
VVCPTLRecord::num_bytes_constraint_info
uint8_t num_bytes_constraint_info
Definition: vvc.c:42
VVCCProfileTierLevel::tier_flag
uint8_t tier_flag
Definition: vvc.c:73
VVC_PPS_NUT
@ VVC_PPS_NUT
Definition: vvc.h:45
VVCDecoderConfigurationRecord::ptl
VVCPTLRecord ptl
Definition: vvc.c:63
VVCDecoderConfigurationRecord::max_picture_height
uint16_t max_picture_height
Definition: vvc.c:65
vvcc_init
static void vvcc_init(VVCDecoderConfigurationRecord *vvcc)
Definition: vvc.c:578
VVCCProfileTierLevel::general_sub_profile_idc
uint32_t general_sub_profile_idc[VVC_MAX_SUB_PROFILES]
Definition: vvc.c:85
vvcc_write
static int vvcc_write(AVIOContext *pb, VVCDecoderConfigurationRecord *vvcc)
Definition: vvc.c:602
VVC_OPI_NUT
@ VVC_OPI_NUT
Definition: vvc.h:41
mem.h
nal_unit_parse_header
static void nal_unit_parse_header(GetBitContext *gb, uint8_t *nal_type)
Definition: vvc.c:430
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
VVCPTLRecord::ptl_sublayer_level_present_flag
uint8_t ptl_sublayer_level_present_flag[VVC_MAX_SUBLAYERS - 1]
Definition: vvc.c:49
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
VVCDecoderConfigurationRecord::max_picture_width
uint16_t max_picture_width
Definition: vvc.c:64
avio_wb16
void avio_wb16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:443
VVCPTLRecord::general_tier_flag
uint8_t general_tier_flag
Definition: vvc.c:44
VVCCNALUnitArray::array_completeness
uint8_t array_completeness
Definition: vvc.c:34
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
AV_RB24
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_RB24
Definition: bytestream.h:97
VVCPTLRecord::ptl_multilayer_enabled_flag
uint8_t ptl_multilayer_enabled_flag
Definition: vvc.c:47
VVC_MAX_SPS_COUNT
@ VVC_MAX_SPS_COUNT
Definition: vvc.h:97
VVCPTLRecord::ptl_frame_only_constraint_flag
uint8_t ptl_frame_only_constraint_flag
Definition: vvc.c:46
vvcc_add_nal_unit
static int vvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, int ps_array_completeness, VVCDecoderConfigurationRecord *vvcc)
Definition: vvc.c:518