examples/SFExamples/oggvorbiscodec94/src/tremor/ivorbiscodec.h

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

Generated by  doxygen 1.6.2