michael@0: /******************************************************************** michael@0: * * michael@0: * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * michael@0: * * michael@0: * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * michael@0: * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * michael@0: * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * michael@0: * * michael@0: * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * michael@0: * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * michael@0: * * michael@0: ******************************************************************** michael@0: michael@0: function: libvorbis codec headers michael@0: michael@0: ********************************************************************/ michael@0: michael@0: #ifndef _vorbis_codec_h_ michael@0: #define _vorbis_codec_h_ michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" michael@0: { michael@0: #endif /* __cplusplus */ michael@0: michael@0: #include michael@0: michael@0: typedef struct vorbis_info{ michael@0: int version; michael@0: int channels; michael@0: long rate; michael@0: michael@0: /* The below bitrate declarations are *hints*. michael@0: Combinations of the three values carry the following implications: michael@0: michael@0: all three set to the same value: michael@0: implies a fixed rate bitstream michael@0: only nominal set: michael@0: implies a VBR stream that averages the nominal bitrate. No hard michael@0: upper/lower limit michael@0: upper and or lower set: michael@0: implies a VBR bitstream that obeys the bitrate limits. nominal michael@0: may also be set to give a nominal rate. michael@0: none set: michael@0: the coder does not care to speculate. michael@0: */ michael@0: michael@0: long bitrate_upper; michael@0: long bitrate_nominal; michael@0: long bitrate_lower; michael@0: long bitrate_window; michael@0: michael@0: void *codec_setup; michael@0: } vorbis_info; michael@0: michael@0: /* vorbis_dsp_state buffers the current vorbis audio michael@0: analysis/synthesis state. The DSP state belongs to a specific michael@0: logical bitstream ****************************************************/ michael@0: typedef struct vorbis_dsp_state{ michael@0: int analysisp; michael@0: vorbis_info *vi; michael@0: michael@0: ogg_int32_t **pcm; michael@0: ogg_int32_t **pcmret; michael@0: int pcm_storage; michael@0: int pcm_current; michael@0: int pcm_returned; michael@0: michael@0: int preextrapolate; michael@0: int eofflag; michael@0: michael@0: long lW; michael@0: long W; michael@0: long nW; michael@0: long centerW; michael@0: michael@0: ogg_int64_t granulepos; michael@0: ogg_int64_t sequence; michael@0: michael@0: void *backend_state; michael@0: } vorbis_dsp_state; michael@0: michael@0: typedef struct vorbis_block{ michael@0: /* necessary stream state for linking to the framing abstraction */ michael@0: ogg_int32_t **pcm; /* this is a pointer into local storage */ michael@0: oggpack_buffer opb; michael@0: michael@0: long lW; michael@0: long W; michael@0: long nW; michael@0: int pcmend; michael@0: int mode; michael@0: michael@0: int eofflag; michael@0: ogg_int64_t granulepos; michael@0: ogg_int64_t sequence; michael@0: vorbis_dsp_state *vd; /* For read-only access of configuration */ michael@0: michael@0: /* local storage to avoid remallocing; it's up to the mapping to michael@0: structure it */ michael@0: void *localstore; michael@0: long localtop; michael@0: long localalloc; michael@0: long totaluse; michael@0: struct alloc_chain *reap; michael@0: michael@0: } vorbis_block; michael@0: michael@0: /* vorbis_block is a single block of data to be processed as part of michael@0: the analysis/synthesis stream; it belongs to a specific logical michael@0: bitstream, but is independant from other vorbis_blocks belonging to michael@0: that logical bitstream. *************************************************/ michael@0: michael@0: struct alloc_chain{ michael@0: void *ptr; michael@0: struct alloc_chain *next; michael@0: }; michael@0: michael@0: /* vorbis_info contains all the setup information specific to the michael@0: specific compression/decompression mode in progress (eg, michael@0: psychoacoustic settings, channel setup, options, codebook michael@0: etc). vorbis_info and substructures are in backends.h. michael@0: *********************************************************************/ michael@0: michael@0: /* the comments are not part of vorbis_info so that vorbis_info can be michael@0: static storage */ michael@0: typedef struct vorbis_comment{ michael@0: /* unlimited user comment fields. libvorbis writes 'libvorbis' michael@0: whatever vendor is set to in encode */ michael@0: char **user_comments; michael@0: int *comment_lengths; michael@0: int comments; michael@0: char *vendor; michael@0: michael@0: } vorbis_comment; michael@0: michael@0: michael@0: /* libvorbis encodes in two abstraction layers; first we perform DSP michael@0: and produce a packet (see docs/analysis.txt). The packet is then michael@0: coded into a framed OggSquish bitstream by the second layer (see michael@0: docs/framing.txt). Decode is the reverse process; we sync/frame michael@0: the bitstream and extract individual packets, then decode the michael@0: packet back into PCM audio. michael@0: michael@0: The extra framing/packetizing is used in streaming formats, such as michael@0: files. Over the net (such as with UDP), the framing and michael@0: packetization aren't necessary as they're provided by the transport michael@0: and the streaming layer is not used */ michael@0: michael@0: /* Vorbis PRIMITIVES: general ***************************************/ michael@0: michael@0: extern void vorbis_info_init(vorbis_info *vi); michael@0: extern void vorbis_info_clear(vorbis_info *vi); michael@0: extern int vorbis_info_blocksize(vorbis_info *vi,int zo); michael@0: extern void vorbis_comment_init(vorbis_comment *vc); michael@0: extern void vorbis_comment_add(vorbis_comment *vc, char *comment); michael@0: extern void vorbis_comment_add_tag(vorbis_comment *vc, michael@0: char *tag, char *contents); michael@0: extern char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count); michael@0: extern int vorbis_comment_query_count(vorbis_comment *vc, char *tag); michael@0: extern void vorbis_comment_clear(vorbis_comment *vc); michael@0: michael@0: extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); michael@0: extern int vorbis_block_clear(vorbis_block *vb); michael@0: extern void vorbis_dsp_clear(vorbis_dsp_state *v); michael@0: michael@0: /* Vorbis PRIMITIVES: synthesis layer *******************************/ michael@0: extern int vorbis_synthesis_idheader(ogg_packet *op); michael@0: extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, michael@0: ogg_packet *op); michael@0: michael@0: extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); michael@0: extern int vorbis_synthesis_restart(vorbis_dsp_state *v); michael@0: extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op); michael@0: extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op); michael@0: extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb); michael@0: extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm); michael@0: extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples); michael@0: extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op); michael@0: michael@0: /* Vorbis ERRORS and return codes ***********************************/ michael@0: michael@0: #define OV_FALSE -1 michael@0: #define OV_EOF -2 michael@0: #define OV_HOLE -3 michael@0: michael@0: #define OV_EREAD -128 michael@0: #define OV_EFAULT -129 michael@0: #define OV_EIMPL -130 michael@0: #define OV_EINVAL -131 michael@0: #define OV_ENOTVORBIS -132 michael@0: #define OV_EBADHEADER -133 michael@0: #define OV_EVERSION -134 michael@0: #define OV_ENOTAUDIO -135 michael@0: #define OV_EBADPACKET -136 michael@0: #define OV_EBADLINK -137 michael@0: #define OV_ENOSEEK -138 michael@0: michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif /* __cplusplus */ michael@0: michael@0: #endif michael@0: