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-2002 *
9 * by the Xiph.Org Foundation http://www.xiph.org/ *
11 ********************************************************************
13 function: toplevel libogg include
16 ********************************************************************/
26 typedef short spx_ogg_int16_t
;
27 typedef unsigned short spx_ogg_uint16_t
;
28 typedef int spx_ogg_int32_t
;
29 typedef unsigned int spx_ogg_uint32_t
;
30 typedef long long spx_ogg_int64_t
;
33 #define _spx_ogg_malloc codec_malloc
34 #define _spx_ogg_calloc codec_calloc
35 #define _spx_ogg_realloc codec_realloc
36 #define _spx_ogg_free codec_free
43 unsigned char *buffer
;
48 /* spx_ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
51 unsigned char *header
;
57 /* spx_ogg_stream_state contains the current encode/decode state of a logical
58 Ogg bitstream **********************************************************/
61 unsigned char *body_data
; /* bytes from packet bodies */
62 long body_storage
; /* storage elements allocated */
63 long body_fill
; /* elements stored; fill mark */
64 long body_returned
; /* elements of fill returned */
67 int *lacing_vals
; /* The values that will go to the segment table */
68 spx_ogg_int64_t
*granule_vals
; /* granulepos values for headers. Not compact
69 this way, but it is simple coupled to the
76 unsigned char header
[282]; /* working space for header encode */
79 int e_o_s
; /* set when we have buffered the last packet in the
81 int b_o_s
; /* set after we've written the initial page
82 of a logical bitstream */
85 spx_ogg_int64_t packetno
; /* sequence number for decode; the framing
86 knows where there's a hole in the data,
87 but we need coupling so that the codec
88 (which is in a seperate abstraction
89 layer) also knows about the gap */
90 spx_ogg_int64_t granulepos
;
92 } spx_ogg_stream_state
;
94 /* spx_ogg_packet is used to encapsulate the data and metadata belonging
95 to a single raw Ogg/Vorbis packet *************************************/
98 unsigned char *packet
;
103 spx_ogg_int64_t granulepos
;
105 spx_ogg_int64_t packetno
; /* sequence number for decode; the framing
106 knows where there's a hole in the data,
107 but we need coupling so that the codec
108 (which is in a seperate abstraction
109 layer) also knows about the gap */
121 } spx_ogg_sync_state
;
123 /* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
125 extern void oggpack_writeinit(oggpack_buffer
*b
);
126 extern void oggpack_writetrunc(oggpack_buffer
*b
,long bits
);
127 extern void oggpack_writealign(oggpack_buffer
*b
);
128 extern void oggpack_writecopy(oggpack_buffer
*b
,void *source
,long bits
);
129 extern void oggpack_reset(oggpack_buffer
*b
);
130 extern void oggpack_writeclear(oggpack_buffer
*b
);
131 extern void oggpack_readinit(oggpack_buffer
*b
,unsigned char *buf
,int bytes
);
132 extern void oggpack_write(oggpack_buffer
*b
,unsigned long value
,int bits
);
133 extern long oggpack_look(oggpack_buffer
*b
,int bits
);
134 extern long oggpack_look1(oggpack_buffer
*b
);
135 extern void oggpack_adv(oggpack_buffer
*b
,int bits
);
136 extern void oggpack_adv1(oggpack_buffer
*b
);
137 extern long oggpack_read(oggpack_buffer
*b
,int bits
);
138 extern long oggpack_read1(oggpack_buffer
*b
);
139 extern long oggpack_bytes(oggpack_buffer
*b
);
140 extern long oggpack_bits(oggpack_buffer
*b
);
141 extern unsigned char *oggpack_get_buffer(oggpack_buffer
*b
);
143 extern void oggpackB_writeinit(oggpack_buffer
*b
);
144 extern void oggpackB_writetrunc(oggpack_buffer
*b
,long bits
);
145 extern void oggpackB_writealign(oggpack_buffer
*b
);
146 extern void oggpackB_writecopy(oggpack_buffer
*b
,void *source
,long bits
);
147 extern void oggpackB_reset(oggpack_buffer
*b
);
148 extern void oggpackB_writeclear(oggpack_buffer
*b
);
149 extern void oggpackB_readinit(oggpack_buffer
*b
,unsigned char *buf
,int bytes
);
150 extern void oggpackB_write(oggpack_buffer
*b
,unsigned long value
,int bits
);
151 extern long oggpackB_look(oggpack_buffer
*b
,int bits
);
152 extern long oggpackB_look1(oggpack_buffer
*b
);
153 extern void oggpackB_adv(oggpack_buffer
*b
,int bits
);
154 extern void oggpackB_adv1(oggpack_buffer
*b
);
155 extern long oggpackB_read(oggpack_buffer
*b
,int bits
);
156 extern long oggpackB_read1(oggpack_buffer
*b
);
157 extern long oggpackB_bytes(oggpack_buffer
*b
);
158 extern long oggpackB_bits(oggpack_buffer
*b
);
159 extern unsigned char *oggpackB_get_buffer(oggpack_buffer
*b
);
161 /* Ogg BITSTREAM PRIMITIVES: encoding **************************/
163 extern int spx_ogg_stream_packetin(spx_ogg_stream_state
*os
, spx_ogg_packet
*op
);
164 extern int spx_ogg_stream_pageout(spx_ogg_stream_state
*os
, spx_ogg_page
*og
);
165 extern int spx_ogg_stream_flush(spx_ogg_stream_state
*os
, spx_ogg_page
*og
);
167 /* Ogg BITSTREAM PRIMITIVES: decoding **************************/
169 extern int spx_ogg_sync_init(spx_ogg_sync_state
*oy
);
170 extern int spx_ogg_sync_clear(spx_ogg_sync_state
*oy
);
171 extern int spx_ogg_sync_reset(spx_ogg_sync_state
*oy
);
172 extern int spx_ogg_sync_destroy(spx_ogg_sync_state
*oy
);
174 extern void spx_ogg_alloc_buffer(spx_ogg_sync_state
*oy
, long size
);
175 extern char *spx_ogg_sync_buffer(spx_ogg_sync_state
*oy
, long size
);
176 extern int spx_ogg_sync_wrote(spx_ogg_sync_state
*oy
, long bytes
);
177 extern long spx_ogg_sync_pageseek(spx_ogg_sync_state
*oy
,spx_ogg_page
*og
);
178 extern int spx_ogg_sync_pageout(spx_ogg_sync_state
*oy
, spx_ogg_page
*og
);
179 extern int spx_ogg_stream_pagein(spx_ogg_stream_state
*os
, spx_ogg_page
*og
);
180 extern int spx_ogg_stream_packetout(spx_ogg_stream_state
*os
,spx_ogg_packet
*op
);
181 extern int spx_ogg_stream_packetpeek(spx_ogg_stream_state
*os
,spx_ogg_packet
*op
);
183 /* Ogg BITSTREAM PRIMITIVES: general ***************************/
185 extern int spx_ogg_stream_init(spx_ogg_stream_state
*os
,int serialno
);
186 extern int spx_ogg_stream_clear(spx_ogg_stream_state
*os
);
187 extern int spx_ogg_stream_reset(spx_ogg_stream_state
*os
);
188 extern int spx_ogg_stream_reset_serialno(spx_ogg_stream_state
*os
,int serialno
);
189 extern int spx_ogg_stream_destroy(spx_ogg_stream_state
*os
);
190 extern int spx_ogg_stream_eos(spx_ogg_stream_state
*os
);
192 extern void spx_ogg_page_checksum_set(spx_ogg_page
*og
);
194 extern int spx_ogg_page_version(spx_ogg_page
*og
);
195 extern int spx_ogg_page_continued(spx_ogg_page
*og
);
196 extern int spx_ogg_page_bos(spx_ogg_page
*og
);
197 extern int spx_ogg_page_eos(spx_ogg_page
*og
);
198 extern spx_ogg_int64_t
spx_ogg_page_granulepos(spx_ogg_page
*og
);
199 extern int spx_ogg_page_serialno(spx_ogg_page
*og
);
200 extern long spx_ogg_page_pageno(spx_ogg_page
*og
);
201 extern int spx_ogg_page_packets(spx_ogg_page
*og
);
203 extern void spx_ogg_packet_clear(spx_ogg_packet
*op
);