32 fixed(8, ff_byte, 0xff);
43 HEADER(
"User Data Registered ITU-T T.35");
45 u(8, itu_t_t35_country_code, 0x00, 0xff);
46 if (
current->itu_t_t35_country_code != 0xff)
49 u(8, itu_t_t35_country_code_extension_byte, 0x00, 0xff);
54 if (
state->payload_size <
i) {
56 "Invalid SEI user data registered payload.\n");
65 if (
current->itu_t_t35_country_code == 0xff)
70 for (j = 0; j <
current->data_length; j++)
71 xu(8, itu_t_t35_payload_byte[],
current->data[j], 0x00, 0xff, 1,
i + j);
82 HEADER(
"User Data Unregistered");
85 if (
state->payload_size < 16) {
87 "Invalid SEI user data unregistered payload.\n");
93 for (
i = 0;
i < 16;
i++)
94 us(8, uuid_iso_iec_11578[
i], 0x00, 0xff, 1,
i);
105 xu(8, user_data_payload_byte[
i],
current->data[
i], 0x00, 0xff, 1,
i);
116 HEADER(
"Frame Packing Arrangement");
119 flag(fp_arrangement_cancel_flag);
120 if (!
current->fp_arrangement_cancel_flag) {
121 u(7, fp_arrangement_type, 3, 5);
122 flag(fp_quincunx_sampling_flag);
123 u(6, fp_content_interpretation_type, 0, 2);
124 flag(fp_spatial_flipping_flag);
125 flag(fp_frame0_flipped_flag);
126 flag(fp_field_views_flag);
127 flag(fp_current_frame_is_frame0_flag);
128 flag(fp_frame0_self_contained_flag);
129 flag(fp_frame1_self_contained_flag);
130 if (!
current->fp_quincunx_sampling_flag &&
current->fp_arrangement_type != 5) {
131 ub(4, fp_frame0_grid_position_x);
132 ub(4, fp_frame0_grid_position_y);
133 ub(4, fp_frame1_grid_position_x);
134 ub(4, fp_frame1_grid_position_y);
136 fixed(8, fp_arrangement_reserved_byte, 0);
137 flag(fp_arrangement_persistence_flag);
139 flag(fp_upsampled_aspect_ratio_flag);
151 HEADER(
"Decoded Picture Hash");
153 u(8, dph_sei_hash_type, 0, 2);
154 flag(dph_sei_single_component_flag);
155 ub(7, dph_sei_reserved_zero_7bits);
157 for (c_idx = 0; c_idx < (
current->dph_sei_single_component_flag ? 1 : 3);
159 if (
current->dph_sei_hash_type == 0) {
160 for (
i = 0;
i < 16;
i++)
161 us(8, dph_sei_picture_md5[c_idx][
i], 0x00, 0xff, 2, c_idx,
i);
162 }
else if (
current->dph_sei_hash_type == 1) {
163 us(16, dph_sei_picture_crc[c_idx], 0x0000, 0xffff, 1, c_idx);
164 }
else if (
current->dph_sei_hash_type == 2) {
165 us(32, dph_sei_picture_checksum[c_idx], 0x00000000, 0xffffffff, 1,
179 HEADER(
"Mastering Display Colour Volume");
181 for (
c = 0;
c < 3;
c++) {
182 ubs(16, display_primaries_x[
c], 1,
c);
183 ubs(16, display_primaries_y[
c], 1,
c);
186 ub(16, white_point_x);
187 ub(16, white_point_y);
189 ub(32, max_display_mastering_luminance);
190 ub(32, min_display_mastering_luminance);
201 HEADER(
"Content Light Level Information");
203 ub(16, max_content_light_level);
204 ub(16, max_pic_average_light_level);
216 HEADER(
"Alternative Transfer Characteristics");
218 ub(8, preferred_transfer_characteristics);
228 static const uint16_t max_ambient_light_value = 50000;
231 HEADER(
"Ambient Viewing Environment");
234 u(16, ambient_light_x, 0, max_ambient_light_value);
235 u(16, ambient_light_y, 0, max_ambient_light_value);
247 HEADER(
"Film Grain Characteristics");
249 flag(fg_characteristics_cancel_flag);
250 if (!
current->fg_characteristics_cancel_flag) {
251 int filmGrainBitDepth[3];
253 u(2, fg_model_id, 0, 1);
254 flag(fg_separate_colour_description_present_flag);
255 if (
current->fg_separate_colour_description_present_flag) {
256 ub(3, fg_bit_depth_luma_minus8);
257 ub(3, fg_bit_depth_chroma_minus8);
258 flag(fg_full_range_flag);
259 ub(8, fg_colour_primaries);
260 ub(8, fg_transfer_characteristics);
261 ub(8, fg_matrix_coeffs);
264 filmGrainBitDepth[0] =
current->fg_bit_depth_luma_minus8 + 8;
265 filmGrainBitDepth[1] =
266 filmGrainBitDepth[2] =
current->fg_bit_depth_chroma_minus8 + 8;
268 u(2, fg_blending_mode_id, 0, 1);
269 ub(4, fg_log2_scale_factor);
270 for (
c = 0;
c < 3;
c++)
271 flags(fg_comp_model_present_flag[
c], 1,
c);
273 for (
c = 0;
c < 3;
c++) {
274 if (
current->fg_comp_model_present_flag[
c]) {
275 ubs(8, fg_num_intensity_intervals_minus1[
c], 1,
c);
276 us(3, fg_num_model_values_minus1[
c], 0, 5, 1,
c);
277 for (
i = 0;
i <=
current->fg_num_intensity_intervals_minus1[
c];
i++) {
278 ubs(8, fg_intensity_interval_lower_bound[
c][
i], 2,
c,
i);
279 ubs(8, fg_intensity_interval_upper_bound[
c][
i], 2,
c,
i);
280 for (j = 0; j <=
current->fg_num_model_values_minus1[
c]; j++)
281 ses(fg_comp_model_value[
c][
i][j], 0 -
current->fg_model_id * (1 << (filmGrainBitDepth[
c] - 1)),
282 ((1 << filmGrainBitDepth[
c]) - 1) -
current->fg_model_id * (1 << (filmGrainBitDepth[
c] - 1)),
287 flag(fg_characteristics_persistence_flag);
299 HEADER(
"Display Orientation");
301 flag(display_orientation_cancel_flag);
302 if (!
current->display_orientation_cancel_flag) {
303 flag(display_orientation_persistence_flag);
304 u(3, display_orientation_transform_type, 0, 7);
305 ub(3, display_orientation_reserved_zero_3bits);
317 HEADER(
"Frame-field information");
319 flag(ffi_field_pic_flag);
320 if (
current->ffi_field_pic_flag) {
321 flag(ffi_bottom_field_flag);
322 flag(ffi_pairing_indicated_flag);
323 if (
current->ffi_pairing_indicated_flag)
324 flag(ffi_paired_with_next_field_flag);
326 flag(ffi_display_fields_from_frame_flag);
327 if (
current->ffi_display_fields_from_frame_flag)
328 flag(ffi_top_field_first_flag);
329 u(8, ffi_display_elemental_periods_minus1, 0, 0xff);
331 u(2, ffi_source_scan_type, 0, 3);
332 flag(ffi_duplicate_flag);
346 .payload_type =
current->payload_type,
347 .payload_size =
current->payload_size,
348 .extension_present =
current->extension_bit_length > 0,
350 int start_position, current_position, bits_written;
361 bits_written = current_position - start_position;
364 bits_written < 8 * current->payload_size) {
381 current->extension_bit_length =
385 if (
current->extension_bit_length > 0) {
387 (
current->extension_bit_length + 7) / 8);
392 xu(length, reserved_payload_extension_data,
399 fixed(1, bit_equal_to_one, 1);
401 fixed(1, bit_equal_to_zero, 0);
419 xu(8, payload_byte[
i],
data[
i], 0, 255, 1,
i);
433 uint32_t payload_type = 0;
434 uint32_t payload_size = 0;
439 fixed(8, ff_byte, 0xff);
442 xu(8, last_payload_type_byte,
tmp, 0, 254, 0);
446 fixed(8, ff_byte, 0xff);
449 xu(8, last_payload_size_byte,
tmp, 0, 254, 0);
456 "Invalid SEI message: payload_size too large "
457 "(%"PRIu32
" bytes).\n", payload_size);
467 message->payload_type = payload_type;
468 message->payload_size = payload_size;
478 for (k = 0; k <
current->nb_messages; k++) {
487 trace =
ctx->trace_enable;
488 ctx->trace_enable = 0;
491 for (
i = 0;
i < 2;
i++) {
496 fixed(8, ff_byte, 0xff);
499 xu(8, last_payload_type_byte,
tmp, 0, 254, 0);
503 fixed(8, ff_byte, 0xff);
506 xu(8, last_payload_size_byte,
tmp, 0, 254, 0);
509 ctx->trace_enable = trace;