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

Generated by  doxygen 1.6.2