annotate DOCS/tech/mpcf.txt @ 12082:f705b0777572

removing subpackets (everyone hates them ...) removing shuffle_type (meaningless without subpackets) making timestamp_lsb a simple unsigned value (someone proposed that a long time ago, dunno dont remember who, IIRC it was rejected as it more often required the timestamp_msb to be coded but by defining lsb relative to the last lsb we need very few msbs in the error free case and for damaged files its also pretty difficult to trash the timestamp, for example for a fixed fps stream with 7bit lsb_timestamps we need to loose >64 frames in a row to end up with a wrong timestamp) cleanup (filesize and such where only partially removed) frame_code byte, with the meaning of each value stored in the main header the frame_code contains the keyframe_flag, packet_type and can contain the timestamp_delta, stream_id and the data_size or part if it
author michael
date Tue, 30 Mar 2004 01:05:51 +0000
parents 645975e01061
children 68baf8877c07
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
1 NUT Open Container Format DRAFT 20040330
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
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
26 checksums to allow quick redownloading of damaged parts
10158
93e5428d0b3e some changes (michael: is the colorspace_type field needed?)
alex
parents: 10061
diff changeset
27 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
28 resyncing times
9294
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
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
32 Definitions:
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
33
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
34 MUST the specific part must be done to conform to this standard
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
35 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
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
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
39 Syntax:
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
40
9295
michael
parents: 9294
diff changeset
41 Type definitions:
michael
parents: 9294
diff changeset
42 v
michael
parents: 9294
diff changeset
43 value=0
michael
parents: 9294
diff changeset
44 do{
michael
parents: 9294
diff changeset
45 more_data u(1)
michael
parents: 9294
diff changeset
46 data u(7)
michael
parents: 9294
diff changeset
47 value= 128*value + data
michael
parents: 9294
diff changeset
48 }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
49
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
50 s
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
51 temp v
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
52 temp++
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
53 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
54 else value= (temp>>1)
9323
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
55
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
56 b (binary data or string)
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
57 length v
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
58 for(i=0; i<length; i++){
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
59 data[i] u(8)
9295
michael
parents: 9294
diff changeset
60 }
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
61 Note: strings MUST be encoded in utf8
9295
michael
parents: 9294
diff changeset
62
9323
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
63
10824
d163db068a12 reserved_bytes & byte order stuff
michael
parents: 10817
diff changeset
64 f(x) n fixed bits in big endian order
9295
michael
parents: 9294
diff changeset
65 u(x) unsigned number encoded in x bits in MSB first order
michael
parents: 9294
diff changeset
66
michael
parents: 9294
diff changeset
67
michael
parents: 9294
diff changeset
68 Bitstream syntax:
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
69 packet header
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
70 backward ptr v
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
71 forward ptr v
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
72
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
73 align_byte
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
74 while(not byte aligned)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
75 one f(1)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
76
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
77 reserved_bytes
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
78 for(i=0; i<forward_ptr - length_of_non_reserved; i++)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
79 reserved u(8)
10824
d163db068a12 reserved_bytes & byte order stuff
michael
parents: 10817
diff changeset
80 a decoder MUST ignore any reserved bytes
d163db068a12 reserved_bytes & byte order stuff
michael
parents: 10817
diff changeset
81 a encoder MUST NOT write any reserved bytes, as this would make it
d163db068a12 reserved_bytes & byte order stuff
michael
parents: 10817
diff changeset
82 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
83 a compatible way
d163db068a12 reserved_bytes & byte order stuff
michael
parents: 10817
diff changeset
84
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
85 main header:
10831
3f716efeb27a moved packet header after startcodes
alex
parents: 10827
diff changeset
86 main_startcode f(64)
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
87 packet header
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
88 version v
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
89 stream_count v
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
90 checksum_threshold v
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
91 for(i=0; i<256; i++){
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
92 flags[i] v
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
93 if(flags&64){
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
94 stream_id[i] v
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
95 lsb_size[i] v
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
96 data_size_mul[i] v
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
97 }
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
98 }
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
99 reserved_bytes
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
100 checksum u(32)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
101
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
102 stream_header:
10831
3f716efeb27a moved packet header after startcodes
alex
parents: 10827
diff changeset
103 stream_startcode f(64)
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
104 packet_header
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
105 stream_id v
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
106 stream_class v
9323
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
107 fourcc b
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
108 average_bitrate v
9325
18cdba535f36 hex editor friendly language_code
michael
parents: 9323
diff changeset
109 language_code b
9297
8a19be9649e7 use fraction for time_base
michael
parents: 9296
diff changeset
110 time_base_nom v
8a19be9649e7 use fraction for time_base
michael
parents: 9296
diff changeset
111 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
112 msb_timestamp_shift v
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
113 inital_timestamp_predictor v(3)
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
114 initial_data_size_predictor v(2)
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
115 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
116 index_flag u(1)
9356
025a25987ac0 simplification
michael
parents: 9350
diff changeset
117 reserved u(6)
9357
21347f49e8d8 supprting various codec specific/private headers for different APIs (ideas by arpi/alex/fabian)
michael
parents: 9356
diff changeset
118 for(;;){
9361
06c106f23a41 encoding the whole name doesnt make sense
michael
parents: 9360
diff changeset
119 codec_specific_data_type v
06c106f23a41 encoding the whole name doesnt make sense
michael
parents: 9360
diff changeset
120 if(codec_specific_data_type==0) break;
10985
c041999a8d5b codec_specific_data_size
alex
parents: 10873
diff changeset
121 codec_specific_data_size v
9357
21347f49e8d8 supprting various codec specific/private headers for different APIs (ideas by arpi/alex/fabian)
michael
parents: 9356
diff changeset
122 codec_specific_data b
21347f49e8d8 supprting various codec specific/private headers for different APIs (ideas by arpi/alex/fabian)
michael
parents: 9356
diff changeset
123 }
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
124
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
125 video_stream_header:
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
126 stream_header
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
127 width v
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
128 height v
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
129 sample_width v
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
130 sample_height v
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
131 colorspace_type v
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
132 reserved_bytes
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
133 checksum u(32)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
134
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
135 audio_stream_header:
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
136 stream_header
9579
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
137 samplerate_mul v
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
138 channel_count v
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
139 reserved_bytes
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
140 checksum u(32)
9420
8a1a8f5e9c91 variable subpacket size support
michael
parents: 9373
diff changeset
141
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
142
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
143 frame
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
144 if(frame_type == 2){
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
145 frame_type2_startcode f(64)
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
146 }
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
147 frame_code f(8)
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
148 if(flags[frame_code]&1){
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
149 packet header
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
150 }
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
151 if(stream_id[frame_code]==stream_count){
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
152 stream_id v
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
153 }
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
154 if(frame_type == 2){
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
155 msb_timestamp v
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
156 }
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
157 if((flags[frame_code]&12) == 12){
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
158 lsb_timestamp v
9420
8a1a8f5e9c91 variable subpacket size support
michael
parents: 9373
diff changeset
159 }
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
160 if(flags[frame_code]&2){
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
161 data_size_msb v
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
162 }
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
163 data
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
164 if(checksum_threshold < frame_type)
9312
michael
parents: 9311
diff changeset
165 frame_checksum u(32)
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
166
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
167 Index:
10831
3f716efeb27a moved packet header after startcodes
alex
parents: 10827
diff changeset
168 index_startcode f(64)
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
169 packet header
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
170 stream_id v
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
171 index_length v
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
172 for(i=0; i<index_length; i++){
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
173 index_timestamp v
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
174 index_position v
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
175 }
9310
b16480522be9 some typos
michael
parents: 9307
diff changeset
176 reserved_bytes
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
177 checksum u(32)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
178
9310
b16480522be9 some typos
michael
parents: 9307
diff changeset
179 info_packet: (optional)
10831
3f716efeb27a moved packet header after startcodes
alex
parents: 10827
diff changeset
180 info_startcode f(64)
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
181 packet header
9323
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
182 for(;;){
9579
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
183 id v
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
184 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
185 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
186 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
187 if(type==NULL)
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
188 type b
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
189 if(name==NULL)
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
190 name b
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
191 if(type=="v")
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
192 value v
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
193 else if(type=="s")
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
194 value s
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
195 else
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
196 value b
9323
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
197 }
9310
b16480522be9 some typos
michael
parents: 9307
diff changeset
198 reserved_bytes
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
199 checksum u(32)
9323
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
200
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
201
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
202 forward_ptr
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
203 backward_ptr
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
204 pointer to the next / previous packet
9323
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
205 pointers are relative and backward pointer is implicitelly negative
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
206 Note: a frame with 0 bytes means that its skiped
9323
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
207 Note: the forward pointer is equal to the size of this packet including
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
208 the header
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
209 the backward pointer is equal to the size of the previous packet
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
210 Example:
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
211 0
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
212 size1 (size of frame1 including header)
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
213 frame1
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
214
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
215 size1
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
216 size2
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
217 frame2
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
218
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
219 size2
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
220 size3
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
221 frame3
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
222
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
223
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
224 *_startcode
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
225 the first bit is allways set
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
226
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
227 version
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
228 0 for now
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
229
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
230 stream_id
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
231 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
232 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
233 stream with class > 0
9295
michael
parents: 9294
diff changeset
234 streams should use low ids
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
235
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
236 stream_class
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
237 0 video
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
238 32 audio
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
239 64 subtiles
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
240 Note the remaining values are reserved and MUST NOT be used
9312
michael
parents: 9311
diff changeset
241 a decoder MUST ignore streams with reserved classes
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
242
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
243 fourcc
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
244 identification for the codec
9323
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
245 example: "H264"
10817
59ac254c2541 some updates
alex
parents: 10166
diff changeset
246 MUST contain 2 or 4 bytes, note, this might be increased in the future
59ac254c2541 some updates
alex
parents: 10166
diff changeset
247 if needed
59ac254c2541 some updates
alex
parents: 10166
diff changeset
248
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
249 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
250 ISO 639 and ISO 3166 for language/country code
9325
18cdba535f36 hex editor friendly language_code
michael
parents: 9323
diff changeset
251 something like "usen" (US english), can be 0
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
252 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
253 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
254 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
255
9297
8a19be9649e7 use fraction for time_base
michael
parents: 9296
diff changeset
256 time_base_nom / time_base_denom = time_base
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
257 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
258 if the fixed_fps is 1
9297
8a19be9649e7 use fraction for time_base
michael
parents: 9296
diff changeset
259 time_base_denom MUST not be 0
8a19be9649e7 use fraction for time_base
michael
parents: 9296
diff changeset
260 time_base_nom and time_base_denom MUST be relative prime
9579
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
261 time_base_nom MUST be < 2^16
9297
8a19be9649e7 use fraction for time_base
michael
parents: 9296
diff changeset
262 examples:
8a19be9649e7 use fraction for time_base
michael
parents: 9296
diff changeset
263 fps time_base_nom time_base_denom
8a19be9649e7 use fraction for time_base
michael
parents: 9296
diff changeset
264 30 30 1
8a19be9649e7 use fraction for time_base
michael
parents: 9296
diff changeset
265 29.97 30000 1001
8a19be9649e7 use fraction for time_base
michael
parents: 9296
diff changeset
266 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
267 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
268 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
269 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
270 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
271 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
272 timestamps need fewer bits
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
273
9579
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
274 msb_timestamp_shift
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
275 amount of bits msb_timestamp is shifted left before adding lsb_timestamp
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
276 MUST be <16
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
277
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
278 fixed_fps
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
279 1 indicates that the fps is fixed
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
280
10158
93e5428d0b3e some changes (michael: is the colorspace_type field needed?)
alex
parents: 10061
diff changeset
281 index_flag
93e5428d0b3e some changes (michael: is the colorspace_type field needed?)
alex
parents: 10061
diff changeset
282 1 indicates that this file has an index
93e5428d0b3e some changes (michael: is the colorspace_type field needed?)
alex
parents: 10061
diff changeset
283 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
284 Note, all streams SHOULD have an index
93e5428d0b3e some changes (michael: is the colorspace_type field needed?)
alex
parents: 10061
diff changeset
285
9357
21347f49e8d8 supprting various codec specific/private headers for different APIs (ideas by arpi/alex/fabian)
michael
parents: 9356
diff changeset
286 codec_specific_data_type
10817
59ac254c2541 some updates
alex
parents: 10166
diff changeset
287 0 none/end
9361
06c106f23a41 encoding the whole name doesnt make sense
michael
parents: 9360
diff changeset
288 1 native
06c106f23a41 encoding the whole name doesnt make sense
michael
parents: 9360
diff changeset
289 2 bitmapinfoheader
06c106f23a41 encoding the whole name doesnt make sense
michael
parents: 9360
diff changeset
290 3 waveformatex
06c106f23a41 encoding the whole name doesnt make sense
michael
parents: 9360
diff changeset
291 4 imagedesc
06c106f23a41 encoding the whole name doesnt make sense
michael
parents: 9360
diff changeset
292 5 sounddesc
9357
21347f49e8d8 supprting various codec specific/private headers for different APIs (ideas by arpi/alex/fabian)
michael
parents: 9356
diff changeset
293 "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
294 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
295
9356
025a25987ac0 simplification
michael
parents: 9350
diff changeset
296 codec_specific_data
025a25987ac0 simplification
michael
parents: 9350
diff changeset
297 private global data for a codec (could be huffman tables or ...)
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
298
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
299 frame_code
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
300 the meaning of this byte is stored in the main header
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
301 the value 78 ('N') is forbidden to ensure that the byte is always
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
302 different from the first byte of any startcode
9420
8a1a8f5e9c91 variable subpacket size support
michael
parents: 9373
diff changeset
303
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
304 flags[frame_code]
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
305 the bits of the flags from MSB to LSB are CKKTTDP
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
306 P is 1 for type 1 and 2 packets, 0 for type 0 packets
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
307 TT is the timestamp_code 00,01,10 use the last timestamp + the first,
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
308 second and third last unique timestamp difference, so if the
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
309 timestamp differences, are +3,+1,+2,+2,+1 then last diff is
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
310 +1, second is +2 and third is +3
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
311 if TT is 11, then the timestamp is calculated by
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
312 mask = (1<<msb_timestamp_shift)-1;
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
313 delta= last_timestamp - mask/2
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
314 timestamp= ((timestamp_lsb-delta)&mask) + delta
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
315 TT must be 11 if packet_type is not 0
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
316 the last timestamp differences are reset to the default values
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
317 from the stream header if a packet of type not 0 in encountered
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
318 if D is 1 then the data_size_msb is coded otherwise data_size_msb is 0
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
319 KK is the keyframe_type
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
320 00-> no keyframe,
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
321 01-> keyframe,
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
322 10-> equal to last of the same stream,
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
323 11-> opposite from last of the same stream
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
324 KK must be 00 or 01 if the packet_type is not 0
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
325 if C is 1 then stream_id, data_size_mul and data_size_lsb are not
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
326 stored, but predicted from the last ones
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
327 the value 1000001 (65) is used to mark illegal frame_code bytes, at
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
328 least flags[78] must be 65
9420
8a1a8f5e9c91 variable subpacket size support
michael
parents: 9373
diff changeset
329
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
330 frame_type
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
331 0       is indicated by (flags[frame_code]&1)==0
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
332 1       is indicated by (flags[frame_code]&1)==1 && !startcode
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
333 2       is indicated by (flags[frame_code]&1)==1 && startcode
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
334 there SHOULD not be more then 0.5 seconds or 16kbyte of type 0 frames
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
335 wihout a intervening frame of different frame_type
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
336
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
337 stream_id[frame_code]
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
338 if its not coded in the main_header then its equal to the last one
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
339 from the main header
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
340 must be <250
9579
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
341
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
342 data_size_mul[frame_code]
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
343 if its not coded in the main_header then its equal to the last one
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
344 from the main header
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
345 must be <250
9579
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
346
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
347 data_size_lsb[frame_code]
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
348 if its not coded in the main_header then its equal to the last one
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
349 from the main header + 1
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
350 must be <250
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
351
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
352 data_size
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
353 if(data_size_lsb == data_size_mul)
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
354 data_size= last;
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
355 else if(data_size_lsb == data_size_mul+1)
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
356 data_size= next last;
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
357 else if(data_size_lsb < data_size_mul)
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
358 data_size= data_size_lsb + data_size_msb*data_size_mul;
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
359 else reserved
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
360 last and next last are reset to the values stored in the stream header
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
361 if an frame with type > 0 is encountered
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
362
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
363 msb_timestamp
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
364 most significant bits of the timestamp, SHOULD be 0 for the first frame
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
365
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
366 lsb_timestamp
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
367 least significant bits of the timestamp in time_base precission
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
368 Example: IBBP display order
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
369 keyframe msb_timestamp=0 lsb_timestamp=0 -> timestamp=0
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
370 frame lsb_timestamp=3 -> timestamp=3
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
371 frame lsb_timestamp=1 -> timestamp=1
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
372 frame lsb_timestamp=2 -> timestamp=2
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
373 ...
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
374 keyframe msb_timestamp=1 lsb_timestamp=1 -> timestamp=257
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
375 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
376 frame lsb_timestamp=0 -> timestamp=256
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
377 frame lsb_timestamp=4 -> timestamp=260
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
378 frame lsb_timestamp=2 -> timestamp=258
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
379 frame lsb_timestamp=3 -> timestamp=259
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
380
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
381 width/height
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
382 MUST be set to the coded width/height
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
383
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
384 sample_width/sample_height (aspect ratio)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
385 sample_width is the horizontal distance between samples
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
386 sample_width and sample_height MUST be relative prime if not zero
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
387 MUST be 0 if unknown
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
388
10158
93e5428d0b3e some changes (michael: is the colorspace_type field needed?)
alex
parents: 10061
diff changeset
389 colorspace_type
10166
e860465ef46e colorspace_type
michael
parents: 10158
diff changeset
390 0 unknown
e860465ef46e colorspace_type
michael
parents: 10158
diff changeset
391 1 ITU Rec 624 / ITU Rec 601 Y range: 16..235 Cb/Cr range: 16..240
e860465ef46e colorspace_type
michael
parents: 10158
diff changeset
392 2 ITU Rec 709 Y range: 16..235 Cb/Cr range: 16..240
e860465ef46e colorspace_type
michael
parents: 10158
diff changeset
393 17 ITU Rec 624 / ITU Rec 601 Y range: 0..255 Cb/Cr range: 0..255
e860465ef46e colorspace_type
michael
parents: 10158
diff changeset
394 18 ITU Rec 709 Y range: 0..255 Cb/Cr range: 0..255
e860465ef46e colorspace_type
michael
parents: 10158
diff changeset
395
9579
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
396 samplerate_mul
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
397 the number of samples per second in one time_base unit
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
398 samplerate = time_base*samplerate_mul
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
399
9311
4b04416ada91 zero_bit for normal frames, so we can distinguish them from other packets
michael
parents: 9310
diff changeset
400 zero_bit
4b04416ada91 zero_bit for normal frames, so we can distinguish them from other packets
michael
parents: 9310
diff changeset
401 MUST be 0, its there to distinguish non keyframes from other packets,
4b04416ada91 zero_bit for normal frames, so we can distinguish them from other packets
michael
parents: 9310
diff changeset
402 Note: all packets have a 64-bit startcode except non-keyframes to reduce
4b04416ada91 zero_bit for normal frames, so we can distinguish them from other packets
michael
parents: 9310
diff changeset
403 their size, and all startcodes start with a 1 bit
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
404
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
405 checksum
9307
ec18ad315bbe 10l (copy & pasting the generator poly for crc32 from ogg was a bad idea...)
michael
parents: 9299
diff changeset
406 crc32 checksum using the generator polynomial 0x104c11db7 (same as ogg)
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
407
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
408 frame_checksum
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
409 identical to checksum, but instead of covering just the current
12082
f705b0777572 removing subpackets (everyone hates them ...)
michael
parents: 11975
diff changeset
410 packet, it covers all frames since the last frame_checksum
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
411
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
412 index_timestamp
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
413 value in time_base precission, relative to the last index_timestamp
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
414
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
415 index_position
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
416 position in bytes of the first byte of the keyframe header, relative
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
417 to the last index_position
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
418
9579
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
419 id
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
420 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
421 0 means end
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
422
9323
774afe44f17b some more info (copy & pasted from ML)
michael
parents: 9312
diff changeset
423 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
424 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
425 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
426 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
427
9295
michael
parents: 9294
diff changeset
428 name
michael
parents: 9294
diff changeset
429 the name of the info entry, valid names are
10873
4b956204bed0 moved file_size and len_in_msec
alex
parents: 10831
diff changeset
430 "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
431 "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
432 "StartTimestamp"
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
433 "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
434 "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
435 "Author"
97888c25ae60 changing name to "nut" for now, we can change it again if we agree on something else
michael
parents: 9335
diff changeset
436 "Description"
97888c25ae60 changing name to "nut" for now, we can change it again if we agree on something else
michael
parents: 9335
diff changeset
437 "Copyright"
9369
f7fc442571f7 added (PAL),(NTSC),..
alex
parents: 9361
diff changeset
438 "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
439 "Title"
9373
e1e2177841ef dvds have covers too - Andreas Hess <jaska@gmx.net>
alex
parents: 9372
diff changeset
440 "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
441 "Source" "DVD", "VCD", "CD", "MD", "FM radio", "VHS", "TV",
12391e52c2f7 -typo, +time, -ntsc/pal (idea by alex)
michael
parents: 9347
diff changeset
442 "LD"
9373
e1e2177841ef dvds have covers too - Andreas Hess <jaska@gmx.net>
alex
parents: 9372
diff changeset
443 Optional: appended PAL,NTSC,SECAM, ... in parentheses
9350
12391e52c2f7 -typo, +time, -ntsc/pal (idea by alex)
michael
parents: 9347
diff changeset
444 "CaptureDevice" "BT878", "BT848", "webcam", ... (more exact names are fine too)
12391e52c2f7 -typo, +time, -ntsc/pal (idea by alex)
michael
parents: 9347
diff changeset
445 "CreationTime" "2003-01-20 20:13:15Z", ...
12391e52c2f7 -typo, +time, -ntsc/pal (idea by alex)
michael
parents: 9347
diff changeset
446 (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
447 Note: dont forget the timezone
11975
645975e01061 replaygain
alex
parents: 10985
diff changeset
448 "ReplayGain"
9360
add934b25d6d "X-" prefix for nonstd fields & "keywords" idea by (Andreas Hess <jaska at gmx dot net>)
michael
parents: 9357
diff changeset
449 "Keywords"
9295
michael
parents: 9294
diff changeset
450 Note: if someone needs some others, please tell us about them, so we can
michael
parents: 9294
diff changeset
451 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
452 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
453 Note: MUST be less than 64 bytes long
9295
michael
parents: 9294
diff changeset
454
michael
parents: 9294
diff changeset
455 value
9579
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
456 value of this name/type pair
9295
michael
parents: 9294
diff changeset
457
9310
b16480522be9 some typos
michael
parents: 9307
diff changeset
458 stuffing
9579
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
459 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
460 purposes
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
461
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
462 info_table[][2]={
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
463 {NULL , NULL }, // end
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
464 {NULL , NULL },
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
465 {NULL , "UTF8"},
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
466 {NULL , "v"},
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
467 {NULL , "s"},
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
468 {"StreamId" , "v"},
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
469 {"SegmentId" , "v"},
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
470 {"StartTimestamp" , "v"},
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
471 {"EndTimestamp" , "v"},
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
472 {"Author" , "UTF8"},
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
473 {"Titel" , "UTF8"},
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
474 {"Description" , "UTF8"},
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
475 {"Copyright" , "UTF8"},
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
476 {"Encoder" , "UTF8"},
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
477 {"Keyword" , "UTF8"},
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
478 {"Cover" , "JPEG"},
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
479 {"Cover" , "PNG"},
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
480 };
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
481
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
482 Structure:
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
483
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
484 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
485 main header
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
486 stream_header (id=0)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
487 stream_header (id=1)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
488 ...
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
489 stream_header (id=n)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
490
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
491 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
492 and repeated headers MUST be identical
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
493
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
494 headers MUST be repeated every 10sec at least ? FIXME
10817
59ac254c2541 some updates
alex
parents: 10166
diff changeset
495 headers MUST be repeated BEFORE keyframes
9310
b16480522be9 some typos
michael
parents: 9307
diff changeset
496 headers MUST be repeated at least twice (so they exist 3 times in a file)
9295
michael
parents: 9294
diff changeset
497
9310
b16480522be9 some typos
michael
parents: 9307
diff changeset
498 Index
9580
88eabd7a3b3b index per stream
michael
parents: 9579
diff changeset
499 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
500 the end
9311
4b04416ada91 zero_bit for normal frames, so we can distinguish them from other packets
michael
parents: 9310
diff changeset
501 Note: in case of realtime streaming there is no end, so no index there either
9310
b16480522be9 some typos
michael
parents: 9307
diff changeset
502
b16480522be9 some typos
michael
parents: 9307
diff changeset
503 Info packets
b16480522be9 some typos
michael
parents: 9307
diff changeset
504 the info_packet can be repeated, it can also contain different names & values
b16480522be9 some typos
michael
parents: 9307
diff changeset
505 each time but only if allso the time is different
b16480522be9 some typos
michael
parents: 9307
diff changeset
506 Info packets can be used to describe the file or some part of it (chapters)
b16480522be9 some typos
michael
parents: 9307
diff changeset
507
b16480522be9 some typos
michael
parents: 9307
diff changeset
508 info packets, SHOULD be placed at the begin of the file at least
b16480522be9 some typos
michael
parents: 9307
diff changeset
509 for realtime streaming info packets will normally be transmitted when they apply
b16480522be9 some typos
michael
parents: 9307
diff changeset
510 for example, the current song title & artist of the currently shown music video
b16480522be9 some typos
michael
parents: 9307
diff changeset
511
b16480522be9 some typos
michael
parents: 9307
diff changeset
512 Stuffing packets
b16480522be9 some typos
michael
parents: 9307
diff changeset
513 can be used as a filler, for example to leave some empty space at the begin for
b16480522be9 some typos
michael
parents: 9307
diff changeset
514 a copy of the index
b16480522be9 some typos
michael
parents: 9307
diff changeset
515
b16480522be9 some typos
michael
parents: 9307
diff changeset
516 Unknown packets
b16480522be9 some typos
michael
parents: 9307
diff changeset
517 MUST be ignored by the decoder
b16480522be9 some typos
michael
parents: 9307
diff changeset
518
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
519 Sample code (GPL, & untested)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
520
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
521 typedef BufferContext{
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
522 uint8_t *buf;
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
523 uint8_t *buf_ptr;
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
524 }BufferContext;
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
525
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
526 static inline uint64_t get_bytes(BufferContext *bc, int count){
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
527 uint64_t val=0;
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
528
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
529 assert(count>0 && count<9)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
530
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
531 for(i=0; i<count; i++){
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
532 val <<=8;
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
533 val += *(bc->buf_ptr++);
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
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
536 return val;
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
537 }
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
538
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
539 static inline void put_bytes(BufferContext *bc, int count, uint64_t val){
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
540 uint64_t val=0;
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
541
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
542 assert(count>0 && count<9)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
543
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
544 for(i=count-1; i>=0; i--){
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
545 *(bc->buf_ptr++)= val >> (8*i);
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
546 }
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
547
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
548 return val;
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
549 }
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
550
10061
76b1c7d20da8 corrected the sample code
alex
parents: 9580
diff changeset
551 static inline uint64_t get_v(BufferContext *bc){
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
552 uint64_t val= 0;
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
553
10158
93e5428d0b3e some changes (michael: is the colorspace_type field needed?)
alex
parents: 10061
diff changeset
554 for(; space_left(bc) > 0; ){
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
555 int tmp= *(bc->buf_ptr++);
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
556 if(tmp&0x80)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
557 val= (val<<7) + tmp - 0x80;
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
558 else
9299
aa26f77e7aae remove non byte sized stuff
michael
parents: 9297
diff changeset
559 return (val<<7) + tmp;
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
560 }
9579
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
561
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
562 return -1;
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
563 }
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
564
10061
76b1c7d20da8 corrected the sample code
alex
parents: 9580
diff changeset
565 static inline int put_v(BufferContext *bc, uint64_t val){
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
566 int i;
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
567
10158
93e5428d0b3e some changes (michael: is the colorspace_type field needed?)
alex
parents: 10061
diff changeset
568 if(space_left(bc) < 9) return -1;
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
569
9579
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
570 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
571 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
572 if(val>>i == 0) break;
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
573 }
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
574
10827
michael
parents: 10824
diff changeset
575 for(i-=7; i>0; i-=7){
9294
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
576 *(bc->buf_ptr++)= 0x80 | (val>>i);
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 *(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
579
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
580 return 0;
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
581 }
89d27a306886 *signed int vlc (needs only 5 lines of code so its no increase of complexity)
michael
parents: 9422
diff changeset
582
9294
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 Example stream
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 main header
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
587 video_stream_header (stream 0, video jpjp, timebase 30, lsb_timestamp_length=8)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
588 video_stream_header (stream 1 subtitle usen, timebase 30, lsb_timestamp_length=8)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
589 video_stream_header (stream 2 subtitle atde, timebase 30, lsb_timestamp_length=8)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
590 audio_stream_header (stream 3, audio jpjp, timebase 1 , lsb_timestamp_length=8)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
591 audio_stream_header (stream 4, audio usen, timebase 1 , lsb_timestamp_length=8)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
592 index (stream 0)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
593 keyframe (stream 0, msb_timestamp=0, lsb_timestamp=0)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
594 keyframe (stream 1, msb_timestamp=0, lsb_timestamp=0)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
595 keyframe (stream 2, msb_timestamp=0, lsb_timestamp=0)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
596 keyframe (stream 3, msb_timestamp=0, lsb_timestamp=0)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
597 keyframe (stream 4, msb_timestamp=0, lsb_timestamp=0)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
598 frame (stream 0, lsb_timestamp=1)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
599 frame (stream 0, lsb_timestamp=2)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
600 ...
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
601 frame (stream 0, lsb_timestamp=30)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
602 keyframe (stream 3, msb_timestamp=0, lsb_timestamp=1)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
603 keyframe (stream 4, msb_timestamp=0, lsb_timestamp=1)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
604 frame (stream 0, lsb_timestamp=31)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
605 frame (stream 0, lsb_timestamp=32)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
606 ...
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
607 frame (stream 0, lsb_timestamp=60)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
608 frame (stream 1, lsb_timestamp=60)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
609 frame (stream 2, lsb_timestamp=60)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
610 keyframe (stream 3, msb_timestamp=0, lsb_timestamp=2)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
611 keyframe (stream 4, msb_timestamp=0, lsb_timestamp=2)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
612 frame (stream 0, lsb_timestamp=61)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
613 frame (stream 0, lsb_timestamp=62)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
614 ...
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
615 main header
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
616 video_stream_header (stream 0, video jpjp, timebase 30, lsb_timestamp_length=8)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
617 video_stream_header (stream 1 subtitle usen, timebase 30, lsb_timestamp_length=8)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
618 video_stream_header (stream 2 subtitle atde, timebase 30, lsb_timestamp_length=8)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
619 audio_stream_header (stream 3, audio jpjp, timebase 1 , lsb_timestamp_length=8)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
620 audio_stream_header (stream 4, audio usen, timebase 1 , lsb_timestamp_length=8)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
621 frame (stream 0, lsb_timestamp=255)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
622 frame (stream 0, msb_timestamp=1 lsb_timestamp=0)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
623 frame (stream 0, lsb_timestamp=1)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
624 frame (stream 0, lsb_timestamp=2)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
625 frame (stream 1, msb_timestamp=1 lsb_timestamp=2)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
626 frame (stream 2, msb_timestamp=1 lsb_timestamp=2)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
627 frame (stream 0, lsb_timestamp=3)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
628 frame (stream 0, lsb_timestamp=4)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
629 ...
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
630 keyframe (stream 3, msb_timestamp=0, lsb_timestamp=9)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
631 keyframe (stream 4, msb_timestamp=0, lsb_timestamp=9)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
632 main header
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
633 video_stream_header (stream 0, video jpjp, timebase 30, lsb_timestamp_length=8)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
634 video_stream_header (stream 1 subtitle usen, timebase 30, lsb_timestamp_length=8)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
635 video_stream_header (stream 2 subtitle atde, timebase 30, lsb_timestamp_length=8)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
636 audio_stream_header (stream 3, audio jpjp, timebase 1 , lsb_timestamp_length=8)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
637 audio_stream_header (stream 4, audio usen, timebase 1 , lsb_timestamp_length=8)
7159ed6a4d0b nonsense (MPlayer container format draft 0.01)
michael
parents:
diff changeset
638 index (stream 0)
10158
93e5428d0b3e some changes (michael: is the colorspace_type field needed?)
alex
parents: 10061
diff changeset
639
93e5428d0b3e some changes (michael: is the colorspace_type field needed?)
alex
parents: 10061
diff changeset
640 Authors
93e5428d0b3e some changes (michael: is the colorspace_type field needed?)
alex
parents: 10061
diff changeset
641
93e5428d0b3e some changes (michael: is the colorspace_type field needed?)
alex
parents: 10061
diff changeset
642 Folks from MPlayer Developers Mailinglist (http://www.mplayehrq.hu/).
93e5428d0b3e some changes (michael: is the colorspace_type field needed?)
alex
parents: 10061
diff changeset
643 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
644 Beregszaszi, Alex (alex@fsn.hu)
93e5428d0b3e some changes (michael: is the colorspace_type field needed?)
alex
parents: 10061
diff changeset
645 Bunkus, Moritz (moritz@bunkus.org)
93e5428d0b3e some changes (michael: is the colorspace_type field needed?)
alex
parents: 10061
diff changeset
646 Diedrich, Tobias (td@sim.uni-hannover.de)
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)