Mercurial > mplayer.hg
annotate DOCS/tech/mpcf.txt @ 16511:3a24be1b0a60
remove info frame repeating its problematic and controversical
author | michael |
---|---|
date | Sat, 17 Sep 2005 22:32:35 +0000 |
parents | 1e42b8be5b7f |
children | c80f6f322350 |
rev | line source |
---|---|
16429 | 1 NUT Open Container Format DRAFT 20050909 |
10817 | 2 ---------------------------------------- |
9294 | 3 |
4 | |
5 | |
6 Intro: | |
7 | |
8 Features / goals: | |
16428 | 9 (supported by the format, not necessarily by a specific implementation) |
9294 | 10 |
11 Simple | |
12 use the same encoding for nearly all fields | |
16428 | 13 simple decoding, so slow CPUs (and embedded systems) can handle it |
9294 | 14 Extendible |
16428 | 15 no limit for the possible values of all fields (using universal vlc) |
9294 | 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) | |
16428 | 21 a usual header for a file is about 100 bytes (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 | |
16428 | 26 damaged files can be played back with minimal data loss and fast |
27 resync times | |
9294 | 28 |
29 | |
30 Definitions: | |
31 | |
32 MUST the specific part must be done to conform to this standard | |
16428 | 33 SHOULD it is recommended to be done that way, but not strictly required |
9294 | 34 |
35 | |
36 | |
37 Syntax: | |
38 | |
16428 | 39 Since NUT heavily uses variable length fields, the simplest way to describe it |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
40 is using a pseudocode approach. |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
41 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
42 Conventions: |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
43 |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
44 The data types have a name, used in the bitstream syntax description, a short |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
45 text description and a pseudocode (functional) definition, optional notes may |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
46 follow: |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
47 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
48 name (text description) |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
49 functional definition |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
50 [Optional notes] |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
51 |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
52 The bitstream syntax elements have a tagname and a functional definition, they |
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
53 are presented in a bottom up approach, again optional notes may follow and |
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
54 are reproduced in the tag description: |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
55 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
56 name: (optional note) |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
57 functional definition |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
58 [Optional notes] |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
59 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
60 The in-depth tag description follows the bitstream syntax. |
16428 | 61 The functional definition has a C-like syntax. |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
62 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
63 |
9295 | 64 Type definitions: |
12209 | 65 |
66 | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
67 f(n) (n fixed bits in big-endian order) |
16428 | 68 u(n) (unsigned number encoded in n bits in MSB-first order) |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
69 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
70 v (variable length value, unsigned) |
9295 | 71 value=0 |
72 do{ | |
73 more_data u(1) | |
74 data u(7) | |
75 value= 128*value + data | |
76 }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
|
77 |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
78 s (variable length value, signed) |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
79 temp v |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
80 temp++ |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
81 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
|
82 else value= (temp>>1) |
9323 | 83 |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
84 b (binary data or string, to be use in vb, see below) |
9323 | 85 for(i=0; i<length; i++){ |
86 data[i] u(8) | |
9295 | 87 } |
16428 | 88 [Note: strings MUST be encoded in UTF-8] |
9295 | 89 |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
90 vb (variable length binary data or string) |
12117 | 91 length v |
92 value b | |
93 | |
9295 | 94 |
95 Bitstream syntax: | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
96 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
97 Common elements: |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
98 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
99 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
|
100 forward ptr v |
9294 | 101 |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
102 align_byte: |
9294 | 103 while(not byte aligned) |
104 one f(1) | |
105 | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
106 reserved_bytes: |
9294 | 107 for(i=0; i<forward_ptr - length_of_non_reserved; i++) |
108 reserved u(8) | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
109 [a demuxer MUST ignore any reserved bytes |
12184 | 110 a muxer MUST NOT write any reserved bytes, as this would make it |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
111 impossible to add new fields at the end of packets in the future in |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
112 a compatible way] |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
113 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
114 Headers: |
10824 | 115 |
9294 | 116 main header: |
10831 | 117 main_startcode f(64) |
9294 | 118 packet header |
119 version v | |
120 stream_count v | |
12333 | 121 max_distance v |
14919
1d4861b2ac4a
returning to the old index at the end system, alternatives are too complex with questionable advantages
michael
parents:
14911
diff
changeset
|
122 max_index_distance v |
12413 | 123 global_time_base_nom v |
124 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
|
125 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
|
126 tmp_flag v |
12428 | 127 tmp_fields v |
16429 | 128 if(tmp_fields>0) tmp_pts s |
12428 | 129 if(tmp_fields>1) tmp_mul v |
130 if(tmp_fields>2) tmp_stream v | |
131 if(tmp_fields>3) tmp_size v | |
132 else tmp_size=0 | |
133 if(tmp_fields>4) tmp_res v | |
134 else tmp_res=0 | |
135 if(tmp_fields>5) count v | |
136 else count= tmp_mul - tmp_size | |
137 for(j=6; j<tmp_fields; j++){ | |
138 tmp_reserved[i] v | |
139 } | |
140 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
|
141 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
|
142 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
|
143 data_size_mul[i]= tmp_mul; |
12428 | 144 data_size_lsb[i]= tmp_size + j; |
16429 | 145 pts_delta[i]= tmp_pts; |
12501 | 146 reserved_count[i]= tmp_res; |
12082 | 147 } |
148 } | |
9294 | 149 reserved_bytes |
150 checksum u(32) | |
151 | |
152 stream_header: | |
10831 | 153 stream_startcode f(64) |
9294 | 154 packet_header |
155 stream_id v | |
156 stream_class v | |
12150 | 157 fourcc vb |
9297 | 158 time_base_nom v |
159 time_base_denom v | |
16429 | 160 msb_pts_shift v |
12333 | 161 decode_delay v |
9294 | 162 fixed_fps u(1) |
16503 | 163 reserved u(7) |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
164 codec_specific_data vb |
9294 | 165 |
166 video_stream_header: | |
167 stream_header | |
168 width v | |
169 height v | |
170 sample_width v | |
171 sample_height v | |
172 colorspace_type v | |
173 reserved_bytes | |
174 checksum u(32) | |
175 | |
176 audio_stream_header: | |
177 stream_header | |
12333 | 178 samplerate_nom v |
179 samplerate_denom v | |
9294 | 180 channel_count v |
181 reserved_bytes | |
182 checksum u(32) | |
9420 | 183 |
16429 | 184 other_stream_header: |
185 stream_header | |
186 reserved_bytes | |
187 checksum u(32) | |
188 | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
189 Basic Packets: |
12082 | 190 |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
191 frame: |
12082 | 192 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
|
193 if(stream_id_plus1[frame_code]==0){ |
12082 | 194 stream_id v |
195 } | |
16429 | 196 if(pts_delta[frame_code]==0){ |
197 coded_pts v | |
12261 | 198 } |
12413 | 199 if(flags[frame_code]&1){ |
12082 | 200 data_size_msb v |
201 } | |
12501 | 202 for(i=0; i<reserved_count[frame_code]; i++) |
12413 | 203 reserved v |
12082 | 204 data |
205 | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
206 index: |
10831 | 207 index_startcode f(64) |
9294 | 208 packet header |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
209 stream_id v |
16429 | 210 max_pts v |
9294 | 211 index_length v |
212 for(i=0; i<index_length; i++){ | |
16429 | 213 index_pts v |
9294 | 214 index_position v |
215 } | |
9310 | 216 reserved_bytes |
9294 | 217 checksum u(32) |
218 | |
16506 | 219 info_frame: (optional) |
9323 | 220 for(;;){ |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
221 id v |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
222 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
|
223 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
|
224 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
|
225 if(type==NULL) |
12117 | 226 type vb |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
227 if(name==NULL) |
12117 | 228 name vb |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
229 if(type=="v") |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
230 value v |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
231 else |
12117 | 232 value vb |
9323 | 233 } |
9310 | 234 reserved_bytes |
9294 | 235 checksum u(32) |
16506 | 236 |
237 info_packet: (optional) | |
238 info_startcode f(64) | |
239 packet header | |
240 info_frame | |
241 | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
242 sync_point: |
12413 | 243 frame_startcode f(64) |
16506 | 244 global_timestamp v |
245 back_ptr v | |
12413 | 246 |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
247 Complete definition: |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
248 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
249 file: |
12242 | 250 file_id_string |
14919
1d4861b2ac4a
returning to the old index at the end system, alternatives are too complex with questionable advantages
michael
parents:
14911
diff
changeset
|
251 while(!eof && next_code != index_startcode){ |
12242 | 252 main_header |
253 for(i=0; i<stream_count; i++){ | |
254 if(next_packet==video_stream_header) | |
255 video_stream_header | |
16429 | 256 else if(next_packet==audio_stream_header) |
257 audio_stream_header | |
12242 | 258 else |
16429 | 259 other_stream_header |
12242 | 260 } |
16506 | 261 while(next_code == info_startcode){ |
262 info_packet | |
263 } | |
12413 | 264 while(next_code != main_startcode){ |
16506 | 265 if(next_code == frame_startcode) |
266 sync_point | |
267 frame | |
12242 | 268 } |
269 } | |
16429 | 270 if (next_code == index_startcode){ |
271 while(!eof){ | |
272 index | |
273 } | |
274 index_ptr u(64) | |
275 } | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
276 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
277 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
278 Tag description: |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
279 |
9294 | 280 forward_ptr |
16429 | 281 size of the packet data (exactly the distance from the first byte |
282 after the forward_ptr to the first byte of the next packet) | |
12242 | 283 |
16506 | 284 back_ptr |
285 pointer to the latest syncpoint, for which there is at least one | |
286 keyframe prior to the global_timestamp in every stream | |
287 | |
12242 | 288 file_id_string |
289 "nut/multimedia container\0" | |
9323 | 290 |
291 *_startcode | |
12162 | 292 all startcodes start with 'N' |
293 | |
294 main_startcode | |
295 0x7A561F5F04ADULL + (((uint64_t)('N'<<8) + 'M')<<48) | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
296 |
12162 | 297 stream_starcode |
298 0x11405BF2F9DBULL + (((uint64_t)('N'<<8) + 'S')<<48) | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
299 |
12333 | 300 frame_startcode |
12162 | 301 0xE4ADEECA4569ULL + (((uint64_t)('N'<<8) + 'K')<<48) |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
302 |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
303 frame_startcodes SHOULD be placed immediately before a keyframe if the |
12392 | 304 previous frame of the same stream was a non-keyframe, unless such |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
305 non-keyframe - keyframe transitions are very frequent |
12365
dc05db3f172f
additional start_code rule (implemenattion does this since a long time already)
michael
parents:
12333
diff
changeset
|
306 |
12162 | 307 index_startcode |
308 0xDD672F23E64EULL + (((uint64_t)('N'<<8) + 'X')<<48) | |
309 info_startcode | |
310 0xAB68B596BA78ULL + (((uint64_t)('N'<<8) + 'I')<<48) | |
9294 | 311 |
312 version | |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
313 NUT version. The current value is 2. |
12238 | 314 |
12333 | 315 max_distance |
316 max distance of frame_startcodes, the distance may only be larger if | |
16428 | 317 there is only a single frame between the two frame_startcodes this can |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
318 be used by the demuxer to detect damaged frame headers if the damage |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
319 results in too long of a chain |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
320 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
321 SHOULD be set to <=32768 or at least <=65536 unless there is a very |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
322 good reason to set it higher, otherwise reasonable error recovery will |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
323 be impossible |
12501 | 324 |
14919
1d4861b2ac4a
returning to the old index at the end system, alternatives are too complex with questionable advantages
michael
parents:
14911
diff
changeset
|
325 max_index_distance |
1d4861b2ac4a
returning to the old index at the end system, alternatives are too complex with questionable advantages
michael
parents:
14911
diff
changeset
|
326 max distance of keyframes which are represented in the index, the |
1d4861b2ac4a
returning to the old index at the end system, alternatives are too complex with questionable advantages
michael
parents:
14911
diff
changeset
|
327 distance between consecutive entries A and B may only be larger if |
1d4861b2ac4a
returning to the old index at the end system, alternatives are too complex with questionable advantages
michael
parents:
14911
diff
changeset
|
328 there are no keyframes within this stream between A and B |
1d4861b2ac4a
returning to the old index at the end system, alternatives are too complex with questionable advantages
michael
parents:
14911
diff
changeset
|
329 SHOULD be set to <=32768 or at least <=65536 unless there is a very |
1d4861b2ac4a
returning to the old index at the end system, alternatives are too complex with questionable advantages
michael
parents:
14911
diff
changeset
|
330 good reason to set it higher |
12501 | 331 |
16429 | 332 stream_id |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
333 Stream identifier |
12150 | 334 stream_id MUST be < stream_count |
9294 | 335 |
336 stream_class | |
337 0 video | |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
338 1 audio |
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
339 2 subtiles |
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
340 3 metadata |
16506 | 341 4 userdata |
342 in metadata streams each frame contains exactly one info frame | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
343 Note: the remaining values are reserved and MUST NOT be used |
12184 | 344 a demuxer MUST ignore streams with reserved classes |
9294 | 345 |
346 fourcc | |
347 identification for the codec | |
9323 | 348 example: "H264" |
10817 | 349 MUST contain 2 or 4 bytes, note, this might be increased in the future |
350 if needed | |
9294 | 351 |
9297 | 352 time_base_nom / time_base_denom = time_base |
16429 | 353 the length of a timer tick in seconds, this MUST be equal to the 1/fps |
16428 | 354 if fixed_fps is 1 |
16429 | 355 time_base_nom and time_base_denom MUST NOT be 0 |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
356 time_base_nom and time_base_denom MUST be relatively prime |
16429 | 357 time_base_denom MUST be < 2^31 |
9297 | 358 examples: |
359 fps time_base_nom time_base_denom | |
16429 | 360 30 1 30 |
361 29.97 1001 30000 | |
362 23.976 1001 24000 | |
9294 | 363 |
12413 | 364 global_time_base_nom / global_time_base_denom = global_time_base |
16429 | 365 the length of a timer tick in seconds |
366 global_time_base_nom and global_time_base_denom MUST NOT be 0 | |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
367 global_time_base_nom and global_time_base_denom MUST be relatively prime |
16429 | 368 global_time_base_denom MUST be < 2^31 |
12413 | 369 |
370 global_timestamp | |
371 timestamp in global_time_base units | |
16429 | 372 when a global_timestamp is encountered the last_pts of all |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
373 streams is set to the following: |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
374 |
16429 | 375 ln= global_time_base_nom*time_base_denom |
12413 | 376 sn= global_timestamp |
16429 | 377 d1= global_time_base_denom |
378 d2= time_base_nom | |
379 last_pts= (ln/d1*sn + ln%d1*sn/d1)/d2 | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
380 Note: this calculation MUST be done with unsigned 64 bit integers, and |
12413 | 381 is equivalent to (ln*sn)/(d1*d2) but this would require a 96bit integer |
382 | |
16429 | 383 msb_pts_shift |
384 amount of bits in lsb_pts | |
9294 | 385 MUST be <16 |
386 | |
12333 | 387 decode_delay |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
388 maximum time between input and output for a codec, used to generate |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
389 dts from pts |
16428 | 390 is set to 0 for streams without B-frames, and set to 1 for streams with |
391 B-frames, may be larger for future codecs | |
12333 | 392 |
9294 | 393 fixed_fps |
394 1 indicates that the fps is fixed | |
395 | |
9356 | 396 codec_specific_data |
397 private global data for a codec (could be huffman tables or ...) | |
12082 | 398 |
399 frame_code | |
400 the meaning of this byte is stored in the main header | |
401 the value 78 ('N') is forbidden to ensure that the byte is always | |
402 different from the first byte of any startcode | |
9420 | 403 |
12082 | 404 flags[frame_code] |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
405 first of the flags from MSB to LSB are called KD |
12261 | 406 if D is 1 then data_size_msb is coded, otherwise data_size_msb is 0 |
12238 | 407 K is the keyframe_type |
408 0-> no keyframe, | |
409 1-> keyframe, | |
12413 | 410 flags=4 can be used to mark illegal frame_code bytes |
411 frame_code=78 must have flags=4 | |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
412 Note: frames MUST NOT depend(1) upon frames prior to the last |
12333 | 413 frame_startcode |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
414 Important: depend(1) means dependency on the container level (NUT) not |
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
415 dependency on the codec level |
12110
a34dc5a369ca
restrictions to ensure that O(log n) seeking and error recovery is possible
michael
parents:
12084
diff
changeset
|
416 |
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
|
417 stream_id_plus1[frame_code] |
12082 | 418 must be <250 |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
419 if it is 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
|
420 |
12082 | 421 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
|
422 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
|
423 |
12082 | 424 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
|
425 must be <16384 |
12082 | 426 |
16429 | 427 pts_delta[frame_code] |
12413 | 428 must be <16384 and >-16384 |
429 | |
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
|
430 data_size |
12261 | 431 data_size= data_size_lsb + data_size_msb*data_size_mul; |
12082 | 432 |
16429 | 433 coded_pts |
434 if coded_pts < (1<<msb_pts_shift) then it is an lsb | |
435 pts, otherwise it is a full pts + (1<<msb_pts_shift) | |
436 lsb pts is converted to a full pts by: | |
437 mask = (1<<msb_pts_shift)-1; | |
438 delta= last_pts - mask/2 | |
439 pts= ((pts_lsb-delta)&mask) + delta | |
12261 | 440 |
16429 | 441 lsb_pts |
442 least significant bits of the pts in time_base precision | |
9294 | 443 Example: IBBP display order |
16429 | 444 keyframe pts=0 -> pts=0 |
445 frame lsb_pts=3 -> pts=3 | |
446 frame lsb_pts=1 -> pts=1 | |
447 frame lsb_pts=2 -> pts=2 | |
9294 | 448 ... |
16429 | 449 keyframe msb_pts=257 -> pts=257 |
450 frame lsb_pts=255->pts=255 | |
451 frame lsb_pts=0 -> pts=256 | |
452 frame lsb_pts=4 -> pts=260 | |
453 frame lsb_pts=2 -> pts=258 | |
454 frame lsb_pts=3 -> pts=259 | |
455 all pts's of keyframes of a single stream MUST be monotone | |
9294 | 456 |
12333 | 457 dts |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
458 dts is calculated by using a decode_delay+1 sized buffer for each |
12333 | 459 stream, into which the current pts is inserted and the element with |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
460 the smallest value is removed, this is then the current dts |
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
461 this buffer is initalized with decode_delay -1 elements |
16511
3a24be1b0a60
remove info frame repeating its problematic and controversical
michael
parents:
16506
diff
changeset
|
462 all frames must be monotone, that means a frame |
16428 | 463 which occurs later in the stream must have a larger or equal dts |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
464 than an earlier frame |
12333 | 465 |
9294 | 466 width/height |
467 MUST be set to the coded width/height | |
468 | |
469 sample_width/sample_height (aspect ratio) | |
470 sample_width is the horizontal distance between samples | |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
471 sample_width and sample_height MUST be relatively prime if not zero |
9294 | 472 MUST be 0 if unknown |
473 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
474 colorspace_type |
10166 | 475 0 unknown |
476 1 ITU Rec 624 / ITU Rec 601 Y range: 16..235 Cb/Cr range: 16..240 | |
477 2 ITU Rec 709 Y range: 16..235 Cb/Cr range: 16..240 | |
478 17 ITU Rec 624 / ITU Rec 601 Y range: 0..255 Cb/Cr range: 0..255 | |
479 18 ITU Rec 709 Y range: 0..255 Cb/Cr range: 0..255 | |
480 | |
12333 | 481 samplerate_nom / samplerate_denom = samplerate |
482 the number of samples per second | |
9294 | 483 |
484 checksum | |
12118
b8fea9441d02
switching from crc32 to adler32 checksums, cuz they are faster and simpler
michael
parents:
12117
diff
changeset
|
485 adler32 checksum |
16429 | 486 checksum is calculated for the area pointed to by forward_ptr not |
487 including the checksum itself (from first byte after the | |
488 forward_ptr until last byte before the checksum). | |
9294 | 489 |
16429 | 490 max_pts |
491 The highest pts in the stream. | |
492 | |
493 index_pts | |
494 value of the pts of a keyframe relative to the last keyframe | |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
495 stored in this index |
9294 | 496 |
497 index_position | |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
498 position in bytes of the first byte of a keyframe, relative to the |
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
499 last keyframe stored in this index |
14919
1d4861b2ac4a
returning to the old index at the end system, alternatives are too complex with questionable advantages
michael
parents:
14911
diff
changeset
|
500 there MUST be no keyframe with the same stream_id as this index between |
16428 | 501 two consecutive index entries if they are more than max_index_distance |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
502 apart |
9294 | 503 |
16429 | 504 index_ptr |
505 Length in bytes from the first byte of the first index startcode | |
506 to the first byte of the index_ptr. If there is no index, index_ptr | |
507 MUST NOT be written. | |
508 | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
509 id |
16428 | 510 the ID of the type/name pair, so it is more compact |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
511 0 means end |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
512 |
9323 | 513 type |
16428 | 514 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
|
515 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
|
516 Note: MUST be less than 6 byte long (might be increased to 64 later) |
9323 | 517 |
13308
8ff17d153414
info packet is now file global, while meta pakcet is stream specific, as discussed with Rich
alex
parents:
13047
diff
changeset
|
518 info packet types |
9295 | 519 the name of the info entry, valid names are |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
520 "StreamId" the stream(s) to which the info packet applies |
13308
8ff17d153414
info packet is now file global, while meta pakcet is stream specific, as discussed with Rich
alex
parents:
13047
diff
changeset
|
521 |
9347
97888c25ae60
changing name to "nut" for now, we can change it again if we agree on something else
michael
parents:
9335
diff
changeset
|
522 "Author" |
97888c25ae60
changing name to "nut" for now, we can change it again if we agree on something else
michael
parents:
9335
diff
changeset
|
523 "Description" |
97888c25ae60
changing name to "nut" for now, we can change it again if we agree on something else
michael
parents:
9335
diff
changeset
|
524 "Copyright" |
9369 | 525 "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
|
526 "Title" |
16428 | 527 "Cover" an image of the (CD, DVD, VHS, ..) cover (preferably PNG or JPEG) |
9350 | 528 "Source" "DVD", "VCD", "CD", "MD", "FM radio", "VHS", "TV", |
529 "LD" | |
16428 | 530 Optional: appended PAL, NTSC, SECAM, ... in parentheses |
9350 | 531 "CaptureDevice" "BT878", "BT848", "webcam", ... (more exact names are fine too) |
532 "CreationTime" "2003-01-20 20:13:15Z", ... | |
533 (ISO 8601 format, see http://www.cl.cam.ac.uk/~mgk25/iso-time.html) | |
16428 | 534 Note: do not forget the timezone |
13308
8ff17d153414
info packet is now file global, while meta pakcet is stream specific, as discussed with Rich
alex
parents:
13047
diff
changeset
|
535 "Keywords" |
8ff17d153414
info packet is now file global, while meta pakcet is stream specific, as discussed with Rich
alex
parents:
13047
diff
changeset
|
536 "TotalTime" total length of the stream in msecs |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
537 "Language" ISO 639 and ISO 3166 for language/country code |
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
538 something like "eng" (US english), can be 0 if unknown |
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
539 and "multi" if several languages |
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
540 see http://www.loc.gov/standards/iso639-2/englangn.html |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
541 and http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1/en_listp1.html the language code |
12503 | 542 "Disposition" "original", "dub" (translated), "comment", "lyrics", "karaoke" |
9295 | 543 Note: if someone needs some others, please tell us about them, so we can |
544 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
|
545 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
|
546 Note: MUST be less than 64 bytes long |
9295 | 547 |
548 value | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
549 value of this name/type pair |
9295 | 550 |
9310 | 551 stuffing |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
552 0x80 can be placed in front of any type v entry for stuffing purposes |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
553 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
554 info_table[][2]={ |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
555 {NULL , NULL }, // end |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
556 {NULL , NULL }, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
557 {NULL , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
558 {NULL , "v"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
559 {NULL , "s"}, |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
560 {"StreamId" , "v"}, |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
561 {"Author" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
562 {"Titel" , "UTF8"}, |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
563 {"Language" , "UTF8"}, |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
564 {"Description" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
565 {"Copyright" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
566 {"Encoder" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
567 {"Keyword" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
568 {"Cover" , "JPEG"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
569 {"Cover" , "PNG"}, |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
570 {"Disposition" , "UTF8"}, |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
571 }; |
9294 | 572 |
573 Structure: | |
574 | |
575 the headers MUST be in exactly the following order (to simplify demuxer design) | |
576 main header | |
577 stream_header (id=0) | |
578 stream_header (id=1) | |
579 ... | |
580 stream_header (id=n) | |
581 | |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
582 headers may be repeated, but if they are, then they MUST all be repeated |
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
583 together and repeated headers MUST be identical |
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
584 headers MAY only repeat at the closest possible positions after 2^x where x is |
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
585 an integer and the file end, so the headers may be repeated at 4102 if that is |
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
586 the closest position after 2^12=4096 at which the headers can be placed |
9294 | 587 |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
588 headers MUST be placed at least at the start of the file and immediately before |
12501 | 589 the index or at the file end if there is no index |
16428 | 590 headers MUST be repeated at least twice (so they exist three times in a file) |
9295 | 591 |
16506 | 592 there MUST be a sync point immedeatly before the first frame after any headers |
12503 | 593 |
9310 | 594 Index |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
595 Note: with realtime streaming, there is no end, so no index there either |
16429 | 596 An index SHOULD be written for every stream. Indices MUST be placed at end |
597 of file. Indices MAY be repeated for a stream. | |
9310 | 598 |
16506 | 599 Info frames |
600 Info frames can be used to describe the file or some part of it (chapters) | |
9310 | 601 |
602 Unknown packets | |
12184 | 603 MUST be ignored by the demuxer |
9310 | 604 |
12501 | 605 demuxer (non-normative) |
606 | |
16428 | 607 in the absence of a valid header at the beginning, players SHOULD search for |
608 backup headers starting at offset 2^x; for each x players SHOULD end their | |
609 search at a particular offset when any startcode is found (including syncpoint) | |
12501 | 610 |
16429 | 611 Semantic requirements |
612 | |
613 If more than one stream of a given stream class is present, each one MUST | |
614 have info tags specifying disposition, and if applicable, language. | |
615 | |
616 A demuxer MUST NOT demux a stream which contains more than one stream, or which | |
617 is wrapped in a structure to facilitate more than one stream or otherwise | |
618 duplicate the role of a container. any such file is to be considered invalid. | |
619 | |
12501 | 620 |
9294 | 621 Sample code (GPL, & untested) |
622 | |
623 typedef BufferContext{ | |
624 uint8_t *buf; | |
625 uint8_t *buf_ptr; | |
626 }BufferContext; | |
627 | |
628 static inline uint64_t get_bytes(BufferContext *bc, int count){ | |
629 uint64_t val=0; | |
630 | |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
631 assert(count>0 && count<9); |
9294 | 632 |
633 for(i=0; i<count; i++){ | |
634 val <<=8; | |
635 val += *(bc->buf_ptr++); | |
636 } | |
637 | |
638 return val; | |
639 } | |
640 | |
641 static inline void put_bytes(BufferContext *bc, int count, uint64_t val){ | |
642 uint64_t val=0; | |
643 | |
15008
0a43341c8bfd
less amateurish-looking mpcf.txt patch by (Jeff >snacky ikaruga co uk<)
michael
parents:
14919
diff
changeset
|
644 assert(count>0 && count<9); |
9294 | 645 |
646 for(i=count-1; i>=0; i--){ | |
647 *(bc->buf_ptr++)= val >> (8*i); | |
648 } | |
649 | |
650 return val; | |
651 } | |
652 | |
10061 | 653 static inline uint64_t get_v(BufferContext *bc){ |
9294 | 654 uint64_t val= 0; |
655 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
656 for(; space_left(bc) > 0; ){ |
9294 | 657 int tmp= *(bc->buf_ptr++); |
658 if(tmp&0x80) | |
659 val= (val<<7) + tmp - 0x80; | |
660 else | |
9299 | 661 return (val<<7) + tmp; |
9294 | 662 } |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
663 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
664 return -1; |
9294 | 665 } |
666 | |
10061 | 667 static inline int put_v(BufferContext *bc, uint64_t val){ |
9294 | 668 int i; |
669 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
670 if(space_left(bc) < 9) return -1; |
9294 | 671 |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
672 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
|
673 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
|
674 if(val>>i == 0) break; |
9294 | 675 } |
676 | |
10827 | 677 for(i-=7; i>0; i-=7){ |
9294 | 678 *(bc->buf_ptr++)= 0x80 | (val>>i); |
679 } | |
680 *(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
|
681 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
682 return 0; |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
683 } |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
684 |
12333 | 685 static int64_t get_dts(int64_t pts, int64_t *pts_cache, int delay, int reset){ |
686 if(reset) memset(pts_cache, -1, delay*sizeof(int64_t)); | |
687 | |
688 while(delay--){ | |
689 int64_t t= pts_cache[delay]; | |
690 if(t < pts){ | |
691 pts_cache[delay]= pts; | |
692 pts= t; | |
693 } | |
694 } | |
695 | |
696 return pts; | |
697 } | |
698 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
699 Authors |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
700 |
16428 | 701 Folks from the MPlayer developers mailing list (http://www.mplayerhq.hu/). |
702 Authors in alphabetical order: (FIXME! Tell us if we left you out) | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
703 Beregszaszi, Alex (alex@fsn.hu) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
704 Bunkus, Moritz (moritz@bunkus.org) |
15755 | 705 Diedrich, Tobias (ranma+mplayer@tdiedrich.de) |
12297 | 706 Felker, Rich (dalias@aerifal.cx) |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
707 Franz, Fabian (FabianFranz@gmx.de) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
708 Gereoffy, Arpad (arpi@thot.banki.hu) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
709 Hess, Andreas (jaska@gmx.net) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
710 Niedermayer, Michael (michaelni@gmx.at) |
16429 | 711 Shimon, Oded (ods15@ods15.dyndns.org) |