1 /********************************************************************
3 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
5 * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH *
6 * THIS SOURCE. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2000 *
9 * by Monty <monty@xiph.org> and the XIPHOPHORUS Company *
10 * http://www.xiph.org/ *
12 ********************************************************************
14 function: libvorbis codec headers
15 last mod: $Id: codec.h,v 1.35 2001/01/22 01:38:23 xiphmont Exp $
17 ********************************************************************/
19 #ifndef _vorbis_codec_h_
20 #define _vorbis_codec_h_
25 #endif /* __cplusplus */
29 typedef struct vorbis_info{
34 /* The below bitrate declarations are *hints*.
35 Combinations of the three values carry the following implications:
37 all three set to the same value:
38 implies a fixed rate bitstream
40 implies a VBR stream that averages the nominal bitrate. No hard
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.
46 the coder does not care to speculate.
57 /* vorbis_dsp_state buffers the current vorbis audio
58 analysis/synthesis state. The DSP state belongs to a specific
59 logical bitstream ****************************************************/
60 typedef struct vorbis_dsp_state{
78 ogg_int64_t granulepos;
81 ogg_int64_t glue_bits;
82 ogg_int64_t time_bits;
83 ogg_int64_t floor_bits;
89 typedef struct vorbis_block{
90 /* necessary stream state for linking to the framing abstraction */
91 float **pcm; /* this is a pointer into local storage */
101 ogg_int64_t granulepos;
102 ogg_int64_t sequence;
103 vorbis_dsp_state *vd; /* For read-only access of configuration */
105 /* local storage to avoid remallocing; it's up to the mapping to
111 struct alloc_chain *reap;
113 /* bitmetrics for the frame */
123 /* vorbis_block is a single block of data to be processed as part of
124 the analysis/synthesis stream; it belongs to a specific logical
125 bitstream, but is independant from other vorbis_blocks belonging to
126 that logical bitstream. *************************************************/
130 struct alloc_chain *next;
133 /* vorbis_info contains all the setup information specific to the
134 specific compression/decompression mode in progress (eg,
135 psychoacoustic settings, channel setup, options, codebook
136 etc). vorbis_info and substructures are in backends.h.
137 *********************************************************************/
139 /* the comments are not part of vorbis_info so that vorbis_info can be
141 typedef struct vorbis_comment{
142 /* unlimited user comment fields. libvorbis writes 'libvorbis'
143 whatever vendor is set to in encode */
144 char **user_comments;
145 int *comment_lengths;
152 /* libvorbis encodes in two abstraction layers; first we perform DSP
153 and produce a packet (see docs/analysis.txt). The packet is then
154 coded into a framed OggSquish bitstream by the second layer (see
155 docs/framing.txt). Decode is the reverse process; we sync/frame
156 the bitstream and extract individual packets, then decode the
157 packet back into PCM audio.
159 The extra framing/packetizing is used in streaming formats, such as
160 files. Over the net (such as with UDP), the framing and
161 packetization aren't necessary as they're provided by the transport
162 and the streaming layer is not used */
164 /* Vorbis PRIMITIVES: general ***************************************/
166 extern void vorbis_info_init(vorbis_info *vi);
167 extern void vorbis_info_clear(vorbis_info *vi);
168 extern void vorbis_comment_init(vorbis_comment *vc);
169 extern void vorbis_comment_add(vorbis_comment *vc, char *comment);
170 extern void vorbis_comment_add_tag(vorbis_comment *vc,
171 char *tag, char *contents);
172 extern char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count);
173 extern int vorbis_comment_query_count(vorbis_comment *vc, char *tag);
174 extern void vorbis_comment_clear(vorbis_comment *vc);
176 extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
177 extern int vorbis_block_clear(vorbis_block *vb);
178 extern void vorbis_dsp_clear(vorbis_dsp_state *v);
180 /* Vorbis PRIMITIVES: analysis/DSP layer ****************************/
182 extern int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi);
183 extern int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op);
184 extern int vorbis_analysis_headerout(vorbis_dsp_state *v,
188 ogg_packet *op_code);
189 extern float **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals);
190 extern int vorbis_analysis_wrote(vorbis_dsp_state *v,int vals);
191 extern int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb);
192 extern int vorbis_analysis(vorbis_block *vb,ogg_packet *op);
194 /* Vorbis PRIMITIVES: synthesis layer *******************************/
195 extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,
198 extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
199 extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op);
200 extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
201 extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm);
202 extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples);
204 /* Vorbis ERRORS and return codes ***********************************/
210 #define OV_EREAD -128
211 #define OV_EFAULT -129
212 #define OV_EIMPL -130
213 #define OV_EINVAL -131
214 #define OV_ENOTVORBIS -132
215 #define OV_EBADHEADER -133
216 #define OV_EVERSION -134
217 #define OV_ENOTAUDIO -135
218 #define OV_EBADPACKET -136
219 #define OV_EBADLINK -137
220 #define OV_ENOSEEK -138
224 #endif /* __cplusplus */