Commit first part of FS#10832 by Juliusz Chroboczek. Allows playback of unstreamable...
[kugel-rb.git] / apps / codecs / libm4a / m4a.h
blob066f54b722feae16a107453bf01d4ef702382a0e
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 Dave Chapman
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #ifndef _M4A_H
23 #define _M4A_H
25 #include <codecs.h>
26 #include <inttypes.h>
28 /* AAC codecdata appears to always be less than 8 bytes - see
29 AudioSpecificConfig2 in libfaad/mp4.c
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.
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.
39 #define MAX_CODECDATA_SIZE 64
41 typedef struct {
42 struct codec_api* ci;
43 int eof;
44 } stream_t;
46 typedef uint32_t fourcc_t;
48 typedef struct
50 uint16_t num_channels;
51 uint16_t sound_sample_size;
52 uint32_t sound_sample_rate;
53 fourcc_t format;
54 void *buf;
56 struct {
57 uint32_t first_chunk;
58 uint32_t num_samples;
59 } *sample_to_chunk;
60 uint32_t num_sample_to_chunks;
62 uint32_t *chunk_offset;
63 uint32_t num_chunk_offsets;
65 struct {
66 uint32_t sample_count;
67 uint32_t sample_duration;
68 } *time_to_sample;
69 uint32_t num_time_to_samples;
71 uint16_t *sample_byte_size;
72 uint32_t num_sample_byte_sizes;
74 uint32_t codecdata_len;
75 uint8_t codecdata[MAX_CODECDATA_SIZE];
77 int mdat_offset;
78 uint32_t mdat_len;
79 #if 0
80 void *mdat;
81 #endif
82 } demux_res_t;
84 int qtmovie_read(stream_t *stream, demux_res_t *demux_res);
86 #ifndef MAKEFOURCC
87 #define MAKEFOURCC(ch0, ch1, ch2, ch3) ( \
88 ( (int32_t)(char)(ch0) << 24 ) | \
89 ( (int32_t)(char)(ch1) << 16 ) | \
90 ( (int32_t)(char)(ch2) << 8 ) | \
91 ( (int32_t)(char)(ch3) ) )
92 #endif
94 #ifndef SLPITFOURCC
95 /* splits it into ch0, ch1, ch2, ch3 - use for printf's */
96 #define SPLITFOURCC(code) \
97 (char)((int32_t)code >> 24), \
98 (char)((int32_t)code >> 16), \
99 (char)((int32_t)code >> 8), \
100 (char)code
101 #endif
103 void stream_read(stream_t *stream, size_t len, void *buf);
105 int32_t stream_tell(stream_t *stream);
106 int32_t stream_read_int32(stream_t *stream);
107 uint32_t stream_read_uint32(stream_t *stream);
109 int16_t stream_read_int16(stream_t *stream);
110 uint16_t stream_read_uint16(stream_t *stream);
112 int8_t stream_read_int8(stream_t *stream);
113 uint8_t stream_read_uint8(stream_t *stream);
115 void stream_skip(stream_t *stream, size_t skip);
116 void stream_seek(stream_t *stream, size_t offset);
118 int stream_eof(stream_t *stream);
120 void stream_create(stream_t *stream,struct codec_api* ci);
121 int get_sample_info(demux_res_t *demux_res, uint32_t sample,
122 uint32_t *sample_duration, uint32_t *sample_byte_size);
123 unsigned int get_sample_offset(demux_res_t *demux_res, uint32_t sample);
124 unsigned int alac_seek (demux_res_t* demux_res, stream_t* stream,
125 uint32_t sound_sample_loc, uint32_t* sound_samples_done,
126 int* current_sample);
127 unsigned int alac_seek_raw (demux_res_t* demux_res, stream_t* stream,
128 uint32_t file_loc, uint32_t* sound_samples_done, int* current_sample);
130 #endif /* STREAM_H */