summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libspeex/speex/ogg.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libspeex/speex/ogg.h')
-rw-r--r--lib/rbcodec/codecs/libspeex/speex/ogg.h216
1 files changed, 216 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libspeex/speex/ogg.h b/lib/rbcodec/codecs/libspeex/speex/ogg.h
new file mode 100644
index 0000000000..8898b99582
--- /dev/null
+++ b/lib/rbcodec/codecs/libspeex/speex/ogg.h
@@ -0,0 +1,216 @@
1/********************************************************************
2 * *
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. *
7 * *
8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
9 * by the Xiph.Org Foundation http://www.xiph.org/ *
10 * *
11 ********************************************************************
12
13 function: toplevel libogg include
14 last mod: $Id$
15
16 ********************************************************************/
17#ifndef _OGG_H
18#define _OGG_H
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include "codeclib.h"
25
26typedef short spx_ogg_int16_t;
27typedef unsigned short spx_ogg_uint16_t;
28typedef int spx_ogg_int32_t;
29typedef unsigned int spx_ogg_uint32_t;
30typedef long long spx_ogg_int64_t;
31
32
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
37
38
39typedef struct {
40 long endbyte;
41 int endbit;
42
43 unsigned char *buffer;
44 unsigned char *ptr;
45 long storage;
46} oggpack_buffer;
47
48/* spx_ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
49
50typedef struct {
51 unsigned char *header;
52 long header_len;
53 unsigned char *body;
54 long body_len;
55} spx_ogg_page;
56
57/* spx_ogg_stream_state contains the current encode/decode state of a logical
58 Ogg bitstream **********************************************************/
59
60typedef struct {
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 */
65
66
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
70 lacing fifo */
71 long lacing_storage;
72 long lacing_fill;
73 long lacing_packet;
74 long lacing_returned;
75
76 unsigned char header[282]; /* working space for header encode */
77 int header_fill;
78
79 int e_o_s; /* set when we have buffered the last packet in the
80 logical bitstream */
81 int b_o_s; /* set after we've written the initial page
82 of a logical bitstream */
83 long serialno;
84 long pageno;
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;
91
92} spx_ogg_stream_state;
93
94/* spx_ogg_packet is used to encapsulate the data and metadata belonging
95 to a single raw Ogg/Vorbis packet *************************************/
96
97typedef struct {
98 unsigned char *packet;
99 long bytes;
100 long b_o_s;
101 long e_o_s;
102
103 spx_ogg_int64_t granulepos;
104
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 */
110} spx_ogg_packet;
111
112typedef struct {
113 unsigned char *data;
114 int storage;
115 int fill;
116 int returned;
117
118 int unsynced;
119 int headerbytes;
120 int bodybytes;
121} spx_ogg_sync_state;
122
123/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
124
125extern void oggpack_writeinit(oggpack_buffer *b);
126extern void oggpack_writetrunc(oggpack_buffer *b,long bits);
127extern void oggpack_writealign(oggpack_buffer *b);
128extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits);
129extern void oggpack_reset(oggpack_buffer *b);
130extern void oggpack_writeclear(oggpack_buffer *b);
131extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
132extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
133extern long oggpack_look(oggpack_buffer *b,int bits);
134extern long oggpack_look1(oggpack_buffer *b);
135extern void oggpack_adv(oggpack_buffer *b,int bits);
136extern void oggpack_adv1(oggpack_buffer *b);
137extern long oggpack_read(oggpack_buffer *b,int bits);
138extern long oggpack_read1(oggpack_buffer *b);
139extern long oggpack_bytes(oggpack_buffer *b);
140extern long oggpack_bits(oggpack_buffer *b);
141extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
142
143extern void oggpackB_writeinit(oggpack_buffer *b);
144extern void oggpackB_writetrunc(oggpack_buffer *b,long bits);
145extern void oggpackB_writealign(oggpack_buffer *b);
146extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits);
147extern void oggpackB_reset(oggpack_buffer *b);
148extern void oggpackB_writeclear(oggpack_buffer *b);
149extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
150extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits);
151extern long oggpackB_look(oggpack_buffer *b,int bits);
152extern long oggpackB_look1(oggpack_buffer *b);
153extern void oggpackB_adv(oggpack_buffer *b,int bits);
154extern void oggpackB_adv1(oggpack_buffer *b);
155extern long oggpackB_read(oggpack_buffer *b,int bits);
156extern long oggpackB_read1(oggpack_buffer *b);
157extern long oggpackB_bytes(oggpack_buffer *b);
158extern long oggpackB_bits(oggpack_buffer *b);
159extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b);
160
161/* Ogg BITSTREAM PRIMITIVES: encoding **************************/
162
163extern int spx_ogg_stream_packetin(spx_ogg_stream_state *os, spx_ogg_packet *op);
164extern int spx_ogg_stream_pageout(spx_ogg_stream_state *os, spx_ogg_page *og);
165extern int spx_ogg_stream_flush(spx_ogg_stream_state *os, spx_ogg_page *og);
166
167/* Ogg BITSTREAM PRIMITIVES: decoding **************************/
168
169extern int spx_ogg_sync_init(spx_ogg_sync_state *oy);
170extern int spx_ogg_sync_clear(spx_ogg_sync_state *oy);
171extern int spx_ogg_sync_reset(spx_ogg_sync_state *oy);
172extern int spx_ogg_sync_destroy(spx_ogg_sync_state *oy);
173
174extern void spx_ogg_alloc_buffer(spx_ogg_sync_state *oy, long size);
175extern char *spx_ogg_sync_buffer(spx_ogg_sync_state *oy, long size);
176extern int spx_ogg_sync_wrote(spx_ogg_sync_state *oy, long bytes);
177extern long spx_ogg_sync_pageseek(spx_ogg_sync_state *oy,spx_ogg_page *og);
178extern int spx_ogg_sync_pageout(spx_ogg_sync_state *oy, spx_ogg_page *og);
179extern int spx_ogg_stream_pagein(spx_ogg_stream_state *os, spx_ogg_page *og);
180extern int spx_ogg_stream_packetout(spx_ogg_stream_state *os,spx_ogg_packet *op);
181extern int spx_ogg_stream_packetpeek(spx_ogg_stream_state *os,spx_ogg_packet *op);
182
183/* Ogg BITSTREAM PRIMITIVES: general ***************************/
184
185extern int spx_ogg_stream_init(spx_ogg_stream_state *os,int serialno);
186extern int spx_ogg_stream_clear(spx_ogg_stream_state *os);
187extern int spx_ogg_stream_reset(spx_ogg_stream_state *os);
188extern int spx_ogg_stream_reset_serialno(spx_ogg_stream_state *os,int serialno);
189extern int spx_ogg_stream_destroy(spx_ogg_stream_state *os);
190extern int spx_ogg_stream_eos(spx_ogg_stream_state *os);
191
192extern void spx_ogg_page_checksum_set(spx_ogg_page *og);
193
194extern int spx_ogg_page_version(spx_ogg_page *og);
195extern int spx_ogg_page_continued(spx_ogg_page *og);
196extern int spx_ogg_page_bos(spx_ogg_page *og);
197extern int spx_ogg_page_eos(spx_ogg_page *og);
198extern spx_ogg_int64_t spx_ogg_page_granulepos(spx_ogg_page *og);
199extern int spx_ogg_page_serialno(spx_ogg_page *og);
200extern long spx_ogg_page_pageno(spx_ogg_page *og);
201extern int spx_ogg_page_packets(spx_ogg_page *og);
202
203extern void spx_ogg_packet_clear(spx_ogg_packet *op);
204
205
206#ifdef __cplusplus
207}
208#endif
209
210#endif /* _OGG_H */
211
212
213
214
215
216