Mercurial > mplayer.hg
annotate DOCS/tech/mpcf.txt @ 14911:6a8b15582f64
store local keyframes too so faster seeking is possible
author | michael |
---|---|
date | Fri, 04 Mar 2005 03:16:40 +0000 |
parents | f2fcd2622a61 |
children | 1d4861b2ac4a |
rev | line source |
---|---|
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
1 NUT Open Container Format DRAFT 20050111 |
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 | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
40 Since nut heavly uses variable lenght fields the simplest way to describe it |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
41 is using a pseudocode approach. |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
42 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
43 Conventions: |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
44 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
45 The data tipes have a name, used in the bitstream syntax description, a short |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
46 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
|
47 follow: |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
48 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
49 name (text description) |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
50 functional definition |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
51 [Optional notes] |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
52 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
53 The bitream syntax element have a tagname and a functional definition, they are |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
54 presented in a bottom up approach, again optional notes may follow and are reproduced in the tag description: |
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. |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
61 The functional definition has a C like syntax. |
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) |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
68 u(n) (unsigned number encoded in n bits in MSB first order) |
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 } |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
88 [Note: strings MUST be encoded in utf8] |
9295 | 89 |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
90 vb (variable lenght 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 |
14906 | 122 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 |
128 if(tmp_fields>0) tmp_timestamp s | |
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; |
12413 | 145 timestamp_delta[i]= tmp_timestamp; |
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 |
9294 | 158 average_bitrate v |
9297 | 159 time_base_nom v |
160 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
|
161 msb_timestamp_shift v |
12333 | 162 decode_delay v |
14906 | 163 index_modulo v |
164 index_increment v | |
9294 | 165 fixed_fps u(1) |
9356 | 166 reserved u(6) |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
167 codec_specific_data vb |
9294 | 168 |
169 video_stream_header: | |
170 stream_header | |
171 width v | |
172 height v | |
173 sample_width v | |
174 sample_height v | |
175 colorspace_type v | |
176 reserved_bytes | |
177 checksum u(32) | |
178 | |
179 audio_stream_header: | |
180 stream_header | |
12333 | 181 samplerate_nom v |
182 samplerate_denom v | |
9294 | 183 channel_count v |
184 reserved_bytes | |
185 checksum u(32) | |
9420 | 186 |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
187 Basic Packets: |
12082 | 188 |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
189 frame: |
12082 | 190 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
|
191 if(stream_id_plus1[frame_code]==0){ |
12082 | 192 stream_id v |
193 } | |
12413 | 194 if(timestamp_delta[frame_code]==0){ |
12261 | 195 coded_timestamp v |
196 } | |
12413 | 197 if(flags[frame_code]&1){ |
12082 | 198 data_size_msb v |
199 } | |
12501 | 200 for(i=0; i<reserved_count[frame_code]; i++) |
12413 | 201 reserved v |
12082 | 202 data |
203 | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
204 index: |
10831 | 205 index_startcode f(64) |
9294 | 206 packet header |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
207 stream_id v |
14906 | 208 index_id v |
9294 | 209 index_length v |
210 for(i=0; i<index_length; i++){ | |
211 index_timestamp v | |
212 index_position v | |
213 } | |
9310 | 214 reserved_bytes |
9294 | 215 checksum u(32) |
216 | |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
217 info_packet: (optional) |
10831 | 218 info_startcode f(64) |
9294 | 219 packet header |
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) |
9323 | 236 |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
237 sync_point: |
12413 | 238 frame_startcode f(64) |
239 global_timestamp v | |
240 | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
241 Complete definition: |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
242 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
243 file: |
12242 | 244 file_id_string |
14906 | 245 while(!eof){ |
12242 | 246 main_header |
247 for(i=0; i<stream_count; i++){ | |
248 if(next_packet==video_stream_header) | |
249 video_stream_header | |
250 else | |
251 audio_stream_header | |
252 } | |
12413 | 253 while(next_code != main_startcode){ |
254 if(next_code == info_startcode) | |
12242 | 255 info_packet |
14906 | 256 else if(next_code == index_startcode){ |
257 index | |
258 }else{ | |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
259 if(next_code == frame_startcode) |
12413 | 260 sync_point |
12242 | 261 frame |
12368 | 262 } |
12242 | 263 } |
264 } | |
9323 | 265 |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
266 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
267 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
268 Tag description: |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
269 |
9294 | 270 forward_ptr |
12238 | 271 size of the packet (exactly the distance from the first byte of the |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
272 startcode of the current packet to the first byte of the following |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
273 packet |
12242 | 274 |
275 file_id_string | |
276 "nut/multimedia container\0" | |
9323 | 277 |
278 *_startcode | |
12162 | 279 all startcodes start with 'N' |
280 | |
281 main_startcode | |
282 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
|
283 |
12162 | 284 stream_starcode |
285 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
|
286 |
12333 | 287 frame_startcode |
12162 | 288 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
|
289 |
12392 | 290 frame_startcodes SHOULD be placed immedeatly before a keyframe if the |
291 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
|
292 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
|
293 |
12162 | 294 index_startcode |
295 0xDD672F23E64EULL + (((uint64_t)('N'<<8) + 'X')<<48) | |
296 info_startcode | |
297 0xAB68B596BA78ULL + (((uint64_t)('N'<<8) + 'I')<<48) | |
9294 | 298 |
299 version | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
300 NUT version, the current values is 2 |
12238 | 301 |
12333 | 302 max_distance |
303 max distance of frame_startcodes, the distance may only be larger if | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
304 there is only a single frame between the 2 frame_startcodes this can |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
305 be used by the demuxer to detect damaged frame headers if the damage |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
306 results in a too long chain |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
307 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
308 SHOULD be set to <=32768 or at least <=65536 unless there is a very |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
309 good reason to set it higher otherwise reasonable error recovery will |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
310 be impossible |
12501 | 311 |
14906 | 312 index_distance |
313 distance at which indexes are approximately stored, or 0 if there are | |
314 no indexes in the file | |
315 in every [x*index_distance, (x+1)*index_distance) interval, there | |
316 must be an index packet for every stream, and these packets must be | |
317 located prior to all frames within the interval | |
318 reasoning: this ensures good error recovery as there are many and | |
319 evenly distributed indexes, and also allows very quick finding of the | |
320 index packets | |
321 | |
322 index_modulo | |
323 index_id | |
324 each index packet contains every index_moduloth's keyframe of a stream, | |
325 so the i'th keyframe of a stream will be at least in packets with | |
326 (i % index_modulo) == index_id | |
14911
6a8b15582f64
store local keyframes too so faster seeking is possible
michael
parents:
14906
diff
changeset
|
327 furthermore a index packet contains all indexed keyframes since the |
6a8b15582f64
store local keyframes too so faster seeking is possible
michael
parents:
14906
diff
changeset
|
328 last index packet |
6a8b15582f64
store local keyframes too so faster seeking is possible
michael
parents:
14906
diff
changeset
|
329 (indexed keyframes == keyframes which are referenced from any index |
6a8b15582f64
store local keyframes too so faster seeking is possible
michael
parents:
14906
diff
changeset
|
330 packet) |
14906 | 331 |
332 index_increment | |
333 the index_id increment value, this MUST be a relative prime to | |
334 index_modulo | |
335 index_increment / index_modulo SHOULD be approximately 2/(sqrt(5)+1) | |
12501 | 336 |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
337 stream_id[FIXME] |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
338 Stream identifier |
9294 | 339 Note: streams with a lower relative class MUST have a lower relative id |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
340 so a stream with class 0 MUST always have a id which is lower then any |
9294 | 341 stream with class > 0 |
12150 | 342 stream_id MUST be < stream_count |
9294 | 343 |
344 stream_class | |
345 0 video | |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
346 1 audio |
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
347 2 subtiles |
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
348 3 metadata |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
349 Note: the remaining values are reserved and MUST NOT be used |
12184 | 350 a demuxer MUST ignore streams with reserved classes |
9294 | 351 |
352 fourcc | |
353 identification for the codec | |
9323 | 354 example: "H264" |
10817 | 355 MUST contain 2 or 4 bytes, note, this might be increased in the future |
356 if needed | |
9294 | 357 |
9297 | 358 time_base_nom / time_base_denom = time_base |
9294 | 359 the number of timer ticks per second, this MUST be equal to the fps |
360 if the fixed_fps is 1 | |
9297 | 361 time_base_denom MUST not be 0 |
362 time_base_nom and time_base_denom MUST be relative prime | |
12254 | 363 time_base_nom MUST be < 2^31 |
9297 | 364 examples: |
365 fps time_base_nom time_base_denom | |
366 30 30 1 | |
367 29.97 30000 1001 | |
368 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
|
369 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
|
370 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
|
371 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
|
372 48000 1024 375 8 |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
373 |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
374 Note: the advantage to using a large sample_rate_mul is that |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
375 the timestamps need fewer bits |
9294 | 376 |
12413 | 377 global_time_base_nom / global_time_base_denom = global_time_base |
378 the number of timer ticks per second | |
379 global_time_base_denom MUST not be 0 | |
380 global_time_base_nom and global_time_base_denom MUST be relative prime | |
381 global_time_base_nom MUST be < 2^31 | |
382 | |
383 global_timestamp | |
384 timestamp in global_time_base units | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
385 when a global_timestamp is encountered the last_timestamp of all |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
386 streams is set to the following: |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
387 |
12413 | 388 ln= global_time_base_denom*time_base_nom |
389 sn= global_timestamp | |
390 d1= global_time_base_nom | |
391 d2= time_base_denom | |
392 last_timestamp= (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
|
393 Note: this calculation MUST be done with unsigned 64 bit integers, and |
12413 | 394 is equivalent to (ln*sn)/(d1*d2) but this would require a 96bit integer |
395 | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
396 msb_timestamp_shift |
12261 | 397 amount of bits in lsb_timestamp |
9294 | 398 MUST be <16 |
399 | |
12333 | 400 decode_delay |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
401 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
|
402 dts from pts |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
403 is set to 0 for streams without b frames, and set to 1 for streams with |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
404 b frames, may be larger for future codecs |
12333 | 405 |
9294 | 406 fixed_fps |
407 1 indicates that the fps is fixed | |
408 | |
9356 | 409 codec_specific_data |
410 private global data for a codec (could be huffman tables or ...) | |
12082 | 411 |
412 frame_code | |
413 the meaning of this byte is stored in the main header | |
414 the value 78 ('N') is forbidden to ensure that the byte is always | |
415 different from the first byte of any startcode | |
9420 | 416 |
12082 | 417 flags[frame_code] |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
418 first of the flags from MSB to LSB are called KD |
12261 | 419 if D is 1 then data_size_msb is coded, otherwise data_size_msb is 0 |
12238 | 420 K is the keyframe_type |
421 0-> no keyframe, | |
422 1-> keyframe, | |
12413 | 423 flags=4 can be used to mark illegal frame_code bytes |
424 frame_code=78 must have flags=4 | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
425 Note: frames MUST not depend(1) upon frames prior to the last |
12333 | 426 frame_startcode |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
427 Important: depend(1) means dependancy on the container level (NUT) not |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
428 dependancy on the codec level |
12110
a34dc5a369ca
restrictions to ensure that O(log n) seeking and error recovery is possible
michael
parents:
12084
diff
changeset
|
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 stream_id_plus1[frame_code] |
12082 | 431 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
|
432 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
|
433 |
12082 | 434 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
|
435 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
|
436 |
12082 | 437 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
|
438 must be <16384 |
12082 | 439 |
12413 | 440 timestamp_delta[frame_code] |
441 must be <16384 and >-16384 | |
442 | |
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
|
443 data_size |
12261 | 444 data_size= data_size_lsb + data_size_msb*data_size_mul; |
12082 | 445 |
12261 | 446 coded_timestamp |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
447 if coded_timestamp < (1<<msb_timestamp_shift) then its a lsb |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
448 timestamp, otherwise its a full timestamp + (1<<msb_timestamp_shift) |
12261 | 449 lsb timestamps are converted to full timesamps by: |
450 mask = (1<<msb_timestamp_shift)-1; | |
451 delta= last_timestamp - mask/2 | |
452 timestamp= ((timestamp_lsb-delta)&mask) + delta | |
12333 | 453 a full timestamp must be used if there is no reference timestamp |
454 available after the last frame_startcode with the current stream_id | |
12261 | 455 |
9294 | 456 lsb_timestamp |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
457 least significant bits of the timestamp in time_base precision |
9294 | 458 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
|
459 keyframe timestamp=0 -> timestamp=0 |
9294 | 460 frame lsb_timestamp=3 -> timestamp=3 |
461 frame lsb_timestamp=1 -> timestamp=1 | |
462 frame lsb_timestamp=2 -> timestamp=2 | |
463 ... | |
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
|
464 keyframe msb_timestamp=257 -> timestamp=257 |
12082 | 465 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
|
466 frame lsb_timestamp=0 -> timestamp=256 |
9294 | 467 frame lsb_timestamp=4 -> timestamp=260 |
468 frame lsb_timestamp=2 -> timestamp=258 | |
469 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
|
470 all timestamps of keyframes of a single stream MUST be monotone |
9294 | 471 |
12333 | 472 dts |
473 dts are calculated by using a decode_delay+1 sized buffer for each | |
474 stream, into which the current pts is inserted and the element with | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
475 the smallest value is removed, this is then the current dts this |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
476 buffer is initalized with decode_delay -1 elements |
12333 | 477 all frames with dts == timestamp must be monotone, that means a frame |
478 which occures later in the stream must have a larger or equal dts | |
479 then an earlier frame | |
480 FIXME rename timestamp* to pts* ? | |
481 | |
9294 | 482 width/height |
483 MUST be set to the coded width/height | |
484 | |
485 sample_width/sample_height (aspect ratio) | |
486 sample_width is the horizontal distance between samples | |
487 sample_width and sample_height MUST be relative prime if not zero | |
488 MUST be 0 if unknown | |
489 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
490 colorspace_type |
10166 | 491 0 unknown |
492 1 ITU Rec 624 / ITU Rec 601 Y range: 16..235 Cb/Cr range: 16..240 | |
493 2 ITU Rec 709 Y range: 16..235 Cb/Cr range: 16..240 | |
494 17 ITU Rec 624 / ITU Rec 601 Y range: 0..255 Cb/Cr range: 0..255 | |
495 18 ITU Rec 709 Y range: 0..255 Cb/Cr range: 0..255 | |
496 | |
12333 | 497 samplerate_nom / samplerate_denom = samplerate |
498 the number of samples per second | |
9294 | 499 |
500 checksum | |
12118
b8fea9441d02
switching from crc32 to adler32 checksums, cuz they are faster and simpler
michael
parents:
12117
diff
changeset
|
501 adler32 checksum |
9294 | 502 |
503 index_timestamp | |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
504 value of the timetamp of a keyframe relative to the last keyframe |
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
505 stored in this index |
9294 | 506 |
507 index_position | |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
508 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
|
509 last keyframe stored in this index |
9294 | 510 |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
511 id |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
512 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
|
513 0 means end |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
514 |
9323 | 515 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
|
516 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
|
517 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
|
518 Note: MUST be less than 6 byte long (might be increased to 64 later) |
9323 | 519 |
13308
8ff17d153414
info packet is now file global, while meta pakcet is stream specific, as discussed with Rich
alex
parents:
13047
diff
changeset
|
520 info packet types |
9295 | 521 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
|
522 "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
|
523 |
9347
97888c25ae60
changing name to "nut" for now, we can change it again if we agree on something else
michael
parents:
9335
diff
changeset
|
524 "Author" |
97888c25ae60
changing name to "nut" for now, we can change it again if we agree on something else
michael
parents:
9335
diff
changeset
|
525 "Description" |
97888c25ae60
changing name to "nut" for now, we can change it again if we agree on something else
michael
parents:
9335
diff
changeset
|
526 "Copyright" |
9369 | 527 "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
|
528 "Title" |
9373 | 529 "Cover" an image of the (cd,dvd,vhs,..) cover (preferable PNG or JPEG) |
9350 | 530 "Source" "DVD", "VCD", "CD", "MD", "FM radio", "VHS", "TV", |
531 "LD" | |
9373 | 532 Optional: appended PAL,NTSC,SECAM, ... in parentheses |
9350 | 533 "CaptureDevice" "BT878", "BT848", "webcam", ... (more exact names are fine too) |
534 "CreationTime" "2003-01-20 20:13:15Z", ... | |
535 (ISO 8601 format, see http://www.cl.cam.ac.uk/~mgk25/iso-time.html) | |
536 Note: dont 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
|
537 "Keywords" |
8ff17d153414
info packet is now file global, while meta pakcet is stream specific, as discussed with Rich
alex
parents:
13047
diff
changeset
|
538 "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
|
539 "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
|
540 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
|
541 and "multi" if several languages |
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
542 see http://www.loc.gov/standards/iso639-2/englangn.html |
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
543 and http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1/en_listp1.htmlthe language code |
12503 | 544 "Disposition" "original", "dub" (translated), "comment", "lyrics", "karaoke" |
9295 | 545 Note: if someone needs some others, please tell us about them, so we can |
546 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
|
547 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
|
548 Note: MUST be less than 64 bytes long |
9295 | 549 |
550 value | |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
551 value of this name/type pair |
9295 | 552 |
9310 | 553 stuffing |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
554 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
|
555 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
556 info_table[][2]={ |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
557 {NULL , NULL }, // end |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
558 {NULL , NULL }, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
559 {NULL , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
560 {NULL , "v"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
561 {NULL , "s"}, |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
562 {"StreamId" , "v"}, |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
563 {"Author" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
564 {"Titel" , "UTF8"}, |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
565 {"Language" , "UTF8"}, |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
566 {"Description" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
567 {"Copyright" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
568 {"Encoder" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
569 {"Keyword" , "UTF8"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
570 {"Cover" , "JPEG"}, |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
571 {"Cover" , "PNG"}, |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
572 {"Disposition" , "UTF8"}, |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
573 }; |
9294 | 574 |
575 Structure: | |
576 | |
577 the headers MUST be in exactly the following order (to simplify demuxer design) | |
578 main header | |
579 stream_header (id=0) | |
580 stream_header (id=1) | |
581 ... | |
582 stream_header (id=n) | |
583 | |
584 headers may be repated, but if they are then they MUST all be repeated together | |
585 and repeated headers MUST be identical | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
586 headers MAY only repeated at the closest possible positions after 2^x where x |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
587 is an integer and the file end, so the headers may be repeated at 4102 if that |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
588 is the closest possition after 2^12=4096 at which the headers can be placed |
9294 | 589 |
12501 | 590 headers MUST be placed at least at the begin of the file and immedeatly before |
591 the index or at the file end if there is no index | |
9310 | 592 headers MUST be repeated at least twice (so they exist 3 times in a file) |
9295 | 593 |
12501 | 594 a demuxer MUST not demux a stream which contains more than one stream, or which |
595 is wrapped in a structure to facilitate more than one stream or otherwise | |
596 duplicate the role of a container. any such file is to be considered invalid | |
597 | |
12503 | 598 info packets which describe the whole file or individual streams/tracks must be |
599 placed before any video/audio/... frames | |
600 | |
9310 | 601 Index |
602 | |
603 Info packets | |
604 the info_packet can be repeated, it can also contain different names & values | |
14471
6cdd5669e930
Here is an updated draft with the bits discussed previously merged:
michael
parents:
13308
diff
changeset
|
605 each time but only if also the time is different |
9310 | 606 Info packets can be used to describe the file or some part of it (chapters) |
607 | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
608 info packets, SHOULD be placed at the begin of the file at least for realtime |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
609 streaming info packets will normally be transmitted when they apply for |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
610 example, the current song title & artist of the currently shown music video |
9310 | 611 |
612 Unknown packets | |
12184 | 613 MUST be ignored by the demuxer |
9310 | 614 |
12501 | 615 demuxer (non-normative) |
616 | |
617 in the absence of valid header at beginning, players SHOULD search for backup | |
14854
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
618 headers starting at offset 2^x for each x players SHOULD end their search from |
ebc5136f2a56
some comments and whitespace changes by (Luca Barbato <lu_zero gentoo org>)
michael
parents:
14471
diff
changeset
|
619 a particular offset when any startcode is found (including syncpoint) |
12501 | 620 |
621 | |
9294 | 622 Sample code (GPL, & untested) |
623 | |
624 typedef BufferContext{ | |
625 uint8_t *buf; | |
626 uint8_t *buf_ptr; | |
627 }BufferContext; | |
628 | |
629 static inline uint64_t get_bytes(BufferContext *bc, int count){ | |
630 uint64_t val=0; | |
631 | |
632 assert(count>0 && count<9) | |
633 | |
634 for(i=0; i<count; i++){ | |
635 val <<=8; | |
636 val += *(bc->buf_ptr++); | |
637 } | |
638 | |
639 return val; | |
640 } | |
641 | |
642 static inline void put_bytes(BufferContext *bc, int count, uint64_t val){ | |
643 uint64_t val=0; | |
644 | |
645 assert(count>0 && count<9) | |
646 | |
647 for(i=count-1; i>=0; i--){ | |
648 *(bc->buf_ptr++)= val >> (8*i); | |
649 } | |
650 | |
651 return val; | |
652 } | |
653 | |
10061 | 654 static inline uint64_t get_v(BufferContext *bc){ |
9294 | 655 uint64_t val= 0; |
656 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
657 for(; space_left(bc) > 0; ){ |
9294 | 658 int tmp= *(bc->buf_ptr++); |
659 if(tmp&0x80) | |
660 val= (val<<7) + tmp - 0x80; | |
661 else | |
9299 | 662 return (val<<7) + tmp; |
9294 | 663 } |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
664 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
665 return -1; |
9294 | 666 } |
667 | |
10061 | 668 static inline int put_v(BufferContext *bc, uint64_t val){ |
9294 | 669 int i; |
670 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
671 if(space_left(bc) < 9) return -1; |
9294 | 672 |
9579
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
673 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
|
674 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
|
675 if(val>>i == 0) break; |
9294 | 676 } |
677 | |
10827 | 678 for(i-=7; i>0; i-=7){ |
9294 | 679 *(bc->buf_ptr++)= 0x80 | (val>>i); |
680 } | |
681 *(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
|
682 |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
683 return 0; |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
684 } |
89d27a306886
*signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents:
9422
diff
changeset
|
685 |
12333 | 686 static int64_t get_dts(int64_t pts, int64_t *pts_cache, int delay, int reset){ |
687 if(reset) memset(pts_cache, -1, delay*sizeof(int64_t)); | |
688 | |
689 while(delay--){ | |
690 int64_t t= pts_cache[delay]; | |
691 if(t < pts){ | |
692 pts_cache[delay]= pts; | |
693 pts= t; | |
694 } | |
695 } | |
696 | |
697 return pts; | |
698 } | |
699 | |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
700 Authors |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
701 |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
702 Folks from MPlayer Developers Mailinglist (http://www.mplayehrq.hu/). |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
703 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
|
704 Beregszaszi, Alex (alex@fsn.hu) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
705 Bunkus, Moritz (moritz@bunkus.org) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
706 Diedrich, Tobias (td@sim.uni-hannover.de) |
12297 | 707 Felker, Rich (dalias@aerifal.cx) |
10158
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
708 Franz, Fabian (FabianFranz@gmx.de) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
709 Gereoffy, Arpad (arpi@thot.banki.hu) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
710 Hess, Andreas (jaska@gmx.net) |
93e5428d0b3e
some changes (michael: is the colorspace_type field needed?)
alex
parents:
10061
diff
changeset
|
711 Niedermayer, Michael (michaelni@gmx.at) |