1 /********************************************************************
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
12 ********************************************************************
14 function: subsumed libogg includes
16 ********************************************************************/
26 typedef struct ogg_buffer_state
{
27 struct ogg_buffer
*unused_buffers
;
28 struct ogg_reference
*unused_references
;
33 typedef struct ogg_buffer
{
39 ogg_buffer_state
*owner
;
40 struct ogg_buffer
*next
;
44 typedef struct ogg_reference
{
49 struct ogg_reference
*next
;
52 typedef struct oggpack_buffer
{
54 unsigned char *headptr
;
57 /* memory management */
61 /* render the byte/bit counter API constant time */
62 long count
; /* doesn't count the tail */
65 typedef struct oggbyte_buffer
{
66 ogg_reference
*baseref
;
74 typedef struct ogg_sync_state
{
75 /* decode memory management pool */
76 ogg_buffer_state
*bufferpool
;
79 ogg_reference
*fifo_head
;
80 ogg_reference
*fifo_tail
;
83 /* stream sync management */
90 typedef struct ogg_stream_state
{
91 ogg_reference
*header_head
;
92 ogg_reference
*header_tail
;
93 ogg_reference
*body_head
;
94 ogg_reference
*body_tail
;
96 int e_o_s
; /* set when we have buffered the last
97 packet in the logical bitstream */
98 int b_o_s
; /* set after we've written the initial page
99 of a logical bitstream */
102 ogg_int64_t packetno
; /* sequence number for decode; the framing
103 knows where there's a hole in the data,
104 but we need coupling so that the codec
105 (which is in a seperate abstraction
106 layer) also knows about the gap */
107 ogg_int64_t granulepos
;
110 ogg_uint32_t body_fill
;
112 /* decode-side state data */
117 ogg_uint32_t body_fill_next
;
122 ogg_reference
*packet
;
126 ogg_int64_t granulepos
;
127 ogg_int64_t packetno
; /* sequence number for decode; the framing
128 knows where there's a hole in the data,
129 but we need coupling so that the codec
130 (which is in a seperate abstraction
131 layer) also knows about the gap */
135 ogg_reference
*header
;
141 /* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
143 extern void oggpack_readinit(oggpack_buffer
*b
,ogg_reference
*r
);
144 extern long oggpack_look(oggpack_buffer
*b
,int bits
);
145 extern void oggpack_adv(oggpack_buffer
*b
,int bits
);
146 extern long oggpack_read(oggpack_buffer
*b
,int bits
);
147 extern long oggpack_bytes(oggpack_buffer
*b
);
148 extern long oggpack_bits(oggpack_buffer
*b
);
149 extern int oggpack_eop(oggpack_buffer
*b
);
151 /* Ogg BITSTREAM PRIMITIVES: decoding **************************/
153 extern ogg_sync_state
*ogg_sync_create(void);
154 extern int ogg_sync_destroy(ogg_sync_state
*oy
);
155 extern int ogg_sync_reset(ogg_sync_state
*oy
);
157 extern unsigned char *ogg_sync_bufferin(ogg_sync_state
*oy
, long size
);
158 extern int ogg_sync_wrote(ogg_sync_state
*oy
, long bytes
);
159 extern long ogg_sync_pageseek(ogg_sync_state
*oy
,ogg_page
*og
);
160 extern int ogg_sync_pageout(ogg_sync_state
*oy
, ogg_page
*og
);
161 extern int ogg_stream_pagein(ogg_stream_state
*os
, ogg_page
*og
);
162 extern int ogg_stream_packetout(ogg_stream_state
*os
,ogg_packet
*op
);
163 extern int ogg_stream_packetpeek(ogg_stream_state
*os
,ogg_packet
*op
);
165 /* Ogg BITSTREAM PRIMITIVES: general ***************************/
167 extern ogg_stream_state
*ogg_stream_create(int serialno
);
168 extern int ogg_stream_destroy(ogg_stream_state
*os
);
169 extern int ogg_stream_reset(ogg_stream_state
*os
);
170 extern int ogg_stream_reset_serialno(ogg_stream_state
*os
,int serialno
);
171 extern int ogg_stream_eos(ogg_stream_state
*os
);
173 extern int ogg_page_checksum_set(ogg_page
*og
);
175 extern int ogg_page_version(ogg_page
*og
);
176 extern int ogg_page_continued(ogg_page
*og
);
177 extern int ogg_page_bos(ogg_page
*og
);
178 extern int ogg_page_eos(ogg_page
*og
);
179 extern ogg_int64_t
ogg_page_granulepos(ogg_page
*og
);
180 extern ogg_uint32_t
ogg_page_serialno(ogg_page
*og
);
181 extern ogg_uint32_t
ogg_page_pageno(ogg_page
*og
);
182 extern int ogg_page_packets(ogg_page
*og
);
183 extern int ogg_page_getbuffer(ogg_page
*og
, unsigned char **buffer
);
185 extern int ogg_packet_release(ogg_packet
*op
);
186 extern int ogg_page_release(ogg_page
*og
);
188 extern void ogg_page_dup(ogg_page
*d
, ogg_page
*s
);
190 /* Ogg BITSTREAM PRIMITIVES: return codes ***************************/
192 #define OGG_SUCCESS 0
196 #define OGG_EVERSION -12
197 #define OGG_ESERIAL -13
198 #define OGG_EINVAL -14