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

Generated by  doxygen 1.6.2