14280
|
1 /********************************************************************
|
|
2 * *
|
|
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
|
|
4 * *
|
|
5 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
|
|
6 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
|
|
7 * ALL REDISTRIBUTION RIGHTS RESERVED. *
|
|
8 * *
|
|
9 ********************************************************************
|
|
10
|
|
11 function: subsumed libogg includes
|
|
12
|
|
13 ********************************************************************/
|
|
14 #ifndef _OGG_H
|
|
15 #define _OGG_H
|
|
16
|
|
17 #ifdef __cplusplus
|
|
18 extern "C" {
|
|
19 #endif
|
|
20
|
|
21 #include "os_types.h"
|
|
22
|
|
23 typedef struct {
|
|
24 long endbyte;
|
|
25 int endbit;
|
|
26
|
|
27 unsigned char *buffer;
|
|
28 unsigned char *ptr;
|
|
29 long storage;
|
|
30 } oggpack_buffer;
|
|
31
|
|
32 /* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
|
|
33
|
|
34 typedef struct {
|
|
35 unsigned char *header;
|
|
36 long header_len;
|
|
37 unsigned char *body;
|
|
38 long body_len;
|
|
39 } ogg_page;
|
|
40
|
|
41 /* ogg_stream_state contains the current encode/decode state of a logical
|
|
42 Ogg bitstream **********************************************************/
|
|
43
|
|
44 typedef struct {
|
|
45 unsigned char *body_data; /* bytes from packet bodies */
|
|
46 long body_storage; /* storage elements allocated */
|
|
47 long body_fill; /* elements stored; fill mark */
|
|
48 long body_returned; /* elements of fill returned */
|
|
49
|
|
50
|
|
51 int *lacing_vals; /* The values that will go to the segment table */
|
|
52 ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
|
|
53 this way, but it is simple coupled to the
|
|
54 lacing fifo */
|
|
55 long lacing_storage;
|
|
56 long lacing_fill;
|
|
57 long lacing_packet;
|
|
58 long lacing_returned;
|
|
59
|
|
60 unsigned char header[282]; /* working space for header encode */
|
|
61 int header_fill;
|
|
62
|
|
63 int e_o_s; /* set when we have buffered the last packet in the
|
|
64 logical bitstream */
|
|
65 int b_o_s; /* set after we've written the initial page
|
|
66 of a logical bitstream */
|
|
67 long serialno;
|
|
68 long pageno;
|
|
69 ogg_int64_t packetno; /* sequence number for decode; the framing
|
|
70 knows where there's a hole in the data,
|
|
71 but we need coupling so that the codec
|
|
72 (which is in a seperate abstraction
|
|
73 layer) also knows about the gap */
|
|
74 ogg_int64_t granulepos;
|
|
75
|
|
76 } ogg_stream_state;
|
|
77
|
|
78 /* ogg_packet is used to encapsulate the data and metadata belonging
|
|
79 to a single raw Ogg/Vorbis packet *************************************/
|
|
80
|
|
81 typedef struct {
|
|
82 unsigned char *packet;
|
|
83 long bytes;
|
|
84 long b_o_s;
|
|
85 long e_o_s;
|
|
86
|
|
87 ogg_int64_t granulepos;
|
|
88
|
|
89 ogg_int64_t packetno; /* sequence number for decode; the framing
|
|
90 knows where there's a hole in the data,
|
|
91 but we need coupling so that the codec
|
|
92 (which is in a seperate abstraction
|
|
93 layer) also knows about the gap */
|
|
94 } ogg_packet;
|
|
95
|
|
96 typedef struct {
|
|
97 unsigned char *data;
|
|
98 int storage;
|
|
99 int fill;
|
|
100 int returned;
|
|
101
|
|
102 int unsynced;
|
|
103 int headerbytes;
|
|
104 int bodybytes;
|
|
105 } ogg_sync_state;
|
|
106
|
|
107 /* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
|
|
108
|
|
109 extern void oggpack_writeinit(oggpack_buffer *b);
|
|
110 extern void oggpack_reset(oggpack_buffer *b);
|
|
111 extern void oggpack_writeclear(oggpack_buffer *b);
|
|
112 extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
|
|
113 extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
|
|
114 extern long oggpack_look(oggpack_buffer *b,int bits);
|
|
115 extern long oggpack_look_huff(oggpack_buffer *b,int bits);
|
|
116 extern long oggpack_look1(oggpack_buffer *b);
|
|
117 extern void oggpack_adv(oggpack_buffer *b,int bits);
|
|
118 extern int oggpack_adv_huff(oggpack_buffer *b,int bits);
|
|
119 extern void oggpack_adv1(oggpack_buffer *b);
|
|
120 extern long oggpack_read(oggpack_buffer *b,int bits);
|
|
121 extern long oggpack_read1(oggpack_buffer *b);
|
|
122 extern long oggpack_bytes(oggpack_buffer *b);
|
|
123 extern long oggpack_bits(oggpack_buffer *b);
|
|
124 extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
|
|
125
|
|
126 /* Ogg BITSTREAM PRIMITIVES: decoding **************************/
|
|
127
|
|
128 extern int ogg_sync_init(ogg_sync_state *oy);
|
|
129 extern int ogg_sync_clear(ogg_sync_state *oy);
|
|
130 extern int ogg_sync_reset(ogg_sync_state *oy);
|
|
131 extern int ogg_sync_destroy(ogg_sync_state *oy);
|
|
132
|
|
133 extern char *ogg_sync_buffer(ogg_sync_state *oy, long size);
|
|
134 extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
|
|
135 extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
|
|
136 extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
|
|
137 extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
|
|
138 extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
|
|
139 extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
|
|
140
|
|
141 /* Ogg BITSTREAM PRIMITIVES: general ***************************/
|
|
142
|
|
143 extern int ogg_stream_init(ogg_stream_state *os,int serialno);
|
|
144 extern int ogg_stream_clear(ogg_stream_state *os);
|
|
145 extern int ogg_stream_reset(ogg_stream_state *os);
|
|
146 extern int ogg_stream_destroy(ogg_stream_state *os);
|
|
147 extern int ogg_stream_eos(ogg_stream_state *os);
|
|
148
|
|
149 extern void ogg_page_checksum_set(ogg_page *og);
|
|
150
|
|
151 extern int ogg_page_version(ogg_page *og);
|
|
152 extern int ogg_page_continued(ogg_page *og);
|
|
153 extern int ogg_page_bos(ogg_page *og);
|
|
154 extern int ogg_page_eos(ogg_page *og);
|
|
155 extern ogg_int64_t ogg_page_granulepos(ogg_page *og);
|
|
156 extern int ogg_page_serialno(ogg_page *og);
|
|
157 extern long ogg_page_pageno(ogg_page *og);
|
|
158 extern int ogg_page_packets(ogg_page *og);
|
|
159
|
|
160 extern void ogg_packet_clear(ogg_packet *op);
|
|
161
|
|
162
|
|
163 #ifdef __cplusplus
|
|
164 }
|
|
165 #endif
|
|
166
|
|
167 #endif /* _OGG_H */
|