author | unc0rr |
Thu, 13 Aug 2009 12:45:24 +0000 | |
changeset 2311 | 977ee15c3c1f |
parent 2266 | 289dc8e51210 |
child 2421 | a4b039ee2eb0 |
permissions | -rw-r--r-- |
2213 | 1 |
/******************************************************************** |
2 |
* * |
|
3 |
* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * |
|
4 |
* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * |
|
5 |
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * |
|
6 |
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * |
|
7 |
* * |
|
8 |
* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * |
|
9 |
* by the Xiph.Org Foundation http://www.xiph.org/ * |
|
10 |
* * |
|
11 |
********************************************************************/ |
|
12 |
||
13 |
#ifndef _OGGVORBIS_H |
|
14 |
#define _OGGVORBIS_H |
|
15 |
||
16 |
/*data types for ogg and vorbis that are required to be external*/ |
|
17 |
#ifndef ogg_int64_t |
|
18 |
#define ogg_int64_t int64_t |
|
19 |
#endif |
|
20 |
typedef struct { |
|
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
21 |
unsigned char *data; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
22 |
int storage; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
23 |
int fill; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
24 |
int returned; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
25 |
int unsynced; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
26 |
int headerbytes; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
27 |
int bodybytes; |
2213 | 28 |
} ogg_sync_state; |
29 |
typedef struct vorbis_info{ |
|
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
30 |
int version; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
31 |
int channels; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
32 |
long rate; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
33 |
/* The below bitrate declarations are *hints*. |
2265
eae64600fb69
fix a bug where a fclose() was called after an ov_clear()
koda
parents:
2260
diff
changeset
|
34 |
Combinations of the three values carry the following implications: all three set to the same value: implies a fixed rate bitstream |
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
35 |
only nominal set: implies a VBR stream that averages the nominal bitrate. No hard upper/lower limit |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
36 |
upper and or lower set: implies a VBR bitstream that obeys the bitrate limits. nominal may also be set to give a nominal rate. |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
37 |
none set: the coder does not care to speculate. */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
38 |
long bitrate_upper; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
39 |
long bitrate_nominal; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
40 |
long bitrate_lower; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
41 |
long bitrate_window; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
42 |
void *codec_setup; |
2213 | 43 |
} vorbis_info; |
44 |
typedef struct vorbis_comment{ |
|
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
45 |
/* unlimited user comment fields. libvorbis writes 'libvorbis' whatever vendor is set to in encode */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
46 |
char **user_comments; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
47 |
int *comment_lengths; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
48 |
int comments; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
49 |
char *vendor; |
2213 | 50 |
} vorbis_comment; |
51 |
typedef struct { |
|
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
52 |
unsigned char *body_data; /* bytes from packet bodies */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
53 |
long body_storage; /* storage elements allocated */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
54 |
long body_fill; /* elements stored; fill mark */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
55 |
long body_returned; /* elements of fill returned */ |
2265
eae64600fb69
fix a bug where a fclose() was called after an ov_clear()
koda
parents:
2260
diff
changeset
|
56 |
int *lacing_vals; /* The values that will go to the segment table */ |
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
57 |
ogg_int64_t *granule_vals; |
2265
eae64600fb69
fix a bug where a fclose() was called after an ov_clear()
koda
parents:
2260
diff
changeset
|
58 |
/* granulepos values for headers. Not compact this way, but it is simple coupled to the lacing fifo */ |
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
59 |
long lacing_storage; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
60 |
long lacing_fill; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
61 |
long lacing_packet; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
62 |
long lacing_returned; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
63 |
unsigned char header[282]; /* working space for header encode */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
64 |
int header_fill; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
65 |
int e_o_s; /* set when we have buffered the last packet in the logical bitstream */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
66 |
int b_o_s; /* set after we've written the initial page of a logical bitstream */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
67 |
long serialno; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
68 |
long pageno; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
69 |
ogg_int64_t packetno; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
70 |
/* sequence number for decode; the framing knows where there's a hole in the data, |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
71 |
but we need coupling so that the codec (which is in a seperate abstraction layer) also knows about the gap */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
72 |
ogg_int64_t granulepos; |
2213 | 73 |
} ogg_stream_state; |
74 |
typedef struct vorbis_dsp_state{ |
|
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
75 |
int analysisp; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
76 |
vorbis_info *vi; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
77 |
float **pcm; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
78 |
float **pcmret; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
79 |
int pcm_storage; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
80 |
int pcm_current; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
81 |
int pcm_returned; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
82 |
int preextrapolate; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
83 |
int eofflag; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
84 |
long lW; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
85 |
long W; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
86 |
long nW; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
87 |
long centerW; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
88 |
ogg_int64_t granulepos; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
89 |
ogg_int64_t sequence; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
90 |
ogg_int64_t glue_bits; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
91 |
ogg_int64_t time_bits; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
92 |
ogg_int64_t floor_bits; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
93 |
ogg_int64_t res_bits; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
94 |
void *backend_state; |
2213 | 95 |
} vorbis_dsp_state; |
96 |
typedef struct { |
|
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
97 |
long endbyte; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
98 |
int endbit; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
99 |
unsigned char *buffer; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
100 |
unsigned char *ptr; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
101 |
long storage; |
2213 | 102 |
} oggpack_buffer; |
103 |
typedef struct vorbis_block{ |
|
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
104 |
/* necessary stream state for linking to the framing abstraction */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
105 |
float **pcm; /* this is a pointer into local storage */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
106 |
oggpack_buffer opb; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
107 |
long lW; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
108 |
long W; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
109 |
long nW; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
110 |
int pcmend; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
111 |
int mode; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
112 |
int eofflag; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
113 |
ogg_int64_t granulepos; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
114 |
ogg_int64_t sequence; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
115 |
vorbis_dsp_state *vd; /* For read-only access of configuration */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
116 |
/* local storage to avoid remallocing; it's up to the mapping to structure it */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
117 |
void *localstore; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
118 |
long localtop; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
119 |
long localalloc; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
120 |
long totaluse; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
121 |
struct alloc_chain *reap; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
122 |
/* bitmetrics for the frame */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
123 |
long glue_bits; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
124 |
long time_bits; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
125 |
long floor_bits; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
126 |
long res_bits; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
127 |
void *internal; |
2213 | 128 |
} vorbis_block; |
129 |
typedef struct { |
|
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
130 |
size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource); |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
131 |
int (*seek_func) (void *datasource, ogg_int64_t offset, int whence); |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
132 |
int (*close_func) (void *datasource); |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
133 |
long (*tell_func) (void *datasource); |
2213 | 134 |
} ov_callbacks; |
135 |
typedef struct OggVorbis_File { |
|
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
136 |
void *datasource; /* Pointer to a FILE *, etc. */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
137 |
int seekable; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
138 |
ogg_int64_t offset; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
139 |
ogg_int64_t end; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
140 |
ogg_sync_state oy; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
141 |
/* If the FILE handle isn't seekable (eg, a pipe), only the current stream appears */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
142 |
int links; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
143 |
ogg_int64_t *offsets; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
144 |
ogg_int64_t *dataoffsets; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
145 |
long *serialnos; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
146 |
ogg_int64_t *pcmlengths; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
147 |
/* overloaded to maintain binary |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
148 |
compatability; x2 size, stores both |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
149 |
beginning and end values */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
150 |
vorbis_info *vi; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
151 |
vorbis_comment *vc; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
152 |
/* Decoding working state local storage */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
153 |
ogg_int64_t pcm_offset; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
154 |
int ready_state; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
155 |
long current_serialno; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
156 |
int current_link; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
157 |
double bittrack; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
158 |
double samptrack; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
159 |
ogg_stream_state os; /* take physical pages, weld into a logical stream of packets */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
160 |
vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
161 |
vorbis_block vb; /* local working space for packet->PCM decode */ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2257
diff
changeset
|
162 |
ov_callbacks callbacks; |
2213 | 163 |
} OggVorbis_File; |
164 |
||
165 |
||
166 |
extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); |
|
2266 | 167 |
extern int ov_fopen(char *path,OggVorbis_File *vf); |
2213 | 168 |
extern long ov_read(OggVorbis_File *vf,char *buffer,int length,int bigendianp,int word,int sgned,int *bitstream); |
169 |
extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i); |
|
170 |
extern vorbis_info *ov_info(OggVorbis_File *vf,int link); |
|
171 |
extern vorbis_comment *ov_comment(OggVorbis_File *f, int num); |
|
2257
7eb31efcfb9b
updates licence and fix a memory leak (which was consuming iphone memory)
koda
parents:
2213
diff
changeset
|
172 |
extern int ov_clear(OggVorbis_File *vf); |
2213 | 173 |
|
174 |
#endif /*_OGGVORBIS_H*/ |