annotate win32-mingw/include/vorbis/vorbisfile.h @ 3:6c505a35919a

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