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-2007 *
9 * by the Xiph.Org Foundation http://www.xiph.org/ *
11 ********************************************************************/
12 module iv
.xyph
.ogg
/*is aliced*/;
15 import core
.stdc
.config
;
18 alias ogg_int64_t
= long;
26 struct oggpack_buffer
{
36 /* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
45 /* ogg_stream_state contains the current encode/decode state of a logical
46 Ogg bitstream **********************************************************/
47 struct ogg_stream_state
{
48 ubyte* body_data
; /* bytes from packet bodies */
49 c_long body_storage
; /* storage elements allocated */
50 c_long body_fill
; /* elements stored; fill mark */
51 c_long body_returned
; /* elements of fill returned */
54 int* lacing_vals
; /* The values that will go to the segment table */
55 long* granule_vals
; /* granulepos values for headers. Not compact
56 this way, but it is simple coupled to the
58 c_long lacing_storage
;
61 c_long lacing_returned
;
63 ubyte[282] header
; /* working space for header encode */
66 int e_o_s
; /* set when we have buffered the last packet in the logical bitstream */
67 int b_o_s
; /* set after we've written the initial page of a logical bitstream */
70 long packetno
; /* sequence number for decode; the framing
71 knows where there's a hole in the data,
72 but we need coupling so that the codec
73 (which is in a separate abstraction
74 layer) also knows about the gap */
79 /* ogg_packet is used to encapsulate the data and metadata belonging
80 to a single raw Ogg/Vorbis packet *************************************/
89 long 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 separate abstraction
93 layer) also knows about the gap */
97 struct ogg_sync_state
{
109 extern(C
) nothrow @nogc:
111 /* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
112 void oggpack_writeinit (oggpack_buffer
* b
);
113 int oggpack_writecheck (oggpack_buffer
* b
);
114 void oggpack_writetrunc (oggpack_buffer
* b
, c_long bits
);
115 void oggpack_writealign (oggpack_buffer
* b
);
116 void oggpack_writecopy (oggpack_buffer
* b
, void* source
, c_long bits
);
117 void oggpack_reset (oggpack_buffer
* b
);
118 void oggpack_writeclear (oggpack_buffer
* b
);
119 void oggpack_readinit (oggpack_buffer
* b
, ubyte* buf
, int bytes
);
120 void oggpack_write (oggpack_buffer
* b
, c_ulong value
, int bits
);
121 c_long
oggpack_look (oggpack_buffer
* b
, int bits
);
122 c_long
oggpack_look1 (oggpack_buffer
* b
);
123 void oggpack_adv (oggpack_buffer
* b
, int bits
);
124 void oggpack_adv1 (oggpack_buffer
* b
);
125 c_long
oggpack_read (oggpack_buffer
* b
, int bits
);
126 c_long
oggpack_read1 (oggpack_buffer
* b
);
127 c_long
oggpack_bytes (oggpack_buffer
* b
);
128 c_long
oggpack_bits (oggpack_buffer
* b
);
129 ubyte* oggpack_get_buffer (oggpack_buffer
* b
);
131 void oggpackB_writeinit (oggpack_buffer
* b
);
132 int oggpackB_writecheck (oggpack_buffer
* b
);
133 void oggpackB_writetrunc (oggpack_buffer
* b
, c_long bits
);
134 void oggpackB_writealign (oggpack_buffer
* b
);
135 void oggpackB_writecopy (oggpack_buffer
* b
, void* source
, c_long bits
);
136 void oggpackB_reset (oggpack_buffer
* b
);
137 void oggpackB_writeclear (oggpack_buffer
* b
);
138 void oggpackB_readinit (oggpack_buffer
* b
, ubyte* buf
, int bytes
);
139 void oggpackB_write (oggpack_buffer
* b
, c_ulong value
, int bits
);
140 c_long
oggpackB_look (oggpack_buffer
* b
, int bits
);
141 c_long
oggpackB_look1 (oggpack_buffer
* b
);
142 void oggpackB_adv (oggpack_buffer
* b
, int bits
);
143 void oggpackB_adv1 (oggpack_buffer
* b
);
144 c_long
oggpackB_read (oggpack_buffer
* b
, int bits
);
145 c_long
oggpackB_read1 (oggpack_buffer
* b
);
146 c_long
oggpackB_bytes (oggpack_buffer
* b
);
147 c_long
oggpackB_bits (oggpack_buffer
* b
);
148 ubyte* oggpackB_get_buffer (oggpack_buffer
* b
);
151 /* Ogg BITSTREAM PRIMITIVES: encoding **************************/
152 int ogg_stream_packetin (ogg_stream_state
* os
, ogg_packet
* op
);
153 int ogg_stream_iovecin (ogg_stream_state
* os
, ogg_iovec_t
* iov
,
154 int count
, c_long e_o_s
, long granulepos
);
155 int ogg_stream_pageout (ogg_stream_state
* os
, ogg_page
* og
);
156 int ogg_stream_pageout_fill (ogg_stream_state
* os
, ogg_page
* og
, int nfill
);
157 int ogg_stream_flush (ogg_stream_state
* os
, ogg_page
* og
);
158 int ogg_stream_flush_fill (ogg_stream_state
* os
, ogg_page
* og
, int nfill
);
161 /* Ogg BITSTREAM PRIMITIVES: decoding **************************/
162 int ogg_sync_init (ogg_sync_state
* oy
);
163 int ogg_sync_clear (ogg_sync_state
* oy
);
164 int ogg_sync_reset (ogg_sync_state
* oy
);
165 int ogg_sync_destroy (ogg_sync_state
* oy
);
166 int ogg_sync_check (ogg_sync_state
* oy
);
168 char* ogg_sync_buffer (ogg_sync_state
* oy
, c_long size
);
169 int ogg_sync_wrote (ogg_sync_state
* oy
, c_long bytes
);
170 c_long
ogg_sync_pageseek (ogg_sync_state
* oy
, ogg_page
* og
);
171 int ogg_sync_pageout (ogg_sync_state
* oy
, ogg_page
* og
);
172 int ogg_stream_pagein (ogg_stream_state
* os
, ogg_page
* og
);
173 int ogg_stream_packetout (ogg_stream_state
* os
, ogg_packet
* op
);
174 int ogg_stream_packetpeek (ogg_stream_state
* os
, ogg_packet
* op
);
177 /* Ogg BITSTREAM PRIMITIVES: general ***************************/
178 int ogg_stream_init (ogg_stream_state
* os
, int serialno
);
179 int ogg_stream_clear (ogg_stream_state
* os
);
180 int ogg_stream_reset (ogg_stream_state
* os
);
181 int ogg_stream_reset_serialno (ogg_stream_state
* os
, int serialno
);
182 int ogg_stream_destroy (ogg_stream_state
* os
);
183 int ogg_stream_check (ogg_stream_state
* os
);
184 int ogg_stream_eos (ogg_stream_state
* os
);
186 void ogg_page_checksum_set (ogg_page
* og
);
188 int ogg_page_version (const ogg_page
* og
);
189 int ogg_page_continued (const ogg_page
* og
);
190 int ogg_page_bos (const ogg_page
* og
);
191 int ogg_page_eos (const ogg_page
* og
);
192 long ogg_page_granulepos (const ogg_page
* og
);
193 int ogg_page_serialno (const ogg_page
* og
);
194 c_long
ogg_page_pageno (const ogg_page
* og
);
195 int ogg_page_packets (const ogg_page
* og
);
197 void ogg_packet_clear (ogg_packet
* op
);