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