diff options
author | Sean Bartell <wingedtachikoma@gmail.com> | 2011-06-25 21:32:25 -0400 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2012-04-25 22:13:20 +0200 |
commit | f40bfc9267b13b54e6379dfe7539447662879d24 (patch) | |
tree | 9b20069d5e62809ff434061ad730096836f916f2 /lib/rbcodec/codecs/libtremor/ivorbiscodec.h | |
parent | a0009907de7a0107d49040d8a180f140e2eff299 (diff) | |
download | rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.tar.gz rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.zip |
Add codecs to librbcodec.
Change-Id: Id7f4717d51ed02d67cb9f9cb3c0ada4a81843f97
Reviewed-on: http://gerrit.rockbox.org/137
Reviewed-by: Nils Wallménius <nils@rockbox.org>
Tested-by: Nils Wallménius <nils@rockbox.org>
Diffstat (limited to 'lib/rbcodec/codecs/libtremor/ivorbiscodec.h')
-rw-r--r-- | lib/rbcodec/codecs/libtremor/ivorbiscodec.h | 204 |
1 files changed, 204 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libtremor/ivorbiscodec.h b/lib/rbcodec/codecs/libtremor/ivorbiscodec.h new file mode 100644 index 0000000000..4fb041603d --- /dev/null +++ b/lib/rbcodec/codecs/libtremor/ivorbiscodec.h | |||
@@ -0,0 +1,204 @@ | |||
1 | /******************************************************************** | ||
2 | * * | ||
3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * | ||
4 | * * | ||
5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * | ||
6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * | ||
7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * | ||
8 | * * | ||
9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * | ||
10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * | ||
11 | * * | ||
12 | ******************************************************************** | ||
13 | |||
14 | function: libvorbis codec headers | ||
15 | |||
16 | ********************************************************************/ | ||
17 | |||
18 | #ifndef _vorbis_codec_h_ | ||
19 | #define _vorbis_codec_h_ | ||
20 | |||
21 | #ifdef __cplusplus | ||
22 | extern "C" | ||
23 | { | ||
24 | #endif /* __cplusplus */ | ||
25 | |||
26 | #include "ogg.h" | ||
27 | //#include <codecs/lib/codeclib.h> | ||
28 | |||
29 | typedef struct vorbis_info{ | ||
30 | int version; | ||
31 | int channels; | ||
32 | long rate; | ||
33 | |||
34 | /* The below bitrate declarations are *hints*. | ||
35 | Combinations of the three values carry the following implications: | ||
36 | |||
37 | all three set to the same value: | ||
38 | implies a fixed rate bitstream | ||
39 | only nominal set: | ||
40 | implies a VBR stream that averages the nominal bitrate. No hard | ||
41 | upper/lower limit | ||
42 | upper and or lower set: | ||
43 | implies a VBR bitstream that obeys the bitrate limits. nominal | ||
44 | may also be set to give a nominal rate. | ||
45 | none set: | ||
46 | the coder does not care to speculate. | ||
47 | */ | ||
48 | |||
49 | long bitrate_upper; | ||
50 | long bitrate_nominal; | ||
51 | long bitrate_lower; | ||
52 | |||
53 | void *codec_setup; | ||
54 | } vorbis_info; | ||
55 | |||
56 | /* vorbis_dsp_state buffers the current vorbis audio | ||
57 | analysis/synthesis state. The DSP state belongs to a specific | ||
58 | logical bitstream ****************************************************/ | ||
59 | typedef struct vorbis_dsp_state{ | ||
60 | vorbis_info *vi; | ||
61 | |||
62 | ogg_int32_t *residues[2]; | ||
63 | ogg_int32_t *floors; | ||
64 | ogg_int32_t *saved; | ||
65 | ogg_int32_t *saved_ptr[CHANNELS]; | ||
66 | |||
67 | int ri; | ||
68 | |||
69 | ogg_int32_t **pcmb; | ||
70 | ogg_int32_t **pcmret; | ||
71 | int pcm_storage; | ||
72 | int pcm_current; | ||
73 | int pcm_returned; | ||
74 | |||
75 | int eofflag; | ||
76 | |||
77 | long lW; | ||
78 | long W; | ||
79 | long nW; | ||
80 | |||
81 | ogg_int64_t granulepos; | ||
82 | ogg_int64_t sequence; | ||
83 | |||
84 | void *backend_state; | ||
85 | } vorbis_dsp_state; | ||
86 | |||
87 | typedef struct vorbis_block{ | ||
88 | /* necessary stream state for linking to the framing abstraction */ | ||
89 | oggpack_buffer opb; | ||
90 | |||
91 | long lW; | ||
92 | long W; | ||
93 | long nW; | ||
94 | int pcmend; | ||
95 | int mode; | ||
96 | |||
97 | int eofflag; | ||
98 | ogg_int64_t granulepos; | ||
99 | ogg_int64_t sequence; | ||
100 | vorbis_dsp_state *vd; /* For read-only access of configuration */ | ||
101 | |||
102 | /* local storage to avoid remallocing; it's up to the mapping to | ||
103 | structure it */ | ||
104 | void *localstore; | ||
105 | long localtop; | ||
106 | long localalloc; | ||
107 | long totaluse; | ||
108 | struct alloc_chain *reap; | ||
109 | } vorbis_block; | ||
110 | |||
111 | /* vorbis_block is a single block of data to be processed as part of | ||
112 | the analysis/synthesis stream; it belongs to a specific logical | ||
113 | bitstream, but is independant from other vorbis_blocks belonging to | ||
114 | that logical bitstream. *************************************************/ | ||
115 | |||
116 | struct alloc_chain{ | ||
117 | void *ptr; | ||
118 | struct alloc_chain *next; | ||
119 | }; | ||
120 | |||
121 | /* vorbis_info contains all the setup information specific to the | ||
122 | specific compression/decompression mode in progress (eg, | ||
123 | psychoacoustic settings, channel setup, options, codebook | ||
124 | etc). vorbis_info and substructures are in backends.h. | ||
125 | *********************************************************************/ | ||
126 | |||
127 | /* the comments are not part of vorbis_info so that vorbis_info can be | ||
128 | static storage */ | ||
129 | typedef struct vorbis_comment{ | ||
130 | /* unlimited user comment fields. libvorbis writes 'libvorbis' | ||
131 | whatever vendor is set to in encode */ | ||
132 | char **user_comments; | ||
133 | int *comment_lengths; | ||
134 | int comments; | ||
135 | char *vendor; | ||
136 | |||
137 | } vorbis_comment; | ||
138 | |||
139 | |||
140 | /* libvorbis encodes in two abstraction layers; first we perform DSP | ||
141 | and produce a packet (see docs/analysis.txt). The packet is then | ||
142 | coded into a framed OggSquish bitstream by the second layer (see | ||
143 | docs/framing.txt). Decode is the reverse process; we sync/frame | ||
144 | the bitstream and extract individual packets, then decode the | ||
145 | packet back into PCM audio. | ||
146 | |||
147 | The extra framing/packetizing is used in streaming formats, such as | ||
148 | files. Over the net (such as with UDP), the framing and | ||
149 | packetization aren't necessary as they're provided by the transport | ||
150 | and the streaming layer is not used */ | ||
151 | |||
152 | /* Vorbis PRIMITIVES: general ***************************************/ | ||
153 | |||
154 | extern void vorbis_info_init(vorbis_info *vi); | ||
155 | extern void vorbis_info_clear(vorbis_info *vi); | ||
156 | extern int vorbis_info_blocksize(vorbis_info *vi,int zo); | ||
157 | /* | ||
158 | extern void vorbis_comment_init(vorbis_comment *vc); | ||
159 | extern void vorbis_comment_add(vorbis_comment *vc, char *comment); | ||
160 | extern void vorbis_comment_add_tag(vorbis_comment *vc, | ||
161 | char *tag, char *contents); | ||
162 | extern void vorbis_comment_clear(vorbis_comment *vc); | ||
163 | */ | ||
164 | extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); | ||
165 | extern int vorbis_block_clear(vorbis_block *vb); | ||
166 | extern void vorbis_dsp_clear(vorbis_dsp_state *v); | ||
167 | |||
168 | /* Vorbis PRIMITIVES: synthesis layer *******************************/ | ||
169 | extern int vorbis_synthesis_idheader(ogg_packet *op); | ||
170 | extern int vorbis_synthesis_headerin(vorbis_info *vi,ogg_packet *op); | ||
171 | |||
172 | extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); | ||
173 | extern int vorbis_synthesis_restart(vorbis_dsp_state *v); | ||
174 | extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op); | ||
175 | extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op); | ||
176 | extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb); | ||
177 | extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm); | ||
178 | extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples); | ||
179 | extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op); | ||
180 | |||
181 | /* Vorbis ERRORS and return codes ***********************************/ | ||
182 | |||
183 | #define OV_FALSE -1 | ||
184 | #define OV_EOF -2 | ||
185 | #define OV_HOLE -3 | ||
186 | |||
187 | #define OV_EREAD -128 | ||
188 | #define OV_EFAULT -129 | ||
189 | #define OV_EIMPL -130 | ||
190 | #define OV_EINVAL -131 | ||
191 | #define OV_ENOTVORBIS -132 | ||
192 | #define OV_EBADHEADER -133 | ||
193 | #define OV_EVERSION -134 | ||
194 | #define OV_ENOTAUDIO -135 | ||
195 | #define OV_EBADPACKET -136 | ||
196 | #define OV_EBADLINK -137 | ||
197 | #define OV_ENOSEEK -138 | ||
198 | |||
199 | #ifdef __cplusplus | ||
200 | } | ||
201 | #endif /* __cplusplus */ | ||
202 | |||
203 | #endif | ||
204 | |||