00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
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 
00037 
00038 #include "ogg/ogg.h"
00039 
00040 typedef struct vorbis_info{
00041   int version;
00042   int channels;
00043   long rate;
00044 
00045   
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
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 
00069 
00070 
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   
00102   float  **pcm;       
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; 
00115 
00116   
00117 
00118   void               *localstore;
00119   long                localtop;
00120   long                localalloc;
00121   long                totaluse;
00122   struct alloc_chain *reap;
00123 
00124   
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 
00135 
00136 
00137 
00138 
00139 struct alloc_chain{
00140   void *ptr;
00141   struct alloc_chain *next;
00142 };
00143 
00144 
00145 
00146 
00147 
00148 
00149 
00150 
00151 
00152 typedef struct vorbis_comment{
00153   
00154 
00155   char **user_comments;
00156   int   *comment_lengths;
00157   int    comments;
00158   char  *vendor;
00159 
00160 } vorbis_comment;
00161 
00162 
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175 
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 
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 
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 
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 
00250 
00251 #endif
00252