assman was renamed to assfile
[laserbrain_demo] / libs / vorbis / vorbisfile.h
1 /********************************************************************
2  *                                                                  *
3  * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
4  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
5  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
7  *                                                                  *
8  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
9  * by the Xiph.Org Foundation http://www.xiph.org/                  *
10  *                                                                  *
11  ********************************************************************
12
13  function: stdio-based convenience library for opening/seeking/decoding
14  last mod: $Id: vorbisfile.h 17182 2010-04-29 03:48:32Z xiphmont $
15
16  ********************************************************************/
17
18 #ifndef _OV_FILE_H_
19 #define _OV_FILE_H_
20
21 #define OV_EXCLUDE_STATIC_CALLBACKS
22
23 #ifdef __cplusplus
24 extern "C"
25 {
26 #endif /* __cplusplus */
27
28 #include <stdio.h>
29 #include "codec.h"
30
31 /* The function prototypes for the callbacks are basically the same as for
32  * the stdio functions fread, fseek, fclose, ftell.
33  * The one difference is that the FILE * arguments have been replaced with
34  * a void * - this is to be used as a pointer to whatever internal data these
35  * functions might need. In the stdio case, it's just a FILE * cast to a void *
36  *
37  * If you use other functions, check the docs for these functions and return
38  * the right values. For seek_func(), you *MUST* return -1 if the stream is
39  * unseekable
40  */
41 typedef struct {
42   size_t (*read_func)  (void *ptr, size_t size, size_t nmemb, void *datasource);
43   int    (*seek_func)  (void *datasource, ogg_int64_t offset, int whence);
44   int    (*close_func) (void *datasource);
45   long   (*tell_func)  (void *datasource);
46 } ov_callbacks;
47
48 #ifndef OV_EXCLUDE_STATIC_CALLBACKS
49
50 /* a few sets of convenient callbacks, especially for use under
51  * Windows where ov_open_callbacks() should always be used instead of
52  * ov_open() to avoid problems with incompatible crt.o version linking
53  * issues. */
54
55 static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){
56   if(f==NULL)return(-1);
57
58 #ifdef __MINGW32__
59   return fseeko64(f,off,whence);
60 #elif defined (_WIN32)
61   return _fseeki64(f,off,whence);
62 #else
63   return fseek(f,off,whence);
64 #endif
65 }
66
67 /* These structs below (OV_CALLBACKS_DEFAULT etc) are defined here as
68  * static data. That means that every file which includes this header
69  * will get its own copy of these structs whether it uses them or
70  * not unless it #defines OV_EXCLUDE_STATIC_CALLBACKS.
71  * These static symbols are essential on platforms such as Windows on
72  * which several different versions of stdio support may be linked to
73  * by different DLLs, and we need to be certain we know which one
74  * we're using (the same one as the main application).
75  */
76
77 static ov_callbacks OV_CALLBACKS_DEFAULT = {
78   (size_t (*)(void *, size_t, size_t, void *))  fread,
79   (int (*)(void *, ogg_int64_t, int))           _ov_header_fseek_wrap,
80   (int (*)(void *))                             fclose,
81   (long (*)(void *))                            ftell
82 };
83
84 static ov_callbacks OV_CALLBACKS_NOCLOSE = {
85   (size_t (*)(void *, size_t, size_t, void *))  fread,
86   (int (*)(void *, ogg_int64_t, int))           _ov_header_fseek_wrap,
87   (int (*)(void *))                             NULL,
88   (long (*)(void *))                            ftell
89 };
90
91 static ov_callbacks OV_CALLBACKS_STREAMONLY = {
92   (size_t (*)(void *, size_t, size_t, void *))  fread,
93   (int (*)(void *, ogg_int64_t, int))           NULL,
94   (int (*)(void *))                             fclose,
95   (long (*)(void *))                            NULL
96 };
97
98 static ov_callbacks OV_CALLBACKS_STREAMONLY_NOCLOSE = {
99   (size_t (*)(void *, size_t, size_t, void *))  fread,
100   (int (*)(void *, ogg_int64_t, int))           NULL,
101   (int (*)(void *))                             NULL,
102   (long (*)(void *))                            NULL
103 };
104
105 #endif
106
107 #define  NOTOPEN   0
108 #define  PARTOPEN  1
109 #define  OPENED    2
110 #define  STREAMSET 3
111 #define  INITSET   4
112
113 typedef struct OggVorbis_File {
114   void            *datasource; /* Pointer to a FILE *, etc. */
115   int              seekable;
116   ogg_int64_t      offset;
117   ogg_int64_t      end;
118   ogg_sync_state   oy;
119
120   /* If the FILE handle isn't seekable (eg, a pipe), only the current
121      stream appears */
122   int              links;
123   ogg_int64_t     *offsets;
124   ogg_int64_t     *dataoffsets;
125   long            *serialnos;
126   ogg_int64_t     *pcmlengths; /* overloaded to maintain binary
127                                   compatibility; x2 size, stores both
128                                   beginning and end values */
129   vorbis_info     *vi;
130   vorbis_comment  *vc;
131
132   /* Decoding working state local storage */
133   ogg_int64_t      pcm_offset;
134   int              ready_state;
135   long             current_serialno;
136   int              current_link;
137
138   double           bittrack;
139   double           samptrack;
140
141   ogg_stream_state os; /* take physical pages, weld into a logical
142                           stream of packets */
143   vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
144   vorbis_block     vb; /* local working space for packet->PCM decode */
145
146   ov_callbacks callbacks;
147
148 } OggVorbis_File;
149
150
151 extern int ov_clear(OggVorbis_File *vf);
152 extern int ov_fopen(const char *path,OggVorbis_File *vf);
153 extern int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes);
154 extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
155                 const char *initial, long ibytes, ov_callbacks callbacks);
156
157 extern int ov_test(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes);
158 extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf,
159                 const char *initial, long ibytes, ov_callbacks callbacks);
160 extern int ov_test_open(OggVorbis_File *vf);
161
162 extern long ov_bitrate(OggVorbis_File *vf,int i);
163 extern long ov_bitrate_instant(OggVorbis_File *vf);
164 extern long ov_streams(OggVorbis_File *vf);
165 extern long ov_seekable(OggVorbis_File *vf);
166 extern long ov_serialnumber(OggVorbis_File *vf,int i);
167
168 extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i);
169 extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i);
170 extern double ov_time_total(OggVorbis_File *vf,int i);
171
172 extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos);
173 extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos);
174 extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos);
175 extern int ov_time_seek(OggVorbis_File *vf,double pos);
176 extern int ov_time_seek_page(OggVorbis_File *vf,double pos);
177
178 extern int ov_raw_seek_lap(OggVorbis_File *vf,ogg_int64_t pos);
179 extern int ov_pcm_seek_lap(OggVorbis_File *vf,ogg_int64_t pos);
180 extern int ov_pcm_seek_page_lap(OggVorbis_File *vf,ogg_int64_t pos);
181 extern int ov_time_seek_lap(OggVorbis_File *vf,double pos);
182 extern int ov_time_seek_page_lap(OggVorbis_File *vf,double pos);
183
184 extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf);
185 extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf);
186 extern double ov_time_tell(OggVorbis_File *vf);
187
188 extern vorbis_info *ov_info(OggVorbis_File *vf,int link);
189 extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link);
190
191 extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int samples,
192                           int *bitstream);
193 extern long ov_read_filter(OggVorbis_File *vf,char *buffer,int length,
194                           int bigendianp,int word,int sgned,int *bitstream,
195                           void (*filter)(float **pcm,long channels,long samples,void *filter_param),void *filter_param);
196 extern long ov_read(OggVorbis_File *vf,char *buffer,int length,
197                     int bigendianp,int word,int sgned,int *bitstream);
198 extern int ov_crosslap(OggVorbis_File *vf1,OggVorbis_File *vf2);
199
200 extern int ov_halfrate(OggVorbis_File *vf,int flag);
201 extern int ov_halfrate_p(OggVorbis_File *vf);
202
203 #ifdef __cplusplus
204 }
205 #endif /* __cplusplus */
206
207 #endif
208