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 */
114 } vorbis_stream_state;
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 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 /* ENCODING PRIMITIVES: analysis/DSP layer **************************/
151 extern int vorbis_analysis_init(vorbis_dsp_state *vd,vorbis_info *i);
152 extern void vorbis_dsp_state_free(vorbis_dsp_state *vd);
153 extern int vorbis_analysis_input(vorbis_dsp_state *vd,double **pcm,int vals);
154 extern int vorbis_analysis(vorbis_dsp_state *vd,vorbis_packet *vp);
156 /* GENERAL PRIMITIVES: packet streaming layer ***********************/
158 extern int vorbis_stream_init(vorbis_stream_state *vs,int serialno);
159 extern int vorbis_stream_clear(vorbis_stream_state *vs);
160 extern int vorbis_stream_destroy(vorbis_stream_state *vs);
161 extern int vorbis_stream_eof(vorbis_stream_state *vs);
163 extern int vorbis_page_version(vorbis_page *vg);
164 extern int vorbis_page_continued(vorbis_page *vg);
165 extern int vorbis_page_bos(vorbis_page *vg);
166 extern int vorbis_page_eos(vorbis_page *vg);
167 extern size64 vorbis_page_pcmpos(vorbis_page *vg);
168 extern int vorbis_page_serialno(vorbis_page *vg);
169 extern int vorbis_page_pageno(vorbis_page *vg);
171 /* ENCODING PRIMITIVES: packet streaming layer **********************/
173 extern int vorbis_stream_encode(vorbis_stream_state *vs,vorbis_packet *vp);
174 extern int vorbis_stream_page(vorbis_stream_state *vs, vorbis_page *vg);
176 /* DECODING PRIMITIVES: packet streaming layer **********************/
178 extern int vorbis_sync_init(vorbis_sync_state *vs);
179 extern int vorbis_sync_clear(vorbis_sync_state *vs);
180 extern int vorbis_sync_destroy(vorbis_sync_state *vs);
182 extern char *vorbis_decode_buffer(vorbis_sync_state *vs, long size);
183 extern int vorbis_decode_wrote(vorbis_sync_state *vs, long bytes);
184 extern int vorbis_decode_stream(vorbis_sync_state *vs, vorbis_page *vg);
185 extern int vorbis_decode_page(vorbis_stream_state *vs, vorbis_page *vg);
186 extern int vorbis_stream_packet(vorbis_stream_state *vs,vorbis_packet *vp);
188 extern int vorbis_sync_reset(vorbis_sync_state *vs);
189 extern int vorbis_stream_reset(vorbis_stream_state *vs);
191 /* DECODING PRIMITIVES: synthesis layer *****************************/
193 extern int vorbis_synthesis_info(vorbis_dsp_state *vd,vorbis_info *vi);
194 extern int vorbis_synthesis(vorbis_dsp_state *vd,vorbis_packet *vp);
195 extern int vorbis_synthesis_output(vorbis_dsp_state *vd,double **pcm);