Mercurial > mplayer.hg
annotate DOCS/tech/mncf.txt @ 15569:dff7e79b194f
quicktime fix update
- check for existence of sh->ImageDesc instead of h263 fourcc
- honor -lavdopts lowres
author | henry |
---|---|
date | Wed, 25 May 2005 16:29:53 +0000 |
parents | 9b55ea3879ef |
children | b1b06adc5cd3 |
rev | line source |
---|---|
13559 | 1 NUT Open Container Format DRAFT 20041005 (Michael's experimental fork) |
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 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
26 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
|
27 resyncing times |
9294 | 28 |
29 | |
30 | |
31 Definitions: | |
32 | |
33 MUST the specific part must be done to conform to this standard | |
34 SHOULD its recommanded to be done that way but its not strictly required | |
35 | |
36 | |
37 | |
38 Syntax: | |
39 | |
9295 | 40 Type definitions: |
12209 | 41 |
13047 | 42 f(x) n fixed bits in big-endian order |
12209 | 43 u(x) unsigned number encoded in x bits in MSB first order |
44 | |
9295 | 45 v |
46 value=0 | |
47 do{ | |
48 more_data u(1) | |
49 data u(7) | |
50 value= 128*value + data | |
51 }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
|
52 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
53 s |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
54 temp v |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
55 temp++ |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
56 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
|
57 else value= (temp>>1) |
9323 | 58 |
59 b (binary data or string) | |
60 for(i=0; i<length; i++){ | |
61 data[i] u(8) | |
9295 | 62 } |
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
|
63 Note: strings MUST be encoded in utf8 |
9295 | 64 |
12117 | 65 vb |
66 length v | |
67 value b | |
68 | |
9295 | 69 |
70 Bitstream syntax: | |
9294 | 71 packet header |
12084
68baf8877c07
reversing the change to the forw/backw pointers, its somewhat simpler to update it if the forward pointer is first
michael
parents:
12082
diff
changeset
|
72 forward ptr v |
9294 | 73 |
74 align_byte | |
75 while(not byte aligned) | |
76 one f(1) | |
77 | |
78 reserved_bytes | |
79 for(i=0; i<forward_ptr - length_of_non_reserved; i++) | |
80 reserved u(8) | |
12184 | 81 a demuxer MUST ignore any reserved bytes |
82 a muxer MUST NOT write any reserved bytes, as this would make it | |
10824 | 83 inpossible to add new fields at the end of packets in the future in |
84 a compatible way | |
85 | |
9294 | 86 main header: |
10831 | 87 main_startcode f(64) |
9294 | 88 packet header |
13561 | 89 branch v |
9294 | 90 version v |
91 stream_count v | |
12333 | 92 max_distance v |
13563 | 93 max_index_distance v |
12413 | 94 global_time_base_nom v |
95 global_time_base_denom v | |
12084
68baf8877c07
reversing the change to the forw/backw pointers, its somewhat simpler to update it if the forward pointer is first
michael
parents:
12082
diff
changeset
|
96 for(i=0; i<256; ){ |
68baf8877c07
reversing the change to the forw/backw pointers, its somewhat simpler to update it if the forward pointer is first
michael
parents:
12082
diff
changeset
|
97 tmp_flag v |
12428 | 98 tmp_fields v |
99 if(tmp_fields>0) tmp_timestamp s | |
100 if(tmp_fields>1) tmp_mul v | |
101 if(tmp_fields>2) tmp_stream v | |
102 if(tmp_fields>3) tmp_size v | |
103 else tmp_size=0 | |
104 if(tmp_fields>4) tmp_res v | |
105 else tmp_res=0 | |
106 if(tmp_fields>5) count v | |
107 else count= tmp_mul - tmp_size | |
108 for(j=6; j<tmp_fields; j++){ | |
109 tmp_reserved[i] v | |
110 } | |
111 for(j=0; j<count && i<256; j++, i++){ | |
12084
68baf8877c07
reversing the change to the forw/backw pointers, its somewhat simpler to update it if the forward pointer is first
michael
parents:
12082
diff
changeset
|
112 flags[i]= tmp_flag; |
68baf8877c07
reversing the change to the forw/backw pointers, its somewhat simpler to update it if the forward pointer is first
michael
parents:
12082
diff
changeset
|
113 stream_id_plus1[i]= tmp_stream; |
68baf8877c07
reversing the change to the forw/backw pointers, its somewhat simpler to update it if the forward pointer is first
michael
parents:
12082
diff
changeset
|
114 data_size_mul[i]= tmp_mul; |
12428 | 115 data_size_lsb[i]= tmp_size + j; |
12413 | 116 timestamp_delta[i]= tmp_timestamp; |
12501 | 117 reserved_count[i]= tmp_res; |
12082 | 118 } |
119 } | |
9294 | 120 reserved_bytes |
121 checksum u(32) | |
122 | |
123 stream_header: | |
10831 | 124 stream_startcode f(64) |
9294 | 125 packet_header |
126 stream_id v | |
127 stream_class v | |
12150 | 128 fourcc vb |
9294 | 129 average_bitrate v |
9297 | 130 time_base_nom v |
131 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
|
132 msb_timestamp_shift v |
12333 | 133 decode_delay v |
9294 | 134 fixed_fps u(1) |
9356 | 135 reserved u(6) |
13559 | 136 codec_specific_data vb |
9294 | 137 |
138 video_stream_header: | |
139 stream_header | |
140 width v | |
141 height v | |
142 sample_width v | |
143 sample_height v | |
144 colorspace_type v | |
145 reserved_bytes | |
146 checksum u(32) | |
147 | |
148 audio_stream_header: | |
149 stream_header | |
12333 | 150 samplerate_nom v |
151 samplerate_denom v | |
9294 | 152 channel_count v |
153 reserved_bytes | |
154 checksum u(32) | |
9420 | 155 |
12082 | 156 |
9294 | 157 frame |
12082 | 158 frame_code f(8) |
12084
68baf8877c07
reversing the change to the forw/backw pointers, its somewhat simpler to update it if the forward pointer is first
michael
parents:
12082
diff
changeset
|
159 if(stream_id_plus1[frame_code]==0){ |
12082 | 160 stream_id v |
161 } | |
12413 | 162 if(timestamp_delta[frame_code]==0){ |
12261 | 163 coded_timestamp v |
164 } | |
12413 | 165 if(flags[frame_code]&1){ |
12082 | 166 data_size_msb v |
167 } | |
12501 | 168 for(i=0; i<reserved_count[frame_code]; i++) |
12413 | 169 reserved v |
12082 | 170 data |
171 | |
9294 | 172 Index: |
10831 | 173 index_startcode f(64) |
9294 | 174 packet header |
13563 | 175 stream_id v |
9294 | 176 index_length v |
177 for(i=0; i<index_length; i++){ | |
178 index_timestamp v | |
179 index_position v | |
180 } | |
9310 | 181 reserved_bytes |
9294 | 182 checksum u(32) |
183 | |
13559 | 184 info_packet: (optional) |
10831 | 185 info_startcode f(64) |
9294 | 186 packet header |
9323 | 187 for(;;){ |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
188 id v |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
189 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
|
190 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
|
191 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
|
192 if(type==NULL) |
12117 | 193 type vb |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
194 if(name==NULL) |
12117 | 195 name vb |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
196 if(type=="v") |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
197 value v |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
198 else |
12117 | 199 value vb |
9323 | 200 } |
9310 | 201 reserved_bytes |
9294 | 202 checksum u(32) |
9323 | 203 |
12413 | 204 sync_point |
205 frame_startcode f(64) | |
206 global_timestamp v | |
207 | |
12242 | 208 file |
209 file_id_string | |
12502 | 210 while(!eof && next_code != index_startcode){ |
12242 | 211 main_header |
212 for(i=0; i<stream_count; i++){ | |
213 if(next_packet==video_stream_header) | |
214 video_stream_header | |
215 else | |
216 audio_stream_header | |
217 } | |
12413 | 218 while(next_code != main_startcode){ |
219 if(next_code == info_startcode) | |
12242 | 220 info_packet |
12368 | 221 else{ |
13560 | 222 if(next_code == frame_startcode) |
12413 | 223 sync_point |
12242 | 224 frame |
12368 | 225 } |
12242 | 226 } |
227 } | |
12502 | 228 index |
9323 | 229 |
9294 | 230 forward_ptr |
12238 | 231 size of the packet (exactly the distance from the first byte of the |
232 startcode of the current packet to the first byte of the following packet | |
12242 | 233 |
234 file_id_string | |
235 "nut/multimedia container\0" | |
9323 | 236 |
237 *_startcode | |
12162 | 238 all startcodes start with 'N' |
239 | |
240 main_startcode | |
241 0x7A561F5F04ADULL + (((uint64_t)('N'<<8) + 'M')<<48) | |
242 stream_starcode | |
243 0x11405BF2F9DBULL + (((uint64_t)('N'<<8) + 'S')<<48) | |
12333 | 244 frame_startcode |
12162 | 245 0xE4ADEECA4569ULL + (((uint64_t)('N'<<8) + 'K')<<48) |
12392 | 246 frame_startcodes SHOULD be placed immedeatly before a keyframe if the |
247 previous frame of the same stream was a non-keyframe, unless such | |
248 non-keyframe - keyframe tansitions are very frequent | |
12365
dc05db3f172f
additional start_code rule (implemenattion does this since a long time already)
michael
parents:
12333
diff
changeset
|
249 |
12162 | 250 index_startcode |
251 0xDD672F23E64EULL + (((uint64_t)('N'<<8) + 'X')<<48) | |
252 info_startcode | |
253 0xAB68B596BA78ULL + (((uint64_t)('N'<<8) + 'I')<<48) | |
9294 | 254 |
13561 | 255 branch |
256 1 for my fork, 0 for the official nut container | |
257 | |
9294 | 258 version |
12238 | 259 2 for now |
260 | |
12333 | 261 max_distance |
262 max distance of frame_startcodes, the distance may only be larger if | |
263 there is only a single frame between the 2 frame_startcodes | |
264 this can be used by the demuxer to detect damaged frame headers if the | |
265 damage results in a too long chain | |
12501 | 266 SHOULD be set to <=32768 or at least <=65536 unless there is a very good |
267 reason to set it higher otherwise reasonable error recovery will be | |
268 impossible | |
269 | |
13563 | 270 max_index_distance |
271 max distance of keyframes which are represented in the index, the | |
272 distance between consecutive entries A and B may only be larger if | |
273 there are no keyframes within this stream between A and B | |
274 SHOULD be set to <=32768 or at least <=65536 unless there is a very good | |
275 reason to set it higher | |
276 | |
9294 | 277 stream_id |
278 Note: streams with a lower relative class MUST have a lower relative id | |
279 so a stream with class 0 MUST allways have a id which is lower then any | |
280 stream with class > 0 | |
12150 | 281 stream_id MUST be < stream_count |
9294 | 282 |
283 stream_class | |
284 0 video | |
285 32 audio | |
286 64 subtiles | |
287 Note the remaining values are reserved and MUST NOT be used | |
12184 | 288 a demuxer MUST ignore streams with reserved classes |
9294 | 289 |
290 fourcc | |
291 identification for the codec | |
9323 | 292 example: "H264" |
10817 | 293 MUST contain 2 or 4 bytes, note, this might be increased in the future |
294 if needed | |
9294 | 295 |
9297 | 296 time_base_nom / time_base_denom = time_base |
9294 | 297 the number of timer ticks per second, this MUST be equal to the fps |
298 if the fixed_fps is 1 | |
9297 | 299 time_base_denom MUST not be 0 |
300 time_base_nom and time_base_denom MUST be relative prime | |
12254 | 301 time_base_nom MUST be < 2^31 |
9297 | 302 examples: |
303 fps time_base_nom time_base_denom | |
304 30 30 1 | |
305 29.97 30000 1001 | |
306 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
|
307 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
|
308 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
|
309 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
|
310 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
|
311 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
|
312 timestamps need fewer bits |
9294 | 313 |
12413 | 314 global_time_base_nom / global_time_base_denom = global_time_base |
315 the number of timer ticks per second | |
316 global_time_base_denom MUST not be 0 | |
317 global_time_base_nom and global_time_base_denom MUST be relative prime | |
318 global_time_base_nom MUST be < 2^31 | |
319 | |
320 global_timestamp | |
321 timestamp in global_time_base units | |
322 when a global_timestamp is encountered the last_timestamp of all streams | |
323 is set to the following: | |
324 ln= global_time_base_denom*time_base_nom | |
325 sn= global_timestamp | |
326 d1= global_time_base_nom | |
327 d2= time_base_denom | |
328 last_timestamp= (ln/d1*sn + ln%d1*sn/d1)/d2 | |
329 Note, this calculation MUST be done with unsigned 64 bit integers, and | |
330 is equivalent to (ln*sn)/(d1*d2) but this would require a 96bit integer | |
331 | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
332 msb_timestamp_shift |
12261 | 333 amount of bits in lsb_timestamp |
9294 | 334 MUST be <16 |
335 | |
12333 | 336 decode_delay |
337 maximum time between input and output for a codec, used to generate dts | |
338 from pts | |
339 is 0 for streams without b frames, and 1 for streams with b frames, may | |
340 be larger for future codecs | |
341 | |
9294 | 342 fixed_fps |
343 1 indicates that the fps is fixed | |
344 | |
9356 | 345 codec_specific_data |
346 private global data for a codec (could be huffman tables or ...) | |
12082 | 347 |
348 frame_code | |
349 the meaning of this byte is stored in the main header | |
350 the value 78 ('N') is forbidden to ensure that the byte is always | |
351 different from the first byte of any startcode | |
9420 | 352 |
12082 | 353 flags[frame_code] |
12413 | 354 the bits of the flags from MSB to LSB are KD |
12261 | 355 if D is 1 then data_size_msb is coded, otherwise data_size_msb is 0 |
12238 | 356 K is the keyframe_type |
357 0-> no keyframe, | |
358 1-> keyframe, | |
12413 | 359 flags=4 can be used to mark illegal frame_code bytes |
360 frame_code=78 must have flags=4 | |
12333 | 361 * frames MUST not depend(1) upon frames prior to the last |
362 frame_startcode | |
12110
a34dc5a369ca
restrictions to ensure that O(log n) seeking and error recovery is possible
michael
parents:
12084
diff
changeset
|
363 depend(1) means dependancy on the container level (NUT) not dependancy |
a34dc5a369ca
restrictions to ensure that O(log n) seeking and error recovery is possible
michael
parents:
12084
diff
changeset
|
364 on the codec level |
a34dc5a369ca
restrictions to ensure that O(log n) seeking and error recovery is possible
michael
parents:
12084
diff
changeset
|
365 |
12084
68baf8877c07
reversing the change to the forw/backw pointers, its somewhat simpler to update it if the forward pointer is first
michael
parents:
12082
diff
changeset
|
366 stream_id_plus1[frame_code] |
12082 | 367 must be <250 |
12084
68baf8877c07
reversing the change to the forw/backw pointers, its somewhat simpler to update it if the forward pointer is first
michael
parents:
12082
diff
changeset
|
368 if its 0 then the stream_id is coded in the frame |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
369 |
12082 | 370 data_size_mul[frame_code] |
12379
4100528fadf1
limits too small, my CBR mp3 samples have 2x overhead after removial of size prediction
michael
parents:
12368
diff
changeset
|
371 must be <16384 |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
372 |
12082 | 373 data_size_lsb[frame_code] |
12379
4100528fadf1
limits too small, my CBR mp3 samples have 2x overhead after removial of size prediction
michael
parents:
12368
diff
changeset
|
374 must be <16384 |
12082 | 375 |
12413 | 376 timestamp_delta[frame_code] |
377 must be <16384 and >-16384 | |
378 | |
12084
68baf8877c07
reversing the change to the forw/backw pointers, its somewhat simpler to update it if the forward pointer is first
michael
parents:
12082
diff
changeset
|
379 data_size |
12261 | 380 data_size= data_size_lsb + data_size_msb*data_size_mul; |
12082 | 381 |
12261 | 382 coded_timestamp |
383 if coded_timestamp < (1<<msb_timestamp_shift) then its a | |
384 lsb timestamp, otherwise its a full timestamp + (1<<msb_timestamp_shift) | |
385 lsb timestamps are converted to full timesamps by: | |
386 mask = (1<<msb_timestamp_shift)-1; | |
387 delta= last_timestamp - mask/2 | |
388 timestamp= ((timestamp_lsb-delta)&mask) + delta | |
12333 | 389 a full timestamp must be used if there is no reference timestamp |
390 available after the last frame_startcode with the current stream_id | |
12261 | 391 |
9294 | 392 lsb_timestamp |
12082 | 393 least significant bits of the timestamp in time_base precission |
9294 | 394 Example: IBBP display order |
12084
68baf8877c07
reversing the change to the forw/backw pointers, its somewhat simpler to update it if the forward pointer is first
michael
parents:
12082
diff
changeset
|
395 keyframe timestamp=0 -> timestamp=0 |
9294 | 396 frame lsb_timestamp=3 -> timestamp=3 |
397 frame lsb_timestamp=1 -> timestamp=1 | |
398 frame lsb_timestamp=2 -> timestamp=2 | |
399 ... | |
12084
68baf8877c07
reversing the change to the forw/backw pointers, its somewhat simpler to update it if the forward pointer is first
michael
parents:
12082
diff
changeset
|
400 keyframe msb_timestamp=257 -> timestamp=257 |
12082 | 401 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
|
402 frame lsb_timestamp=0 -> timestamp=256 |
9294 | 403 frame lsb_timestamp=4 -> timestamp=260 |
404 frame lsb_timestamp=2 -> timestamp=258 | |
405 frame lsb_timestamp=3 -> timestamp=259 | |
12110
a34dc5a369ca
restrictions to ensure that O(log n) seeking and error recovery is possible
michael
parents:
12084
diff
changeset
|
406 all timestamps of keyframes of a single stream MUST be monotone |
9294 | 407 |
12333 | 408 dts |
409 dts are calculated by using a decode_delay+1 sized buffer for each | |
410 stream, into which the current pts is inserted and the element with | |
411 the smallest value is removed, this is then the current dts | |
412 this buffer is initalized with decode_delay -1 elements | |
413 all frames with dts == timestamp must be monotone, that means a frame | |
414 which occures later in the stream must have a larger or equal dts | |
415 then an earlier frame | |
416 FIXME rename timestamp* to pts* ? | |
417 | |
9294 | 418 width/height |
419 MUST be set to the coded width/height | |
420 | |
421 sample_width/sample_height (aspect ratio) | |
422 sample_width is the horizontal distance between samples | |
423 sample_width and sample_height MUST be relative prime if not zero | |
424 MUST be 0 if unknown | |
425 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
426 colorspace_type |
10166 | 427 0 unknown |
428 1 ITU Rec 624 / ITU Rec 601 Y range: 16..235 Cb/Cr range: 16..240 | |
429 2 ITU Rec 709 Y range: 16..235 Cb/Cr range: 16..240 | |
430 17 ITU Rec 624 / ITU Rec 601 Y range: 0..255 Cb/Cr range: 0..255 | |
431 18 ITU Rec 709 Y range: 0..255 Cb/Cr range: 0..255 | |
432 | |
12333 | 433 samplerate_nom / samplerate_denom = samplerate |
434 the number of samples per second | |
9294 | 435 |
436 checksum | |
12118
b8fea9441d02
switching from crc32 to adler32 checksums, cuz they are faster and simpler
michael
parents:
12117
diff
changeset
|
437 adler32 checksum |
9294 | 438 |
439 index_timestamp | |
13563 | 440 value of the timetamp of a keyframe relative to the last keyframe |
441 stored in this index | |
9294 | 442 |
443 index_position | |
13563 | 444 position in bytes of the first byte of a keyframe, relative to the |
445 last keyframe stored in this index | |
446 there MUST be no keyframe with the same stream_id as this index between | |
447 2 consecutive index entries if they are more then max_index_distance | |
448 appart | |
9294 | 449 |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
450 id |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
451 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
|
452 0 means end |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
453 |
9323 | 454 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
|
455 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
|
456 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
|
457 Note: MUST be less than 6 byte long (might be increased to 64 later) |
9323 | 458 |
13559 | 459 name |
9295 | 460 the name of the info entry, valid names are |
13559 | 461 "TotalTime" total length of the stream in msecs |
462 "StreamId" the stream(s) to which the info packet applies | |
463 "StartTimestamp" | |
464 "EndTimestamp" the time range in msecs to which the info applies | |
465 "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
|
466 "Author" |
97888c25ae60
changing name to "nut" for now, we can change it again if we agree on something else
michael
parents:
9335
diff
changeset
|
467 "Description" |
97888c25ae60
changing name to "nut" for now, we can change it again if we agree on something else
michael
parents:
9335
diff
changeset
|
468 "Copyright" |
9369 | 469 "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
|
470 "Title" |
9373 | 471 "Cover" an image of the (cd,dvd,vhs,..) cover (preferable PNG or JPEG) |
9350 | 472 "Source" "DVD", "VCD", "CD", "MD", "FM radio", "VHS", "TV", |
473 "LD" | |
9373 | 474 Optional: appended PAL,NTSC,SECAM, ... in parentheses |
9350 | 475 "CaptureDevice" "BT878", "BT848", "webcam", ... (more exact names are fine too) |
476 "CreationTime" "2003-01-20 20:13:15Z", ... | |
477 (ISO 8601 format, see http://www.cl.cam.ac.uk/~mgk25/iso-time.html) | |
478 Note: dont forget the timezone | |
13559 | 479 "ReplayGain" |
13308
8ff17d153414
info packet is now file global, while meta pakcet is stream specific, as discussed with Rich
alex
parents:
13047
diff
changeset
|
480 "Keywords" |
13559 | 481 "Language" ISO 639 and ISO 3166 for language/country code |
482 something like "usen" (US english), can be 0 if unknown | |
483 and "multi" if several languages | |
484 see http://www.loc.gov/standards/iso639-2/englangn.html | |
485 and http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1/en_listp1.htmlthe language code | |
12503 | 486 "Disposition" "original", "dub" (translated), "comment", "lyrics", "karaoke" |
9295 | 487 Note: if someone needs some others, please tell us about them, so we can |
488 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
|
489 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
|
490 Note: MUST be less than 64 bytes long |
9295 | 491 |
492 value | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
493 value of this name/type pair |
9295 | 494 |
9310 | 495 stuffing |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
496 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
|
497 purposes |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
498 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
499 info_table[][2]={ |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
500 {NULL , NULL }, // end |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
501 {NULL , NULL }, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
502 {NULL , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
503 {NULL , "v"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
504 {NULL , "s"}, |
13559 | 505 {"StreamId" , "v"}, |
506 {"SegmentId" , "v"}, | |
507 {"StartTimestamp" , "v"}, | |
508 {"EndTimestamp" , "v"}, | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
509 {"Author" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
510 {"Titel" , "UTF8"}, |
13559 | 511 {"Language" , "UTF8"}, |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
512 {"Description" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
513 {"Copyright" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
514 {"Encoder" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
515 {"Keyword" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
516 {"Cover" , "JPEG"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
517 {"Cover" , "PNG"}, |
13559 | 518 {"Disposition" , "UTF8"}, |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
519 }; |
9294 | 520 |
521 Structure: | |
522 | |
523 the headers MUST be in exactly the following order (to simplify demuxer design) | |
524 main header | |
525 stream_header (id=0) | |
526 stream_header (id=1) | |
527 ... | |
528 stream_header (id=n) | |
529 | |
530 headers may be repated, but if they are then they MUST all be repeated together | |
531 and repeated headers MUST be identical | |
12501 | 532 headers MAY only repeated at the closest possible positions after 2^x where x is |
533 an integer and the file end, so the headers may be repeated at 4102 if thats the | |
534 closest possition after 2^12=4096 at which the headers can be placed | |
9294 | 535 |
12501 | 536 headers MUST be placed at least at the begin of the file and immedeatly before |
537 the index or at the file end if there is no index | |
9310 | 538 headers MUST be repeated at least twice (so they exist 3 times in a file) |
9295 | 539 |
12501 | 540 a demuxer MUST not demux a stream which contains more than one stream, or which |
541 is wrapped in a structure to facilitate more than one stream or otherwise | |
542 duplicate the role of a container. any such file is to be considered invalid | |
543 | |
12503 | 544 info packets which describe the whole file or individual streams/tracks must be |
545 placed before any video/audio/... frames | |
546 | |
9310 | 547 Index |
9311
4b04416ada91
zero_bit for normal frames, so we can distinguish them from other packets
michael
parents:
9310
diff
changeset
|
548 Note: in case of realtime streaming there is no end, so no index there either |
9310 | 549 |
550 Info packets | |
551 the info_packet can be repeated, it can also contain different names & values | |
552 each time but only if allso the time is different | |
553 Info packets can be used to describe the file or some part of it (chapters) | |
554 | |
555 info packets, SHOULD be placed at the begin of the file at least | |
556 for realtime streaming info packets will normally be transmitted when they apply | |
557 for example, the current song title & artist of the currently shown music video | |
558 | |
559 Unknown packets | |
12184 | 560 MUST be ignored by the demuxer |
9310 | 561 |
12501 | 562 demuxer (non-normative) |
563 | |
564 in the absence of valid header at beginning, players SHOULD search for backup | |
565 headers starting at offset 2^x for each x players SHOULD end their search from a | |
566 particular offset when any startcode is found (including syncpoint) | |
567 | |
568 | |
9294 | 569 Sample code (GPL, & untested) |
570 | |
571 typedef BufferContext{ | |
572 uint8_t *buf; | |
573 uint8_t *buf_ptr; | |
574 }BufferContext; | |
575 | |
576 static inline uint64_t get_bytes(BufferContext *bc, int count){ | |
577 uint64_t val=0; | |
578 | |
579 assert(count>0 && count<9) | |
580 | |
581 for(i=0; i<count; i++){ | |
582 val <<=8; | |
583 val += *(bc->buf_ptr++); | |
584 } | |
585 | |
586 return val; | |
587 } | |
588 | |
589 static inline void put_bytes(BufferContext *bc, int count, uint64_t val){ | |
590 uint64_t val=0; | |
591 | |
592 assert(count>0 && count<9) | |
593 | |
594 for(i=count-1; i>=0; i--){ | |
595 *(bc->buf_ptr++)= val >> (8*i); | |
596 } | |
597 | |
598 return val; | |
599 } | |
600 | |
10061 | 601 static inline uint64_t get_v(BufferContext *bc){ |
9294 | 602 uint64_t val= 0; |
603 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
604 for(; space_left(bc) > 0; ){ |
9294 | 605 int tmp= *(bc->buf_ptr++); |
606 if(tmp&0x80) | |
607 val= (val<<7) + tmp - 0x80; | |
608 else | |
9299 | 609 return (val<<7) + tmp; |
9294 | 610 } |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
611 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
612 return -1; |
9294 | 613 } |
614 | |
10061 | 615 static inline int put_v(BufferContext *bc, uint64_t val){ |
9294 | 616 int i; |
617 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
618 if(space_left(bc) < 9) return -1; |
9294 | 619 |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
620 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
|
621 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
|
622 if(val>>i == 0) break; |
9294 | 623 } |
624 | |
10827 | 625 for(i-=7; i>0; i-=7){ |
9294 | 626 *(bc->buf_ptr++)= 0x80 | (val>>i); |
627 } | |
628 *(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
|
629 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
630 return 0; |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
631 } |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
632 |
12333 | 633 static int64_t get_dts(int64_t pts, int64_t *pts_cache, int delay, int reset){ |
634 if(reset) memset(pts_cache, -1, delay*sizeof(int64_t)); | |
635 | |
636 while(delay--){ | |
637 int64_t t= pts_cache[delay]; | |
638 if(t < pts){ | |
639 pts_cache[delay]= pts; | |
640 pts= t; | |
641 } | |
642 } | |
643 | |
644 return pts; | |
645 } | |
646 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
647 Authors |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
648 |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
649 Folks from MPlayer Developers Mailinglist (http://www.mplayehrq.hu/). |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
650 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
|
651 Beregszaszi, Alex (alex@fsn.hu) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
652 Bunkus, Moritz (moritz@bunkus.org) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
653 Diedrich, Tobias (td@sim.uni-hannover.de) |
12297 | 654 Felker, Rich (dalias@aerifal.cx) |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
655 Franz, Fabian (FabianFranz@gmx.de) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
656 Gereoffy, Arpad (arpi@thot.banki.hu) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
657 Hess, Andreas (jaska@gmx.net) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
658 Niedermayer, Michael (michaelni@gmx.at) |