Chris@634
|
1 #ifndef IMAFENCODER_H
|
Chris@634
|
2 #define IMAFENCODER_H
|
Chris@634
|
3
|
Chris@634
|
4 //***********************************************************//
|
Chris@634
|
5 // Interactive Music Audio Format (IMAF) ENCODER //
|
Chris@634
|
6 // Version 2.0 //
|
Chris@634
|
7 // //
|
Chris@634
|
8 // Eugenio Oñate Hospital //
|
Chris@634
|
9 // Costantino Taglialatela & Jesus Corral Garcìa //
|
Chris@634
|
10 // //
|
Chris@634
|
11 // Copyright (c) 2013 Centre for Digital Music (C4DM) //
|
Chris@634
|
12 // Queen Mary University of London. All rights reserved. //
|
Chris@634
|
13 //***********************************************************//
|
Chris@634
|
14 // IM_AF Encoder.h //
|
Chris@634
|
15 //***********************************************************//
|
Chris@634
|
16
|
Chris@634
|
17
|
Chris@634
|
18 /* for FILE typedef, */
|
Chris@634
|
19 #include <stdio.h>
|
Chris@634
|
20
|
Chris@634
|
21 #define maxtracks 8 //change this value to support more than 8 audio tracks. This value was 6 before I changed it
|
Chris@634
|
22 #define maxgroups 2
|
Chris@634
|
23 #define maxpreset 10
|
Chris@634
|
24 #define maxrules 10
|
Chris@634
|
25 #define maxfilters 3 //Max number of Filters for an EQ preset
|
Chris@634
|
26 #define maxdynamic 2 //Max number of Dynamic Volume changes
|
Chris@634
|
27 #define num_ch 2 //Number of channel outputs (STEREO)
|
Chris@634
|
28
|
Chris@634
|
29 typedef long long u64;
|
Chris@634
|
30 typedef unsigned int u32;
|
Chris@634
|
31 typedef unsigned short u16;
|
Chris@634
|
32 typedef unsigned char u8;
|
Chris@634
|
33
|
Chris@634
|
34 //typedef struct nametrack { // Stores the different titles of the tracks
|
Chris@634
|
35 // char title[20];
|
Chris@634
|
36 //}nametrack[maxtracks];
|
Chris@634
|
37
|
Chris@634
|
38 typedef struct FileTypeBox
|
Chris@634
|
39 {
|
Chris@634
|
40 u32 size;
|
Chris@634
|
41 u32 type; // ftyp
|
Chris@634
|
42 u32 major_brand; // brand identifier
|
Chris@634
|
43 u32 minor_version; // informative integer for the mirror version
|
Chris@634
|
44 u32 compatible_brands[2]; //list of brands
|
Chris@634
|
45 }FileTypeBox;
|
Chris@634
|
46
|
Chris@634
|
47 typedef struct MovieBox //extends Box('moov')
|
Chris@634
|
48 {
|
Chris@634
|
49 u32 size;
|
Chris@634
|
50 u32 type; // moov
|
Chris@634
|
51
|
Chris@634
|
52 struct MovieHeaderBox
|
Chris@634
|
53 {
|
Chris@634
|
54 u32 size;
|
Chris@634
|
55 u32 type; // mvhd
|
Chris@634
|
56 u32 version; // version + flag
|
Chris@634
|
57 u32 creation_time;
|
Chris@634
|
58 u32 modification_time;
|
Chris@634
|
59 u32 timescale; // specifies the time-scale
|
Chris@634
|
60 u32 duration;
|
Chris@634
|
61 u32 rate; // typically 1.0
|
Chris@634
|
62 u16 volume; // typically full volume
|
Chris@634
|
63 u16 reserved; // =0
|
Chris@634
|
64 u32 reserved2[2]; //=0
|
Chris@634
|
65 u32 matrix[9]; // information matrix for video (u,v,w)
|
Chris@634
|
66 u32 pre_defined[6]; // =0
|
Chris@634
|
67 u32 next_track_ID; //non zero value for the next track ID
|
Chris@634
|
68 }MovieHeaderBox;
|
Chris@634
|
69
|
Chris@634
|
70 struct TrackBox
|
Chris@634
|
71 {
|
Chris@634
|
72 u32 size;
|
Chris@634
|
73 u32 type;
|
Chris@634
|
74 struct TrackHeaderBox
|
Chris@634
|
75 {
|
Chris@634
|
76 u32 size;
|
Chris@634
|
77 u32 type;
|
Chris@634
|
78 u32 version; // version + flag
|
Chris@634
|
79 u32 creation_time;
|
Chris@634
|
80 u32 modification_time;
|
Chris@634
|
81 u32 track_ID;
|
Chris@634
|
82 u32 reserved; // =0
|
Chris@634
|
83 u32 duration;
|
Chris@634
|
84 u32 reserved2[2]; // =0
|
Chris@634
|
85 u16 layer; // =0 // for video
|
Chris@634
|
86 u16 alternate_group; // =0
|
Chris@634
|
87 u16 volume; // full volume is 1 = 0x0100
|
Chris@634
|
88 u16 reserved3;// =0
|
Chris@634
|
89 u32 matrix[9]; // for video
|
Chris@634
|
90 u32 width; // video
|
Chris@634
|
91 u32 height; // video
|
Chris@634
|
92 }TrackHeaderBox;
|
Chris@634
|
93
|
Chris@634
|
94 struct MediaBox // extends Box('mdia')
|
Chris@634
|
95 {
|
Chris@634
|
96 u32 size;
|
Chris@634
|
97 u32 type;
|
Chris@634
|
98 struct MediaHeaderBox // extends FullBox('mdhd', version,0)
|
Chris@634
|
99 {
|
Chris@634
|
100 u32 size;
|
Chris@634
|
101 u32 type;
|
Chris@634
|
102 u32 version; // version + flag
|
Chris@634
|
103 u32 creation_time;
|
Chris@634
|
104 u32 modification_time;
|
Chris@634
|
105 u32 timescale;
|
Chris@634
|
106 u32 duration;
|
Chris@634
|
107 u16 language; // [pad,5x3] = 16 bits and pad = 0
|
Chris@634
|
108 u16 pre_defined; // =0
|
Chris@634
|
109 }MediaHeaderBox;
|
Chris@634
|
110 struct HandlerBox // extends FullBox('hdlr')
|
Chris@634
|
111 {
|
Chris@634
|
112 u32 size;
|
Chris@634
|
113 u32 type;
|
Chris@634
|
114 u32 version; // version = 0 + flag
|
Chris@634
|
115 u32 pre_defined; // =0
|
Chris@634
|
116 u32 handler_type; // = 'soun' for audio track, text or hint
|
Chris@634
|
117 u32 reserved[3]; // =0
|
Chris@634
|
118 unsigned char data[5]; // Does not work! only 4 bytes
|
Chris@634
|
119
|
Chris@634
|
120 }HandlerBox;
|
Chris@634
|
121 struct MediaInformationBox //extends Box('minf')
|
Chris@634
|
122 {
|
Chris@634
|
123 u32 size;
|
Chris@634
|
124 u32 type;
|
Chris@634
|
125 // smhd in sound track only!!
|
Chris@634
|
126 struct SoundMediaHeaderBox //extends FullBox('smhd')
|
Chris@634
|
127 {
|
Chris@634
|
128 u32 size;
|
Chris@634
|
129 u32 type;
|
Chris@634
|
130 u32 version;
|
Chris@634
|
131 u16 balance; // =0 place mono tracks in stereo. 0 is center
|
Chris@634
|
132 u16 reserved; // =0
|
Chris@634
|
133 }SoundMediaHeaderBox;
|
Chris@634
|
134 struct NullMediaHeaderBox //extends FullBox('nmhd')
|
Chris@634
|
135 {
|
Chris@634
|
136 u32 size;
|
Chris@634
|
137 u32 type;
|
Chris@634
|
138 u32 flags;
|
Chris@634
|
139 }NullMediaHeaderBox;
|
Chris@634
|
140 struct DataInformationBox //extends Box('dinf')
|
Chris@634
|
141 {
|
Chris@634
|
142 u32 size;
|
Chris@634
|
143 u32 type;
|
Chris@634
|
144 struct DataReferenceBox
|
Chris@634
|
145 {
|
Chris@634
|
146 u32 size;
|
Chris@634
|
147 u32 type;
|
Chris@634
|
148 u32 flags;
|
Chris@634
|
149 u32 entry_count; // counts the actual entries.
|
Chris@634
|
150 struct DataEntryUrlBox //extends FullBox('url', version=0, flags)
|
Chris@634
|
151 {
|
Chris@634
|
152 u32 size;
|
Chris@634
|
153 u32 type;
|
Chris@634
|
154 u32 flags;
|
Chris@634
|
155 }DataEntryUrlBox;
|
Chris@634
|
156 }DataReferenceBox;
|
Chris@634
|
157 }DataInformationBox;
|
Chris@634
|
158 struct SampleTableBox // extends Box('stbl')
|
Chris@634
|
159 {
|
Chris@634
|
160 u32 size;
|
Chris@634
|
161 u32 type;
|
Chris@634
|
162 struct TimeToSampleBox{
|
Chris@634
|
163 u32 size;
|
Chris@634
|
164 u32 type;
|
Chris@634
|
165 u32 version;
|
Chris@634
|
166 u32 entry_count;
|
Chris@634
|
167 u32 sample_count[3000];
|
Chris@634
|
168 u32 sample_delta[3000];
|
Chris@634
|
169 }TimeToSampleBox;
|
Chris@634
|
170 struct SampleDescriptionBox // stsd
|
Chris@634
|
171 {
|
Chris@634
|
172 u32 size;
|
Chris@634
|
173 u32 type;
|
Chris@634
|
174 u32 version;
|
Chris@634
|
175 u32 entry_count; // = 1 number of entries
|
Chris@634
|
176 // unsigned char esds[88];
|
Chris@634
|
177 struct TextSampleEntry{
|
Chris@634
|
178 u32 size;
|
Chris@634
|
179 u32 type; //tx3g
|
Chris@634
|
180 u32 a;
|
Chris@634
|
181 u32 b;
|
Chris@634
|
182 u32 displayFlags;
|
Chris@634
|
183 u8 horizontaljustification;
|
Chris@634
|
184 u8 verticaljustification;
|
Chris@634
|
185 u8 backgroundcolorrgba[4];
|
Chris@634
|
186 u16 top;
|
Chris@634
|
187 u16 left;
|
Chris@634
|
188 u16 bottom;
|
Chris@634
|
189 u16 right;
|
Chris@634
|
190 //StyleRecord
|
Chris@634
|
191 u16 startChar;
|
Chris@634
|
192 u16 endChar;
|
Chris@634
|
193 u16 fontID;
|
Chris@634
|
194 u8 facestyleflags;
|
Chris@634
|
195 u8 fontsize;
|
Chris@634
|
196 u8 textcolorrgba[4];
|
Chris@634
|
197 struct FontTableBoX{
|
Chris@634
|
198 u32 size;
|
Chris@634
|
199 u32 type;
|
Chris@634
|
200 u16 entrycount;
|
Chris@634
|
201 u16 fontID;
|
Chris@634
|
202 u8 fontnamelenght;
|
Chris@634
|
203 u8 font[5]; //Serif
|
Chris@634
|
204 }FontTableBox;
|
Chris@634
|
205 }TextSampleEntry;
|
Chris@634
|
206 struct AudioSampleEntry{
|
Chris@634
|
207 u32 size;
|
Chris@634
|
208 u32 type; //mp4a
|
Chris@634
|
209 char reserved[6];
|
Chris@634
|
210 u16 data_reference_index; // = 1
|
Chris@634
|
211 u32 reserved2[2];
|
Chris@634
|
212 u16 channelcount; // = 2
|
Chris@634
|
213 u16 samplesize; // = 16
|
Chris@634
|
214 u32 reserved3;
|
Chris@634
|
215 u32 samplerate; // 44100 << 16
|
Chris@634
|
216 // unsigned char esds[81];
|
Chris@634
|
217 struct ESbox{
|
Chris@634
|
218 u32 size;
|
Chris@634
|
219 u32 type;
|
Chris@634
|
220 u32 version;
|
Chris@634
|
221 struct ES_Descriptor{
|
Chris@634
|
222 unsigned char tag;
|
Chris@634
|
223 unsigned char length;
|
Chris@634
|
224 u16 ES_ID;
|
Chris@634
|
225 unsigned char mix;
|
Chris@634
|
226 struct DecoderConfigDescriptor{
|
Chris@634
|
227 unsigned char tag;
|
Chris@634
|
228 unsigned char length;
|
Chris@634
|
229 unsigned char objectProfileInd;
|
Chris@634
|
230 u32 mix;
|
Chris@634
|
231 u32 maxBitRate;
|
Chris@634
|
232 u32 avgBitrate;
|
Chris@634
|
233 /* struct DecoderSpecificInfo{
|
Chris@634
|
234 unsigned char tag;
|
Chris@634
|
235 unsigned length;
|
Chris@634
|
236 // unsigned char decSpecificInfosize;
|
Chris@634
|
237 unsigned char decSpecificInfoData[2];
|
Chris@634
|
238 }DecoderSpecificInfo;
|
Chris@634
|
239 */ }DecoderConfigDescriptor;
|
Chris@634
|
240 struct SLConfigDescriptor{
|
Chris@634
|
241 unsigned char tag;
|
Chris@634
|
242 unsigned char length;
|
Chris@634
|
243 unsigned char predifined;
|
Chris@634
|
244 }SLConfigDescriptor;
|
Chris@634
|
245 }ES_Descriptor;
|
Chris@634
|
246 }ESbox;
|
Chris@634
|
247 }AudioSampleEntry;
|
Chris@634
|
248 }SampleDescriptionBox;
|
Chris@634
|
249 struct SampleSizeBox{
|
Chris@634
|
250 u32 size;
|
Chris@634
|
251 u32 type;
|
Chris@634
|
252 u32 version;
|
Chris@634
|
253 u32 sample_size; // =0
|
Chris@634
|
254 u32 sample_count;
|
Chris@634
|
255 u32 entry_size[9000];
|
Chris@634
|
256 }SampleSizeBox;
|
Chris@634
|
257 struct SampleToChunk{
|
Chris@634
|
258 u32 size;
|
Chris@634
|
259 u32 type;
|
Chris@634
|
260 u32 version;
|
Chris@634
|
261 u32 entry_count;
|
Chris@634
|
262 u32 first_chunk;
|
Chris@634
|
263 u32 samples_per_chunk;
|
Chris@634
|
264 u32 sample_description_index;
|
Chris@634
|
265 }SampleToChunk;
|
Chris@634
|
266 struct ChunkOffsetBox{
|
Chris@634
|
267 u32 size;
|
Chris@634
|
268 u32 type;
|
Chris@634
|
269 u32 version;
|
Chris@634
|
270 u32 entry_count;
|
Chris@634
|
271 u32 chunk_offset[maxtracks];
|
Chris@634
|
272 }ChunkOffsetBox;
|
Chris@634
|
273 }SampleTableBox;
|
Chris@634
|
274 }MediaInformationBox;
|
Chris@634
|
275 }MediaBox;
|
Chris@634
|
276 }TrackBox[maxtracks]; // max 10 tracks
|
Chris@634
|
277
|
Chris@634
|
278 struct PresetContainerBox // extends Box('prco')
|
Chris@634
|
279 {
|
Chris@634
|
280 u32 size;
|
Chris@634
|
281 u32 type;
|
Chris@634
|
282 unsigned char num_preset;
|
Chris@634
|
283 unsigned char default_preset_ID;
|
Chris@634
|
284 struct PresetBox //extends FullBox('prst',version=0,flags)
|
Chris@634
|
285 {
|
Chris@634
|
286 u32 size;
|
Chris@634
|
287 u32 type;
|
Chris@634
|
288 u32 flags;
|
Chris@634
|
289 unsigned char preset_ID;
|
Chris@634
|
290 unsigned char num_preset_elements;
|
Chris@634
|
291 struct presElemId{
|
Chris@634
|
292 u32 preset_element_ID;
|
Chris@634
|
293 }presElemId[maxtracks];
|
Chris@634
|
294 unsigned char preset_type;
|
Chris@634
|
295 unsigned char preset_global_volume;
|
Chris@634
|
296
|
Chris@634
|
297 // if (preset_type == 0) || (preset_type == 8) - Static track volume preset
|
Chris@634
|
298 struct StaticTrackVolume{
|
Chris@634
|
299 struct presVolumElem{
|
Chris@634
|
300 u8 preset_volume_element;
|
Chris@634
|
301 struct EQ{ // if preset_type == 8 (with EQ)
|
Chris@634
|
302 u8 num_eq_filters;
|
Chris@634
|
303 struct Filter{
|
Chris@634
|
304 u8 filter_type;
|
Chris@634
|
305 u16 filter_reference_frequency;
|
Chris@634
|
306 u8 filter_gain;
|
Chris@634
|
307 u8 filter_bandwidth;
|
Chris@634
|
308 }Filter[maxfilters];
|
Chris@634
|
309 }EQ;
|
Chris@634
|
310 }presVolumElem[maxtracks];
|
Chris@634
|
311 }StaticTrackVolume;
|
Chris@634
|
312
|
Chris@634
|
313 // if (preset_type == 1) || (preset_type == 9) - Static object volume preset
|
Chris@634
|
314 struct StaticObjectVolume{
|
Chris@634
|
315 struct InputCH{
|
Chris@634
|
316 u8 num_input_channel;
|
Chris@634
|
317 }InputCH[maxtracks];
|
Chris@634
|
318 u8 output_channel_type;
|
Chris@634
|
319 struct presElVol_1{
|
Chris@634
|
320 struct Input{
|
Chris@634
|
321 struct Output{
|
Chris@634
|
322 u8 preset_volume_element;
|
Chris@634
|
323 }Output[num_ch];
|
Chris@634
|
324 struct EQ_1{ // if preset_type == 9 (with EQ)
|
Chris@634
|
325 u8 num_eq_filters;
|
Chris@634
|
326 struct Filter_1{
|
Chris@634
|
327 u8 filter_type;
|
Chris@634
|
328 u16 filter_reference_frequency;
|
Chris@634
|
329 u8 filter_gain;
|
Chris@634
|
330 u8 filter_bandwidth;
|
Chris@634
|
331 }Filter[maxfilters];
|
Chris@634
|
332 }EQ;
|
Chris@634
|
333 }Input[num_ch];
|
Chris@634
|
334 }presElVol[maxtracks];
|
Chris@634
|
335 }StaticObjectVolume;
|
Chris@634
|
336
|
Chris@634
|
337 // if (preset_type == 2) || (preset_type == 10) - Dynamic track volume preset
|
Chris@634
|
338 struct DynamicTrackVolume{
|
Chris@634
|
339 u16 num_updates;
|
Chris@634
|
340 struct DynamicChange{
|
Chris@634
|
341 u16 updated_sample_number;
|
Chris@634
|
342 struct presVolumElem_2{
|
Chris@634
|
343 u8 preset_volume_element;
|
Chris@634
|
344 struct EQ_2{ // if preset_type == 10 (with EQ)
|
Chris@634
|
345 u8 num_eq_filters;
|
Chris@634
|
346 struct Filter_2{
|
Chris@634
|
347 u8 filter_type;
|
Chris@634
|
348 u16 filter_reference_frequency;
|
Chris@634
|
349 u8 filter_gain;
|
Chris@634
|
350 u8 filter_bandwidth;
|
Chris@634
|
351 }Filter[maxfilters];
|
Chris@634
|
352 }EQ;
|
Chris@634
|
353 }presVolumElem[maxtracks];
|
Chris@634
|
354 }DynamicChange[maxdynamic];
|
Chris@634
|
355 }DynamicTrackVolume;
|
Chris@634
|
356
|
Chris@634
|
357 // if (preset_type == 3) || (preset_type == 11) - Dynamic object volume preset
|
Chris@634
|
358 struct DynamicObjectVolume{
|
Chris@634
|
359 u16 num_updates;
|
Chris@634
|
360 struct InputCH_3{
|
Chris@634
|
361 u8 num_input_channel;
|
Chris@634
|
362 }InputCH[maxtracks];
|
Chris@634
|
363 u8 output_channel_type;
|
Chris@634
|
364 struct DynamicChange_3{
|
Chris@634
|
365 u16 updated_sample_number;
|
Chris@634
|
366 struct presElVol{
|
Chris@634
|
367 struct Input_3{
|
Chris@634
|
368 struct Output_3{
|
Chris@634
|
369 u8 preset_volume_element;
|
Chris@634
|
370 }Output[num_ch];
|
Chris@634
|
371 struct EQ_3{ // if preset_type == 11 (with EQ)
|
Chris@634
|
372 u8 num_eq_filters;
|
Chris@634
|
373 struct Filter_3{
|
Chris@634
|
374 u8 filter_type;
|
Chris@634
|
375 u16 filter_reference_frequency;
|
Chris@634
|
376 u8 filter_gain;
|
Chris@634
|
377 u8 filter_bandwidth;
|
Chris@634
|
378 }Filter[maxfilters];
|
Chris@634
|
379 }EQ;
|
Chris@634
|
380 }Input[num_ch];
|
Chris@634
|
381 }presElVol[maxtracks];
|
Chris@634
|
382 }DynamicChange[maxdynamic];
|
Chris@634
|
383 }DynamicObjectVolume;
|
Chris@634
|
384
|
Chris@634
|
385 // if (preset_type == 4) || (preset_type == 12) - Dynamic track approximated volume preset
|
Chris@634
|
386 struct DynamicTrackApproxVolume{
|
Chris@634
|
387 u16 num_updates;
|
Chris@634
|
388 struct DynamicChange_4{
|
Chris@634
|
389 u16 start_sample_number;
|
Chris@634
|
390 u16 duration_update;
|
Chris@634
|
391 struct presElVol_4{
|
Chris@634
|
392 u8 end_preset_volume_element;
|
Chris@634
|
393 struct EQ_4{ // if preset_type == 12 (with EQ)
|
Chris@634
|
394 u8 num_eq_filters;
|
Chris@634
|
395 struct Filter_4{
|
Chris@634
|
396 u8 filter_type;
|
Chris@634
|
397 u16 filter_reference_frequency;
|
Chris@634
|
398 u8 end_filter_gain;
|
Chris@634
|
399 u8 filter_bandwidth;
|
Chris@634
|
400 }Filter[maxfilters];
|
Chris@634
|
401 }EQ;
|
Chris@634
|
402 }presElVol[maxtracks];
|
Chris@634
|
403 }DynamicChange[maxdynamic];
|
Chris@634
|
404 }DynamicTrackApproxVolume;
|
Chris@634
|
405
|
Chris@634
|
406 // if (preset_type == 5) || (preset_type == 13) - Dynamic object approximated volume preset
|
Chris@634
|
407 // THIS STRUCTURE GIVES STACK OVERFLOW PROBLEMS - MORE STACK SIZE NEEDED -> Needs investigation
|
Chris@634
|
408 struct DynamicObjectApproxVolume{
|
Chris@634
|
409 u16 num_updates;
|
Chris@634
|
410 struct InputCH_5{
|
Chris@634
|
411 u8 num_input_channel;
|
Chris@634
|
412 }InputCH[maxtracks];
|
Chris@634
|
413 u8 output_channel_type;
|
Chris@634
|
414 struct DynamicChange_5{
|
Chris@634
|
415 u16 start_sample_number;
|
Chris@634
|
416 u16 duration_update;
|
Chris@634
|
417 struct presElVol_5{
|
Chris@634
|
418 struct Input_5{
|
Chris@634
|
419 struct Output_5{
|
Chris@634
|
420 u8 preset_volume_element;
|
Chris@634
|
421 }Output[num_ch];
|
Chris@634
|
422 struct EQ_5{ // if preset_type == 11 (with EQ)
|
Chris@634
|
423 u8 num_eq_filters;
|
Chris@634
|
424 struct Filter_5{
|
Chris@634
|
425 u8 filter_type;
|
Chris@634
|
426 u16 filter_reference_frequency;
|
Chris@634
|
427 u8 end_filter_gain;
|
Chris@634
|
428 u8 filter_bandwidth;
|
Chris@634
|
429 }Filter[maxfilters];
|
Chris@634
|
430 }EQ;
|
Chris@634
|
431 }Input[num_ch];
|
Chris@634
|
432 }presElVol[maxtracks];
|
Chris@634
|
433 }DynamicChange[maxdynamic];
|
Chris@634
|
434 }DynamicObjectApproxVolume;
|
Chris@634
|
435
|
Chris@634
|
436 char preset_name[50];
|
Chris@634
|
437
|
Chris@634
|
438 }PresetBox[maxpreset];
|
Chris@634
|
439
|
Chris@634
|
440 }PresetContainerBox;
|
Chris@634
|
441
|
Chris@634
|
442 struct RulesContainer{
|
Chris@634
|
443 u32 size;
|
Chris@634
|
444 u32 type;
|
Chris@634
|
445 u16 num_selection_rules;
|
Chris@634
|
446 u16 num_mixing_rules;
|
Chris@634
|
447 struct SelectionRules{
|
Chris@634
|
448 u32 size;
|
Chris@634
|
449 u32 type;
|
Chris@634
|
450 u32 version;
|
Chris@634
|
451 u16 selection_rule_ID;
|
Chris@634
|
452 unsigned char selection_rule_type;
|
Chris@634
|
453 u32 element_ID;
|
Chris@634
|
454 // Only for Min/Max Rule
|
Chris@634
|
455 // if (selection_rule_type==0)
|
Chris@634
|
456 u16 min_num_elements;
|
Chris@634
|
457 u16 max_num_elements;
|
Chris@634
|
458 // Only for Exclusion and Implication Rules
|
Chris@634
|
459 // if (selection_rule_type==1 || selection_rule_type==3)
|
Chris@634
|
460 u32 key_element_ID;
|
Chris@634
|
461 char rule_description[20];
|
Chris@634
|
462 }SelectionRules;
|
Chris@634
|
463 struct MixingRules{
|
Chris@634
|
464 u32 size;
|
Chris@634
|
465 u32 type;
|
Chris@634
|
466 u32 version;
|
Chris@634
|
467 u16 mixing_rule_ID;
|
Chris@634
|
468 unsigned char mixing_type;
|
Chris@634
|
469 u32 element_ID;
|
Chris@634
|
470 u16 min_volume;
|
Chris@634
|
471 u16 max_volume;
|
Chris@634
|
472 u32 key_elem_ID;
|
Chris@634
|
473 char mix_description[17];
|
Chris@634
|
474 }MixingRules;
|
Chris@634
|
475 }RulesContainer;
|
Chris@634
|
476 struct GroupContainerBox{ //extends Box('grco')
|
Chris@634
|
477 u32 size; // = 10 + sizeGRUP
|
Chris@634
|
478 u32 type;
|
Chris@634
|
479 u16 num_groups;
|
Chris@634
|
480 struct GroupBox{ // extends FullBox('grup')
|
Chris@634
|
481 u32 size; // = 21 + 22 + 32 (+2 if group_activation_mode = 2)
|
Chris@634
|
482 u32 type;
|
Chris@634
|
483 u32 version;
|
Chris@634
|
484 u32 group_ID;
|
Chris@634
|
485 u16 num_elements;
|
Chris@634
|
486 struct groupElemId{
|
Chris@634
|
487 u32 element_ID;
|
Chris@634
|
488 }groupElemId[maxtracks];
|
Chris@634
|
489 unsigned char group_activation_mode;
|
Chris@634
|
490 u16 group_activation_elements_number;
|
Chris@634
|
491 u16 group_reference_volume;
|
Chris@634
|
492 char group_name[22];
|
Chris@634
|
493 char group_description[32];
|
Chris@634
|
494 }GroupBox[maxgroups];
|
Chris@634
|
495 }GroupContainerBox;
|
Chris@634
|
496 }MovieBox;
|
Chris@634
|
497
|
Chris@634
|
498 typedef struct MetaBox // extends FullBox ('meta')
|
Chris@634
|
499 {
|
Chris@634
|
500 u32 size;
|
Chris@634
|
501 u32 type;
|
Chris@634
|
502 u32 version;
|
Chris@634
|
503 struct theHandler //extends FullBox HandlerBox('hdlr')
|
Chris@634
|
504 {
|
Chris@634
|
505 u32 size;
|
Chris@634
|
506 u32 type;
|
Chris@634
|
507 u32 version; // version = 0 + flag
|
Chris@634
|
508 u32 pre_defined; // =0
|
Chris@634
|
509 u32 handler_type; // = 'meta' for Timed Metadata track
|
Chris@634
|
510 u32 reserved[3]; // =0
|
Chris@634
|
511 unsigned char name[4];
|
Chris@634
|
512 }theHandler;
|
Chris@634
|
513 struct file_locations //extends Box DataInformationBox('dinf')
|
Chris@634
|
514 {
|
Chris@634
|
515 u32 size;
|
Chris@634
|
516 u32 type;
|
Chris@634
|
517 /* struct DataReferenceBox2
|
Chris@634
|
518 {
|
Chris@634
|
519 u32 size;
|
Chris@634
|
520 u32 type;
|
Chris@634
|
521 u32 flags;
|
Chris@634
|
522 u32 entry_count; // = 1
|
Chris@634
|
523 struct DataEntryUrlBox2 //extends FullBox('url', version=0, flags)
|
Chris@634
|
524 {
|
Chris@634
|
525 u32 size;
|
Chris@634
|
526 u32 type;
|
Chris@634
|
527 u32 flags;
|
Chris@634
|
528 }DataEntryUrlBox;
|
Chris@634
|
529 }DataReferenceBox; */
|
Chris@634
|
530 }file_locations;
|
Chris@634
|
531 struct item_locations //extends FullBox ItemLocationBox('iloc')
|
Chris@634
|
532 {
|
Chris@634
|
533 u32 size;
|
Chris@634
|
534 u32 type;
|
Chris@634
|
535 u32 version; // version = 0 + flags
|
Chris@634
|
536 unsigned char offset_size; // = 4 bytes
|
Chris@634
|
537 unsigned char lenght_size; // = 4 bytes
|
Chris@634
|
538 unsigned char base_offset_size; // = 4 bytes
|
Chris@634
|
539 unsigned char reserved; // = 0
|
Chris@634
|
540 u16 item_count; // = 1
|
Chris@634
|
541 u16 item_ID; // = 1
|
Chris@634
|
542 u16 data_reference_index; // = 0 (this file)
|
Chris@634
|
543 u32 base_offset; // size=(base_offset_size*8)=4*8
|
Chris@634
|
544 u16 extent_count; // = 1
|
Chris@634
|
545 u32 extent_offset; // size=(offset_size*8)=4*8
|
Chris@634
|
546 u32 extent_length; // size=(lenght_size*8)=4*8
|
Chris@634
|
547 }item_locations;
|
Chris@634
|
548 struct item_infos //extends FullBox ItemInfoBox('iinf')
|
Chris@634
|
549 {
|
Chris@634
|
550 u32 size;
|
Chris@634
|
551 u32 type;
|
Chris@634
|
552 u32 version; // version = 0 + flag
|
Chris@634
|
553 u16 entry_count; // = 1
|
Chris@634
|
554 struct info_entry// extends FullBox ItemInfoEntry('infe')
|
Chris@634
|
555 {
|
Chris@634
|
556 u32 size;
|
Chris@634
|
557 u32 type;
|
Chris@634
|
558 u32 version; // = 0
|
Chris@634
|
559 u16 item_ID; // = 1
|
Chris@634
|
560 u16 item_protection_index; // = 0 for "unprotected"
|
Chris@634
|
561 char item_name[6]; // name with max 5 characters
|
Chris@634
|
562 char content_type[18]; // = 'application/other' -> 17 characters
|
Chris@634
|
563 char content_encoding[4]; // = 'jpg' for JPEG image -> 3 characters
|
Chris@634
|
564 }info_entry;
|
Chris@634
|
565 }item_infos;
|
Chris@634
|
566 struct XMLBox // extends FullBox('xml ')
|
Chris@634
|
567 {
|
Chris@634
|
568 u32 size;
|
Chris@634
|
569 u32 type;
|
Chris@634
|
570 u32 version;
|
Chris@634
|
571 char string[2000];
|
Chris@634
|
572 }XMLBox;
|
Chris@634
|
573 }MetaBox;
|
Chris@634
|
574
|
Chris@634
|
575 typedef struct MediaDataBox // extends Box('mdat')
|
Chris@634
|
576 {
|
Chris@634
|
577 u32 size;
|
Chris@634
|
578 u32 type;
|
Chris@634
|
579 unsigned char data;
|
Chris@634
|
580 }MediaDataBox;
|
Chris@634
|
581
|
Chris@634
|
582
|
Chris@634
|
583
|
Chris@634
|
584
|
Chris@634
|
585
|
Chris@634
|
586
|
Chris@634
|
587
|
Chris@634
|
588
|
Chris@634
|
589
|
Chris@634
|
590
|
Chris@634
|
591
|
Chris@634
|
592
|
Chris@634
|
593
|
Chris@634
|
594
|
Chris@634
|
595
|
Chris@634
|
596
|
Chris@634
|
597
|
Chris@634
|
598
|
Chris@634
|
599
|
Chris@634
|
600
|
Chris@634
|
601
|
Chris@634
|
602
|
Chris@634
|
603
|
Chris@634
|
604
|
Chris@634
|
605
|
Chris@634
|
606
|
Chris@634
|
607
|
Chris@634
|
608
|
Chris@634
|
609 #endif // IMAFENCODER_H
|