Debian Codegraph @

src/audio/ogg_vorbis/castleinternalogg.pas

raw
1 { Minimal translation of C /usr/include/ogg/ogg.h header.
2
3 Renamed to CastleInternalOgg, to avoid name clash with FPC's Ogg unit.
4 In the future, this may be removed in favor of simply using
5 FPC's Ogg unit. Although, from the 1st glance, it will require
6 fixing FPC's Ogg unit --- it will fail when Ogg library is not available,
7 while my CastleInternalOgg and CastleInternalVorbisFile units are made such that they can continue
8 (function pointers are loaded in initialization and failure only
9 casues setting some bool variable to @false).
10 Actually, CastleInternalOgg unit doesn't link at all to ogg library (it's not needed,
11 only structs are needed).
12
13 @exclude (Unit not really ready for PasDoc, with many comments from
14 original C headers.) }
15 unit CastleInternalOgg;
16
17 {$I castleconf.inc}
18 {$ifdef FPC}
19 {$packrecords C}
20 {$else}
21 {$ALIGN 4}
22 {$endif}
23
24
25 interface
26
27 uses CTypes;
28
29 type
30 Toggpack_buffer = record
31 endbyte: Clong;
32 endbit: Cint;
33 buffer: PChar;
34 ptr: PChar;
35 storage: Clong;
36 end;
37
38 (*
39 typedef struct {
40 long endbyte;
41 int endbit;
42
43 unsigned char *buffer;
44 unsigned char *ptr;
45 long storage;
46 } oggpack_buffer;
47
48 /* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
49
50 typedef struct {
51 unsigned char *header;
52 long header_len;
53 unsigned char *body;
54 long body_len;
55 } ogg_page;
56 *)
57
58 {* ogg_stream_state contains the current encode/decode state of a logical
59 Ogg bitstream **********************************************************}
60
61 Togg_stream_state = record
62 body_data: PChar; (* bytes from packet bodies *)
63 body_storage: Clong; (* storage elements allocated *)
64 body_fill: Clong; (* elements stored; fill mark *)
65 body_returned: Clong; (* elements of fill returned *)
66
67 lacing_vals: Pointer; (* The values that will go to the segment table *)
68 granule_vals: PInt64; (* granulepos values for headers. Not compact
69 this way, but it is simple coupled to the
70 lacing fifo *)
71 lacing_storage: Clong;
72 lacing_fill: Clong;
73 lacing_packet: Clong;
74 lacing_returned: Clong;
75
76 header: array[0..282] of Char; (* working space for header encode *)
77 header_fill: Cint;
78 e_o_s: Cint; (* set when we have buffered the last packet in the
79 logical bitstream *)
80 b_o_s: Cint; (* set after we've written the initial page
81 of a logical bitstream *)
82 serialno: Clong;
83 pageno: Clong;
84 packetno: Int64; (* sequence number for decode; the framing
85 knows where there's a hole in the data,
86 but we need coupling so that the codec
87 (which is in a seperate abstraction
88 layer) also knows about the gap *)
89 granulepos: Int64;
90 end;
91
92 (*
93 /* ogg_packet is used to encapsulate the data and metadata belonging
94 to a single raw Ogg/Vorbis packet *************************************/
95
96 typedef struct {
97 unsigned char *packet;
98 long bytes;
99 long b_o_s;
100 long e_o_s;
101
102 ogg_int64_t granulepos;
103
104 ogg_int64_t packetno; /* sequence number for decode; the framing
105 knows where there's a hole in the data,
106 but we need coupling so that the codec
107 (which is in a seperate abstraction
108 layer) also knows about the gap */
109 } ogg_packet;
110 *)
111
112 Togg_sync_state = record
113 data: PChar;
114 storage: CInt;
115 fill: CInt;
116 returned: CInt;
117
118 unsynced: CInt;
119 headerbytes: CInt;
120 bodybytes: CInt;
121 end;
122
123 (*
124 /* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
125
126 extern void oggpack_writeinit(oggpack_buffer *b);
127 extern void oggpack_writetrunc(oggpack_buffer *b,long bits);
128 extern void oggpack_writealign(oggpack_buffer *b);
129 extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits);
130 extern void oggpack_reset(oggpack_buffer *b);
131 extern void oggpack_writeclear(oggpack_buffer *b);
132 extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
133 extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
134 extern long oggpack_look(oggpack_buffer *b,int bits);
135 extern long oggpack_look1(oggpack_buffer *b);
136 extern void oggpack_adv(oggpack_buffer *b,int bits);
137 extern void oggpack_adv1(oggpack_buffer *b);
138 extern long oggpack_read(oggpack_buffer *b,int bits);
139 extern long oggpack_read1(oggpack_buffer *b);
140 extern long oggpack_bytes(oggpack_buffer *b);
141 extern long oggpack_bits(oggpack_buffer *b);
142 extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
143
144 extern void oggpackB_writeinit(oggpack_buffer *b);
145 extern void oggpackB_writetrunc(oggpack_buffer *b,long bits);
146 extern void oggpackB_writealign(oggpack_buffer *b);
147 extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits);
148 extern void oggpackB_reset(oggpack_buffer *b);
149 extern void oggpackB_writeclear(oggpack_buffer *b);
150 extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
151 extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits);
152 extern long oggpackB_look(oggpack_buffer *b,int bits);
153 extern long oggpackB_look1(oggpack_buffer *b);
154 extern void oggpackB_adv(oggpack_buffer *b,int bits);
155 extern void oggpackB_adv1(oggpack_buffer *b);
156 extern long oggpackB_read(oggpack_buffer *b,int bits);
157 extern long oggpackB_read1(oggpack_buffer *b);
158 extern long oggpackB_bytes(oggpack_buffer *b);
159 extern long oggpackB_bits(oggpack_buffer *b);
160 extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b);
161
162 /* Ogg BITSTREAM PRIMITIVES: encoding **************************/
163
164 extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
165 extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
166 extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
167
168 /* Ogg BITSTREAM PRIMITIVES: decoding **************************/
169
170 extern int ogg_sync_init(ogg_sync_state *oy);
171 extern int ogg_sync_clear(ogg_sync_state *oy);
172 extern int ogg_sync_reset(ogg_sync_state *oy);
173 extern int ogg_sync_destroy(ogg_sync_state *oy);
174
175 extern char *ogg_sync_buffer(ogg_sync_state *oy, long size);
176 extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
177 extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
178 extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
179 extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
180 extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
181 extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
182
183 /* Ogg BITSTREAM PRIMITIVES: general ***************************/
184
185 extern int ogg_stream_init(ogg_stream_state *os,int serialno);
186 extern int ogg_stream_clear(ogg_stream_state *os);
187 extern int ogg_stream_reset(ogg_stream_state *os);
188 extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
189 extern int ogg_stream_destroy(ogg_stream_state *os);
190 extern int ogg_stream_eos(ogg_stream_state *os);
191
192 extern void ogg_page_checksum_set(ogg_page *og);
193
194 extern int ogg_page_version(ogg_page *og);
195 extern int ogg_page_continued(ogg_page *og);
196 extern int ogg_page_bos(ogg_page *og);
197 extern int ogg_page_eos(ogg_page *og);
198 extern ogg_int64_t ogg_page_granulepos(ogg_page *og);
199 extern int ogg_page_serialno(ogg_page *og);
200 extern long ogg_page_pageno(ogg_page *og);
201 extern int ogg_page_packets(ogg_page *og);
202
203 extern void ogg_packet_clear(ogg_packet *op);
204 *)
205
206 implementation
207
208 end.