annotate DOCS/tech/mpcf.txt @ 10109:b84118357b83

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