summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libm4a/m4a.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libm4a/m4a.h')
-rw-r--r--lib/rbcodec/codecs/libm4a/m4a.h138
1 files changed, 138 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libm4a/m4a.h b/lib/rbcodec/codecs/libm4a/m4a.h
new file mode 100644
index 0000000000..aa8e768045
--- /dev/null
+++ b/lib/rbcodec/codecs/libm4a/m4a.h
@@ -0,0 +1,138 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 Dave Chapman
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef _M4A_H
23#define _M4A_H
24
25#include <codecs.h>
26#include <inttypes.h>
27
28/* AAC codecdata appears to always be less than 8 bytes - see
29 AudioSpecificConfig2 in libfaad/mp4.c
30
31 ALAC codecdata appears to always be 44 bytes (see alac_set_info in
32 libalac/alac.c) but my test file contains 56 bytes.
33
34 So we go safe and round up to 64 bytes - if we find more than this,
35 we give an error (even though we could possibly continue), so we
36 can increase this buffer.
37*/
38
39#define MAX_CODECDATA_SIZE 64
40
41typedef struct {
42 struct codec_api* ci;
43 int eof;
44} stream_t;
45
46typedef uint32_t fourcc_t;
47
48typedef struct
49{
50 uint32_t first_chunk;
51 uint32_t num_samples;
52} sample_to_chunk_t;
53
54typedef struct
55{
56 uint32_t sample_count;
57 uint32_t sample_duration;
58} time_to_sample_t;
59
60typedef struct
61{
62 uint32_t sample;
63 uint32_t offset;
64} sample_offset_t;
65
66typedef struct
67{
68 uint16_t num_channels;
69 uint16_t sound_sample_size;
70 uint32_t sound_sample_rate;
71 fourcc_t format;
72 void *buf;
73
74 sample_to_chunk_t *sample_to_chunk;
75 uint32_t num_sample_to_chunks;
76
77 sample_offset_t *lookup_table;
78 uint32_t num_lookup_table;
79
80 time_to_sample_t *time_to_sample;
81 uint32_t num_time_to_samples;
82
83 uint32_t num_sample_byte_sizes;
84
85 uint32_t codecdata_len;
86 uint8_t codecdata[MAX_CODECDATA_SIZE];
87
88 int mdat_offset;
89 uint32_t mdat_len;
90#if 0
91 void *mdat;
92#endif
93} demux_res_t;
94
95int qtmovie_read(stream_t *stream, demux_res_t *demux_res);
96
97#ifndef MAKEFOURCC
98#define MAKEFOURCC(ch0, ch1, ch2, ch3) ( \
99 ( (int32_t)(char)(ch0) << 24 ) | \
100 ( (int32_t)(char)(ch1) << 16 ) | \
101 ( (int32_t)(char)(ch2) << 8 ) | \
102 ( (int32_t)(char)(ch3) ) )
103#endif
104
105#ifndef SLPITFOURCC
106/* splits it into ch0, ch1, ch2, ch3 - use for printf's */
107#define SPLITFOURCC(code) \
108 (char)((int32_t)code >> 24), \
109 (char)((int32_t)code >> 16), \
110 (char)((int32_t)code >> 8), \
111 (char)code
112#endif
113
114void stream_read(stream_t *stream, size_t len, void *buf);
115
116int32_t stream_tell(stream_t *stream);
117int32_t stream_read_int32(stream_t *stream);
118uint32_t stream_read_uint32(stream_t *stream);
119
120uint16_t stream_read_uint16(stream_t *stream);
121
122uint8_t stream_read_uint8(stream_t *stream);
123
124void stream_skip(stream_t *stream, size_t skip);
125void stream_seek(stream_t *stream, size_t offset);
126
127int stream_eof(stream_t *stream);
128
129void stream_create(stream_t *stream,struct codec_api* ci);
130unsigned int get_sample_offset(demux_res_t *demux_res, uint32_t sample);
131unsigned int m4a_seek (demux_res_t* demux_res, stream_t* stream,
132 uint32_t sound_sample_loc, uint32_t* sound_samples_done,
133 int* current_sample);
134unsigned int m4a_seek_raw (demux_res_t* demux_res, stream_t* stream,
135 uint32_t file_loc, uint32_t* sound_samples_done, int* current_sample);
136int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start);
137
138#endif /* STREAM_H */