| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#ifndef _OV_FILE_H_ |
| 19 |
#define _OV_FILE_H_ |
| 20 |
|
| 21 |
#ifdef __cplusplus |
| 22 |
extern "C" |
| 23 |
{ |
| 24 |
#endif |
| 25 |
|
| 26 |
#include <stdio.h> |
| 27 |
#include "codec.h" |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
typedef struct { |
| 40 |
size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource); |
| 41 |
int (*seek_func) (void *datasource, ogg_int64_t offset, int whence); |
| 42 |
int (*close_func) (void *datasource); |
| 43 |
long (*tell_func) (void *datasource); |
| 44 |
} ov_callbacks; |
| 45 |
|
| 46 |
#ifndef OV_EXCLUDE_STATIC_CALLBACKS |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){ |
| 54 |
if(f==NULL)return(-1); |
| 55 |
|
| 56 |
#ifdef __MINGW32__ |
| 57 |
return fseeko64(f,off,whence); |
| 58 |
#elif defined (_WIN32) |
| 59 |
return _fseeki64(f,off,whence); |
| 60 |
#else |
| 61 |
return fseek(f,off,whence); |
| 62 |
#endif |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
static ov_callbacks OV_CALLBACKS_DEFAULT = { |
| 76 |
(size_t (*)(void *, size_t, size_t, void *)) fread, |
| 77 |
(int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap, |
| 78 |
(int (*)(void *)) fclose, |
| 79 |
(long (*)(void *)) ftell |
| 80 |
}; |
| 81 |
|
| 82 |
static ov_callbacks OV_CALLBACKS_NOCLOSE = { |
| 83 |
(size_t (*)(void *, size_t, size_t, void *)) fread, |
| 84 |
(int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap, |
| 85 |
(int (*)(void *)) NULL, |
| 86 |
(long (*)(void *)) ftell |
| 87 |
}; |
| 88 |
|
| 89 |
static ov_callbacks OV_CALLBACKS_STREAMONLY = { |
| 90 |
(size_t (*)(void *, size_t, size_t, void *)) fread, |
| 91 |
(int (*)(void *, ogg_int64_t, int)) NULL, |
| 92 |
(int (*)(void *)) fclose, |
| 93 |
(long (*)(void *)) NULL |
| 94 |
}; |
| 95 |
|
| 96 |
static ov_callbacks OV_CALLBACKS_STREAMONLY_NOCLOSE = { |
| 97 |
(size_t (*)(void *, size_t, size_t, void *)) fread, |
| 98 |
(int (*)(void *, ogg_int64_t, int)) NULL, |
| 99 |
(int (*)(void *)) NULL, |
| 100 |
(long (*)(void *)) NULL |
| 101 |
}; |
| 102 |
|
| 103 |
#endif |
| 104 |
|
| 105 |
#define NOTOPEN 0 |
| 106 |
#define PARTOPEN 1 |
| 107 |
#define OPENED 2 |
| 108 |
#define STREAMSET 3 |
| 109 |
#define INITSET 4 |
| 110 |
|
| 111 |
typedef struct OggVorbis_File { |
| 112 |
void *datasource; |
| 113 |
int seekable; |
| 114 |
ogg_int64_t offset; |
| 115 |
ogg_int64_t end; |
| 116 |
ogg_sync_state oy; |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
int links; |
| 121 |
ogg_int64_t *offsets; |
| 122 |
ogg_int64_t *dataoffsets; |
| 123 |
long *serialnos; |
| 124 |
ogg_int64_t *pcmlengths; |
| 125 |
|
| 126 |
|
| 127 |
vorbis_info *vi; |
| 128 |
vorbis_comment *vc; |
| 129 |
|
| 130 |
|
| 131 |
ogg_int64_t pcm_offset; |
| 132 |
int ready_state; |
| 133 |
long current_serialno; |
| 134 |
int current_link; |
| 135 |
|
| 136 |
double bittrack; |
| 137 |
double samptrack; |
| 138 |
|
| 139 |
ogg_stream_state os; |
| 140 |
|
| 141 |
vorbis_dsp_state vd; |
| 142 |
vorbis_block vb; |
| 143 |
|
| 144 |
ov_callbacks callbacks; |
| 145 |
|
| 146 |
} OggVorbis_File; |
| 147 |
|
| 148 |
|
| 149 |
extern int ov_clear(OggVorbis_File *vf); |
| 150 |
extern int ov_fopen(const char *path,OggVorbis_File *vf); |
| 151 |
extern int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes); |
| 152 |
extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, |
| 153 |
const char *initial, long ibytes, ov_callbacks callbacks); |
| 154 |
|
| 155 |
extern int ov_test(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes); |
| 156 |
extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, |
| 157 |
const char *initial, long ibytes, ov_callbacks callbacks); |
| 158 |
extern int ov_test_open(OggVorbis_File *vf); |
| 159 |
|
| 160 |
extern long ov_bitrate(OggVorbis_File *vf,int i); |
| 161 |
extern long ov_bitrate_instant(OggVorbis_File *vf); |
| 162 |
extern long ov_streams(OggVorbis_File *vf); |
| 163 |
extern long ov_seekable(OggVorbis_File *vf); |
| 164 |
extern long ov_serialnumber(OggVorbis_File *vf,int i); |
| 165 |
|
| 166 |
extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i); |
| 167 |
extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i); |
| 168 |
extern double ov_time_total(OggVorbis_File *vf,int i); |
| 169 |
|
| 170 |
extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos); |
| 171 |
extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos); |
| 172 |
extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos); |
| 173 |
extern int ov_time_seek(OggVorbis_File *vf,double pos); |
| 174 |
extern int ov_time_seek_page(OggVorbis_File *vf,double pos); |
| 175 |
|
| 176 |
extern int ov_raw_seek_lap(OggVorbis_File *vf,ogg_int64_t pos); |
| 177 |
extern int ov_pcm_seek_lap(OggVorbis_File *vf,ogg_int64_t pos); |
| 178 |
extern int ov_pcm_seek_page_lap(OggVorbis_File *vf,ogg_int64_t pos); |
| 179 |
extern int ov_time_seek_lap(OggVorbis_File *vf,double pos); |
| 180 |
extern int ov_time_seek_page_lap(OggVorbis_File *vf,double pos); |
| 181 |
|
| 182 |
extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf); |
| 183 |
extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf); |
| 184 |
extern double ov_time_tell(OggVorbis_File *vf); |
| 185 |
|
| 186 |
extern vorbis_info *ov_info(OggVorbis_File *vf,int link); |
| 187 |
extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); |
| 188 |
|
| 189 |
extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int samples, |
| 190 |
int *bitstream); |
| 191 |
extern long ov_read_filter(OggVorbis_File *vf,char *buffer,int length, |
| 192 |
int bigendianp,int word,int sgned,int *bitstream, |
| 193 |
void (*filter)(float **pcm,long channels,long samples,void *filter_param),void *filter_param); |
| 194 |
extern long ov_read(OggVorbis_File *vf,char *buffer,int length, |
| 195 |
int bigendianp,int word,int sgned,int *bitstream); |
| 196 |
extern int ov_crosslap(OggVorbis_File *vf1,OggVorbis_File *vf2); |
| 197 |
|
| 198 |
extern int ov_halfrate(OggVorbis_File *vf,int flag); |
| 199 |
extern int ov_halfrate_p(OggVorbis_File *vf); |
| 200 |
|
| 201 |
#ifdef __cplusplus |
| 202 |
} |
| 203 |
#endif |
| 204 |
|
| 205 |
#endif |
| 206 |
|