1 /* packet-h265.c
2 * Routines for H.265 dissection
3 * Copyright 2018, Asaf Kave <kave.asaf[at]gmail.com>
4 * Based on the H.264 dissector, thanks!
5 *
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 *
12 * References:
13 * https://tools.ietf.org/html/rfc7798
14 * http://www.itu.int/rec/T-REC-H.265/en
15 */
16 
17 #include "config.h"
18 
19 
20 #include <epan/packet.h>
21 #include <epan/asn1.h>
22 #include <epan/expert.h>
23 #include <epan/prefs.h>
24 #include "packet-h265.h"
25 #include "math.h"
26 
27 void proto_register_h265(void);
28 void proto_reg_handoff_h265(void);
29 
30 /* Initialize the protocol and registered fields */
31 static int proto_h265 = -1;
32 static int hf_h265_type = -1;
33 static int hf_h265_nal_unit_type = -1;
34 static int hf_h265_nuh_layer_id = -1;
35 static int hf_h265_nuh_temporal_id_plus1 = -1;
36 static int hf_h265_nal_f_bit = -1;
37 static int hf_h265_start_bit = -1;
38 static int hf_h265_end_bit = -1;
39 static int hf_h265_rbsp_stop_bit = -1;
40 static int hf_h265_rbsp_trailing_bits = -1;
41 
42 /* SDP */
43 static int hf_h265_sdp_parameter_sprop_vps = -1;
44 static int hf_h265_sdp_parameter_sprop_sps = -1;
45 static int hf_h265_sdp_parameter_sprop_pps = -1;
46 
47 /*vps*/
48 static int hf_h265_vps_video_parameter_set_id = -1;
49 static int hf_h265_vps_base_layer_internal_flag = -1;
50 static int hf_h265_vps_base_layer_available_flag = -1;
51 static int hf_h265_vps_max_layers_minus1 = -1;
52 static int hf_h265_vps_max_sub_layers_minus1 = -1;
53 static int hf_h265_vps_temporal_id_nesting_flag = -1;
54 static int hf_h265_vps_reserved_0xffff_16bits = -1;
55 static int hf_h265_vps_sub_layer_ordering_info_present_flag = -1;
56 static int hf_h265_vps_max_dec_pic_buffering_minus1/*[i]*/ = -1;
57 static int hf_h265_vps_max_num_reorder_pics/*[i]*/ = -1;
58 static int hf_h265_vps_max_latency_increase_plus1/*[i]*/ = -1;
59 static int hf_h265_vps_max_layer_id = -1;
60 static int hf_h265_vps_num_layer_sets_minus1 = -1;
61 static int hf_h265_layer_id_included_flag/*[i][j]*/ = -1;
62 static int hf_h265_vps_timing_info_present_flag = -1;
63 static int hf_h265_vps_num_units_in_tick = -1;
64 static int hf_h265_vps_time_scale = -1;
65 static int hf_h265_vps_poc_proportional_to_timing_flag = -1;
66 static int hf_h265_vps_num_ticks_poc_diff_one_minus1 = -1;
67 static int hf_h265_vps_num_hrd_parameters = -1;
68 static int hf_h265_hrd_layer_set_idx/*[i]*/ = -1;
69 static int hf_h265_cprms_present_flag/*[i]*/ = -1;
70 static int hf_h265_vps_extension_flag = -1;
71 static int hf_h265_vps_extension_data_flag = -1;
72 
73 /* profile_tier_level  */
74 static int hf_h265_general_profile_space = -1;
75 static int hf_h265_general_tier_flag = -1;
76 static int hf_h265_general_profile_idc = -1;
77 static int hf_h265_general_profile_compatibility_flags/*[j]*/ = -1;
78 static int hf_h265_general_progressive_source_flag = -1;
79 static int hf_h265_general_interlaced_source_flag = -1;
80 static int hf_h265_general_non_packed_constraint_flag = -1;
81 static int hf_h265_general_frame_only_constraint_flag = -1;
82 static int hf_h265_general_max_12bit_constraint_flag = -1;
83 static int hf_h265_general_max_10bit_constraint_flag = -1;
84 static int hf_h265_general_max_8bit_constraint_flag = -1;
85 static int hf_h265_general_max_422chroma_constraint_flag = -1;
86 static int hf_h265_general_max_420chroma_constraint_flag = -1;
87 static int hf_h265_general_max_monochrome_constraint_flag = -1;
88 static int hf_h265_general_intra_constraint_flag = -1;
89 static int hf_h265_general_one_picture_only_constraint_flag = -1;
90 static int hf_h265_general_lower_bit_rate_constraint_flag = -1;
91 static int hf_h265_general_max_14bit_constraint_flag = -1;
92 static int hf_h265_general_reserved_zero_33bits = -1;
93 static int hf_h265_general_reserved_zero_34bits = -1;
94 static int hf_h265_general_reserved_zero_7bits = -1;
95 static int hf_h265_general_reserved_zero_35bits = -1;
96 static int hf_h265_general_reserved_zero_43bits = -1;
97 static int hf_h265_general_inbld_flag = -1;
98 static int hf_h265_general_reserved_zero_bit = -1;
99 static int hf_h265_general_level_idc = -1;
100 static int hf_h265_sub_layer_profile_present_flag/*[i]*/ = -1;
101 static int hf_h265_sub_layer_level_present_flag/*[i]*/ = -1;
102 static int hf_h265_reserved_zero_2bits/*[i]*/ = -1;
103 static int hf_h265_sub_layer_profile_space/*[i]*/ = -1;
104 static int hf_h265_sub_layer_tier_flag/*[i]*/ = -1;
105 static int hf_h265_sub_layer_profile_idc/*[i]*/ = -1;
106 static int hf_h265_sub_layer_profile_compatibility_flag/*[i][j]*/ = -1;
107 static int hf_h265_sub_layer_progressive_source_flag/*[i]*/ = -1;
108 static int hf_h265_sub_layer_interlaced_source_flag/*[i]*/ = -1;
109 static int hf_h265_sub_layer_non_packed_constraint_flag/*[i]*/ = -1;
110 static int hf_h265_sub_layer_frame_only_constraint_flag/*[i]*/ = -1;
111 static int hf_h265_sub_layer_max_12bit_constraint_flag/*[i]*/ = -1;
112 static int hf_h265_sub_layer_max_10bit_constraint_flag/*[i]*/ = -1;
113 static int hf_h265_sub_layer_max_8bit_constraint_flag/*[i]*/ = -1;
114 static int hf_h265_sub_layer_max_422chroma_constraint_flag/*[i]*/ = -1;
115 static int hf_h265_sub_layer_max_420chroma_constraint_flag/*[i]*/ = -1;
116 static int hf_h265_sub_layer_max_monochrome_constraint_flag/*[i]*/ = -1;
117 static int hf_h265_sub_layer_intra_constraint_flag/*[i]*/ = -1;
118 static int hf_h265_sub_layer_one_picture_only_constraint_flag/*[i]*/ = -1;
119 static int hf_h265_sub_layer_lower_bit_rate_constraint_flag/*[i]*/ = -1;
120 static int hf_h265_sub_layer_max_14bit_constraint_flag/*[i]*/ = -1;
121 static int hf_h265_sub_layer_reserved_zero_33bits/*[i]*/ = -1;
122 static int hf_h265_sub_layer_reserved_zero_34bits/*[i]*/ = -1;
123 static int hf_h265_sub_layer_reserved_zero_7bits/*[i]*/ = -1;
124 static int hf_h265_sub_layer_reserved_zero_35bits/*[i]*/ = -1;
125 static int hf_h265_sub_layer_reserved_zero_43bits/*[i]*/ = -1;
126 static int hf_h265_sub_layer_inbld_flag/*[i]*/ = -1;
127 static int hf_h265_sub_layer_reserved_zero_bit/*[i]*/ = -1;
128 static int hf_h265_sub_layer_level_idc/*[i]*/ = -1;
129 
130 /* hrd_parameters */
131 static int hf_h265_nal_hrd_parameters_present_flag = -1;
132 static int hf_h265_vcl_hrd_parameters_present_flag = -1;
133 static int hf_h265_sub_pic_hrd_params_present_flag = -1;
134 static int hf_h265_tick_divisor_minus2 = -1;
135 static int hf_h265_du_cpb_removal_delay_increment_length_minus1 = -1;
136 static int hf_h265_sub_pic_cpb_params_in_pic_timing_sei_flag = -1;
137 static int hf_h265_dpb_output_delay_du_length_minus1 = -1;
138 static int hf_h265_bit_rate_scale = -1;
139 static int hf_h265_cpb_size_scale = -1;
140 static int hf_h265_cpb_size_du_scale = -1;
141 static int hf_h265_initial_cpb_removal_delay_length_minus1 = -1;
142 static int hf_h265_au_cpb_removal_delay_length_minus1 = -1;
143 static int hf_h265_dpb_output_delay_length_minus1 = -1;
144 static int hf_h265_fixed_pic_rate_general_flag/*[i]*/ = -1;
145 static int hf_h265_fixed_pic_rate_within_cvs_flag/*[i]*/ = -1;
146 static int hf_h265_elemental_duration_in_tc_minus1/*[i]*/ = -1;
147 static int hf_h265_low_delay_hrd_flag/*[i]*/ = -1;
148 static int hf_h265_cpb_cnt_minus1/*[i]*/ = -1;
149 /* sub-layer hrd_parameters */
150 static int hf_h265_bit_rate_value_minus1/*[i]*/ = -1;
151 static int hf_h265_cpb_size_value_minus1/*[i]*/ = -1;
152 static int hf_h265_cpb_size_du_value_minus1/*[i]*/ = -1;
153 static int hf_h265_bit_rate_du_value_minus1/*[i]*/ = -1;
154 static int hf_h265_cbr_flag/*[i]*/ = -1;
155 
156 /*sps*/
157 static int hf_h265_sps_video_parameter_set_id = -1;
158 static int hf_h265_sps_max_sub_layers_minus1 = -1;
159 static int hf_h265_sps_temporal_id_nesting_flag = -1;
160 static int hf_h265_sps_seq_parameter_set_id = -1;
161 static int hf_h265_chroma_format_idc = -1;
162 static int hf_h265_separate_colour_plane_flag = -1;
163 static int hf_h265_pic_width_in_luma_samples = -1;
164 static int hf_h265_pic_height_in_luma_samples = -1;
165 static int hf_h265_conformance_window_flag = -1;
166 static int hf_h265_conf_win_left_offset = -1;
167 static int hf_h265_conf_win_right_offset = -1;
168 static int hf_h265_conf_win_top_offset = -1;
169 static int hf_h265_conf_win_bottom_offset = -1;
170 static int hf_h265_bit_depth_luma_minus8 = -1;
171 static int hf_h265_bit_depth_chroma_minus8 = -1;
172 static int hf_h265_log2_max_pic_order_cnt_lsb_minus4 = -1;
173 static int hf_h265_sps_sub_layer_ordering_info_present_flag = -1;
174 static int hf_h265_sps_max_dec_pic_buffering_minus1/*[i]*/ = -1;
175 static int hf_h265_sps_max_num_reorder_pics/*[i]*/ = -1;
176 static int hf_h265_sps_max_latency_increase_plus1/*[i]*/ = -1;
177 static int hf_h265_log2_min_luma_coding_block_size_minus3 = -1;
178 static int hf_h265_log2_diff_max_min_luma_coding_block_size = -1;
179 static int hf_h265_log2_min_luma_transform_block_size_minus2 = -1;
180 static int hf_h265_log2_diff_max_min_luma_transform_block_size = -1;
181 static int hf_h265_max_transform_hierarchy_depth_inter = -1;
182 static int hf_h265_max_transform_hierarchy_depth_intra = -1;
183 static int hf_h265_scaling_list_enabled_flag = -1;
184 static int hf_h265_sps_scaling_list_data_present_flag = -1;
185 static int hf_h265_amp_enabled_flag = -1;
186 static int hf_h265_sample_adaptive_offset_enabled_flag = -1;
187 static int hf_h265_pcm_enabled_flag = -1;
188 static int hf_h265_pcm_sample_bit_depth_luma_minus1 = -1;
189 static int hf_h265_pcm_sample_bit_depth_chroma_minus1 = -1;
190 static int hf_h265_log2_min_pcm_luma_coding_block_size_minus3 = -1;
191 static int hf_h265_log2_diff_max_min_pcm_luma_coding_block_size = -1;
192 static int hf_h265_pcm_loop_filter_disabled_flag = -1;
193 static int hf_h265_num_short_term_ref_pic_sets = -1;
194 static int hf_h265_long_term_ref_pics_present_flag = -1;
195 static int hf_h265_num_long_term_ref_pics_sps = -1;
196 static int hf_h265_lt_ref_pic_poc_lsb_sps/*[i]*/ = -1;
197 static int hf_h265_used_by_curr_pic_lt_sps_flag/*[i]*/ = -1;
198 static int hf_h265_sps_temporal_mvp_enabled_flag = -1;
199 static int hf_h265_strong_intra_smoothing_enabled_flag = -1;
200 static int hf_h265_vui_parameters_present_flag = -1;
201 static int hf_h265_sps_extension_present_flag = -1;
202 static int hf_h265_sps_range_extension_flag = -1;
203 static int hf_h265_sps_multilayer_extension_flag = -1;
204 static int hf_h265_sps_3d_extension_flag = -1;
205 static int hf_h265_sps_scc_extension_flag = -1;
206 static int hf_h265_sps_extension_4bits = -1;
207 static int hf_h265_sps_extension_data_flag = -1;
208 /* scaling_list_data */
209 static int hf_h265_scaling_list_pred_mode_flag/*[sizeId][matrixId]*/ = -1;
210 static int hf_h265_scaling_list_pred_matrix_id_delta/*[sizeId][matrixId]*/ = -1;
211 static int hf_h265_scaling_list_dc_coef_minus8/*[sizeId - 2][matrixId]*/ = -1;
212 static int hf_h265_scaling_list_delta_coef = -1;
213 /* st_ref_pic_set */
214 static int hf_h265_inter_ref_pic_set_prediction_flag = -1;
215 static int hf_h265_delta_idx_minus1 = -1;
216 static int hf_h265_delta_rps_sign = -1;
217 static int hf_h265_abs_delta_rps_minus1 = -1;
218 static int hf_h265_used_by_curr_pic_flag/*[j]*/ = -1;
219 static int hf_h265_use_delta_flag/*[j]*/ = -1;
220 static int hf_h265_num_negative_pics = -1;
221 static int hf_h265_num_positive_pics = -1;
222 static int hf_h265_delta_poc_s0_minus1/*[i]*/ = -1;
223 static int hf_h265_used_by_curr_pic_s0_flag/*[i]*/ = -1;
224 static int hf_h265_delta_poc_s1_minus1/*[i]*/ = -1;
225 static int hf_h265_used_by_curr_pic_s1_flag/*[i]*/ = -1;
226 /* sps_range_extension */
227 static int hf_h265_transform_skip_rotation_enabled_flag = -1;
228 static int hf_h265_transform_skip_context_enabled_flag = -1;
229 static int hf_h265_implicit_rdpcm_enabled_flag = -1;
230 static int hf_h265_explicit_rdpcm_enabled_flag = -1;
231 static int hf_h265_extended_precision_processing_flag = -1;
232 static int hf_h265_intra_smoothing_disabled_flag = -1;
233 static int hf_h265_high_precision_offsets_enabled_flag = -1;
234 static int hf_h265_persistent_rice_adaptation_enabled_flag = -1;
235 static int hf_h265_cabac_bypass_alignment_enabled_flag = -1;
236 /* sps_scc_extension */
237 static int hf_h265_sps_curr_pic_ref_enabled_flag = -1;
238 static int hf_h265_palette_mode_enabled_flag = -1;
239 static int hf_h265_palette_max_size = -1;
240 static int hf_h265_delta_palette_max_predictor_size = -1;
241 static int hf_h265_sps_palette_predictor_initializers_present_flag = -1;
242 static int hf_h265_sps_num_palette_predictor_initializers_minus1 = -1;
243 static int hf_h265_sps_palette_predictor_initializer/*[comp][i]*/ = -1;
244 static int hf_h265_motion_vector_resolution_control_idc = -1;
245 static int hf_h265_intra_boundary_filtering_disabled_flag = -1;
246 
247 /* PPS */
248 static int hf_h265_pps_pic_parameter_set_id = -1;
249 static int hf_h265_pps_seq_parameter_set_id = -1;
250 static int hf_h265_dependent_slice_segments_enabled_flag = -1;
251 static int hf_h265_output_flag_present_flag = -1;
252 static int hf_h265_num_extra_slice_header_bits = -1;
253 static int hf_h265_sign_data_hiding_enabled_flag = -1;
254 static int hf_h265_cabac_init_present_flag = -1;
255 static int hf_h265_num_ref_idx_l0_default_active_minus1 = -1;
256 static int hf_h265_num_ref_idx_l1_default_active_minus1 = -1;
257 static int hf_h265_init_qp_minus26 = -1;
258 static int hf_h265_constrained_intra_pred_flag = -1;
259 static int hf_h265_transform_skip_enabled_flag = -1;
260 static int hf_h265_cu_qp_delta_enabled_flag = -1;
261 static int hf_h265_diff_cu_qp_delta_depth = -1;
262 static int hf_h265_pps_cb_qp_offset = -1;
263 static int hf_h265_pps_cr_qp_offset = -1;
264 static int hf_h265_pps_slice_chroma_qp_offsets_present_flag = -1;
265 static int hf_h265_weighted_pred_flag = -1;
266 static int hf_h265_weighted_bipred_flag = -1;
267 static int hf_h265_transquant_bypass_enabled_flag = -1;
268 static int hf_h265_tiles_enabled_flag = -1;
269 static int hf_h265_entropy_coding_sync_enabled_flag = -1;
270 static int hf_h265_num_tile_columns_minus1 = -1;
271 static int hf_h265_num_tile_rows_minus1 = -1;
272 static int hf_h265_uniform_spacing_flag = -1;
273 static int hf_h265_column_width_minus1/*[i]*/ = -1;
274 static int hf_h265_row_height_minus1/*[i]*/ = -1;
275 static int hf_h265_loop_filter_across_tiles_enabled_flag = -1;
276 static int hf_h265_pps_loop_filter_across_slices_enabled_flag = -1;
277 static int hf_h265_deblocking_filter_control_present_flag = -1;
278 static int hf_h265_deblocking_filter_override_enabled_flag = -1;
279 static int hf_h265_pps_deblocking_filter_disabled_flag = -1;
280 static int hf_h265_pps_beta_offset_div2 = -1;
281 static int hf_h265_pps_tc_offset_div2 = -1;
282 static int hf_h265_pps_scaling_list_data_present_flag = -1;
283 static int hf_h265_lists_modification_present_flag = -1;
284 static int hf_h265_log2_parallel_merge_level_minus2 = -1;
285 static int hf_h265_slice_segment_header_extension_present_flag = -1;
286 static int hf_h265_pps_extension_present_flag = -1;
287 static int hf_h265_pps_range_extension_flag = -1;
288 static int hf_h265_pps_multilayer_extension_flag = -1;
289 static int hf_h265_pps_3d_extension_flag = -1;
290 static int hf_h265_pps_scc_extension_flag = -1;
291 static int hf_h265_pps_extension_4bits = -1;
292 static int hf_h265_pps_extension_data_flag = -1;
293 /*pps_range_extension*/
294 static int hf_h265_log2_max_transform_skip_block_size_minus2 = -1;
295 static int hf_h265_cross_component_prediction_enabled_flag = -1;
296 static int hf_h265_chroma_qp_offset_list_enabled_flag = -1;
297 static int hf_h265_diff_cu_chroma_qp_offset_depth = -1;
298 static int hf_h265_chroma_qp_offset_list_len_minus1 = -1;
299 static int hf_h265_cb_qp_offset_list/*[i]*/ = -1;
300 static int hf_h265_cr_qp_offset_list/*[i]*/ = -1;
301 static int hf_h265_log2_sao_offset_scale_luma = -1;
302 static int hf_h265_log2_sao_offset_scale_chroma = -1;
303 /*pps_scc_extension*/
304 static int hf_h265_pps_curr_pic_ref_enabled_flag = -1;
305 static int hf_h265_residual_adaptive_colour_transform_enabled_flag = -1;
306 static int hf_h265_pps_slice_act_qp_offsets_present_flag = -1;
307 static int hf_h265_pps_act_y_qp_offset_plus5 = -1;
308 static int hf_h265_pps_act_cb_qp_offset_plus5 = -1;
309 static int hf_h265_pps_act_cr_qp_offset_plus3 = -1;
310 static int hf_h265_pps_palette_predictor_initializers_present_flag = -1;
311 static int hf_h265_pps_num_palette_predictor_initializers = -1;
312 static int hf_h265_monochrome_palette_flag = -1;
313 static int hf_h265_luma_bit_depth_entry_minus8 = -1;
314 static int hf_h265_chroma_bit_depth_entry_minus8 = -1;
315 static int hf_h265_pps_palette_predictor_initializer/*[comp][i]*/ = -1;
316 
317 /* VUI parameters */
318 static int hf_h265_aspect_ratio_info_present_flag = -1;
319 static int hf_h265_aspect_ratio_idc = -1;
320 static int hf_h265_sar_width = -1;
321 static int hf_h265_sar_height = -1;
322 static int hf_h265_overscan_info_present_flag = -1;
323 static int hf_h265_overscan_appropriate_flag = -1;
324 static int hf_h265_video_signal_type_present_flag = -1;
325 static int hf_h265_video_format = -1;
326 static int hf_h265_video_full_range_flag = -1;
327 static int hf_h265_colour_description_present_flag = -1;
328 static int hf_h265_colour_primaries = -1;
329 static int hf_h265_transfer_characteristics = -1;
330 static int hf_h265_matrix_coeffs = -1;
331 static int hf_h265_chroma_loc_info_present_flag = -1;
332 static int hf_h265_chroma_sample_loc_type_top_field = -1;
333 static int hf_h265_chroma_sample_loc_type_bottom_field = -1;
334 static int hf_h265_neutral_chroma_indication_flag = -1;
335 static int hf_h265_field_seq_flag = -1;
336 static int hf_h265_frame_field_info_present_flag = -1;
337 static int hf_h265_default_display_window_flag = -1;
338 static int hf_h265_def_disp_win_left_offset = -1;
339 static int hf_h265_def_disp_win_right_offset = -1;
340 static int hf_h265_def_disp_win_top_offset = -1;
341 static int hf_h265_def_disp_win_bottom_offset = -1;
342 static int hf_h265_vui_timing_info_present_flag = -1;
343 static int hf_h265_vui_num_units_in_tick = -1;
344 static int hf_h265_vui_time_scale = -1;
345 static int hf_h265_vui_poc_proportional_to_timing_flag = -1;
346 static int hf_h265_vui_num_ticks_poc_diff_one_minus1 = -1;
347 static int hf_h265_vui_hrd_parameters_present_flag = -1;
348 static int hf_h265_bitstream_restriction_flag = -1;
349 static int hf_h265_tiles_fixed_structure_flag = -1;
350 static int hf_h265_motion_vectors_over_pic_boundaries_flag = -1;
351 static int hf_h265_restricted_ref_pic_lists_flag = -1;
352 static int hf_h265_min_spatial_segmentation_idc = -1;
353 static int hf_h265_max_bytes_per_pic_denom = -1;
354 static int hf_h265_max_bits_per_min_cu_denom = -1;
355 static int hf_h265_log2_max_mv_length_horizontal = -1;
356 static int hf_h265_log2_max_mv_length_vertical = -1;
357 
358 /* slice_segment_header */
359 static int hf_h265_slice_pic_parameter_set_id = -1;
360 static int hf_h265_slice_segment_address = -1;
361 static int hf_h265_slice_type = -1;
362 
363 /* SEI */
364 static int hf_h265_payloadsize = -1;
365 static int hf_h265_payloadtype = -1;
366 
367 /* Initialize the subtree pointers */
368 static int ett_h265 = -1;
369 static int ett_h265_profile = -1;
370 static int ett_h265_nal = -1;
371 static int ett_h265_fu = -1;
372 static int ett_h265_stream = -1;
373 
374 static int ett_h265_sps_multilayer_extension = -1;
375 static int ett_h265_sps_3d_extension = -1;
376 static int ett_h265_pps_multilayer_extension = -1;
377 static int ett_h265_pps_3d_extension = -1;
378 static int ett_h265_access_unit_delimiter_rbsp = -1;
379 static int ett_h265_sei_rbsp = -1;
380 static int ett_h265_filler_data_rbsp = -1;
381 static int ett_h265_end_of_seq_rbsp = -1;
382 static int ett_h265_end_of_bitstream_rbsp = -1;
383 static int ett_h265_profile_tier_level = -1;
384 static int ett_h265_vui_parameters = -1;
385 static int ett_h265_hrd_parameters = -1;
386 static int ett_h265_sprop_parameters = -1;
387 
388 static expert_field ei_h265_undecoded = EI_INIT;
389 static expert_field ei_h265_format_specific_parameter = EI_INIT;
390 static expert_field ei_h265_oversized_exp_golomb_code = EI_INIT;
391 static expert_field ei_h265_value_to_large = EI_INIT;
392 
393 /* The dynamic payload type range which will be dissected as H.265 */
394 
395 static range_t *temp_dynamic_payload_type_range = NULL;
396 
397 static dissector_handle_t h265_handle;
398 
399 static gboolean dependent_slice_segments_enabled_flag = 0;
400 static guint num_extra_slice_header_bits = 0;
401 static guint log2_min_luma_coding_block_size_minus3 = 0;
402 static guint log2_diff_max_min_luma_coding_block_size = 0;
403 static guint pic_width_in_luma_samples = 0;
404 static guint pic_height_in_luma_samples = 0;
405 
406 /* syntax tables in subclause 7.3 is equal to
407 * ue(v), me(v), se(v), or te(v).
408 */
409 typedef enum {
410 	H265_UE_V = 0,
411 	H265_ME_V = 1,
412 	H265_SE_V = 2,
413 	H265_TE_V = 3
414 } h265_golomb_descriptors;
415 
416 
417 static const true_false_string h265_f_bit_vals = {
418 	"Bit errors or other syntax violations",
419 	"No bit errors or other syntax violations"
420 };
421 
422 static const true_false_string h265_start_bit_vals = {
423 	"the first packet of FU-A picture",
424 	"Not the first packet of FU-A picture"
425 };
426 
427 static const true_false_string h265_end_bit_vals = {
428 	"the last packet of FU-A picture",
429 	"Not the last packet of FU-A picture"
430 };
431 
432 static const value_string h265_type_values[] = {
433 	{ 0,   "TRAIL_N - Coded slice segment of a non-TSA, non-STSA trailing picture" },
434 	{ 1,   "TRAIL_R - Coded slice segment of a non-TSA, non-STSA trailing picture" },
435 	{ 2,   "TSA_N - Coded slice segment of a TSA picture" },
436 	{ 3,   "TSA_R - Coded slice segment of a TSA picture" },
437 	{ 4,   "STSA_N - Coded slice segment of an STSA picture" },
438 	{ 5,   "STSA_R - Coded slice segment of an STSA picture" },
439 	{ 6,   "RADL_N - Coded slice segment of a RADL picture" },
440 	{ 7,   "RADL_R - Coded slice segment of a RADL picture" },
441 	{ 8,   "RASL_N - Coded slice segment of a RASL picture" },
442 	{ 9,   "RASL_R - Coded slice segment of a RASL picture" },
443 	{ 10,  "RSV_VCL_N10 - Reserved non-IRAP SLNR VCL NAL unit types" },
444 	{ 11,  "RSV_VCL_R11 - Reserved non-IRAP sub-layer reference VCL NAL unit types" },
445 	{ 12,  "RSV_VCL_N12 - Reserved non-IRAP SLNR VCL NAL unit types" },
446 	{ 13,  "RSV_VCL_R13 - Reserved non-IRAP sub-layer reference VCL NAL unit types" },
447 	{ 14,  "RSV_VCL_N14 - Reserved non-IRAP SLNR VCL NAL unit types" },
448 	{ 15,  "RSV_VCL_R15 - Reserved non-IRAP sub-layer reference VCL NAL unit types" },
449 	{ 16,  "BLA_W_LP - Coded slice segment of a BLA picture" },
450 	{ 17,  "BLA_W_RADL - Coded slice segment of a BLA picture" },
451 	{ 18,  "BLA_N_LP - Coded slice segment of a BLA picture" },
452 	{ 19,  "IDR_W_RADL - Coded slice segment of an IDR picture" },
453 	{ 20,  "IDR_N_LP - Coded slice segment of an IDR picture" },
454 	{ 21,  "CRA_NUT - Coded slice segment of a CRA picture" },
455 	{ 22,  "RSV_IRAP_VCL22 - Reserved IRAP VCL NAL unit types" },
456 	{ 23,  "RSV_IRAP_VCL23 - Reserved IRAP VCL NAL unit types" },
457 	{ 24,  "RSV_VCL24 - Reserved non-IRAP VCL NAL unit types" },
458 	{ 25,  "RSV_VCL25 - Reserved non-IRAP VCL NAL unit types" },
459 	{ 26,  "RSV_VCL26 - Reserved non-IRAP VCL NAL unit types" },
460 	{ 27,  "RSV_VCL27 - Reserved non-IRAP VCL NAL unit types" },
461 	{ 28,  "RSV_VCL28 - Reserved non-IRAP VCL NAL unit types" },
462 	{ 29,  "RSV_VCL29 - Reserved non-IRAP VCL NAL unit types" },
463 	{ 30,  "RSV_VCL30 - Reserved non-IRAP VCL NAL unit types" },
464 	{ 31,  "RSV_VCL31 - Reserved non-IRAP VCL NAL unit types" },
465 	{ 32,  "VPS_NUT - Video parameter set" },
466 	{ 33,  "SPS_NUT - Sequence parameter set" },
467 	{ 34,  "PPS_NUT - Picture parameter set" },
468 	{ 35,  "AUD_NUT - Access unit delimiter" },
469 	{ 36,  "EOS_NUT - End of sequence" },
470 	{ 37,  "EOB_NUT - End of bitstream" },
471 	{ 38,  "FD_NUT - Filler data" },
472 	{ 39,  "PREFIX_SEI_NUT - Supplemental enhancement information" },
473 	{ 40,  "SUFFIX_SEI_NUT - Supplemental enhancement information" },
474 	{ 41,  "RSV_NVCL41 - Reserved" },
475 	{ 42,  "RSV_NVCL42 - Reserved" },
476 	{ 43,  "RSV_NVCL43 - Reserved" },
477 	{ 44,  "RSV_NVCL44 - Reserved" },
478 	{ 45,  "RSV_NVCL45 - Reserved" },
479 	{ 46,  "RSV_NVCL46 - Reserved" },
480 	{ 47,  "RSV_NVCL47 - Reserved" },
481 	{ 48,  "APS -  Aggregation Packets" },
482 	{ 49,  "FU - Fragmentation Units" },
483 	{ 50,  "PACI - PACI Packets" },
484 	{ 51,  "UNSPEC51 - Unspecified" },
485 	{ 52,  "UNSPEC52 - Unspecified" },
486 	{ 53,  "UNSPEC53 - Unspecified" },
487 	{ 54,  "UNSPEC54 - Unspecified" },
488 	{ 55,  "UNSPEC55 - Unspecified" },
489 	{ 56,  "UNSPEC56 - Unspecified" },
490 	{ 57,  "UNSPEC57 - Unspecified" },
491 	{ 58,  "UNSPEC58 - Unspecified" },
492 	{ 59,  "UNSPEC59 - Unspecified" },
493 	{ 60,  "UNSPEC60 - Unspecified" },
494 	{ 61,  "UNSPEC61 - Unspecified" },
495 	{ 62,  "UNSPEC62 - Unspecified" },
496 	{ 63,  "UNSPEC63 - Unspecified" },
497 	{ 0, NULL }
498 };
499 
500 static const value_string h265_type_summary_values[] = {
501 	{ 0,   "TRAIL_N" },
502 	{ 1,   "TRAIL_R" },
503 	{ 2,   "TSA_N" },
504 	{ 3,   "TSA_R" },
505 	{ 4,   "STSA_N" },
506 	{ 5,   "STSA_R" },
507 	{ 6,   "RADL_N" },
508 	{ 7,   "RADL_R" },
509 	{ 8,   "RASL_N" },
510 	{ 9,   "RASL_R" },
511 	{ 10,  "RSV_VCL_N10" },
512 	{ 11,  "RSV_VCL_R11" },
513 	{ 12,  "RSV_VCL_N12" },
514 	{ 13,  "RSV_VCL_R13" },
515 	{ 14,  "RSV_VCL_N14" },
516 	{ 15,  "RSV_VCL_R15" },
517 	{ 16,  "BLA_W_LP" },
518 	{ 17,  "BLA_W_RADL" },
519 	{ 18,  "BLA_N_LP" },
520 	{ 19,  "IDR_W_RADL" },
521 	{ 20,  "IDR_N_LP" },
522 	{ 21,  "CRA_NUT" },
523 	{ 22,  "RSV_IRAP_VCL22" },
524 	{ 23,  "RSV_IRAP_VCL23" },
525 	{ 24,  "RSV_VCL24" },
526 	{ 25,  "RSV_VCL25" },
527 	{ 26,  "RSV_VCL26" },
528 	{ 27,  "RSV_VCL27" },
529 	{ 28,  "RSV_VCL28" },
530 	{ 29,  "RSV_VCL29" },
531 	{ 30,  "RSV_VCL30" },
532 	{ 31,  "RSV_VCL31" },
533 	{ 32,  "VPS_NUT" },
534 	{ 33,  "SPS_NUT" },
535 	{ 34,  "PPS_NUT" },
536 	{ 35,  "AUD_NUT" },
537 	{ 36,  "EOS_NUT" },
538 	{ 37,  "EOB_NUT" },
539 	{ 38,  "FD_NUT" },
540 	{ 39,  "PREFIX_SEI_NUT" },
541 	{ 40,  "SUFFIX_SEI_NUT" },
542 	{ 41,  "RSV_NVCL41" },
543 	{ 42,  "RSV_NVCL42" },
544 	{ 43,  "RSV_NVCL43" },
545 	{ 44,  "RSV_NVCL44" },
546 	{ 45,  "RSV_NVCL45" },
547 	{ 46,  "RSV_NVCL46" },
548 	{ 47,  "RSV_NVCL47" },
549 	{ 48,  "APS" },
550 	{ 49,  "FU" },
551 	{ 50,  "PACI" },
552 	{ 51,  "UNSPEC51" },
553 	{ 52,  "UNSPEC52" },
554 	{ 53,  "UNSPEC53" },
555 	{ 54,  "UNSPEC54" },
556 	{ 55,  "UNSPEC55" },
557 	{ 56,  "UNSPEC56" },
558 	{ 57,  "UNSPEC57" },
559 	{ 58,  "UNSPEC58" },
560 	{ 59,  "UNSPEC59" },
561 	{ 60,  "UNSPEC60" },
562 	{ 61,  "UNSPEC61" },
563 	{ 62,  "UNSPEC62" },
564 	{ 63,  "UNSPEC63" },
565 	{ 0, NULL }
566 };
567 
568 /* A.3 Profiles */
569 static const value_string h265_profile_idc_values[] = {
570 	{ 1,  "Main profile" },
571 	{ 2,  "Main 10 and Main 10 Still Picture profiles" },
572 	{ 3,  "Main Still Picture profile" },
573 	{ 4,  "Format range extensions profiles" },
574 	{ 5,  "High throughput profiles" },
575 	{ 9,  "Screen content coding extensions profiles" },
576 	{ 0, NULL }
577 };
578 
579 /* Table A.7-Tier and level limits for the video profiles */
580 /* XXX - this looks as if the values are 10 times the level value
581  * in Table A.7. */
582 static const value_string h265_level_main_tier_bitrate_values[] = {
583 	{ 10,   "128 kb/s" },
584 	{ 20,   "1.5 Mb/s" },
585 	{ 21,   "3 Mb/s" },
586 	{ 30,   "6 Mb/s" },
587 	{ 31,   "10 Mb/s" },
588 	{ 40,   "12 Mb/s" },
589 	{ 41,   "20 Mb/s" },
590 	{ 50,   "25 Mb/s" },
591 	{ 51,   "40 Mb/s" },
592 	{ 52,   "60 Mb/s" },
593 	{ 60,   "60 Mb/s" },
594 	{ 61,   "120 Mb/s" },
595 	{ 62,   "240 Mb/s" },
596 	{ 0, NULL }
597 };
598 /*High tier*/
599 static const value_string h265_level_high_tier_bitrate_values[] = {
600 	{ 40,   "30 Mb/s" },
601 	{ 41,   "50 Mb/s" },
602 	{ 50,   "100 Mb/s" },
603 	{ 51,   "160 Mb/s" },
604 	{ 52,   "240 Mb/s" },
605 	{ 60,   "240 Mb/s" },
606 	{ 61,   "480 Mb/s" },
607 	{ 62,   "800 Mb/s" },
608 	{ 0, NULL }
609 };
610 
611 /* Table 7-7 - Name association to slice_type */
612 static const value_string h265_slice_type_vals[] = {
613 	{ 0,    "B (B slice)" },
614 	{ 1,    "P (P slice)" },
615 	{ 2,    "I (I slice)" },
616 	{ 0, NULL }
617 };
618 
619 /* D.2 SEI payload syntax */
620 static const value_string h265_sei_payload_vals[] = {
621 	{ 0,   "buffering_period" },
622 	{ 1,   "pic_timing" },
623 	{ 2,   "pan_scan_rect" },
624 	{ 3,   "filler_payload" },
625 	{ 4,   "user_data_registered_itu_t_t35" },
626 	{ 5,   "user_data_unregistered" },
627 	{ 6,   "recovery_point" },
628 	{ 9,   "scene_info" },
629 	{ 15,   "picture_snapshot" },
630 	{ 16,   "progressive_refinement_segment_start" },
631 	{ 17,   "progressive_refinement_segment_end" },
632 	{ 19,   "film_grain_characteristics" },
633 	{ 23,   "tone_mapping_info" },
634 	{ 45,   "frame_packing_arrangement" },
635 	{ 47,   "display_orientation" },
636 	{ 56,   "green_metadata" }, /* specified in ISO/IEC 23001-11 */
637 	{ 128,   "structure_of_pictures_info" },
638 	{ 129,   "active_parameter_sets" },
639 	{ 130,   "decoding_unit_info" },
640 	{ 131,   "temporal_sub_layer_zero_idx" },
641 	{ 133,   "scalable_nesting" },
642 	{ 134,   "region_refresh_info" },
643 	{ 135,   "no_display" },
644 	{ 136,   "time_code" },
645 	{ 137,   "mastering_display_colour_volume" },
646 	{ 138,   "segmented_rect_frame_packing_arrangement" },
647 	{ 139,   "temporal_motion_constrained_tile_sets" },
648 	{ 140,   "chroma_resampling_filter_hint" },
649 	{ 141,   "knee_function_info" },
650 	{ 142,   "colour_remapping_info" },
651 	{ 143,   "deinterlaced_field_identification" },
652 	{ 144,   "content_light_level_info" },
653 	{ 145,   "dependent_rap_indication" },
654 	{ 146,   "coded_region_completion" },
655 	{ 147,   "alternative_transfer_characteristics" },
656 	{ 148,   "ambient_viewing_environment" },
657 	{ 149,   "content_colour_volume" },
658 	{ 150,   "equirectangular_projection" },
659 	{ 151,   "cubemap_projection" },
660 	{ 154,   "sphere_rotation" },
661 	{ 155,   "regionwise_packing" },
662 	{ 156,   "omni_viewport" },
663 	{ 157,   "regional_nesting" },
664 	{ 158,   "mcts_extraction_info_sets" },
665 	{ 159,   "mcts_extraction_info_nesting" },
666 	{ 160,   "layers_not_present" }, /* specified in Annex F */
667 	{ 161,   "inter_layer_constrained_tile_sets" }, /* specified in Annex F */
668 	{ 162,   "bsp_nesting" }, /* specified in Annex F */
669 	{ 163,   "bsp_initial_arrival_time" }, /* specified in Annex F */
670 	{ 164,   "sub_bitstream_property" }, /* specified in Annex F */
671 	{ 165,   "alpha_channel_info" }, /* specified in Annex F */
672 	{ 166,   "overlay_info" }, /* specified in Annex F */
673 	{ 167,   "temporal_mv_prediction_constraints" }, /* specified in Annex F */
674 	{ 168,   "frame_field_info" }, /* specified in Annex F */
675 	{ 176,   "three_dimensional_reference_displays_info" }, /* specified in Annex G */
676 	{ 177,   "depth_representation_info" }, /* specified in Annex G */
677 	{ 178,   "multiview_scene_info" }, /* specified in Annex G */
678 	{ 179,   "multiview_acquisition_info" }, /* specified in Annex G */
679 	{ 180,   "multiview_view_position" }, /* specified in Annex G */
680 	{ 181,   "alternative_depth_info" }, /* specified in Annex I */
681 	{ 0, NULL }
682 };
683 
684 static int
685 dissect_h265(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_);
686 static int
687 dissect_h265_profile_tier_level(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint offset, gboolean profilePresentFlag, gint vps_max_sub_layers_minus1);
688 static int
689 dissect_h265_hrd_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset, gboolean commonInfPresentFlag, guint maxNumSubLayersMinus1);
690 static int
691 dissect_h265_scaling_list_data(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint bit_offset);
692 static int
693 dissect_h265_st_ref_pic_set(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint bit_offset, gint stRpsIdx, gint num_short_term_ref_pic_sets);
694 static int
695 dissect_h265_vui_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint bit_offset, guint8 sps_max_sub_layers_minus1);
696 static int
697 dissect_h265_sps_range_extension(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint bit_offset);
698 static int
699 dissect_h265_sps_multilayer_extension(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint bit_offset);
700 static int
701 dissect_h265_sps_3d_extension(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint bit_offset);
702 static int
703 dissect_h265_sps_scc_extension(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint bit_offset, guint chroma_format_idc, guint bit_depth_luma_minus8, guint bit_depth_chroma_minus8);
704 static int
705 dissect_h265_pps_range_extension(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint bit_offset, guint transform_skip_enabled_flag);
706 static int
707 dissect_h265_pps_scc_extension(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint bit_offset);
708 static int
709 dissect_h265_pps_multilayer_extension(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint bit_offset);
710 static int
711 dissect_h265_pps_3d_extension(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint bit_offset);
712 static int
713 dissect_h265_sei_message(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint bit_offset, guint8 nal_unit_type);
714 
715 #if 0
716 /* byte_aligned( ) is specified as follows.
717 * - If the current position in the bitstream is on a byte boundary, i.e.,
718 *   the next bit in the bitstream is the first bit in a byte,
719 *   the return value of byte_aligned( ) is equal to TRUE.
720 * - Otherwise, the return value of byte_aligned( ) is equal to FALSE.
721 */
722 static gboolean
723 h265_byte_aligned(gint bit_offset)
724 {
725 	if (bit_offset & 0x3)
726 		return FALSE;
727 
728 	return TRUE;
729 }
730 
731 /* more_data_in_payload( ) is specified as follows:
732 * - If byte_aligned( ) is equal to TRUE and the current position in the sei_payload( ) syntax structure is
733 * 8 * payloadSize bits from the beginning of the sei_payload( ) syntax structure, the return value of
734 * more_data_in_payload( ) is equal to FALSE.
735 * - Otherwise, the return value of more_data_in_payload( ) is equal to TRUE.
736 */
737 static gboolean
738 h265_more_data_in_payload(gint bit_start, gint bit_offset, gint payloadSize)
739 {
740 	if (h265_byte_aligned(bit_offset) && bit_start + 8 * payloadSize == bit_offset)
741 		return FALSE;
742 
743 	return TRUE;
744 }
745 
746 /* payload_extension_present( ) is specified as follows:
747 * - If the current position in the sei_payload( ) syntax structure is not the position of the last (least significant, right-
748 * most) bit that is equal to 1 that is less than 8 * payloadSize bits from the beginning of the syntax structure (i.e.,
749 * the position of the payload_bit_equal_to_one syntax element), the return value of payload_extension_present( ) is equal to TRUE.
750 * - Otherwise, the return value of payload_extension_present( )
751 * is equal to FALSE.
752 */
753 static gboolean
754 h265_payload_extension_present(tvbuff_t* tvb, gint bit_start, gint bit_offset, gint payloadSize)
755 {
756 	if (bit_start + 8 * payloadSize > bit_offset && tvb_get_bits8(tvb, bit_offset, 1))
757 		return TRUE;
758 
759 	return FALSE;
760 }
761 #endif
762 
763 /* Expect a tvb and a bit offset into the tvb
764 * returns the value and bit_offset
765 *
766 * This supports 32 bit output values. If the exp-Golomb coded value overflows
767 * the 32 bit type, it will return the actual bit offset but clamp the value
768 * and add an expert info.
769 */
770 #define cVALS(x) (const value_string*)(x)
771 
772 static guint32
dissect_h265_exp_golomb_code(proto_tree * tree,int hf_index,tvbuff_t * tvb,packet_info * pinfo,gint * start_bit_offset,h265_golomb_descriptors descriptor)773 dissect_h265_exp_golomb_code(proto_tree *tree, int hf_index, tvbuff_t *tvb, packet_info *pinfo, gint *start_bit_offset, h265_golomb_descriptors descriptor)
774 /*(tvbuff_t *tvb, gint *start_bit_offset) */
775 {
776 	proto_item *ti;
777 
778 	gint     leading_zero_bits, bit_offset, start_offset;
779 	guint32  codenum, mask, value, tmp;
780 	gint32   se_value = 0;
781 	gint     b;
782 	char    *str;
783 	int      bit;
784 	int      i;
785 	gboolean overflow = FALSE;
786 	header_field_info *hf_field = NULL;
787 
788 	start_offset = *start_bit_offset >> 3;
789 
790 	if (hf_index > -1)
791 		hf_field = proto_registrar_get_nth(hf_index);
792 
793 	/* Allow only gint32 for se(v), guint32 for others. */
794 	switch (descriptor) {
795 	case H265_SE_V:
796 		DISSECTOR_ASSERT_FIELD_TYPE(hf_field, FT_INT32);
797 		break;
798 
799 	default:
800 		DISSECTOR_ASSERT_FIELD_TYPE(hf_field, FT_UINT32);
801 		break;
802 	}
803 
804 	bit_offset = *start_bit_offset;
805 
806 	/* prepare the string */
807 	str = (char *)wmem_alloc(pinfo->pool, 256);
808 	str[0] = '\0';
809 	for (bit = 0; bit<((int)(bit_offset & 0x07)); bit++) {
810 		if (bit && (!(bit % 4))) {
811 			(void) g_strlcat(str, " ", 256);
812 		}
813 		(void) g_strlcat(str, ".", 256);
814 	}
815 
816 
817 	leading_zero_bits = -1;
818 	for (b = 0; !b; leading_zero_bits++) {
819 		if (bit && (!(bit % 4))) {
820 			(void) g_strlcat(str, " ", 256);
821 		}
822 		if (bit && (!(bit % 8))) {
823 			(void) g_strlcat(str, " ", 256);
824 		}
825 		b = tvb_get_bits8(tvb, bit_offset, 1);
826 		if (b != 0) {
827 			(void) g_strlcat(str, "1", 256);
828 		}
829 		else {
830 			(void) g_strlcat(str, "0", 256);
831 		}
832 		bit++;
833 		bit_offset++;
834 	}
835 
836 	/* XXX: This could be handled in the general case and reduce code
837 	 * duplication.  */
838 	if (leading_zero_bits == 0) {
839 		codenum = 0;
840 		*start_bit_offset = bit_offset;
841 		for (; bit % 8; bit++) {
842 			if (bit && (!(bit % 4))) {
843 				(void) g_strlcat(str, " ", 256);
844 			}
845 			(void) g_strlcat(str, ".", 256);
846 		}
847 		if (hf_field) {
848 			(void) g_strlcat(str, " = ", 256);
849 			(void) g_strlcat(str, hf_field->name, 256);
850 			switch (descriptor) {
851 			case H265_SE_V:
852 				/* if the syntax element is coded as se(v),
853 				* the value of the syntax element is derived by invoking the
854 				* mapping process for signed Exp-Golomb codes as specified in
855 				* subclause 9.1.1 with codeNum as the input.
856 				*/
857 				if (hf_field->type == FT_INT32) {
858 					if (hf_field->strings) {
859 						proto_tree_add_int_format(tree, hf_index, tvb, start_offset, 1, codenum,
860 							"%s: %s (%d)",
861 							str,
862 							val_to_str_const(codenum, cVALS(hf_field->strings), "Unknown "),
863 							codenum);
864 					}
865 					else {
866 						switch (hf_field->display) {
867 						case BASE_DEC:
868 							proto_tree_add_int_format(tree, hf_index, tvb, start_offset, 1, codenum,
869 								"%s: %d",
870 								str,
871 								codenum);
872 							break;
873 						default:
874 							DISSECTOR_ASSERT_NOT_REACHED();
875 							break;
876 						}
877 					}
878 				}
879 				return codenum;
880 			default:
881 				break;
882 			}
883 			if (hf_field->type == FT_UINT32) {
884 				if (hf_field->strings) {
885 					proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
886 						"%s: %s (%u)",
887 						str,
888 						val_to_str_const(codenum, cVALS(hf_field->strings), "Unknown "),
889 						codenum);
890 				}
891 				else {
892 					switch (hf_field->display) {
893 					case BASE_DEC:
894 						proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
895 							"%s: %u",
896 							str,
897 							codenum);
898 						break;
899 					case BASE_HEX:
900 						proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
901 							"%s: 0x%x",
902 							str,
903 							codenum);
904 						break;
905 					default:
906 						DISSECTOR_ASSERT_NOT_REACHED();
907 						break;
908 					}
909 				}
910 			}
911 			else {
912 				/* Only allow guint32 */
913 				DISSECTOR_ASSERT_NOT_REACHED();
914 			}
915 		}
916 		return codenum;
917 	}
918 
919 	/*
920 	Syntax elements coded as ue(v), me(v), or se(v) are Exp-Golomb-coded. Syntax elements coded as te(v) are truncated
921 	Exp-Golomb-coded. The parsing process for these syntax elements begins with reading the bits starting at the current
922 	location in the bitstream up to and including the first non-zero bit, and counting the number of leading bits that are
923 	equal to 0. This process is specified as follows:
924 	leadingZeroBits = -1;
925 	for (b = 0; !b; leadingZeroBits++)
926 	b = read_bits( 1 )
927 	The variable codeNum is then assigned as follows:
928 	codeNum = 2leadingZeroBits - 1 + read_bits( leadingZeroBits )
929 	where the value returned from read_bits( leadingZeroBits ) is interpreted as a binary representation of an unsigned
930 	integer with most significant bit written first.
931 	*/
932 	if (leading_zero_bits > 32) {
933 		overflow = TRUE;
934 		codenum = G_MAXUINT32;
935 		if (descriptor == H265_SE_V) {
936 			/* For signed, must read the last bit to get the sign. */
937 			value = tvb_get_bits32(tvb, bit_offset + leading_zero_bits / 32, leading_zero_bits % 32, ENC_BIG_ENDIAN);
938 			if (value % 1) {
939 				se_value = G_MININT32;
940 			} else {
941 				se_value = G_MAXINT32;
942 			}
943 		}
944 	} else if (leading_zero_bits == 32) {
945 		value = tvb_get_bits32(tvb, bit_offset, leading_zero_bits, ENC_BIG_ENDIAN);
946 		codenum = G_MAXUINT32;
947 		/* One one value doesn't overflow a 32 bit integer, but they're
948 		 * different for unsigned and signed (because codenum G_MAXUINT32 maps
949 		 * to G_MAXINT32 + 1 and G_MAXUINT32 + 1 maps to G_MININT32.) */
950 		if (descriptor == H265_SE_V) {
951 			if (value != 1) {
952 				overflow = TRUE;
953 			}
954 			if (value % 1) {
955 				se_value = G_MININT32;
956 			} else {
957 				se_value = G_MAXINT32;
958 			}
959 		} else {
960 			if (value != 0) {
961 				overflow = TRUE;
962 			}
963 		}
964 		mask = 1U << 31;
965 	} else { /* Non-overflow general case */
966 		if (leading_zero_bits > 16)
967 			value = tvb_get_bits32(tvb, bit_offset, leading_zero_bits, ENC_BIG_ENDIAN);
968 		else if (leading_zero_bits > 8)
969 			value = tvb_get_bits16(tvb, bit_offset, leading_zero_bits, ENC_BIG_ENDIAN);
970 		else
971 			value = tvb_get_bits8(tvb, bit_offset, leading_zero_bits);
972 
973 		codenum = 1;
974 		codenum = codenum << leading_zero_bits;
975 		mask = codenum >> 1;
976 		codenum = (codenum - 1) + value;
977 
978 		if (descriptor == H265_SE_V) {
979 			/* if the syntax element is coded as se(v),
980 			* the value of the syntax element is derived by invoking the
981 			* mapping process for signed Exp-Golomb codes as specified in
982 			* subclause 9.1.1 with codeNum as the input.
983 			*      k+1
984 			* (-1)    Ceil( k/2 )
985 			*/
986 			se_value = (codenum + 1) >> 1;
987 			if (!(codenum & 1)) {
988 				se_value = -se_value;
989 			}
990 		}
991 
992 	}
993 
994 	bit_offset = bit_offset + leading_zero_bits;
995 
996 	if (overflow) {
997 		*start_bit_offset = bit_offset;
998 		/* We will probably get a BoundsError later in the packet. */
999 		if (descriptor == H265_SE_V) {
1000 			ti = proto_tree_add_int_format_value(tree, hf_index, tvb, start_offset, (bit_offset >> 3) - start_offset + 1, codenum, "Invalid value (%d leading zero bits), clamped to %" G_GINT32_MODIFIER "d", leading_zero_bits, se_value);
1001 			expert_add_info(NULL, ti, &ei_h265_oversized_exp_golomb_code);
1002 			return se_value;
1003 		} else {
1004 			ti = proto_tree_add_uint_format_value(tree, hf_index, tvb, start_offset, (bit_offset >> 3) - start_offset + 1, codenum, "Invalid value (%d leading zero bits), clamped to %" G_GINT32_MODIFIER "u", leading_zero_bits, codenum);
1005 			expert_add_info(NULL, ti, &ei_h265_oversized_exp_golomb_code);
1006 			return codenum;
1007 		}
1008 	}
1009 
1010 	/* read the bits for the int */
1011 	for (i = 0; i<leading_zero_bits; i++) {
1012 		if (bit && (!(bit % 4))) {
1013 			(void) g_strlcat(str, " ", 256);
1014 		}
1015 		if (bit && (!(bit % 8))) {
1016 			(void) g_strlcat(str, " ", 256);
1017 		}
1018 		bit++;
1019 		tmp = value & mask;
1020 		if (tmp != 0) {
1021 			(void) g_strlcat(str, "1", 256);
1022 		}
1023 		else {
1024 			(void) g_strlcat(str, "0", 256);
1025 		}
1026 		mask = mask >> 1;
1027 	}
1028 	for (; bit % 8; bit++) {
1029 		if (bit && (!(bit % 4))) {
1030 			(void) g_strlcat(str, " ", 256);
1031 		}
1032 		(void) g_strlcat(str, ".", 256);
1033 	}
1034 
1035 	if (hf_field) {
1036 		(void) g_strlcat(str, " = ", 256);
1037 		(void) g_strlcat(str, hf_field->name, 256);
1038 		switch (descriptor) {
1039 		case H265_SE_V:
1040 			(void) g_strlcat(str, "(se(v))", 256);
1041 			/* if the syntax element is coded as se(v),
1042 			* the value of the syntax element is derived by invoking the
1043 			* mapping process for signed Exp-Golomb codes as specified in
1044 			* subclause 9.1.1 with codeNum as the input.
1045 			*/
1046 			break;
1047 		default:
1048 			break;
1049 		}
1050 		if (hf_field->type == FT_UINT32) {
1051 			if (hf_field->strings) {
1052 				proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
1053 					"%s: %s (%u)",
1054 					str,
1055 					val_to_str_const(codenum, cVALS(hf_field->strings), "Unknown "),
1056 					codenum);
1057 			}
1058 			else {
1059 				switch (hf_field->display) {
1060 				case BASE_DEC:
1061 					proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
1062 						"%s: %u",
1063 						str,
1064 						codenum);
1065 					break;
1066 				case BASE_HEX:
1067 					proto_tree_add_uint_format(tree, hf_index, tvb, start_offset, 1, codenum,
1068 						"%s: 0x%x",
1069 						str,
1070 						codenum);
1071 					break;
1072 				default:
1073 					DISSECTOR_ASSERT_NOT_REACHED();
1074 					break;
1075 				}
1076 			}
1077 		}
1078 		else if (hf_field->type == FT_INT32) {
1079 			if (hf_field->strings) {
1080 				proto_tree_add_int_format(tree, hf_index, tvb, start_offset, 1, codenum,
1081 					"%s: %s (%d)",
1082 					str,
1083 					val_to_str_const(codenum, cVALS(hf_field->strings), "Unknown "),
1084 					se_value);
1085 			}
1086 			else {
1087 				switch (hf_field->display) {
1088 				case BASE_DEC:
1089 					proto_tree_add_int_format(tree, hf_index, tvb, start_offset, 1, codenum,
1090 						"%s: %d",
1091 						str,
1092 						se_value);
1093 					break;
1094 				default:
1095 					DISSECTOR_ASSERT_NOT_REACHED();
1096 					break;
1097 				}
1098 			}
1099 			*start_bit_offset = bit_offset;
1100 			return se_value;
1101 
1102 		}
1103 		else {
1104 			DISSECTOR_ASSERT_NOT_REACHED();
1105 		}
1106 	}
1107 
1108 	*start_bit_offset = bit_offset;
1109 	return codenum;
1110 }
1111 
1112 
1113 static gboolean
more_rbsp_data(proto_tree * tree _U_,tvbuff_t * tvb,packet_info * pinfo _U_,gint bit_offset)1114 more_rbsp_data(proto_tree *tree _U_, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
1115 {
1116 	int    offset;
1117 	int    remaining_length;
1118 	int    last_one_bit;
1119 	guint8 b = 0;
1120 
1121 	/* XXX might not be the best way of doing things but:
1122 	* Serch from the end of the tvb for the first '1' bit
1123 	* assuming that it's the RTBSP stop bit
1124 	*/
1125 
1126 	/* Set offset to the byte we are treating */
1127 	offset = bit_offset >> 3;
1128 	remaining_length = tvb_reported_length_remaining(tvb, offset);
1129 	/* If there is more then 2 bytes left there *should* be more data */
1130 	if (remaining_length>2) {
1131 		return TRUE;
1132 	}
1133 	/* Start from last bit */
1134 	last_one_bit = (tvb_reported_length(tvb) << 3);
1135 
1136 	for (b = 0; !b; ) {
1137 		last_one_bit--;
1138 		b = tvb_get_bits8(tvb, last_one_bit, 1);
1139 	}
1140 
1141 	if (last_one_bit == bit_offset) {
1142 		return FALSE;
1143 	}
1144 
1145 	return TRUE;
1146 }
1147 
1148 /* 7.3.2.11 RBSP trailing bits syntax */
1149 static int
dissect_h265_rbsp_trailing_bits(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo _U_,gint bit_offset)1150 dissect_h265_rbsp_trailing_bits(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset)
1151 {
1152 	gint remaining_bits = 0;
1153 
1154 	proto_tree_add_bits_item(tree, hf_h265_rbsp_stop_bit, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1155 	bit_offset++;
1156 
1157 	if ((bit_offset & 0x7) != 0) {
1158 		remaining_bits = 8 - (bit_offset & 0x7);
1159 		proto_tree_add_bits_item(tree, hf_h265_rbsp_trailing_bits, tvb, bit_offset, remaining_bits, ENC_BIG_ENDIAN);
1160 	}
1161 
1162 	return bit_offset + remaining_bits;
1163 }
1164 
1165 /* Ref 7.3.2.1 Video parameter set RBSP syntax */
1166 static void
dissect_h265_video_parameter_set_rbsp(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,gint offset)1167 dissect_h265_video_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1168 {
1169 	//proto_item *level_item;
1170 	gint        bit_offset;
1171 	proto_tree *profile_tier_level_tree, *hrd_parameters_tree;
1172 
1173 	bit_offset = offset << 3;
1174 
1175 	proto_tree_add_bits_item(tree, hf_h265_vps_video_parameter_set_id, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
1176 	bit_offset = bit_offset + 4;
1177 
1178 	proto_tree_add_bits_item(tree, hf_h265_vps_base_layer_internal_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1179 	bit_offset = bit_offset + 1;
1180 
1181 	proto_tree_add_bits_item(tree, hf_h265_vps_base_layer_available_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1182 	bit_offset = bit_offset + 1;
1183 
1184 	proto_tree_add_bits_item(tree, hf_h265_vps_max_layers_minus1, tvb, bit_offset, 6, ENC_BIG_ENDIAN);
1185 	bit_offset = bit_offset + 6;
1186 
1187 	guint8 vps_max_sub_layers_minus1 = tvb_get_bits8(tvb, bit_offset, 3);
1188 	proto_tree_add_bits_item(tree, hf_h265_vps_max_sub_layers_minus1, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
1189 	bit_offset = bit_offset + 3;
1190 
1191 	proto_tree_add_bits_item(tree, hf_h265_vps_temporal_id_nesting_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1192 	bit_offset = bit_offset + 1;
1193 
1194 	proto_tree_add_bits_item(tree, hf_h265_vps_reserved_0xffff_16bits, tvb, bit_offset, 16, ENC_BIG_ENDIAN);
1195 	bit_offset = bit_offset + 16;
1196 
1197 	offset = bit_offset >> 3;
1198 	profile_tier_level_tree = proto_tree_add_subtree(tree, tvb, offset, 1, ett_h265_profile_tier_level, NULL, "Profile, tier and level");
1199 	offset = dissect_h265_profile_tier_level(profile_tier_level_tree, tvb, pinfo, offset, 1, vps_max_sub_layers_minus1);
1200 	bit_offset = offset << 3;
1201 
1202 	guint8 vps_sub_layer_ordering_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1203 	proto_tree_add_item(tree, hf_h265_vps_sub_layer_ordering_info_present_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1204 	bit_offset = bit_offset + 1;
1205 
1206 	for (int i = (vps_sub_layer_ordering_info_present_flag ? 0 : vps_max_sub_layers_minus1);
1207 		i <= vps_max_sub_layers_minus1; i++) {
1208 		dissect_h265_exp_golomb_code(tree, hf_h265_vps_max_dec_pic_buffering_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
1209 		dissect_h265_exp_golomb_code(tree, hf_h265_vps_max_num_reorder_pics, tvb, pinfo, &bit_offset, H265_UE_V);
1210 		dissect_h265_exp_golomb_code(tree, hf_h265_vps_max_latency_increase_plus1, tvb, pinfo, &bit_offset, H265_UE_V);
1211 	}
1212 
1213 	guint8 vps_max_layer_id = tvb_get_bits8(tvb, bit_offset, 6);
1214 	proto_tree_add_bits_item(tree, hf_h265_vps_max_layer_id, tvb, bit_offset, 6, ENC_BIG_ENDIAN);
1215 	bit_offset = bit_offset + 6;
1216 
1217 	guint32	vps_num_layer_sets_minus1 = dissect_h265_exp_golomb_code(tree, hf_h265_vps_num_layer_sets_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
1218 	for (unsigned i = 1; i <= vps_num_layer_sets_minus1; i++)
1219 		for (int j = 0; j <= vps_max_layer_id; j++) {
1220 			proto_tree_add_bits_item(tree, hf_h265_layer_id_included_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1221 			bit_offset = bit_offset + 1;
1222 		}
1223 
1224 	guint8 vps_timing_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1225 	proto_tree_add_bits_item(tree, hf_h265_vps_timing_info_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1226 	bit_offset = bit_offset + 1;
1227 
1228 	if (vps_timing_info_present_flag) {
1229 		proto_tree_add_bits_item(tree, hf_h265_vps_num_units_in_tick, tvb, bit_offset, 32, ENC_BIG_ENDIAN);
1230 		bit_offset = bit_offset + 32;
1231 		proto_tree_add_bits_item(tree, hf_h265_vps_time_scale, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1232 		bit_offset = bit_offset + 32;
1233 		guint8 vps_poc_proportional_to_timing_flag = tvb_get_bits8(tvb, bit_offset, 1);
1234 		proto_tree_add_bits_item(tree, hf_h265_vps_poc_proportional_to_timing_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1235 		bit_offset = bit_offset + 1;
1236 
1237 		if (vps_poc_proportional_to_timing_flag) {
1238 			dissect_h265_exp_golomb_code(tree, hf_h265_vps_num_ticks_poc_diff_one_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
1239 		}
1240 		guint32	vps_num_hrd_parameters = dissect_h265_exp_golomb_code(tree, hf_h265_vps_num_hrd_parameters, tvb, pinfo, &bit_offset, H265_UE_V);
1241 		for (unsigned i = 0; i < vps_num_hrd_parameters; i++) {
1242 			 dissect_h265_exp_golomb_code(tree, hf_h265_hrd_layer_set_idx, tvb, pinfo, &bit_offset, H265_UE_V);
1243 			 if (i > 0) {
1244 				 gboolean cprms_present_flag/*[i]*/ = tvb_get_bits8(tvb, bit_offset, 1);
1245 				 proto_tree_add_bits_item(tree, hf_h265_cprms_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1246 				 bit_offset = bit_offset + 1;
1247 
1248 				 offset = bit_offset >> 3;
1249 				 hrd_parameters_tree = proto_tree_add_subtree(tree, tvb, offset, 1, ett_h265_hrd_parameters, NULL, "HRD parameters");
1250 				 bit_offset = offset << 3;
1251 
1252 				 bit_offset = dissect_h265_hrd_parameters(hrd_parameters_tree, tvb, pinfo, bit_offset, cprms_present_flag/*[i]*/, vps_max_sub_layers_minus1);
1253 			 }
1254 		}
1255 	}
1256 
1257 	guint8 vps_extension_flag = tvb_get_bits8(tvb, bit_offset, 1);
1258 	proto_tree_add_bits_item(tree, hf_h265_vps_extension_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1259 	bit_offset = bit_offset + 1;
1260 
1261 	if (vps_extension_flag) {
1262 		while (more_rbsp_data(tree, tvb, pinfo, bit_offset)) {
1263 			proto_tree_add_bits_item(tree, hf_h265_vps_extension_data_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1264 			bit_offset = bit_offset + 1;
1265 		}
1266 	}
1267 	dissect_h265_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
1268 }
1269 
1270 /* Ref 7.3.2.2 Sequence parameter set RBSP syntax
1271  * num_short_term_ref_pic_sets specifies the number of st_ref_pic_set( ) syntax structures included in the SPS. The value
1272  * of num_short_term_ref_pic_sets shall be in the range of 0 to 64, inclusive
1273  */
1274 #define H265_MAX_NUM_SHORT_TERM_REF_PIC_SETS 64
1275 static void
dissect_h265_seq_parameter_set_rbsp(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,gint offset)1276 dissect_h265_seq_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1277 {
1278 	gint        bit_offset;
1279 	guint8		i, sps_max_sub_layers_minus1, sps_extension_4bits = 0;
1280 	guint32		num_short_term_ref_pic_sets, num_long_term_ref_pics_sps, log2_max_pic_order_cnt_lsb_minus4, bit_depth_luma_minus8, bit_depth_chroma_minus8;
1281 	gboolean	sps_sub_layer_ordering_info_present_flag = 0, scaling_list_enabled_flag = 0, sps_scaling_list_data_present_flag = 0,
1282 		pcm_enabled_flag = 0, long_term_ref_pics_present_flag = 0, vui_parameters_present_flag = 0, sps_extension_present_flag = 0,
1283 		sps_range_extension_flag = 0, sps_multilayer_extension_flag = 0, sps_3d_extension_flag = 0, sps_scc_extension_flag = 0;
1284 	proto_tree *profile_tier_level_tree, *vui_parameters_tree;
1285 
1286 	sps_max_sub_layers_minus1 = tvb_get_bits8(tvb, offset << 3, 8) >> 1 & 0x07;
1287 	proto_tree_add_item(tree, hf_h265_sps_video_parameter_set_id, tvb, offset,  1, ENC_BIG_ENDIAN);
1288 	proto_tree_add_item(tree, hf_h265_sps_max_sub_layers_minus1, tvb, offset, 1, ENC_BIG_ENDIAN);
1289 	proto_tree_add_item(tree, hf_h265_sps_temporal_id_nesting_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
1290 	offset++;
1291 
1292 	profile_tier_level_tree = proto_tree_add_subtree(tree, tvb, offset, 1, ett_h265_profile_tier_level, NULL, "Profile, tier and level");
1293 	offset = dissect_h265_profile_tier_level(profile_tier_level_tree, tvb, pinfo, offset, 1, sps_max_sub_layers_minus1);
1294 
1295 	bit_offset = offset << 3;
1296 
1297 	dissect_h265_exp_golomb_code(tree, hf_h265_sps_seq_parameter_set_id, tvb, pinfo, &bit_offset, H265_UE_V);
1298 	guint chroma_format_idc = dissect_h265_exp_golomb_code(tree, hf_h265_chroma_format_idc, tvb, pinfo, &bit_offset, H265_UE_V);
1299 	if (chroma_format_idc == 3)
1300 	{
1301 		proto_tree_add_bits_item(tree, hf_h265_separate_colour_plane_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1302 		bit_offset++;
1303 	}
1304 	pic_width_in_luma_samples = dissect_h265_exp_golomb_code(tree, hf_h265_pic_width_in_luma_samples, tvb, pinfo, &bit_offset, H265_UE_V);
1305 	pic_height_in_luma_samples = dissect_h265_exp_golomb_code(tree, hf_h265_pic_height_in_luma_samples, tvb, pinfo, &bit_offset, H265_UE_V);
1306 
1307 	gboolean conformance_window_flag = tvb_get_bits8(tvb, bit_offset, 1);
1308 	proto_tree_add_bits_item(tree, hf_h265_conformance_window_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1309 	bit_offset++;
1310 	if (conformance_window_flag) {
1311 		dissect_h265_exp_golomb_code(tree, hf_h265_conf_win_left_offset, tvb, pinfo, &bit_offset, H265_UE_V);
1312 		dissect_h265_exp_golomb_code(tree, hf_h265_conf_win_right_offset, tvb, pinfo, &bit_offset, H265_UE_V);
1313 		dissect_h265_exp_golomb_code(tree, hf_h265_conf_win_top_offset, tvb, pinfo, &bit_offset, H265_UE_V);
1314 		dissect_h265_exp_golomb_code(tree, hf_h265_conf_win_bottom_offset, tvb, pinfo, &bit_offset, H265_UE_V);
1315 	}
1316 	bit_depth_luma_minus8 = dissect_h265_exp_golomb_code(tree, hf_h265_bit_depth_luma_minus8, tvb, pinfo, &bit_offset, H265_UE_V);
1317 	bit_depth_chroma_minus8 = dissect_h265_exp_golomb_code(tree, hf_h265_bit_depth_chroma_minus8, tvb, pinfo, &bit_offset, H265_UE_V);
1318 	log2_max_pic_order_cnt_lsb_minus4 = dissect_h265_exp_golomb_code(tree, hf_h265_log2_max_pic_order_cnt_lsb_minus4, tvb, pinfo, &bit_offset, H265_UE_V);
1319 
1320 	sps_sub_layer_ordering_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1321 	proto_tree_add_bits_item(tree, hf_h265_sps_sub_layer_ordering_info_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1322 	bit_offset++;
1323 
1324 	for (i = (sps_sub_layer_ordering_info_present_flag ? 0 : sps_max_sub_layers_minus1);
1325 		i <= sps_max_sub_layers_minus1; i++) {
1326 		dissect_h265_exp_golomb_code(tree, hf_h265_sps_max_dec_pic_buffering_minus1/*[i]*/, tvb, pinfo, &bit_offset, H265_UE_V);
1327 		dissect_h265_exp_golomb_code(tree, hf_h265_sps_max_num_reorder_pics/*[i]*/, tvb, pinfo, &bit_offset, H265_UE_V);
1328 		dissect_h265_exp_golomb_code(tree, hf_h265_sps_max_latency_increase_plus1/*[i]*/, tvb, pinfo, &bit_offset, H265_UE_V);
1329 	}
1330 	// data between packets TODO: move to "conversations"
1331 	log2_min_luma_coding_block_size_minus3 =
1332 	dissect_h265_exp_golomb_code(tree, hf_h265_log2_min_luma_coding_block_size_minus3, tvb, pinfo, &bit_offset, H265_UE_V);
1333 	// data between packets TODO: move to "conversations"
1334 	log2_diff_max_min_luma_coding_block_size =
1335 	dissect_h265_exp_golomb_code(tree, hf_h265_log2_diff_max_min_luma_coding_block_size, tvb, pinfo, &bit_offset, H265_UE_V);
1336 	dissect_h265_exp_golomb_code(tree, hf_h265_log2_min_luma_transform_block_size_minus2, tvb, pinfo, &bit_offset, H265_UE_V);
1337 	dissect_h265_exp_golomb_code(tree, hf_h265_log2_diff_max_min_luma_transform_block_size, tvb, pinfo, &bit_offset, H265_UE_V);
1338 	dissect_h265_exp_golomb_code(tree, hf_h265_max_transform_hierarchy_depth_inter, tvb, pinfo, &bit_offset, H265_UE_V);
1339 	dissect_h265_exp_golomb_code(tree, hf_h265_max_transform_hierarchy_depth_intra, tvb, pinfo, &bit_offset, H265_UE_V);
1340 
1341 	scaling_list_enabled_flag = tvb_get_bits8(tvb, bit_offset, 1);
1342 	proto_tree_add_bits_item(tree, hf_h265_scaling_list_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1343 	bit_offset++;
1344 
1345 	if (scaling_list_enabled_flag) {
1346 		sps_scaling_list_data_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1347 		proto_tree_add_bits_item(tree, hf_h265_sps_scaling_list_data_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1348 		bit_offset++;
1349 		if (sps_scaling_list_data_present_flag)
1350 			bit_offset = dissect_h265_scaling_list_data(tree, tvb, pinfo, bit_offset);
1351 	}
1352 
1353 	proto_tree_add_bits_item(tree, hf_h265_amp_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1354 	bit_offset++;
1355 
1356 	proto_tree_add_bits_item(tree, hf_h265_sample_adaptive_offset_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1357 	bit_offset++;
1358 
1359 	pcm_enabled_flag = tvb_get_bits8(tvb, bit_offset, 1);
1360 	proto_tree_add_bits_item(tree, hf_h265_pcm_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1361 	bit_offset++;
1362 
1363 	if (pcm_enabled_flag) {
1364 
1365 		proto_tree_add_bits_item(tree, hf_h265_pcm_sample_bit_depth_luma_minus1, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
1366 		bit_offset = bit_offset + 4;
1367 
1368 		proto_tree_add_bits_item(tree, hf_h265_pcm_sample_bit_depth_chroma_minus1, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
1369 		bit_offset = bit_offset + 4;
1370 
1371 		dissect_h265_exp_golomb_code(tree, hf_h265_log2_min_pcm_luma_coding_block_size_minus3, tvb, pinfo, &bit_offset, H265_UE_V);
1372 
1373 		dissect_h265_exp_golomb_code(tree, hf_h265_log2_diff_max_min_pcm_luma_coding_block_size, tvb, pinfo, &bit_offset, H265_UE_V);
1374 
1375 		proto_tree_add_bits_item(tree, hf_h265_pcm_loop_filter_disabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1376 		bit_offset++;
1377 	}
1378 
1379 	num_short_term_ref_pic_sets = dissect_h265_exp_golomb_code(tree, hf_h265_num_short_term_ref_pic_sets, tvb, pinfo, &bit_offset, H265_UE_V);
1380 	if (num_short_term_ref_pic_sets > H265_MAX_NUM_SHORT_TERM_REF_PIC_SETS) {
1381 		proto_tree_add_expert(tree, pinfo, &ei_h265_value_to_large, tvb, bit_offset>>3, 1);
1382 		return;
1383 	}
1384 	for (i = 0; i < num_short_term_ref_pic_sets; i++)
1385 		bit_offset = dissect_h265_st_ref_pic_set(tree, tvb, pinfo, bit_offset, i, num_short_term_ref_pic_sets);
1386 
1387 	long_term_ref_pics_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1388 	proto_tree_add_bits_item(tree, hf_h265_long_term_ref_pics_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1389 	bit_offset++;
1390 
1391 	if (long_term_ref_pics_present_flag) {
1392 
1393 		num_long_term_ref_pics_sps = dissect_h265_exp_golomb_code(tree, hf_h265_num_long_term_ref_pics_sps, tvb, pinfo, &bit_offset, H265_UE_V);
1394 		for (i = 0; i < num_long_term_ref_pics_sps; i++) {
1395 
1396 			proto_tree_add_bits_item(tree, hf_h265_lt_ref_pic_poc_lsb_sps/*[i]*/, tvb, bit_offset, log2_max_pic_order_cnt_lsb_minus4 + 4, ENC_BIG_ENDIAN);
1397 			bit_offset = bit_offset + log2_max_pic_order_cnt_lsb_minus4 + 4;
1398 
1399 			proto_tree_add_bits_item(tree, hf_h265_used_by_curr_pic_lt_sps_flag/*[i]*/, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1400 			bit_offset++;
1401 		}
1402 	}
1403 	proto_tree_add_bits_item(tree, hf_h265_sps_temporal_mvp_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1404 	bit_offset++;
1405 
1406 	proto_tree_add_bits_item(tree, hf_h265_strong_intra_smoothing_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1407 	bit_offset++;
1408 
1409 	vui_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1410 	proto_tree_add_bits_item(tree, hf_h265_vui_parameters_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1411 	bit_offset++;
1412 
1413 	if (vui_parameters_present_flag)
1414 	{
1415 		vui_parameters_tree = proto_tree_add_subtree(tree, tvb, bit_offset >> 3, 1, ett_h265_vui_parameters, NULL, "VUI parameters");
1416 		bit_offset = dissect_h265_vui_parameters(vui_parameters_tree, tvb, pinfo, bit_offset, sps_max_sub_layers_minus1);
1417 	}
1418 
1419 	sps_extension_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1420 	proto_tree_add_bits_item(tree, hf_h265_sps_extension_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1421 	bit_offset++;
1422 
1423 	if (sps_extension_present_flag)
1424 	{
1425 		sps_range_extension_flag = tvb_get_bits8(tvb, bit_offset, 1);
1426 		proto_tree_add_bits_item(tree, hf_h265_sps_range_extension_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1427 		bit_offset++;
1428 
1429 		sps_multilayer_extension_flag = tvb_get_bits8(tvb, bit_offset, 1);
1430 		proto_tree_add_bits_item(tree, hf_h265_sps_multilayer_extension_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1431 		bit_offset++;
1432 
1433 		sps_3d_extension_flag = tvb_get_bits8(tvb, bit_offset, 1);
1434 		proto_tree_add_bits_item(tree, hf_h265_sps_3d_extension_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1435 		bit_offset++;
1436 
1437 		sps_scc_extension_flag = tvb_get_bits8(tvb, bit_offset, 1);
1438 		proto_tree_add_bits_item(tree, hf_h265_sps_scc_extension_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1439 		bit_offset++;
1440 
1441 		sps_extension_4bits = tvb_get_bits8(tvb, bit_offset, 4);
1442 		proto_tree_add_bits_item(tree, hf_h265_sps_extension_4bits, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
1443 		bit_offset = bit_offset + 4;
1444 	}
1445 	if (sps_range_extension_flag)
1446 		bit_offset = dissect_h265_sps_range_extension(tree, tvb, pinfo, bit_offset);
1447 	if (sps_multilayer_extension_flag)
1448 		bit_offset = dissect_h265_sps_multilayer_extension(tree, tvb, pinfo, bit_offset); /* specified in Annex F */
1449 	if (sps_3d_extension_flag)
1450 		bit_offset = dissect_h265_sps_3d_extension(tree, tvb, pinfo, bit_offset); /* specified in Annex I */
1451 	if (sps_scc_extension_flag)
1452 		bit_offset = dissect_h265_sps_scc_extension(tree, tvb, pinfo, bit_offset, chroma_format_idc, bit_depth_luma_minus8, bit_depth_chroma_minus8);
1453 	if (sps_extension_4bits)
1454 		while (more_rbsp_data(tree, tvb, pinfo, bit_offset)) {
1455 			proto_tree_add_bits_item(tree, hf_h265_sps_extension_data_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1456 			bit_offset++;
1457 		}
1458 	dissect_h265_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
1459 }
1460 
1461 /* Ref 7.3.2.3 Picture parameter set RBSP syntax */
1462 static void
dissect_h265_pic_parameter_set_rbsp(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,gint offset)1463 dissect_h265_pic_parameter_set_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1464 {
1465 	gint bit_offset;
1466 	guint num_tile_columns_minus1, num_tile_rows_minus1, i;
1467 	gboolean cu_qp_delta_enabled_flag, tiles_enabled_flag, uniform_spacing_flag;
1468 	gboolean deblocking_filter_control_present_flag, pps_deblocking_filter_disabled_flag;
1469 	gboolean pps_scaling_list_data_present_flag, pps_extension_present_flag;
1470 	gboolean pps_range_extension_flag = 0, pps_multilayer_extension_flag = 0, pps_3d_extension_flag = 0,
1471 		pps_scc_extension_flag = 0, pps_extension_4bits = 0, transform_skip_enabled_flag = 0;
1472 
1473 	bit_offset = offset << 3;
1474 
1475 	dissect_h265_exp_golomb_code(tree, hf_h265_pps_pic_parameter_set_id, tvb, pinfo, &bit_offset, H265_UE_V);
1476 	dissect_h265_exp_golomb_code(tree, hf_h265_pps_seq_parameter_set_id, tvb, pinfo, &bit_offset, H265_UE_V);
1477 
1478 	// data between packets TODO: move to "conversations"
1479 	dependent_slice_segments_enabled_flag = tvb_get_bits8(tvb, bit_offset, 1);
1480 
1481 	proto_tree_add_bits_item(tree, hf_h265_dependent_slice_segments_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1482 	bit_offset++;
1483 
1484 	proto_tree_add_bits_item(tree, hf_h265_output_flag_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1485 	bit_offset++;
1486 
1487 	// data between packets TODO: move to "conversations"
1488 	num_extra_slice_header_bits = tvb_get_bits8(tvb, bit_offset, 3);
1489 	proto_tree_add_bits_item(tree, hf_h265_num_extra_slice_header_bits, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
1490 	bit_offset = bit_offset + 3;
1491 
1492 	proto_tree_add_bits_item(tree, hf_h265_sign_data_hiding_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1493 	bit_offset++;
1494 
1495 	proto_tree_add_bits_item(tree, hf_h265_cabac_init_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1496 	bit_offset++;
1497 
1498 	dissect_h265_exp_golomb_code(tree, hf_h265_num_ref_idx_l0_default_active_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
1499 	dissect_h265_exp_golomb_code(tree, hf_h265_num_ref_idx_l1_default_active_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
1500 	dissect_h265_exp_golomb_code(tree, hf_h265_init_qp_minus26, tvb, pinfo, &bit_offset, H265_SE_V);
1501 
1502 	proto_tree_add_bits_item(tree, hf_h265_constrained_intra_pred_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1503 	bit_offset++;
1504 
1505 	transform_skip_enabled_flag = tvb_get_bits8(tvb, bit_offset, 1);
1506 	proto_tree_add_bits_item(tree, hf_h265_transform_skip_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1507 	bit_offset++;
1508 
1509 	cu_qp_delta_enabled_flag = tvb_get_bits8(tvb, bit_offset, 1);
1510 	proto_tree_add_bits_item(tree, hf_h265_cu_qp_delta_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1511 	bit_offset++;
1512 
1513 	if (cu_qp_delta_enabled_flag) {
1514 		dissect_h265_exp_golomb_code(tree, hf_h265_diff_cu_qp_delta_depth, tvb, pinfo, &bit_offset, H265_UE_V);
1515 	}
1516 
1517 	dissect_h265_exp_golomb_code(tree, hf_h265_pps_cb_qp_offset, tvb, pinfo, &bit_offset, H265_SE_V);
1518 	dissect_h265_exp_golomb_code(tree, hf_h265_pps_cr_qp_offset, tvb, pinfo, &bit_offset, H265_SE_V);
1519 
1520 	proto_tree_add_bits_item(tree, hf_h265_pps_slice_chroma_qp_offsets_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1521 	bit_offset++;
1522 
1523 	proto_tree_add_bits_item(tree, hf_h265_weighted_pred_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1524 	bit_offset++;
1525 
1526 	proto_tree_add_bits_item(tree, hf_h265_weighted_bipred_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1527 	bit_offset++;
1528 
1529 	proto_tree_add_bits_item(tree, hf_h265_transquant_bypass_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1530 	bit_offset++;
1531 
1532 	tiles_enabled_flag = tvb_get_bits8(tvb, bit_offset, 1);
1533 	proto_tree_add_bits_item(tree, hf_h265_tiles_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1534 	bit_offset++;
1535 
1536 	proto_tree_add_bits_item(tree, hf_h265_entropy_coding_sync_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1537 	bit_offset++;
1538 
1539 	if (tiles_enabled_flag) {
1540 
1541 		num_tile_columns_minus1 = dissect_h265_exp_golomb_code(tree, hf_h265_num_tile_columns_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
1542 		num_tile_rows_minus1 = dissect_h265_exp_golomb_code(tree, hf_h265_num_tile_rows_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
1543 
1544 		uniform_spacing_flag = tvb_get_bits8(tvb, bit_offset, 1);
1545 		proto_tree_add_bits_item(tree, hf_h265_uniform_spacing_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1546 		bit_offset++;
1547 		if (!uniform_spacing_flag) {
1548 			for (i = 0; i < num_tile_columns_minus1; i++)
1549 				dissect_h265_exp_golomb_code(tree, hf_h265_column_width_minus1/*[i]*/, tvb, pinfo, &bit_offset, H265_UE_V);
1550 			for (i = 0; i < num_tile_rows_minus1; i++)
1551 				dissect_h265_exp_golomb_code(tree, hf_h265_row_height_minus1/*[i]*/, tvb, pinfo, &bit_offset, H265_UE_V);
1552 		}
1553 
1554 		proto_tree_add_bits_item(tree, hf_h265_loop_filter_across_tiles_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1555 		bit_offset++;
1556 	}
1557 
1558 	proto_tree_add_bits_item(tree, hf_h265_pps_loop_filter_across_slices_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1559 	bit_offset++;
1560 
1561 	deblocking_filter_control_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1562 	proto_tree_add_bits_item(tree, hf_h265_deblocking_filter_control_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1563 	bit_offset++;
1564 
1565 	if (deblocking_filter_control_present_flag) {
1566 		proto_tree_add_bits_item(tree, hf_h265_deblocking_filter_override_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1567 		bit_offset++;
1568 
1569 		pps_deblocking_filter_disabled_flag = tvb_get_bits8(tvb, bit_offset, 1);
1570 		proto_tree_add_bits_item(tree, hf_h265_pps_deblocking_filter_disabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1571 		bit_offset++;
1572 
1573 		if (!pps_deblocking_filter_disabled_flag) {
1574 
1575 			dissect_h265_exp_golomb_code(tree, hf_h265_pps_beta_offset_div2, tvb, pinfo, &bit_offset, H265_SE_V);
1576 			dissect_h265_exp_golomb_code(tree, hf_h265_pps_tc_offset_div2, tvb, pinfo, &bit_offset, H265_SE_V);
1577 
1578 		}
1579 	}
1580 
1581 	pps_scaling_list_data_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1582 	proto_tree_add_bits_item(tree, hf_h265_pps_scaling_list_data_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1583 	bit_offset++;
1584 
1585 	if (pps_scaling_list_data_present_flag) {
1586 		bit_offset = dissect_h265_scaling_list_data(tree, tvb, pinfo, bit_offset);
1587 	}
1588 
1589 	proto_tree_add_bits_item(tree, hf_h265_lists_modification_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1590 	bit_offset++;
1591 
1592 	dissect_h265_exp_golomb_code(tree, hf_h265_log2_parallel_merge_level_minus2, tvb, pinfo, &bit_offset, H265_UE_V);
1593 
1594 	proto_tree_add_bits_item(tree, hf_h265_slice_segment_header_extension_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1595 	bit_offset++;
1596 
1597 	pps_extension_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
1598 	proto_tree_add_bits_item(tree, hf_h265_pps_extension_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1599 	bit_offset++;
1600 
1601 	if (pps_extension_present_flag) {
1602 		pps_range_extension_flag = tvb_get_bits8(tvb, bit_offset, 1);
1603 		proto_tree_add_bits_item(tree, hf_h265_pps_range_extension_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1604 		bit_offset++;
1605 
1606 		pps_multilayer_extension_flag = tvb_get_bits8(tvb, bit_offset, 1);
1607 		proto_tree_add_bits_item(tree, hf_h265_pps_multilayer_extension_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1608 		bit_offset++;
1609 
1610 		pps_3d_extension_flag = tvb_get_bits8(tvb, bit_offset, 1);
1611 		proto_tree_add_bits_item(tree, hf_h265_pps_3d_extension_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1612 		bit_offset++;
1613 
1614 		pps_scc_extension_flag = tvb_get_bits8(tvb, bit_offset, 1);
1615 		proto_tree_add_bits_item(tree, hf_h265_pps_scc_extension_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1616 		bit_offset++;
1617 
1618 		pps_extension_4bits = tvb_get_bits8(tvb, bit_offset, 1);
1619 		proto_tree_add_bits_item(tree, hf_h265_pps_extension_4bits, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1620 		bit_offset++;
1621 	}
1622 
1623 	if (pps_range_extension_flag)
1624 		bit_offset = dissect_h265_pps_range_extension(tree, tvb, pinfo, bit_offset, transform_skip_enabled_flag);
1625 	if (pps_multilayer_extension_flag)
1626 		bit_offset = dissect_h265_pps_multilayer_extension(tree, tvb, pinfo, bit_offset); /* specified in Annex F */
1627 	if (pps_3d_extension_flag)
1628 		bit_offset = dissect_h265_pps_3d_extension(tree, tvb, pinfo, bit_offset); /* specified in Annex I */
1629 	if (pps_scc_extension_flag)
1630 		bit_offset = dissect_h265_pps_scc_extension(tree, tvb, pinfo, bit_offset);
1631 	if (pps_extension_4bits)
1632 		while (more_rbsp_data(tree, tvb, pinfo, bit_offset)) {
1633 			proto_tree_add_bits_item(tree, hf_h265_pps_extension_data_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1634 			bit_offset++;
1635 		}
1636 	dissect_h265_rbsp_trailing_bits(tree, tvb, pinfo, bit_offset);
1637 }
1638 
1639 /* Ref 7.3.2.4 Supplemental enhancement information RBSP syntax */
1640 static void
dissect_h265_sei_rbsp(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,gint offset,guint8 nal_unit_type)1641 dissect_h265_sei_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset, guint8 nal_unit_type)
1642 {
1643 	proto_tree *sei_rbsp_tree;
1644 	sei_rbsp_tree = proto_tree_add_subtree(tree, tvb, offset, 1, ett_h265_sei_rbsp, NULL, "Supplemental enhancement information RBSP");
1645 
1646 	gint bit_offset;
1647 
1648 	bit_offset = offset << 3;
1649 
1650 	do
1651 	{
1652 		bit_offset = dissect_h265_sei_message(sei_rbsp_tree, tvb, pinfo, bit_offset, nal_unit_type);
1653 	} while (more_rbsp_data(sei_rbsp_tree, tvb, pinfo, bit_offset));
1654 
1655 	dissect_h265_rbsp_trailing_bits(sei_rbsp_tree, tvb, pinfo, bit_offset);
1656 }
1657 
1658 /* Ref 7.3.2.5 Access unit delimiter RBSP syntax */
1659 static void
dissect_h265_access_unit_delimiter_rbsp(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,gint offset)1660 dissect_h265_access_unit_delimiter_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1661 {
1662 	proto_tree *access_unit_delimiter_rbsp_tree;
1663 	access_unit_delimiter_rbsp_tree = proto_tree_add_subtree(tree, tvb, offset, 1, ett_h265_access_unit_delimiter_rbsp, NULL, "Access unit delimiter RBSP");
1664 	proto_tree_add_expert(access_unit_delimiter_rbsp_tree, pinfo, &ei_h265_undecoded, tvb, offset, -1);
1665 }
1666 
1667 /* Ref 7.3.2.6 End of sequence RBSP syntax*/
1668 static void
dissect_h265_end_of_seq_rbsp(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,gint offset)1669 dissect_h265_end_of_seq_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1670 {
1671 	proto_tree *end_of_seq_rbsp_tree;
1672 	end_of_seq_rbsp_tree = proto_tree_add_subtree(tree, tvb, offset, 1, ett_h265_end_of_seq_rbsp, NULL, "End of sequence RBSP");
1673 	proto_tree_add_expert(end_of_seq_rbsp_tree, pinfo, &ei_h265_undecoded, tvb, offset, -1);
1674 }
1675 
1676 /* Ref  7.3.2.7 End of bitstream RBSP syntax*/
1677 static void
dissect_h265_end_of_bitstream_rbsp(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,gint offset)1678 dissect_h265_end_of_bitstream_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1679 {
1680 	proto_tree *end_of_bitstream_rbsp_tree;
1681 	end_of_bitstream_rbsp_tree = proto_tree_add_subtree(tree, tvb, offset, 1, ett_h265_end_of_bitstream_rbsp, NULL, "End of bitstream RBSP");
1682 	proto_tree_add_expert(end_of_bitstream_rbsp_tree, pinfo, &ei_h265_undecoded, tvb, offset, -1);
1683 }
1684 
1685 /* Ref 7.3.2.8 Filler data RBSP syntax */
1686 static void
dissect_h265_filler_data_rbsp(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,gint offset)1687 dissect_h265_filler_data_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset)
1688 {
1689 	proto_tree *filler_data_rbsp_tree;
1690 	filler_data_rbsp_tree = proto_tree_add_subtree(tree, tvb, offset, 1, ett_h265_filler_data_rbsp, NULL, "Filler data RBSP");
1691 	proto_tree_add_expert(filler_data_rbsp_tree, pinfo, &ei_h265_undecoded, tvb, offset, -1);
1692 }
1693 
1694 /* Ref 7.3.3 Profile, tier and level syntax */
1695 static int
dissect_h265_profile_tier_level(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo _U_,gint offset,gboolean profilePresentFlag,gint vps_max_sub_layers_minus1)1696 dissect_h265_profile_tier_level(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo _U_, gint offset, gboolean profilePresentFlag, gint vps_max_sub_layers_minus1)
1697 {
1698 	proto_item *general_level_idc_item;
1699 	guint32     general_profile_idc, general_level_idc;
1700 	guint32		sub_layer_profile_idc[32] = { 0 };
1701 	gboolean general_tier_flag = 0;
1702 	gboolean general_profile_compatibility_flag[32] = { 0 };
1703 	gboolean sub_layer_profile_present_flag[32] = { 0 };
1704 	gboolean sub_layer_level_present_flag[32] = { 0 };
1705 	gboolean sub_layer_profile_compatibility_flag[32][32] = { { 0 } };
1706 
1707 	if (profilePresentFlag) {
1708 		proto_tree_add_item(tree, hf_h265_general_profile_space, tvb, offset, 1, ENC_BIG_ENDIAN);
1709 		proto_tree_add_item_ret_boolean(tree, hf_h265_general_tier_flag, tvb, offset, 1, ENC_BIG_ENDIAN, &general_tier_flag);
1710 		proto_tree_add_item_ret_uint(tree, hf_h265_general_profile_idc, tvb, offset, 1, ENC_BIG_ENDIAN, &general_profile_idc);
1711 		offset++;
1712 
1713 		proto_tree_add_item(tree, hf_h265_general_profile_compatibility_flags, tvb, offset, 4, ENC_BIG_ENDIAN);
1714 
1715 		gint bit_offset = offset << 3;
1716 		for (int j = 0; j < 32; j++)
1717 			general_profile_compatibility_flag[j] = tvb_get_bits8(tvb, bit_offset + j, 1);
1718 		bit_offset = bit_offset + 32;
1719 
1720 		proto_tree_add_bits_item(tree, hf_h265_general_progressive_source_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1721 		bit_offset++;
1722 		proto_tree_add_bits_item(tree, hf_h265_general_interlaced_source_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1723 		bit_offset++;
1724 		proto_tree_add_bits_item(tree, hf_h265_general_non_packed_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1725 		bit_offset++;
1726 		proto_tree_add_bits_item(tree, hf_h265_general_frame_only_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1727 		bit_offset++;
1728 
1729 		if (general_profile_idc == 4 || general_profile_compatibility_flag[4] ||
1730 			general_profile_idc == 5 || general_profile_compatibility_flag[5] ||
1731 			general_profile_idc == 6 || general_profile_compatibility_flag[6] ||
1732 			general_profile_idc == 7 || general_profile_compatibility_flag[7] ||
1733 			general_profile_idc == 8 || general_profile_compatibility_flag[8] ||
1734 			general_profile_idc == 9 || general_profile_compatibility_flag[9] ||
1735 			general_profile_idc == 10 || general_profile_compatibility_flag[10]) {
1736 			/* The number of bits in this syntax structure is not affected by this condition */
1737 			proto_tree_add_bits_item(tree, hf_h265_general_max_12bit_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1738 			bit_offset++;
1739 			proto_tree_add_bits_item(tree, hf_h265_general_max_10bit_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1740 			bit_offset++;
1741 			proto_tree_add_bits_item(tree, hf_h265_general_max_8bit_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1742 			bit_offset++;
1743 			proto_tree_add_bits_item(tree, hf_h265_general_max_422chroma_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1744 			bit_offset++;
1745 			proto_tree_add_bits_item(tree, hf_h265_general_max_420chroma_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1746 			bit_offset++;
1747 			proto_tree_add_bits_item(tree, hf_h265_general_max_monochrome_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1748 			bit_offset++;
1749 			proto_tree_add_bits_item(tree, hf_h265_general_intra_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1750 			bit_offset++;
1751 			proto_tree_add_bits_item(tree, hf_h265_general_one_picture_only_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1752 			bit_offset++;
1753 			proto_tree_add_bits_item(tree, hf_h265_general_lower_bit_rate_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1754 			bit_offset++;
1755 			if (general_profile_idc == 5 || general_profile_compatibility_flag[5] ||
1756 				general_profile_idc == 9 || general_profile_compatibility_flag[9] ||
1757 				general_profile_idc == 10 || general_profile_compatibility_flag[10]) {
1758 				proto_tree_add_bits_item(tree, hf_h265_general_max_14bit_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1759 				bit_offset++;
1760 				proto_tree_add_bits_item(tree, hf_h265_general_reserved_zero_33bits, tvb, bit_offset, 33, ENC_BIG_ENDIAN);
1761 				bit_offset = bit_offset + 33;
1762 			}
1763 			else {
1764 				proto_tree_add_bits_item(tree, hf_h265_general_reserved_zero_34bits, tvb, bit_offset, 34, ENC_BIG_ENDIAN);
1765 				bit_offset = bit_offset + 34;
1766 			}
1767 		}
1768 		else if (general_profile_idc == 2 || general_profile_compatibility_flag[2]) {
1769 			proto_tree_add_bits_item(tree, hf_h265_general_reserved_zero_7bits, tvb, bit_offset, 7, ENC_BIG_ENDIAN);
1770 			bit_offset = bit_offset + 7;
1771 			proto_tree_add_bits_item(tree, hf_h265_general_one_picture_only_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1772 			bit_offset++;
1773 			proto_tree_add_bits_item(tree, hf_h265_general_reserved_zero_35bits, tvb, bit_offset, 35, ENC_BIG_ENDIAN);
1774 			bit_offset = bit_offset + 35;
1775 		}
1776 		else {
1777 			proto_tree_add_bits_item(tree, hf_h265_general_reserved_zero_43bits, tvb, bit_offset, 43, ENC_BIG_ENDIAN);
1778 			bit_offset = bit_offset + 43;
1779 		}
1780 
1781 		if ((general_profile_idc >= 1 && general_profile_idc <= 5) ||
1782 			general_profile_idc == 9 ||
1783 			general_profile_compatibility_flag[1] || general_profile_compatibility_flag[2] ||
1784 			general_profile_compatibility_flag[3] || general_profile_compatibility_flag[4] ||
1785 			general_profile_compatibility_flag[5] || general_profile_compatibility_flag[9])
1786 			/* The number of bits in this syntax structure is not affected by this condition */ {
1787 			proto_tree_add_bits_item(tree, hf_h265_general_inbld_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1788 		}
1789 		else {
1790 			proto_tree_add_bits_item(tree, hf_h265_general_reserved_zero_bit, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1791 		}
1792 		bit_offset++;
1793 
1794 		general_level_idc_item = proto_tree_add_item_ret_uint(tree, hf_h265_general_level_idc, tvb, bit_offset >> 3, 1, ENC_BIG_ENDIAN, &general_level_idc);
1795 		if (general_tier_flag) {
1796 			proto_item_append_text(general_level_idc_item, " [Level %.1f %s]", ((double)general_level_idc / 30), val_to_str_const(general_level_idc / 3, h265_level_high_tier_bitrate_values, "Unknown"));
1797 		}
1798 		else {
1799 			proto_item_append_text(general_level_idc_item, " [Level %.1f %s]", ((double)general_level_idc / 30), val_to_str_const(general_level_idc / 3, h265_level_main_tier_bitrate_values, "Unknown"));
1800 		}
1801 		bit_offset += 8;
1802 
1803 		for (int i = 0; i < vps_max_sub_layers_minus1; i++) {
1804 			sub_layer_profile_present_flag[i] = tvb_get_bits8(tvb, bit_offset, 1);
1805 			proto_tree_add_bits_item(tree, hf_h265_sub_layer_profile_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1806 			bit_offset++;
1807 			proto_tree_add_bits_item(tree, hf_h265_sub_layer_level_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1808 			bit_offset++;
1809 		}
1810 
1811 		if (vps_max_sub_layers_minus1 > 0)
1812 			for (int i = vps_max_sub_layers_minus1; i < 8; i++) {
1813 				proto_tree_add_bits_item(tree, hf_h265_reserved_zero_2bits/*[i]*/, tvb, bit_offset, 2, ENC_BIG_ENDIAN);
1814 				bit_offset = bit_offset + 2;
1815 			}
1816 
1817 		for (int i = 0; i < vps_max_sub_layers_minus1; i++) {
1818 			if (sub_layer_profile_present_flag[i]) {
1819 				proto_tree_add_item(tree, hf_h265_sub_layer_profile_space, tvb, bit_offset >> 3, 1, ENC_BIG_ENDIAN);
1820 				proto_tree_add_item(tree, hf_h265_sub_layer_tier_flag, tvb, bit_offset >> 3, 1, ENC_BIG_ENDIAN);
1821 				proto_tree_add_item(tree, hf_h265_sub_layer_profile_idc, tvb, bit_offset >> 3, 1, ENC_BIG_ENDIAN);
1822 				sub_layer_profile_idc[i] = tvb_get_bits8(tvb, (bit_offset >> 3) + 3, 5);
1823 
1824 				bit_offset = bit_offset + 8;
1825 
1826 				for (int j = 0; j < 32; j++) {
1827 					sub_layer_profile_compatibility_flag[i][j] = tvb_get_bits8(tvb, bit_offset, 1);
1828 				}
1829 				proto_tree_add_item(tree, hf_h265_sub_layer_profile_compatibility_flag, tvb, bit_offset >> 3, 4, ENC_BIG_ENDIAN);
1830 				bit_offset = bit_offset + 32;
1831 
1832 				proto_tree_add_bits_item(tree, hf_h265_sub_layer_progressive_source_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1833 				bit_offset++;
1834 				proto_tree_add_bits_item(tree, hf_h265_sub_layer_interlaced_source_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1835 				bit_offset++;
1836 				proto_tree_add_bits_item(tree, hf_h265_sub_layer_non_packed_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1837 				bit_offset++;
1838 				proto_tree_add_bits_item(tree, hf_h265_sub_layer_frame_only_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1839 				bit_offset++;
1840 
1841 				if (sub_layer_profile_idc[i] == 4 || sub_layer_profile_compatibility_flag[i][4] ||
1842 					sub_layer_profile_idc[i] == 5 || sub_layer_profile_compatibility_flag[i][5] ||
1843 					sub_layer_profile_idc[i] == 6 || sub_layer_profile_compatibility_flag[i][6] ||
1844 					sub_layer_profile_idc[i] == 7 || sub_layer_profile_compatibility_flag[i][7] ||
1845 					sub_layer_profile_idc[i] == 8 || sub_layer_profile_compatibility_flag[i][8] ||
1846 					sub_layer_profile_idc[i] == 9 || sub_layer_profile_compatibility_flag[i][9] ||
1847 					sub_layer_profile_idc[i] == 10 || sub_layer_profile_compatibility_flag[i][10]) {
1848 					/* The number of bits in this syntax structure is not affected by this condition */
1849 					proto_tree_add_bits_item(tree, hf_h265_sub_layer_max_12bit_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1850 					bit_offset++;
1851 					proto_tree_add_bits_item(tree, hf_h265_sub_layer_max_10bit_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1852 					bit_offset++;
1853 					proto_tree_add_bits_item(tree, hf_h265_sub_layer_max_8bit_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1854 					bit_offset++;
1855 					proto_tree_add_bits_item(tree, hf_h265_sub_layer_max_422chroma_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1856 					bit_offset++;
1857 					proto_tree_add_bits_item(tree, hf_h265_sub_layer_max_420chroma_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1858 					bit_offset++;
1859 					proto_tree_add_bits_item(tree, hf_h265_sub_layer_max_monochrome_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1860 					bit_offset++;
1861 					proto_tree_add_bits_item(tree, hf_h265_sub_layer_intra_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1862 					bit_offset++;
1863 					proto_tree_add_bits_item(tree, hf_h265_sub_layer_one_picture_only_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1864 					bit_offset++;
1865 					proto_tree_add_bits_item(tree, hf_h265_sub_layer_lower_bit_rate_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1866 					bit_offset++;
1867 
1868 					if (sub_layer_profile_idc[i] == 5 ||
1869 						sub_layer_profile_compatibility_flag[i][5]) {
1870 						proto_tree_add_bits_item(tree, hf_h265_sub_layer_max_14bit_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1871 						proto_tree_add_bits_item(tree, hf_h265_sub_layer_reserved_zero_33bits, tvb, bit_offset + 1, 33, ENC_BIG_ENDIAN);
1872 						bit_offset = bit_offset + 34;
1873 					}
1874 					else {
1875 						proto_tree_add_bits_item(tree, hf_h265_sub_layer_reserved_zero_34bits, tvb, bit_offset + 1, 33, ENC_BIG_ENDIAN);
1876 						bit_offset = bit_offset + 34;
1877 					}
1878 				}
1879 				else if (sub_layer_profile_idc[i] == 2 ||
1880 					sub_layer_profile_compatibility_flag[i][2]) {
1881 					proto_tree_add_bits_item(tree, hf_h265_sub_layer_reserved_zero_7bits, tvb, bit_offset, 7, ENC_BIG_ENDIAN);
1882 					bit_offset = bit_offset + 7;
1883 					proto_tree_add_bits_item(tree, hf_h265_sub_layer_one_picture_only_constraint_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1884 					bit_offset++;
1885 					proto_tree_add_bits_item(tree, hf_h265_sub_layer_reserved_zero_35bits, tvb, bit_offset, 35, ENC_BIG_ENDIAN);
1886 					bit_offset = bit_offset + 35;
1887 				}
1888 				else {
1889 					proto_tree_add_bits_item(tree, hf_h265_sub_layer_reserved_zero_43bits, tvb, bit_offset, 43, ENC_BIG_ENDIAN);
1890 					bit_offset = bit_offset + 43;
1891 				}
1892 				if ((sub_layer_profile_idc[i] >= 1 && sub_layer_profile_idc[i] <= 5) ||
1893 					sub_layer_profile_idc[i] == 9 ||
1894 					sub_layer_profile_compatibility_flag[i][1] ||
1895 					sub_layer_profile_compatibility_flag[i][2] ||
1896 					sub_layer_profile_compatibility_flag[i][3] ||
1897 					sub_layer_profile_compatibility_flag[i][4] ||
1898 					sub_layer_profile_compatibility_flag[i][5] ||
1899 					sub_layer_profile_compatibility_flag[i][9]) {
1900 					/* The number of bits in this syntax structure is not affected by this condition */
1901 					proto_tree_add_bits_item(tree, hf_h265_sub_layer_inbld_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1902 					bit_offset++;
1903 				}
1904 				else {
1905 					proto_tree_add_bits_item(tree, hf_h265_sub_layer_reserved_zero_bit, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1906 					bit_offset++;
1907 				}
1908 			}
1909 			if (sub_layer_level_present_flag[i]) {
1910 				proto_tree_add_item(tree, hf_h265_sub_layer_level_idc, tvb, bit_offset >> 3, 1, ENC_BIG_ENDIAN);
1911 				bit_offset = bit_offset + 8;
1912 			}
1913 		}
1914 		offset = bit_offset >> 3;
1915 	}
1916 
1917 	return offset;
1918 }
1919 
1920 /* 7.3.6 Slice segment header syntax */
1921 /* Just parse a few bits same as in H.264 */
1922 /* TODO: if need more info from slice hedaer , do more parsing */
1923 static int
dissect_h265_slice_segment_header(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo _U_,gint bit_offset,guint8 nal_unit_type)1924 dissect_h265_slice_segment_header(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset, guint8 nal_unit_type)
1925 {
1926 	gboolean first_slice_segment_in_pic_flag = 0, /*no_output_of_prior_pics_flag = 0,*/ dependent_slice_segment_flag = 0;
1927 
1928 	guint MinCbLog2SizeY = log2_min_luma_coding_block_size_minus3 + 3;
1929 	guint CtbLog2SizeY = MinCbLog2SizeY + log2_diff_max_min_luma_coding_block_size;
1930 	guint CtbSizeY = 1 << CtbLog2SizeY;
1931 	double PicWidthInCtbsY = ceil(pic_width_in_luma_samples / CtbSizeY);
1932         double PicHeightInCtbsY = ceil(pic_height_in_luma_samples / CtbSizeY);
1933         double PicSizeInCtbsY = PicWidthInCtbsY * PicHeightInCtbsY;
1934 	guint nBits = (guint)(ceil(log2(PicSizeInCtbsY)));
1935 	guint i;
1936 
1937 	first_slice_segment_in_pic_flag = tvb_get_bits8(tvb, bit_offset, 1);
1938 	bit_offset++;
1939 
1940 	if (nal_unit_type >= str_to_val("BLA_W_LP", h265_type_summary_values, 16) &&
1941 		nal_unit_type <= str_to_val("RSV_IRAP_VCL23", h265_type_summary_values, 23)) {
1942 		/*no_output_of_prior_pics_flag = tvb_get_bits8(tvb, bit_offset, 1);*/
1943 		bit_offset++;
1944 	}
1945 
1946 	dissect_h265_exp_golomb_code(tree, hf_h265_slice_pic_parameter_set_id, tvb, pinfo, &bit_offset, H265_UE_V);
1947 
1948 	if (!first_slice_segment_in_pic_flag) {
1949 		if (dependent_slice_segments_enabled_flag){
1950 			dependent_slice_segment_flag = tvb_get_bits8(tvb, bit_offset, 1);
1951 			bit_offset++;
1952 		}
1953 		proto_tree_add_bits_item(tree, hf_h265_slice_segment_address, tvb, bit_offset, nBits, ENC_BIG_ENDIAN);
1954 		bit_offset = bit_offset + nBits;
1955 	}
1956 
1957 	if (!dependent_slice_segment_flag) {
1958 		for (i = 0; i < num_extra_slice_header_bits; i++) {
1959 			/* slice_reserved_flag[i] u(1) */
1960 			bit_offset++;
1961 		}
1962 		dissect_h265_exp_golomb_code(tree, hf_h265_slice_type, tvb, pinfo, &bit_offset, H265_UE_V);
1963 	}
1964 
1965 	return bit_offset;
1966 }
1967 
1968 /* 7.3.2.9 Slice segment layer RBSP syntax */
1969 static void
dissect_h265_slice_segment_layer_rbsp(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,gint offset,guint8 nal_unit_type)1970 dissect_h265_slice_segment_layer_rbsp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint offset, guint8 nal_unit_type)
1971 {
1972 	gint bit_offset;
1973 
1974 	bit_offset = offset << 3;
1975 
1976 	/* slice_segment_header( ) */
1977 	dissect_h265_slice_segment_header(tree, tvb, pinfo, bit_offset, nal_unit_type);
1978 	/* slice_segment_data( ) */
1979 	/* rbsp_slice_segment_trailing_bits( ) */
1980 }
1981 
1982 /* 7.3.4 Scaling list data syntax */
1983 static int
dissect_h265_scaling_list_data(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo _U_,gint bit_offset)1984 dissect_h265_scaling_list_data(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo _U_, gint bit_offset)
1985 {
1986 	gboolean scaling_list_pred_mode_flag[4][6] = { { 0 } };
1987 	/*gint32 ScalingList[4][6][64] = { 0 };*/
1988 	gint sizeId, matrixId, nextCoef, coefNum, i;
1989 	gint32 scaling_list_dc_coef_minus8, scaling_list_delta_coef;
1990 	for (sizeId = 0; sizeId < 4; sizeId++)
1991 		for (matrixId = 0; matrixId < 6; matrixId += (sizeId == 3) ? 3 : 1) {
1992 			scaling_list_pred_mode_flag[sizeId][matrixId] = tvb_get_bits8(tvb, bit_offset, 1);
1993 			proto_tree_add_bits_item(tree, hf_h265_scaling_list_pred_mode_flag/*[sizeId][matrixId]*/, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
1994 			bit_offset++;
1995 			if (!scaling_list_pred_mode_flag[sizeId][matrixId])
1996 				dissect_h265_exp_golomb_code(tree, hf_h265_scaling_list_pred_matrix_id_delta/*[sizeId][matrixId]*/, tvb, pinfo, &bit_offset, H265_UE_V);
1997 			else {
1998 				nextCoef = 8;
1999 				coefNum = MIN(64, (1 << (4 + (sizeId << 1))));
2000 				if (sizeId > 1) {
2001 					scaling_list_dc_coef_minus8 = dissect_h265_exp_golomb_code(tree, hf_h265_scaling_list_dc_coef_minus8/*[sizeId - 2][matrixId]*/, tvb, pinfo, &bit_offset, H265_SE_V);
2002 					nextCoef = scaling_list_dc_coef_minus8 + 8;
2003 				}
2004 				for (i = 0; i < coefNum; i++) {
2005 					scaling_list_delta_coef = dissect_h265_exp_golomb_code(tree, hf_h265_scaling_list_delta_coef, tvb, pinfo, &bit_offset, H265_SE_V);
2006 					nextCoef = (nextCoef + scaling_list_delta_coef + 256) % 256;
2007 					/*ScalingList[sizeId][matrixId][i] = nextCoef;*/
2008 				}
2009 			}
2010 		}
2011 	return bit_offset;
2012 }
2013 
2014 /* D.2.1 General SEI message syntax */
2015 static int
dissect_h265_sei_payload(proto_tree * tree _U_,tvbuff_t * tvb _U_,packet_info * pinfo _U_,gint bit_offset,guint payloadType _U_,guint payloadSize,guint8 nal_unit_type _U_)2016 dissect_h265_sei_payload(proto_tree* tree _U_, tvbuff_t* tvb _U_, packet_info* pinfo _U_, gint bit_offset, guint payloadType _U_, guint payloadSize, guint8 nal_unit_type _U_)
2017 {
2018 	//gint bit_start = bit_offset;
2019 #if 0
2020 	if (nal_unit_type == str_to_val("PREFIX_SEI_NUT", h265_type_summary_values, 39)) {
2021 		if (payloadType == 0)
2022 			buffering_period(payloadSize);
2023 		else if (payloadType == 1)
2024 			pic_timing(payloadSize);
2025 		else if (payloadType == 2)
2026 			pan_scan_rect(payloadSize);
2027 		else if (payloadType == 3)
2028 			filler_payload(payloadSize);
2029 		else if (payloadType == 4)
2030 			user_data_registered_itu_t_t35(payloadSize);
2031 		else if (payloadType == 5)
2032 			user_data_unregistered(payloadSize);
2033 		else if (payloadType == 6)
2034 			recovery_point(payloadSize);
2035 		else if (payloadType == 9)
2036 			scene_info(payloadSize);
2037 		else if (payloadType == 15)
2038 			picture_snapshot(payloadSize);
2039 		else if (payloadType == 16)
2040 			progressive_refinement_segment_start(payloadSize);
2041 		else if (payloadType == 17)
2042 			progressive_refinement_segment_end(payloadSize);
2043 		else if (payloadType == 19)
2044 			film_grain_characteristics(payloadSize);
2045 		else if (payloadType == 22)
2046 			post_filter_hint(payloadSize);
2047 		else if (payloadType == 23)
2048 			tone_mapping_info(payloadSize);
2049 		else if (payloadType == 45)
2050 			frame_packing_arrangement(payloadSize);
2051 		else if (payloadType == 47)
2052 			display_orientation(payloadSize);
2053 		else if (payloadType == 56)
2054 			green_metadata(payloadSize); /* specified in ISO/IEC 23001-11 */
2055 		else if (payloadType == 128)
2056 			structure_of_pictures_info(payloadSize);
2057 		else if (payloadType == 129)
2058 			active_parameter_sets(payloadSize);
2059 		else if (payloadType == 130)
2060 			decoding_unit_info(payloadSize);
2061 		else if (payloadType == 131)
2062 			temporal_sub_layer_zero_idx(payloadSize);
2063 		else if (payloadType == 133)
2064 			scalable_nesting(payloadSize);
2065 		else if (payloadType == 134)
2066 			region_refresh_info(payloadSize);
2067 		else if (payloadType == 135)
2068 			no_display(payloadSize);
2069 		else if (payloadType == 136)
2070 			time_code(payloadSize);
2071 		else if (payloadType == 137)
2072 			mastering_display_colour_volume(payloadSize);
2073 		else if (payloadType == 138)
2074 			segmented_rect_frame_packing_arrangement(payloadSize);
2075 		else if (payloadType == 139)
2076 			temporal_motion_constrained_tile_sets(payloadSize);
2077 		else if (payloadType == 140)
2078 			chroma_resampling_filter_hint(payloadSize);
2079 		else if (payloadType == 141)
2080 			knee_function_info(payloadSize);
2081 		else if (payloadType == 142)
2082 			colour_remapping_info(payloadSize);
2083 		else if (payloadType == 143)
2084 			deinterlaced_field_identification(payloadSize);
2085 		else if (payloadType == 144)
2086 			content_light_level_info(payloadSize);
2087 		else if (payloadType == 145)
2088 			dependent_rap_indication(payloadSize);
2089 		else if (payloadType == 146)
2090 			coded_region_completion(payloadSize);
2091 		else if (payloadType == 147)
2092 			alternative_transfer_characteristics(payloadSize);
2093 		else if (payloadType == 148)
2094 			ambient_viewing_environment(payloadSize);
2095 		else if (payloadType == 149)
2096 			content_colour_volume(payloadSize);
2097 		else if (payloadType == 150)
2098 			equirectangular_projection(payloadSize);
2099 		else if (payloadType == 151)
2100 			cubemap_projection(payloadSize);
2101 		else if (payloadType == 154)
2102 			sphere_rotation(payloadSize);
2103 		else if (payloadType == 155)
2104 			regionwise_packing(payloadSize);
2105 		else if (payloadType == 156)
2106 			omni_viewport(payloadSize);
2107 		else if (payloadType == 157)
2108 			regional_nesting(payloadSize);
2109 		else if (payloadType == 158)
2110 			mcts_extraction_info_sets(payloadSize);
2111 		else if (payloadType == 159)
2112 			mcts_extraction_info_nesting(payloadSize);
2113 		else if (payloadType == 160)
2114 			layers_not_present(payloadSize); /* specified in Annex F */
2115 		else if (payloadType == 161)
2116 			inter_layer_constrained_tile_sets(payloadSize); /* specified in Annex F */
2117 		else if (payloadType == 162)
2118 			bsp_nesting(payloadSize); /* specified in Annex F */
2119 		else if (payloadType == 163)
2120 			bsp_initial_arrival_time(payloadSize); /* specified in Annex F */
2121 		else if (payloadType == 164)
2122 			sub_bitstream_property(payloadSize); /* specified in Annex F */
2123 		else if (payloadType == 165)
2124 			alpha_channel_info(payloadSize); /* specified in Annex F */
2125 		else if (payloadType == 166)
2126 			overlay_info(payloadSize); /* specified in Annex F */
2127 		else if (payloadType == 167)
2128 			temporal_mv_prediction_constraints(payloadSize); /* specified in Annex F */
2129 		else if (payloadType == 168)
2130 			frame_field_info(payloadSize); /* specified in Annex F */
2131 		else if (payloadType == 176)
2132 			three_dimensional_reference_displays_info(payloadSize); /* specified in Annex G */
2133 		else if (payloadType == 177)
2134 			depth_representation_info(payloadSize); /* specified in Annex G */
2135 		else if (payloadType == 178)
2136 			multiview_scene_info(payloadSize); /* specified in Annex G */
2137 		else if (payloadType == 179)
2138 			multiview_acquisition_info(payloadSize); /* specified in Annex G */
2139 		else if (payloadType == 180)
2140 			multiview_view_position(payloadSize); /* specified in Annex G */
2141 		else if (payloadType == 181)
2142 			alternative_depth_info(payloadSize); /* specified in Annex I */
2143 		else
2144 			reserved_sei_message(payloadSize);
2145 	}
2146 	else /* nal_unit_type == SUFFIX_SEI_NUT */ {
2147 		if (payloadType == 3)
2148 			filler_payload(payloadSize);
2149 		else if (payloadType == 4)
2150 			user_data_registered_itu_t_t35(payloadSize);
2151 		else if (payloadType == 5)
2152 			user_data_unregistered(payloadSize);
2153 		else if (payloadType == 17)
2154 			progressive_refinement_segment_end(payloadSize);
2155 		else if (payloadType == 22)
2156 			post_filter_hint(payloadSize);
2157 		else if (payloadType == 132)
2158 			decoded_picture_hash(payloadSize);
2159 		else if (payloadType == 146)
2160 			coded_region_completion(payloadSize);
2161 		else
2162 			reserved_sei_message(payloadSize);
2163 	}
2164 	if (h265_more_data_in_payload(bit_start, bit_offset, payloadSize)) {
2165 		if (h265_payload_extension_present(tvb, bit_start, bit_offset, payloadSize)) {
2166 			/*reserved_payload_extension_data u(v) */
2167 			guint nEarlierBits = bit_offset - bit_start;
2168 			guint v_bits = 8 * payloadSize - nEarlierBits - nPayloadZeroBits - 1;
2169 			bit_offset = bit_offset + v_bits;
2170 		}
2171 		/* payload_bit_equal_to_one (equal to 1) f(1) */
2172 		bit_offset++;
2173 		while (!h265_byte_aligned(bit_offset)) {
2174 			/* payload_bit_equal_to_zero (equal to 0) f(1)*/
2175 			bit_offset++;
2176 		}
2177 	}
2178 #else
2179 	bit_offset = bit_offset + (payloadSize << 3);
2180 #endif
2181 	return bit_offset;
2182 }
2183 
2184 /* 7.3.5 Supplemental enhancement information message syntax */
2185 static int
dissect_h265_sei_message(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,gint bit_offset,guint8 nal_unit_type)2186 dissect_h265_sei_message(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint bit_offset, guint8 nal_unit_type)
2187 {
2188 	guint payloadType = 0, last_payload_type_byte, payloadSize, last_payload_size_byte;
2189 	gint    start_bit_offset, length;
2190 
2191 	start_bit_offset = bit_offset;
2192 
2193 	while (tvb_get_bits8(tvb, bit_offset, 8) == 0xFF) {
2194 		bit_offset = bit_offset + 8;
2195 		payloadType += 255;
2196 	}
2197 
2198 	last_payload_type_byte = tvb_get_bits8(tvb, bit_offset, 8);
2199 	bit_offset = bit_offset + 8;
2200 
2201 	payloadType += last_payload_type_byte;
2202 	length = (bit_offset - start_bit_offset) >> 3;
2203 
2204 	proto_tree_add_uint(tree, hf_h265_payloadtype, tvb, start_bit_offset >> 3, length, payloadType);
2205 
2206 	payloadSize = 0;
2207 	start_bit_offset = bit_offset;
2208 	while (tvb_get_bits8(tvb, bit_offset, 8) == 0xFF) {
2209 		bit_offset = bit_offset + 8;
2210 		payloadSize += 255;
2211 	}
2212 
2213 	last_payload_size_byte = tvb_get_bits8(tvb, bit_offset, 8);
2214 	bit_offset = bit_offset + 8;
2215 
2216 	payloadSize += last_payload_size_byte;
2217 	length = (bit_offset - start_bit_offset) >> 3;
2218 	proto_tree_add_uint(tree, hf_h265_payloadsize, tvb, start_bit_offset >> 3, length, payloadSize);
2219 
2220 	bit_offset = dissect_h265_sei_payload(tree, tvb, pinfo, bit_offset, payloadType, payloadSize, nal_unit_type);
2221 
2222 	return bit_offset;
2223 }
2224 
2225 /* 7.3.7 Short-term reference picture set syntax */
2226 static int
dissect_h265_st_ref_pic_set(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo _U_,gint bit_offset,gint stRpsIdx,gint num_short_term_ref_pic_sets)2227 dissect_h265_st_ref_pic_set(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo _U_, gint bit_offset, gint stRpsIdx, gint num_short_term_ref_pic_sets)
2228 {
2229 	gint j;
2230 	guint i;
2231 	guint32 num_negative_pics, num_positive_pics;
2232 	gboolean inter_ref_pic_set_prediction_flag = 0;
2233 	gboolean used_by_curr_pic_flag;
2234 	gint32 NumDeltaPocs[64] = { 0 }; //TODO: need to initlize
2235 
2236 	if (stRpsIdx != 0) {
2237 		inter_ref_pic_set_prediction_flag = tvb_get_bits8(tvb, bit_offset, 1);
2238 		proto_tree_add_bits_item(tree, hf_h265_inter_ref_pic_set_prediction_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2239 		bit_offset++;
2240 	}
2241 	if (inter_ref_pic_set_prediction_flag) {
2242 		if (stRpsIdx == num_short_term_ref_pic_sets) {
2243 			dissect_h265_exp_golomb_code(tree, hf_h265_delta_idx_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
2244 		}
2245 		proto_tree_add_bits_item(tree, hf_h265_delta_rps_sign, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2246 		bit_offset++;
2247 		dissect_h265_exp_golomb_code(tree, hf_h265_abs_delta_rps_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
2248 		for (j = 0; j <= NumDeltaPocs[stRpsIdx]; j++) {
2249 			used_by_curr_pic_flag = tvb_get_bits8(tvb, bit_offset, 1);
2250 			proto_tree_add_bits_item(tree, hf_h265_used_by_curr_pic_flag/*[j]*/, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2251 			bit_offset++;
2252 			if (!used_by_curr_pic_flag/*[j]*/) {
2253 				proto_tree_add_bits_item(tree, hf_h265_use_delta_flag/*[j]*/, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2254 				bit_offset++;
2255 			}
2256 		}
2257 	}
2258 	else {
2259 		num_negative_pics = dissect_h265_exp_golomb_code(tree, hf_h265_num_negative_pics, tvb, pinfo, &bit_offset, H265_UE_V);
2260 		num_positive_pics = dissect_h265_exp_golomb_code(tree, hf_h265_num_positive_pics, tvb, pinfo, &bit_offset, H265_UE_V);
2261 		for (i = 0; i < num_negative_pics; i++) {
2262 			dissect_h265_exp_golomb_code(tree, hf_h265_delta_poc_s0_minus1/*[i]*/, tvb, pinfo, &bit_offset, H265_UE_V);
2263 			proto_tree_add_bits_item(tree, hf_h265_used_by_curr_pic_s0_flag/*[i]*/, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2264 			bit_offset++;
2265 		}
2266 		for (i = 0; i < num_positive_pics; i++) {
2267 			dissect_h265_exp_golomb_code(tree, hf_h265_delta_poc_s1_minus1/*[i]*/, tvb, pinfo, &bit_offset, H265_UE_V);
2268 			proto_tree_add_bits_item(tree, hf_h265_used_by_curr_pic_s1_flag/*[i]*/, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2269 			bit_offset++;
2270 		}
2271 	}
2272 	return bit_offset;
2273 }
2274 
2275 /* E.2.3 Sub-layer HRD parameters syntax */
2276 static int
dissect_h265_sub_layer_hrd_parameters(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo _U_,gint bit_offset,guint subLayerId _U_,guint32 CpbCnt,gboolean sub_pic_hrd_params_present_flag)2277 dissect_h265_sub_layer_hrd_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset, guint subLayerId _U_, guint32 CpbCnt, gboolean sub_pic_hrd_params_present_flag)
2278 {
2279 	/*The variable CpbCnt is set equal to cpb_cnt_minus1[ subLayerId ] + 1.*/
2280 	guint i;
2281 	for (i = 0; i < CpbCnt; i++) {
2282 		dissect_h265_exp_golomb_code(tree, hf_h265_bit_rate_value_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
2283 		dissect_h265_exp_golomb_code(tree, hf_h265_cpb_size_value_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
2284 		if (sub_pic_hrd_params_present_flag) {
2285 			dissect_h265_exp_golomb_code(tree, hf_h265_cpb_size_du_value_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
2286 			dissect_h265_exp_golomb_code(tree, hf_h265_bit_rate_du_value_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
2287 		}
2288 		proto_tree_add_bits_item(tree, hf_h265_cbr_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2289 		bit_offset++;
2290 	}
2291 	return bit_offset;
2292 }
2293 
2294 /* E.2.2 HRD parameters syntax */
2295 static int
dissect_h265_hrd_parameters(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo _U_,gint bit_offset,gboolean commonInfPresentFlag,guint maxNumSubLayersMinus1)2296 dissect_h265_hrd_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo _U_, gint bit_offset, gboolean commonInfPresentFlag, guint maxNumSubLayersMinus1)
2297 {
2298 	guint subLayerId;
2299 	gboolean nal_hrd_parameters_present_flag = 0, vcl_hrd_parameters_present_flag = 0, sub_pic_hrd_params_present_flag = 0;
2300 	gboolean fixed_pic_rate_general_flag[32] = { 0 };
2301 	gboolean fixed_pic_rate_within_cvs_flag[32] = { 0 };
2302 	gboolean low_delay_hrd_flag[32] = { 0 };
2303 	guint32 cpb_cnt_minus1[32] = { 0 };
2304 
2305 	if (commonInfPresentFlag) {
2306 
2307 		nal_hrd_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
2308 		proto_tree_add_bits_item(tree, hf_h265_nal_hrd_parameters_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2309 		bit_offset++;
2310 
2311 		vcl_hrd_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
2312 		proto_tree_add_bits_item(tree, hf_h265_vcl_hrd_parameters_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2313 		bit_offset++;
2314 
2315 		if (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag) {
2316 
2317 			sub_pic_hrd_params_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
2318 			proto_tree_add_bits_item(tree, hf_h265_sub_pic_hrd_params_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2319 			bit_offset++;
2320 
2321 			if (sub_pic_hrd_params_present_flag) {
2322 				proto_tree_add_bits_item(tree, hf_h265_tick_divisor_minus2, tvb, bit_offset, 8, ENC_BIG_ENDIAN);
2323 				bit_offset = bit_offset + 8;
2324 
2325 				proto_tree_add_bits_item(tree, hf_h265_du_cpb_removal_delay_increment_length_minus1, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
2326 				bit_offset = bit_offset + 5;
2327 
2328 				proto_tree_add_bits_item(tree, hf_h265_sub_pic_cpb_params_in_pic_timing_sei_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2329 				bit_offset++;
2330 
2331 				proto_tree_add_bits_item(tree, hf_h265_dpb_output_delay_du_length_minus1, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
2332 				bit_offset = bit_offset + 5;
2333 
2334 			}
2335 
2336 			proto_tree_add_bits_item(tree, hf_h265_bit_rate_scale, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
2337 			bit_offset = bit_offset + 4;
2338 
2339 			proto_tree_add_bits_item(tree, hf_h265_cpb_size_scale, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
2340 			bit_offset = bit_offset + 4;
2341 
2342 			if (sub_pic_hrd_params_present_flag) {
2343 
2344 				proto_tree_add_bits_item(tree, hf_h265_cpb_size_du_scale, tvb, bit_offset, 4, ENC_BIG_ENDIAN);
2345 				bit_offset = bit_offset + 4;
2346 			}
2347 
2348 			proto_tree_add_bits_item(tree, hf_h265_initial_cpb_removal_delay_length_minus1, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
2349 			bit_offset = bit_offset + 5;
2350 
2351 			proto_tree_add_bits_item(tree, hf_h265_au_cpb_removal_delay_length_minus1, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
2352 			bit_offset = bit_offset + 5;
2353 
2354 			proto_tree_add_bits_item(tree, hf_h265_dpb_output_delay_length_minus1, tvb, bit_offset, 5, ENC_BIG_ENDIAN);
2355 			bit_offset = bit_offset + 5;
2356 		}
2357 	}
2358 	for (subLayerId = 0; subLayerId <= maxNumSubLayersMinus1; subLayerId++) {
2359 
2360 		fixed_pic_rate_general_flag[subLayerId] = tvb_get_bits8(tvb, bit_offset, 1);
2361 		proto_tree_add_bits_item(tree, hf_h265_fixed_pic_rate_general_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2362 		bit_offset++;
2363 
2364 		if (!fixed_pic_rate_general_flag[subLayerId]) {
2365 
2366 			fixed_pic_rate_within_cvs_flag[subLayerId] = tvb_get_bits8(tvb, bit_offset, 1);
2367 			proto_tree_add_bits_item(tree, hf_h265_fixed_pic_rate_within_cvs_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2368 			bit_offset++;
2369 		}
2370 		if (fixed_pic_rate_within_cvs_flag[subLayerId]) {
2371 
2372 			dissect_h265_exp_golomb_code(tree, hf_h265_elemental_duration_in_tc_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
2373 		}
2374 		else {
2375 
2376 			low_delay_hrd_flag[subLayerId] = tvb_get_bits8(tvb, bit_offset, 1);
2377 			proto_tree_add_bits_item(tree, hf_h265_low_delay_hrd_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2378 			bit_offset++;
2379 		}
2380 		if (!low_delay_hrd_flag[subLayerId]) {
2381 
2382 			cpb_cnt_minus1[subLayerId] = dissect_h265_exp_golomb_code(tree, hf_h265_cpb_cnt_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
2383 		}
2384 		if (nal_hrd_parameters_present_flag) {
2385 
2386 			dissect_h265_sub_layer_hrd_parameters(tree, tvb, pinfo, bit_offset, subLayerId, cpb_cnt_minus1[subLayerId] + 1, sub_pic_hrd_params_present_flag);
2387 		}
2388 		if (vcl_hrd_parameters_present_flag) {
2389 
2390 			dissect_h265_sub_layer_hrd_parameters(tree, tvb, pinfo, bit_offset, subLayerId, cpb_cnt_minus1[subLayerId] + 1, sub_pic_hrd_params_present_flag);
2391 		}
2392 	}
2393 	return bit_offset;
2394 }
2395 
2396 #define EXTENDED_SAR 255
2397 
2398 /* Table E-2 - Meaning of video_format */
2399 static const value_string h265_video_format_vals[] = {
2400 	{ 0,   "Component" },
2401 	{ 1,   "PAL" },
2402 	{ 2,   "NTSC" },
2403 	{ 3,   "SECAM" },
2404 	{ 4,   "MAC" },
2405 	{ 5,   "Unspecified video format" },
2406 	{ 0, NULL }
2407 };
2408 
2409 /* E.2.1 VUI parameters syntax */
2410 static int
dissect_h265_vui_parameters(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,gint bit_offset,guint8 sps_max_sub_layers_minus1)2411 dissect_h265_vui_parameters(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, gint bit_offset, guint8 sps_max_sub_layers_minus1)
2412 {
2413 	guint8 aspect_ratio_info_present_flag, aspect_ratio_idc, overscan_info_present_flag;
2414 	guint8 video_signal_type_present_flag, colour_description_present_flag, chroma_loc_info_present_flag;
2415 	guint8 bitstream_restriction_flag, default_display_window_flag, vui_timing_info_present_flag;
2416 	guint8 vui_poc_proportional_to_timing_flag, vui_hrd_parameters_present_flag;
2417 
2418 	/* vui_parameters( ) {
2419 	* aspect_ratio_info_present_flag 0 u(1)
2420 	*/
2421 	aspect_ratio_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
2422 	proto_tree_add_bits_item(tree, hf_h265_aspect_ratio_info_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2423 	bit_offset++;
2424 
2425 	if (aspect_ratio_info_present_flag) {
2426 		/* aspect_ratio_idc 0 u(8) */
2427 		aspect_ratio_idc = tvb_get_bits8(tvb, bit_offset, 8);
2428 		proto_tree_add_bits_item(tree, hf_h265_aspect_ratio_idc, tvb, bit_offset, 8, ENC_BIG_ENDIAN);
2429 		bit_offset = bit_offset + 8;
2430 
2431 		if (aspect_ratio_idc == EXTENDED_SAR) {
2432 			/* sar_width 0 u(16) */
2433 			proto_tree_add_bits_item(tree, hf_h265_sar_width, tvb, bit_offset, 16, ENC_BIG_ENDIAN);
2434 			bit_offset = bit_offset + 16;
2435 
2436 			/* sar_height 0 u(16) */
2437 			proto_tree_add_bits_item(tree, hf_h265_sar_height, tvb, bit_offset, 16, ENC_BIG_ENDIAN);
2438 			bit_offset = bit_offset + 16;
2439 		}
2440 	}
2441 	/* overscan_info_present_flag 0 u(1) */
2442 	overscan_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
2443 	proto_tree_add_bits_item(tree, hf_h265_overscan_info_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2444 	bit_offset++;
2445 
2446 	if (overscan_info_present_flag) {
2447 		/* overscan_appropriate_flag 0 u(1) */
2448 		proto_tree_add_bits_item(tree, hf_h265_overscan_appropriate_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2449 		bit_offset++;
2450 	}
2451 
2452 	/* video_signal_type_present_flag 0 u(1) */
2453 	video_signal_type_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
2454 	proto_tree_add_bits_item(tree, hf_h265_video_signal_type_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2455 	bit_offset++;
2456 
2457 	if (video_signal_type_present_flag) {
2458 		/* video_format 0 u(3) > */
2459 		proto_tree_add_bits_item(tree, hf_h265_video_format, tvb, bit_offset, 3, ENC_BIG_ENDIAN);
2460 		bit_offset = bit_offset + 3;
2461 
2462 		/* video_full_range_flag 0 u(1)*/
2463 		proto_tree_add_bits_item(tree, hf_h265_video_full_range_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2464 		bit_offset++;
2465 
2466 		/* colour_description_present_flag 0 u(1) */
2467 		colour_description_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
2468 		proto_tree_add_bits_item(tree, hf_h265_colour_description_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2469 		bit_offset++;
2470 
2471 		if (colour_description_present_flag) {
2472 			/* colour_primaries 0 u(8) */
2473 			proto_tree_add_bits_item(tree, hf_h265_colour_primaries, tvb, bit_offset, 8, ENC_BIG_ENDIAN);
2474 			bit_offset = bit_offset + 8;
2475 
2476 			/* transfer_characteristics 0 u(8) */
2477 			proto_tree_add_bits_item(tree, hf_h265_transfer_characteristics, tvb, bit_offset, 8, ENC_BIG_ENDIAN);
2478 			bit_offset = bit_offset + 8;
2479 
2480 			/* matrix_coefficients 0 u(8)*/
2481 			proto_tree_add_bits_item(tree, hf_h265_matrix_coeffs, tvb, bit_offset, 8, ENC_BIG_ENDIAN);
2482 			bit_offset = bit_offset + 8;
2483 		}
2484 	}
2485 
2486 	/* chroma_loc_info_present_flag 0 u(1) */
2487 	chroma_loc_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
2488 	proto_tree_add_bits_item(tree, hf_h265_chroma_loc_info_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2489 	bit_offset++;
2490 
2491 	if (chroma_loc_info_present_flag) {
2492 		/* chroma_sample_loc_type_top_field 0 ue(v) */
2493 		dissect_h265_exp_golomb_code(tree, hf_h265_chroma_sample_loc_type_top_field, tvb, pinfo, &bit_offset, H265_UE_V);
2494 
2495 		/* chroma_sample_loc_type_bottom_field 0 ue(v) */
2496 		dissect_h265_exp_golomb_code(tree, hf_h265_chroma_sample_loc_type_bottom_field, tvb, pinfo, &bit_offset, H265_UE_V);
2497 	}
2498 
2499 	/* neutral_chroma_indication_flag u(1) */
2500 	proto_tree_add_bits_item(tree, hf_h265_neutral_chroma_indication_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2501 	bit_offset++;
2502 
2503 	/* field_seq_flag u(1) */
2504 	proto_tree_add_bits_item(tree, hf_h265_field_seq_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2505 	bit_offset++;
2506 
2507 	/* frame_field_info_present_flag u(1) */
2508 	proto_tree_add_bits_item(tree, hf_h265_frame_field_info_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2509 	bit_offset++;
2510 
2511 	/* default_display_window_flag u(1) */
2512 	default_display_window_flag = tvb_get_bits8(tvb, bit_offset, 1);
2513 	proto_tree_add_bits_item(tree, hf_h265_default_display_window_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2514 	bit_offset++;
2515 
2516 	if (default_display_window_flag) {
2517 		/* def_disp_win_left_offset ue(v) */
2518 		dissect_h265_exp_golomb_code(tree, hf_h265_def_disp_win_left_offset, tvb, pinfo, &bit_offset, H265_UE_V);
2519 
2520 		/* def_disp_win_right_offset ue(v) */
2521 		dissect_h265_exp_golomb_code(tree, hf_h265_def_disp_win_right_offset, tvb, pinfo, &bit_offset, H265_UE_V);
2522 
2523 		/* def_disp_win_top_offset ue(v) */
2524 		dissect_h265_exp_golomb_code(tree, hf_h265_def_disp_win_top_offset, tvb, pinfo, &bit_offset, H265_UE_V);
2525 
2526 		/* def_disp_win_bottom_offset ue(v) */
2527 		dissect_h265_exp_golomb_code(tree, hf_h265_def_disp_win_bottom_offset, tvb, pinfo, &bit_offset, H265_UE_V);
2528 	}
2529 
2530 	/* vui_timing_info_present_flag u(1) */
2531 	vui_timing_info_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
2532 	proto_tree_add_bits_item(tree, hf_h265_vui_timing_info_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2533 	bit_offset++;
2534 
2535 	if (vui_timing_info_present_flag) {
2536 		/* vui_num_units_in_tick u(32) */
2537 		proto_tree_add_bits_item(tree, hf_h265_vui_num_units_in_tick, tvb, bit_offset, 32, ENC_BIG_ENDIAN);
2538 		bit_offset = bit_offset + 32;
2539 
2540 		/* vui_time_scale u(32) */
2541 		proto_tree_add_bits_item(tree, hf_h265_vui_time_scale, tvb, bit_offset, 32, ENC_BIG_ENDIAN);
2542 		bit_offset = bit_offset + 32;
2543 
2544 		/* vui_poc_proportional_to_timing_flag u(1) */
2545 		vui_poc_proportional_to_timing_flag = tvb_get_bits8(tvb, bit_offset, 1);
2546 		proto_tree_add_bits_item(tree, hf_h265_vui_poc_proportional_to_timing_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2547 		bit_offset++;
2548 
2549 		if (vui_poc_proportional_to_timing_flag) {
2550 			/* vui_num_ticks_poc_diff_one_minus1 ue(v) */
2551 			dissect_h265_exp_golomb_code(tree, hf_h265_vui_num_ticks_poc_diff_one_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
2552 		}
2553 
2554 		/* vui_hrd_parameters_present_flag u(1) */
2555 		vui_hrd_parameters_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
2556 		proto_tree_add_bits_item(tree, hf_h265_vui_hrd_parameters_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2557 		bit_offset++;
2558 
2559 		if (vui_hrd_parameters_present_flag) {
2560 			dissect_h265_hrd_parameters(tree, tvb, pinfo, bit_offset, 1, sps_max_sub_layers_minus1);
2561 		}
2562 	}
2563 
2564 	/* bitstream_restriction_flag 0 u(1) */
2565 	bitstream_restriction_flag = tvb_get_bits8(tvb, bit_offset, 1);
2566 	proto_tree_add_bits_item(tree, hf_h265_bitstream_restriction_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2567 	bit_offset++;
2568 
2569 	if (bitstream_restriction_flag) {
2570 		/* tiles_fixed_structure_flag u(1) */
2571 		proto_tree_add_bits_item(tree, hf_h265_tiles_fixed_structure_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2572 		bit_offset++;
2573 
2574 		/* motion_vectors_over_pic_boundaries_flag u(1) */
2575 		proto_tree_add_bits_item(tree, hf_h265_motion_vectors_over_pic_boundaries_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2576 		bit_offset++;
2577 
2578 		/* restricted_ref_pic_lists_flag u(1) */
2579 		proto_tree_add_bits_item(tree, hf_h265_restricted_ref_pic_lists_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2580 		bit_offset++;
2581 
2582 		/* min_spatial_segmentation_idc ue(v) */
2583 		dissect_h265_exp_golomb_code(tree, hf_h265_min_spatial_segmentation_idc, tvb, pinfo, &bit_offset, H265_UE_V);
2584 
2585 		/* max_bytes_per_pic_denom ue(v) */
2586 		dissect_h265_exp_golomb_code(tree, hf_h265_max_bytes_per_pic_denom, tvb, pinfo, &bit_offset, H265_UE_V);
2587 
2588 		/* max_bits_per_min_cu_denom ue(v) */
2589 		dissect_h265_exp_golomb_code(tree, hf_h265_max_bits_per_min_cu_denom, tvb, pinfo, &bit_offset, H265_UE_V);
2590 
2591 		/* log2_max_mv_length_horizontal ue(v) */
2592 		dissect_h265_exp_golomb_code(tree, hf_h265_log2_max_mv_length_horizontal, tvb, pinfo, &bit_offset, H265_UE_V);
2593 
2594 		/* log2_max_mv_length_vertical ue(v) */
2595 		dissect_h265_exp_golomb_code(tree, hf_h265_log2_max_mv_length_vertical, tvb, pinfo, &bit_offset, H265_UE_V);
2596 	}
2597 
2598 	return bit_offset;
2599 }
2600 
2601 /* 7.3.2.2.2 Sequence parameter set range extension syntax */
2602 static int
dissect_h265_sps_range_extension(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo _U_,gint bit_offset)2603 dissect_h265_sps_range_extension(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo _U_, gint bit_offset)
2604 {
2605 	proto_tree_add_bits_item(tree, hf_h265_transform_skip_rotation_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2606 	bit_offset++;
2607 
2608 	proto_tree_add_bits_item(tree, hf_h265_transform_skip_context_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2609 	bit_offset++;
2610 
2611 	proto_tree_add_bits_item(tree, hf_h265_implicit_rdpcm_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2612 	bit_offset++;
2613 
2614 	proto_tree_add_bits_item(tree, hf_h265_explicit_rdpcm_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2615 	bit_offset++;
2616 
2617 	proto_tree_add_bits_item(tree, hf_h265_extended_precision_processing_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2618 	bit_offset++;
2619 
2620 	proto_tree_add_bits_item(tree, hf_h265_intra_smoothing_disabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2621 	bit_offset++;
2622 
2623 	proto_tree_add_bits_item(tree, hf_h265_high_precision_offsets_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2624 	bit_offset++;
2625 
2626 	proto_tree_add_bits_item(tree, hf_h265_persistent_rice_adaptation_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2627 	bit_offset++;
2628 
2629 	proto_tree_add_bits_item(tree, hf_h265_cabac_bypass_alignment_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2630 	bit_offset++;
2631 
2632 	return bit_offset;
2633 }
2634 
2635 /* F.7.3.2.2.4 Sequence parameter set multilayer extension syntax */
2636 static int
dissect_h265_sps_multilayer_extension(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,gint bit_offset)2637 dissect_h265_sps_multilayer_extension(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint bit_offset)
2638 {
2639 	proto_tree *sps_multilayer_extension_tree;
2640 	sps_multilayer_extension_tree = proto_tree_add_subtree(tree, tvb, bit_offset >> 3, 1, ett_h265_sps_multilayer_extension, NULL, "sps_multilayer_extension");
2641 	proto_tree_add_expert(sps_multilayer_extension_tree, pinfo, &ei_h265_undecoded, tvb, bit_offset >> 3, -1);
2642 	return bit_offset;
2643 }
2644 
2645 /* I.7.3.2.2.5 Sequence parameter set 3D extension syntax */
2646 static int
dissect_h265_sps_3d_extension(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,gint bit_offset)2647 dissect_h265_sps_3d_extension(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint bit_offset)
2648 {
2649 	proto_tree *sps_3d_extension_tree;
2650 	sps_3d_extension_tree = proto_tree_add_subtree(tree, tvb, bit_offset >> 3, 1, ett_h265_sps_3d_extension, NULL, "sps_3d_extension");
2651 	proto_tree_add_expert(sps_3d_extension_tree, pinfo, &ei_h265_undecoded, tvb, bit_offset >> 3, -1);
2652 	return bit_offset;
2653 }
2654 
2655 /* 7.3.2.2.3 Sequence parameter set screen content coding extension syntax */
2656 static int
dissect_h265_sps_scc_extension(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo _U_,gint bit_offset,guint chroma_format_idc,guint bit_depth_luma_minus8,guint bit_depth_chroma_minus8)2657 dissect_h265_sps_scc_extension(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo _U_, gint bit_offset, guint chroma_format_idc, guint bit_depth_luma_minus8, guint bit_depth_chroma_minus8)
2658 {
2659 	guint BitDepthY = 8 + bit_depth_luma_minus8, BitDepthC = 8 + bit_depth_chroma_minus8;
2660 	gboolean palette_mode_enabled_flag, sps_palette_predictor_initializers_present_flag;
2661 	guint32 sps_num_palette_predictor_initializers_minus1;
2662 	guint32 numComps, comp, i;
2663 
2664 	proto_tree_add_bits_item(tree, hf_h265_sps_curr_pic_ref_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2665 	bit_offset++;
2666 
2667 	palette_mode_enabled_flag = tvb_get_bits8(tvb, bit_offset, 1);
2668 	proto_tree_add_bits_item(tree, hf_h265_palette_mode_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2669 	bit_offset++;
2670 
2671 	if (palette_mode_enabled_flag) {
2672 		dissect_h265_exp_golomb_code(tree, hf_h265_palette_max_size, tvb, pinfo, &bit_offset, H265_UE_V);
2673 		dissect_h265_exp_golomb_code(tree, hf_h265_delta_palette_max_predictor_size, tvb, pinfo, &bit_offset, H265_UE_V);
2674 
2675 		sps_palette_predictor_initializers_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
2676 		proto_tree_add_bits_item(tree, hf_h265_sps_palette_predictor_initializers_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2677 		bit_offset++;
2678 		if (sps_palette_predictor_initializers_present_flag) {
2679 			sps_num_palette_predictor_initializers_minus1 = dissect_h265_exp_golomb_code(tree, hf_h265_sps_num_palette_predictor_initializers_minus1, tvb, pinfo, &bit_offset, H265_UE_V);
2680 			numComps = (chroma_format_idc == 0) ? 1 : 3;
2681 			for (comp = 0; comp < numComps; comp++)
2682 				for (i = 0; i <= sps_num_palette_predictor_initializers_minus1; i++) {
2683 					if (comp == 0) {
2684 						proto_tree_add_bits_item(tree, hf_h265_sps_palette_predictor_initializer/*[comp][i]*/, tvb, bit_offset, (1 << BitDepthY) - 1, ENC_BIG_ENDIAN);
2685 						bit_offset = bit_offset + (1 << BitDepthY) - 1;
2686 					}
2687 					else {
2688 						proto_tree_add_bits_item(tree, hf_h265_sps_palette_predictor_initializer/*[comp][i]*/, tvb, bit_offset, (1 << BitDepthC) - 1, ENC_BIG_ENDIAN);
2689 						bit_offset = bit_offset + (1 << BitDepthC) - 1;
2690 					}
2691 				}
2692 		}
2693 	}
2694 
2695 	proto_tree_add_bits_item(tree, hf_h265_motion_vector_resolution_control_idc, tvb, bit_offset, 2, ENC_BIG_ENDIAN);
2696 	bit_offset = bit_offset + 2;
2697 
2698 	proto_tree_add_bits_item(tree, hf_h265_intra_boundary_filtering_disabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2699 	bit_offset++;
2700 
2701 	return bit_offset;
2702 }
2703 
2704 /* 7.3.2.3.2 Picture parameter set range extension syntax */
2705 static int
dissect_h265_pps_range_extension(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo _U_,gint bit_offset,guint transform_skip_enabled_flag)2706 dissect_h265_pps_range_extension(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo _U_, gint bit_offset, guint transform_skip_enabled_flag)
2707 {
2708 	gboolean chroma_qp_offset_list_enabled_flag;
2709         gint offset;
2710 	guint i, chroma_qp_offset_list_len_minus1;
2711 
2712 	if (transform_skip_enabled_flag) {
2713 		offset = bit_offset >> 3;
2714 
2715 		dissect_h265_exp_golomb_code(tree, hf_h265_log2_max_transform_skip_block_size_minus2, tvb, pinfo, &offset, H265_UE_V);
2716 
2717 		bit_offset = offset << 3;
2718 	}
2719 
2720 	proto_tree_add_bits_item(tree, hf_h265_cross_component_prediction_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2721 	bit_offset++;
2722 
2723 	chroma_qp_offset_list_enabled_flag = tvb_get_bits8(tvb, bit_offset, 1);
2724 	proto_tree_add_bits_item(tree, hf_h265_chroma_qp_offset_list_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2725 	bit_offset++;
2726 
2727 	offset = bit_offset >> 3;
2728 
2729 	if (chroma_qp_offset_list_enabled_flag) {
2730 		dissect_h265_exp_golomb_code(tree, hf_h265_diff_cu_chroma_qp_offset_depth, tvb, pinfo, &offset, H265_UE_V);
2731 		chroma_qp_offset_list_len_minus1 = dissect_h265_exp_golomb_code(tree, hf_h265_chroma_qp_offset_list_len_minus1, tvb, pinfo, &offset, H265_UE_V);
2732 
2733 		for (i = 0; i <= chroma_qp_offset_list_len_minus1; i++) {
2734 			dissect_h265_exp_golomb_code(tree, hf_h265_cb_qp_offset_list/*[i]*/, tvb, pinfo, &offset, H265_SE_V);
2735 			dissect_h265_exp_golomb_code(tree, hf_h265_cr_qp_offset_list/*[i]*/, tvb, pinfo, &offset, H265_SE_V);
2736 		}
2737 	}
2738 
2739 	dissect_h265_exp_golomb_code(tree, hf_h265_log2_sao_offset_scale_luma, tvb, pinfo, &offset, H265_UE_V);
2740 	dissect_h265_exp_golomb_code(tree, hf_h265_log2_sao_offset_scale_chroma, tvb, pinfo, &offset, H265_UE_V);
2741 
2742 	bit_offset = offset << 3;
2743 
2744 	return bit_offset;
2745 }
2746 
2747 /* 7.3.2.3.3 Picture parameter set screen content coding extension syntax */
2748 static int
dissect_h265_pps_scc_extension(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo _U_,gint bit_offset)2749 dissect_h265_pps_scc_extension(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo _U_, gint bit_offset)
2750 {
2751 	gint offset;
2752 	guint pps_num_palette_predictor_initializers, numComps, comp, i;
2753 	gboolean residual_adaptive_colour_transform_enabled_flag, pps_palette_predictor_initializers_present_flag,
2754 		monochrome_palette_flag;
2755 	guint32 luma_bit_depth_entry_minus8 = 0, chroma_bit_depth_entry_minus8 = 0;
2756 
2757 	proto_tree_add_bits_item(tree, hf_h265_pps_curr_pic_ref_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2758 	bit_offset++;
2759 
2760 	residual_adaptive_colour_transform_enabled_flag = tvb_get_bits8(tvb, bit_offset, 1);
2761 	proto_tree_add_bits_item(tree, hf_h265_residual_adaptive_colour_transform_enabled_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2762 	bit_offset++;
2763 
2764 	if (residual_adaptive_colour_transform_enabled_flag) {
2765 		proto_tree_add_bits_item(tree, hf_h265_pps_slice_act_qp_offsets_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2766 		bit_offset++;
2767 
2768 		offset = bit_offset >> 3;
2769 
2770 		dissect_h265_exp_golomb_code(tree, hf_h265_pps_act_y_qp_offset_plus5, tvb, pinfo, &offset, H265_SE_V);
2771 		dissect_h265_exp_golomb_code(tree, hf_h265_pps_act_cb_qp_offset_plus5, tvb, pinfo, &offset, H265_SE_V);
2772 		dissect_h265_exp_golomb_code(tree, hf_h265_pps_act_cr_qp_offset_plus3, tvb, pinfo, &offset, H265_SE_V);
2773 
2774 		bit_offset = offset << 3;
2775 	}
2776 
2777 	pps_palette_predictor_initializers_present_flag = tvb_get_bits8(tvb, bit_offset, 1);
2778 	proto_tree_add_bits_item(tree, hf_h265_pps_palette_predictor_initializers_present_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2779 	bit_offset++;
2780 
2781 	if (pps_palette_predictor_initializers_present_flag) {
2782 		offset = bit_offset >> 3;
2783 
2784 		pps_num_palette_predictor_initializers = dissect_h265_exp_golomb_code(tree, hf_h265_pps_num_palette_predictor_initializers, tvb, pinfo, &offset, H265_SE_V);
2785 		if (pps_num_palette_predictor_initializers > 0) {
2786 
2787 			bit_offset = offset << 3;
2788 
2789 			monochrome_palette_flag = tvb_get_bits8(tvb, bit_offset, 1);
2790 			proto_tree_add_bits_item(tree, hf_h265_monochrome_palette_flag, tvb, bit_offset, 1, ENC_BIG_ENDIAN);
2791 			bit_offset++;
2792 
2793 			offset = bit_offset >> 3;
2794 
2795 			luma_bit_depth_entry_minus8 = dissect_h265_exp_golomb_code(tree, hf_h265_luma_bit_depth_entry_minus8, tvb, pinfo, &offset, H265_UE_V);
2796 
2797 			if (!monochrome_palette_flag) {
2798 				chroma_bit_depth_entry_minus8 = dissect_h265_exp_golomb_code(tree, hf_h265_chroma_bit_depth_entry_minus8, tvb, pinfo, &offset, H265_UE_V);
2799 			}
2800 
2801 			numComps = monochrome_palette_flag ? 1 : 3;
2802 			for (comp = 0; comp < numComps; comp++)
2803 				for (i = 0; i < pps_num_palette_predictor_initializers; i++) {
2804 					bit_offset = offset << 3;
2805 
2806 					if (comp == 0) {
2807 						proto_tree_add_bits_item(tree, hf_h265_pps_palette_predictor_initializer/*[comp][i]*/, tvb, bit_offset, luma_bit_depth_entry_minus8 + 8, ENC_BIG_ENDIAN);
2808 						bit_offset = bit_offset + luma_bit_depth_entry_minus8 + 8;
2809 					}
2810 					else {
2811 						proto_tree_add_bits_item(tree, hf_h265_pps_palette_predictor_initializer/*[comp][i]*/, tvb, bit_offset, chroma_bit_depth_entry_minus8 + 8, ENC_BIG_ENDIAN);
2812 						bit_offset = bit_offset + chroma_bit_depth_entry_minus8 + 8;
2813 					}
2814 
2815 					offset = bit_offset >> 3;
2816 				}
2817 		}
2818 
2819 		bit_offset = offset << 3;
2820 	}
2821 
2822 	return bit_offset;
2823 }
2824 
2825 /* F.7.3.2.3.4 Picture parameter set multilayer extension syntax */
2826 static int
dissect_h265_pps_multilayer_extension(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,gint bit_offset)2827 dissect_h265_pps_multilayer_extension(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint bit_offset)
2828 {
2829 	proto_tree *pps_multilayer_extension_tree;
2830 	pps_multilayer_extension_tree = proto_tree_add_subtree(tree, tvb, bit_offset >> 3, 1, ett_h265_pps_multilayer_extension, NULL, "pps_multilayer_extension");
2831 	proto_tree_add_expert(pps_multilayer_extension_tree, pinfo, &ei_h265_undecoded, tvb, bit_offset >> 3, -1);
2832 
2833 	return bit_offset;
2834 }
2835 
2836 /* I.7.3.2.3.7 Picture parameter set 3D extension syntax */
2837 static int
dissect_h265_pps_3d_extension(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,gint bit_offset)2838 dissect_h265_pps_3d_extension(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, gint bit_offset)
2839 {
2840 	proto_tree *pps_3d_extension_tree;
2841 	pps_3d_extension_tree = proto_tree_add_subtree(tree, tvb, bit_offset >> 3, 1, ett_h265_pps_3d_extension, NULL, "pps_3d_extension");
2842 	proto_tree_add_expert(pps_3d_extension_tree, pinfo, &ei_h265_undecoded, tvb, bit_offset >> 3, -1);
2843 
2844 	return bit_offset;
2845 }
2846 
2847 
2848 static tvbuff_t *
dissect_h265_unescap_nal_unit(tvbuff_t * tvb,packet_info * pinfo,int offset)2849 dissect_h265_unescap_nal_unit(tvbuff_t *tvb, packet_info *pinfo, int offset)
2850 {
2851 	tvbuff_t *tvb_rbsp;
2852 	int       length = tvb_reported_length_remaining(tvb, offset);
2853 	int       NumBytesInRBSP = 0;
2854 	int       i;
2855 	guint8    *buff;
2856 
2857 	buff = (gchar *)wmem_alloc(pinfo->pool, length);
2858 	for (i = 0; i < length; i++) {
2859 		if ((i + 2 < length) && (tvb_get_ntoh24(tvb, offset) == 0x000003)) {
2860 			buff[NumBytesInRBSP++] = tvb_get_guint8(tvb, offset);
2861 			buff[NumBytesInRBSP++] = tvb_get_guint8(tvb, offset + 1);
2862 			i += 2;
2863 			offset += 3;
2864 		}
2865 		else {
2866 			buff[NumBytesInRBSP++] = tvb_get_guint8(tvb, offset);
2867 			offset++;
2868 		}
2869 	}
2870 
2871 	tvb_rbsp = tvb_new_child_real_data(tvb, buff, NumBytesInRBSP, NumBytesInRBSP);
2872 	add_new_data_source(pinfo, tvb_rbsp, "Unescaped RSP Data");
2873 
2874 	return tvb_rbsp;
2875 }
2876 
2877 void
dissect_h265_format_specific_parameter(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo)2878 dissect_h265_format_specific_parameter(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo)
2879 {
2880 	int         offset = 0;
2881 	proto_item *item;
2882 	proto_tree *h265_nal_tree;
2883 	guint8     type;
2884 	tvbuff_t   *rbsp_tvb;
2885 
2886 	type = tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN) >> 9 & 0x3F;
2887 
2888 	/* Unescape NAL unit */
2889 	rbsp_tvb = dissect_h265_unescap_nal_unit(tvb, pinfo, offset + 2);
2890 
2891 	switch (type) {
2892 	case 32: /* VPS_NUT - Video parameter set */
2893 		item = proto_tree_add_item(tree, hf_h265_sdp_parameter_sprop_vps, tvb, offset, -1, ENC_NA);
2894 		h265_nal_tree = proto_item_add_subtree(item, ett_h265_sprop_parameters);
2895 		dissect_h265_video_parameter_set_rbsp(h265_nal_tree, rbsp_tvb, pinfo, 0);
2896 		break;
2897 	case 33: /* SPS_NUT - Sequence parameter set*/
2898 		item = proto_tree_add_item(tree, hf_h265_sdp_parameter_sprop_sps, tvb, offset, -1, ENC_NA);
2899 		h265_nal_tree = proto_item_add_subtree(item, ett_h265_sprop_parameters);
2900 		dissect_h265_seq_parameter_set_rbsp(h265_nal_tree, rbsp_tvb, pinfo, 0);
2901 		break;
2902 	case 34: /* PPS_NUT - Picture parameter set */
2903 		item = proto_tree_add_item(tree, hf_h265_sdp_parameter_sprop_pps, tvb, offset, -1, ENC_NA);
2904 		h265_nal_tree = proto_item_add_subtree(item, ett_h265_sprop_parameters);
2905 		dissect_h265_pic_parameter_set_rbsp(h265_nal_tree, rbsp_tvb, pinfo, 0);
2906 		break;
2907 	default:
2908 		proto_tree_add_expert(tree, pinfo, &ei_h265_format_specific_parameter, tvb, offset, -1);
2909 		break;
2910 	}
2911 }
2912 
2913 /* Code to actually dissect the packets */
2914 static int
dissect_h265(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data _U_)2915 dissect_h265(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
2916 {
2917 	int         offset = 0;
2918 	proto_item *item;
2919 	proto_tree *h265_tree, *h265_nal_tree, *stream_tree, *fua_tree;
2920 	guint8     type;
2921 	tvbuff_t   *rbsp_tvb;
2922 
2923 
2924 	/* Make entries in Protocol column and Info column on summary display */
2925 	col_set_str(pinfo->cinfo, COL_PROTOCOL, "H265");
2926 
2927 	guint16 h265_nalu_hextet = tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN);
2928 	type = h265_nalu_hextet >> 9 & 0x3F;
2929 
2930 	col_append_fstr(pinfo->cinfo, COL_INFO, " %s",
2931 		val_to_str(type, h265_type_summary_values, "Unknown Type (%u)"));
2932 
2933 	/* if (tree) */ {
2934 		item = proto_tree_add_item(tree, proto_h265, tvb, 0, -1, ENC_NA);
2935 		h265_tree = proto_item_add_subtree(item, ett_h265);
2936 
2937 		/* if the type is 49, it would be draw another title */
2938 		if (type == 49)
2939 			h265_nal_tree = proto_tree_add_subtree(h265_tree, tvb, offset, 1, ett_h265_nal, NULL, "FU identifier");
2940 		else
2941 			h265_nal_tree = proto_tree_add_subtree(h265_tree, tvb, offset, 1, ett_h265_nal, NULL, "NAL unit header or first byte of the payload");
2942 
2943 		/*   decode the HEVC payload header according to section 4:
2944 		0                   1
2945 		0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
2946 		+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
2947 		|F|   Type    |  LayerId  | TID |
2948 		+-------------+-----------------+
2949 		Forbidden zero (F): 1 bit
2950 		NAL unit type (Type): 6 bits
2951 		NUH layer ID (LayerId): 6 bits
2952 		NUH temporal ID plus 1 (TID): 3 bits
2953 		*/
2954 
2955 		proto_tree_add_item(h265_nal_tree, hf_h265_nal_f_bit, tvb, offset, 2, ENC_BIG_ENDIAN);
2956 		proto_tree_add_item(h265_nal_tree, hf_h265_type, tvb, offset, 2, ENC_BIG_ENDIAN);
2957 		proto_tree_add_item(h265_nal_tree, hf_h265_nuh_layer_id, tvb, offset, 2, ENC_BIG_ENDIAN);
2958 		proto_tree_add_item(h265_nal_tree, hf_h265_nuh_temporal_id_plus1, tvb, offset, 2, ENC_BIG_ENDIAN);
2959 
2960 		offset++;
2961 		offset++;
2962 		if (type == 48) { // Aggregation Packets (APs)
2963 
2964 		}
2965 		else if (type == 49) { // Fragmentation Units
2966 			fua_tree = proto_tree_add_subtree(h265_tree, tvb, offset, 1, ett_h265_fu, NULL, "FU Header");
2967 			proto_tree_add_item(fua_tree, hf_h265_start_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
2968 			proto_tree_add_item(fua_tree, hf_h265_end_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
2969 			proto_tree_add_item(fua_tree, hf_h265_nal_unit_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2970 			if ((tvb_get_guint8(tvb, offset) & 0x80) == 0x80) {
2971 				type = tvb_get_guint8(tvb, offset) & 0x1f;
2972 				col_append_fstr(pinfo->cinfo, COL_INFO, " Start:%s",
2973 					val_to_str(type, h265_type_summary_values, "Unknown Type (%u)"));
2974 				offset++;
2975 			}
2976 			else
2977 			{
2978 				if ((tvb_get_guint8(tvb, offset) & 0x40) == 0x40) {
2979 					col_append_fstr(pinfo->cinfo, COL_INFO, " End");
2980 				}
2981 				return offset;
2982 			}
2983 		}
2984 		else if (type == 50) { //PACI Packets
2985 
2986 		}
2987 
2988 		/* Unescape NAL unit */
2989 		rbsp_tvb = dissect_h265_unescap_nal_unit(tvb, pinfo, offset);
2990 
2991 		stream_tree = proto_tree_add_subtree(h265_tree, tvb, offset, -1, ett_h265_stream, NULL, "H265 NAL Unit Payload");
2992 		switch (type) {
2993 		case 0:
2994 		case 1: /* Coded slice segment of a non-TSA, non-STSA trailing picture */
2995 		case 2:
2996 		case 3: /*  Coded slice segment of a TSA picture */
2997 		case 4:
2998 		case 5: /* Coded slice segment of an STSA picture */
2999 		case 6:
3000 		case 7: /* Coded slice segment of a RADL picture */
3001 		case 8:
3002 		case 9: /* Coded slice segment of a RASL picture */
3003 			dissect_h265_slice_segment_layer_rbsp(stream_tree, rbsp_tvb, pinfo, 0, type);
3004 			break;
3005 		case 10:
3006 		case 12:
3007 		case 14: /* Reserved non-IRAP SLNR VCL NAL unit types */
3008 		case 11:
3009 		case 13:
3010 		case 15: /* Reserved non-IRAP sub-layer reference VCL NAL unit types */
3011 			break;
3012 		case 16:
3013 		case 17:
3014 		case 18: /* Coded slice segment of a BLA picture */
3015 		case 19:
3016 		case 20:  /* Coded slice segment of an IDR picture */
3017 		case 21: /* CRA_NUT - Coded slice segment of a CRA picture */
3018 			dissect_h265_slice_segment_layer_rbsp(stream_tree, rbsp_tvb, pinfo, 0, type);
3019 			break;
3020 		//case 22..31
3021 		case 32 : /* VPS_NUT - Video parameter set */
3022 			dissect_h265_video_parameter_set_rbsp(stream_tree, rbsp_tvb, pinfo, 0);
3023 			break;
3024 		case 33: /* SPS_NUT - Sequence parameter set*/
3025 			dissect_h265_seq_parameter_set_rbsp(stream_tree, rbsp_tvb, pinfo, 0);
3026 			break;
3027 		case 34: /* PPS_NUT - Picture parameter set */
3028 			dissect_h265_pic_parameter_set_rbsp(stream_tree, rbsp_tvb, pinfo, 0);
3029 			break;
3030 		case 35:  /*AUD_NUT - Access unit delimiter*/
3031 			dissect_h265_access_unit_delimiter_rbsp(stream_tree, rbsp_tvb, pinfo, 0);
3032 			break;
3033 		case 36:  /*EOS_NUT - End of sequence*/
3034 			dissect_h265_end_of_seq_rbsp(stream_tree, rbsp_tvb, pinfo, 0);
3035 			break;
3036 		case 37: /*EOB_NUT - End of bitstream*/
3037 			dissect_h265_end_of_bitstream_rbsp(stream_tree, rbsp_tvb, pinfo, 0);
3038 			break;
3039 		case 38:  /*FD_NUT - Filler data*/
3040 			dissect_h265_filler_data_rbsp(stream_tree, rbsp_tvb, pinfo, 0);
3041 			break;
3042 		case 39:  /*PREFIX_SEI_NUT - Supplemental enhancement information*/
3043 		case 40:  /*SUFFIX_SEI_NUT - Supplemental enhancement information*/
3044 			dissect_h265_sei_rbsp(stream_tree, rbsp_tvb, pinfo, 0, type);
3045 			break;
3046 
3047 		case 49:       /* FU - Fragmentation Units */
3048 			break;
3049 		case 50:       /* PACI - PACI Packets */
3050 			break;
3051 		}
3052 	} /* if (tree) */
3053 	return tvb_captured_length(tvb);
3054 }
3055 
3056 void
proto_register_h265(void)3057 proto_register_h265(void)
3058 {
3059 	module_t *h265_module;
3060 	expert_module_t* expert_h265;
3061 
3062 	/* Setup list of header fields  See Section 1.6.1 for details*/
3063 	static hf_register_info hf[] = {
3064 		{ &hf_h265_nal_f_bit,
3065 		{ "F bit", "h265.f",
3066 		FT_BOOLEAN, 16, TFS(&h265_f_bit_vals), 0x8000,
3067 		NULL, HFILL }
3068 		},
3069 		{ &hf_h265_type,
3070 		{ "Type", "h265.nal_unit_type",
3071 		FT_UINT16, BASE_DEC, VALS(h265_type_values), 0x7E00,
3072 		NULL, HFILL }
3073 		},
3074 		{ &hf_h265_nuh_layer_id,
3075 		{ "LayerId", "h265.layer_id",
3076 		FT_UINT16, BASE_DEC, NULL, 0x01F8,
3077 		NULL, HFILL }
3078 		},
3079 		{ &hf_h265_nuh_temporal_id_plus1,
3080 		{ "TID", "h265.temporal_id",
3081 		FT_UINT16, BASE_DEC, NULL, 0x0007,
3082 		NULL, HFILL }
3083 		},
3084 		{ &hf_h265_start_bit,
3085 		{ "Start bit", "h265.start.bit",
3086 		FT_BOOLEAN, 8, TFS(&h265_start_bit_vals), 0x80,
3087 		NULL, HFILL }
3088 		},
3089 		{ &hf_h265_end_bit,
3090 		{ "End bit", "h265.end.bit",
3091 		FT_BOOLEAN, 8, TFS(&h265_end_bit_vals), 0x40,
3092 		NULL, HFILL }
3093 		},
3094 		{ &hf_h265_nal_unit_type,
3095 		{ "Nal_unit_type", "h265.nal_unit_type",
3096 		FT_UINT8, BASE_DEC, VALS(h265_type_values), 0x1f,
3097 		NULL, HFILL }
3098 		},
3099 		{ &hf_h265_rbsp_stop_bit,
3100 		{ "rbsp_stop_bit", "h265.rbsp_stop_bit",
3101 		FT_UINT8, BASE_DEC, NULL, 0x0,
3102 		NULL, HFILL }
3103 		},
3104 		{ &hf_h265_rbsp_trailing_bits,
3105 		{ "rbsp_trailing_bits", "h265.rbsp_trailing_bits",
3106 		FT_UINT8, BASE_DEC, NULL, 0x0,
3107 		NULL, HFILL }
3108 		},
3109 		/*VPS*/
3110 		{ &hf_h265_vps_video_parameter_set_id,
3111 		{ "vps_video_parameter_set_id", "h265.vps_video_parameter_set_id",
3112 		FT_UINT8, BASE_DEC, NULL, 0x0,
3113 		NULL, HFILL }
3114 		},
3115 		{ &hf_h265_vps_base_layer_internal_flag,
3116 		{ "vps_base_layer_internal_flag", "h265.vps_base_layer_internal_flag",
3117 		FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3118 		NULL, HFILL }
3119 		},
3120 		{ &hf_h265_vps_base_layer_available_flag,
3121 		{ "vps_base_layer_available_flag", "h265.vps_base_layer_available_flag",
3122 		FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3123 		NULL, HFILL }
3124 		},
3125 		{ &hf_h265_vps_max_layers_minus1,
3126 		{ "vps_max_layers_minus1", "h265.vps_max_layers_minus1",
3127 		FT_UINT8, BASE_DEC, NULL, 0x0,
3128 		NULL, HFILL }
3129 		},
3130 		{ &hf_h265_vps_max_sub_layers_minus1,
3131 		{ "vps_max_sub_layers_minus1", "h265.vps_max_sub_layers_minus1",
3132 		FT_UINT8, BASE_DEC, NULL, 0x0,
3133 		NULL, HFILL }
3134 		},
3135 		{ &hf_h265_vps_temporal_id_nesting_flag,
3136 		{ "vps_temporal_id_nesting_flag", "h265.vps_temporal_id_nesting_flag",
3137 		FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3138 		NULL, HFILL }
3139 		},
3140 		{ &hf_h265_vps_reserved_0xffff_16bits,
3141 		{ "vps_reserved_0xffff_16bits", "h265.vps_reserved_0xffff_16bits",
3142 		FT_UINT16, BASE_HEX, NULL, 0x0,
3143 		NULL, HFILL }
3144 		},
3145 		/* profile, level and tier*/
3146 		{ &hf_h265_general_profile_space,
3147 		{ "general_profile_space", "h265.general_profile_space",
3148 		FT_UINT8, BASE_DEC, NULL, 0xC0,
3149 		NULL, HFILL }
3150 		},
3151 		{ &hf_h265_general_tier_flag,
3152 		{ "general_tier_flag", "h265.general_tier_flag",
3153 		FT_BOOLEAN, 8, NULL, 0x20,
3154 		NULL, HFILL }
3155 		},
3156 		{ &hf_h265_general_profile_idc,
3157 		{ "general_profile_idc", "h265.general_profile_idc",
3158 		FT_UINT8, BASE_DEC, VALS(h265_profile_idc_values), 0x1F,
3159 		NULL, HFILL }
3160 		},
3161 		{ &hf_h265_general_profile_compatibility_flags,
3162 		{ "general_profile_compatibility_flags", "h265.general_profile_compatibility_flags",
3163 		FT_UINT32, BASE_HEX, NULL, 0xFFFFFFFF,
3164 		NULL, HFILL }
3165 		},
3166 		{ &hf_h265_general_progressive_source_flag,
3167 		{ "general_progressive_source_flag", "h265.general_progressive_source_flag",
3168 		FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3169 		NULL, HFILL }
3170 		},
3171 		{ &hf_h265_general_interlaced_source_flag,
3172 		{ "general_interlaced_source_flag", "h265.general_interlaced_source_flag",
3173 		FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3174 		NULL, HFILL }
3175 		},
3176 		{ &hf_h265_general_non_packed_constraint_flag,
3177 		{ "general_non_packed_constraint_flag", "h265.general_non_packed_constraint_flag",
3178 			FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3179 		NULL, HFILL }
3180 		},
3181 		{ &hf_h265_general_frame_only_constraint_flag,
3182 		{ "general_frame_only_constraint_flag", "h265.general_frame_only_constraint_flag",
3183 			FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3184 			NULL, HFILL }
3185 		},
3186 		{ &hf_h265_general_max_12bit_constraint_flag,
3187 		{ "general_max_12bit_constraint_flag", "h265.general_max_12bit_constraint_flag",
3188 			FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3189 			NULL, HFILL }
3190 		},
3191 		{ &hf_h265_general_max_10bit_constraint_flag,
3192 		{ "general_max_10bit_constraint_flag", "h265.general_max_10bit_constraint_flag",
3193 			FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3194 			NULL, HFILL }
3195 		},
3196 		{ &hf_h265_general_max_8bit_constraint_flag,
3197 		{ "general_max_8bit_constraint_flag", "h265.general_max_8bit_constraint_flag",
3198 			FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3199 			NULL, HFILL }
3200 		},
3201 		{ &hf_h265_general_max_422chroma_constraint_flag,
3202 		{ "general_max_422chroma_constraint_flag", "h265.general_max_422chroma_constraint_flag",
3203 			FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3204 			NULL, HFILL }
3205 		},
3206 		{ &hf_h265_general_max_420chroma_constraint_flag,
3207 		{ "general_max_420chroma_constraint_flag", "h265.general_max_420chroma_constraint_flag",
3208 			FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3209 			NULL, HFILL }
3210 		},
3211 		{ &hf_h265_general_max_monochrome_constraint_flag,
3212 		{ "general_max_monochrome_constraint_flag", "h265.general_max_monochrome_constraint_flag",
3213 			FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3214 			NULL, HFILL }
3215 		},
3216 		{ &hf_h265_general_intra_constraint_flag,
3217 		{ "general_intra_constraint_flag", "h265.general_intra_constraint_flag",
3218 			FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3219 			NULL, HFILL }
3220 		},
3221 		{ &hf_h265_general_one_picture_only_constraint_flag,
3222 		{ "general_one_picture_only_constraint_flag", "h265.general_one_picture_only_constraint_flag",
3223 			FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3224 			NULL, HFILL }
3225 		},
3226 		{ &hf_h265_general_lower_bit_rate_constraint_flag,
3227 		{ "general_lower_bit_rate_constraint_flag", "h265.general_lower_bit_rate_constraint_flag",
3228 			FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3229 			NULL, HFILL }
3230 		},
3231 		{ &hf_h265_general_max_14bit_constraint_flag,
3232 		{ "general_max_14bit_constraint_flag", "h265.general_max_14bit_constraint_flag",
3233 			FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3234 			NULL, HFILL }
3235 		},
3236 		{ &hf_h265_general_reserved_zero_33bits,
3237 		{ "general_reserved_zero_33bits", "h265.general_reserved_zero_33bits",
3238 			FT_UINT40, BASE_DEC, NULL, 0x0,
3239 			NULL, HFILL }
3240 		},
3241 		{ &hf_h265_general_reserved_zero_34bits,
3242 		{ "general_reserved_zero_34bits", "h265.general_reserved_zero_34bits",
3243 			FT_UINT40, BASE_DEC, NULL, 0x0,
3244 			NULL, HFILL }
3245 		},
3246 		{ &hf_h265_general_reserved_zero_7bits,
3247 		{ "general_reserved_zero_7bits", "h265.general_reserved_zero_7bits",
3248 			FT_UINT8, BASE_DEC, NULL, 0x0,
3249 			NULL, HFILL }
3250 		},
3251 		{ &hf_h265_general_reserved_zero_35bits,
3252 		{ "general_reserved_zero_35bits", "h265.general_reserved_zero_35bits",
3253 			FT_UINT40, BASE_DEC, NULL, 0x0,
3254 			NULL, HFILL }
3255 		},
3256 		{ &hf_h265_general_reserved_zero_43bits,
3257 		{ "general_reserved_zero_43bits", "h265.general_reserved_zero_43bits",
3258 			FT_UINT48, BASE_DEC, NULL, 0x0,
3259 			NULL, HFILL }
3260 		},
3261 		{ &hf_h265_general_inbld_flag,
3262 		{ "general_inbld_flag", "h265.general_inbld_flag",
3263 			FT_BOOLEAN, BASE_DEC, NULL, 0x0,
3264 			NULL, HFILL }
3265 		},
3266 		{ &hf_h265_general_reserved_zero_bit,
3267 		{ "general_reserved_zero_bit", "h265.general_reserved_zero_bit",
3268 			FT_UINT8, BASE_DEC, NULL, 0x0,
3269 			NULL, HFILL }
3270 		},
3271 		{ &hf_h265_general_level_idc,
3272 		{ "general_level_idc", "h265.general_level_idc",
3273 			FT_UINT8, BASE_DEC, NULL, 0xFF,
3274 			NULL, HFILL }
3275 		},
3276 		{ &hf_h265_sub_layer_profile_present_flag/*[i]*/,
3277 		{ "sub_layer_profile_present_flag", "h265.sub_layer_profile_present_flag",
3278 			FT_UINT8, BASE_DEC, NULL, 0x0,
3279 			NULL, HFILL }
3280 		},
3281 		{ &hf_h265_sub_layer_level_present_flag/*[i]*/,
3282 		{ "sub_layer_level_present_flag", "h265.sub_layer_level_present_flag",
3283 			FT_UINT8, BASE_DEC, NULL, 0x0,
3284 			NULL, HFILL }
3285 		},
3286 		{ &hf_h265_reserved_zero_2bits/*[i]*/,
3287 		{ "reserved_zero_2bits", "h265.reserved_zero_2bits",
3288 			FT_UINT8, BASE_DEC, NULL, 0x0,
3289 			NULL, HFILL }
3290 		},
3291 		{ &hf_h265_sub_layer_profile_space/*[i]*/,
3292 		{ "sub_layer_profile_space", "h265.sub_layer_profile_space",
3293 			FT_UINT8, BASE_DEC, NULL, 0x03,
3294 			NULL, HFILL }
3295 		},
3296 		{ &hf_h265_sub_layer_tier_flag/*[i]*/,
3297 		{ "sub_layer_tier_flag", "h265.sub_layer_tier_flag",
3298 			FT_UINT8, BASE_DEC, NULL, 0x04,
3299 			NULL, HFILL }
3300 		},
3301 		{ &hf_h265_sub_layer_profile_idc/*[i]*/,
3302 		{ "sub_layer_profile_idc", "h265.sub_layer_profile_idc",
3303 			FT_UINT8, BASE_DEC, NULL, 0xF8,
3304 			NULL, HFILL }
3305 		},
3306 		{ &hf_h265_sub_layer_profile_compatibility_flag/*[i][j]*/,
3307 		{ "sub_layer_profile_compatibility_flag", "h265.sub_layer_profile_compatibility_flag",
3308 			FT_UINT32, BASE_DEC, NULL, 0xFF,
3309 			NULL, HFILL }
3310 		},
3311 		{ &hf_h265_sub_layer_progressive_source_flag/*[i]*/,
3312 		{ "sub_layer_progressive_source_flag", "h265.sub_layer_progressive_source_flag",
3313 			FT_UINT8, BASE_DEC, NULL, 0x0,
3314 			NULL, HFILL }
3315 		},
3316 
3317 		{ &hf_h265_sub_layer_interlaced_source_flag/*[i]*/,
3318 		{ "sub_layer_interlaced_source_flag", "h265.sub_layer_interlaced_source_flag",
3319 			FT_UINT8, BASE_DEC, NULL, 0x0,
3320 			NULL, HFILL }
3321 		},
3322 		{ &hf_h265_sub_layer_non_packed_constraint_flag/*[i]*/,
3323 		{ "sub_layer_non_packed_constraint_flag", "h265.sub_layer_non_packed_constraint_flag",
3324 			FT_UINT8, BASE_DEC, NULL, 0x0,
3325 			NULL, HFILL }
3326 		},
3327 		{ &hf_h265_sub_layer_frame_only_constraint_flag/*[i]*/,
3328 		{ "sub_layer_frame_only_constraint_flag", "h265.sub_layer_frame_only_constraint_flag",
3329 			FT_UINT8, BASE_DEC, NULL, 0x0,
3330 			NULL, HFILL }
3331 		},
3332 		{ &hf_h265_sub_layer_max_12bit_constraint_flag/*[i]*/,
3333 		{ "sub_layer_max_12bit_constraint_flag", "h265.sub_layer_max_12bit_constraint_flag",
3334 			FT_UINT8, BASE_DEC, NULL, 0x0,
3335 			NULL, HFILL }
3336 		},
3337 		{ &hf_h265_sub_layer_max_10bit_constraint_flag/*[i]*/,
3338 		{ "sub_layer_max_10bit_constraint_flag", "h265.sub_layer_max_10bit_constraint_flag",
3339 			FT_UINT8, BASE_DEC, NULL, 0x0,
3340 			NULL, HFILL }
3341 		},
3342 		{ &hf_h265_sub_layer_max_8bit_constraint_flag/*[i]*/,
3343 		{ "sub_layer_max_8bit_constraint_flag", "h265.sub_layer_max_8bit_constraint_flag",
3344 			FT_UINT8, BASE_DEC, NULL, 0x0,
3345 			NULL, HFILL }
3346 		},
3347 		{ &hf_h265_sub_layer_max_422chroma_constraint_flag/*[i]*/,
3348 		{ "sub_layer_max_422chroma_constraint_flag", "h265.sub_layer_max_422chroma_constraint_flag",
3349 			FT_UINT8, BASE_DEC, NULL, 0x0,
3350 			NULL, HFILL }
3351 		},
3352 		{ &hf_h265_sub_layer_max_420chroma_constraint_flag/*[i]*/,
3353 		{ "sub_layer_max_420chroma_constraint_flag", "h265.sub_layer_max_420chroma_constraint_flag",
3354 			FT_UINT8, BASE_DEC, NULL, 0x0,
3355 			NULL, HFILL }
3356 		},
3357 		{ &hf_h265_sub_layer_max_monochrome_constraint_flag/*[i]*/,
3358 		{ "sub_layer_max_monochrome_constraint_flag", "h265.sub_layer_max_monochrome_constraint_flag",
3359 			FT_UINT8, BASE_DEC, NULL, 0x0,
3360 			NULL, HFILL }
3361 		},
3362 		{ &hf_h265_sub_layer_intra_constraint_flag/*[i]*/,
3363 		{ "sub_layer_intra_constraint_flag", "h265.sub_layer_intra_constraint_flag",
3364 			FT_UINT8, BASE_DEC, NULL, 0x0,
3365 			NULL, HFILL }
3366 		},
3367 		{ &hf_h265_sub_layer_one_picture_only_constraint_flag/*[i]*/,
3368 		{ "sub_layer_one_picture_only_constraint_flag", "h265.sub_layer_one_picture_only_constraint_flag",
3369 			FT_UINT8, BASE_DEC, NULL, 0x0,
3370 			NULL, HFILL }
3371 		},
3372 		{ &hf_h265_sub_layer_lower_bit_rate_constraint_flag/*[i]*/,
3373 		{ "sub_layer_lower_bit_rate_constraint_flag", "h265.sub_layer_lower_bit_rate_constraint_flag",
3374 			FT_UINT8, BASE_DEC, NULL, 0x0,
3375 			NULL, HFILL }
3376 		},
3377 		{ &hf_h265_sub_layer_max_14bit_constraint_flag/*[i]*/,
3378 		{ "sub_layer_max_14bit_constraint_flag", "h265.sub_layer_max_14bit_constraint_flag",
3379 			FT_UINT8, BASE_DEC, NULL, 0x0,
3380 			NULL, HFILL }
3381 		},
3382 		{ &hf_h265_sub_layer_reserved_zero_33bits/*[i]*/,
3383 		{ "sub_layer_reserved_zero_33bits", "h265.sub_layer_reserved_zero_33bits",
3384 			FT_UINT8, BASE_DEC, NULL, 0x0,
3385 			NULL, HFILL }
3386 		},
3387 		{ &hf_h265_sub_layer_reserved_zero_34bits/*[i]*/,
3388 		{ "sub_layer_reserved_zero_34bits", "h265.sub_layer_reserved_zero_34bits",
3389 			FT_UINT8, BASE_DEC, NULL, 0x0,
3390 			NULL, HFILL }
3391 		},
3392 		{ &hf_h265_sub_layer_reserved_zero_7bits/*[i]*/,
3393 		{ "sub_layer_reserved_zero_7bits", "h265.sub_layer_reserved_zero_7bits",
3394 			FT_UINT8, BASE_DEC, NULL, 0x0,
3395 			NULL, HFILL }
3396 		},
3397 		{ &hf_h265_sub_layer_reserved_zero_35bits/*[i]*/,
3398 		{ "sub_layer_reserved_zero_35bits", "h265.sub_layer_reserved_zero_35bits",
3399 			FT_UINT8, BASE_DEC, NULL, 0x0,
3400 			NULL, HFILL }
3401 		},
3402 		{ &hf_h265_sub_layer_reserved_zero_43bits/*[i]*/,
3403 		{ "sub_layer_reserved_zero_43bits", "h265.sub_layer_reserved_zero_43bits",
3404 			FT_UINT8, BASE_DEC, NULL, 0x0,
3405 			NULL, HFILL }
3406 		},
3407 		{ &hf_h265_sub_layer_inbld_flag/*[i]*/,
3408 		{ "sub_layer_inbld_flag", "h265.sub_layer_inbld_flag",
3409 			FT_UINT8, BASE_DEC, NULL, 0x0,
3410 			NULL, HFILL }
3411 		},
3412 		{ &hf_h265_sub_layer_reserved_zero_bit/*[i]*/,
3413 		{ "sub_layer_reserved_zero_bit", "h265.sub_layer_reserved_zero_bit",
3414 			FT_UINT8, BASE_DEC, NULL, 0x0,
3415 			NULL, HFILL }
3416 		},
3417 		{ &hf_h265_sub_layer_level_idc/*[i]*/,
3418 		{ "sub_layer_level_idc", "h265.sub_layer_level_idc",
3419 			FT_UINT8, BASE_DEC, NULL, 0xFF,
3420 			NULL, HFILL }
3421 		},
3422 		{ &hf_h265_vps_sub_layer_ordering_info_present_flag,
3423 		{ "vps_sub_layer_ordering_info_present_flag", "h265.vps_sub_layer_ordering_info_present_flag",
3424 			FT_UINT8, BASE_DEC, NULL, 0x01,
3425 			NULL, HFILL }
3426 		},
3427 		{ &hf_h265_vps_max_dec_pic_buffering_minus1/*[i]*/,
3428 		{ "vps_max_dec_pic_buffering_minus1", "h265.vps_max_dec_pic_buffering_minus1",
3429 			FT_UINT32, BASE_DEC, NULL, 0x0,
3430 			NULL, HFILL }
3431 		},
3432 		{ &hf_h265_vps_max_num_reorder_pics/*[i]*/,
3433 		{ "vps_max_num_reorder_pics", "h265.vps_max_num_reorder_pics",
3434 			FT_UINT32, BASE_DEC, NULL, 0x0,
3435 			NULL, HFILL }
3436 		},
3437 		{ &hf_h265_vps_max_latency_increase_plus1/*[i]*/,
3438 		{ "vps_max_latency_increase_plus1", "h265.vps_max_latency_increase_plus1",
3439 			FT_UINT32, BASE_DEC, NULL, 0x0,
3440 			NULL, HFILL }
3441 		},
3442 		{ &hf_h265_vps_max_layer_id,
3443 		{ "vps_max_layer_id", "h265.vps_max_layer_id",
3444 			FT_UINT8, BASE_DEC, NULL, 0x0,
3445 			NULL, HFILL }
3446 		},
3447 		{ &hf_h265_vps_num_layer_sets_minus1,
3448 		{ "vps_num_layer_sets_minus1", "h265.vps_num_layer_sets_minus1",
3449 			FT_UINT32, BASE_DEC, NULL, 0x0,
3450 			NULL, HFILL }
3451 		},
3452 		{ &hf_h265_layer_id_included_flag/*[i][j]*/,
3453 		{ "layer_id_included_flag", "h265.layer_id_included_flag",
3454 			FT_UINT8, BASE_DEC, NULL, 0x0,
3455 			NULL, HFILL }
3456 		},
3457 		{ &hf_h265_vps_timing_info_present_flag,
3458 		{ "vps_timing_info_present_flag", "h265.vps_timing_info_present_flag",
3459 			FT_UINT8, BASE_DEC, NULL, 0x0,
3460 			NULL, HFILL }
3461 		},
3462 		{ &hf_h265_vps_num_units_in_tick,
3463 		{ "vps_num_units_in_tick", "h265.vps_num_units_in_tick",
3464 			FT_UINT8, BASE_DEC, NULL, 0x0,
3465 			NULL, HFILL }
3466 		},
3467 		{ &hf_h265_vps_time_scale,
3468 		{ "vps_time_scale", "h265.vps_time_scale",
3469 			FT_UINT8, BASE_DEC, NULL, 0x0,
3470 			NULL, HFILL }
3471 		},
3472 		{ &hf_h265_vps_poc_proportional_to_timing_flag,
3473 		{ "vps_poc_proportional_to_timing_flag", "h265.vps_poc_proportional_to_timing_flag",
3474 			FT_UINT8, BASE_DEC, NULL, 0x0,
3475 			NULL, HFILL }
3476 		},
3477 		{ &hf_h265_vps_num_ticks_poc_diff_one_minus1,
3478 		{ "vps_num_ticks_poc_diff_one_minus1", "h265.vps_num_ticks_poc_diff_one_minus1",
3479 			FT_UINT32, BASE_DEC, NULL, 0x0,
3480 			NULL, HFILL }
3481 		},
3482 		{ &hf_h265_vps_num_hrd_parameters,
3483 		{ "vps_num_hrd_parameters", "h265.vps_num_hrd_parameters",
3484 			FT_UINT32, BASE_DEC, NULL, 0x0,
3485 			NULL, HFILL }
3486 		},
3487 		{ &hf_h265_hrd_layer_set_idx/*[i]*/,
3488 		{ "hrd_layer_set_idx", "h265.hrd_layer_set_idx",
3489 			FT_UINT8, BASE_DEC, NULL, 0x0,
3490 			NULL, HFILL }
3491 		},
3492 		{ &hf_h265_cprms_present_flag/*[i]*/,
3493 		{ "cprms_present_flag", "h265.cprms_present_flag",
3494 			FT_UINT8, BASE_DEC, NULL, 0x0,
3495 			NULL, HFILL }
3496 		},
3497 		{ &hf_h265_vps_extension_flag,
3498 		{ "vps_extension_flag", "h265.vps_extension_flag",
3499 			FT_UINT8, BASE_DEC, NULL, 0x0,
3500 			NULL, HFILL }
3501 		},
3502 		{ &hf_h265_vps_extension_data_flag,
3503 		{ "vps_extension_data_flag", "h265.vps_extension_data_flag",
3504 			FT_UINT8, BASE_DEC, NULL, 0x0,
3505 			NULL, HFILL }
3506 		},
3507 			/*hrd_parameters*/
3508 		{ &hf_h265_nal_hrd_parameters_present_flag,
3509 		{ "nal_hrd_parameters_present_flag", "h265.nal_hrd_parameters_present_flag",
3510 			FT_UINT8, BASE_DEC, NULL, 0x0,
3511 			NULL, HFILL }
3512 		},
3513 		{ &hf_h265_vcl_hrd_parameters_present_flag,
3514 		{ "vcl_hrd_parameters_present_flag", "h265.vcl_hrd_parameters_present_flag",
3515 			FT_UINT8, BASE_DEC, NULL, 0x0,
3516 			NULL, HFILL }
3517 		},
3518 		{ &hf_h265_sub_pic_hrd_params_present_flag,
3519 		{ "sub_pic_hrd_params_present_flag", "h265.sub_pic_hrd_params_present_flag",
3520 			FT_UINT8, BASE_DEC, NULL, 0x0,
3521 			NULL, HFILL }
3522 		},
3523 		{ &hf_h265_tick_divisor_minus2,
3524 		{ "tick_divisor_minus2", "h265.tick_divisor_minus2",
3525 			FT_UINT8, BASE_DEC, NULL, 0x0,
3526 			NULL, HFILL }
3527 		},
3528 		{ &hf_h265_du_cpb_removal_delay_increment_length_minus1,
3529 		{ "du_cpb_removal_delay_increment_length_minus1", "h265.du_cpb_removal_delay_increment_length_minus1",
3530 			FT_UINT8, BASE_DEC, NULL, 0x0,
3531 			NULL, HFILL }
3532 		},
3533 		{ &hf_h265_sub_pic_cpb_params_in_pic_timing_sei_flag,
3534 		{ "sub_pic_cpb_params_in_pic_timing_sei_flag", "h265.sub_pic_cpb_params_in_pic_timing_sei_flag",
3535 			FT_UINT8, BASE_DEC, NULL, 0x0,
3536 			NULL, HFILL }
3537 		},
3538 		{ &hf_h265_dpb_output_delay_du_length_minus1,
3539 		{ "dpb_output_delay_du_length_minus1", "h265.dpb_output_delay_du_length_minus1",
3540 			FT_UINT8, BASE_DEC, NULL, 0x0,
3541 			NULL, HFILL }
3542 		},
3543 		{ &hf_h265_bit_rate_scale,
3544 		{ "bit_rate_scale", "h265.bit_rate_scale",
3545 			FT_UINT8, BASE_DEC, NULL, 0x0,
3546 			NULL, HFILL }
3547 		},
3548 		{ &hf_h265_cpb_size_scale,
3549 		{ "cpb_size_scale", "h265.cpb_size_scale",
3550 			FT_UINT8, BASE_DEC, NULL, 0x0,
3551 			NULL, HFILL }
3552 		},
3553 		{ &hf_h265_cpb_size_du_scale,
3554 		{ "cpb_size_du_scale", "h265.cpb_size_du_scale",
3555 			FT_UINT8, BASE_DEC, NULL, 0x0,
3556 			NULL, HFILL }
3557 		},
3558 		{ &hf_h265_initial_cpb_removal_delay_length_minus1,
3559 		{ "initial_cpb_removal_delay_length_minus1", "h265.initial_cpb_removal_delay_length_minus1",
3560 			FT_UINT8, BASE_DEC, NULL, 0x0,
3561 			NULL, HFILL }
3562 		},
3563 		{ &hf_h265_au_cpb_removal_delay_length_minus1,
3564 		{ "au_cpb_removal_delay_length_minus1", "h265.au_cpb_removal_delay_length_minus1",
3565 			FT_UINT8, BASE_DEC, NULL, 0x0,
3566 			NULL, HFILL }
3567 		},
3568 		{ &hf_h265_dpb_output_delay_length_minus1,
3569 		{ "dpb_output_delay_length_minus1", "h265.dpb_output_delay_length_minus1",
3570 			FT_UINT8, BASE_DEC, NULL, 0x0,
3571 			NULL, HFILL }
3572 		},
3573 		{ &hf_h265_fixed_pic_rate_general_flag/*[i]*/,
3574 		{ "fixed_pic_rate_general_flag", "h265.fixed_pic_rate_general_flag",
3575 			FT_UINT8, BASE_DEC, NULL, 0x0,
3576 			NULL, HFILL }
3577 		},
3578 		{ &hf_h265_fixed_pic_rate_within_cvs_flag/*[i]*/,
3579 		{ "fixed_pic_rate_within_cvs_flag", "h265.fixed_pic_rate_within_cvs_flag",
3580 			FT_UINT8, BASE_DEC, NULL, 0x0,
3581 			NULL, HFILL }
3582 		},
3583 		{ &hf_h265_elemental_duration_in_tc_minus1/*[i]*/,
3584 		{ "elemental_duration_in_tc_minus1", "h265.elemental_duration_in_tc_minus1",
3585 			FT_UINT32, BASE_DEC, NULL, 0x0,
3586 			NULL, HFILL }
3587 		},
3588 		{ &hf_h265_low_delay_hrd_flag/*[i]*/,
3589 		{ "low_delay_hrd_flag", "h265.low_delay_hrd_flag",
3590 			FT_UINT8, BASE_DEC, NULL, 0x0,
3591 			NULL, HFILL }
3592 		},
3593 		{ &hf_h265_cpb_cnt_minus1/*[i]*/,
3594 		{ "cpb_cnt_minus1", "h265.cpb_cnt_minus1",
3595 			FT_UINT32, BASE_DEC, NULL, 0x0,
3596 			NULL, HFILL }
3597 		},
3598 			/*sub_layer_hrd_parameters*/
3599 		{ &hf_h265_bit_rate_value_minus1/*[i]*/,
3600 		{ "bit_rate_value_minus1", "h265.bit_rate_value_minus1",
3601 			FT_UINT32, BASE_DEC, NULL, 0x0,
3602 			NULL, HFILL }
3603 		},
3604 		{ &hf_h265_cpb_size_value_minus1/*[i]*/,
3605 		{ "cpb_size_value_minus1", "h265.cpb_size_value_minus1",
3606 			FT_UINT32, BASE_DEC, NULL, 0x0,
3607 			NULL, HFILL }
3608 		},
3609 		{ &hf_h265_cpb_size_du_value_minus1/*[i]*/,
3610 		{ "cpb_size_du_value_minus1", "h265.cpb_size_du_value_minus1",
3611 			FT_UINT32, BASE_DEC, NULL, 0x0,
3612 			NULL, HFILL }
3613 		},
3614 		{ &hf_h265_bit_rate_du_value_minus1/*[i]*/,
3615 		{ "bit_rate_du_value_minus1", "h265.bit_rate_du_value_minus1",
3616 			FT_UINT32, BASE_DEC, NULL, 0x0,
3617 			NULL, HFILL }
3618 		},
3619 		{ &hf_h265_cbr_flag/*[i]*/,
3620 		{ "cbr_flag", "h265.cbr_flag",
3621 			FT_UINT8, BASE_DEC, NULL, 0x0,
3622 			NULL, HFILL }
3623 		},
3624 			/*SPS*/
3625 		{ &hf_h265_sps_video_parameter_set_id,
3626 		{ "sps_video_parameter_set_id", "h265.sps_video_parameter_set_id",
3627 			FT_UINT8, BASE_DEC, NULL, 0xF0,
3628 			NULL, HFILL }
3629 		},
3630 		{ &hf_h265_sps_max_sub_layers_minus1,
3631 		{ "sps_max_sub_layers_minus1", "h265.sps_max_sub_layers_minus1",
3632 			FT_UINT8, BASE_DEC, NULL, 0x0E,
3633 			NULL, HFILL }
3634 		},
3635 		{ &hf_h265_sps_temporal_id_nesting_flag,
3636 		{ "sps_temporal_id_nesting_flag", "h265.sps_temporal_id_nesting_flag",
3637 			FT_UINT8, BASE_DEC, NULL, 0x01,
3638 			NULL, HFILL }
3639 		},
3640 		{ &hf_h265_sps_seq_parameter_set_id,
3641 		{ "sps_seq_parameter_set_id", "h265.sps_seq_parameter_set_id",
3642 			FT_UINT32, BASE_DEC, NULL, 0x0,
3643 			NULL, HFILL }
3644 		},
3645 		{ &hf_h265_chroma_format_idc,
3646 		{ "chroma_format_idc", "h265.chroma_format_idc",
3647 			FT_UINT32, BASE_DEC, NULL, 0x0,
3648 			NULL, HFILL }
3649 		},
3650 		{ &hf_h265_separate_colour_plane_flag,
3651 		{ "separate_colour_plane_flag", "h265.separate_colour_plane_flag",
3652 			FT_UINT8, BASE_DEC, NULL, 0x0,
3653 			NULL, HFILL }
3654 		},
3655 		{ &hf_h265_pic_width_in_luma_samples,
3656 		{ "pic_width_in_luma_samples", "h265.pic_width_in_luma_samples",
3657 			FT_UINT32, BASE_DEC, NULL, 0x0,
3658 			NULL, HFILL }
3659 		},
3660 		{ &hf_h265_pic_height_in_luma_samples,
3661 		{ "pic_height_in_luma_samples", "h265.pic_height_in_luma_samples",
3662 			FT_UINT32, BASE_DEC, NULL, 0x0,
3663 			NULL, HFILL }
3664 		},
3665 		{ &hf_h265_conformance_window_flag,
3666 		{ "conformance_window_flag", "h265.conformance_window_flag",
3667 			FT_UINT8, BASE_DEC, NULL, 0x0,
3668 			NULL, HFILL }
3669 		},
3670 		{ &hf_h265_conf_win_left_offset,
3671 		{ "conf_win_left_offset", "h265.conf_win_left_offset",
3672 			FT_UINT32, BASE_DEC, NULL, 0x0,
3673 			NULL, HFILL }
3674 		},
3675 		{ &hf_h265_conf_win_right_offset,
3676 		{ "conf_win_right_offset", "h265.conf_win_right_offset",
3677 			FT_UINT32, BASE_DEC, NULL, 0x0,
3678 			NULL, HFILL }
3679 		},
3680 		{ &hf_h265_conf_win_top_offset,
3681 		{ "conf_win_top_offset", "h265.conf_win_top_offset",
3682 			FT_UINT32, BASE_DEC, NULL, 0x0,
3683 			NULL, HFILL }
3684 		},
3685 		{ &hf_h265_conf_win_bottom_offset,
3686 		{ "conf_win_bottom_offset", "h265.conf_win_bottom_offset",
3687 			FT_UINT32, BASE_DEC, NULL, 0x0,
3688 			NULL, HFILL }
3689 		},
3690 		{ &hf_h265_bit_depth_luma_minus8,
3691 		{ "bit_depth_luma_minus8", "h265.bit_depth_luma_minus8",
3692 			FT_UINT32, BASE_DEC, NULL, 0x0,
3693 			NULL, HFILL }
3694 		},
3695 		{ &hf_h265_bit_depth_chroma_minus8,
3696 		{ "bit_depth_chroma_minus8", "h265.bit_depth_chroma_minus8",
3697 			FT_UINT32, BASE_DEC, NULL, 0x0,
3698 			NULL, HFILL }
3699 		},
3700 		{ &hf_h265_log2_max_pic_order_cnt_lsb_minus4,
3701 		{ "log2_max_pic_order_cnt_lsb_minus4", "h265.log2_max_pic_order_cnt_lsb_minus4",
3702 			FT_UINT32, BASE_DEC, NULL, 0x0,
3703 			NULL, HFILL }
3704 		},
3705 		{ &hf_h265_sps_sub_layer_ordering_info_present_flag,
3706 		{ "sps_sub_layer_ordering_info_present_flag", "h265.sps_sub_layer_ordering_info_present_flag",
3707 			FT_UINT8, BASE_DEC, NULL, 0x0,
3708 			NULL, HFILL }
3709 		},
3710 		{ &hf_h265_sps_max_dec_pic_buffering_minus1/*[i]*/,
3711 		{ "sps_max_dec_pic_buffering_minus1", "h265.sps_max_dec_pic_buffering_minus1",
3712 			FT_UINT32, BASE_DEC, NULL, 0x0,
3713 			NULL, HFILL }
3714 		},
3715 		{ &hf_h265_sps_max_num_reorder_pics/*[i]*/,
3716 		{ "sps_max_num_reorder_pics", "h265.sps_max_num_reorder_pics",
3717 			FT_UINT32, BASE_DEC, NULL, 0x0,
3718 			NULL, HFILL }
3719 		},
3720 		{ &hf_h265_sps_max_latency_increase_plus1/*[i]*/,
3721 		{ "sps_max_latency_increase_plus1", "h265.sps_max_latency_increase_plus1",
3722 			FT_UINT32, BASE_DEC, NULL, 0x0,
3723 			NULL, HFILL }
3724 		},
3725 		{ &hf_h265_log2_min_luma_coding_block_size_minus3,
3726 		{ "log2_min_luma_coding_block_size_minus3", "h265.log2_min_luma_coding_block_size_minus3",
3727 			FT_UINT32, BASE_DEC, NULL, 0x0,
3728 			NULL, HFILL }
3729 		},
3730 		{ &hf_h265_log2_diff_max_min_luma_coding_block_size,
3731 		{ "log2_diff_max_min_luma_coding_block_size", "h265.log2_diff_max_min_luma_coding_block_size",
3732 			FT_UINT32, BASE_DEC, NULL, 0x0,
3733 			NULL, HFILL }
3734 		},
3735 		{ &hf_h265_log2_min_luma_transform_block_size_minus2,
3736 		{ "log2_min_luma_transform_block_size_minus2", "h265.log2_min_luma_transform_block_size_minus2",
3737 			FT_UINT32, BASE_DEC, NULL, 0x0,
3738 			NULL, HFILL }
3739 		},
3740 		{ &hf_h265_log2_diff_max_min_luma_transform_block_size,
3741 		{ "log2_diff_max_min_luma_transform_block_size", "h265.log2_diff_max_min_luma_transform_block_size",
3742 			FT_UINT32, BASE_DEC, NULL, 0x0,
3743 			NULL, HFILL }
3744 		},
3745 		{ &hf_h265_max_transform_hierarchy_depth_inter,
3746 		{ "max_transform_hierarchy_depth_inter", "h265.max_transform_hierarchy_depth_inter",
3747 			FT_UINT32, BASE_DEC, NULL, 0x0,
3748 			NULL, HFILL }
3749 		},
3750 		{ &hf_h265_max_transform_hierarchy_depth_intra,
3751 		{ "max_transform_hierarchy_depth_intra", "h265.max_transform_hierarchy_depth_intra",
3752 			FT_UINT32, BASE_DEC, NULL, 0x0,
3753 			NULL, HFILL }
3754 		},
3755 		{ &hf_h265_scaling_list_enabled_flag,
3756 		{ "scaling_list_enabled_flag", "h265.scaling_list_enabled_flag",
3757 			FT_UINT8, BASE_DEC, NULL, 0x0,
3758 			NULL, HFILL }
3759 		},
3760 		{ &hf_h265_sps_scaling_list_data_present_flag,
3761 		{ "sps_scaling_list_data_present_flag", "h265.sps_scaling_list_data_present_flag",
3762 			FT_UINT8, BASE_DEC, NULL, 0x0,
3763 			NULL, HFILL }
3764 		},
3765 		{ &hf_h265_amp_enabled_flag,
3766 		{ "amp_enabled_flag", "h265.amp_enabled_flag",
3767 			FT_UINT8, BASE_DEC, NULL, 0x0,
3768 			NULL, HFILL }
3769 		},
3770 		{ &hf_h265_sample_adaptive_offset_enabled_flag,
3771 		{ "sample_adaptive_offset_enabled_flag", "h265.sample_adaptive_offset_enabled_flag",
3772 			FT_UINT8, BASE_DEC, NULL, 0x0,
3773 			NULL, HFILL }
3774 		},
3775 		{ &hf_h265_pcm_enabled_flag,
3776 		{ "pcm_enabled_flag", "h265.pcm_enabled_flag",
3777 			FT_UINT8, BASE_DEC, NULL, 0x0,
3778 			NULL, HFILL }
3779 		},
3780 		{ &hf_h265_pcm_sample_bit_depth_luma_minus1,
3781 		{ "pcm_sample_bit_depth_luma_minus1", "h265.pcm_sample_bit_depth_luma_minus1",
3782 			FT_UINT8, BASE_DEC, NULL, 0x0,
3783 			NULL, HFILL }
3784 		},
3785 		{ &hf_h265_pcm_sample_bit_depth_chroma_minus1,
3786 		{ "pcm_sample_bit_depth_chroma_minus1", "h265.pcm_sample_bit_depth_chroma_minus1",
3787 			FT_UINT8, BASE_DEC, NULL, 0x0,
3788 			NULL, HFILL }
3789 		},
3790 		{ &hf_h265_log2_min_pcm_luma_coding_block_size_minus3,
3791 		{ "log2_min_pcm_luma_coding_block_size_minus3", "h265.log2_min_pcm_luma_coding_block_size_minus3",
3792 			FT_UINT32, BASE_DEC, NULL, 0x0,
3793 			NULL, HFILL }
3794 		},
3795 		{ &hf_h265_log2_diff_max_min_pcm_luma_coding_block_size,
3796 		{ "log2_diff_max_min_pcm_luma_coding_block_size", "h265.log2_diff_max_min_pcm_luma_coding_block_size",
3797 			FT_UINT32, BASE_DEC, NULL, 0x0,
3798 			NULL, HFILL }
3799 		},
3800 		{ &hf_h265_pcm_loop_filter_disabled_flag,
3801 		{ "pcm_loop_filter_disabled_flag", "h265.pcm_loop_filter_disabled_flag",
3802 			FT_UINT8, BASE_DEC, NULL, 0x0,
3803 			NULL, HFILL }
3804 		},
3805 		{ &hf_h265_num_short_term_ref_pic_sets,
3806 		{ "num_short_term_ref_pic_sets", "h265.num_short_term_ref_pic_sets",
3807 			FT_UINT32, BASE_DEC, NULL, 0x0,
3808 			NULL, HFILL }
3809 		},
3810 		{ &hf_h265_long_term_ref_pics_present_flag,
3811 		{ "long_term_ref_pics_present_flag", "h265.long_term_ref_pics_present_flag",
3812 			FT_UINT8, BASE_DEC, NULL, 0x0,
3813 			NULL, HFILL }
3814 		},
3815 		{ &hf_h265_num_long_term_ref_pics_sps,
3816 		{ "num_long_term_ref_pics_sps", "h265.num_long_term_ref_pics_sps",
3817 			FT_UINT32, BASE_DEC, NULL, 0x0,
3818 			NULL, HFILL }
3819 		},
3820 		{ &hf_h265_lt_ref_pic_poc_lsb_sps/*[i]*/,
3821 		{ "lt_ref_pic_poc_lsb_sps", "h265.lt_ref_pic_poc_lsb_sps",
3822 			FT_UINT32, BASE_DEC, NULL, 0x0,
3823 			NULL, HFILL }
3824 		},
3825 		{ &hf_h265_used_by_curr_pic_lt_sps_flag/*[i]*/,
3826 		{ "used_by_curr_pic_lt_sps_flag", "h265.used_by_curr_pic_lt_sps_flag",
3827 			FT_UINT8, BASE_DEC, NULL, 0x0,
3828 			NULL, HFILL }
3829 		},
3830 		{ &hf_h265_sps_temporal_mvp_enabled_flag,
3831 		{ "sps_temporal_mvp_enabled_flag", "h265.sps_temporal_mvp_enabled_flag",
3832 			FT_UINT8, BASE_DEC, NULL, 0x0,
3833 			NULL, HFILL }
3834 		},
3835 		{ &hf_h265_strong_intra_smoothing_enabled_flag,
3836 		{ "strong_intra_smoothing_enabled_flag", "h265.strong_intra_smoothing_enabled_flag",
3837 			FT_UINT8, BASE_DEC, NULL, 0x0,
3838 			NULL, HFILL }
3839 		},
3840 		{ &hf_h265_vui_parameters_present_flag,
3841 		{ "vui_parameters_present_flag", "h265.vui_parameters_present_flag",
3842 			FT_UINT8, BASE_DEC, NULL, 0x0,
3843 			NULL, HFILL }
3844 		},
3845 		{ &hf_h265_sps_extension_present_flag,
3846 		{ "sps_extension_present_flag", "h265.sps_extension_present_flag",
3847 			FT_UINT8, BASE_DEC, NULL, 0x0,
3848 			NULL, HFILL }
3849 		},
3850 		{ &hf_h265_sps_range_extension_flag,
3851 		{ "sps_range_extension_flag", "h265.sps_range_extension_flag",
3852 			FT_UINT8, BASE_DEC, NULL, 0x0,
3853 			NULL, HFILL }
3854 		},
3855 		{ &hf_h265_sps_multilayer_extension_flag,
3856 		{ "sps_multilayer_extension_flag", "h265.sps_multilayer_extension_flag",
3857 			FT_UINT8, BASE_DEC, NULL, 0x0,
3858 			NULL, HFILL }
3859 		},
3860 		{ &hf_h265_sps_3d_extension_flag,
3861 		{ "sps_3d_extension_flag", "h265.sps_3d_extension_flag",
3862 			FT_UINT8, BASE_DEC, NULL, 0x0,
3863 			NULL, HFILL }
3864 		},
3865 		{ &hf_h265_sps_scc_extension_flag,
3866 		{ "sps_scc_extension_flag", "h265.sps_scc_extension_flag",
3867 			FT_UINT8, BASE_DEC, NULL, 0x0,
3868 			NULL, HFILL }
3869 		},
3870 		{ &hf_h265_sps_extension_4bits,
3871 		{ "sps_extension_4bits", "h265.sps_extension_4bits",
3872 			FT_UINT8, BASE_DEC, NULL, 0x0,
3873 			NULL, HFILL }
3874 		},
3875 		{ &hf_h265_sps_extension_data_flag,
3876 		{ "sps_extension_data_flag", "h265.sps_extension_data_flag",
3877 			FT_UINT8, BASE_DEC, NULL, 0x0,
3878 			NULL, HFILL }
3879 		},
3880 			/* scaling_list_data */
3881 		{ &hf_h265_scaling_list_pred_mode_flag/*[sizeId][matrixId]*/,
3882 		{ "scaling_list_pred_mode_flag", "h265.scaling_list_pred_mode_flag",
3883 			FT_UINT8, BASE_DEC, NULL, 0x0,
3884 			NULL, HFILL }
3885 		},
3886 		{ &hf_h265_scaling_list_pred_matrix_id_delta/*[sizeId][matrixId]*/,
3887 		{ "scaling_list_pred_matrix_id_delta", "h265.scaling_list_pred_matrix_id_delta",
3888 			FT_UINT32, BASE_DEC, NULL, 0x0,
3889 			NULL, HFILL }
3890 		},
3891 		{ &hf_h265_scaling_list_dc_coef_minus8/*[sizeId - 2][matrixId]*/,
3892 		{ "scaling_list_dc_coef_minus8", "h265.scaling_list_dc_coef_minus8",
3893 			FT_INT32, BASE_DEC, NULL, 0x0,
3894 			NULL, HFILL }
3895 		},
3896 		{ &hf_h265_scaling_list_delta_coef,
3897 		{ "scaling_list_delta_coef", "h265.scaling_list_delta_coef",
3898 			FT_INT32, BASE_DEC, NULL, 0x0,
3899 			NULL, HFILL }
3900 		},
3901 			/*st_ref_pic_set*/
3902 		{ &hf_h265_inter_ref_pic_set_prediction_flag,
3903 		{ "inter_ref_pic_set_prediction_flag", "h265.inter_ref_pic_set_prediction_flag",
3904 			FT_UINT8, BASE_DEC, NULL, 0x0,
3905 			NULL, HFILL }
3906 		},
3907 		{ &hf_h265_delta_idx_minus1,
3908 		{ "delta_idx_minus1", "h265.delta_idx_minus1",
3909 			FT_UINT32, BASE_DEC, NULL, 0x0,
3910 			NULL, HFILL }
3911 		},
3912 		{ &hf_h265_delta_rps_sign,
3913 		{ "delta_rps_sign", "h265.delta_rps_sign",
3914 			FT_UINT8, BASE_DEC, NULL, 0x0,
3915 			NULL, HFILL }
3916 		},
3917 		{ &hf_h265_abs_delta_rps_minus1,
3918 		{ "abs_delta_rps_minus1", "h265.abs_delta_rps_minus1",
3919 			FT_UINT32, BASE_DEC, NULL, 0x0,
3920 			NULL, HFILL }
3921 		},
3922 		{ &hf_h265_used_by_curr_pic_flag/*[j]*/,
3923 		{ "used_by_curr_pic_flag", "h265.used_by_curr_pic_flag",
3924 			FT_UINT8, BASE_DEC, NULL, 0x0,
3925 			NULL, HFILL }
3926 		},
3927 		{ &hf_h265_use_delta_flag/*[j]*/,
3928 		{ "use_delta_flag", "h265.use_delta_flag",
3929 			FT_UINT8, BASE_DEC, NULL, 0x0,
3930 			NULL, HFILL }
3931 		},
3932 		{ &hf_h265_num_negative_pics,
3933 		{ "num_negative_pics", "h265.num_negative_pics",
3934 			FT_UINT32, BASE_DEC, NULL, 0x0,
3935 			NULL, HFILL }
3936 		},
3937 		{ &hf_h265_num_positive_pics,
3938 		{ "num_positive_pics", "h265.num_positive_pics",
3939 			FT_UINT32, BASE_DEC, NULL, 0x0,
3940 			NULL, HFILL }
3941 		},
3942 		{ &hf_h265_delta_poc_s0_minus1/*[i]*/,
3943 		{ "delta_poc_s0_minus1", "h265.delta_poc_s0_minus1",
3944 			FT_UINT32, BASE_DEC, NULL, 0x0,
3945 			NULL, HFILL }
3946 		},
3947 		{ &hf_h265_used_by_curr_pic_s0_flag/*[i]*/,
3948 		{ "used_by_curr_pic_s0_flag", "h265.used_by_curr_pic_s0_flag",
3949 			FT_UINT8, BASE_DEC, NULL, 0x0,
3950 			NULL, HFILL }
3951 		},
3952 		{ &hf_h265_delta_poc_s1_minus1/*[i]*/,
3953 		{ "delta_poc_s1_minus1", "h265.delta_poc_s1_minus1",
3954 			FT_UINT32, BASE_DEC, NULL, 0x0,
3955 			NULL, HFILL }
3956 		},
3957 		{ &hf_h265_used_by_curr_pic_s1_flag/*[i]*/,
3958 		{ "used_by_curr_pic_s1_flag", "h265.used_by_curr_pic_s1_flag",
3959 			FT_UINT8, BASE_DEC, NULL, 0x0,
3960 			NULL, HFILL }
3961 		},
3962 			/*vui*/
3963 		{ &hf_h265_aspect_ratio_info_present_flag,
3964 		{ "aspect_ratio_info_present_flag", "h265.aspect_ratio_info_present_flag",
3965 			FT_UINT8, BASE_DEC, NULL, 0x0,
3966 			NULL, HFILL }
3967 		},
3968 		{ &hf_h265_aspect_ratio_idc,
3969 		{ "aspect_ratio_idc", "h265.aspect_ratio_idc",
3970 			FT_UINT8, BASE_DEC, NULL, 0x0,
3971 			NULL, HFILL }
3972 		},
3973 		{ &hf_h265_sar_width,
3974 		{ "sar_width", "h265.sar_width",
3975 			FT_UINT16, BASE_DEC, NULL, 0x0,
3976 			NULL, HFILL }
3977 		},
3978 		{ &hf_h265_sar_height,
3979 		{ "sar_height", "h265.sar_height",
3980 			FT_UINT16, BASE_DEC, NULL, 0x0,
3981 			NULL, HFILL }
3982 		},
3983 		{ &hf_h265_overscan_info_present_flag,
3984 		{ "overscan_info_present_flag", "h265.overscan_info_present_flag",
3985 			FT_UINT8, BASE_DEC, NULL, 0x0,
3986 			NULL, HFILL }
3987 		},
3988 		{ &hf_h265_overscan_appropriate_flag,
3989 		{ "overscan_appropriate_flag", "h265.overscan_appropriate_flag",
3990 			FT_UINT8, BASE_DEC, NULL, 0x0,
3991 			NULL, HFILL }
3992 		},
3993 		{ &hf_h265_video_signal_type_present_flag,
3994 		{ "video_signal_type_present_flag", "h265.video_signal_type_present_flag",
3995 			FT_UINT8, BASE_DEC, NULL, 0x0,
3996 			NULL, HFILL }
3997 		},
3998 		{ &hf_h265_video_format,
3999 		{ "video_format", "h265.video_format",
4000 			FT_UINT8, BASE_DEC, VALS(h265_video_format_vals), 0x0,
4001 			NULL, HFILL }
4002 		},
4003 		{ &hf_h265_video_full_range_flag,
4004 		{ "video_full_range_flag", "h265.video_full_range_flag",
4005 			FT_UINT8, BASE_DEC, NULL, 0x0,
4006 			NULL, HFILL }
4007 		},
4008 		{ &hf_h265_colour_description_present_flag,
4009 		{ "colour_description_present_flag", "h265.colour_description_present_flag",
4010 			FT_UINT8, BASE_DEC, NULL, 0x0,
4011 			NULL, HFILL }
4012 		},
4013 		{ &hf_h265_colour_primaries,
4014 		{ "colour_primaries", "h265.colour_primaries",
4015 			FT_UINT8, BASE_DEC, NULL, 0x0,
4016 			NULL, HFILL }
4017 		},
4018 		{ &hf_h265_transfer_characteristics,
4019 		{ "transfer_characteristics", "h265.transfer_characteristics",
4020 			FT_UINT8, BASE_DEC, NULL, 0x0,
4021 			NULL, HFILL }
4022 		},
4023 		{ &hf_h265_matrix_coeffs,
4024 		{ "matrix_coefficients", "h265.matrix_coefficients",
4025 			FT_UINT8, BASE_DEC, NULL, 0x0,
4026 			NULL, HFILL }
4027 		},
4028 		{ &hf_h265_chroma_loc_info_present_flag,
4029 		{ "chroma_loc_info_present_flag", "h265.chroma_loc_info_present_flag",
4030 			FT_UINT8, BASE_DEC, NULL, 0x0,
4031 			NULL, HFILL }
4032 		},
4033 		{ &hf_h265_chroma_sample_loc_type_top_field,
4034 		{ "chroma_sample_loc_type_top_field", "h265.chroma_sample_loc_type_top_field",
4035 			FT_UINT32, BASE_DEC, NULL, 0x0,
4036 			NULL, HFILL }
4037 		},
4038 		{ &hf_h265_chroma_sample_loc_type_bottom_field,
4039 		{ "chroma_sample_loc_type_bottom_field", "h265.chroma_sample_loc_type_bottom_field",
4040 			FT_UINT32, BASE_DEC, NULL, 0x0,
4041 			NULL, HFILL }
4042 		},
4043 		{ &hf_h265_neutral_chroma_indication_flag,
4044 		{ "neutral_chroma_indication_flag", "h265.neutral_chroma_indication_flag",
4045 			FT_UINT8, BASE_DEC, NULL, 0x0,
4046 			NULL, HFILL }
4047 		}, { &hf_h265_field_seq_flag,
4048 		{ "field_seq_flag", "h265.field_seq_flag",
4049 			FT_UINT8, BASE_DEC, NULL, 0x0,
4050 			NULL, HFILL }
4051 		}, { &hf_h265_frame_field_info_present_flag,
4052 		{ "frame_field_info_present_flag", "h265.frame_field_info_present_flag",
4053 			FT_UINT8, BASE_DEC, NULL, 0x0,
4054 			NULL, HFILL }
4055 		}, { &hf_h265_default_display_window_flag,
4056 		{ "default_display_window_flag", "h265.default_display_window_flag",
4057 			FT_UINT8, BASE_DEC, NULL, 0x0,
4058 			NULL, HFILL }
4059 		},
4060 		{ &hf_h265_def_disp_win_left_offset,
4061 		{ "def_disp_win_left_offset", "h265.def_disp_win_left_offset",
4062 			FT_UINT32, BASE_DEC, NULL, 0x0,
4063 			NULL, HFILL }
4064 		},
4065 		{ &hf_h265_def_disp_win_right_offset,
4066 		{ "def_disp_win_right_offset", "h265.def_disp_win_right_offset",
4067 			FT_UINT32, BASE_DEC, NULL, 0x0,
4068 			NULL, HFILL }
4069 		},
4070 		{ &hf_h265_def_disp_win_top_offset,
4071 		{ "def_disp_win_top_offset", "h265.def_disp_win_top_offset",
4072 			FT_UINT32, BASE_DEC, NULL, 0x0,
4073 			NULL, HFILL }
4074 		},
4075 		{ &hf_h265_def_disp_win_bottom_offset,
4076 		{ "def_disp_win_bottom_offset", "h265.def_disp_win_bottom_offset",
4077 			FT_UINT32, BASE_DEC, NULL, 0x0,
4078 			NULL, HFILL }
4079 		},
4080 		{ &hf_h265_vui_timing_info_present_flag,
4081 		{ "vui_timing_info_present_flag", "h265.vui_timing_info_present_flag",
4082 			FT_UINT8, BASE_DEC, NULL, 0x0,
4083 			NULL, HFILL }
4084 		},
4085 		{ &hf_h265_vui_num_units_in_tick,
4086 		{ "vui_num_units_in_tick", "h265.vui_num_units_in_tick",
4087 			FT_UINT32, BASE_DEC, NULL, 0x0,
4088 			NULL, HFILL }
4089 		},
4090 		{ &hf_h265_vui_time_scale,
4091 		{ "vui_time_scale", "h265.vui_time_scale",
4092 			FT_UINT32, BASE_DEC, NULL, 0x0,
4093 			NULL, HFILL }
4094 		},
4095 		{ &hf_h265_vui_poc_proportional_to_timing_flag,
4096 		{ "vui_poc_proportional_to_timing_flag", "h265.vui_poc_proportional_to_timing_flag",
4097 			FT_UINT8, BASE_DEC, NULL, 0x0,
4098 			NULL, HFILL }
4099 		},
4100 		{ &hf_h265_vui_num_ticks_poc_diff_one_minus1,
4101 		{ "vui_num_ticks_poc_diff_one_minus1", "h265.vui_num_ticks_poc_diff_one_minus1",
4102 			FT_UINT32, BASE_DEC, NULL, 0x0,
4103 			NULL, HFILL }
4104 		},
4105 		{ &hf_h265_vui_hrd_parameters_present_flag,
4106 		{ "vui_hrd_parameters_present_flag", "h265.vui_hrd_parameters_present_flag",
4107 			FT_UINT8, BASE_DEC, NULL, 0x0,
4108 			NULL, HFILL }
4109 		},
4110 		{ &hf_h265_bitstream_restriction_flag,
4111 		{ "bitstream_restriction_flag", "h265.bitstream_restriction_flag",
4112 			FT_UINT8, BASE_DEC, NULL, 0x0,
4113 			NULL, HFILL }
4114 		},
4115 		{ &hf_h265_tiles_fixed_structure_flag,
4116 		{ "tiles_fixed_structure_flag", "h265.tiles_fixed_structure_flag",
4117 			FT_UINT8, BASE_DEC, NULL, 0x0,
4118 			NULL, HFILL }
4119 		},
4120 		{ &hf_h265_motion_vectors_over_pic_boundaries_flag,
4121 		{ "motion_vectors_over_pic_boundaries_flag", "h265.motion_vectors_over_pic_boundaries_flag",
4122 			FT_UINT32, BASE_DEC, NULL, 0x0,
4123 			NULL, HFILL }
4124 		},
4125 		{ &hf_h265_restricted_ref_pic_lists_flag,
4126 		{ "restricted_ref_pic_lists_flag", "h265.restricted_ref_pic_lists_flag",
4127 			FT_UINT32, BASE_DEC, NULL, 0x0,
4128 			NULL, HFILL }
4129 		},
4130 		{ &hf_h265_min_spatial_segmentation_idc,
4131 		{ "min_spatial_segmentation_idc", "h265.min_spatial_segmentation_idc",
4132 			FT_UINT32, BASE_DEC, NULL, 0x0,
4133 			NULL, HFILL }
4134 		},
4135 		{ &hf_h265_max_bytes_per_pic_denom,
4136 		{ "max_bytes_per_pic_denom", "h265.max_bytes_per_pic_denom",
4137 			FT_UINT32, BASE_DEC, NULL, 0x0,
4138 			NULL, HFILL }
4139 		},
4140 		{ &hf_h265_max_bits_per_min_cu_denom,
4141 		{ "max_bits_per_mb_denom", "h265.max_bits_per_mb_denom",
4142 			FT_UINT32, BASE_DEC, NULL, 0x0,
4143 			NULL, HFILL }
4144 		},
4145 		{ &hf_h265_log2_max_mv_length_horizontal,
4146 		{ "max_mv_length_horizontal", "h265.max_mv_length_horizontal",
4147 			FT_UINT32, BASE_DEC, NULL, 0x0,
4148 			NULL, HFILL }
4149 		},
4150 		{ &hf_h265_log2_max_mv_length_vertical,
4151 		{ "log2_max_mv_length_vertical", "h265.log2_max_mv_length_vertical",
4152 			FT_UINT32, BASE_DEC, NULL, 0x0,
4153 			NULL, HFILL }
4154 		},
4155 			/* sps_range_extension */
4156 		{ &hf_h265_transform_skip_rotation_enabled_flag,
4157 		{ "transform_skip_rotation_enabled_flag", "h265.transform_skip_rotation_enabled_flag",
4158 			FT_UINT8, BASE_DEC, NULL, 0x0,
4159 			NULL, HFILL }
4160 		},
4161 		{ &hf_h265_transform_skip_context_enabled_flag,
4162 		{ "transform_skip_context_enabled_flag", "h265.transform_skip_context_enabled_flag",
4163 			FT_UINT8, BASE_DEC, NULL, 0x0,
4164 			NULL, HFILL }
4165 		},
4166 		{ &hf_h265_implicit_rdpcm_enabled_flag,
4167 		{ "implicit_rdpcm_enabled_flag", "h265.implicit_rdpcm_enabled_flag",
4168 			FT_UINT8, BASE_DEC, NULL, 0x0,
4169 			NULL, HFILL }
4170 		},
4171 		{ &hf_h265_explicit_rdpcm_enabled_flag,
4172 		{ "explicit_rdpcm_enabled_flag", "h265.explicit_rdpcm_enabled_flag",
4173 			FT_UINT8, BASE_DEC, NULL, 0x0,
4174 			NULL, HFILL }
4175 		},
4176 		{ &hf_h265_extended_precision_processing_flag,
4177 		{ "extended_precision_processing_flag", "h265.extended_precision_processing_flag",
4178 			FT_UINT8, BASE_DEC, NULL, 0x0,
4179 			NULL, HFILL }
4180 		},
4181 		{ &hf_h265_intra_smoothing_disabled_flag,
4182 		{ "intra_smoothing_disabled_flag", "h265.intra_smoothing_disabled_flag",
4183 			FT_UINT8, BASE_DEC, NULL, 0x0,
4184 			NULL, HFILL }
4185 		},
4186 		{ &hf_h265_high_precision_offsets_enabled_flag,
4187 		{ "high_precision_offsets_enabled_flag", "h265.high_precision_offsets_enabled_flag",
4188 			FT_UINT8, BASE_DEC, NULL, 0x0,
4189 			NULL, HFILL }
4190 		},
4191 		{ &hf_h265_persistent_rice_adaptation_enabled_flag,
4192 		{ "persistent_rice_adaptation_enabled_flag", "h265.persistent_rice_adaptation_enabled_flag",
4193 			FT_UINT8, BASE_DEC, NULL, 0x0,
4194 			NULL, HFILL }
4195 		},
4196 		{ &hf_h265_cabac_bypass_alignment_enabled_flag,
4197 		{ "cabac_bypass_alignment_enabled_flag", "h265.cabac_bypass_alignment_enabled_flag",
4198 			FT_UINT8, BASE_DEC, NULL, 0x0,
4199 			NULL, HFILL }
4200 		},
4201 			/* sps_scc_extension */
4202 		{ &hf_h265_sps_curr_pic_ref_enabled_flag,
4203 		{ "sps_curr_pic_ref_enabled_flag", "h265.sps_curr_pic_ref_enabled_flag",
4204 			FT_UINT8, BASE_DEC, NULL, 0x0,
4205 			NULL, HFILL }
4206 		},
4207 		{ &hf_h265_palette_mode_enabled_flag,
4208 		{ "palette_mode_enabled_flag", "h265.palette_mode_enabled_flag",
4209 			FT_UINT8, BASE_DEC, NULL, 0x0,
4210 			NULL, HFILL }
4211 		},
4212 		{ &hf_h265_palette_max_size,
4213 		{ "palette_max_size", "h265.palette_max_size",
4214 			FT_UINT32, BASE_DEC, NULL, 0x0,
4215 			NULL, HFILL }
4216 		},
4217 		{ &hf_h265_delta_palette_max_predictor_size,
4218 		{ "delta_palette_max_predictor_size", "h265.delta_palette_max_predictor_size",
4219 			FT_UINT32, BASE_DEC, NULL, 0x0,
4220 			NULL, HFILL }
4221 		},
4222 		{ &hf_h265_sps_palette_predictor_initializers_present_flag,
4223 		{ "sps_palette_predictor_initializers_present_flag", "h265.sps_palette_predictor_initializers_present_flag",
4224 			FT_UINT8, BASE_DEC, NULL, 0x0,
4225 			NULL, HFILL }
4226 		},
4227 		{ &hf_h265_sps_num_palette_predictor_initializers_minus1,
4228 		{ "sps_num_palette_predictor_initializers_minus1", "h265.sps_num_palette_predictor_initializers_minus1",
4229 			FT_UINT32, BASE_DEC, NULL, 0x0,
4230 			NULL, HFILL }
4231 		},
4232 		{ &hf_h265_sps_palette_predictor_initializer/*[comp][i]*/,
4233 		{ "sps_palette_predictor_initializer", "h265.sps_palette_predictor_initializer",
4234 			FT_UINT32, BASE_DEC, NULL, 0x0,
4235 			NULL, HFILL }
4236 		},
4237 		{ &hf_h265_motion_vector_resolution_control_idc,
4238 		{ "motion_vector_resolution_control_idc", "h265.motion_vector_resolution_control_idc",
4239 			FT_UINT8, BASE_DEC, NULL, 0x0,
4240 			NULL, HFILL }
4241 		},
4242 		{ &hf_h265_intra_boundary_filtering_disabled_flag,
4243 		{ "intra_boundary_filtering_disabled_flag", "h265.intra_boundary_filtering_disabled_flag",
4244 			FT_UINT8, BASE_DEC, NULL, 0x0,
4245 			NULL, HFILL }
4246 		},
4247 			/* PPS */
4248 		{ &hf_h265_pps_pic_parameter_set_id,
4249 		{ "pps_pic_parameter_set_id", "h265.pps_pic_parameter_set_id",
4250 			FT_UINT32, BASE_DEC, NULL, 0x0,
4251 			NULL, HFILL }
4252 		},
4253 		{ &hf_h265_pps_seq_parameter_set_id,
4254 		{ "pps_seq_parameter_set_id", "h265.pps_seq_parameter_set_id",
4255 			FT_UINT32, BASE_DEC, NULL, 0x0,
4256 			NULL, HFILL }
4257 		},
4258 		{ &hf_h265_dependent_slice_segments_enabled_flag,
4259 		{ "dependent_slice_segments_enabled_flag", "h265.dependent_slice_segments_enabled_flag",
4260 			FT_UINT8, BASE_DEC, NULL, 0x0,
4261 			NULL, HFILL }
4262 		},
4263 		{ &hf_h265_output_flag_present_flag,
4264 		{ "output_flag_present_flag", "h265.output_flag_present_flag",
4265 			FT_UINT8, BASE_DEC, NULL, 0x0,
4266 			NULL, HFILL }
4267 		},
4268 		{ &hf_h265_num_extra_slice_header_bits,
4269 		{ "num_extra_slice_header_bits", "h265.num_extra_slice_header_bits",
4270 			FT_UINT8, BASE_DEC, NULL, 0x0,
4271 			NULL, HFILL }
4272 		},
4273 		{ &hf_h265_sign_data_hiding_enabled_flag,
4274 		{ "sign_data_hiding_enabled_flag", "h265.sign_data_hiding_enabled_flag",
4275 			FT_UINT8, BASE_DEC, NULL, 0x0,
4276 			NULL, HFILL }
4277 		},
4278 		{ &hf_h265_cabac_init_present_flag,
4279 		{ "cabac_init_present_flag", "h265.cabac_init_present_flag",
4280 			FT_UINT8, BASE_DEC, NULL, 0x0,
4281 			NULL, HFILL }
4282 		},
4283 		{ &hf_h265_num_ref_idx_l0_default_active_minus1,
4284 		{ "num_ref_idx_l0_default_active_minus1", "h265.num_ref_idx_l0_default_active_minus1",
4285 			FT_UINT32, BASE_DEC, NULL, 0x0,
4286 			NULL, HFILL }
4287 		},
4288 		{ &hf_h265_num_ref_idx_l1_default_active_minus1,
4289 		{ "num_ref_idx_l1_default_active_minus1", "h265.num_ref_idx_l1_default_active_minus1",
4290 			FT_UINT32, BASE_DEC, NULL, 0x0,
4291 			NULL, HFILL }
4292 		},
4293 		{ &hf_h265_init_qp_minus26,
4294 		{ "init_qp_minus26", "h265.init_qp_minus26",
4295 			FT_INT32, BASE_DEC, NULL, 0x0,
4296 			NULL, HFILL }
4297 		},
4298 		{ &hf_h265_constrained_intra_pred_flag,
4299 		{ "constrained_intra_pred_flag", "h265.constrained_intra_pred_flag",
4300 			FT_UINT8, BASE_DEC, NULL, 0x0,
4301 			NULL, HFILL }
4302 		},
4303 		{ &hf_h265_transform_skip_enabled_flag,
4304 		{ "transform_skip_enabled_flag", "h265.transform_skip_enabled_flag",
4305 			FT_UINT8, BASE_DEC, NULL, 0x0,
4306 			NULL, HFILL }
4307 		},
4308 		{ &hf_h265_cu_qp_delta_enabled_flag,
4309 		{ "cu_qp_delta_enabled_flag", "h265.cu_qp_delta_enabled_flag",
4310 			FT_UINT8, BASE_DEC, NULL, 0x0,
4311 			NULL, HFILL }
4312 		},
4313 		{ &hf_h265_diff_cu_qp_delta_depth,
4314 		{ "diff_cu_qp_delta_depth", "h265.diff_cu_qp_delta_depth",
4315 			FT_UINT32, BASE_DEC, NULL, 0x0,
4316 			NULL, HFILL }
4317 		},
4318 		{ &hf_h265_pps_cb_qp_offset,
4319 		{ "pps_cb_qp_offset", "h265.pps_cb_qp_offset",
4320 			FT_INT32, BASE_DEC, NULL, 0x0,
4321 			NULL, HFILL }
4322 		},
4323 		{ &hf_h265_pps_cr_qp_offset,
4324 		{ "pps_cr_qp_offset", "h265.pps_cr_qp_offset",
4325 			FT_INT32, BASE_DEC, NULL, 0x0,
4326 			NULL, HFILL }
4327 		},
4328 		{ &hf_h265_pps_slice_chroma_qp_offsets_present_flag,
4329 		{ "pps_slice_chroma_qp_offsets_present_flag", "h265.pps_slice_chroma_qp_offsets_present_flag",
4330 			FT_UINT8, BASE_DEC, NULL, 0x0,
4331 			NULL, HFILL }
4332 		},
4333 		{ &hf_h265_weighted_pred_flag,
4334 		{ "weighted_pred_flag", "h265.weighted_pred_flag",
4335 			FT_UINT8, BASE_DEC, NULL, 0x0,
4336 			NULL, HFILL }
4337 		},
4338 		{ &hf_h265_weighted_bipred_flag,
4339 		{ "weighted_bipred_flag", "h265.weighted_bipred_flag",
4340 			FT_UINT8, BASE_DEC, NULL, 0x0,
4341 			NULL, HFILL }
4342 		},
4343 		{ &hf_h265_transquant_bypass_enabled_flag,
4344 		{ "transquant_bypass_enabled_flag", "h265.transquant_bypass_enabled_flag",
4345 			FT_UINT8, BASE_DEC, NULL, 0x0,
4346 			NULL, HFILL }
4347 		},
4348 		{ &hf_h265_tiles_enabled_flag,
4349 		{ "tiles_enabled_flag", "h265.tiles_enabled_flag",
4350 			FT_UINT8, BASE_DEC, NULL, 0x0,
4351 			NULL, HFILL }
4352 		},
4353 		{ &hf_h265_entropy_coding_sync_enabled_flag,
4354 		{ "entropy_coding_sync_enabled_flag", "h265.entropy_coding_sync_enabled_flag",
4355 			FT_UINT8, BASE_DEC, NULL, 0x0,
4356 			NULL, HFILL }
4357 		},
4358 		{ &hf_h265_num_tile_columns_minus1,
4359 		{ "num_tile_columns_minus1", "h265.num_tile_columns_minus1",
4360 			FT_UINT32, BASE_DEC, NULL, 0x0,
4361 			NULL, HFILL }
4362 		},
4363 		{ &hf_h265_num_tile_rows_minus1,
4364 		{ "num_tile_rows_minus1", "h265.num_tile_rows_minus1",
4365 			FT_UINT32, BASE_DEC, NULL, 0x0,
4366 			NULL, HFILL }
4367 		},
4368 		{ &hf_h265_uniform_spacing_flag,
4369 		{ "uniform_spacing_flag", "h265.uniform_spacing_flag",
4370 			FT_UINT8, BASE_DEC, NULL, 0x0,
4371 			NULL, HFILL }
4372 		},
4373 		{ &hf_h265_column_width_minus1/*[i]*/,
4374 		{ "column_width_minus1", "h265.column_width_minus1",
4375 			FT_UINT32, BASE_DEC, NULL, 0x0,
4376 			NULL, HFILL }
4377 		},
4378 		{ &hf_h265_row_height_minus1/*[i]*/,
4379 		{ "row_height_minus1", "h265.row_height_minus1",
4380 			FT_UINT32, BASE_DEC, NULL, 0x0,
4381 			NULL, HFILL }
4382 		},
4383 		{ &hf_h265_loop_filter_across_tiles_enabled_flag,
4384 		{ "loop_filter_across_tiles_enabled_flag", "h265.loop_filter_across_tiles_enabled_flag",
4385 			FT_UINT8, BASE_DEC, NULL, 0x0,
4386 			NULL, HFILL }
4387 		},
4388 		{ &hf_h265_pps_loop_filter_across_slices_enabled_flag,
4389 		{ "pps_loop_filter_across_slices_enabled_flag", "h265.pps_loop_filter_across_slices_enabled_flag",
4390 			FT_UINT8, BASE_DEC, NULL, 0x0,
4391 			NULL, HFILL }
4392 		},
4393 		{ &hf_h265_deblocking_filter_control_present_flag,
4394 		{ "deblocking_filter_control_present_flag", "h265.deblocking_filter_control_present_flag",
4395 			FT_UINT8, BASE_DEC, NULL, 0x0,
4396 			NULL, HFILL }
4397 		},
4398 		{ &hf_h265_deblocking_filter_override_enabled_flag,
4399 		{ "deblocking_filter_override_enabled_flag", "h265.deblocking_filter_override_enabled_flag",
4400 			FT_UINT8, BASE_DEC, NULL, 0x0,
4401 			NULL, HFILL }
4402 		},
4403 		{ &hf_h265_pps_deblocking_filter_disabled_flag,
4404 		{ "pps_deblocking_filter_disabled_flag", "h265.pps_deblocking_filter_disabled_flag",
4405 			FT_UINT8, BASE_DEC, NULL, 0x0,
4406 			NULL, HFILL }
4407 		},
4408 		{ &hf_h265_pps_beta_offset_div2,
4409 		{ "pps_beta_offset_div2", "h265.pps_beta_offset_div2",
4410 			FT_INT32, BASE_DEC, NULL, 0x0,
4411 			NULL, HFILL }
4412 		},
4413 		{ &hf_h265_pps_tc_offset_div2,
4414 		{ "pps_tc_offset_div2", "h265.pps_tc_offset_div2",
4415 			FT_INT32, BASE_DEC, NULL, 0x0,
4416 			NULL, HFILL }
4417 		},
4418 		{ &hf_h265_pps_scaling_list_data_present_flag,
4419 		{ "pps_scaling_list_data_present_flag", "h265.pps_scaling_list_data_present_flag",
4420 			FT_UINT8, BASE_DEC, NULL, 0x0,
4421 			NULL, HFILL }
4422 		},
4423 		{ &hf_h265_lists_modification_present_flag,
4424 		{ "lists_modification_present_flag", "h265.lists_modification_present_flag",
4425 			FT_UINT8, BASE_DEC, NULL, 0x0,
4426 			NULL, HFILL }
4427 		},
4428 		{ &hf_h265_log2_parallel_merge_level_minus2,
4429 		{ "log2_parallel_merge_level_minus2", "h265.log2_parallel_merge_level_minus2",
4430 			FT_UINT32, BASE_DEC, NULL, 0x0,
4431 			NULL, HFILL }
4432 		},
4433 		{ &hf_h265_slice_segment_header_extension_present_flag,
4434 		{ "slice_segment_header_extension_present_flag", "h265.slice_segment_header_extension_present_flag",
4435 			FT_UINT8, BASE_DEC, NULL, 0x0,
4436 			NULL, HFILL }
4437 		},
4438 		{ &hf_h265_pps_extension_present_flag,
4439 		{ "pps_extension_present_flag", "h265.pps_extension_present_flag",
4440 			FT_UINT8, BASE_DEC, NULL, 0x0,
4441 			NULL, HFILL }
4442 		},
4443 		{ &hf_h265_pps_range_extension_flag,
4444 		{ "pps_range_extension_flag", "h265.pps_range_extension_flag",
4445 			FT_UINT8, BASE_DEC, NULL, 0x0,
4446 			NULL, HFILL }
4447 		},
4448 		{ &hf_h265_pps_multilayer_extension_flag,
4449 		{ "pps_multilayer_extension_flag", "h265.pps_multilayer_extension_flag",
4450 			FT_UINT8, BASE_DEC, NULL, 0x0,
4451 			NULL, HFILL }
4452 		},
4453 		{ &hf_h265_pps_3d_extension_flag,
4454 		{ "pps_3d_extension_flag", "h265.pps_3d_extension_flag",
4455 			FT_UINT8, BASE_DEC, NULL, 0x0,
4456 			NULL, HFILL }
4457 		},
4458 		{ &hf_h265_pps_scc_extension_flag,
4459 		{ "pps_scc_extension_flag", "h265.pps_scc_extension_flag",
4460 			FT_UINT8, BASE_DEC, NULL, 0x0,
4461 			NULL, HFILL }
4462 		},
4463 		{ &hf_h265_pps_extension_4bits,
4464 		{ "pps_extension_4bits", "h265.pps_extension_4bits",
4465 			FT_UINT8, BASE_DEC, NULL, 0x0,
4466 			NULL, HFILL }
4467 		},
4468 		{ &hf_h265_pps_extension_data_flag,
4469 		{ "pps_extension_data_flag", "h265.pps_extension_data_flag",
4470 			FT_UINT8, BASE_DEC, NULL, 0x0,
4471 			NULL, HFILL }
4472 		},
4473 
4474 		{ &hf_h265_log2_max_transform_skip_block_size_minus2,
4475 		{ "log2_max_transform_skip_block_size_minus2", "h265.log2_max_transform_skip_block_size_minus2",
4476 			FT_UINT32, BASE_DEC, NULL, 0x0,
4477 			NULL, HFILL }
4478 		},
4479 		{ &hf_h265_cross_component_prediction_enabled_flag,
4480 		{ "cross_component_prediction_enabled_flag", "h265.cross_component_prediction_enabled_flag",
4481 			FT_UINT8, BASE_DEC, NULL, 0x0,
4482 			NULL, HFILL }
4483 		},
4484 		{ &hf_h265_chroma_qp_offset_list_enabled_flag,
4485 		{ "chroma_qp_offset_list_enabled_flag", "h265.chroma_qp_offset_list_enabled_flag",
4486 			FT_UINT8, BASE_DEC, NULL, 0x0,
4487 			NULL, HFILL }
4488 		},
4489 		{ &hf_h265_diff_cu_chroma_qp_offset_depth,
4490 		{ "diff_cu_chroma_qp_offset_depth", "h265.diff_cu_chroma_qp_offset_depth",
4491 			FT_UINT32, BASE_DEC, NULL, 0x0,
4492 			NULL, HFILL }
4493 		},
4494 		{ &hf_h265_chroma_qp_offset_list_len_minus1,
4495 		{ "chroma_qp_offset_list_len_minus1", "h265.chroma_qp_offset_list_len_minus1",
4496 			FT_UINT32, BASE_DEC, NULL, 0x0,
4497 			NULL, HFILL }
4498 		},
4499 		{ &hf_h265_cb_qp_offset_list/*[i]*/,
4500 		{ "cb_qp_offset_list", "h265.cb_qp_offset_list",
4501 			FT_INT32, BASE_DEC, NULL, 0x0,
4502 			NULL, HFILL }
4503 		},
4504 		{ &hf_h265_cr_qp_offset_list/*[i]*/,
4505 		{ "cr_qp_offset_list", "h265.cr_qp_offset_list",
4506 			FT_INT32, BASE_DEC, NULL, 0x0,
4507 			NULL, HFILL }
4508 		},
4509 		{ &hf_h265_log2_sao_offset_scale_luma,
4510 		{ "log2_sao_offset_scale_luma", "h265.log2_sao_offset_scale_luma",
4511 			FT_UINT32, BASE_DEC, NULL, 0x0,
4512 			NULL, HFILL }
4513 		},
4514 		{ &hf_h265_log2_sao_offset_scale_chroma,
4515 		{ "log2_sao_offset_scale_chroma", "h265.log2_sao_offset_scale_chroma",
4516 			FT_UINT32, BASE_DEC, NULL, 0x0,
4517 			NULL, HFILL }
4518 		},
4519 			/*pps_scc_extension*/
4520 		{ &hf_h265_pps_curr_pic_ref_enabled_flag,
4521 		{ "pps_curr_pic_ref_enabled_flag", "h265.pps_curr_pic_ref_enabled_flag",
4522 			FT_UINT8, BASE_DEC, NULL, 0x0,
4523 			NULL, HFILL }
4524 		}, { &hf_h265_residual_adaptive_colour_transform_enabled_flag,
4525 		{ "residual_adaptive_colour_transform_enabled_flag", "h265.residual_adaptive_colour_transform_enabled_flag",
4526 			FT_UINT8, BASE_DEC, NULL, 0x0,
4527 			NULL, HFILL }
4528 		},
4529 		{ &hf_h265_pps_slice_act_qp_offsets_present_flag,
4530 		{ "pps_slice_act_qp_offsets_present_flag", "h265.pps_slice_act_qp_offsets_present_flag",
4531 			FT_UINT8, BASE_DEC, NULL, 0x0,
4532 			NULL, HFILL }
4533 		},
4534 		{ &hf_h265_pps_act_y_qp_offset_plus5,
4535 		{ "pps_act_y_qp_offset_plus5", "h265.pps_act_y_qp_offset_plus5",
4536 			FT_INT32, BASE_DEC, NULL, 0x0,
4537 			NULL, HFILL }
4538 		},
4539 		{ &hf_h265_pps_act_cb_qp_offset_plus5,
4540 		{ "pps_act_cb_qp_offset_plus5", "h265.pps_act_cb_qp_offset_plus5",
4541 			FT_INT32, BASE_DEC, NULL, 0x0,
4542 			NULL, HFILL }
4543 		},
4544 		{ &hf_h265_pps_act_cr_qp_offset_plus3,
4545 		{ "pps_act_cr_qp_offset_plus3", "h265.pps_act_cr_qp_offset_plus3",
4546 			FT_INT32, BASE_DEC, NULL, 0x0,
4547 			NULL, HFILL }
4548 		},
4549 		{ &hf_h265_pps_palette_predictor_initializers_present_flag,
4550 		{ "pps_palette_predictor_initializers_present_flag", "h265.pps_palette_predictor_initializers_present_flag",
4551 			FT_UINT8, BASE_DEC, NULL, 0x0,
4552 			NULL, HFILL }
4553 		},
4554 		{ &hf_h265_pps_num_palette_predictor_initializers,
4555 		{ "pps_num_palette_predictor_initializers", "h265.pps_num_palette_predictor_initializers",
4556 			FT_UINT32, BASE_DEC, NULL, 0x0,
4557 			NULL, HFILL }
4558 		},
4559 		{ &hf_h265_monochrome_palette_flag,
4560 		{ "monochrome_palette_flag", "h265.monochrome_palette_flag",
4561 			FT_UINT8, BASE_DEC, NULL, 0x0,
4562 			NULL, HFILL }
4563 		},
4564 		{ &hf_h265_luma_bit_depth_entry_minus8,
4565 		{ "luma_bit_depth_entry_minus8", "h265.luma_bit_depth_entry_minus8",
4566 			FT_UINT32, BASE_DEC, NULL, 0x0,
4567 			NULL, HFILL }
4568 		},
4569 		{ &hf_h265_chroma_bit_depth_entry_minus8,
4570 		{ "chroma_bit_depth_entry_minus8", "h265.chroma_bit_depth_entry_minus8",
4571 			FT_UINT32, BASE_DEC, NULL, 0x0,
4572 			NULL, HFILL }
4573 		},
4574 		{ &hf_h265_pps_palette_predictor_initializer/*[comp][i]*/,
4575 		{ "pps_palette_predictor_initializer", "h265.pps_palette_predictor_initializer",
4576 			FT_UINT32, BASE_DEC, NULL, 0x0,
4577 			NULL, HFILL }
4578 		},
4579 
4580 			/*Slice*/
4581 		{ &hf_h265_slice_pic_parameter_set_id,
4582 		{ "slice_pic_parameter_set_id", "h265.slice_pic_parameter_set_id",
4583 			FT_UINT32, BASE_DEC, NULL, 0x0,
4584 			NULL, HFILL }
4585 		},
4586 		{ &hf_h265_slice_segment_address,
4587 		{ "slice_segment_address", "h265.slice_segment_address",
4588 			FT_UINT32, BASE_DEC, NULL, 0x0,
4589 			NULL, HFILL }
4590 		},
4591 		{ &hf_h265_slice_type,
4592 		{ "slice_type", "h265.slice_type",
4593 			FT_UINT32, BASE_DEC, VALS(h265_slice_type_vals), 0x0,
4594 			NULL, HFILL }
4595 		},
4596 			/* SEI */
4597 		{ &hf_h265_payloadsize,
4598 		{ "PayloadSize", "h265.payloadsize",
4599 			FT_UINT32, BASE_DEC, NULL, 0x0,
4600 			NULL, HFILL }
4601 		},
4602 		{ &hf_h265_payloadtype,
4603 		{ "payloadType", "h265.payloadtype",
4604 			FT_UINT32, BASE_DEC, VALS(h265_sei_payload_vals), 0x0,
4605 			NULL, HFILL }
4606 		},
4607 			/* SDP parameters*/
4608 		{ &hf_h265_sdp_parameter_sprop_vps,
4609 		{ "sprop-vps", "h265.sdp.sprop_vps",
4610 			FT_BYTES, BASE_NONE, NULL, 0x0,
4611 			NULL, HFILL }
4612 		},
4613 		{ &hf_h265_sdp_parameter_sprop_sps,
4614 		{ "sprop-sps", "h265.sdp.sprop_sps",
4615 			FT_BYTES, BASE_NONE, NULL, 0x0,
4616 			NULL, HFILL }
4617 		},
4618 		{ &hf_h265_sdp_parameter_sprop_pps,
4619 		{ "sprop-pps", "h265.sdp.sprop_pps",
4620 			FT_BYTES, BASE_NONE, NULL, 0x0,
4621 			NULL, HFILL }
4622 		},
4623 
4624 		};
4625 
4626 	/* Setup protocol subtree array */
4627 	static gint *ett[] = {
4628 		&ett_h265,
4629 		&ett_h265_profile,
4630 		&ett_h265_nal,
4631 		&ett_h265_fu,
4632 		&ett_h265_stream,
4633 		&ett_h265_sps_multilayer_extension,
4634 		&ett_h265_sps_3d_extension,
4635 		&ett_h265_pps_multilayer_extension,
4636 		&ett_h265_pps_3d_extension,
4637 		&ett_h265_access_unit_delimiter_rbsp,
4638 		&ett_h265_sei_rbsp,
4639 		&ett_h265_filler_data_rbsp,
4640 		&ett_h265_end_of_seq_rbsp,
4641 		&ett_h265_end_of_bitstream_rbsp,
4642 		&ett_h265_profile_tier_level,
4643 		&ett_h265_vui_parameters,
4644 		&ett_h265_hrd_parameters,
4645 		&ett_h265_sprop_parameters
4646 	};
4647 
4648 	static ei_register_info ei[] = {
4649 		{ &ei_h265_undecoded,{ "h265.undecoded", PI_UNDECODED, PI_WARN, "[Not decoded yet]", EXPFILL } },
4650 		{ &ei_h265_oversized_exp_golomb_code, {"h265.oversized_exp_golomb_code", PI_MALFORMED, PI_ERROR, "Exponential Golomb encoded value greater than 32 bit integer, clamped", EXPFILL } },
4651 		{ &ei_h265_value_to_large,{ "h265.value_to_large", PI_PROTOCOL, PI_ERROR, "[Value to large, protocol violation]", EXPFILL } },
4652 		{ &ei_h265_format_specific_parameter,{ "h265.format_specific_parameter", PI_UNDECODED, PI_WARN, "[Unspecified media format specific parameter]", EXPFILL } },
4653 	};
4654 
4655 	/* Register the protocol name and description */
4656 	proto_h265 = proto_register_protocol("H.265", "H.265", "h265");
4657 
4658 	/* Required function calls to register the header fields and subtrees used */
4659 	proto_register_field_array(proto_h265, hf, array_length(hf));
4660 	proto_register_subtree_array(ett, array_length(ett));
4661 	expert_h265 = expert_register_protocol(proto_h265);
4662 	expert_register_field_array(expert_h265, ei, array_length(ei));
4663 	/* Register a configuration option for port */
4664 
4665 
4666 	h265_module = prefs_register_protocol(proto_h265, proto_reg_handoff_h265);
4667 
4668 
4669 	prefs_register_range_preference(h265_module, "dynamic.payload.type",
4670 		"H.265 dynamic payload types",
4671 		"Dynamic payload types which will be interpreted as H.265"
4672 		"; values must be in the range 1 - 127",
4673 		&temp_dynamic_payload_type_range, 127);
4674 
4675 	h265_handle = register_dissector("h265", dissect_h265, proto_h265);
4676 }
4677 
4678 /* Register the protocol with Wireshark */
4679 void
proto_reg_handoff_h265(void)4680 proto_reg_handoff_h265(void)
4681 {
4682 	static range_t  *dynamic_payload_type_range = NULL;
4683 	static gboolean  h265_prefs_initialized = FALSE;
4684 
4685 	if (!h265_prefs_initialized) {
4686 		dissector_add_string("rtp_dyn_payload_type", "H265", h265_handle);
4687 
4688 		h265_prefs_initialized = TRUE;
4689 	}
4690 	else {
4691 		dissector_delete_uint_range("rtp.pt", dynamic_payload_type_range, h265_handle);
4692 		wmem_free(wmem_epan_scope(), dynamic_payload_type_range);
4693 	}
4694 
4695 	dynamic_payload_type_range = range_copy(wmem_epan_scope(), temp_dynamic_payload_type_range);
4696 	range_remove_value(wmem_epan_scope(), &dynamic_payload_type_range, 0);
4697 	dissector_add_uint_range("rtp.pt", dynamic_payload_type_range, h265_handle);
4698 }
4699 
4700 /*
4701 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
4702 *
4703 * Local variables:
4704 * c-basic-offset: 4
4705 * tab-width: 8
4706 * indent-tabs-mode: nil
4707 * End:
4708 *
4709 * vi: set shiftwidth=4 tabstop=8 expandtab:
4710 * :indentSize=4:tabSize=8:noTabs=true:
4711 */
4712