vrshoot

annotate libs/vorbis/vorbisfile.h @ 0:b2f14e535253

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