annotate DOCS/tech/mpcf.txt @ 10873:4b956204bed0

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