Mercurial > mplayer.hg
annotate DOCS/tech/mpcf.txt @ 12082:f705b0777572
removing subpackets (everyone hates them ...)
removing shuffle_type (meaningless without subpackets)
making timestamp_lsb a simple unsigned value (someone proposed that a long time ago, dunno dont remember who, IIRC it was rejected as it more often required the timestamp_msb to be coded but by defining lsb relative to the last lsb we need very few msbs in the error free case and for damaged files its also pretty difficult to trash the timestamp, for example for a fixed fps stream with 7bit lsb_timestamps we need to loose >64 frames in a row to end up with a wrong timestamp)
cleanup (filesize and such where only partially removed)
frame_code byte, with the meaning of each value stored in the main header
the frame_code contains the keyframe_flag, packet_type and can contain the timestamp_delta, stream_id and the data_size or part if it
author | michael |
---|---|
date | Tue, 30 Mar 2004 01:05:51 +0000 |
parents | 645975e01061 |
children | 68baf8877c07 |
rev | line source |
---|---|
12082 | 1 NUT Open Container Format DRAFT 20040330 |
10817 | 2 ---------------------------------------- |
9294 | 3 |
4 | |
5 | |
6 Intro: | |
7 | |
8 Features / goals: | |
9 (supported by the format, not necessary by a specific implementation) | |
10 | |
11 Simple | |
12 use the same encoding for nearly all fields | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
13 simple decoding, so slow cpus (and embedded systems) can handle it |
9294 | 14 Extendible |
15 no limit for the possible values for all fields (using universal vlc) | |
16 allow adding of new headers in the future | |
17 allow adding more fields at the end of headers | |
18 Compact | |
19 ~0.2% overhead, for normal bitrates | |
20 index is <10kb per hour (1 keyframe every 3sec) | |
10831 | 21 a usual header for a file is about 100bytes (audio + video headers together) |
12082 | 22 a packet header is about ~1-8 bytes |
9294 | 23 Error resistant |
24 seeking / playback without an index | |
25 headers & index can be repeated | |
26 checksums to allow quick redownloading of damaged parts | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
27 damaged files can be played back with minimal data lost and fast |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
28 resyncing times |
9294 | 29 |
30 | |
31 | |
32 Definitions: | |
33 | |
34 MUST the specific part must be done to conform to this standard | |
35 SHOULD its recommanded to be done that way but its not strictly required | |
36 | |
37 | |
38 | |
39 Syntax: | |
40 | |
9295 | 41 Type definitions: |
42 v | |
43 value=0 | |
44 do{ | |
45 more_data u(1) | |
46 data u(7) | |
47 value= 128*value + data | |
48 }while(more_data) | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
49 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
50 s |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
51 temp v |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
52 temp++ |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
53 if(temp&1) value= -(temp>>1) |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
54 else value= (temp>>1) |
9323 | 55 |
56 b (binary data or string) | |
57 length v | |
58 for(i=0; i<length; i++){ | |
59 data[i] u(8) | |
9295 | 60 } |
9335
de287fe94511
lang & country codes from ISO & utf8 requirement (ideas from Tobias Diedrich <td at sim dot uni-hannover dot de>
michael
parents:
9325
diff
changeset
|
61 Note: strings MUST be encoded in utf8 |
9295 | 62 |
9323 | 63 |
10824 | 64 f(x) n fixed bits in big endian order |
9295 | 65 u(x) unsigned number encoded in x bits in MSB first order |
66 | |
67 | |
68 Bitstream syntax: | |
9294 | 69 packet header |
12082 | 70 backward ptr v |
9294 | 71 forward ptr v |
72 | |
73 align_byte | |
74 while(not byte aligned) | |
75 one f(1) | |
76 | |
77 reserved_bytes | |
78 for(i=0; i<forward_ptr - length_of_non_reserved; i++) | |
79 reserved u(8) | |
10824 | 80 a decoder MUST ignore any reserved bytes |
81 a encoder MUST NOT write any reserved bytes, as this would make it | |
82 inpossible to add new fields at the end of packets in the future in | |
83 a compatible way | |
84 | |
9294 | 85 main header: |
10831 | 86 main_startcode f(64) |
9294 | 87 packet header |
88 version v | |
89 stream_count v | |
12082 | 90 checksum_threshold v |
91 for(i=0; i<256; i++){ | |
92 flags[i] v | |
93 if(flags&64){ | |
94 stream_id[i] v | |
95 lsb_size[i] v | |
96 data_size_mul[i] v | |
97 } | |
98 } | |
9294 | 99 reserved_bytes |
100 checksum u(32) | |
101 | |
102 stream_header: | |
10831 | 103 stream_startcode f(64) |
9294 | 104 packet_header |
105 stream_id v | |
106 stream_class v | |
9323 | 107 fourcc b |
9294 | 108 average_bitrate v |
9325 | 109 language_code b |
9297 | 110 time_base_nom v |
111 time_base_denom v | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
112 msb_timestamp_shift v |
12082 | 113 inital_timestamp_predictor v(3) |
114 initial_data_size_predictor v(2) | |
9294 | 115 fixed_fps u(1) |
9347
97888c25ae60
changing name to "nut" for now, we can change it again if we agree on something else
michael
parents:
9335
diff
changeset
|
116 index_flag u(1) |
9356 | 117 reserved u(6) |
9357
21347f49e8d8
supprting various codec specific/private headers for different APIs (ideas by arpi/alex/fabian)
michael
parents:
9356
diff
changeset
|
118 for(;;){ |
9361 | 119 codec_specific_data_type v |
120 if(codec_specific_data_type==0) break; | |
10985 | 121 codec_specific_data_size v |
9357
21347f49e8d8
supprting various codec specific/private headers for different APIs (ideas by arpi/alex/fabian)
michael
parents:
9356
diff
changeset
|
122 codec_specific_data b |
21347f49e8d8
supprting various codec specific/private headers for different APIs (ideas by arpi/alex/fabian)
michael
parents:
9356
diff
changeset
|
123 } |
9294 | 124 |
125 video_stream_header: | |
126 stream_header | |
127 width v | |
128 height v | |
129 sample_width v | |
130 sample_height v | |
131 colorspace_type v | |
132 reserved_bytes | |
133 checksum u(32) | |
134 | |
135 audio_stream_header: | |
136 stream_header | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
137 samplerate_mul v |
9294 | 138 channel_count v |
139 reserved_bytes | |
140 checksum u(32) | |
9420 | 141 |
12082 | 142 |
9294 | 143 frame |
12082 | 144 if(frame_type == 2){ |
145 frame_type2_startcode f(64) | |
9294 | 146 } |
12082 | 147 frame_code f(8) |
148 if(flags[frame_code]&1){ | |
149 packet header | |
150 } | |
151 if(stream_id[frame_code]==stream_count){ | |
152 stream_id v | |
153 } | |
154 if(frame_type == 2){ | |
9294 | 155 msb_timestamp v |
12082 | 156 } |
157 if((flags[frame_code]&12) == 12){ | |
158 lsb_timestamp v | |
9420 | 159 } |
12082 | 160 if(flags[frame_code]&2){ |
161 data_size_msb v | |
162 } | |
163 data | |
164 if(checksum_threshold < frame_type) | |
9312 | 165 frame_checksum u(32) |
12082 | 166 |
9294 | 167 Index: |
10831 | 168 index_startcode f(64) |
9294 | 169 packet header |
170 stream_id v | |
171 index_length v | |
172 for(i=0; i<index_length; i++){ | |
173 index_timestamp v | |
174 index_position v | |
175 } | |
9310 | 176 reserved_bytes |
9294 | 177 checksum u(32) |
178 | |
9310 | 179 info_packet: (optional) |
10831 | 180 info_startcode f(64) |
9294 | 181 packet header |
9323 | 182 for(;;){ |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
183 id v |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
184 if(id==0) break |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
185 name= info_table[id][0] |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
186 type= info_table[id][1] |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
187 if(type==NULL) |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
188 type b |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
189 if(name==NULL) |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
190 name b |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
191 if(type=="v") |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
192 value v |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
193 else if(type=="s") |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
194 value s |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
195 else |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
196 value b |
9323 | 197 } |
9310 | 198 reserved_bytes |
9294 | 199 checksum u(32) |
9323 | 200 |
201 | |
9294 | 202 forward_ptr |
203 backward_ptr | |
204 pointer to the next / previous packet | |
9323 | 205 pointers are relative and backward pointer is implicitelly negative |
9294 | 206 Note: a frame with 0 bytes means that its skiped |
9323 | 207 Note: the forward pointer is equal to the size of this packet including |
208 the header | |
209 the backward pointer is equal to the size of the previous packet | |
210 Example: | |
211 0 | |
212 size1 (size of frame1 including header) | |
213 frame1 | |
214 | |
215 size1 | |
216 size2 | |
217 frame2 | |
218 | |
219 size2 | |
220 size3 | |
221 frame3 | |
222 | |
223 | |
224 *_startcode | |
225 the first bit is allways set | |
9294 | 226 |
227 version | |
228 0 for now | |
12082 | 229 |
9294 | 230 stream_id |
231 Note: streams with a lower relative class MUST have a lower relative id | |
232 so a stream with class 0 MUST allways have a id which is lower then any | |
233 stream with class > 0 | |
9295 | 234 streams should use low ids |
9294 | 235 |
236 stream_class | |
237 0 video | |
238 32 audio | |
239 64 subtiles | |
240 Note the remaining values are reserved and MUST NOT be used | |
9312 | 241 a decoder MUST ignore streams with reserved classes |
9294 | 242 |
243 fourcc | |
244 identification for the codec | |
9323 | 245 example: "H264" |
10817 | 246 MUST contain 2 or 4 bytes, note, this might be increased in the future |
247 if needed | |
248 | |
9294 | 249 language_code |
9335
de287fe94511
lang & country codes from ISO & utf8 requirement (ideas from Tobias Diedrich <td at sim dot uni-hannover dot de>
michael
parents:
9325
diff
changeset
|
250 ISO 639 and ISO 3166 for language/country code |
9325 | 251 something like "usen" (US english), can be 0 |
9294 | 252 if unknown |
9335
de287fe94511
lang & country codes from ISO & utf8 requirement (ideas from Tobias Diedrich <td at sim dot uni-hannover dot de>
michael
parents:
9325
diff
changeset
|
253 see http://www.loc.gov/standards/iso639-2/englangn.html |
de287fe94511
lang & country codes from ISO & utf8 requirement (ideas from Tobias Diedrich <td at sim dot uni-hannover dot de>
michael
parents:
9325
diff
changeset
|
254 and http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1/en_listp1.html |
9294 | 255 |
9297 | 256 time_base_nom / time_base_denom = time_base |
9294 | 257 the number of timer ticks per second, this MUST be equal to the fps |
258 if the fixed_fps is 1 | |
9297 | 259 time_base_denom MUST not be 0 |
260 time_base_nom and time_base_denom MUST be relative prime | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
261 time_base_nom MUST be < 2^16 |
9297 | 262 examples: |
263 fps time_base_nom time_base_denom | |
264 30 30 1 | |
265 29.97 30000 1001 | |
266 23.976 24000 1001 | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
267 sample_rate sample_rate_mul time_base_nom time_base_denom |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
268 44100 1 44100 1 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
269 44100 64 11025 16 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
270 48000 1024 375 8 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
271 Note: the advantage to using a large sample_rate_mul is that the |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
272 timestamps need fewer bits |
9294 | 273 |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
274 msb_timestamp_shift |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
275 amount of bits msb_timestamp is shifted left before adding lsb_timestamp |
9294 | 276 MUST be <16 |
277 | |
278 fixed_fps | |
279 1 indicates that the fps is fixed | |
280 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
281 index_flag |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
282 1 indicates that this file has an index |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
283 Note, all files SHOULD have an index at the end except, (realtime) streams |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
284 Note, all streams SHOULD have an index |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
285 |
9357
21347f49e8d8
supprting various codec specific/private headers for different APIs (ideas by arpi/alex/fabian)
michael
parents:
9356
diff
changeset
|
286 codec_specific_data_type |
10817 | 287 0 none/end |
9361 | 288 1 native |
289 2 bitmapinfoheader | |
290 3 waveformatex | |
291 4 imagedesc | |
292 5 sounddesc | |
9357
21347f49e8d8
supprting various codec specific/private headers for different APIs (ideas by arpi/alex/fabian)
michael
parents:
9356
diff
changeset
|
293 "native", means a simple api & container independanet storage form, |
21347f49e8d8
supprting various codec specific/private headers for different APIs (ideas by arpi/alex/fabian)
michael
parents:
9356
diff
changeset
|
294 for example some mpeg4-es headers |
21347f49e8d8
supprting various codec specific/private headers for different APIs (ideas by arpi/alex/fabian)
michael
parents:
9356
diff
changeset
|
295 |
9356 | 296 codec_specific_data |
297 private global data for a codec (could be huffman tables or ...) | |
12082 | 298 |
299 frame_code | |
300 the meaning of this byte is stored in the main header | |
301 the value 78 ('N') is forbidden to ensure that the byte is always | |
302 different from the first byte of any startcode | |
9420 | 303 |
12082 | 304 flags[frame_code] |
305 the bits of the flags from MSB to LSB are CKKTTDP | |
306 P is 1 for type 1 and 2 packets, 0 for type 0 packets | |
307 TT is the timestamp_code 00,01,10 use the last timestamp + the first, | |
308 second and third last unique timestamp difference, so if the | |
309 timestamp differences, are +3,+1,+2,+2,+1 then last diff is | |
310 +1, second is +2 and third is +3 | |
311 if TT is 11, then the timestamp is calculated by | |
312 mask = (1<<msb_timestamp_shift)-1; | |
313 delta= last_timestamp - mask/2 | |
314 timestamp= ((timestamp_lsb-delta)&mask) + delta | |
315 TT must be 11 if packet_type is not 0 | |
316 the last timestamp differences are reset to the default values | |
317 from the stream header if a packet of type not 0 in encountered | |
318 if D is 1 then the data_size_msb is coded otherwise data_size_msb is 0 | |
319 KK is the keyframe_type | |
320 00-> no keyframe, | |
321 01-> keyframe, | |
322 10-> equal to last of the same stream, | |
323 11-> opposite from last of the same stream | |
324 KK must be 00 or 01 if the packet_type is not 0 | |
325 if C is 1 then stream_id, data_size_mul and data_size_lsb are not | |
326 stored, but predicted from the last ones | |
327 the value 1000001 (65) is used to mark illegal frame_code bytes, at | |
328 least flags[78] must be 65 | |
9420 | 329 |
12082 | 330 frame_type |
331 0 is indicated by (flags[frame_code]&1)==0 | |
332 1 is indicated by (flags[frame_code]&1)==1 && !startcode | |
333 2 is indicated by (flags[frame_code]&1)==1 && startcode | |
334 there SHOULD not be more then 0.5 seconds or 16kbyte of type 0 frames | |
335 wihout a intervening frame of different frame_type | |
336 | |
337 stream_id[frame_code] | |
338 if its not coded in the main_header then its equal to the last one | |
339 from the main header | |
340 must be <250 | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
341 |
12082 | 342 data_size_mul[frame_code] |
343 if its not coded in the main_header then its equal to the last one | |
344 from the main header | |
345 must be <250 | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
346 |
12082 | 347 data_size_lsb[frame_code] |
348 if its not coded in the main_header then its equal to the last one | |
349 from the main header + 1 | |
350 must be <250 | |
351 | |
352 data_size | |
353 if(data_size_lsb == data_size_mul) | |
354 data_size= last; | |
355 else if(data_size_lsb == data_size_mul+1) | |
356 data_size= next last; | |
357 else if(data_size_lsb < data_size_mul) | |
358 data_size= data_size_lsb + data_size_msb*data_size_mul; | |
359 else reserved | |
360 last and next last are reset to the values stored in the stream header | |
361 if an frame with type > 0 is encountered | |
362 | |
9294 | 363 msb_timestamp |
364 most significant bits of the timestamp, SHOULD be 0 for the first frame | |
365 | |
366 lsb_timestamp | |
12082 | 367 least significant bits of the timestamp in time_base precission |
9294 | 368 Example: IBBP display order |
369 keyframe msb_timestamp=0 lsb_timestamp=0 -> timestamp=0 | |
370 frame lsb_timestamp=3 -> timestamp=3 | |
371 frame lsb_timestamp=1 -> timestamp=1 | |
372 frame lsb_timestamp=2 -> timestamp=2 | |
373 ... | |
374 keyframe msb_timestamp=1 lsb_timestamp=1 -> timestamp=257 | |
12082 | 375 frame lsb_timestamp=255->timestamp=255 |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
376 frame lsb_timestamp=0 -> timestamp=256 |
9294 | 377 frame lsb_timestamp=4 -> timestamp=260 |
378 frame lsb_timestamp=2 -> timestamp=258 | |
379 frame lsb_timestamp=3 -> timestamp=259 | |
380 | |
381 width/height | |
382 MUST be set to the coded width/height | |
383 | |
384 sample_width/sample_height (aspect ratio) | |
385 sample_width is the horizontal distance between samples | |
386 sample_width and sample_height MUST be relative prime if not zero | |
387 MUST be 0 if unknown | |
388 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
389 colorspace_type |
10166 | 390 0 unknown |
391 1 ITU Rec 624 / ITU Rec 601 Y range: 16..235 Cb/Cr range: 16..240 | |
392 2 ITU Rec 709 Y range: 16..235 Cb/Cr range: 16..240 | |
393 17 ITU Rec 624 / ITU Rec 601 Y range: 0..255 Cb/Cr range: 0..255 | |
394 18 ITU Rec 709 Y range: 0..255 Cb/Cr range: 0..255 | |
395 | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
396 samplerate_mul |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
397 the number of samples per second in one time_base unit |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
398 samplerate = time_base*samplerate_mul |
9294 | 399 |
9311
4b04416ada91
zero_bit for normal frames, so we can distinguish them from other packets
michael
parents:
9310
diff
changeset
|
400 zero_bit |
4b04416ada91
zero_bit for normal frames, so we can distinguish them from other packets
michael
parents:
9310
diff
changeset
|
401 MUST be 0, its there to distinguish non keyframes from other packets, |
4b04416ada91
zero_bit for normal frames, so we can distinguish them from other packets
michael
parents:
9310
diff
changeset
|
402 Note: all packets have a 64-bit startcode except non-keyframes to reduce |
4b04416ada91
zero_bit for normal frames, so we can distinguish them from other packets
michael
parents:
9310
diff
changeset
|
403 their size, and all startcodes start with a 1 bit |
9294 | 404 |
405 checksum | |
9307
ec18ad315bbe
10l (copy & pasting the generator poly for crc32 from ogg was a bad idea...)
michael
parents:
9299
diff
changeset
|
406 crc32 checksum using the generator polynomial 0x104c11db7 (same as ogg) |
9294 | 407 |
408 frame_checksum | |
409 identical to checksum, but instead of covering just the current | |
12082 | 410 packet, it covers all frames since the last frame_checksum |
9294 | 411 |
412 index_timestamp | |
413 value in time_base precission, relative to the last index_timestamp | |
414 | |
415 index_position | |
416 position in bytes of the first byte of the keyframe header, relative | |
417 to the last index_position | |
418 | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
419 id |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
420 the id of the type/name pair, so its more compact |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
421 0 means end |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
422 |
9323 | 423 type |
9347
97888c25ae60
changing name to "nut" for now, we can change it again if we agree on something else
michael
parents:
9335
diff
changeset
|
424 for example: "UTF8" -> String or "JPEG" -> jpeg image |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
425 Note: nonstandard fields should be prefixed by "X-" |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
426 Note: MUST be less than 6 byte long (might be increased to 64 later) |
9323 | 427 |
9295 | 428 name |
429 the name of the info entry, valid names are | |
10873 | 430 "TotalTime" total length of the stream in msecs |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
431 "StreamId" the stream(s) to which the info packet applies |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
432 "StartTimestamp" |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
433 "EndTimestamp" the time range in msecs to which the info applies |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
434 "SegmentId" a unique id for the streams + time specified |
9347
97888c25ae60
changing name to "nut" for now, we can change it again if we agree on something else
michael
parents:
9335
diff
changeset
|
435 "Author" |
97888c25ae60
changing name to "nut" for now, we can change it again if we agree on something else
michael
parents:
9335
diff
changeset
|
436 "Description" |
97888c25ae60
changing name to "nut" for now, we can change it again if we agree on something else
michael
parents:
9335
diff
changeset
|
437 "Copyright" |
9369 | 438 "Encoder" the name & version of the software used for encoding |
9347
97888c25ae60
changing name to "nut" for now, we can change it again if we agree on something else
michael
parents:
9335
diff
changeset
|
439 "Title" |
9373 | 440 "Cover" an image of the (cd,dvd,vhs,..) cover (preferable PNG or JPEG) |
9350 | 441 "Source" "DVD", "VCD", "CD", "MD", "FM radio", "VHS", "TV", |
442 "LD" | |
9373 | 443 Optional: appended PAL,NTSC,SECAM, ... in parentheses |
9350 | 444 "CaptureDevice" "BT878", "BT848", "webcam", ... (more exact names are fine too) |
445 "CreationTime" "2003-01-20 20:13:15Z", ... | |
446 (ISO 8601 format, see http://www.cl.cam.ac.uk/~mgk25/iso-time.html) | |
447 Note: dont forget the timezone | |
11975 | 448 "ReplayGain" |
9360
add934b25d6d
"X-" prefix for nonstd fields & "keywords" idea by (Andreas Hess <jaska at gmx dot net>)
michael
parents:
9357
diff
changeset
|
449 "Keywords" |
9295 | 450 Note: if someone needs some others, please tell us about them, so we can |
451 add them to the official standard (if they are sane) | |
9360
add934b25d6d
"X-" prefix for nonstd fields & "keywords" idea by (Andreas Hess <jaska at gmx dot net>)
michael
parents:
9357
diff
changeset
|
452 Note: nonstandard fields should be prefixed by "X-" |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
453 Note: MUST be less than 64 bytes long |
9295 | 454 |
455 value | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
456 value of this name/type pair |
9295 | 457 |
9310 | 458 stuffing |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
459 0x80 can be placed infront of any type v entry for stuffing |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
460 purposes |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
461 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
462 info_table[][2]={ |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
463 {NULL , NULL }, // end |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
464 {NULL , NULL }, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
465 {NULL , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
466 {NULL , "v"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
467 {NULL , "s"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
468 {"StreamId" , "v"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
469 {"SegmentId" , "v"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
470 {"StartTimestamp" , "v"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
471 {"EndTimestamp" , "v"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
472 {"Author" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
473 {"Titel" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
474 {"Description" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
475 {"Copyright" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
476 {"Encoder" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
477 {"Keyword" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
478 {"Cover" , "JPEG"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
479 {"Cover" , "PNG"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
480 }; |
9294 | 481 |
482 Structure: | |
483 | |
484 the headers MUST be in exactly the following order (to simplify demuxer design) | |
485 main header | |
486 stream_header (id=0) | |
487 stream_header (id=1) | |
488 ... | |
489 stream_header (id=n) | |
490 | |
491 headers may be repated, but if they are then they MUST all be repeated together | |
492 and repeated headers MUST be identical | |
493 | |
494 headers MUST be repeated every 10sec at least ? FIXME | |
10817 | 495 headers MUST be repeated BEFORE keyframes |
9310 | 496 headers MUST be repeated at least twice (so they exist 3 times in a file) |
9295 | 497 |
9310 | 498 Index |
9580 | 499 the index can be repeated but there SHOULD be at least one for each stream at |
500 the end | |
9311
4b04416ada91
zero_bit for normal frames, so we can distinguish them from other packets
michael
parents:
9310
diff
changeset
|
501 Note: in case of realtime streaming there is no end, so no index there either |
9310 | 502 |
503 Info packets | |
504 the info_packet can be repeated, it can also contain different names & values | |
505 each time but only if allso the time is different | |
506 Info packets can be used to describe the file or some part of it (chapters) | |
507 | |
508 info packets, SHOULD be placed at the begin of the file at least | |
509 for realtime streaming info packets will normally be transmitted when they apply | |
510 for example, the current song title & artist of the currently shown music video | |
511 | |
512 Stuffing packets | |
513 can be used as a filler, for example to leave some empty space at the begin for | |
514 a copy of the index | |
515 | |
516 Unknown packets | |
517 MUST be ignored by the decoder | |
518 | |
9294 | 519 Sample code (GPL, & untested) |
520 | |
521 typedef BufferContext{ | |
522 uint8_t *buf; | |
523 uint8_t *buf_ptr; | |
524 }BufferContext; | |
525 | |
526 static inline uint64_t get_bytes(BufferContext *bc, int count){ | |
527 uint64_t val=0; | |
528 | |
529 assert(count>0 && count<9) | |
530 | |
531 for(i=0; i<count; i++){ | |
532 val <<=8; | |
533 val += *(bc->buf_ptr++); | |
534 } | |
535 | |
536 return val; | |
537 } | |
538 | |
539 static inline void put_bytes(BufferContext *bc, int count, uint64_t val){ | |
540 uint64_t val=0; | |
541 | |
542 assert(count>0 && count<9) | |
543 | |
544 for(i=count-1; i>=0; i--){ | |
545 *(bc->buf_ptr++)= val >> (8*i); | |
546 } | |
547 | |
548 return val; | |
549 } | |
550 | |
10061 | 551 static inline uint64_t get_v(BufferContext *bc){ |
9294 | 552 uint64_t val= 0; |
553 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
554 for(; space_left(bc) > 0; ){ |
9294 | 555 int tmp= *(bc->buf_ptr++); |
556 if(tmp&0x80) | |
557 val= (val<<7) + tmp - 0x80; | |
558 else | |
9299 | 559 return (val<<7) + tmp; |
9294 | 560 } |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
561 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
562 return -1; |
9294 | 563 } |
564 | |
10061 | 565 static inline int put_v(BufferContext *bc, uint64_t val){ |
9294 | 566 int i; |
567 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
568 if(space_left(bc) < 9) return -1; |
9294 | 569 |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
570 val &= 0x7FFFFFFFFFFFFFFFULL; // FIXME can only encode upto 63 bits currently |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
571 for(i=7; ; i+=7){ |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
572 if(val>>i == 0) break; |
9294 | 573 } |
574 | |
10827 | 575 for(i-=7; i>0; i-=7){ |
9294 | 576 *(bc->buf_ptr++)= 0x80 | (val>>i); |
577 } | |
578 *(bc->buf_ptr++)= val&0x7F; | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
579 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
580 return 0; |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
581 } |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
582 |
9294 | 583 |
584 Example stream | |
585 | |
586 main header | |
587 video_stream_header (stream 0, video jpjp, timebase 30, lsb_timestamp_length=8) | |
588 video_stream_header (stream 1 subtitle usen, timebase 30, lsb_timestamp_length=8) | |
589 video_stream_header (stream 2 subtitle atde, timebase 30, lsb_timestamp_length=8) | |
590 audio_stream_header (stream 3, audio jpjp, timebase 1 , lsb_timestamp_length=8) | |
591 audio_stream_header (stream 4, audio usen, timebase 1 , lsb_timestamp_length=8) | |
592 index (stream 0) | |
593 keyframe (stream 0, msb_timestamp=0, lsb_timestamp=0) | |
594 keyframe (stream 1, msb_timestamp=0, lsb_timestamp=0) | |
595 keyframe (stream 2, msb_timestamp=0, lsb_timestamp=0) | |
596 keyframe (stream 3, msb_timestamp=0, lsb_timestamp=0) | |
597 keyframe (stream 4, msb_timestamp=0, lsb_timestamp=0) | |
598 frame (stream 0, lsb_timestamp=1) | |
599 frame (stream 0, lsb_timestamp=2) | |
600 ... | |
601 frame (stream 0, lsb_timestamp=30) | |
602 keyframe (stream 3, msb_timestamp=0, lsb_timestamp=1) | |
603 keyframe (stream 4, msb_timestamp=0, lsb_timestamp=1) | |
604 frame (stream 0, lsb_timestamp=31) | |
605 frame (stream 0, lsb_timestamp=32) | |
606 ... | |
607 frame (stream 0, lsb_timestamp=60) | |
608 frame (stream 1, lsb_timestamp=60) | |
609 frame (stream 2, lsb_timestamp=60) | |
610 keyframe (stream 3, msb_timestamp=0, lsb_timestamp=2) | |
611 keyframe (stream 4, msb_timestamp=0, lsb_timestamp=2) | |
612 frame (stream 0, lsb_timestamp=61) | |
613 frame (stream 0, lsb_timestamp=62) | |
614 ... | |
615 main header | |
616 video_stream_header (stream 0, video jpjp, timebase 30, lsb_timestamp_length=8) | |
617 video_stream_header (stream 1 subtitle usen, timebase 30, lsb_timestamp_length=8) | |
618 video_stream_header (stream 2 subtitle atde, timebase 30, lsb_timestamp_length=8) | |
619 audio_stream_header (stream 3, audio jpjp, timebase 1 , lsb_timestamp_length=8) | |
620 audio_stream_header (stream 4, audio usen, timebase 1 , lsb_timestamp_length=8) | |
621 frame (stream 0, lsb_timestamp=255) | |
622 frame (stream 0, msb_timestamp=1 lsb_timestamp=0) | |
623 frame (stream 0, lsb_timestamp=1) | |
624 frame (stream 0, lsb_timestamp=2) | |
625 frame (stream 1, msb_timestamp=1 lsb_timestamp=2) | |
626 frame (stream 2, msb_timestamp=1 lsb_timestamp=2) | |
627 frame (stream 0, lsb_timestamp=3) | |
628 frame (stream 0, lsb_timestamp=4) | |
629 ... | |
630 keyframe (stream 3, msb_timestamp=0, lsb_timestamp=9) | |
631 keyframe (stream 4, msb_timestamp=0, lsb_timestamp=9) | |
632 main header | |
633 video_stream_header (stream 0, video jpjp, timebase 30, lsb_timestamp_length=8) | |
634 video_stream_header (stream 1 subtitle usen, timebase 30, lsb_timestamp_length=8) | |
635 video_stream_header (stream 2 subtitle atde, timebase 30, lsb_timestamp_length=8) | |
636 audio_stream_header (stream 3, audio jpjp, timebase 1 , lsb_timestamp_length=8) | |
637 audio_stream_header (stream 4, audio usen, timebase 1 , lsb_timestamp_length=8) | |
638 index (stream 0) | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
639 |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
640 Authors |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
641 |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
642 Folks from MPlayer Developers Mailinglist (http://www.mplayehrq.hu/). |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
643 Authors in ABC-order: (FIXME! Tell us if we left you out) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
644 Beregszaszi, Alex (alex@fsn.hu) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
645 Bunkus, Moritz (moritz@bunkus.org) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
646 Diedrich, Tobias (td@sim.uni-hannover.de) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
647 Franz, Fabian (FabianFranz@gmx.de) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
648 Gereoffy, Arpad (arpi@thot.banki.hu) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
649 Hess, Andreas (jaska@gmx.net) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
650 Niedermayer, Michael (michaelni@gmx.at) |