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-2001 *
9 * by the Xiph.Org Foundation http://www.xiph.org/ *
10 ********************************************************************/
11 module iv
.xyph
.vorbis
/*is aliced*/;
12 pragma(lib
, "vorbis");
14 import core
.stdc
.config
;
15 import iv
.xyph
.ogg
/*: oggpack_buffer, ogg_packet*/;
25 /* The below bitrate declarations are *hints*.
26 Combinations of the three values carry the following implications:
28 all three set to the same value:
29 implies a fixed rate bitstream
31 implies a VBR stream that averages the nominal bitrate. No hard
33 upper and or lower set:
34 implies a VBR bitstream that obeys the bitrate limits. nominal
35 may also be set to give a nominal rate.
37 the coder does not care to speculate.
41 c_long bitrate_nominal
;
43 c_long bitrate_window
;
49 /* vorbis_dsp_state buffers the current vorbis audio
50 analysis/synthesis state. The DSP state belongs to a specific
51 logical bitstream ****************************************************/
52 struct vorbis_dsp_state
{
82 /* vorbis_block is a single block of data to be processed as part of
83 the analysis/synthesis stream; it belongs to a specific logical
84 bitstream, but is independent from other vorbis_blocks belonging to
85 that logical bitstream. *************************************************/
93 /* necessary stream state for linking to the framing abstraction */
94 float** pcm
; /* this is a pointer into local storage */
106 vorbis_dsp_state
* vd
; /* For read-only access of configuration */
108 /* local storage to avoid remallocing; it's up to the mapping to structure it */
115 /* bitmetrics for the frame */
125 /* vorbis_info contains all the setup information specific to the
126 specific compression/decompression mode in progress (eg,
127 psychoacoustic settings, channel setup, options, codebook
128 etc). vorbis_info and substructures are in backends.h.
129 *********************************************************************/
131 /* the comments are not part of vorbis_info so that vorbis_info can be
133 struct vorbis_comment
{
134 /* unlimited user comment fields. libvorbis writes 'libvorbis'
135 whatever vendor is set to in encode */
136 char** user_comments
;
137 int* comment_lengths
;
143 /* libvorbis encodes in two abstraction layers; first we perform DSP
144 and produce a packet (see docs/analysis.txt). The packet is then
145 coded into a framed OggSquish bitstream by the second layer (see
146 docs/framing.txt). Decode is the reverse process; we sync/frame
147 the bitstream and extract individual packets, then decode the
148 packet back into PCM audio.
150 The extra framing/packetizing is used in streaming formats, such as
151 files. Over the net (such as with UDP), the framing and
152 packetization aren't necessary as they're provided by the transport
153 and the streaming layer is not used */
155 extern(C
) nothrow @nogc:
157 /* Vorbis PRIMITIVES: general ***************************************/
158 void vorbis_info_init (vorbis_info
* vi
);
159 void vorbis_info_clear (vorbis_info
* vi
);
160 int vorbis_info_blocksize (vorbis_info
* vi
, int zo
);
161 void vorbis_comment_init (vorbis_comment
* vc
);
162 void vorbis_comment_add (vorbis_comment
* vc
, const(char)* comment
);
163 void vorbis_comment_add_tag (vorbis_comment
* vc
, const(char)* tag
, const(char)* contents
);
164 char* vorbis_comment_query (vorbis_comment
* vc
, const(char)* tag
, int count
);
165 int vorbis_comment_query_count (vorbis_comment
* vc
, const(char)* tag
);
166 void vorbis_comment_clear (vorbis_comment
* vc
);
168 int vorbis_block_init (vorbis_dsp_state
* v
, vorbis_block
* vb
);
169 int vorbis_block_clear (vorbis_block
* vb
);
170 void vorbis_dsp_clear (vorbis_dsp_state
* v
);
171 double vorbis_granule_time (vorbis_dsp_state
* v
, long granulepos
);
173 const(char)* vorbis_version_string ();
175 /* Vorbis PRIMITIVES: analysis/DSP layer ****************************/
177 int vorbis_analysis_init (vorbis_dsp_state
* v
, vorbis_info
* vi
);
178 int vorbis_commentheader_out (vorbis_comment
* vc
, ogg_packet
* op
);
179 int vorbis_analysis_headerout (vorbis_dsp_state
* v
, vorbis_comment
* vc
, ogg_packet
* op
, ogg_packet
* op_comm
, ogg_packet
* op_code
);
180 float** vorbis_analysis_buffer (vorbis_dsp_state
* v
, int vals
);
181 int vorbis_analysis_wrote (vorbis_dsp_state
* v
, int vals
);
182 int vorbis_analysis_blockout (vorbis_dsp_state
* v
, vorbis_block
* vb
);
183 int vorbis_analysis (vorbis_block
* vb
, ogg_packet
* op
);
185 int vorbis_bitrate_addblock (vorbis_block
* vb
);
186 int vorbis_bitrate_flushpacket (vorbis_dsp_state
* vd
, ogg_packet
* op
);
188 /* Vorbis PRIMITIVES: synthesis layer *******************************/
189 int vorbis_synthesis_idheader (ogg_packet
* op
);
190 int vorbis_synthesis_headerin (vorbis_info
* vi
, vorbis_comment
* vc
, ogg_packet
* op
);
192 int vorbis_synthesis_init (vorbis_dsp_state
* v
, vorbis_info
* vi
);
193 int vorbis_synthesis_restart (vorbis_dsp_state
* v
);
194 int vorbis_synthesis (vorbis_block
* vb
, ogg_packet
* op
);
195 int vorbis_synthesis_trackonly (vorbis_block
* vb
, ogg_packet
* op
);
196 int vorbis_synthesis_blockin (vorbis_dsp_state
* v
, vorbis_block
* vb
);
197 int vorbis_synthesis_pcmout (vorbis_dsp_state
* v
, float*** pcm
);
198 int vorbis_synthesis_lapout (vorbis_dsp_state
* v
, float*** pcm
);
199 int vorbis_synthesis_read (vorbis_dsp_state
* v
, int samples
);
200 c_long
vorbis_packet_blocksize (vorbis_info
* vi
, ogg_packet
* op
);
202 int vorbis_synthesis_halfrate (vorbis_info
* v
, int flag
);
203 int vorbis_synthesis_halfrate_p (vorbis_info
* v
);
206 /* Vorbis ERRORS and return codes ***********************************/
216 OV_ENOTVORBIS
= -132,
217 OV_EBADHEADER
= -133,
220 OV_EBADPACKET
= -136,