1 /********************************************************************
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. *
8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
9 * by the Xiph.Org Foundation http://www.xiph.org/ *
11 ********************************************************************
13 function: toplevel libogg include
15 ********************************************************************/
24 #include <ogg/os_types.h>
35 unsigned char *buffer;
40 /* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
43 unsigned char *header;
49 /* ogg_stream_state contains the current encode/decode state of a logical
50 Ogg bitstream **********************************************************/
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 */
59 int *lacing_vals; /* The values that will go to the segment table */
60 ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
61 this way, but it is simple coupled to the
68 unsigned char header[282]; /* working space for header encode */
71 int e_o_s; /* set when we have buffered the last packet in the
73 int b_o_s; /* set after we've written the initial page
74 of a logical bitstream */
77 ogg_int64_t packetno; /* sequence number for decode; the framing
78 knows where there's a hole in the data,
79 but we need coupling so that the codec
80 (which is in a separate abstraction
81 layer) also knows about the gap */
82 ogg_int64_t granulepos;
86 /* ogg_packet is used to encapsulate the data and metadata belonging
87 to a single raw Ogg/Vorbis packet *************************************/
90 unsigned char *packet;
95 ogg_int64_t granulepos;
97 ogg_int64_t packetno; /* sequence number for decode; the framing
98 knows where there's a hole in the data,
99 but we need coupling so that the codec
100 (which is in a separate abstraction
101 layer) also knows about the gap */
115 /* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
117 extern void oggpack_writeinit(oggpack_buffer *b);
118 extern int oggpack_writecheck(oggpack_buffer *b);
119 extern void oggpack_writetrunc(oggpack_buffer *b,long bits);
120 extern void oggpack_writealign(oggpack_buffer *b);
121 extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits);
122 extern void oggpack_reset(oggpack_buffer *b);
123 extern void oggpack_writeclear(oggpack_buffer *b);
124 extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
125 extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
126 extern long oggpack_look(oggpack_buffer *b,int bits);
127 extern long oggpack_look1(oggpack_buffer *b);
128 extern void oggpack_adv(oggpack_buffer *b,int bits);
129 extern void oggpack_adv1(oggpack_buffer *b);
130 extern long oggpack_read(oggpack_buffer *b,int bits);
131 extern long oggpack_read1(oggpack_buffer *b);
132 extern long oggpack_bytes(oggpack_buffer *b);
133 extern long oggpack_bits(oggpack_buffer *b);
134 extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
136 extern void oggpackB_writeinit(oggpack_buffer *b);
137 extern int oggpackB_writecheck(oggpack_buffer *b);
138 extern void oggpackB_writetrunc(oggpack_buffer *b,long bits);
139 extern void oggpackB_writealign(oggpack_buffer *b);
140 extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits);
141 extern void oggpackB_reset(oggpack_buffer *b);
142 extern void oggpackB_writeclear(oggpack_buffer *b);
143 extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
144 extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits);
145 extern long oggpackB_look(oggpack_buffer *b,int bits);
146 extern long oggpackB_look1(oggpack_buffer *b);
147 extern void oggpackB_adv(oggpack_buffer *b,int bits);
148 extern void oggpackB_adv1(oggpack_buffer *b);
149 extern long oggpackB_read(oggpack_buffer *b,int bits);
150 extern long oggpackB_read1(oggpack_buffer *b);
151 extern long oggpackB_bytes(oggpack_buffer *b);
152 extern long oggpackB_bits(oggpack_buffer *b);
153 extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b);
155 /* Ogg BITSTREAM PRIMITIVES: encoding **************************/
157 extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
158 extern int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov,
159 int count, long e_o_s, ogg_int64_t granulepos);
160 extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
161 extern int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill);
162 extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
163 extern int ogg_stream_flush_fill(ogg_stream_state *os, ogg_page *og, int nfill);
165 /* Ogg BITSTREAM PRIMITIVES: decoding **************************/
167 extern int ogg_sync_init(ogg_sync_state *oy);
168 extern int ogg_sync_clear(ogg_sync_state *oy);
169 extern int ogg_sync_reset(ogg_sync_state *oy);
170 extern int ogg_sync_destroy(ogg_sync_state *oy);
171 extern int ogg_sync_check(ogg_sync_state *oy);
173 extern char *ogg_sync_buffer(ogg_sync_state *oy, long size);
174 extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
175 extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
176 extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
177 extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
178 extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
179 extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
181 /* Ogg BITSTREAM PRIMITIVES: general ***************************/
183 extern int ogg_stream_init(ogg_stream_state *os,int serialno);
184 extern int ogg_stream_clear(ogg_stream_state *os);
185 extern int ogg_stream_reset(ogg_stream_state *os);
186 extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
187 extern int ogg_stream_destroy(ogg_stream_state *os);
188 extern int ogg_stream_check(ogg_stream_state *os);
189 extern int ogg_stream_eos(ogg_stream_state *os);
191 extern void ogg_page_checksum_set(ogg_page *og);
193 extern int ogg_page_version(const ogg_page *og);
194 extern int ogg_page_continued(const ogg_page *og);
195 extern int ogg_page_bos(const ogg_page *og);
196 extern int ogg_page_eos(const ogg_page *og);
197 extern ogg_int64_t ogg_page_granulepos(const ogg_page *og);
198 extern int ogg_page_serialno(const ogg_page *og);
199 extern long ogg_page_pageno(const ogg_page *og);
200 extern int ogg_page_packets(const ogg_page *og);
202 extern void ogg_packet_clear(ogg_packet *op);