spAudio
Loading...
Searching...
No Matches
spMp4.h
1/*
2 * spMp4.h
3 *
4 * **** UNOFFICIAL VERSION, DON'T USE THIS API ****
5 */
6
7#ifndef __SPMP4_H
8#define __SPMP4_H
9
10#include <time.h>
11
12#include <sp/spChunk.h>
13#include <sp/spWave.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19#define SP_MP4_BOX_MIN_ENTRY_ALLOC_COUNT 4
20
21#define spMp4BoxSize spChunkSize
22
23#define SP_MP4_META_DATA_TYPE_INDICATOR_UTF8 1
24#define SP_MP4_META_DATA_TYPE_INDICATOR_UTF16 2
25#define SP_MP4_META_DATA_TYPE_INDICATOR_SJIS 3
26#define SP_MP4_META_DATA_TYPE_INDICATOR_UTF8_SORT 4
27#define SP_MP4_META_DATA_TYPE_INDICATOR_UTF16_SORT 5
28#define SP_MP4_META_DATA_TYPE_INDICATOR_JPEG 13
29#define SP_MP4_META_DATA_TYPE_INDICATOR_PNG 14
30#define SP_MP4_META_DATA_TYPE_INDICATOR_BE_SIGNED_INT 21
31#define SP_MP4_META_DATA_TYPE_INDICATOR_BE_UNSIGNED_INT 22
32#define SP_MP4_META_DATA_TYPE_INDICATOR_BE_FLOAT 23
33#define SP_MP4_META_DATA_TYPE_INDICATOR_BE_DOUBLE 24
34#define SP_MP4_META_DATA_TYPE_INDICATOR_BMP 27
35#define SP_MP4_META_DATA_TYPE_INDICATOR_QT_METADATA 28
36
37#define SP_MP4_META_DATA_TYPE_TITLE "\251nam"
38#define SP_MP4_META_DATA_TYPE_ARTIST "\251ART"
39#define SP_MP4_META_DATA_TYPE_ALBUM_ARTIST "aART"
40#define SP_MP4_META_DATA_TYPE_ALBUM "\251alb"
41#define SP_MP4_META_DATA_TYPE_COMPOSER "\251wrt"
42#define SP_MP4_META_DATA_TYPE_GENRE "\251gen"
43#define SP_MP4_META_DATA_TYPE_RELEASE "\251day"
44#define SP_MP4_META_DATA_TYPE_SOFTWARE "\251too"
45#define SP_MP4_META_DATA_TYPE_COPYRIGHT "cprt"
46#define SP_MP4_META_DATA_TYPE_COMMENT "\251cmt"
47#define SP_MP4_META_DATA_TYPE_TITLE_YOMI "sonm"
48#define SP_MP4_META_DATA_TYPE_ARTIST_YOMI "soar"
49#define SP_MP4_META_DATA_TYPE_ALBUM_ARTIST_YOMI "soaa"
50#define SP_MP4_META_DATA_TYPE_ALBUM_YOMI "soal"
51#define SP_MP4_META_DATA_TYPE_COMPOSER_YOMI "soco"
52#define SP_MP4_META_DATA_TYPE_TRACK "trkn"
53#define SP_MP4_META_DATA_TYPE_DISC "disc"
54#define SP_MP4_META_DATA_TYPE_TEMPO "tmpo"
55#define SP_MP4_META_DATA_TYPE_COMPILATION "cpil"
56#define SP_MP4_META_DATA_TYPE_GAPLESS "pgap"
57
58typedef struct _spMp4BoxHeader {
59 char type[4];
60 unsigned long size;
61 spMp4BoxSize largesize;
62 unsigned char version;
63 unsigned char flags[3];
64 spBool fullbox_flag;
65
66 spMp4BoxSize marginsize; /* internal */
67} spMp4BoxHeader;
68
69typedef struct _spMp4Box {
70 struct _spMp4Box *parent;
71 struct _spMp4Box *child;
72
73 struct _spMp4Box *prev;
74 struct _spMp4Box *next;
75
76 spFileOffset offset;
77
78 spMp4BoxHeader header;
79} spMp4Box;
80
81typedef struct _spMp4ULongOnlyBox {
82 struct _spMp4Box *parent;
83 struct _spMp4Box *child;
84
85 struct _spMp4Box *prev;
86 struct _spMp4Box *next;
87
88 spFileOffset offset;
89
90 spMp4BoxHeader header;
91
92 unsigned long value;
93} spMp4ULongOnlyBox;
94
95typedef struct _spMp4DataOnlyBox {
96 struct _spMp4Box *parent;
97 struct _spMp4Box *child;
98
99 struct _spMp4Box *prev;
100 struct _spMp4Box *next;
101
102 spFileOffset offset;
103
104 spMp4BoxHeader header;
105
106 char *data;
107} spMp4DataOnlyBox;
108
109typedef struct _spMp4MetaDataValueBox { /* 'data' */
110 struct _spMp4Box *parent;
111 struct _spMp4Box *child;
112
113 struct _spMp4Box *prev;
114 struct _spMp4Box *next;
115
116 spFileOffset offset;
117
118 spMp4BoxHeader header;
119
120 unsigned long type_indicator;
121 unsigned short country;
122 unsigned short language;
123 char *value;
124} spMp4MetaDataValueBox;
125
126typedef struct _spMp4UserDataStringBox {
127 struct _spMp4Box *parent;
128 struct _spMp4Box *child;
129
130 struct _spMp4Box *prev;
131 struct _spMp4Box *next;
132
133 spFileOffset offset;
134
135 spMp4BoxHeader header;
136
137 unsigned short size;
138 unsigned short language;
139 char *string;
140} spMp4UserDataStringBox;
141
142typedef struct _spMp4FileTypeBox { /* 'ftyp' */
143 struct _spMp4Box *parent;
144 struct _spMp4Box *child;
145
146 struct _spMp4Box *prev;
147 struct _spMp4Box *next;
148
149 spFileOffset offset;
150
151 spMp4BoxHeader header;
152
153 char major_brand[4];
154 long minor_version;
155
156 long nbrands;
157 char *compatible_brands;
158} spMp4FileTypeBox;
159
160typedef struct _spMp4MovieHeaderBox { /* 'mvhd' */
161 struct _spMp4MovieBox *parent;
162 struct _spMp4Box *child;
163
164 struct _spMp4Box *prev;
165 struct _spMp4Box *next;
166
167 spFileOffset offset;
168
169 spMp4BoxHeader header; /* full header */
170
171 union {
172 struct {
173 char creation_time[8];
174 char modification_time[8];
175 unsigned long timescale;
176 char duration[8];
177 } version1;
178
179 struct {
180 unsigned long creation_time;
181 unsigned long modification_time;
182 unsigned long timescale;
183 unsigned long duration;
184 } version0;
185 } u;
186
187 long rate;
188 short volume;
189 short reserved;
190 unsigned long reserved2[2];
191 long matrix[9];
192 unsigned long pre_defined[6];
193 unsigned long next_track_id;
194
195} spMp4MovieHeaderBox;
196
197typedef struct _spMp4TrackHeaderBox { /* 'tkhd' */
198 struct _spMp4TrackBox *parent;
199 struct _spMp4Box *child;
200
201 struct _spMp4Box *prev;
202 struct _spMp4Box *next;
203
204 spFileOffset offset;
205
206 spMp4BoxHeader header; /* full header */
207 union {
208 struct {
209 char creation_time[8];
210 char modification_time[8];
211 unsigned long track_id;
212 unsigned long reserved;
213 char duration[8];
214 } version1;
215
216 struct {
217 unsigned long creation_time;
218 unsigned long modification_time;
219 unsigned long track_id;
220 unsigned long reserved;
221 unsigned long duration;
222 } version0;
223 } u;
224
225 unsigned long reserved2[2];
226 short layer;
227 short alternate_group;
228 short volume;
229 unsigned short reserved3;
230 long matrix[9];
231
232 unsigned long width;
233 unsigned long height;
234} spMp4TrackHeaderBox;
235
236typedef struct _spMp4MediaHeaderBox { /* 'mdhd' */
237 struct _spMp4MediaBox *parent;
238 struct _spMp4Box *child;
239
240 struct _spMp4Box *prev;
241 struct _spMp4Box *next;
242
243 spFileOffset offset;
244
245 spMp4BoxHeader header; /* full header */
246
247 union {
248 struct {
249 char creation_time[8];
250 char modification_time[8];
251 unsigned long timescale;
252 char duration[8];
253 } version1;
254
255 struct {
256 unsigned long creation_time;
257 unsigned long modification_time;
258 unsigned long timescale;
259 unsigned long duration;
260 } version0;
261 } u;
262
263 unsigned short language;
264 unsigned short quality;
265} spMp4MediaHeaderBox;
266
267typedef struct _spMp4UserDataBox { /* 'udta' */
268 struct _spMp4Box *parent;
269 struct _spMp4Box *child;
270
271 struct _spMp4Box *prev;
272 struct _spMp4Box *next;
273
274 spFileOffset offset;
275
276 spMp4BoxHeader header;
277
278 struct _spMp4MetaBox *meta; /* optional */
279 spMp4Box *cprt; /* optional */
280 spMp4Box *tsel; /* optional */
281 spMp4Box *hinf; /* optional */
282 spMp4Box *hnti; /* optional */
283} spMp4UserDataBox;
284
285typedef struct _spMp4LanguageList {
286 unsigned short language_count;
287 short *language;
288} spMp4LanguageList;
289
290typedef struct _spMp4LanguageListBox { /* 'lang' */
291 struct _spMp4Box *parent;
292 struct _spMp4Box *child;
293
294 struct _spMp4Box *prev;
295 struct _spMp4Box *next;
296
297 spFileOffset offset;
298
299 spMp4BoxHeader header; /* full header */
300
301 unsigned long alloc_count; /* internal */
302 unsigned long entry_count;
303 spMp4LanguageList *language_lists;
304} spMp4LanguageListBox;
305
306typedef struct _spMp4CountryList {
307 unsigned short country_count;
308 char *country;
309} spMp4CountryList;
310
311typedef struct _spMp4CountryListBox { /* 'ctry' */
312 struct _spMp4Box *parent;
313 struct _spMp4Box *child;
314
315 struct _spMp4Box *prev;
316 struct _spMp4Box *next;
317
318 spFileOffset offset;
319
320 spMp4BoxHeader header; /* full header */
321
322 unsigned long alloc_count; /* internal */
323 unsigned long entry_count;
324 spMp4CountryList *country_lists;
325} spMp4CountryListBox;
326
327typedef struct _spMp4KeyEntry {
328 unsigned long size;
329 char name_space[4];
330 char *value;
331} spMp4KeyEntry;
332
333typedef struct _spMp4KeysBox { /* 'keys' */
334 struct _spMp4Box *parent;
335 struct _spMp4Box *child;
336
337 struct _spMp4Box *prev;
338 struct _spMp4Box *next;
339
340 spFileOffset offset;
341
342 spMp4BoxHeader header; /* full header */
343
344 unsigned long alloc_count; /* internal */
345 unsigned long entry_count;
346 spMp4KeyEntry *keys;
347} spMp4KeysBox;
348
349typedef struct _spMp4HandlerReferenceBox { /* 'hdlr' */
350 struct _spMp4Box *parent;
351 struct _spMp4Box *child;
352
353 struct _spMp4Box *prev;
354 struct _spMp4Box *next;
355
356 spFileOffset offset;
357
358 spMp4BoxHeader header; /* full header */
359
360 unsigned long pre_defined;
361 char handler_type[4];
362
363 unsigned long reserved[3]; /* reserved[0]: sometimes 'appl' */
364
365 char *name;
366} spMp4HandlerReferenceBox;
367
368typedef struct _spMp4VideoMediaHeaderBox { /* 'vmhd' */
369 struct _spMp4Box *parent;
370 struct _spMp4Box *child;
371
372 struct _spMp4Box *prev;
373 struct _spMp4Box *next;
374
375 spFileOffset offset;
376
377 spMp4BoxHeader header; /* full header */
378
379 unsigned short graphicsmode;
380 unsigned short opcolor[3];
381} spMp4VideoMediaHeaderBox;
382
383typedef struct _spMp4SoundMediaHeaderBox { /* 'smhd' */
384 struct _spMp4Box *parent;
385 struct _spMp4Box *child;
386
387 struct _spMp4Box *prev;
388 struct _spMp4Box *next;
389
390 spFileOffset offset;
391
392 spMp4BoxHeader header; /* full header */
393
394 unsigned short balance; /* 8.8 format; actual balance = (double)balance / 256.0 */
395 unsigned short reserved;
396} spMp4SoundMediaHeaderBox;
397
398typedef struct _spMp4HintMediaHeaderBox { /* 'hmhd' */
399 struct _spMp4Box *parent;
400 struct _spMp4Box *child;
401
402 struct _spMp4Box *prev;
403 struct _spMp4Box *next;
404
405 spFileOffset offset;
406
407 spMp4BoxHeader header; /* full header */
408
409 unsigned short maxPDUSize;
410 unsigned short avgPDUSize;
411 unsigned long maxBitRate;
412 unsigned long avgBitRate;
413 unsigned long reserved;
414} spMp4HintMediaHeaderBox;
415
416typedef struct _spMp4NullMediaHeaderBox { /* 'nmhd' */
417 struct _spMp4Box *parent;
418 struct _spMp4Box *child;
419
420 struct _spMp4Box *prev;
421 struct _spMp4Box *next;
422
423 spFileOffset offset;
424
425 spMp4BoxHeader header; /* full header */
426} spMp4NullMediaHeaderBox;
427
428typedef struct _spMp4DataSampleEntry {
429 char *data;
430} spMp4DataSampleEntry;
431
432typedef struct _spMp4RtpHintSampleEntry { /* 'rtp ' */
433 unsigned short hint_track_version;
434 unsigned short highest_compatible_version;
435 unsigned long max_packet_size;
436
437 spMp4ULongOnlyBox *tims; /* optional */
438 spMp4ULongOnlyBox *tsro; /* optional */
439 spMp4ULongOnlyBox *snro; /* optional */
440} spMp4RtpHintSampleEntry;
441
442typedef struct _spMp4BitRateBox { /* 'btrt' */
443 spMp4BoxHeader btrt;
444
445 unsigned long bufferSizeDB;
446 unsigned long maxBitRate;
447 unsigned long avgBitRate;
448} spMp4BitRateBox;
449
450typedef struct _spMp4XMLMetaDataSampleEntry { /* 'metx' */
451 char content_encoding[256];
452 char name_space[256];
453 char schema_location[256];
454
455 spMp4BitRateBox bitRate; /* optional */
456} spMp4XMLMetaDataSampleEntry;
457
458typedef struct _spMp4TextMetaDataSampleEntry { /* 'mett' */
459 char content_encoding[256];
460 char mime_format[256];
461
462 spMp4BitRateBox bitRate; /* optional */
463} spMp4TextMetaDataSampleEntry;
464
465typedef struct _spMp4SampleScaleBox { /* 'stsl' */
466 struct _spMp4Box *parent;
467 struct _spMp4Box *child;
468
469 struct _spMp4Box *prev;
470 struct _spMp4Box *next;
471
472 spFileOffset offset;
473
474 spMp4BoxHeader header; /* full header */
475
476 unsigned char flag;
477 unsigned char scale_method;
478 short display_center_x;
479 short display_center_y;
480} spMp4SampleScaleBox;
481
482typedef struct _spMp4PixelAspectRatioBox { /* 'pasp' */
483 struct _spMp4Box *parent;
484 struct _spMp4Box *child;
485
486 struct _spMp4Box *prev;
487 struct _spMp4Box *next;
488
489 spFileOffset offset;
490
491 spMp4BoxHeader header;
492
493 unsigned long hSpacing;
494 unsigned long vSpacing;
495} spMp4PixelAspectRatioBox;
496
497typedef struct _spMp4CleanApertureBox { /* 'clap' */
498 struct _spMp4Box *parent;
499 struct _spMp4Box *child;
500
501 struct _spMp4Box *prev;
502 struct _spMp4Box *next;
503
504 spFileOffset offset;
505
506 spMp4BoxHeader header;
507
508 unsigned long cleanApertureWidthN;
509 unsigned long cleanApertureWidthD;
510
511 unsigned long cleanApertureHeightN;
512 unsigned long cleanApertureHeightD;
513
514 unsigned long horizOffN;
515 unsigned long horizOffD;
516
517 unsigned long vertOffN;
518 unsigned long vertOffD;
519} spMp4CleanApertureBox;
520
521typedef struct _spMp4ColorParameterBox { /* 'colr' */
522 struct _spMp4Box *parent;
523 struct _spMp4Box *child;
524
525 struct _spMp4Box *prev;
526 struct _spMp4Box *next;
527
528 spFileOffset offset;
529
530 spMp4BoxHeader header;
531
532 char type[4];
533 /* type == nclc case */
534 short primaries_index;
535 short transfer_function_index;
536 short matrix_index;
537
538 /* type != nclc case */
539 char *data;
540} spMp4ColorParameterBox;
541
542typedef struct _spMp4VisualSampleEntry { /* 'vide' */
543 unsigned short version;
544 unsigned short revision;
545 unsigned long vendor;
546 unsigned long temporal_quality;
547 unsigned long spatial_quality;
548 unsigned short width;
549 unsigned short height;
550 unsigned long horizresolution; /* pixels per inch */
551 unsigned long vertresolution; /* pixels per inch */
552 unsigned long reserved2;
553 unsigned short frame_count;
554 char compressorname[32]; /* compressorname[0]: string length */
555 unsigned short depth;
556 short color_table_id; /*short pre_defined3;*/
557
558 spMp4ULongOnlyBox *gama; /* optional */
559 spMp4DataOnlyBox *fiel; /* optional */
560 spMp4DataOnlyBox *esds; /* optional */
561 spMp4CleanApertureBox *clap; /* optional */
562 spMp4ColorParameterBox *colr; /* optional */
563 spMp4PixelAspectRatioBox *pasp; /* optional */
564 spMp4SampleScaleBox *stsl; /* optional */
565 spMp4DataOnlyBox *avcC; /* optional */
566 spMp4DataOnlyBox *uuid; /* optional */
567 spMp4DataOnlyBox *mjqt; /* optional */
568 spMp4DataOnlyBox *mjht; /* optional */
569} spMp4VisualSampleEntry;
570
571typedef struct _spMp4AudioSampleEntry { /* 'soun' */
572 unsigned short version;
573 unsigned short revision;
574 unsigned long vendor;
575 unsigned short channelcount;
576 unsigned short samplesize;
577 short compression_id;
578 unsigned short reserved;
579 unsigned long samplerate; /* 16.16 format; actual rate = (double)samplerate / 65536.0 */
580
581 unsigned long samples_per_packet;
582 unsigned long bytes_per_packet;
583 unsigned long bytes_per_frame;
584 unsigned long bytes_per_sample;
585
586 spMp4DataOnlyBox *frma; /* optional */
587 spMp4DataOnlyBox *esds; /* optional */
588 spMp4DataOnlyBox *alac; /* optional */
589} spMp4AudioSampleEntry;
590
591typedef struct _spMp4AudioV2SampleEntry { /* 'soun' */
592 unsigned short version; /* 2 */
593 unsigned short revision; /* 0 */
594 unsigned long vendor; /* 0 */
595 unsigned short always3; /* 3 */
596 unsigned short always16; /* 16 */
597 short alwaysMinus2; /* -2 */
598 unsigned short always0; /* 0 */
599 unsigned long always65536; /* 65536 */
600
601 unsigned long sizeOfStructOnly;
602 double audioSampleRate;
603 unsigned long numAudioChannels;
604 unsigned long always7F000000; /* 0x7F000000 */
605 unsigned long constBitsPerChannels;
606 unsigned long formatSpecificFlags;
607 unsigned long constBytesPerAudioPacket;
608 unsigned long constLPCMFramesPerAudioPacket;
609
610 spMp4DataOnlyBox *frma; /* optional */
611 spMp4DataOnlyBox *esds; /* optional */
612 spMp4DataOnlyBox *alac; /* optional */
613} spMp4AudioV2SampleEntry;
614
615typedef struct _spMp4TimecodeSampleEntry { /* 'tmcd' */
616 unsigned long reserved; /* 0 */
617 unsigned long flags;
618 unsigned long timescale;
619 unsigned long frame_duration;
620 unsigned char number_of_frames;
621 unsigned char reserved2; /* 0 */
622
623 spMp4DataOnlyBox *name; /* optional */
624} spMp4TimecodeSampleEntry;
625
626typedef struct _spMp4SampleEntryBox {
627 struct _spMp4Box *parent;
628 struct _spMp4Box *child;
629
630 struct _spMp4Box *prev;
631 struct _spMp4Box *next;
632
633 spFileOffset offset;
634
635 spMp4BoxHeader header;
636
637 unsigned char reserved[6];
638 unsigned short data_reference_index; /* 1-based index */
639
640 union {
641 spMp4AudioSampleEntry soun;
642 spMp4VisualSampleEntry vide;
643 spMp4DataSampleEntry hint;
644 spMp4RtpHintSampleEntry rtp;
645 spMp4XMLMetaDataSampleEntry metx;
646 spMp4TextMetaDataSampleEntry mett;
647 spMp4TimecodeSampleEntry tmcd;
648 spMp4DataSampleEntry data;
649 } u;
650} spMp4SampleEntryBox;
651
652typedef struct _spMp4TimeToSampleEntry {
653 unsigned long sample_count;
654 unsigned long sample_delta;
655} spMp4TimeToSampleEntry;
656
657typedef struct _spMp4TimeToSampleBox { /* 'stts' */
658 struct _spMp4SampleTableBox *parent;
659 struct _spMp4Box *child;
660
661 struct _spMp4Box *prev;
662 struct _spMp4Box *next;
663
664 spFileOffset offset;
665
666 spMp4BoxHeader header; /* full header */
667
668 unsigned long alloc_count; /* internal */
669 unsigned long entry_count;
670 spMp4TimeToSampleEntry *entries;
671
672 unsigned long total_sample; /* internal */
673#ifdef SP_SUPPORT_64BIT_INT
674 spLong64 total_duration; /* internal */
675#else
676 char total_duration[8]; /* internal */
677#endif
678} spMp4TimeToSampleBox;
679
680typedef struct _spMp4SampleToChunkEntry {
681 unsigned long first_chunk;
682 unsigned long samples_per_chunk;
683 unsigned long sample_description_index;
684} spMp4SampleToChunkEntry;
685
686typedef struct _spMp4SampleToChunkBox { /* 'stsc' */
687 struct _spMp4SampleTableBox *parent;
688 struct _spMp4Box *child;
689
690 struct _spMp4Box *prev;
691 struct _spMp4Box *next;
692
693 spFileOffset offset;
694
695 spMp4BoxHeader header; /* full header */
696
697 unsigned long alloc_count; /* internal */
698 unsigned long entry_count;
699 spMp4SampleToChunkEntry *entries;
700} spMp4SampleToChunkBox;
701
702typedef struct _spMp4CompositionOffsetEntry {
703 unsigned long sample_count;
704 unsigned long sample_offset;
705} spMp4CompositionOffsetEntry;
706
707typedef struct _spMp4CompositionOffsetBox { /* 'ctts' */
708 struct _spMp4SampleTableBox *parent;
709 struct _spMp4Box *child;
710
711 struct _spMp4Box *prev;
712 struct _spMp4Box *next;
713
714 spFileOffset offset;
715
716 spMp4BoxHeader header; /* full header */
717
718 unsigned long alloc_count; /* internal */
719 unsigned long entry_count;
720 spMp4CompositionOffsetEntry *entries;
721} spMp4CompositionOffsetBox;
722
723typedef struct _spMp4ChunkOffsetBox { /* 'stco' */
724 struct _spMp4SampleTableBox *parent;
725 struct _spMp4Box *child;
726
727 struct _spMp4Box *prev;
728 struct _spMp4Box *next;
729
730 spFileOffset offset;
731
732 spMp4BoxHeader header; /* full header */
733
734 unsigned long alloc_count; /* internal */
735 unsigned long entry_count;
736 spFileOffset *chunk_offset;
737} spMp4ChunkOffsetBox;
738
739typedef struct _spMp4SyncSampleBox { /* 'stss' */
740 struct _spMp4SampleTableBox *parent;
741 struct _spMp4Box *child;
742
743 struct _spMp4Box *prev;
744 struct _spMp4Box *next;
745
746 spFileOffset offset;
747
748 spMp4BoxHeader header; /* full header */
749
750 unsigned long alloc_count; /* internal */
751 unsigned long entry_count;
752 unsigned long *sample_number;
753} spMp4SyncSampleBox;
754
755typedef struct _spMp4ShadowSyncSampleEntry {
756 unsigned long shadowed_sample_number;
757 unsigned long sync_sample_number;
758} spMp4ShadowSyncSampleEntry;
759
760typedef struct _spMp4ShadowSyncSampleBox { /* 'stsh' */
761 struct _spMp4SampleTableBox *parent;
762 struct _spMp4Box *child;
763
764 struct _spMp4Box *prev;
765 struct _spMp4Box *next;
766
767 spFileOffset offset;
768
769 spMp4BoxHeader header; /* full header */
770
771 unsigned long alloc_count; /* internal */
772 unsigned long entry_count;
773 spMp4ShadowSyncSampleEntry *entries;
774} spMp4ShadowSyncSampleBox;
775
776typedef struct _spMp4SampleDescriptionBox { /* 'stsd' */
777 struct _spMp4SampleTableBox *parent;
778 struct _spMp4Box *child;
779
780 struct _spMp4Box *prev;
781 struct _spMp4Box *next;
782
783 spFileOffset offset;
784
785 spMp4BoxHeader header; /* full header */
786
787 unsigned long alloc_count; /* internal */
788 unsigned long entry_count;
789 spMp4SampleEntryBox *entries;
790 unsigned long end_marker_size; /* internal */
791} spMp4SampleDescriptionBox;
792
793typedef struct _spMp4SampleDependencyTypeBox { /* 'sdtp' */
794 struct _spMp4SampleTableBox *parent;
795 struct _spMp4Box *child;
796
797 struct _spMp4Box *prev;
798 struct _spMp4Box *next;
799
800 spFileOffset offset;
801
802 spMp4BoxHeader header; /* full header */
803
804 unsigned long entry_count;
805 unsigned char *entries;
806} spMp4SampleDependencyTypeBox;
807
808typedef struct _spMp4DegradationPriorityBox { /* 'stdp' */
809 struct _spMp4SampleTableBox *parent;
810 struct _spMp4Box *child;
811
812 struct _spMp4Box *prev;
813 struct _spMp4Box *next;
814
815 spFileOffset offset;
816
817 spMp4BoxHeader header; /* full header */
818
819 unsigned long entry_count;
820 unsigned short *priority;
821} spMp4DegradationPriorityBox;
822
823typedef struct _spMp4SampleSizeBox { /* 'stsz' or 'stz2' */
824 struct _spMp4SampleTableBox *parent;
825 struct _spMp4Box *child;
826
827 struct _spMp4Box *prev;
828 struct _spMp4Box *next;
829
830 spFileOffset offset;
831
832 spMp4BoxHeader header; /* full header */
833
834 unsigned long sample_size; /* 'stsz' only */
835 unsigned char field_size; /* 'stz2' only */
836
837 unsigned long alloc_count; /* internal */
838 unsigned long entry_count;
839
840 unsigned long *entries;
841} spMp4SampleSizeBox;
842
843typedef struct _spMp4SampleTableBox { /* 'stbl' */
844 struct _spMp4MediaInformationBox *parent;
845 struct _spMp4Box *child;
846
847 struct _spMp4Box *prev;
848 struct _spMp4Box *next;
849
850 spFileOffset offset;
851
852 spMp4BoxHeader header;
853
854 spMp4SampleDescriptionBox *stsd;
855 spMp4TimeToSampleBox *stts;
856 spMp4CompositionOffsetBox *ctts; /* optional */
857 spMp4SampleToChunkBox *stsc;
858
859 spMp4SampleSizeBox *stsz; /* or 'stz2' */
860 spMp4ChunkOffsetBox *stco;
861 spMp4SyncSampleBox *stss; /* optional */
862 spMp4ShadowSyncSampleBox *stsh; /* optional */
863 spMp4DegradationPriorityBox *stdp; /* optional */
864 spMp4SampleDependencyTypeBox *sdtp; /* optional */
865} spMp4SampleTableBox;
866
867typedef struct _spMp4DataReferenceBox { /* 'dref' */
868 struct _spMp4DataInformationBox *parent;
869 struct _spMp4Box *child;
870
871 struct _spMp4Box *prev;
872 struct _spMp4Box *next;
873
874 spFileOffset offset; /* full header */
875
876 spMp4BoxHeader header;
877
878 unsigned long entry_count;
879} spMp4DataReferenceBox;
880
881typedef struct _spMp4DataInformationBox { /* 'dinf' */
882 struct _spMp4MediaInformationBox *parent;
883 struct _spMp4Box *child;
884
885 struct _spMp4Box *prev;
886 struct _spMp4Box *next;
887
888 spFileOffset offset; /* full header */
889
890 spMp4BoxHeader header;
891
892 spMp4DataReferenceBox *dref;
893} spMp4DataInformationBox;
894
895typedef struct _spMp4MediaInformationBox { /* 'minf' */
896 struct _spMp4MediaBox *parent;
897 struct _spMp4Box *child;
898
899 struct _spMp4Box *prev;
900 struct _spMp4Box *next;
901
902 spFileOffset offset;
903
904 spMp4BoxHeader header;
905
906 union {
907 spMp4VideoMediaHeaderBox *vmhd;
908 spMp4SoundMediaHeaderBox *smhd;
909 spMp4HintMediaHeaderBox *hmhd;
910 spMp4NullMediaHeaderBox *nmhd;
911 } u;
912
913 spMp4DataInformationBox *dinf;
914 spMp4SampleTableBox *stbl;
915 spMp4HandlerReferenceBox *hdlr; /* optional */
916} spMp4MediaInformationBox;
917
918typedef struct _spMp4MediaBox { /* 'mdia' */
919 struct _spMp4TrackBox *parent;
920 struct _spMp4Box *child;
921
922 struct _spMp4Box *prev;
923 struct _spMp4Box *next;
924
925 spFileOffset offset;
926
927 spMp4BoxHeader header;
928
929 spMp4MediaHeaderBox *mdhd;
930
931 spMp4HandlerReferenceBox *hdlr;
932 spMp4MediaInformationBox *minf;
933 spMp4UserDataBox *udta; /* optional */
934} spMp4MediaBox;
935
936typedef struct _spMp4TrackReferenceBox { /* 'tref' */
937 struct _spMp4TrackBox *parent;
938 struct _spMp4Box *child;
939
940 struct _spMp4Box *prev;
941 struct _spMp4Box *next;
942
943 spFileOffset offset;
944
945 spMp4BoxHeader header;
946
947 spMp4BoxHeader reference_type;
948 unsigned long *track_ids;
949} spMp4TrackReferenceBox;
950
951typedef struct _spMp4EditListEntryV0 {
952 unsigned long segment_duration;
953 long media_time;
954 unsigned long media_rate; /* 16.16 format */
955} spMp4EditListEntryV0;
956
957typedef struct _spMp4EditListEntryV1 {
958#ifdef SP_SUPPORT_64BIT_INT
959 spULong64 segment_duration;
960 spLong64 media_time;
961#else
962 char segment_duration[8];
963 char media_time[8];
964#endif
965 unsigned long media_rate; /* 16.16 format */
966} spMp4EditListEntryV1;
967
968typedef struct _spMp4EditListBox { /* 'elst' */
969 struct _spMp4Box *parent;
970 struct _spMp4Box *child;
971
972 struct _spMp4Box *prev;
973 struct _spMp4Box *next;
974
975 spFileOffset offset;
976
977 spMp4BoxHeader header; /* full header */
978
979 unsigned long alloc_count; /* internal */
980 unsigned long entry_count;
981 union {
982 spMp4EditListEntryV0 *edit_list_table_v0;
983 spMp4EditListEntryV1 *edit_list_table_v1;
984 } u;
985} spMp4EditListBox;
986
987typedef struct _spMp4MetaBox { /* 'meta' */
988 struct _spMp4Box *parent;
989 struct _spMp4Box *child;
990
991 struct _spMp4Box *prev;
992 struct _spMp4Box *next;
993
994 spFileOffset offset;
995
996 spMp4BoxHeader header; /* full header */
997
998 spMp4HandlerReferenceBox *hdlr;
999 spMp4Box *ilst;
1000 spMp4ULongOnlyBox *mhdr; /* optional */
1001 spMp4KeysBox *keys; /* optional */
1002 spMp4CountryListBox *ctry; /* optional */
1003 spMp4LanguageListBox *lang; /* optional */
1004} spMp4MetaBox;
1005
1006typedef struct _spMp4TrackBox { /* 'trak' */
1007 struct _spMp4MovieBox *parent; /* 'moov' */
1008 struct _spMp4Box *child;
1009
1010 struct _spMp4Box *prev;
1011 struct _spMp4Box *next;
1012
1013 spFileOffset offset;
1014
1015 spMp4BoxHeader header;
1016
1017 spMp4TrackHeaderBox *tkhd;
1018
1019 spMp4DataOnlyBox *clip; /* optional */
1020 spMp4Box *matt; /* optional */
1021 spMp4Box *edts; /* optional */
1022 spMp4TrackReferenceBox *tref; /* optional */
1023 spMp4DataOnlyBox *load; /* optional */
1024 spMp4Box *imap; /* optional */
1025
1026 spMp4MediaBox *mdia;
1027 spMp4UserDataBox *udta; /* optional */
1028} spMp4TrackBox;
1029
1030typedef struct _spMp4MovieBox { /* 'moov' */
1031 struct _spMp4Box *parent;
1032 struct _spMp4Box *child; /* normally 'mvhd' */
1033
1034 struct _spMp4Box *prev;
1035 struct _spMp4Box *next;
1036
1037 spFileOffset offset;
1038
1039 spMp4BoxHeader header;
1040
1041 spMp4MovieHeaderBox *mvhd;
1042 spMp4TrackBox *trak;
1043 spMp4UserDataBox *udta; /* optional */
1044} spMp4MovieBox;
1045
1046typedef struct _spMp4Header {
1047 struct _spMp4Box *parent; /* NULL */
1048 struct _spMp4Box *child; /* normally 'ftyp' */
1049
1050 struct _spMp4Box *prev; /* NULL */
1051 struct _spMp4Box *next; /* NULL */
1052
1053 spFileOffset offset;
1054
1055 spMp4BoxHeader header; /* dummy */
1056
1057 spMp4FileTypeBox *ftyp; /* first child */
1058 spMp4MovieBox *moov;
1059 struct _spMp4Box *mdat;
1060} spMp4Header;
1061
1062typedef spMp4BoxSize (*spMp4BoxUpdateFunc)(spMp4Box *box, void *data);
1063
1064extern unsigned short spGetMp4LangCode(const char *lang);
1065extern void spGetMp4LangStr(unsigned short code, char *lang, int lang_size);
1066
1067extern spBool spEqMp4BoxType(spMp4Box *box, const char *type);
1068
1069extern spMp4BoxSize spGetMp4BoxContentMarginSize(spMp4Box *box);
1070extern spBool spSetMp4BoxContentMarginSize(spMp4Box *box, spMp4BoxSize marginsize);
1071extern spBool spSetMp4BoxHeaderContentSize(spMp4BoxHeader *box_header, spMp4BoxSize size);
1072extern spBool spSetMp4BoxContentSize(spMp4Box *box, spMp4BoxSize size, spBool propagate_size);
1073extern spMp4BoxSize spGetMp4BoxHeaderContentSize(spMp4BoxHeader *box_header);
1074extern spMp4BoxSize spGetMp4BoxHeaderBoxSize(spMp4BoxHeader *box_header);
1075extern spMp4BoxSize spGetMp4BoxHeaderSize(spMp4Box *box);
1076
1077extern spMp4BoxSize spGetMp4BoxSize(spMp4Box *box, char *string/* = char string[5] or NULL */);
1078extern spMp4BoxSize spGetMp4BoxContentSize(spMp4Box *box, char *string/* = char string[5] or NULL */);
1079
1080extern spBool spGetMp4BoxHandleType(spMp4Box *box, char *type);
1081
1082extern spMp4BoxSize spUpdateMp4ULongOnlyBox(spMp4ULongOnlyBox *ulobox, unsigned long value);
1083extern spMp4Box *spAppendMp4ULongOnlyBox(spMp4Box *parent, const char *type, unsigned long value);
1084
1085extern spMp4BoxSize spUpdateMp4DataOnlyBox(spMp4DataOnlyBox *dobox, const char *data, spMp4BoxSize size, spBool propagate_size);
1086extern spMp4Box *spAppendMp4DataOnlyBox(spMp4Box *parent, const char *type, const char *data, spMp4BoxSize size);
1087
1088extern spMp4MetaBox *spAppendMp4UserDataMetaBox(spMp4Box *parent, spMp4BoxSize meta_size, const char *handler_type, const char *handler_name);
1089
1090extern spMp4BoxSize spUpdateMp4UserDataStringBox(spMp4UserDataStringBox *udsbox, short language, const char *string, spBool propagate_size);
1091extern spMp4Box *spAppendMp4UserDataStringBox(spMp4Box *parent, const char *type, short language, const char *string);
1092
1093/* 'data' */
1094extern spMp4BoxSize spUpdateMp4MetaDataValueBox(spMp4MetaDataValueBox *databox,
1095 unsigned long type_indicator, unsigned short country, unsigned short language,
1096 const char *value, spMp4BoxSize value_size, spBool propagate_size);
1097extern spMp4MetaDataValueBox *spAppendMp4MetaDataValueBox(spMp4Box *parent, const char *type, unsigned long type_indicator,
1098 unsigned short country, unsigned short language,
1099 const char *value, spMp4BoxSize value_size);
1100extern spMp4MetaDataValueBox *spAppendMp4MetaDataUTF8String(spMp4MetaBox *meta, const char *type,
1101 unsigned short country, unsigned short language, const char *utf8str);
1102extern spMp4MetaDataValueBox *spAppendMp4MetaDataUTF8StringFromLocaleCode(spMp4MetaBox *meta, const char *type,
1103 unsigned short country, unsigned short language, const unsigned char *str_in_locale);
1104
1105extern spBool spParseMp4MetaDataUTF8StringToLocaleCode(spMp4MetaDataValueBox *databox, unsigned char *str_in_locale, long size);
1106extern char *xspParseMp4MetaDataUTF8StringToLocaleCode(spMp4MetaDataValueBox *databox);
1107extern const char *spGetMp4MetaDataUTF8String(spMp4MetaBox *meta, const char *type);
1108extern spBool spGetMp4MetaDataUTF8StringToLocaleCode(spMp4MetaBox *meta, const char *type, unsigned char *str_in_locale, long size);
1109extern char *xspGetMp4MetaDataUTF8StringToLocaleCode(spMp4MetaBox *meta, const char *type);
1110
1111extern unsigned long spParseMp4MetaDataBESignedInt(spMp4MetaDataValueBox *databox, long *number);
1112extern unsigned long spParseMp4MetaDataBEUnsignedInt(spMp4MetaDataValueBox *databox, unsigned long *number);
1113extern spBool spGetMp4MetaDataTempo(spMp4MetaBox *meta, long *tempo);
1114extern spBool spGetMp4MetaDataBoolean(spMp4MetaBox *meta, const char *type, spBool *flag);
1115extern spBool spGetMp4MetaDataGapless(spMp4MetaBox *meta, spBool *flag);
1116extern spBool spGetMp4MetaDataCompilation(spMp4MetaBox *meta, spBool *flag);
1117extern spMp4MetaDataValueBox *spAppendMp4MetaDataBESignedInt(spMp4MetaBox *meta, const char *type, long number, unsigned long size);
1118extern spMp4MetaDataValueBox *spAppendMp4MetaDataBEUnsignedInt(spMp4MetaBox *meta, const char *type, unsigned long number, unsigned long size);
1119extern spMp4MetaDataValueBox *spAppendMp4MetaDataTempo(spMp4MetaBox *meta, long tempo);
1120extern spMp4MetaDataValueBox *spAppendMp4MetaDataBoolean(spMp4MetaBox *meta, const char *type, spBool flag);
1121extern spMp4MetaDataValueBox *spAppendMp4MetaDataGapless(spMp4MetaBox *meta, spBool flag);
1122extern spMp4MetaDataValueBox *spAppendMp4MetaDataCompilation(spMp4MetaBox *meta, spBool flag);
1123
1124extern spBool spParseMp4MetaDataTrackNumber(spMp4MetaDataValueBox *databox, unsigned short *number, unsigned short *total);
1125extern spBool spParseMp4MetaDataDiscNumber(spMp4MetaDataValueBox *databox, unsigned short *number, unsigned short *total);
1126extern spBool spGetMp4MetaDataTrackNumber(spMp4MetaBox *meta, unsigned short *number, unsigned short *total);
1127extern spBool spGetMp4MetaDataDiscNumber(spMp4MetaBox *meta, unsigned short *number, unsigned short *total);
1128extern spMp4MetaDataValueBox *spAppendMp4MetaDataTrackNumber(spMp4MetaBox *meta, unsigned short number, unsigned short total);
1129extern spMp4MetaDataValueBox *spAppendMp4MetaDataDiscNumber(spMp4MetaBox *meta, unsigned short number, unsigned short total);
1130
1131/* 'stsh' */
1132extern unsigned long spAppendMp4ShadowSyncSample(spMp4ShadowSyncSampleBox *stsh,
1133 unsigned long shadowed_sample_number, unsigned long sync_sample_number);
1134
1135/* 'stss' */
1136extern unsigned long spAppendMp4SyncSample(spMp4SyncSampleBox *stss, unsigned long sample);
1137
1138/* 'stco' */
1139unsigned long spAppendMp4ChunkOffset(spMp4ChunkOffsetBox *stco, spFileOffset offset);
1140
1141/* 'stsz' */
1142extern unsigned long spGetMp4SampleSize(spMp4SampleSizeBox *stsz, unsigned long sample); /* 'stsz' or 'stz2' */
1143extern spBool spSetMp4SampleSize(spMp4SampleSizeBox *stsz, unsigned long sample, unsigned long size);
1144extern unsigned long spAppendMp4SampleSize(spMp4SampleSizeBox *stsz, unsigned long size);
1145
1146/* 'stsc' */
1147extern unsigned long spAppendMp4SampleToChunk(spMp4SampleToChunkBox *stsc,
1148 unsigned long chunk /* 1-based chunk */, unsigned long samples_per_chunk, unsigned long sample_description_index);
1149
1150/* 'stts' */
1151extern unsigned long spGetMp4SampleDuration(spMp4TimeToSampleBox *stts, unsigned long sample);
1152extern unsigned long spGetMp4MaxSampleDuration(spMp4TimeToSampleBox *stts);
1153extern unsigned long spAppendMp4SampleDuration(spMp4TimeToSampleBox *stts, unsigned long sample, unsigned long sample_delta);
1154
1155/* 'stsd' */
1156extern spMp4SampleEntryBox *spAppendMp4SampleDescriptionEntry(spMp4SampleDescriptionBox *stsd, const char *codingname, unsigned short data_reference_index);
1157
1158/* 'vmhd' */
1159extern spMp4BoxSize spUpdateMp4VideoMediaHeaderBox(spMp4VideoMediaHeaderBox *vmhd, unsigned short graphicsmode, unsigned short opcolor[3]);
1160/* 'smhd' */
1161extern spMp4BoxSize spUpdateMp4SoundMediaHeaderBox(spMp4SoundMediaHeaderBox *smhd, unsigned short balance);
1162/* 'hmhd' */
1163extern spMp4BoxSize spUpdateMp4HintMediaHeaderBox(spMp4HintMediaHeaderBox *hmhd, unsigned short maxPDUSize, unsigned short avgPDUSize,
1164 unsigned long maxBitRate, unsigned long avgBitRate);
1165
1166/* 'keys' */
1167extern spMp4BoxSize spUpdateMp4KeysBox(spMp4KeysBox *keys, spMp4KeyEntry *entries, long count, spBool propagate_size);
1168
1169/* 'hdlr' */
1170extern spMp4BoxSize spUpdateMp4HandlerReferenceBox(spMp4HandlerReferenceBox *hdlr, const char *handler_type, const char *name, spBool propagate_size);
1171
1172/* 'mdhd' */
1173extern spMp4BoxSize spUpdateMp4MediaHeaderBoxV0(spMp4MediaHeaderBox *mdhd,
1174 time_t creation_time, time_t modification_time,
1175 unsigned long timescale, unsigned long duration,
1176 unsigned short language, unsigned short quality);
1177#ifdef SP_SUPPORT_64BIT_INT
1178extern spMp4BoxSize spUpdateMp4MediaHeaderBoxV1(spMp4MediaHeaderBox *mdhd,
1179 time_t creation_time, time_t modification_time,
1180 unsigned long timescale, spLong64 duration,
1181 unsigned short language, unsigned short quality);
1182#endif
1183
1184/* 'dref' */
1185extern spMp4Box *spAppendMp4DataReferenceEntry(spMp4DataReferenceBox *dref, const char *type, const char *data, long size);
1186
1187/* 'tref' */
1188extern spMp4BoxSize spUpdateMp4TrackReferenceBox(spMp4TrackReferenceBox *tref, const char *reference_type,
1189 unsigned long *track_ids, long count, spBool propagate_size);
1190
1191/* 'tkhd' */
1192extern spMp4BoxSize spUpdateMp4TrackHeaderBoxV0(spMp4TrackHeaderBox *tkhd, unsigned long flags,
1193 time_t creation_time, time_t modification_time,
1194 unsigned long track_id, unsigned long duration,
1195 short layer, short alternate_group, short volume, long matrix[9],
1196 unsigned long width, unsigned long height);
1197#ifdef SP_SUPPORT_64BIT_INT
1198extern spMp4BoxSize spUpdateMp4TrackHeaderBoxV1(spMp4TrackHeaderBox *tkhd, unsigned long flags,
1199 time_t creation_time, time_t modification_time,
1200 unsigned long track_id, spLong64 duration,
1201 short layer, short alternate_group, short volume, long matrix[9],
1202 unsigned long width, unsigned long height);
1203#endif
1204
1205/* 'mvhd' */
1206extern spMp4BoxSize spUpdateMp4MovieHeaderBoxV0(spMp4MovieHeaderBox *mvhd,
1207 time_t creation_time, time_t modification_time,
1208 unsigned long timescale, unsigned long duration,
1209 long rate, short volume, long matrix[9], unsigned long next_track_id);
1210#ifdef SP_SUPPORT_64BIT_INT
1211extern spMp4BoxSize spUpdateMp4MovieHeaderBoxV1(spMp4MovieHeaderBox *mvhd,
1212 time_t creation_time, time_t modification_time,
1213 unsigned long timescale, spLong64 duration,
1214 long rate, short volume, long matrix[9], unsigned long next_track_id);
1215#endif
1216
1217/* 'ftyp' */
1218extern spMp4BoxSize spUpdateMp4FileTypeBox(spMp4FileTypeBox *ftypbox, const char *major_brand, long minor_version,
1219 long nbrands, const char *compatible_brands);
1220
1221extern void spPropagateMp4BoxContentSize(spMp4Box *parent, spChunkSize size_diff);
1222
1223extern spMp4BoxSize spReadMp4Header(spMp4Header *header, FILE *fp);
1224extern spBool spFreeMp4Header(spMp4Header *header);
1225extern spBool spInitMp4HeaderWithCB(spMp4Header *header, spMp4BoxUpdateFunc update_func, void *data);
1226extern spBool spInitMp4Header(spMp4Header *header, const char *major_brand, long minor_version,
1227 long nbrands, const char *compatible_brands);
1228
1229extern spMp4BoxSize spWriteMp4Header(spMp4Header *header, spMp4BoxSize moov_size, spMp4Box **paused_box, FILE *fp);
1230extern spMp4BoxSize spRewriteMp4Header(spMp4Header *header, spMp4BoxSize mdat_size, spMp4Box **paused_box, FILE *fp);
1231
1232extern spMp4BoxSize spCopyMp4Header(spMp4Header *dest_header, spMp4Header *src_header);
1233
1234extern spMp4Box *spCreateMp4BoxWithCB(spMp4Box *parent, const char *type, spMp4BoxUpdateFunc update_func, void *data);
1235extern spMp4Box *spCreateMp4Box(spMp4Box *parent, const char *type);
1236
1237extern spMp4Box *spFindMp4BoxFromHeader(spMp4Header *header, const char *type, const char *parent_type);
1238extern spMp4Box *spFindMp4Box(spMp4Box *box, const char *type, const char *parent_type);
1239extern spMp4TrackBox *spFindMp4TrackBox(spMp4Header *header, long index, const char *handler_type);
1240extern unsigned long spGetMp4MaxTrackId(spMp4Header *header);
1241extern spMp4SampleTableBox *spGetMp4TrackSampleTableBox(spMp4TrackBox *trak);
1242extern spMp4SampleEntryBox *spGetMp4TrackSampleEntryBox(spMp4TrackBox *trak, unsigned long index);
1243
1244extern spMp4TrackBox *spAppendMp4SoundTrackBox(spMp4Header *header, unsigned long track_id,
1245 const char *codingname, unsigned short data_reference_index,
1246 unsigned short channelcount, unsigned short samplesize,
1247 short compression_id, double samplerate, char stz2_field_size, spBool co64_flag,
1248 spMp4BoxUpdateFunc update_func, void *data);
1249
1250extern spFileOffset spGetMp4MdatContentOffset(spMp4Header *header);
1251extern unsigned long spConvertMp4TimeToSample(spMp4TimeToSampleBox *stts, spULong t, unsigned long *remainder);
1252extern unsigned long spConvertMp4ChunkToSample(spMp4SampleToChunkBox *stsc, unsigned long chunk /* 1-based */,
1253 unsigned long *samples_per_chunk, unsigned long *description_index);
1254/* returns 1-based index of the chunk */
1255extern unsigned long spConvertMp4SampleToChunk(spMp4SampleToChunkBox *stsc, unsigned long description_index, unsigned long sample,
1256 unsigned long *remainder);
1257extern spFileOffset spConvertMp4SampleToFileOffset(spMp4SampleToChunkBox *stsc, unsigned long description_index, unsigned long sample,
1258 unsigned long *chunk, unsigned long *remainder, unsigned long *sample_size);
1259extern spMp4TrackBox *spFindMp4NextChunkFromFileOffset(spMp4Header *header, spFileOffset offset,
1260 spFileOffset *o_offset, unsigned long *chunk /* 1-based */);
1261
1262extern spBool spParseMp4SongInfo(spMp4MetaBox *meta, spSongInfoV2 *song_info);
1263extern spBool spAppendMp4SongInfo(spMp4MetaBox *meta, spSongInfoV2 *song_info);
1264
1265extern void spShowMp4HeaderInfo(spMp4Header *header);
1266
1267extern void spConvMp4MatrixToDouble(long *imatrix, double *omatrix);
1268extern void spConvDoubleMatrixToMp4(double *imatrix, long *omatrix);
1269extern void spMultMp4MatrixToXY(long *matrix, long *x, long *y);
1270extern void spMultMp4MatrixToXYZ(long *matrix, long *x, long *y, long *z);
1271
1272#ifdef __cplusplus
1273} /* Close scope of 'extern "C"' declaration */
1274#endif
1275
1276#endif /* __SPMP4_H */
int spBool
Definition spWave.h:138