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