annotate DOCS/tech/mpcf.txt @ 11269:669e67c3d6b3

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