FFmpeg  4.4.9
hevc.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Tim Walker <tdskywalker@gmail.com>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include "libavcodec/avcodec.h"
22 #include "libavcodec/get_bits.h"
23 #include "libavcodec/golomb.h"
24 #include "libavcodec/hevc.h"
25 #include "libavutil/intreadwrite.h"
26 #include "avc.h"
27 #include "avio.h"
28 #include "avio_internal.h"
29 #include "hevc.h"
30 
31 #define MAX_SPATIAL_SEGMENTATION 4096 // max. value of u(12) field
32 
33 enum {
39  NB_ARRAYS
40 };
41 
42 typedef struct HVCCNALUnitArray {
45  uint16_t numNalus;
46  uint16_t *nalUnitLength;
49 
63  uint16_t avgFrameRate;
71 
72 typedef struct HVCCProfileTierLevel {
80 
83 {
84  /*
85  * The value of general_profile_space in all the parameter sets must be
86  * identical.
87  */
88  hvcc->general_profile_space = ptl->profile_space;
89 
90  /*
91  * The level indication general_level_idc must indicate a level of
92  * capability equal to or greater than the highest level indicated for the
93  * highest tier in all the parameter sets.
94  */
95  if (hvcc->general_tier_flag < ptl->tier_flag)
96  hvcc->general_level_idc = ptl->level_idc;
97  else
98  hvcc->general_level_idc = FFMAX(hvcc->general_level_idc, ptl->level_idc);
99 
100  /*
101  * The tier indication general_tier_flag must indicate a tier equal to or
102  * greater than the highest tier indicated in all the parameter sets.
103  */
104  hvcc->general_tier_flag = FFMAX(hvcc->general_tier_flag, ptl->tier_flag);
105 
106  /*
107  * The profile indication general_profile_idc must indicate a profile to
108  * which the stream associated with this configuration record conforms.
109  *
110  * If the sequence parameter sets are marked with different profiles, then
111  * the stream may need examination to determine which profile, if any, the
112  * entire stream conforms to. If the entire stream is not examined, or the
113  * examination reveals that there is no profile to which the entire stream
114  * conforms, then the entire stream must be split into two or more
115  * sub-streams with separate configuration records in which these rules can
116  * be met.
117  *
118  * Note: set the profile to the highest value for the sake of simplicity.
119  */
120  hvcc->general_profile_idc = FFMAX(hvcc->general_profile_idc, ptl->profile_idc);
121 
122  /*
123  * Each bit in general_profile_compatibility_flags may only be set if all
124  * the parameter sets set that bit.
125  */
126  hvcc->general_profile_compatibility_flags &= ptl->profile_compatibility_flags;
127 
128  /*
129  * Each bit in general_constraint_indicator_flags may only be set if all
130  * the parameter sets set that bit.
131  */
132  hvcc->general_constraint_indicator_flags &= ptl->constraint_indicator_flags;
133 }
134 
137  unsigned int max_sub_layers_minus1)
138 {
139  unsigned int i;
140  HVCCProfileTierLevel general_ptl;
141  uint8_t sub_layer_profile_present_flag[HEVC_MAX_SUB_LAYERS];
142  uint8_t sub_layer_level_present_flag[HEVC_MAX_SUB_LAYERS];
143 
144  general_ptl.profile_space = get_bits(gb, 2);
145  general_ptl.tier_flag = get_bits1(gb);
146  general_ptl.profile_idc = get_bits(gb, 5);
147  general_ptl.profile_compatibility_flags = get_bits_long(gb, 32);
148  general_ptl.constraint_indicator_flags = get_bits64(gb, 48);
149  general_ptl.level_idc = get_bits(gb, 8);
150  hvcc_update_ptl(hvcc, &general_ptl);
151 
152  for (i = 0; i < max_sub_layers_minus1; i++) {
153  sub_layer_profile_present_flag[i] = get_bits1(gb);
154  sub_layer_level_present_flag[i] = get_bits1(gb);
155  }
156 
157  if (max_sub_layers_minus1 > 0)
158  for (i = max_sub_layers_minus1; i < 8; i++)
159  skip_bits(gb, 2); // reserved_zero_2bits[i]
160 
161  for (i = 0; i < max_sub_layers_minus1; i++) {
162  if (sub_layer_profile_present_flag[i]) {
163  /*
164  * sub_layer_profile_space[i] u(2)
165  * sub_layer_tier_flag[i] u(1)
166  * sub_layer_profile_idc[i] u(5)
167  * sub_layer_profile_compatibility_flag[i][0..31] u(32)
168  * sub_layer_progressive_source_flag[i] u(1)
169  * sub_layer_interlaced_source_flag[i] u(1)
170  * sub_layer_non_packed_constraint_flag[i] u(1)
171  * sub_layer_frame_only_constraint_flag[i] u(1)
172  * sub_layer_reserved_zero_44bits[i] u(44)
173  */
174  skip_bits_long(gb, 32);
175  skip_bits_long(gb, 32);
176  skip_bits (gb, 24);
177  }
178 
179  if (sub_layer_level_present_flag[i])
180  skip_bits(gb, 8);
181  }
182 }
183 
185  unsigned int cpb_cnt_minus1,
186  uint8_t sub_pic_hrd_params_present_flag)
187 {
188  unsigned int i;
189 
190  for (i = 0; i <= cpb_cnt_minus1; i++) {
191  get_ue_golomb_long(gb); // bit_rate_value_minus1
192  get_ue_golomb_long(gb); // cpb_size_value_minus1
193 
194  if (sub_pic_hrd_params_present_flag) {
195  get_ue_golomb_long(gb); // cpb_size_du_value_minus1
196  get_ue_golomb_long(gb); // bit_rate_du_value_minus1
197  }
198 
199  skip_bits1(gb); // cbr_flag
200  }
201 }
202 
203 static int skip_hrd_parameters(GetBitContext *gb, uint8_t cprms_present_flag,
204  unsigned int max_sub_layers_minus1)
205 {
206  unsigned int i;
207  uint8_t sub_pic_hrd_params_present_flag = 0;
208  uint8_t nal_hrd_parameters_present_flag = 0;
209  uint8_t vcl_hrd_parameters_present_flag = 0;
210 
211  if (cprms_present_flag) {
212  nal_hrd_parameters_present_flag = get_bits1(gb);
213  vcl_hrd_parameters_present_flag = get_bits1(gb);
214 
215  if (nal_hrd_parameters_present_flag ||
216  vcl_hrd_parameters_present_flag) {
217  sub_pic_hrd_params_present_flag = get_bits1(gb);
218 
219  if (sub_pic_hrd_params_present_flag)
220  /*
221  * tick_divisor_minus2 u(8)
222  * du_cpb_removal_delay_increment_length_minus1 u(5)
223  * sub_pic_cpb_params_in_pic_timing_sei_flag u(1)
224  * dpb_output_delay_du_length_minus1 u(5)
225  */
226  skip_bits(gb, 19);
227 
228  /*
229  * bit_rate_scale u(4)
230  * cpb_size_scale u(4)
231  */
232  skip_bits(gb, 8);
233 
234  if (sub_pic_hrd_params_present_flag)
235  skip_bits(gb, 4); // cpb_size_du_scale
236 
237  /*
238  * initial_cpb_removal_delay_length_minus1 u(5)
239  * au_cpb_removal_delay_length_minus1 u(5)
240  * dpb_output_delay_length_minus1 u(5)
241  */
242  skip_bits(gb, 15);
243  }
244  }
245 
246  for (i = 0; i <= max_sub_layers_minus1; i++) {
247  unsigned int cpb_cnt_minus1 = 0;
248  uint8_t low_delay_hrd_flag = 0;
249  uint8_t fixed_pic_rate_within_cvs_flag = 0;
250  uint8_t fixed_pic_rate_general_flag = get_bits1(gb);
251 
252  if (!fixed_pic_rate_general_flag)
253  fixed_pic_rate_within_cvs_flag = get_bits1(gb);
254 
255  if (fixed_pic_rate_within_cvs_flag)
256  get_ue_golomb_long(gb); // elemental_duration_in_tc_minus1
257  else
258  low_delay_hrd_flag = get_bits1(gb);
259 
260  if (!low_delay_hrd_flag) {
261  cpb_cnt_minus1 = get_ue_golomb_long(gb);
262  if (cpb_cnt_minus1 > 31)
263  return AVERROR_INVALIDDATA;
264  }
265 
266  if (nal_hrd_parameters_present_flag)
267  skip_sub_layer_hrd_parameters(gb, cpb_cnt_minus1,
268  sub_pic_hrd_params_present_flag);
269 
270  if (vcl_hrd_parameters_present_flag)
271  skip_sub_layer_hrd_parameters(gb, cpb_cnt_minus1,
272  sub_pic_hrd_params_present_flag);
273  }
274 
275  return 0;
276 }
277 
279 {
280  skip_bits_long(gb, 32); // num_units_in_tick
281  skip_bits_long(gb, 32); // time_scale
282 
283  if (get_bits1(gb)) // poc_proportional_to_timing_flag
284  get_ue_golomb_long(gb); // num_ticks_poc_diff_one_minus1
285 }
286 
289  unsigned int max_sub_layers_minus1)
290 {
291  unsigned int min_spatial_segmentation_idc;
292 
293  if (get_bits1(gb)) // aspect_ratio_info_present_flag
294  if (get_bits(gb, 8) == 255) // aspect_ratio_idc
295  skip_bits_long(gb, 32); // sar_width u(16), sar_height u(16)
296 
297  if (get_bits1(gb)) // overscan_info_present_flag
298  skip_bits1(gb); // overscan_appropriate_flag
299 
300  if (get_bits1(gb)) { // video_signal_type_present_flag
301  skip_bits(gb, 4); // video_format u(3), video_full_range_flag u(1)
302 
303  if (get_bits1(gb)) // colour_description_present_flag
304  /*
305  * colour_primaries u(8)
306  * transfer_characteristics u(8)
307  * matrix_coeffs u(8)
308  */
309  skip_bits(gb, 24);
310  }
311 
312  if (get_bits1(gb)) { // chroma_loc_info_present_flag
313  get_ue_golomb_long(gb); // chroma_sample_loc_type_top_field
314  get_ue_golomb_long(gb); // chroma_sample_loc_type_bottom_field
315  }
316 
317  /*
318  * neutral_chroma_indication_flag u(1)
319  * field_seq_flag u(1)
320  * frame_field_info_present_flag u(1)
321  */
322  skip_bits(gb, 3);
323 
324  if (get_bits1(gb)) { // default_display_window_flag
325  get_ue_golomb_long(gb); // def_disp_win_left_offset
326  get_ue_golomb_long(gb); // def_disp_win_right_offset
327  get_ue_golomb_long(gb); // def_disp_win_top_offset
328  get_ue_golomb_long(gb); // def_disp_win_bottom_offset
329  }
330 
331  if (get_bits1(gb)) { // vui_timing_info_present_flag
332  skip_timing_info(gb);
333 
334  if (get_bits1(gb)) // vui_hrd_parameters_present_flag
335  skip_hrd_parameters(gb, 1, max_sub_layers_minus1);
336  }
337 
338  if (get_bits1(gb)) { // bitstream_restriction_flag
339  /*
340  * tiles_fixed_structure_flag u(1)
341  * motion_vectors_over_pic_boundaries_flag u(1)
342  * restricted_ref_pic_lists_flag u(1)
343  */
344  skip_bits(gb, 3);
345 
346  min_spatial_segmentation_idc = get_ue_golomb_long(gb);
347 
348  /*
349  * unsigned int(12) min_spatial_segmentation_idc;
350  *
351  * The min_spatial_segmentation_idc indication must indicate a level of
352  * spatial segmentation equal to or less than the lowest level of
353  * spatial segmentation indicated in all the parameter sets.
354  */
356  min_spatial_segmentation_idc);
357 
358  get_ue_golomb_long(gb); // max_bytes_per_pic_denom
359  get_ue_golomb_long(gb); // max_bits_per_min_cu_denom
360  get_ue_golomb_long(gb); // log2_max_mv_length_horizontal
361  get_ue_golomb_long(gb); // log2_max_mv_length_vertical
362  }
363 }
364 
366 {
367  get_ue_golomb_long(gb); // max_dec_pic_buffering_minus1
368  get_ue_golomb_long(gb); // max_num_reorder_pics
369  get_ue_golomb_long(gb); // max_latency_increase_plus1
370 }
371 
374 {
375  unsigned int vps_max_sub_layers_minus1;
376 
377  /*
378  * vps_video_parameter_set_id u(4)
379  * vps_reserved_three_2bits u(2)
380  * vps_max_layers_minus1 u(6)
381  */
382  skip_bits(gb, 12);
383 
384  vps_max_sub_layers_minus1 = get_bits(gb, 3);
385 
386  /*
387  * numTemporalLayers greater than 1 indicates that the stream to which this
388  * configuration record applies is temporally scalable and the contained
389  * number of temporal layers (also referred to as temporal sub-layer or
390  * sub-layer in ISO/IEC 23008-2) is equal to numTemporalLayers. Value 1
391  * indicates that the stream is not temporally scalable. Value 0 indicates
392  * that it is unknown whether the stream is temporally scalable.
393  */
395  vps_max_sub_layers_minus1 + 1);
396 
397  /*
398  * vps_temporal_id_nesting_flag u(1)
399  * vps_reserved_0xffff_16bits u(16)
400  */
401  skip_bits(gb, 17);
402 
403  hvcc_parse_ptl(gb, hvcc, vps_max_sub_layers_minus1);
404 
405  /* nothing useful for hvcC past this point */
406  return 0;
407 }
408 
410 {
411  int i, j, k, num_coeffs;
412 
413  for (i = 0; i < 4; i++)
414  for (j = 0; j < (i == 3 ? 2 : 6); j++)
415  if (!get_bits1(gb)) // scaling_list_pred_mode_flag[i][j]
416  get_ue_golomb_long(gb); // scaling_list_pred_matrix_id_delta[i][j]
417  else {
418  num_coeffs = FFMIN(64, 1 << (4 + (i << 1)));
419 
420  if (i > 1)
421  get_se_golomb_long(gb); // scaling_list_dc_coef_minus8[i-2][j]
422 
423  for (k = 0; k < num_coeffs; k++)
424  get_se_golomb_long(gb); // scaling_list_delta_coef
425  }
426 }
427 
428 static int parse_rps(GetBitContext *gb, unsigned int rps_idx,
429  unsigned int num_rps,
430  unsigned int num_delta_pocs[HEVC_MAX_SHORT_TERM_REF_PIC_SETS])
431 {
432  unsigned int i;
433 
434  if (rps_idx && get_bits1(gb)) { // inter_ref_pic_set_prediction_flag
435  /* this should only happen for slice headers, and this isn't one */
436  if (rps_idx >= num_rps)
437  return AVERROR_INVALIDDATA;
438 
439  skip_bits1 (gb); // delta_rps_sign
440  get_ue_golomb_long(gb); // abs_delta_rps_minus1
441 
442  num_delta_pocs[rps_idx] = 0;
443 
444  /*
445  * From libavcodec/hevc_ps.c:
446  *
447  * if (is_slice_header) {
448  * //foo
449  * } else
450  * rps_ridx = &sps->st_rps[rps - sps->st_rps - 1];
451  *
452  * where:
453  * rps: &sps->st_rps[rps_idx]
454  * sps->st_rps: &sps->st_rps[0]
455  * is_slice_header: rps_idx == num_rps
456  *
457  * thus:
458  * if (num_rps != rps_idx)
459  * rps_ridx = &sps->st_rps[rps_idx - 1];
460  *
461  * NumDeltaPocs[RefRpsIdx]: num_delta_pocs[rps_idx - 1]
462  */
463  for (i = 0; i <= num_delta_pocs[rps_idx - 1]; i++) {
464  uint8_t use_delta_flag = 0;
465  uint8_t used_by_curr_pic_flag = get_bits1(gb);
466  if (!used_by_curr_pic_flag)
467  use_delta_flag = get_bits1(gb);
468 
469  if (used_by_curr_pic_flag || use_delta_flag)
470  num_delta_pocs[rps_idx]++;
471  }
472  } else {
473  unsigned int num_negative_pics = get_ue_golomb_long(gb);
474  unsigned int num_positive_pics = get_ue_golomb_long(gb);
475 
476  if ((num_positive_pics + (uint64_t)num_negative_pics) * 2 > get_bits_left(gb))
477  return AVERROR_INVALIDDATA;
478 
479  num_delta_pocs[rps_idx] = num_negative_pics + num_positive_pics;
480 
481  for (i = 0; i < num_negative_pics; i++) {
482  get_ue_golomb_long(gb); // delta_poc_s0_minus1[rps_idx]
483  skip_bits1 (gb); // used_by_curr_pic_s0_flag[rps_idx]
484  }
485 
486  for (i = 0; i < num_positive_pics; i++) {
487  get_ue_golomb_long(gb); // delta_poc_s1_minus1[rps_idx]
488  skip_bits1 (gb); // used_by_curr_pic_s1_flag[rps_idx]
489  }
490  }
491 
492  return 0;
493 }
494 
497 {
498  unsigned int i, sps_max_sub_layers_minus1, log2_max_pic_order_cnt_lsb_minus4;
499  unsigned int num_short_term_ref_pic_sets, num_delta_pocs[HEVC_MAX_SHORT_TERM_REF_PIC_SETS];
500 
501  skip_bits(gb, 4); // sps_video_parameter_set_id
502 
503  sps_max_sub_layers_minus1 = get_bits (gb, 3);
504 
505  /*
506  * numTemporalLayers greater than 1 indicates that the stream to which this
507  * configuration record applies is temporally scalable and the contained
508  * number of temporal layers (also referred to as temporal sub-layer or
509  * sub-layer in ISO/IEC 23008-2) is equal to numTemporalLayers. Value 1
510  * indicates that the stream is not temporally scalable. Value 0 indicates
511  * that it is unknown whether the stream is temporally scalable.
512  */
514  sps_max_sub_layers_minus1 + 1);
515 
516  hvcc->temporalIdNested = get_bits1(gb);
517 
518  hvcc_parse_ptl(gb, hvcc, sps_max_sub_layers_minus1);
519 
520  get_ue_golomb_long(gb); // sps_seq_parameter_set_id
521 
522  hvcc->chromaFormat = get_ue_golomb_long(gb);
523 
524  if (hvcc->chromaFormat == 3)
525  skip_bits1(gb); // separate_colour_plane_flag
526 
527  get_ue_golomb_long(gb); // pic_width_in_luma_samples
528  get_ue_golomb_long(gb); // pic_height_in_luma_samples
529 
530  if (get_bits1(gb)) { // conformance_window_flag
531  get_ue_golomb_long(gb); // conf_win_left_offset
532  get_ue_golomb_long(gb); // conf_win_right_offset
533  get_ue_golomb_long(gb); // conf_win_top_offset
534  get_ue_golomb_long(gb); // conf_win_bottom_offset
535  }
536 
539  log2_max_pic_order_cnt_lsb_minus4 = get_ue_golomb_long(gb);
540 
541  /* sps_sub_layer_ordering_info_present_flag */
542  i = get_bits1(gb) ? 0 : sps_max_sub_layers_minus1;
543  for (; i <= sps_max_sub_layers_minus1; i++)
545 
546  get_ue_golomb_long(gb); // log2_min_luma_coding_block_size_minus3
547  get_ue_golomb_long(gb); // log2_diff_max_min_luma_coding_block_size
548  get_ue_golomb_long(gb); // log2_min_transform_block_size_minus2
549  get_ue_golomb_long(gb); // log2_diff_max_min_transform_block_size
550  get_ue_golomb_long(gb); // max_transform_hierarchy_depth_inter
551  get_ue_golomb_long(gb); // max_transform_hierarchy_depth_intra
552 
553  if (get_bits1(gb) && // scaling_list_enabled_flag
554  get_bits1(gb)) // sps_scaling_list_data_present_flag
556 
557  skip_bits1(gb); // amp_enabled_flag
558  skip_bits1(gb); // sample_adaptive_offset_enabled_flag
559 
560  if (get_bits1(gb)) { // pcm_enabled_flag
561  skip_bits (gb, 4); // pcm_sample_bit_depth_luma_minus1
562  skip_bits (gb, 4); // pcm_sample_bit_depth_chroma_minus1
563  get_ue_golomb_long(gb); // log2_min_pcm_luma_coding_block_size_minus3
564  get_ue_golomb_long(gb); // log2_diff_max_min_pcm_luma_coding_block_size
565  skip_bits1 (gb); // pcm_loop_filter_disabled_flag
566  }
567 
568  num_short_term_ref_pic_sets = get_ue_golomb_long(gb);
569  if (num_short_term_ref_pic_sets > HEVC_MAX_SHORT_TERM_REF_PIC_SETS)
570  return AVERROR_INVALIDDATA;
571 
572  for (i = 0; i < num_short_term_ref_pic_sets; i++) {
573  int ret = parse_rps(gb, i, num_short_term_ref_pic_sets, num_delta_pocs);
574  if (ret < 0)
575  return ret;
576  }
577 
578  if (get_bits1(gb)) { // long_term_ref_pics_present_flag
579  unsigned num_long_term_ref_pics_sps = get_ue_golomb_long(gb);
580  if (num_long_term_ref_pics_sps > 31U)
581  return AVERROR_INVALIDDATA;
582  for (i = 0; i < num_long_term_ref_pics_sps; i++) { // num_long_term_ref_pics_sps
583  int len = FFMIN(log2_max_pic_order_cnt_lsb_minus4 + 4, 16);
584  skip_bits (gb, len); // lt_ref_pic_poc_lsb_sps[i]
585  skip_bits1(gb); // used_by_curr_pic_lt_sps_flag[i]
586  }
587  }
588 
589  skip_bits1(gb); // sps_temporal_mvp_enabled_flag
590  skip_bits1(gb); // strong_intra_smoothing_enabled_flag
591 
592  if (get_bits1(gb)) // vui_parameters_present_flag
593  hvcc_parse_vui(gb, hvcc, sps_max_sub_layers_minus1);
594 
595  /* nothing useful for hvcC past this point */
596  return 0;
597 }
598 
601 {
602  uint8_t tiles_enabled_flag, entropy_coding_sync_enabled_flag;
603 
604  get_ue_golomb_long(gb); // pps_pic_parameter_set_id
605  get_ue_golomb_long(gb); // pps_seq_parameter_set_id
606 
607  /*
608  * dependent_slice_segments_enabled_flag u(1)
609  * output_flag_present_flag u(1)
610  * num_extra_slice_header_bits u(3)
611  * sign_data_hiding_enabled_flag u(1)
612  * cabac_init_present_flag u(1)
613  */
614  skip_bits(gb, 7);
615 
616  get_ue_golomb_long(gb); // num_ref_idx_l0_default_active_minus1
617  get_ue_golomb_long(gb); // num_ref_idx_l1_default_active_minus1
618  get_se_golomb_long(gb); // init_qp_minus26
619 
620  /*
621  * constrained_intra_pred_flag u(1)
622  * transform_skip_enabled_flag u(1)
623  */
624  skip_bits(gb, 2);
625 
626  if (get_bits1(gb)) // cu_qp_delta_enabled_flag
627  get_ue_golomb_long(gb); // diff_cu_qp_delta_depth
628 
629  get_se_golomb_long(gb); // pps_cb_qp_offset
630  get_se_golomb_long(gb); // pps_cr_qp_offset
631 
632  /*
633  * pps_slice_chroma_qp_offsets_present_flag u(1)
634  * weighted_pred_flag u(1)
635  * weighted_bipred_flag u(1)
636  * transquant_bypass_enabled_flag u(1)
637  */
638  skip_bits(gb, 4);
639 
640  tiles_enabled_flag = get_bits1(gb);
641  entropy_coding_sync_enabled_flag = get_bits1(gb);
642 
643  if (entropy_coding_sync_enabled_flag && tiles_enabled_flag)
644  hvcc->parallelismType = 0; // mixed-type parallel decoding
645  else if (entropy_coding_sync_enabled_flag)
646  hvcc->parallelismType = 3; // wavefront-based parallel decoding
647  else if (tiles_enabled_flag)
648  hvcc->parallelismType = 2; // tile-based parallel decoding
649  else
650  hvcc->parallelismType = 1; // slice-based parallel decoding
651 
652  /* nothing useful for hvcC past this point */
653  return 0;
654 }
655 
656 static void nal_unit_parse_header(GetBitContext *gb, uint8_t *nal_type)
657 {
658  skip_bits1(gb); // forbidden_zero_bit
659 
660  *nal_type = get_bits(gb, 6);
661 
662  /*
663  * nuh_layer_id u(6)
664  * nuh_temporal_id_plus1 u(3)
665  */
666  skip_bits(gb, 9);
667 }
668 
669 static int hvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
670  uint8_t nal_type, int ps_array_completeness,
672 {
673  int ret;
674  uint16_t numNalus = array->numNalus;
675 
676  if (numNalus >= UINT16_MAX)
677  return AVERROR_INVALIDDATA;
678 
679  ret = av_reallocp_array(&array->nalUnit, numNalus + 1, sizeof(uint8_t*));
680  if (ret < 0)
681  return ret;
682 
683  ret = av_reallocp_array(&array->nalUnitLength, numNalus + 1, sizeof(uint16_t));
684  if (ret < 0)
685  return ret;
686 
687  array->nalUnit [numNalus] = nal_buf;
688  array->nalUnitLength[numNalus] = nal_size;
689  array->NAL_unit_type = nal_type;
690  array->numNalus++;
691 
692  /*
693  * When the sample entry name is ‘hvc1’, the default and mandatory value of
694  * array_completeness is 1 for arrays of all types of parameter sets, and 0
695  * for all other arrays. When the sample entry name is ‘hev1’, the default
696  * value of array_completeness is 0 for all arrays.
697  */
698  if (nal_type == HEVC_NAL_VPS || nal_type == HEVC_NAL_SPS || nal_type == HEVC_NAL_PPS)
699  array->array_completeness = ps_array_completeness;
700 
701  return 0;
702 }
703 
704 static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
705  int ps_array_completeness,
707  unsigned array_idx)
708 {
709  int ret = 0;
710  GetBitContext gbc;
711  uint8_t nal_type;
712  uint8_t *rbsp_buf;
713  uint32_t rbsp_size;
714 
715  rbsp_buf = ff_nal_unit_extract_rbsp(nal_buf, nal_size, &rbsp_size, 2);
716  if (!rbsp_buf) {
717  ret = AVERROR(ENOMEM);
718  goto end;
719  }
720 
721  ret = init_get_bits8(&gbc, rbsp_buf, rbsp_size);
722  if (ret < 0)
723  goto end;
724 
725  nal_unit_parse_header(&gbc, &nal_type);
726 
727  /*
728  * Note: only 'declarative' SEI messages are allowed in
729  * hvcC. Perhaps the SEI playload type should be checked
730  * and non-declarative SEI messages discarded?
731  */
732  ret = hvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
733  ps_array_completeness,
734  &hvcc->arrays[array_idx]);
735  if (ret < 0)
736  goto end;
737  if (hvcc->arrays[array_idx].numNalus == 1)
738  hvcc->numOfArrays++;
739  if (nal_type == HEVC_NAL_VPS)
740  ret = hvcc_parse_vps(&gbc, hvcc);
741  else if (nal_type == HEVC_NAL_SPS)
742  ret = hvcc_parse_sps(&gbc, hvcc);
743  else if (nal_type == HEVC_NAL_PPS)
744  ret = hvcc_parse_pps(&gbc, hvcc);
745  if (ret < 0)
746  goto end;
747 
748 end:
749  av_free(rbsp_buf);
750  return ret;
751 }
752 
754 {
755  memset(hvcc, 0, sizeof(HEVCDecoderConfigurationRecord));
756  hvcc->configurationVersion = 1;
757  hvcc->lengthSizeMinusOne = 3; // 4 bytes
758 
759  /*
760  * The following fields have all their valid bits set by default,
761  * the ProfileTierLevel parsing code will unset them when needed.
762  */
763  hvcc->general_profile_compatibility_flags = 0xffffffff;
764  hvcc->general_constraint_indicator_flags = 0xffffffffffff;
765 
766  /*
767  * Initialize this field with an invalid value which can be used to detect
768  * whether we didn't see any VUI (in which case it should be reset to zero).
769  */
771 }
772 
774 {
775  for (unsigned i = 0; i < FF_ARRAY_ELEMS(hvcc->arrays); i++) {
776  HVCCNALUnitArray *const array = &hvcc->arrays[i];
777  array->numNalus = 0;
778  av_freep(&array->nalUnit);
779  av_freep(&array->nalUnitLength);
780  }
781 }
782 
784 {
785  uint16_t vps_count, sps_count, pps_count;
786 
787  /*
788  * We only support writing HEVCDecoderConfigurationRecord version 1.
789  */
790  hvcc->configurationVersion = 1;
791 
792  /*
793  * If min_spatial_segmentation_idc is invalid, reset to 0 (unspecified).
794  */
797 
798  /*
799  * parallelismType indicates the type of parallelism that is used to meet
800  * the restrictions imposed by min_spatial_segmentation_idc when the value
801  * of min_spatial_segmentation_idc is greater than 0.
802  */
803  if (!hvcc->min_spatial_segmentation_idc)
804  hvcc->parallelismType = 0;
805 
806  /*
807  * It's unclear how to properly compute these fields, so
808  * let's always set them to values meaning 'unspecified'.
809  */
810  hvcc->avgFrameRate = 0;
811  hvcc->constantFrameRate = 0;
812 
813  av_log(NULL, AV_LOG_TRACE, "configurationVersion: %"PRIu8"\n",
814  hvcc->configurationVersion);
815  av_log(NULL, AV_LOG_TRACE, "general_profile_space: %"PRIu8"\n",
816  hvcc->general_profile_space);
817  av_log(NULL, AV_LOG_TRACE, "general_tier_flag: %"PRIu8"\n",
818  hvcc->general_tier_flag);
819  av_log(NULL, AV_LOG_TRACE, "general_profile_idc: %"PRIu8"\n",
820  hvcc->general_profile_idc);
821  av_log(NULL, AV_LOG_TRACE, "general_profile_compatibility_flags: 0x%08"PRIx32"\n",
823  av_log(NULL, AV_LOG_TRACE, "general_constraint_indicator_flags: 0x%012"PRIx64"\n",
825  av_log(NULL, AV_LOG_TRACE, "general_level_idc: %"PRIu8"\n",
826  hvcc->general_level_idc);
827  av_log(NULL, AV_LOG_TRACE, "min_spatial_segmentation_idc: %"PRIu16"\n",
829  av_log(NULL, AV_LOG_TRACE, "parallelismType: %"PRIu8"\n",
830  hvcc->parallelismType);
831  av_log(NULL, AV_LOG_TRACE, "chromaFormat: %"PRIu8"\n",
832  hvcc->chromaFormat);
833  av_log(NULL, AV_LOG_TRACE, "bitDepthLumaMinus8: %"PRIu8"\n",
834  hvcc->bitDepthLumaMinus8);
835  av_log(NULL, AV_LOG_TRACE, "bitDepthChromaMinus8: %"PRIu8"\n",
836  hvcc->bitDepthChromaMinus8);
837  av_log(NULL, AV_LOG_TRACE, "avgFrameRate: %"PRIu16"\n",
838  hvcc->avgFrameRate);
839  av_log(NULL, AV_LOG_TRACE, "constantFrameRate: %"PRIu8"\n",
840  hvcc->constantFrameRate);
841  av_log(NULL, AV_LOG_TRACE, "numTemporalLayers: %"PRIu8"\n",
842  hvcc->numTemporalLayers);
843  av_log(NULL, AV_LOG_TRACE, "temporalIdNested: %"PRIu8"\n",
844  hvcc->temporalIdNested);
845  av_log(NULL, AV_LOG_TRACE, "lengthSizeMinusOne: %"PRIu8"\n",
846  hvcc->lengthSizeMinusOne);
847  av_log(NULL, AV_LOG_TRACE, "numOfArrays: %"PRIu8"\n",
848  hvcc->numOfArrays);
849  for (unsigned i = 0, j = 0; i < FF_ARRAY_ELEMS(hvcc->arrays); i++) {
850  const HVCCNALUnitArray *const array = &hvcc->arrays[i];
851 
852  if (array->numNalus == 0)
853  continue;
854 
855  av_log(NULL, AV_LOG_TRACE, "array_completeness[%"PRIu8"]: %"PRIu8"\n",
856  j, array->array_completeness);
857  av_log(NULL, AV_LOG_TRACE, "NAL_unit_type[%"PRIu8"]: %"PRIu8"\n",
858  j, array->NAL_unit_type);
859  av_log(NULL, AV_LOG_TRACE, "numNalus[%"PRIu8"]: %"PRIu16"\n",
860  j, array->numNalus);
861  for (unsigned k = 0; k < array->numNalus; k++)
863  "nalUnitLength[%"PRIu8"][%"PRIu16"]: %"PRIu16"\n",
864  j, k, array->nalUnitLength[k]);
865  j++;
866  }
867 
868  /*
869  * We need at least one of each: VPS, SPS and PPS.
870  */
871  vps_count = hvcc->arrays[VPS_INDEX].numNalus;
872  sps_count = hvcc->arrays[SPS_INDEX].numNalus;
873  pps_count = hvcc->arrays[PPS_INDEX].numNalus;
874  if (!vps_count || vps_count > HEVC_MAX_VPS_COUNT ||
875  !sps_count || sps_count > HEVC_MAX_SPS_COUNT ||
876  !pps_count || pps_count > HEVC_MAX_PPS_COUNT)
877  return AVERROR_INVALIDDATA;
878 
879  /* unsigned int(8) configurationVersion = 1; */
880  avio_w8(pb, hvcc->configurationVersion);
881 
882  /*
883  * unsigned int(2) general_profile_space;
884  * unsigned int(1) general_tier_flag;
885  * unsigned int(5) general_profile_idc;
886  */
887  avio_w8(pb, hvcc->general_profile_space << 6 |
888  hvcc->general_tier_flag << 5 |
889  hvcc->general_profile_idc);
890 
891  /* unsigned int(32) general_profile_compatibility_flags; */
893 
894  /* unsigned int(48) general_constraint_indicator_flags; */
897 
898  /* unsigned int(8) general_level_idc; */
899  avio_w8(pb, hvcc->general_level_idc);
900 
901  /*
902  * bit(4) reserved = ‘1111’b;
903  * unsigned int(12) min_spatial_segmentation_idc;
904  */
905  avio_wb16(pb, hvcc->min_spatial_segmentation_idc | 0xf000);
906 
907  /*
908  * bit(6) reserved = ‘111111’b;
909  * unsigned int(2) parallelismType;
910  */
911  avio_w8(pb, hvcc->parallelismType | 0xfc);
912 
913  /*
914  * bit(6) reserved = ‘111111’b;
915  * unsigned int(2) chromaFormat;
916  */
917  avio_w8(pb, hvcc->chromaFormat | 0xfc);
918 
919  /*
920  * bit(5) reserved = ‘11111’b;
921  * unsigned int(3) bitDepthLumaMinus8;
922  */
923  avio_w8(pb, hvcc->bitDepthLumaMinus8 | 0xf8);
924 
925  /*
926  * bit(5) reserved = ‘11111’b;
927  * unsigned int(3) bitDepthChromaMinus8;
928  */
929  avio_w8(pb, hvcc->bitDepthChromaMinus8 | 0xf8);
930 
931  /* bit(16) avgFrameRate; */
932  avio_wb16(pb, hvcc->avgFrameRate);
933 
934  /*
935  * bit(2) constantFrameRate;
936  * bit(3) numTemporalLayers;
937  * bit(1) temporalIdNested;
938  * unsigned int(2) lengthSizeMinusOne;
939  */
940  avio_w8(pb, hvcc->constantFrameRate << 6 |
941  hvcc->numTemporalLayers << 3 |
942  hvcc->temporalIdNested << 2 |
943  hvcc->lengthSizeMinusOne);
944 
945  /* unsigned int(8) numOfArrays; */
946  avio_w8(pb, hvcc->numOfArrays);
947 
948  for (unsigned i = 0; i < FF_ARRAY_ELEMS(hvcc->arrays); i++) {
949  const HVCCNALUnitArray *const array = &hvcc->arrays[i];
950 
951  if (!array->numNalus)
952  continue;
953  /*
954  * bit(1) array_completeness;
955  * unsigned int(1) reserved = 0;
956  * unsigned int(6) NAL_unit_type;
957  */
958  avio_w8(pb, array->array_completeness << 7 |
959  array->NAL_unit_type & 0x3f);
960 
961  /* unsigned int(16) numNalus; */
962  avio_wb16(pb, array->numNalus);
963 
964  for (unsigned j = 0; j < array->numNalus; j++) {
965  /* unsigned int(16) nalUnitLength; */
966  avio_wb16(pb, array->nalUnitLength[j]);
967 
968  /* bit(8*nalUnitLength) nalUnit; */
969  avio_write(pb, array->nalUnit[j],
970  array->nalUnitLength[j]);
971  }
972  }
973 
974  return 0;
975 }
976 
977 int ff_hevc_annexb2mp4(AVIOContext *pb, const uint8_t *buf_in,
978  int size, int filter_ps, int *ps_count)
979 {
980  int num_ps = 0, ret = 0;
981  uint8_t *buf, *end, *start = NULL;
982 
983  if (!filter_ps) {
984  ret = ff_avc_parse_nal_units(pb, buf_in, size);
985  goto end;
986  }
987 
988  ret = ff_avc_parse_nal_units_buf(buf_in, &start, &size);
989  if (ret < 0)
990  goto end;
991 
992  ret = 0;
993  buf = start;
994  end = start + size;
995 
996  while (end - buf > 4) {
997  uint32_t len = FFMIN(AV_RB32(buf), end - buf - 4);
998  uint8_t type = (buf[4] >> 1) & 0x3f;
999 
1000  buf += 4;
1001 
1002  switch (type) {
1003  case HEVC_NAL_VPS:
1004  case HEVC_NAL_SPS:
1005  case HEVC_NAL_PPS:
1006  num_ps++;
1007  break;
1008  default:
1009  ret += 4 + len;
1010  avio_wb32(pb, len);
1011  avio_write(pb, buf, len);
1012  break;
1013  }
1014 
1015  buf += len;
1016  }
1017 
1018 end:
1019  av_free(start);
1020  if (ps_count)
1021  *ps_count = num_ps;
1022  return ret;
1023 }
1024 
1025 int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out,
1026  int *size, int filter_ps, int *ps_count)
1027 {
1028  AVIOContext *pb;
1029  int ret;
1030 
1031  ret = avio_open_dyn_buf(&pb);
1032  if (ret < 0)
1033  return ret;
1034 
1035  ret = ff_hevc_annexb2mp4(pb, buf_in, *size, filter_ps, ps_count);
1036  if (ret < 0) {
1037  ffio_free_dyn_buf(&pb);
1038  return ret;
1039  }
1040 
1041  *size = avio_close_dyn_buf(pb, buf_out);
1042 
1043  return 0;
1044 }
1045 
1047  int size, int ps_array_completeness)
1048 {
1050  uint8_t *buf, *end, *start;
1051  int ret;
1052 
1053  if (size < 6) {
1054  /* We can't write a valid hvcC from the provided data */
1055  return AVERROR_INVALIDDATA;
1056  } else if (*data == 1) {
1057  /* Data is already hvcC-formatted */
1058  avio_write(pb, data, size);
1059  return 0;
1060  } else if (!(AV_RB24(data) == 1 || AV_RB32(data) == 1)) {
1061  /* Not a valid Annex B start code prefix */
1062  return AVERROR_INVALIDDATA;
1063  }
1064 
1065  ret = ff_avc_parse_nal_units_buf(data, &start, &size);
1066  if (ret < 0)
1067  return ret;
1068 
1069  hvcc_init(&hvcc);
1070 
1071  buf = start;
1072  end = start + size;
1073 
1074  while (end - buf > 4) {
1075  uint32_t len = FFMIN(AV_RB32(buf), end - buf - 4);
1076  uint8_t type = (buf[4] >> 1) & 0x3f;
1077 
1078  buf += 4;
1079 
1080  for (unsigned i = 0; i < FF_ARRAY_ELEMS(hvcc.arrays); i++) {
1081  static const uint8_t array_idx_to_type[] =
1084 
1085  if (type == array_idx_to_type[i]) {
1086  ret = hvcc_add_nal_unit(buf, len, ps_array_completeness,
1087  &hvcc, i);
1088  if (ret < 0)
1089  goto end;
1090  break;
1091  }
1092  }
1093 
1094  buf += len;
1095  }
1096 
1097  ret = hvcc_write(pb, &hvcc);
1098 
1099 end:
1100  hvcc_close(&hvcc);
1101  av_free(start);
1102  return ret;
1103 }
uint8_t
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:270
int ff_avc_parse_nal_units(AVIOContext *pb, const uint8_t *buf_in, int size)
Definition: avc.c:74
int ff_avc_parse_nal_units_buf(const uint8_t *buf_in, uint8_t **buf, int *size)
Definition: avc.c:96
Libavcodec external API header.
Buffered I/O operations.
void avio_w8(AVIOContext *s, int b)
Definition: aviobuf.c:208
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:390
void avio_wb16(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:468
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
Definition: aviobuf.c:1441
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:230
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
Definition: aviobuf.c:1396
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
Definition: aviobuf.c:1471
#define AV_RB24
Definition: intreadwrite.h:64
#define AV_RB32
Definition: intreadwrite.h:130
#define FFMIN(a, b)
Definition: common.h:105
#define FFMAX(a, b)
Definition: common.h:103
#define NULL
Definition: coverity.c:32
bitstream reader API header.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:546
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:849
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
Definition: get_bits.h:291
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:498
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:467
static uint64_t get_bits64(GetBitContext *s, int n)
Read 0-64 bits.
Definition: get_bits.h:572
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:677
static void skip_bits1(GetBitContext *s)
Definition: get_bits.h:538
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:379
exp golomb vlc stuff
static int get_se_golomb_long(GetBitContext *gb)
Definition: golomb.h:296
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:106
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
#define AVERROR(e)
Definition: error.h:43
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:220
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array through a pointer to a pointer.
Definition: mem.c:206
const H265RawProfileTierLevel * ptl
Definition: h265_levels.c:170
#define MAX_SPATIAL_SEGMENTATION
Definition: hevc.c:31
static int hvcc_write(AVIOContext *pb, HEVCDecoderConfigurationRecord *hvcc)
Definition: hevc.c:783
@ SPS_INDEX
Definition: hevc.c:35
@ PPS_INDEX
Definition: hevc.c:36
@ SEI_SUFFIX_INDEX
Definition: hevc.c:38
@ NB_ARRAYS
Definition: hevc.c:39
@ SEI_PREFIX_INDEX
Definition: hevc.c:37
@ VPS_INDEX
Definition: hevc.c:34
static void hvcc_close(HEVCDecoderConfigurationRecord *hvcc)
Definition: hevc.c:773
static void skip_sub_layer_ordering_info(GetBitContext *gb)
Definition: hevc.c:365
int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out, int *size, int filter_ps, int *ps_count)
Writes Annex B formatted HEVC NAL units to a data buffer.
Definition: hevc.c:1025
int ff_hevc_annexb2mp4(AVIOContext *pb, const uint8_t *buf_in, int size, int filter_ps, int *ps_count)
Writes Annex B formatted HEVC NAL units to the provided AVIOContext.
Definition: hevc.c:977
static void hvcc_update_ptl(HEVCDecoderConfigurationRecord *hvcc, HVCCProfileTierLevel *ptl)
Definition: hevc.c:81
static int parse_rps(GetBitContext *gb, unsigned int rps_idx, unsigned int num_rps, unsigned int num_delta_pocs[HEVC_MAX_SHORT_TERM_REF_PIC_SETS])
Definition: hevc.c:428
static int hvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, uint8_t nal_type, int ps_array_completeness, HVCCNALUnitArray *array)
Definition: hevc.c:669
static int hvcc_parse_vps(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc)
Definition: hevc.c:372
static void skip_sub_layer_hrd_parameters(GetBitContext *gb, unsigned int cpb_cnt_minus1, uint8_t sub_pic_hrd_params_present_flag)
Definition: hevc.c:184
static int skip_hrd_parameters(GetBitContext *gb, uint8_t cprms_present_flag, unsigned int max_sub_layers_minus1)
Definition: hevc.c:203
static void nal_unit_parse_header(GetBitContext *gb, uint8_t *nal_type)
Definition: hevc.c:656
int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data, int size, int ps_array_completeness)
Writes HEVC extradata (parameter sets, declarative SEI NAL units) to the provided AVIOContext.
Definition: hevc.c:1046
static void hvcc_parse_ptl(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc, unsigned int max_sub_layers_minus1)
Definition: hevc.c:135
static void hvcc_parse_vui(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc, unsigned int max_sub_layers_minus1)
Definition: hevc.c:287
static int hvcc_parse_pps(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc)
Definition: hevc.c:599
static void skip_scaling_list_data(GetBitContext *gb)
Definition: hevc.c:409
static void skip_timing_info(GetBitContext *gb)
Definition: hevc.c:278
static int hvcc_parse_sps(GetBitContext *gb, HEVCDecoderConfigurationRecord *hvcc)
Definition: hevc.c:495
static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size, int ps_array_completeness, HEVCDecoderConfigurationRecord *hvcc, unsigned array_idx)
Definition: hevc.c:704
static void hvcc_init(HEVCDecoderConfigurationRecord *hvcc)
Definition: hevc.c:753
cl_device_type type
int i
Definition: input.c:407
@ HEVC_NAL_SEI_SUFFIX
Definition: hevc.h:69
@ HEVC_NAL_SEI_PREFIX
Definition: hevc.h:68
@ HEVC_NAL_PPS
Definition: hevc.h:63
@ HEVC_NAL_VPS
Definition: hevc.h:61
@ HEVC_NAL_SPS
Definition: hevc.h:62
@ HEVC_MAX_SPS_COUNT
Definition: hevc.h:112
@ HEVC_MAX_PPS_COUNT
Definition: hevc.h:114
@ HEVC_MAX_SUB_LAYERS
Definition: hevc.h:105
@ HEVC_MAX_VPS_COUNT
Definition: hevc.h:110
@ HEVC_MAX_SHORT_TERM_REF_PIC_SETS
Definition: hevc.h:122
internal header for HEVC (de)muxer utilities
const char data[16]
Definition: mxf.c:142
#define FF_ARRAY_ELEMS(a)
Bytestream IO Context.
Definition: avio.h:161
HVCCNALUnitArray arrays[NB_ARRAYS]
Definition: hevc.c:69
uint16_t min_spatial_segmentation_idc
Definition: hevc.c:58
uint64_t general_constraint_indicator_flags
Definition: hevc.c:56
uint32_t general_profile_compatibility_flags
Definition: hevc.c:55
uint16_t * nalUnitLength
Definition: hevc.c:46
uint8_t NAL_unit_type
Definition: hevc.c:44
uint8_t array_completeness
Definition: hevc.c:43
uint8_t ** nalUnit
Definition: hevc.c:47
uint16_t numNalus
Definition: hevc.c:45
uint8_t profile_space
Definition: hevc.c:73
uint8_t tier_flag
Definition: hevc.c:74
uint8_t level_idc
Definition: hevc.c:78
uint64_t constraint_indicator_flags
Definition: hevc.c:77
uint32_t profile_compatibility_flags
Definition: hevc.c:76
uint8_t profile_idc
Definition: hevc.c:75
#define av_free(p)
#define av_freep(p)
#define av_log(a,...)
static int array[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:106
int size
int len