annotate DOCS/tech/mpcf.txt @ 12413:87a6dc69b65a

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