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: Jun 26 1999
19 ********************************************************************/
21 /* $Id: codec.h,v 1.2 1999/07/13 08:00:15 mwhitson Exp $ */
23 #ifndef _vorbis_codec_h_
24 #define _vorbis_codec_h_
26 typedef struct vorbis_info{
36 typedef struct vorbis_dsp_state{
37 int samples_per_envelope_step;
39 double *window[2][2][2]; /* windowsize, leadin, leadout */
49 int envelope_channels;
72 unsigned char *header;
79 unsigned size32 crc_lookup[256];
81 unsigned char *body_data; /* bytes from packet bodies */
86 int *lacing_vals; /* The values that will go to the segment table */
87 size64 *pcm_vals; /* pcm_pos values for headers. Not compact
88 this way, but it is simple coupled to the
93 unsigned char header[282]; /* working space for header */
96 int e_o_s; /* set when we have buffered the last packet in the
98 int b_o_s; /* set after we've written the initial page
99 of a logical bitstream */
102 } vorbis_stream_state;
105 unsigned char *packet;
113 /* libvorbis encodes in two abstraction layers; first we perform DSP
114 and produce a packet (see docs/analysis.txt). The packet is then
115 coded into a framed bitstream by the second layer (see
116 docs/framing.txt). Decode is the reverse process; we sync/frame
117 the bitstream and extract individual packets, then decode the
118 packet back into PCM audio.
120 The extra framing/packetizing is used in streaming formats, such as
121 files. Over the net (such as with UDP), the framing and
122 packetization aren't necessary as they're provided by the transport
123 and the streaming layer is not used */
125 /* ENCODING PRIMITIVES: analysis/DSP layer **************************/
127 extern int vorbis_analysis_init(vorbis_dsp_state *vd,vorbis_info *i);
128 extern void vorbis_dsp_state_free(vorbis_dsp_state *vd);
129 extern int vorbis_analysis_input(vorbis_dsp_state *vd,double **pcm,int vals);
130 extern int vorbis_analysis(vorbis_dsp_state *vd,vorbis_packet *vp);
132 /* GENERAL PRIMITIVES: packet streaming layer ***********************/
134 extern int vorbis_stream_init(vorbis_stream_state *vs,int serialno);
135 extern int vorbis_stream_clear(vorbis_stream_state *vs);
136 extern int vorbis_stream_destroy(vorbis_stream_state *vs);
137 extern int vorbis_stream_eof(vorbis_stream_state *vs);
139 /* ENCODING PRIMITIVES: packet streaming layer **********************/
141 extern int vorbis_stream_encode(vorbis_stream_state *vs,vorbis_packet *vp);
142 extern int vorbis_stream_page(vorbis_stream_state *vs, vorbis_page *vg);
144 /* DECODING PRIMITIVES: packet streaming layer **********************/
146 /* returns nonzero when it has a complete vorbis packet synced and
147 framed for decoding. Generally, it wants to see two page headers at
148 proper spacing before returning 'yea'. An exception is the initial
149 header to make IDing the vorbis stream easier: it will return sync
150 on the page header + beginning-of-stream marker.
152 _sync will also abort framing if is sees a problem in the packet
155 extern int vorbis_stream_decode(vorbis_stream_state *vs,char *stream,int size);
156 extern int vorbis_stream_sync(vorbis_stream_state *vs);
157 extern int vorbis_stream_verify(vorbis_stream_state *vs);
158 extern size64 vorbis_stream_position(vorbis_stream_state *vs);
159 extern int vorbis_stream_skippage(vorbis_stream_state *vs);
160 extern int vorbis_stream_packet(vorbis_stream_state *vs,vorbis_packet *vp);
162 /* DECODING PRIMITIVES: synthesis layer *****************************/
164 extern int vorbis_synthesis_info(vorbis_dsp_state *vd,vorbis_info *vi);
165 extern int vorbis_synthesis(vorbis_dsp_state *vd,vorbis_packet *vp);
166 extern int vorbis_synthesis_output(vorbis_dsp_state *vd,double **pcm);