New makefile solution: A single invocation of 'make' to build the entire tree. Fully...
[kugel-rb.git] / apps / codecs / libtremor / ivorbiscodec.h
blob2574a11f2a25551c2ca77328d18efa694633c2b2
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 ********************************************************************
14 function: libvorbis codec headers
16 ********************************************************************/
18 #ifndef _vorbis_codec_h_
19 #define _vorbis_codec_h_
21 #ifdef __cplusplus
22 extern "C"
24 #endif /* __cplusplus */
26 #include "ogg.h"
28 typedef struct vorbis_info{
29 int version;
30 int channels;
31 long rate;
33 /* The below bitrate declarations are *hints*.
34 Combinations of the three values carry the following implications:
36 all three set to the same value:
37 implies a fixed rate bitstream
38 only nominal set:
39 implies a VBR stream that averages the nominal bitrate. No hard
40 upper/lower limit
41 upper and or lower set:
42 implies a VBR bitstream that obeys the bitrate limits. nominal
43 may also be set to give a nominal rate.
44 none set:
45 the coder does not care to speculate.
48 long bitrate_upper;
49 long bitrate_nominal;
50 long bitrate_lower;
52 void *codec_setup;
53 } vorbis_info;
55 /* vorbis_dsp_state buffers the current vorbis audio
56 analysis/synthesis state. The DSP state belongs to a specific
57 logical bitstream ****************************************************/
58 typedef struct vorbis_dsp_state{
59 vorbis_info *vi;
61 ogg_int32_t **pcm;
62 ogg_int32_t **pcmb;
63 ogg_int32_t **pcmret;
64 int pcm_storage;
65 int pcm_current;
66 int pcm_returned;
68 int eofflag;
70 long lW;
71 long W;
72 long nW;
73 long centerW;
75 ogg_int64_t granulepos;
76 ogg_int64_t sequence;
78 void *backend_state;
79 } vorbis_dsp_state;
81 typedef struct vorbis_block{
82 /* necessary stream state for linking to the framing abstraction */
83 ogg_int32_t **pcm; /* this is a pointer into local storage */
84 oggpack_buffer opb;
86 long lW;
87 long W;
88 long nW;
89 int pcmend;
90 int mode;
92 int eofflag;
93 ogg_int64_t granulepos;
94 ogg_int64_t sequence;
95 vorbis_dsp_state *vd; /* For read-only access of configuration */
97 /* local storage to avoid remallocing; it's up to the mapping to
98 structure it */
99 void *localstore;
100 long localtop;
101 long localalloc;
102 long totaluse;
103 struct alloc_chain *reap;
105 } vorbis_block;
107 /* vorbis_block is a single block of data to be processed as part of
108 the analysis/synthesis stream; it belongs to a specific logical
109 bitstream, but is independant from other vorbis_blocks belonging to
110 that logical bitstream. *************************************************/
112 struct alloc_chain{
113 void *ptr;
114 struct alloc_chain *next;
117 /* vorbis_info contains all the setup information specific to the
118 specific compression/decompression mode in progress (eg,
119 psychoacoustic settings, channel setup, options, codebook
120 etc). vorbis_info and substructures are in backends.h.
121 *********************************************************************/
123 /* the comments are not part of vorbis_info so that vorbis_info can be
124 static storage */
125 typedef struct vorbis_comment{
126 /* unlimited user comment fields. libvorbis writes 'libvorbis'
127 whatever vendor is set to in encode */
128 char **user_comments;
129 int *comment_lengths;
130 int comments;
131 char *vendor;
133 } vorbis_comment;
136 /* libvorbis encodes in two abstraction layers; first we perform DSP
137 and produce a packet (see docs/analysis.txt). The packet is then
138 coded into a framed OggSquish bitstream by the second layer (see
139 docs/framing.txt). Decode is the reverse process; we sync/frame
140 the bitstream and extract individual packets, then decode the
141 packet back into PCM audio.
143 The extra framing/packetizing is used in streaming formats, such as
144 files. Over the net (such as with UDP), the framing and
145 packetization aren't necessary as they're provided by the transport
146 and the streaming layer is not used */
148 /* Vorbis PRIMITIVES: general ***************************************/
150 extern void vorbis_info_init(vorbis_info *vi);
151 extern void vorbis_info_clear(vorbis_info *vi);
152 extern int vorbis_info_blocksize(vorbis_info *vi,int zo);
153 extern void vorbis_comment_init(vorbis_comment *vc);
154 extern void vorbis_comment_add(vorbis_comment *vc, char *comment);
155 extern void vorbis_comment_add_tag(vorbis_comment *vc,
156 char *tag, char *contents);
157 extern void vorbis_comment_clear(vorbis_comment *vc);
159 extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
160 extern int vorbis_block_clear(vorbis_block *vb);
161 extern void vorbis_dsp_clear(vorbis_dsp_state *v);
163 /* Vorbis PRIMITIVES: synthesis layer *******************************/
164 extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,
165 ogg_packet *op);
167 extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
168 extern int vorbis_synthesis_restart(vorbis_dsp_state *v);
169 extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep);
170 extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
171 extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm);
172 extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples);
173 extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op);
175 /* Vorbis ERRORS and return codes ***********************************/
177 #define OV_FALSE -1
178 #define OV_EOF -2
179 #define OV_HOLE -3
181 #define OV_EREAD -128
182 #define OV_EFAULT -129
183 #define OV_EIMPL -130
184 #define OV_EINVAL -131
185 #define OV_ENOTVORBIS -132
186 #define OV_EBADHEADER -133
187 #define OV_EVERSION -134
188 #define OV_ENOTAUDIO -135
189 #define OV_EBADPACKET -136
190 #define OV_EBADLINK -137
191 #define OV_ENOSEEK -138
193 #ifdef __cplusplus
195 #endif /* __cplusplus */
197 #endif