author | smxx |
Wed, 03 Mar 2010 16:41:07 +0000 | |
changeset 2926 | 610fe739ee4c |
parent 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 |
|
2421 | 20 |
|
2213 | 21 |
typedef struct { |
2421 | 22 |
unsigned char *data; |
23 |
int storage; |
|
24 |
int fill; |
|
25 |
int returned; |
|
26 |
int unsynced; |
|
27 |
int headerbytes; |
|
28 |
int bodybytes; |
|
2213 | 29 |
} ogg_sync_state; |
30 |
typedef struct vorbis_info{ |
|
2421 | 31 |
int version; |
32 |
int channels; |
|
33 |
long rate; |
|
34 |
/* The below bitrate declarations are *hints*. |
|
35 |
Combinations of the three values carry the following implications: all three set to the same value: implies a fixed rate bitstream |
|
36 |
only nominal set: implies a VBR stream that averages the nominal bitrate. No hard upper/lower limit |
|
37 |
upper and or lower set: implies a VBR bitstream that obeys the bitrate limits. nominal may also be set to give a nominal rate. |
|
38 |
none set: the coder does not care to speculate. */ |
|
39 |
long bitrate_upper; |
|
40 |
long bitrate_nominal; |
|
41 |
long bitrate_lower; |
|
42 |
long bitrate_window; |
|
43 |
void *codec_setup; |
|
2213 | 44 |
} vorbis_info; |
45 |
typedef struct vorbis_comment{ |
|
2421 | 46 |
/* unlimited user comment fields. libvorbis writes 'libvorbis' whatever vendor is set to in encode */ |
47 |
char **user_comments; |
|
48 |
int *comment_lengths; |
|
49 |
int comments; |
|
50 |
char *vendor; |
|
2213 | 51 |
} vorbis_comment; |
52 |
typedef struct { |
|
2421 | 53 |
unsigned char *body_data; /* bytes from packet bodies */ |
54 |
long body_storage; /* storage elements allocated */ |
|
55 |
long body_fill; /* elements stored; fill mark */ |
|
56 |
long body_returned; /* elements of fill returned */ |
|
57 |
int *lacing_vals; /* The values that will go to the segment table */ |
|
58 |
ogg_int64_t *granule_vals; |
|
59 |
/* granulepos values for headers. Not compact this way, but it is simple coupled to the lacing fifo */ |
|
60 |
long lacing_storage; |
|
61 |
long lacing_fill; |
|
62 |
long lacing_packet; |
|
63 |
long lacing_returned; |
|
64 |
unsigned char header[282]; /* working space for header encode */ |
|
65 |
int header_fill; |
|
66 |
int e_o_s; /* set when we have buffered the last packet in the logical bitstream */ |
|
67 |
int b_o_s; /* set after we've written the initial page of a logical bitstream */ |
|
68 |
long serialno; |
|
69 |
long pageno; |
|
70 |
ogg_int64_t packetno; |
|
71 |
/* sequence number for decode; the framing knows where there's a hole in the data, |
|
72 |
but we need coupling so that the codec (which is in a seperate abstraction layer) also knows about the gap */ |
|
73 |
ogg_int64_t granulepos; |
|
2213 | 74 |
} ogg_stream_state; |
75 |
typedef struct vorbis_dsp_state{ |
|
2421 | 76 |
int analysisp; |
77 |
vorbis_info *vi; |
|
78 |
float **pcm; |
|
79 |
float **pcmret; |
|
80 |
int pcm_storage; |
|
81 |
int pcm_current; |
|
82 |
int pcm_returned; |
|
83 |
int preextrapolate; |
|
84 |
int eofflag; |
|
85 |
long lW; |
|
86 |
long W; |
|
87 |
long nW; |
|
88 |
long centerW; |
|
89 |
ogg_int64_t granulepos; |
|
90 |
ogg_int64_t sequence; |
|
91 |
ogg_int64_t glue_bits; |
|
92 |
ogg_int64_t time_bits; |
|
93 |
ogg_int64_t floor_bits; |
|
94 |
ogg_int64_t res_bits; |
|
95 |
void *backend_state; |
|
2213 | 96 |
} vorbis_dsp_state; |
97 |
typedef struct { |
|
2421 | 98 |
long endbyte; |
99 |
int endbit; |
|
100 |
unsigned char *buffer; |
|
101 |
unsigned char *ptr; |
|
102 |
long storage; |
|
2213 | 103 |
} oggpack_buffer; |
104 |
typedef struct vorbis_block{ |
|
2421 | 105 |
/* necessary stream state for linking to the framing abstraction */ |
106 |
float **pcm; /* this is a pointer into local storage */ |
|
107 |
oggpack_buffer opb; |
|
108 |
long lW; |
|
109 |
long W; |
|
110 |
long nW; |
|
111 |
int pcmend; |
|
112 |
int mode; |
|
113 |
int eofflag; |
|
114 |
ogg_int64_t granulepos; |
|
115 |
ogg_int64_t sequence; |
|
116 |
vorbis_dsp_state *vd; /* For read-only access of configuration */ |
|
117 |
/* local storage to avoid remallocing; it's up to the mapping to structure it */ |
|
118 |
void *localstore; |
|
119 |
long localtop; |
|
120 |
long localalloc; |
|
121 |
long totaluse; |
|
122 |
struct alloc_chain *reap; |
|
123 |
/* bitmetrics for the frame */ |
|
124 |
long glue_bits; |
|
125 |
long time_bits; |
|
126 |
long floor_bits; |
|
127 |
long res_bits; |
|
128 |
void *internal; |
|
2213 | 129 |
} vorbis_block; |
130 |
typedef struct { |
|
2421 | 131 |
size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource); |
132 |
int (*seek_func) (void *datasource, ogg_int64_t offset, int whence); |
|
133 |
int (*close_func) (void *datasource); |
|
134 |
long (*tell_func) (void *datasource); |
|
2213 | 135 |
} ov_callbacks; |
136 |
typedef struct OggVorbis_File { |
|
2421 | 137 |
void *datasource; /* Pointer to a FILE *, etc. */ |
138 |
int seekable; |
|
139 |
ogg_int64_t offset; |
|
140 |
ogg_int64_t end; |
|
141 |
ogg_sync_state oy; |
|
142 |
/* If the FILE handle isn't seekable (eg, a pipe), only the current stream appears */ |
|
143 |
int links; |
|
144 |
ogg_int64_t *offsets; |
|
145 |
ogg_int64_t *dataoffsets; |
|
146 |
long *serialnos; |
|
147 |
ogg_int64_t *pcmlengths; |
|
148 |
/* overloaded to maintain binary |
|
149 |
compatability; x2 size, stores both |
|
150 |
beginning and end values */ |
|
151 |
vorbis_info *vi; |
|
152 |
vorbis_comment *vc; |
|
153 |
/* Decoding working state local storage */ |
|
154 |
ogg_int64_t pcm_offset; |
|
155 |
int ready_state; |
|
156 |
long current_serialno; |
|
157 |
int current_link; |
|
158 |
double bittrack; |
|
159 |
double samptrack; |
|
160 |
ogg_stream_state os; /* take physical pages, weld into a logical stream of packets */ |
|
161 |
vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ |
|
162 |
vorbis_block vb; /* local working space for packet->PCM decode */ |
|
163 |
ov_callbacks callbacks; |
|
2213 | 164 |
} OggVorbis_File; |
165 |
||
166 |
||
167 |
extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); |
|
2266 | 168 |
extern int ov_fopen(char *path,OggVorbis_File *vf); |
2213 | 169 |
extern long ov_read(OggVorbis_File *vf,char *buffer,int length,int bigendianp,int word,int sgned,int *bitstream); |
170 |
extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i); |
|
171 |
extern vorbis_info *ov_info(OggVorbis_File *vf,int link); |
|
172 |
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
|
173 |
extern int ov_clear(OggVorbis_File *vf); |
2213 | 174 |
|
175 |
#endif /*_OGGVORBIS_H*/ |