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