cbs_h265.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef AVCODEC_CBS_H265_H
  19. #define AVCODEC_CBS_H265_H
  20. #include <stddef.h>
  21. #include <stdint.h>
  22. #include "cbs_h2645.h"
  23. #include "hevc.h"
  24. enum {
  25. // This limit is arbitrary - it is sufficient for one message of each
  26. // type plus some repeats, and will therefore easily cover all sane
  27. // streams. However, it is possible to make technically-valid streams
  28. // for which it will fail (for example, by including a large number of
  29. // user-data-unregistered messages).
  30. H265_MAX_SEI_PAYLOADS = 64,
  31. };
  32. typedef struct H265RawNALUnitHeader {
  33. uint8_t nal_unit_type;
  34. uint8_t nuh_layer_id;
  35. uint8_t nuh_temporal_id_plus1;
  36. } H265RawNALUnitHeader;
  37. typedef struct H265RawProfileTierLevel {
  38. uint8_t general_profile_space;
  39. uint8_t general_tier_flag;
  40. uint8_t general_profile_idc;
  41. uint8_t general_profile_compatibility_flag[32];
  42. uint8_t general_progressive_source_flag;
  43. uint8_t general_interlaced_source_flag;
  44. uint8_t general_non_packed_constraint_flag;
  45. uint8_t general_frame_only_constraint_flag;
  46. uint8_t general_max_12bit_constraint_flag;
  47. uint8_t general_max_10bit_constraint_flag;
  48. uint8_t general_max_8bit_constraint_flag;
  49. uint8_t general_max_422chroma_constraint_flag;
  50. uint8_t general_max_420chroma_constraint_flag;
  51. uint8_t general_max_monochrome_constraint_flag;
  52. uint8_t general_intra_constraint_flag;
  53. uint8_t general_one_picture_only_constraint_flag;
  54. uint8_t general_lower_bit_rate_constraint_flag;
  55. uint8_t general_max_14bit_constraint_flag;
  56. uint8_t general_inbld_flag;
  57. uint8_t general_level_idc;
  58. uint8_t sub_layer_profile_present_flag[HEVC_MAX_SUB_LAYERS];
  59. uint8_t sub_layer_level_present_flag[HEVC_MAX_SUB_LAYERS];
  60. uint8_t sub_layer_profile_space[HEVC_MAX_SUB_LAYERS];
  61. uint8_t sub_layer_tier_flag[HEVC_MAX_SUB_LAYERS];
  62. uint8_t sub_layer_profile_idc[HEVC_MAX_SUB_LAYERS];
  63. uint8_t sub_layer_profile_compatibility_flag[HEVC_MAX_SUB_LAYERS][32];
  64. uint8_t sub_layer_progressive_source_flag[HEVC_MAX_SUB_LAYERS];
  65. uint8_t sub_layer_interlaced_source_flag[HEVC_MAX_SUB_LAYERS];
  66. uint8_t sub_layer_non_packed_constraint_flag[HEVC_MAX_SUB_LAYERS];
  67. uint8_t sub_layer_frame_only_constraint_flag[HEVC_MAX_SUB_LAYERS];
  68. uint8_t sub_layer_max_12bit_constraint_flag[HEVC_MAX_SUB_LAYERS];
  69. uint8_t sub_layer_max_10bit_constraint_flag[HEVC_MAX_SUB_LAYERS];
  70. uint8_t sub_layer_max_8bit_constraint_flag[HEVC_MAX_SUB_LAYERS];
  71. uint8_t sub_layer_max_422chroma_constraint_flag[HEVC_MAX_SUB_LAYERS];
  72. uint8_t sub_layer_max_420chroma_constraint_flag[HEVC_MAX_SUB_LAYERS];
  73. uint8_t sub_layer_max_monochrome_constraint_flag[HEVC_MAX_SUB_LAYERS];
  74. uint8_t sub_layer_intra_constraint_flag[HEVC_MAX_SUB_LAYERS];
  75. uint8_t sub_layer_one_picture_only_constraint_flag[HEVC_MAX_SUB_LAYERS];
  76. uint8_t sub_layer_lower_bit_rate_constraint_flag[HEVC_MAX_SUB_LAYERS];
  77. uint8_t sub_layer_max_14bit_constraint_flag[HEVC_MAX_SUB_LAYERS];
  78. uint8_t sub_layer_inbld_flag[HEVC_MAX_SUB_LAYERS];
  79. uint8_t sub_layer_level_idc[HEVC_MAX_SUB_LAYERS];
  80. } H265RawProfileTierLevel;
  81. typedef struct H265RawSubLayerHRDParameters {
  82. uint32_t bit_rate_value_minus1[HEVC_MAX_CPB_CNT];
  83. uint32_t cpb_size_value_minus1[HEVC_MAX_CPB_CNT];
  84. uint32_t cpb_size_du_value_minus1[HEVC_MAX_CPB_CNT];
  85. uint32_t bit_rate_du_value_minus1[HEVC_MAX_CPB_CNT];
  86. uint8_t cbr_flag[HEVC_MAX_CPB_CNT];
  87. } H265RawSubLayerHRDParameters;
  88. typedef struct H265RawHRDParameters {
  89. uint8_t nal_hrd_parameters_present_flag;
  90. uint8_t vcl_hrd_parameters_present_flag;
  91. uint8_t sub_pic_hrd_params_present_flag;
  92. uint8_t tick_divisor_minus2;
  93. uint8_t du_cpb_removal_delay_increment_length_minus1;
  94. uint8_t sub_pic_cpb_params_in_pic_timing_sei_flag;
  95. uint8_t dpb_output_delay_du_length_minus1;
  96. uint8_t bit_rate_scale;
  97. uint8_t cpb_size_scale;
  98. uint8_t cpb_size_du_scale;
  99. uint8_t initial_cpb_removal_delay_length_minus1;
  100. uint8_t au_cpb_removal_delay_length_minus1;
  101. uint8_t dpb_output_delay_length_minus1;
  102. uint8_t fixed_pic_rate_general_flag[HEVC_MAX_SUB_LAYERS];
  103. uint8_t fixed_pic_rate_within_cvs_flag[HEVC_MAX_SUB_LAYERS];
  104. uint16_t elemental_duration_in_tc_minus1[HEVC_MAX_SUB_LAYERS];
  105. uint8_t low_delay_hrd_flag[HEVC_MAX_SUB_LAYERS];
  106. uint8_t cpb_cnt_minus1[HEVC_MAX_SUB_LAYERS];
  107. H265RawSubLayerHRDParameters nal_sub_layer_hrd_parameters[HEVC_MAX_SUB_LAYERS];
  108. H265RawSubLayerHRDParameters vcl_sub_layer_hrd_parameters[HEVC_MAX_SUB_LAYERS];
  109. } H265RawHRDParameters;
  110. typedef struct H265RawVUI {
  111. uint8_t aspect_ratio_info_present_flag;
  112. uint8_t aspect_ratio_idc;
  113. uint16_t sar_width;
  114. uint16_t sar_height;
  115. uint8_t overscan_info_present_flag;
  116. uint8_t overscan_appropriate_flag;
  117. uint8_t video_signal_type_present_flag;
  118. uint8_t video_format;
  119. uint8_t video_full_range_flag;
  120. uint8_t colour_description_present_flag;
  121. uint8_t colour_primaries;
  122. uint8_t transfer_characteristics;
  123. uint8_t matrix_coefficients;
  124. uint8_t chroma_loc_info_present_flag;
  125. uint8_t chroma_sample_loc_type_top_field;
  126. uint8_t chroma_sample_loc_type_bottom_field;
  127. uint8_t neutral_chroma_indication_flag;
  128. uint8_t field_seq_flag;
  129. uint8_t frame_field_info_present_flag;
  130. uint8_t default_display_window_flag;
  131. uint16_t def_disp_win_left_offset;
  132. uint16_t def_disp_win_right_offset;
  133. uint16_t def_disp_win_top_offset;
  134. uint16_t def_disp_win_bottom_offset;
  135. uint8_t vui_timing_info_present_flag;
  136. uint32_t vui_num_units_in_tick;
  137. uint32_t vui_time_scale;
  138. uint8_t vui_poc_proportional_to_timing_flag;
  139. uint32_t vui_num_ticks_poc_diff_one_minus1;
  140. uint8_t vui_hrd_parameters_present_flag;
  141. H265RawHRDParameters hrd_parameters;
  142. uint8_t bitstream_restriction_flag;
  143. uint8_t tiles_fixed_structure_flag;
  144. uint8_t motion_vectors_over_pic_boundaries_flag;
  145. uint8_t restricted_ref_pic_lists_flag;
  146. uint16_t min_spatial_segmentation_idc;
  147. uint8_t max_bytes_per_pic_denom;
  148. uint8_t max_bits_per_min_cu_denom;
  149. uint8_t log2_max_mv_length_horizontal;
  150. uint8_t log2_max_mv_length_vertical;
  151. } H265RawVUI;
  152. typedef struct H265RawExtensionData {
  153. uint8_t *data;
  154. size_t bit_length;
  155. AVBufferRef *data_ref;
  156. } H265RawExtensionData;
  157. typedef struct H265RawVPS {
  158. H265RawNALUnitHeader nal_unit_header;
  159. uint8_t vps_video_parameter_set_id;
  160. uint8_t vps_base_layer_internal_flag;
  161. uint8_t vps_base_layer_available_flag;
  162. uint8_t vps_max_layers_minus1;
  163. uint8_t vps_max_sub_layers_minus1;
  164. uint8_t vps_temporal_id_nesting_flag;
  165. H265RawProfileTierLevel profile_tier_level;
  166. uint8_t vps_sub_layer_ordering_info_present_flag;
  167. uint8_t vps_max_dec_pic_buffering_minus1[HEVC_MAX_SUB_LAYERS];
  168. uint8_t vps_max_num_reorder_pics[HEVC_MAX_SUB_LAYERS];
  169. uint32_t vps_max_latency_increase_plus1[HEVC_MAX_SUB_LAYERS];
  170. uint8_t vps_max_layer_id;
  171. uint16_t vps_num_layer_sets_minus1;
  172. uint8_t layer_id_included_flag[HEVC_MAX_LAYER_SETS][HEVC_MAX_LAYERS];
  173. uint8_t vps_timing_info_present_flag;
  174. uint32_t vps_num_units_in_tick;
  175. uint32_t vps_time_scale;
  176. uint8_t vps_poc_proportional_to_timing_flag;
  177. uint32_t vps_num_ticks_poc_diff_one_minus1;
  178. uint16_t vps_num_hrd_parameters;
  179. uint16_t hrd_layer_set_idx[HEVC_MAX_LAYER_SETS];
  180. uint8_t cprms_present_flag[HEVC_MAX_LAYER_SETS];
  181. H265RawHRDParameters hrd_parameters[HEVC_MAX_LAYER_SETS];
  182. uint8_t vps_extension_flag;
  183. H265RawExtensionData extension_data;
  184. } H265RawVPS;
  185. typedef struct H265RawSTRefPicSet {
  186. uint8_t inter_ref_pic_set_prediction_flag;
  187. uint8_t delta_idx_minus1;
  188. uint8_t delta_rps_sign;
  189. uint16_t abs_delta_rps_minus1;
  190. uint8_t used_by_curr_pic_flag[HEVC_MAX_REFS];
  191. uint8_t use_delta_flag[HEVC_MAX_REFS];
  192. uint8_t num_negative_pics;
  193. uint8_t num_positive_pics;
  194. uint16_t delta_poc_s0_minus1[HEVC_MAX_REFS];
  195. uint8_t used_by_curr_pic_s0_flag[HEVC_MAX_REFS];
  196. uint16_t delta_poc_s1_minus1[HEVC_MAX_REFS];
  197. uint8_t used_by_curr_pic_s1_flag[HEVC_MAX_REFS];
  198. } H265RawSTRefPicSet;
  199. typedef struct H265RawScalingList {
  200. uint8_t scaling_list_pred_mode_flag[4][6];
  201. uint8_t scaling_list_pred_matrix_id_delta[4][6];
  202. int16_t scaling_list_dc_coef_minus8[4][6];
  203. int8_t scaling_list_delta_coeff[4][6][64];
  204. } H265RawScalingList;
  205. typedef struct H265RawSPS {
  206. H265RawNALUnitHeader nal_unit_header;
  207. uint8_t sps_video_parameter_set_id;
  208. uint8_t sps_max_sub_layers_minus1;
  209. uint8_t sps_temporal_id_nesting_flag;
  210. H265RawProfileTierLevel profile_tier_level;
  211. uint8_t sps_seq_parameter_set_id;
  212. uint8_t chroma_format_idc;
  213. uint8_t separate_colour_plane_flag;
  214. uint16_t pic_width_in_luma_samples;
  215. uint16_t pic_height_in_luma_samples;
  216. uint8_t conformance_window_flag;
  217. uint16_t conf_win_left_offset;
  218. uint16_t conf_win_right_offset;
  219. uint16_t conf_win_top_offset;
  220. uint16_t conf_win_bottom_offset;
  221. uint8_t bit_depth_luma_minus8;
  222. uint8_t bit_depth_chroma_minus8;
  223. uint8_t log2_max_pic_order_cnt_lsb_minus4;
  224. uint8_t sps_sub_layer_ordering_info_present_flag;
  225. uint8_t sps_max_dec_pic_buffering_minus1[HEVC_MAX_SUB_LAYERS];
  226. uint8_t sps_max_num_reorder_pics[HEVC_MAX_SUB_LAYERS];
  227. uint32_t sps_max_latency_increase_plus1[HEVC_MAX_SUB_LAYERS];
  228. uint8_t log2_min_luma_coding_block_size_minus3;
  229. uint8_t log2_diff_max_min_luma_coding_block_size;
  230. uint8_t log2_min_luma_transform_block_size_minus2;
  231. uint8_t log2_diff_max_min_luma_transform_block_size;
  232. uint8_t max_transform_hierarchy_depth_inter;
  233. uint8_t max_transform_hierarchy_depth_intra;
  234. uint8_t scaling_list_enabled_flag;
  235. uint8_t sps_scaling_list_data_present_flag;
  236. H265RawScalingList scaling_list;
  237. uint8_t amp_enabled_flag;
  238. uint8_t sample_adaptive_offset_enabled_flag;
  239. uint8_t pcm_enabled_flag;
  240. uint8_t pcm_sample_bit_depth_luma_minus1;
  241. uint8_t pcm_sample_bit_depth_chroma_minus1;
  242. uint8_t log2_min_pcm_luma_coding_block_size_minus3;
  243. uint8_t log2_diff_max_min_pcm_luma_coding_block_size;
  244. uint8_t pcm_loop_filter_disabled_flag;
  245. uint8_t num_short_term_ref_pic_sets;
  246. H265RawSTRefPicSet st_ref_pic_set[HEVC_MAX_SHORT_TERM_REF_PIC_SETS];
  247. uint8_t long_term_ref_pics_present_flag;
  248. uint8_t num_long_term_ref_pics_sps;
  249. uint16_t lt_ref_pic_poc_lsb_sps[HEVC_MAX_LONG_TERM_REF_PICS];
  250. uint8_t used_by_curr_pic_lt_sps_flag[HEVC_MAX_LONG_TERM_REF_PICS];
  251. uint8_t sps_temporal_mvp_enabled_flag;
  252. uint8_t strong_intra_smoothing_enabled_flag;
  253. uint8_t vui_parameters_present_flag;
  254. H265RawVUI vui;
  255. uint8_t sps_extension_present_flag;
  256. uint8_t sps_range_extension_flag;
  257. uint8_t sps_multilayer_extension_flag;
  258. uint8_t sps_3d_extension_flag;
  259. uint8_t sps_scc_extension_flag;
  260. uint8_t sps_extension_4bits;
  261. H265RawExtensionData extension_data;
  262. // Range extension.
  263. uint8_t transform_skip_rotation_enabled_flag;
  264. uint8_t transform_skip_context_enabled_flag;
  265. uint8_t implicit_rdpcm_enabled_flag;
  266. uint8_t explicit_rdpcm_enabled_flag;
  267. uint8_t extended_precision_processing_flag;
  268. uint8_t intra_smoothing_disabled_flag;
  269. uint8_t high_precision_offsets_enabled_flag;
  270. uint8_t persistent_rice_adaptation_enabled_flag;
  271. uint8_t cabac_bypass_alignment_enabled_flag;
  272. // Screen content coding extension.
  273. uint8_t sps_curr_pic_ref_enabled_flag;
  274. uint8_t palette_mode_enabled_flag;
  275. uint8_t palette_max_size;
  276. uint8_t delta_palette_max_predictor_size;
  277. uint8_t sps_palette_predictor_initializer_present_flag;
  278. uint8_t sps_num_palette_predictor_initializer_minus1;
  279. uint16_t sps_palette_predictor_initializers[3][128];
  280. uint8_t motion_vector_resolution_control_idc;
  281. uint8_t intra_boundary_filtering_disable_flag;
  282. } H265RawSPS;
  283. typedef struct H265RawPPS {
  284. H265RawNALUnitHeader nal_unit_header;
  285. uint8_t pps_pic_parameter_set_id;
  286. uint8_t pps_seq_parameter_set_id;
  287. uint8_t dependent_slice_segments_enabled_flag;
  288. uint8_t output_flag_present_flag;
  289. uint8_t num_extra_slice_header_bits;
  290. uint8_t sign_data_hiding_enabled_flag;
  291. uint8_t cabac_init_present_flag;
  292. uint8_t num_ref_idx_l0_default_active_minus1;
  293. uint8_t num_ref_idx_l1_default_active_minus1;
  294. int8_t init_qp_minus26;
  295. uint8_t constrained_intra_pred_flag;
  296. uint8_t transform_skip_enabled_flag;
  297. uint8_t cu_qp_delta_enabled_flag;
  298. uint8_t diff_cu_qp_delta_depth;
  299. int8_t pps_cb_qp_offset;
  300. int8_t pps_cr_qp_offset;
  301. uint8_t pps_slice_chroma_qp_offsets_present_flag;
  302. uint8_t weighted_pred_flag;
  303. uint8_t weighted_bipred_flag;
  304. uint8_t transquant_bypass_enabled_flag;
  305. uint8_t tiles_enabled_flag;
  306. uint8_t entropy_coding_sync_enabled_flag;
  307. uint8_t num_tile_columns_minus1;
  308. uint8_t num_tile_rows_minus1;
  309. uint8_t uniform_spacing_flag;
  310. uint16_t column_width_minus1[HEVC_MAX_TILE_COLUMNS];
  311. uint16_t row_height_minus1[HEVC_MAX_TILE_ROWS];
  312. uint8_t loop_filter_across_tiles_enabled_flag;
  313. uint8_t pps_loop_filter_across_slices_enabled_flag;
  314. uint8_t deblocking_filter_control_present_flag;
  315. uint8_t deblocking_filter_override_enabled_flag;
  316. uint8_t pps_deblocking_filter_disabled_flag;
  317. int8_t pps_beta_offset_div2;
  318. int8_t pps_tc_offset_div2;
  319. uint8_t pps_scaling_list_data_present_flag;
  320. H265RawScalingList scaling_list;
  321. uint8_t lists_modification_present_flag;
  322. uint8_t log2_parallel_merge_level_minus2;
  323. uint8_t slice_segment_header_extension_present_flag;
  324. uint8_t pps_extension_present_flag;
  325. uint8_t pps_range_extension_flag;
  326. uint8_t pps_multilayer_extension_flag;
  327. uint8_t pps_3d_extension_flag;
  328. uint8_t pps_scc_extension_flag;
  329. uint8_t pps_extension_4bits;
  330. H265RawExtensionData extension_data;
  331. // Range extension.
  332. uint8_t log2_max_transform_skip_block_size_minus2;
  333. uint8_t cross_component_prediction_enabled_flag;
  334. uint8_t chroma_qp_offset_list_enabled_flag;
  335. uint8_t diff_cu_chroma_qp_offset_depth;
  336. uint8_t chroma_qp_offset_list_len_minus1;
  337. int8_t cb_qp_offset_list[6];
  338. int8_t cr_qp_offset_list[6];
  339. uint8_t log2_sao_offset_scale_luma;
  340. uint8_t log2_sao_offset_scale_chroma;
  341. // Screen content coding extension.
  342. uint8_t pps_curr_pic_ref_enabled_flag;
  343. uint8_t residual_adaptive_colour_transform_enabled_flag;
  344. uint8_t pps_slice_act_qp_offsets_present_flag;
  345. int8_t pps_act_y_qp_offset_plus5;
  346. int8_t pps_act_cb_qp_offset_plus5;
  347. int8_t pps_act_cr_qp_offset_plus3;
  348. uint8_t pps_palette_predictor_initializer_present_flag;
  349. uint8_t pps_num_palette_predictor_initializer;
  350. uint8_t monochrome_palette_flag;
  351. uint8_t luma_bit_depth_entry_minus8;
  352. uint8_t chroma_bit_depth_entry_minus8;
  353. uint16_t pps_palette_predictor_initializers[3][128];
  354. } H265RawPPS;
  355. typedef struct H265RawAUD {
  356. H265RawNALUnitHeader nal_unit_header;
  357. uint8_t pic_type;
  358. } H265RawAUD;
  359. typedef struct H265RawSliceHeader {
  360. H265RawNALUnitHeader nal_unit_header;
  361. uint8_t first_slice_segment_in_pic_flag;
  362. uint8_t no_output_of_prior_pics_flag;
  363. uint8_t slice_pic_parameter_set_id;
  364. uint8_t dependent_slice_segment_flag;
  365. uint16_t slice_segment_address;
  366. uint8_t slice_reserved_flag[8];
  367. uint8_t slice_type;
  368. uint8_t pic_output_flag;
  369. uint8_t colour_plane_id;
  370. uint16_t slice_pic_order_cnt_lsb;
  371. uint8_t short_term_ref_pic_set_sps_flag;
  372. H265RawSTRefPicSet short_term_ref_pic_set;
  373. uint8_t short_term_ref_pic_set_idx;
  374. uint8_t num_long_term_sps;
  375. uint8_t num_long_term_pics;
  376. uint8_t lt_idx_sps[HEVC_MAX_REFS];
  377. uint8_t poc_lsb_lt[HEVC_MAX_REFS];
  378. uint8_t used_by_curr_pic_lt_flag[HEVC_MAX_REFS];
  379. uint8_t delta_poc_msb_present_flag[HEVC_MAX_REFS];
  380. uint32_t delta_poc_msb_cycle_lt[HEVC_MAX_REFS];
  381. uint8_t slice_temporal_mvp_enabled_flag;
  382. uint8_t slice_sao_luma_flag;
  383. uint8_t slice_sao_chroma_flag;
  384. uint8_t num_ref_idx_active_override_flag;
  385. uint8_t num_ref_idx_l0_active_minus1;
  386. uint8_t num_ref_idx_l1_active_minus1;
  387. uint8_t ref_pic_list_modification_flag_l0;
  388. uint8_t list_entry_l0[HEVC_MAX_REFS];
  389. uint8_t ref_pic_list_modification_flag_l1;
  390. uint8_t list_entry_l1[HEVC_MAX_REFS];
  391. uint8_t mvd_l1_zero_flag;
  392. uint8_t cabac_init_flag;
  393. uint8_t collocated_from_l0_flag;
  394. uint8_t collocated_ref_idx;
  395. uint8_t luma_log2_weight_denom;
  396. int8_t delta_chroma_log2_weight_denom;
  397. uint8_t luma_weight_l0_flag[HEVC_MAX_REFS];
  398. uint8_t chroma_weight_l0_flag[HEVC_MAX_REFS];
  399. int8_t delta_luma_weight_l0[HEVC_MAX_REFS];
  400. int16_t luma_offset_l0[HEVC_MAX_REFS];
  401. int8_t delta_chroma_weight_l0[HEVC_MAX_REFS][2];
  402. int16_t chroma_offset_l0[HEVC_MAX_REFS][2];
  403. uint8_t luma_weight_l1_flag[HEVC_MAX_REFS];
  404. uint8_t chroma_weight_l1_flag[HEVC_MAX_REFS];
  405. int8_t delta_luma_weight_l1[HEVC_MAX_REFS];
  406. int16_t luma_offset_l1[HEVC_MAX_REFS];
  407. int8_t delta_chroma_weight_l1[HEVC_MAX_REFS][2];
  408. int16_t chroma_offset_l1[HEVC_MAX_REFS][2];
  409. uint8_t five_minus_max_num_merge_cand;
  410. uint8_t use_integer_mv_flag;
  411. int8_t slice_qp_delta;
  412. int8_t slice_cb_qp_offset;
  413. int8_t slice_cr_qp_offset;
  414. int8_t slice_act_y_qp_offset;
  415. int8_t slice_act_cb_qp_offset;
  416. int8_t slice_act_cr_qp_offset;
  417. uint8_t cu_chroma_qp_offset_enabled_flag;
  418. uint8_t deblocking_filter_override_flag;
  419. uint8_t slice_deblocking_filter_disabled_flag;
  420. int8_t slice_beta_offset_div2;
  421. int8_t slice_tc_offset_div2;
  422. uint8_t slice_loop_filter_across_slices_enabled_flag;
  423. uint16_t num_entry_point_offsets;
  424. uint8_t offset_len_minus1;
  425. uint32_t entry_point_offset_minus1[HEVC_MAX_ENTRY_POINT_OFFSETS];
  426. uint16_t slice_segment_header_extension_length;
  427. uint8_t slice_segment_header_extension_data_byte[256];
  428. } H265RawSliceHeader;
  429. typedef struct H265RawSlice {
  430. H265RawSliceHeader header;
  431. uint8_t *data;
  432. size_t data_size;
  433. int data_bit_start;
  434. AVBufferRef *data_ref;
  435. } H265RawSlice;
  436. typedef struct H265RawSEIBufferingPeriod {
  437. uint8_t bp_seq_parameter_set_id;
  438. uint8_t irap_cpb_params_present_flag;
  439. uint32_t cpb_delay_offset;
  440. uint32_t dpb_delay_offset;
  441. uint8_t concatenation_flag;
  442. uint32_t au_cpb_removal_delay_delta_minus1;
  443. uint32_t nal_initial_cpb_removal_delay[HEVC_MAX_CPB_CNT];
  444. uint32_t nal_initial_cpb_removal_offset[HEVC_MAX_CPB_CNT];
  445. uint32_t nal_initial_alt_cpb_removal_delay[HEVC_MAX_CPB_CNT];
  446. uint32_t nal_initial_alt_cpb_removal_offset[HEVC_MAX_CPB_CNT];
  447. uint32_t vcl_initial_cpb_removal_delay[HEVC_MAX_CPB_CNT];
  448. uint32_t vcl_initial_cpb_removal_offset[HEVC_MAX_CPB_CNT];
  449. uint32_t vcl_initial_alt_cpb_removal_delay[HEVC_MAX_CPB_CNT];
  450. uint32_t vcl_initial_alt_cpb_removal_offset[HEVC_MAX_CPB_CNT];
  451. uint8_t use_alt_cpb_params_flag;
  452. } H265RawSEIBufferingPeriod;
  453. typedef struct H265RawSEIPicTiming {
  454. uint8_t pic_struct;
  455. uint8_t source_scan_type;
  456. uint8_t duplicate_flag;
  457. uint32_t au_cpb_removal_delay_minus1;
  458. uint32_t pic_dpb_output_delay;
  459. uint32_t pic_dpb_output_du_delay;
  460. uint16_t num_decoding_units_minus1;
  461. uint8_t du_common_cpb_removal_delay_flag;
  462. uint32_t du_common_cpb_removal_delay_increment_minus1;
  463. uint16_t num_nalus_in_du_minus1[HEVC_MAX_SLICE_SEGMENTS];
  464. uint32_t du_cpb_removal_delay_increment_minus1[HEVC_MAX_SLICE_SEGMENTS];
  465. } H265RawSEIPicTiming;
  466. typedef struct H265RawSEIPanScanRect {
  467. uint32_t pan_scan_rect_id;
  468. uint8_t pan_scan_rect_cancel_flag;
  469. uint8_t pan_scan_cnt_minus1;
  470. int32_t pan_scan_rect_left_offset[3];
  471. int32_t pan_scan_rect_right_offset[3];
  472. int32_t pan_scan_rect_top_offset[3];
  473. int32_t pan_scan_rect_bottom_offset[3];
  474. uint16_t pan_scan_rect_persistence_flag;
  475. } H265RawSEIPanScanRect;
  476. typedef struct H265RawSEIUserDataRegistered {
  477. uint8_t itu_t_t35_country_code;
  478. uint8_t itu_t_t35_country_code_extension_byte;
  479. uint8_t *data;
  480. size_t data_length;
  481. AVBufferRef *data_ref;
  482. } H265RawSEIUserDataRegistered;
  483. typedef struct H265RawSEIUserDataUnregistered {
  484. uint8_t uuid_iso_iec_11578[16];
  485. uint8_t *data;
  486. size_t data_length;
  487. AVBufferRef *data_ref;
  488. } H265RawSEIUserDataUnregistered;
  489. typedef struct H265RawSEIRecoveryPoint {
  490. int16_t recovery_poc_cnt;
  491. uint8_t exact_match_flag;
  492. uint8_t broken_link_flag;
  493. } H265RawSEIRecoveryPoint;
  494. typedef struct H265RawSEIDisplayOrientation {
  495. uint8_t display_orientation_cancel_flag;
  496. uint8_t hor_flip;
  497. uint8_t ver_flip;
  498. uint16_t anticlockwise_rotation;
  499. uint16_t display_orientation_repetition_period;
  500. uint8_t display_orientation_persistence_flag;
  501. } H265RawSEIDisplayOrientation;
  502. typedef struct H265RawSEIActiveParameterSets {
  503. uint8_t active_video_parameter_set_id;
  504. uint8_t self_contained_cvs_flag;
  505. uint8_t no_parameter_set_update_flag;
  506. uint8_t num_sps_ids_minus1;
  507. uint8_t active_seq_parameter_set_id[HEVC_MAX_SPS_COUNT];
  508. uint8_t layer_sps_idx[HEVC_MAX_LAYERS];
  509. } H265RawSEIActiveParameterSets;
  510. typedef struct H265RawSEIDecodedPictureHash {
  511. uint8_t hash_type;
  512. uint8_t picture_md5[3][16];
  513. uint16_t picture_crc[3];
  514. uint32_t picture_checksum[3];
  515. } H265RawSEIDecodedPictureHash;
  516. typedef struct H265RawSEITimeCode {
  517. uint8_t num_clock_ts;
  518. uint8_t clock_timestamp_flag[3];
  519. uint8_t units_field_based_flag[3];
  520. uint8_t counting_type[3];
  521. uint8_t full_timestamp_flag[3];
  522. uint8_t discontinuity_flag[3];
  523. uint8_t cnt_dropped_flag[3];
  524. uint16_t n_frames[3];
  525. uint8_t seconds_value[3];
  526. uint8_t minutes_value[3];
  527. uint8_t hours_value[3];
  528. uint8_t seconds_flag[3];
  529. uint8_t minutes_flag[3];
  530. uint8_t hours_flag[3];
  531. uint8_t time_offset_length[3];
  532. int32_t time_offset_value[3];
  533. } H265RawSEITimeCode;
  534. typedef struct H265RawSEIMasteringDisplayColourVolume {
  535. uint16_t display_primaries_x[3];
  536. uint16_t display_primaries_y[3];
  537. uint16_t white_point_x;
  538. uint16_t white_point_y;
  539. uint32_t max_display_mastering_luminance;
  540. uint32_t min_display_mastering_luminance;
  541. } H265RawSEIMasteringDisplayColourVolume;
  542. typedef struct H265RawSEIContentLightLevelInfo {
  543. uint16_t max_content_light_level;
  544. uint16_t max_pic_average_light_level;
  545. } H265RawSEIContentLightLevelInfo;
  546. typedef struct H265RawSEIAlternativeTransferCharacteristics {
  547. uint8_t preferred_transfer_characteristics;
  548. } H265RawSEIAlternativeTransferCharacteristics;
  549. typedef struct H265RawSEIAlphaChannelInfo {
  550. uint8_t alpha_channel_cancel_flag;
  551. uint8_t alpha_channel_use_idc;
  552. uint8_t alpha_channel_bit_depth_minus8;
  553. uint16_t alpha_transparent_value;
  554. uint16_t alpha_opaque_value;
  555. uint8_t alpha_channel_incr_flag;
  556. uint8_t alpha_channel_clip_flag;
  557. uint8_t alpha_channel_clip_type_flag;
  558. } H265RawSEIAlphaChannelInfo;
  559. typedef struct H265RawSEIPayload {
  560. uint32_t payload_type;
  561. uint32_t payload_size;
  562. union {
  563. H265RawSEIBufferingPeriod buffering_period;
  564. H265RawSEIPicTiming pic_timing;
  565. H265RawSEIPanScanRect pan_scan_rect;
  566. H265RawSEIUserDataRegistered user_data_registered;
  567. H265RawSEIUserDataUnregistered user_data_unregistered;
  568. H265RawSEIRecoveryPoint recovery_point;
  569. H265RawSEIDisplayOrientation display_orientation;
  570. H265RawSEIActiveParameterSets active_parameter_sets;
  571. H265RawSEIDecodedPictureHash decoded_picture_hash;
  572. H265RawSEITimeCode time_code;
  573. H265RawSEIMasteringDisplayColourVolume mastering_display;
  574. H265RawSEIContentLightLevelInfo content_light_level;
  575. H265RawSEIAlternativeTransferCharacteristics
  576. alternative_transfer_characteristics;
  577. H265RawSEIAlphaChannelInfo alpha_channel_info;
  578. struct {
  579. uint8_t *data;
  580. size_t data_length;
  581. AVBufferRef *data_ref;
  582. } other;
  583. } payload;
  584. H265RawExtensionData extension_data;
  585. } H265RawSEIPayload;
  586. typedef struct H265RawSEI {
  587. H265RawNALUnitHeader nal_unit_header;
  588. H265RawSEIPayload payload[H265_MAX_SEI_PAYLOADS];
  589. uint8_t payload_count;
  590. } H265RawSEI;
  591. typedef struct CodedBitstreamH265Context {
  592. // Reader/writer context in common with the H.264 implementation.
  593. CodedBitstreamH2645Context common;
  594. // All currently available parameter sets. These are updated when
  595. // any parameter set NAL unit is read/written with this context.
  596. AVBufferRef *vps_ref[HEVC_MAX_VPS_COUNT];
  597. AVBufferRef *sps_ref[HEVC_MAX_SPS_COUNT];
  598. AVBufferRef *pps_ref[HEVC_MAX_PPS_COUNT];
  599. H265RawVPS *vps[HEVC_MAX_VPS_COUNT];
  600. H265RawSPS *sps[HEVC_MAX_SPS_COUNT];
  601. H265RawPPS *pps[HEVC_MAX_PPS_COUNT];
  602. // The currently active parameter sets. These are updated when any
  603. // NAL unit refers to the relevant parameter set. These pointers
  604. // must also be present in the arrays above.
  605. const H265RawVPS *active_vps;
  606. const H265RawSPS *active_sps;
  607. const H265RawPPS *active_pps;
  608. } CodedBitstreamH265Context;
  609. #endif /* AVCODEC_CBS_H265_H */