1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
22 {
24
26
27 #ifdef READ
29 #endif
30
32 fixed(8, ff_byte, 0xff);
33
34 return 0;
35 }
36
40 {
42
43 HEADER(
"User Data Registered ITU-T T.35");
44
45 u(8, itu_t_t35_country_code, 0x00, 0xff);
48 else {
49 u(8, itu_t_t35_country_code_extension_byte, 0x00, 0xff);
51 }
52
53 #ifdef READ
54 if (
state->payload_size <
i) {
56 "Invalid SEI user data registered payload.\n");
58 }
60 #endif
61
64 xu(8, itu_t_t35_payload_byte[], current->
data[j], 0x00, 0xff, 1,
i + j);
65
66 return 0;
67 }
68
72 {
74
75 HEADER(
"User Data Unregistered");
76
77 #ifdef READ
78 if (
state->payload_size < 16) {
80 "Invalid SEI user data unregistered payload.\n");
82 }
84 #endif
85
86 for (
i = 0;
i < 16;
i++)
87 us(8, uuid_iso_iec_11578[
i], 0x00, 0xff, 1,
i);
88
90
92 xu(8, user_data_payload_byte[
i], current->
data[
i], 0x00, 0xff, 1,
i);
93
94 return 0;
95 }
96
101 {
103
104 HEADER(
"Mastering Display Colour Volume");
105
106 for (
c = 0;
c < 3;
c++) {
107 ubs(16, display_primaries_x[
c], 1,
c);
108 ubs(16, display_primaries_y[
c], 1,
c);
109 }
110
111 ub(16, white_point_x);
112 ub(16, white_point_y);
113
114 ub(32, max_display_mastering_luminance);
115 ub(32, min_display_mastering_luminance);
116
117 return 0;
118 }
119
123 {
124 int err;
125
126 HEADER(
"Content Light Level Information");
127
128 ub(16, max_content_light_level);
129 ub(16, max_pic_average_light_level);
130
131 return 0;
132 }
133
138 {
139 int err;
140
141 HEADER(
"Alternative Transfer Characteristics");
142
143 ub(8, preferred_transfer_characteristics);
144
145 return 0;
146 }
147
152 {
153 static const uint16_t max_ambient_light_value = 50000;
154 int err;
155
156 HEADER(
"Ambient Viewing Environment");
157
159 u(16, ambient_light_x, 0, max_ambient_light_value);
160 u(16, ambient_light_y, 0, max_ambient_light_value);
161
162 return 0;
163 }
164
167 {
170
174 .payload_type = current->payload_type,
175 .payload_size = current->payload_size,
176 .extension_present = current->extension_bit_length > 0,
177 };
178 int start_position, current_position, bits_written;
179
180 #ifdef READ
182 #endif
183
185
187
189 bits_written = current_position - start_position;
190
192 bits_written < 8 * current->payload_size) {
194
195 #ifdef READ
198
199 bits_left = 8 * current->payload_size - bits_written;
204 // The trailing bits must contain a bit_equal_to_one, so
205 // they can't all be zero.
207 }
209 current->extension_bit_length =
211 #endif
212
213 if (current->extension_bit_length > 0) {
215 (current->extension_bit_length + 7) / 8);
216
217 bits_left = current->extension_bit_length;
220 xu(length, reserved_payload_extension_data,
221 current->extension_data[
i],
224 }
225 }
226
227 fixed(1, bit_equal_to_one, 1);
229 fixed(1, bit_equal_to_zero, 0);
230 }
231
232 #ifdef WRITE
233 current->payload_size = (
put_bits_count(rw) - start_position) / 8;
234 #endif
235 } else {
237
238 #ifdef READ
239 allocate(current->payload_ref, current->payload_size);
240 current->payload = current->payload_ref;
241 #else
242 allocate(current->payload, current->payload_size);
243 #endif
244 data = current->payload;
245
246 for (
i = 0;
i < current->payload_size;
i++)
247 xu(8, payload_byte[
i],
data[
i], 0, 255, 1,
i);
248 }
249
250 return 0;
251 }
252
255 {
257 int err, k;
258
259 #ifdef READ
260 for (k = 0;; k++) {
261 uint32_t payload_type = 0;
262 uint32_t payload_size = 0;
265
267 fixed(8, ff_byte, 0xff);
268 payload_type += 255;
269 }
270 xu(8, last_payload_type_byte,
tmp, 0, 254, 0);
272
274 fixed(8, ff_byte, 0xff);
275 payload_size += 255;
276 }
277 xu(8, last_payload_size_byte,
tmp, 0, 254, 0);
279
280 // There must be space remaining for both the payload and
281 // the trailing bits on the SEI NAL unit.
284 "Invalid SEI message: payload_size too large "
285 "(%"PRIu32" bytes).\n", payload_size);
287 }
291
293 message = ¤t->messages[k];
294
295 message->payload_type = payload_type;
296 message->payload_size = payload_size;
297
299
301
303 break;
304 }
305 #else
306 for (k = 0; k < current->nb_messages; k++) {
310
311 message = ¤t->messages[k];
312
313 // We write the payload twice in order to find the size. Trace
314 // output is switched off for the first write.
315 trace =
ctx->trace_enable;
316 ctx->trace_enable = 0;
317
318 start_state = *rw;
319 for (
i = 0;
i < 2;
i++) {
320 *rw = start_state;
321
324 fixed(8, ff_byte, 0xff);
326 }
327 xu(8, last_payload_type_byte,
tmp, 0, 254, 0);
328
331 fixed(8, ff_byte, 0xff);
333 }
334 xu(8, last_payload_size_byte,
tmp, 0, 254, 0);
335
337 ctx->trace_enable = trace;
338 if (err < 0)
339 return err;
340 }
341 }
342 #endif
343
344 return 0;
345 }