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