2 * Copyright (c) 2005, David McPaul
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
23 * OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <SupportDefs.h>
32 #define AUDIO_NONE 'NONE'
33 #define AUDIO_RAW 'raw '
34 #define AUDIO_TWOS1 'twos'
35 #define AUDIO_TWOS2 'sowt'
36 #define AUDIO_IMA4 'ima4'
37 #define AUDIO_MS_PCM02 0x6D730002
38 #define AUDIO_INTEL_PCM17 0x6D730011
39 #define AUDIO_MPEG3_CBR 0x6D730055
41 // this is all from the avi reader. we rework it for mp4
42 struct mp4_main_header
{
43 uint32 micro_sec_per_frame
;
44 uint32 max_bytes_per_sec
;
45 uint32 padding_granularity
;
48 uint32 initial_frames
;
50 uint32 suggested_buffer_size
;
55 struct mp4_stream_header
58 uint32 fourcc_handler
;
62 uint32 initial_frames
;
67 uint32 suggested_buffer_size
;
86 uint32 HorizontalResolution
;
87 uint32 VerticalResolution
;
89 float FrameRate
; // Frames per second
90 uint8
*theDecoderConfig
;
91 size_t DecoderConfigSize
;
96 uint32 compression
; // compression used (ie codecid)
97 uint32 codecSubType
; // Additional codecid
98 uint16 NoOfChannels
; // 1 = mono, 2 = stereo
99 uint16 SampleSize
; // bits per sample
100 float SampleRate
; // Samples per second
101 uint32 BufferSize
; // (Sample Rate * NoOfchannels * SampleSize * SamplesPerFrame) / 8 = bytes per second
102 uint32 FrameSize
; // No Of Samples in 1 frame of audio (SamplesPerFrame)
103 uint32 BitRate
; // Average Bitrate
104 uint8
*theDecoderConfig
;
105 size_t DecoderConfigSize
;
108 struct TimeToSample
{
113 struct CompTimeToSample
{
118 struct SampleToChunk
{
120 uint32 SamplesPerChunk
;
121 uint32 SampleDescriptionID
;
122 uint32 TotalPrevSamples
;
125 // Note standard is 32bits offsets but later is 64
126 // We standardise on 64 and convert older formats upwards
127 struct ChunkToOffset
{
135 struct SampleSizeEntry
{
141 uint32 ModificationTime
;
144 uint32 PreferredRate
; // Fixed point 16.16
145 uint16 PreferredVolume
; // Fixed point 8.8
149 uint32 pre_defined
[6];
155 uint64 ModificationTime
;
158 uint32 PreferredRate
; // Fixed point 16.16
159 uint16 PreferredVolume
; // Fixed point 8.8
163 uint32 pre_defined
[6];
169 uint32 ModificationTime
;
175 uint16 AlternateGroup
;
176 uint16 Volume
; // Fixed 8.8
178 int32 MatrixStructure
[9];
179 uint32 TrackWidth
; // Fixed 16.16
180 uint32 TrackHeight
; // Fixed 16.16
185 uint64 ModificationTime
;
191 uint16 AlternateGroup
;
192 uint16 Volume
; // Fixed 8.8
194 int32 MatrixStructure
[9];
195 uint32 TrackWidth
; // Fixed 16.16
196 uint32 TrackHeight
; // Fixed 16.16
201 uint32 ModificationTime
;
204 uint16 Language
; // Actually should be 1 bit followed by int(5)[3]
210 uint64 ModificationTime
;
213 uint16 Language
; // Actually should be 1 bit followed by int(5)[3]
233 struct array_header
{
239 uint16 DataReference
;
242 struct AudioSampleEntry
{
248 uint32 SampleRate
; // 16.16
251 struct AudioDescription
{
252 AudioSampleEntry theAudioSampleEntry
;
258 uint8
*theDecoderConfig
;
259 size_t DecoderConfigSize
;
262 struct VideoSampleEntry
{
265 uint32 pre_defined2
[3];
268 uint32 HorizontalResolution
;
269 uint32 VerticalResolution
;
272 char CompressorName
[32];
277 struct VideoDescription
{
278 VideoSampleEntry theVideoSampleEntry
;
281 uint8
*theDecoderConfig
;
282 size_t DecoderConfigSize
;
285 // The parts of the AAC ESDS we care about
288 uint8 sampleRateIndex
;
292 uint8 totalDataBlocksInFrame
;
295 #endif // MP4_STRUCTS_H