annotate DOCS/tech/mpcf.txt @ 10770:7a2f6392fcf0

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