annotate src/libvorbis-1.3.3/include/vorbis/vorbisfile.h @ 88:fe7c3a0b0259

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