1 /********************************************************************
3 * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
5 * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
6 * PLEASE READ THESE TERMS DISTRIBUTING. *
8 * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-1999 *
9 * by 1999 Monty <monty@xiph.org> and The XIPHOPHORUS Company *
10 * http://www.xiph.org/ *
12 ********************************************************************
14 function: codec headers
15 author: Monty <xiphmont@mit.edu>
16 modifications by: Monty
17 last modification date: Jul 28 1999
19 ********************************************************************/
21 #ifndef _vorbis_codec_h_
22 #define _vorbis_codec_h_
28 unsigned char *buffer;
34 typedef struct vorbis_info{
46 int *envelopemap; /* which envelope applies to what pcm channel */
47 int **channelmap; /* which encoding channels produce what pcm */
49 double preecho_thresh;
54 unsigned char *header;
61 unsigned char *body_data; /* bytes from packet bodies */
62 long body_storage; /* storage elements allocated */
63 long body_fill; /* elements stored; fill mark */
64 long body_returned; /* elements of fill returned */
67 int *lacing_vals; /* The values that will go to the segment table */
68 size64 *pcm_vals; /* pcm_pos values for headers. Not compact
69 this way, but it is simple coupled to the
76 unsigned char header[282]; /* working space for header encode */
79 int e_o_s; /* set when we have buffered the last packet in the
81 int b_o_s; /* set after we've written the initial page
82 of a logical bitstream */
90 unsigned char *packet;
115 typedef struct vorbis_dsp_state{
116 int samples_per_envelope_step;
118 double *window[2][2][2]; /* windowsize, leadin, leadout */
130 double **multipliers;
131 int envelope_storage;
132 int envelope_channels;
133 int envelope_current;
147 typedef struct vorbis_block{
150 int pcm_channels; /* allocated, not used */
151 int pcm_storage; /* allocated, not used */
152 int mult_channels; /* allocated, not used */
153 int mult_storage; /* allocated, not used */
163 vorbis_dsp_state *vd; /* For read-only access of configuration */
166 /* libvorbis encodes in two abstraction layers; first we perform DSP
167 and produce a packet (see docs/analysis.txt). The packet is then
168 coded into a framed OggSquish bitstream by the second layer (see
169 docs/framing.txt). Decode is the reverse process; we sync/frame
170 the bitstream and extract individual packets, then decode the
171 packet back into PCM audio.
173 The extra framing/packetizing is used in streaming formats, such as
174 files. Over the net (such as with UDP), the framing and
175 packetization aren't necessary as they're provided by the transport
176 and the streaming layer is not used */
178 /* OggSquish BITSREAM PRIMITIVES: encoding **************************/
180 extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
181 extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
183 /* OggSquish BITSREAM PRIMITIVES: decoding **************************/
185 extern int ogg_sync_init(ogg_sync_state *oy);
186 extern int ogg_sync_clear(ogg_sync_state *oy);
187 extern int ogg_sync_destroy(ogg_sync_state *oy);
188 extern int ogg_sync_reset(ogg_sync_state *oy);
190 extern char *ogg_sync_buffer(ogg_sync_state *oy, long size);
191 extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
192 extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
193 extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
194 extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
196 /* OggSquish BITSREAM PRIMITIVES: general ***************************/
198 extern int ogg_stream_init(ogg_stream_state *os,int serialno);
199 extern int ogg_stream_clear(ogg_stream_state *os);
200 extern int ogg_stream_reset(ogg_stream_state *os);
201 extern int ogg_stream_destroy(ogg_stream_state *os);
202 extern int ogg_stream_eof(ogg_stream_state *os);
204 extern int ogg_page_version(ogg_page *og);
205 extern int ogg_page_continued(ogg_page *og);
206 extern int ogg_page_bos(ogg_page *og);
207 extern int ogg_page_eos(ogg_page *og);
208 extern size64 ogg_page_frameno(ogg_page *og);
209 extern int ogg_page_serialno(ogg_page *og);
210 extern int ogg_page_pageno(ogg_page *og);
212 /* Vorbis PRIMITIVES: analysis/DSP layer ****************************/
214 extern int vorbis_analysis_init(vorbis_dsp_state *vd,vorbis_info *vi);
215 extern int vorbis_analysis_reset(vorbis_dsp_state *vd);
216 extern void vorbis_analysis_free(vorbis_dsp_state *vd);
217 extern double **vorbis_analysis_buffer(vorbis_dsp_state *vd,int vals);
218 extern int vorbis_analysis_wrote(vorbis_dsp_state *vd,int vals);
219 extern int vorbis_analysis_blockout(vorbis_dsp_state *vd,
221 extern int vorbis_analysis_packetout(vorbis_dsp_state *vd,
225 /* Vorbis PRIMITIVES: synthesis layer *******************************/
227 extern void vorbis_synthesis_free(vorbis_dsp_state *vd);
228 extern int vorbis_synthesis_init(vorbis_dsp_state *vd,vorbis_info *vi);
230 extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
231 extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,double ***pcm);
232 extern int vorbis_synthesis_read(vorbis_dsp_state *v,int bytes);