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