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