dbf-halloween2015

annotate libs/vorbis/vorbisfile.h @ 3:c37fe5d8a4ed

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