Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ivorbiscodec.h

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

Generated on Sat Nov 5 16:15:43 2005 for OPIE by  doxygen 1.4.2