examples/SFExamples/oggvorbiscodec/src/libvorbis/include/vorbis/codec.h

00001 /********************************************************************
00002  *                                                                  *
00003  * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
00004  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
00005  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
00006  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
00007  *                                                                  *
00008  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001             *
00009  * by the XIPHOPHORUS Company http://www.xiph.org/                  *
00010 
00011  ********************************************************************
00012 
00013  function: libvorbis codec headers
00014  last mod: $Id: codec.h 7485 2004-08-05 14:54:23Z thomasvs $
00015 
00016  ********************************************************************/
00017 
00018 #ifndef _vorbis_codec_h_
00019 #define _vorbis_codec_h_
00020 
00021 #ifndef __SYMBIAN32__
00022 # define IMPORT_C extern
00023 # define EXPORT_C
00024 #else
00025 # ifndef __cplusplus
00026 #ifndef __X86GCC__
00027 #  undef IMPORT_C
00028 #  define IMPORT_C __declspec(dllexport)
00029 #  define EXPORT_C __declspec(dllexport)
00030 # endif
00031 # endif
00032 #endif
00033 #ifdef __cplusplus
00034 extern "C"
00035 {
00036 #endif /* __cplusplus */
00037 
00038 #include "ogg/ogg.h"
00039 
00040 typedef struct vorbis_info{
00041   int version;
00042   int channels;
00043   long rate;
00044 
00045   /* The below bitrate declarations are *hints*.
00046      Combinations of the three values carry the following implications:
00047 
00048      all three set to the same value:
00049        implies a fixed rate bitstream
00050      only nominal set:
00051        implies a VBR stream that averages the nominal bitrate.  No hard
00052        upper/lower limit
00053      upper and or lower set:
00054        implies a VBR bitstream that obeys the bitrate limits. nominal
00055        may also be set to give a nominal rate.
00056      none set:
00057        the coder does not care to speculate.
00058   */
00059 
00060   long bitrate_upper;
00061   long bitrate_nominal;
00062   long bitrate_lower;
00063   long bitrate_window;
00064 
00065   void *codec_setup;
00066 } vorbis_info;
00067 
00068 /* vorbis_dsp_state buffers the current vorbis audio
00069    analysis/synthesis state.  The DSP state belongs to a specific
00070    logical bitstream ****************************************************/
00071 typedef struct vorbis_dsp_state{
00072   int analysisp;
00073   vorbis_info *vi;
00074 
00075   float **pcm;
00076   float **pcmret;
00077   int      pcm_storage;
00078   int      pcm_current;
00079   int      pcm_returned;
00080 
00081   int  preextrapolate;
00082   int  eofflag;
00083 
00084   long lW;
00085   long W;
00086   long nW;
00087   long centerW;
00088 
00089   ogg_int64_t granulepos;
00090   ogg_int64_t sequence;
00091 
00092   ogg_int64_t glue_bits;
00093   ogg_int64_t time_bits;
00094   ogg_int64_t floor_bits;
00095   ogg_int64_t res_bits;
00096 
00097   void       *backend_state;
00098 } vorbis_dsp_state;
00099 
00100 typedef struct vorbis_block{
00101   /* necessary stream state for linking to the framing abstraction */
00102   float  **pcm;       /* this is a pointer into local storage */
00103   oggpack_buffer opb;
00104 
00105   long  lW;
00106   long  W;
00107   long  nW;
00108   int   pcmend;
00109   int   mode;
00110 
00111   int         eofflag;
00112   ogg_int64_t granulepos;
00113   ogg_int64_t sequence;
00114   vorbis_dsp_state *vd; /* For read-only access of configuration */
00115 
00116   /* local storage to avoid remallocing; it's up to the mapping to
00117      structure it */
00118   void               *localstore;
00119   long                localtop;
00120   long                localalloc;
00121   long                totaluse;
00122   struct alloc_chain *reap;
00123 
00124   /* bitmetrics for the frame */
00125   long glue_bits;
00126   long time_bits;
00127   long floor_bits;
00128   long res_bits;
00129 
00130   void *internal;
00131 
00132 } vorbis_block;
00133 
00134 /* vorbis_block is a single block of data to be processed as part of
00135 the analysis/synthesis stream; it belongs to a specific logical
00136 bitstream, but is independant from other vorbis_blocks belonging to
00137 that logical bitstream. *************************************************/
00138 
00139 struct alloc_chain{
00140   void *ptr;
00141   struct alloc_chain *next;
00142 };
00143 
00144 /* vorbis_info contains all the setup information specific to the
00145    specific compression/decompression mode in progress (eg,
00146    psychoacoustic settings, channel setup, options, codebook
00147    etc). vorbis_info and substructures are in backends.h.
00148 *********************************************************************/
00149 
00150 /* the comments are not part of vorbis_info so that vorbis_info can be
00151    static storage */
00152 typedef struct vorbis_comment{
00153   /* unlimited user comment fields.  libvorbis writes 'libvorbis'
00154      whatever vendor is set to in encode */
00155   char **user_comments;
00156   int   *comment_lengths;
00157   int    comments;
00158   char  *vendor;
00159 
00160 } vorbis_comment;
00161 
00162 
00163 /* libvorbis encodes in two abstraction layers; first we perform DSP
00164    and produce a packet (see docs/analysis.txt).  The packet is then
00165    coded into a framed OggSquish bitstream by the second layer (see
00166    docs/framing.txt).  Decode is the reverse process; we sync/frame
00167    the bitstream and extract individual packets, then decode the
00168    packet back into PCM audio.
00169 
00170    The extra framing/packetizing is used in streaming formats, such as
00171    files.  Over the net (such as with UDP), the framing and
00172    packetization aren't necessary as they're provided by the transport
00173    and the streaming layer is not used */
00174 
00175 /* Vorbis PRIMITIVES: general ***************************************/
00176 
00177 IMPORT_C void     vorbis_info_init(vorbis_info *vi);
00178 IMPORT_C void     vorbis_info_clear(vorbis_info *vi);
00179 IMPORT_C int      vorbis_info_blocksize(vorbis_info *vi,int zo);
00180 IMPORT_C void     vorbis_comment_init(vorbis_comment *vc);
00181 IMPORT_C void     vorbis_comment_add(vorbis_comment *vc, char *comment); 
00182 IMPORT_C void     vorbis_comment_add_tag(vorbis_comment *vc, 
00183                                        char *tag, char *contents);
00184 IMPORT_C char    *vorbis_comment_query(vorbis_comment *vc, char *tag, int count);
00185 IMPORT_C int      vorbis_comment_query_count(vorbis_comment *vc, char *tag);
00186 IMPORT_C void     vorbis_comment_clear(vorbis_comment *vc);
00187 
00188 IMPORT_C int      vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
00189 IMPORT_C int      vorbis_block_clear(vorbis_block *vb);
00190 IMPORT_C void     vorbis_dsp_clear(vorbis_dsp_state *v);
00191 IMPORT_C double   vorbis_granule_time(vorbis_dsp_state *v,
00192                                     ogg_int64_t granulepos);
00193 
00194 /* Vorbis PRIMITIVES: analysis/DSP layer ****************************/
00195 
00196 IMPORT_C int      vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi);
00197 IMPORT_C int      vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op);
00198 IMPORT_C int      vorbis_analysis_headerout(vorbis_dsp_state *v,
00199                                           vorbis_comment *vc,
00200                                           ogg_packet *op,
00201                                           ogg_packet *op_comm,
00202                                           ogg_packet *op_code);
00203 IMPORT_C float  **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals);
00204 IMPORT_C int      vorbis_analysis_wrote(vorbis_dsp_state *v,int vals);
00205 IMPORT_C int      vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb);
00206 IMPORT_C int      vorbis_analysis(vorbis_block *vb,ogg_packet *op);
00207 
00208 IMPORT_C int      vorbis_bitrate_addblock(vorbis_block *vb);
00209 IMPORT_C int      vorbis_bitrate_flushpacket(vorbis_dsp_state *vd,
00210                                            ogg_packet *op);
00211 
00212 /* Vorbis PRIMITIVES: synthesis layer *******************************/
00213 IMPORT_C int      vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,
00214                                           ogg_packet *op);
00215 
00216 IMPORT_C int      vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
00217 IMPORT_C int      vorbis_synthesis_restart(vorbis_dsp_state *v);
00218 IMPORT_C int      vorbis_synthesis(vorbis_block *vb,ogg_packet *op);
00219 IMPORT_C int      vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op);
00220 IMPORT_C int      vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
00221 IMPORT_C int      vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm);
00222 IMPORT_C int      vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm);
00223 IMPORT_C int      vorbis_synthesis_read(vorbis_dsp_state *v,int samples);
00224 IMPORT_C long     vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op);
00225 
00226 IMPORT_C int      vorbis_synthesis_halfrate(vorbis_info *v,int flag);
00227 IMPORT_C int      vorbis_synthesis_halfrate_p(vorbis_info *v);
00228 
00229 /* Vorbis ERRORS and return codes ***********************************/
00230 
00231 #define OV_FALSE      -1
00232 #define OV_EOF        -2
00233 #define OV_HOLE       -3
00234 
00235 #define OV_EREAD      -128
00236 #define OV_EFAULT     -129
00237 #define OV_EIMPL      -130
00238 #define OV_EINVAL     -131
00239 #define OV_ENOTVORBIS -132
00240 #define OV_EBADHEADER -133
00241 #define OV_EVERSION   -134
00242 #define OV_ENOTAUDIO  -135
00243 #define OV_EBADPACKET -136
00244 #define OV_EBADLINK   -137
00245 #define OV_ENOSEEK    -138
00246 
00247 #ifdef __cplusplus
00248 }
00249 #endif /* __cplusplus */
00250 
00251 #endif
00252 

Generated by  doxygen 1.6.2