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: PCM data vector blocking, windowing and dis/reassembly
15 author: Monty <xiphmont@mit.edu>
16 modifications by: Monty
17 last modification date: Jul 13 1999
19 ********************************************************************/
21 #ifndef _vorbis_codec_h_
22 #define _vorbis_codec_h_
24 typedef struct vorbis_info{
34 typedef struct vorbis_dsp_state{
35 int samples_per_envelope_step;
37 double *window[2][2][2]; /* windowsize, leadin, leadout */
47 int envelope_channels;
70 unsigned char *header;
78 /* _________________________________________________
79 body_data: |_________________________________________________|
80 body_returned ----^ ^ ^ ^
81 body_processed------------' | |
82 body_fill ---------------------------------------' |
83 body_storage _______________________________________________'
85 the header is labelled the same way. Not all the pointers are
86 used by both encode and decode */
88 unsigned char *body_data; /* bytes from packet bodies */
89 long body_storage; /* storage elements allocated */
90 long body_fill; /* elements stored; fill mark */
91 long body_returned; /* elements of fill returned */
94 int *lacing_vals; /* The values that will go to the segment table */
95 size64 *pcm_vals; /* pcm_pos values for headers. Not compact
96 this way, but it is simple coupled to the
101 long lacing_returned;
103 unsigned char header[282]; /* working space for header encode */
106 int e_o_s; /* set when we have buffered the last packet in the
108 int b_o_s; /* set after we've written the initial page
109 of a logical bitstream */
117 unsigned char *packet;
137 /* libvorbis encodes in two abstraction layers; first we perform DSP
138 and produce a packet (see docs/analysis.txt). The packet is then
139 coded into a framed OggSquish bitstream by the second layer (see
140 docs/framing.txt). Decode is the reverse process; we sync/frame
141 the bitstream and extract individual packets, then decode the
142 packet back into PCM audio.
144 The extra framing/packetizing is used in streaming formats, such as
145 files. Over the net (such as with UDP), the framing and
146 packetization aren't necessary as they're provided by the transport
147 and the streaming layer is not used */
149 /* OggSquish BITSREAM PRIMITIVES: encoding **************************/
151 extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
152 extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
154 /* OggSquish BITSREAM PRIMITIVES: decoding **************************/
156 extern int ogg_sync_init(ogg_sync_state *oy);
157 extern int ogg_sync_clear(ogg_sync_state *oy);
158 extern int ogg_sync_destroy(ogg_sync_state *oy);
159 extern int ogg_sync_reset(ogg_sync_state *oy);
161 extern char *ogg_sync_buffer(ogg_sync_state *oy, long size);
162 extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
163 extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
164 extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
165 extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
167 /* OggSquish BITSREAM PRIMITIVES: general ***************************/
169 extern int ogg_stream_init(ogg_stream_state *os,int serialno);
170 extern int ogg_stream_clear(ogg_stream_state *os);
171 extern int ogg_stream_reset(ogg_stream_state *os);
172 extern int ogg_stream_destroy(ogg_stream_state *os);
173 extern int ogg_stream_eof(ogg_stream_state *os);
175 extern int ogg_page_version(ogg_page *og);
176 extern int ogg_page_continued(ogg_page *og);
177 extern int ogg_page_bos(ogg_page *og);
178 extern int ogg_page_eos(ogg_page *og);
179 extern size64 ogg_page_frameno(ogg_page *og);
180 extern int ogg_page_serialno(ogg_page *og);
181 extern int ogg_page_pageno(ogg_page *og);
183 /* Vorbis PRIMITIVES: analysis/DSP layer ****************************/
185 extern int vorbis_analysis_init(vorbis_dsp_state *vd,vorbis_info *vi);
186 extern void vorbis_dsp_state_free(vorbis_dsp_state *vd);
187 extern int vorbis_analysis_input(vorbis_dsp_state *vd,double **pcm,int vals);
188 extern int vorbis_analysis(vorbis_dsp_state *vd,ogg_packet *op);
190 /* Vorbis PRIMITIVES: synthesis layer *******************************/
192 extern int vorbis_synthesis_info(vorbis_dsp_state *vd,vorbis_info *vi);
193 extern int vorbis_synthesis_packet(vorbis_dsp_state *vd,ogg_packet *op);
194 extern int vorbis_synthesis_output(vorbis_dsp_state *vd,double **pcm);