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 25 1999
19 ********************************************************************/
21 #ifndef _vorbis_codec_h_
22 #define _vorbis_codec_h_
24 typedef struct vorbis_info{
35 unsigned char *header;
42 unsigned char *body_data; /* bytes from packet bodies */
43 long body_storage; /* storage elements allocated */
44 long body_fill; /* elements stored; fill mark */
45 long body_returned; /* elements of fill returned */
48 int *lacing_vals; /* The values that will go to the segment table */
49 size64 *pcm_vals; /* pcm_pos values for headers. Not compact
50 this way, but it is simple coupled to the
57 unsigned char header[282]; /* working space for header encode */
60 int e_o_s; /* set when we have buffered the last packet in the
62 int b_o_s; /* set after we've written the initial page
63 of a logical bitstream */
71 unsigned char *packet;
97 typedef struct vorbis_dsp_state{
98 int samples_per_envelope_step;
100 double *window[2][2][2]; /* windowsize, leadin, leadout */
113 int envelope_storage;
114 int envelope_channels;
115 int envelope_current;
129 typedef struct vorbis_block{
132 int pcm_channels; /* allocated, not used */
133 int pcm_storage; /* allocated, not used */
134 int mult_channels; /* allocated, not used */
135 int mult_storage; /* allocated, not used */
145 vorbis_dsp_state *vd; /* For read-only access of configuration */
148 /* libvorbis encodes in two abstraction layers; first we perform DSP
149 and produce a packet (see docs/analysis.txt). The packet is then
150 coded into a framed OggSquish bitstream by the second layer (see
151 docs/framing.txt). Decode is the reverse process; we sync/frame
152 the bitstream and extract individual packets, then decode the
153 packet back into PCM audio.
155 The extra framing/packetizing is used in streaming formats, such as
156 files. Over the net (such as with UDP), the framing and
157 packetization aren't necessary as they're provided by the transport
158 and the streaming layer is not used */
160 /* OggSquish BITSREAM PRIMITIVES: encoding **************************/
162 extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
163 extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
165 /* OggSquish BITSREAM PRIMITIVES: decoding **************************/
167 extern int ogg_sync_init(ogg_sync_state *oy);
168 extern int ogg_sync_clear(ogg_sync_state *oy);
169 extern int ogg_sync_destroy(ogg_sync_state *oy);
170 extern int ogg_sync_reset(ogg_sync_state *oy);
172 extern char *ogg_sync_buffer(ogg_sync_state *oy, long size);
173 extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
174 extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
175 extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
176 extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
178 /* OggSquish BITSREAM PRIMITIVES: general ***************************/
180 extern int ogg_stream_init(ogg_stream_state *os,int serialno);
181 extern int ogg_stream_clear(ogg_stream_state *os);
182 extern int ogg_stream_reset(ogg_stream_state *os);
183 extern int ogg_stream_destroy(ogg_stream_state *os);
184 extern int ogg_stream_eof(ogg_stream_state *os);
186 extern int ogg_page_version(ogg_page *og);
187 extern int ogg_page_continued(ogg_page *og);
188 extern int ogg_page_bos(ogg_page *og);
189 extern int ogg_page_eos(ogg_page *og);
190 extern size64 ogg_page_frameno(ogg_page *og);
191 extern int ogg_page_serialno(ogg_page *og);
192 extern int ogg_page_pageno(ogg_page *og);
194 /* Vorbis PRIMITIVES: analysis/DSP layer ****************************/
196 extern int vorbis_analysis_init(vorbis_dsp_state *vd,vorbis_info *vi);
197 extern int vorbis_analysis_reset(vorbis_dsp_state *vd);
198 extern void vorbis_analysis_free(vorbis_dsp_state *vd);
199 extern double **vorbis_analysis_buffer(vorbis_dsp_state *vd,int vals);
200 extern int vorbis_analysis_wrote(vorbis_dsp_state *vd,int vals);
201 extern int vorbis_analysis_block(vorbis_dsp_state *vd,vorbis_block *vb);
202 extern int vorbis_analysis_packetout(vorbis_dsp_state *vd,
206 /* Vorbis PRIMITIVES: synthesis layer *******************************/
208 extern void vorbis_synthesis_free(vorbis_dsp_state *vd);
209 extern int vorbis_synthesis_init(vorbis_dsp_state *vd);
210 extern int vorbis_synthesis_info(vorbis_dsp_state *vd,vorbis_info *vi);
211 extern int vorbis_synthesis_packetin(vorbis_dsp_state *vd,vorbis_block *vb,
213 extern int vorbis_synthesis_pcmout(vorbis_dsp_state *vd,vorbis_block *vb,