25 fixed(1, alignment_bit_equal_to_zero, 0);
34 fixed(1, rbsp_stop_one_bit, 1);
36 fixed(1, rbsp_alignment_zero_bit, 0);
43 uint32_t valid_type_mask)
47 fixed(1, forbidden_zero_bit, 0);
48 fixed(1, forbidden_one_bit, 1);
51 if (!(1 <<
current->nal_unit_type & valid_type_mask)) {
72 flag(processed_planes_type_flag);
73 ub(6, resolution_type);
74 ub(1, transform_type);
75 ub(2, chroma_sampling_type);
76 ub(2, base_depth_type);
77 ub(2, enhancement_depth_type);
78 flag(temporal_step_width_modifier_signalled_flag);
79 flag(predicted_residual_mode_flag);
80 flag(temporal_tile_intra_signalling_enabled_flag);
81 flag(temporal_enabled_flag);
83 flag(level1_filtering_signalled_flag);
84 ub(2, scaling_mode_level1);
85 ub(2, scaling_mode_level2);
86 ub(2, tile_dimensions_type);
87 ub(2, user_data_enabled);
88 flag(level1_depth_flag);
89 flag(chroma_step_width_flag);
91 if (
current->processed_planes_type_flag) {
93 ub(4, reserved_zeros_4bit);
95 infer(planes_type, 0);
97 if (
current->temporal_step_width_modifier_signalled_flag) {
98 ub(8, temporal_step_width_modifier);
101 if (
current->upsample_type == 4) {
102 ub(16, upsampler_coeff1);
103 ub(16, upsampler_coeff2);
104 ub(16, upsampler_coeff3);
105 ub(16, upsampler_coeff4);
108 if (
current->level1_filtering_signalled_flag) {
109 ub(4, level1_filtering_first_coefficient);
110 ub(4, level1_filtering_second_coefficient);
113 if (
current->tile_dimensions_type > 0) {
114 if (
current->tile_dimensions_type == 3) {
115 ub(16, custom_tile_width);
116 ub(16, custom_tile_height);
118 ub(5, reserved_zeros_5bit);
119 flag(compression_type_entropy_enabled_per_tile_flag);
120 ub(2, compression_type_size_per_tile);
123 if (
current->resolution_type == 63) {
124 ub(16, custom_resolution_width);
125 ub(16, custom_resolution_height);
127 if (
current->chroma_step_width_flag) {
128 ub(8, chroma_step_width_multiplier);
130 infer(chroma_step_width_multiplier, 64);
146 HEADER(
"Sequence Config");
151 flag(conformance_window_flag);
152 ub(5, reserved_zeros_5bit);
157 ub(1, reserved_zeros_1bit);
159 if (
current->conformance_window_flag == 1) {
160 mb(conf_win_left_offset);
161 mb(conf_win_right_offset);
162 mb(conf_win_top_offset);
163 mb(conf_win_bottom_offset);
184 flag(no_enhancement_bit_flag);
185 if (
current->no_enhancement_bit_flag == 0) {
186 ub(3, quant_matrix_mode);
187 flag(dequant_offset_signalled_flag);
188 flag(picture_type_bit_flag);
189 flag(temporal_refresh_bit_flag);
190 flag(step_width_sublayer1_enabled_flag);
191 ub(15, step_width_sublayer2);
192 flag(dithering_control_flag);
195 !
current->temporal_refresh_bit_flag);
197 infer(quant_matrix_mode, 0);
198 infer(dequant_offset_signalled_flag, 0);
199 ub(4, reserved_zeros_4bit);
200 flag(picture_type_bit_flag);
201 flag(temporal_refresh_bit_flag);
202 infer(step_width_sublayer1_enabled_flag, 0);
207 flag(temporal_signalling_present_flag);
210 if (
current->picture_type_bit_flag == 1) {
211 flag(field_type_bit_flag);
212 ub(7, reserved_zeros_7bit);
215 if (
current->step_width_sublayer1_enabled_flag == 1) {
216 ub(15, step_width_sublayer1);
217 flag(level1_filtering_enabled_flag);
219 infer(level1_filtering_enabled_flag, 0);
222 if (
current->quant_matrix_mode == 2 ||
223 current->quant_matrix_mode == 3 ||
224 current->quant_matrix_mode == 5) {
225 for (
int layer_idx = 0; layer_idx < nlayers; layer_idx++)
226 ubs(8, qm_coefficient_0[layer_idx], 1, layer_idx);
229 if (
current->quant_matrix_mode == 4 ||
current->quant_matrix_mode == 5) {
230 for (
int layer_idx = 0; layer_idx < nlayers; layer_idx++)
231 ubs(8, qm_coefficient_1[layer_idx], 1, layer_idx);
234 if (
current->dequant_offset_signalled_flag) {
235 flag(dequant_offset_mode_flag);
236 ub(7, dequant_offset);
239 if (
current->dithering_control_flag == 1) {
240 ub(2, dithering_type);
241 ub(1, reserverd_zero);
242 if (
current->dithering_type != 0) {
243 ub(5, dithering_strength);
245 ub(5, reserved_zeros_5bit);
261 int nplanes, nlayers, err;
268 if (!priv->
gc || !priv->
pc)
273 for (
int plane_idx = 0; plane_idx < nplanes; plane_idx++) {
276 for (
int layer_idx = 0; layer_idx < nlayers; layer_idx++) {
277 ubs(1, surfaces_entropy_enabled_flag[plane_idx][
level_idx][layer_idx], 3, plane_idx,
level_idx, layer_idx);
283 ubs(1, temporal_surfaces_entropy_enabled_flag[plane_idx], 1, plane_idx);
284 ubs(1, temporal_surfaces_rle_only_flag[plane_idx], 1, plane_idx);
323 if (
current->payload_type == 1)
325 else if (
current->payload_type == 2)
327 else if (
current->payload_type == 4)
329 else if (
current->payload_type == 5)
335 current->payload_size = payload_size;
344 xu(8, reserved_sei_message_payload_byte[
i],
data[
i], 0, 255, 1,
i);
349 message->payload_type = sei_type;
350 message->payload_size = payload_size;
364 flag(aspect_ratio_info_present_flag);
365 if (
current->aspect_ratio_info_present_flag) {
366 ub(8, aspect_ratio_idc);
368 if (
current->aspect_ratio_idc == 255) {
373 infer(aspect_ratio_idc, 0);
376 flag(overscan_info_present_flag);
377 if (
current->overscan_info_present_flag)
378 flag(overscan_appropriate_flag);
380 infer(overscan_appropriate_flag, 0);
382 flag(video_signal_type_present_flag);
383 if (
current->video_signal_type_present_flag) {
384 u(3, video_format, 0, 5);
385 flag(video_full_range_flag);
386 flag(colour_description_present_flag);
387 if (
current->colour_description_present_flag) {
388 ub(8, colour_primaries);
390 ub(8, matrix_coefficients);
392 infer(colour_primaries, 2);
394 infer(matrix_coefficients, 2);
397 infer(video_format, 5);
398 infer(video_full_range_flag, 0);
399 infer(colour_description_present_flag, 0);
400 infer(colour_primaries, 2);
402 infer(matrix_coefficients, 2);
404 flag(chroma_loc_info_present_flag);
405 if (
current->chroma_loc_info_present_flag) {
406 ue(chroma_sample_loc_type_top_field, 0, 5);
407 ue(chroma_sample_loc_type_bottom_field, 0, 5);
409 infer(chroma_sample_loc_type_top_field, 0);
410 infer(chroma_sample_loc_type_bottom_field, 0);
423 HEADER(
"Additional Info");
425 ub(8, additional_info_type);
444 xu(8, additional_info_byte[
i],
data[
i], 0, 255, 1,
i);
462 fixed(8, filler_byte, 0xaa);
469 for (
int i = 0;
i <
current->filler_size;
i++)
470 fixed(8, filler_byte, 0xaa);
486 .payload_type =
current->payload_type,
487 .payload_size =
current->payload_size,
488 .extension_present =
current->extension_bit_length > 0,
490 int start_position, current_position, bits_written;
501 bits_written = current_position - start_position;
504 bits_written < 8 * current->payload_size) {
521 current->extension_bit_length =
525 if (
current->extension_bit_length > 0) {
527 (
current->extension_bit_length + 7) / 8);
532 xu(length, reserved_payload_extension_data,
539 fixed(1, payload_bit_equal_to_one, 1);
541 fixed(1, payload_bit_equal_to_zero, 0);
559 xu(8, payload_byte[
i],
data[
i], 0, 255, 1,
i);
574 int payload_size_type;
576 uint32_t payload_size;
583 payload_size_type =
tmp;
587 if (payload_size_type == 6) {
592 payload_size = payload_size_type;
593 if (payload_size_type == 7)
594 xmb(custom_byte_size, payload_size);
599 "Invalid process block: payload_size too large "
600 "(%"PRIu32
" bytes).\n", payload_size);
610 block->payload_type = payload_type;
611 block->payload_size = payload_size;
621 for (k = 0; k <
current->nb_blocks; k++) {
630 trace =
ctx->trace_enable;
631 ctx->trace_enable = 0;
634 for (
i = 0;
i < 2;
i++) {
640 xu(3, payload_size_type,
tmp, 0, 7, 0);
644 xmb(custom_byte_size,
block->payload_size);
647 ctx->trace_enable = trace;
671 current->nal_unit_header.nal_unit_type));