1 {
2 Translation of the vorbis headers for FreePascal
3 Copyright (C) 2006 by Ivo Steinmann
4 }
6 (********************************************************************
7 * *
8 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
9 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
10 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
11 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
12 * *
13 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
14 * by the XIPHOPHORUS Company http://www.xiph.org/ *
15 * *
16 ********************************************************************)
20 {$MODE OBJFPC}
21 {$MINENUMSIZE 4}
22 {$PACKRECORDS C}
24 interface
26 uses
29 {$IF DEFINED(WINDOWS)}
30 {$IFDEF VORBIS_WINDOZE_STATIC}
31 {$LINKLIB libvorbisfile.a}
32 {$LINKLIB libvorbis.a}
33 {$ELSE}
34 {$DEFINE OGG_DYNAMIC}
37 {$ENDIF}
38 {$ELSEIF DEFINED(UNIX)}
39 {$DEFINE OGG_DYNAMIC}
40 {$LINKLIB libvorbis}
41 {$LINKLIB libvorbisfile}
44 {$ELSE}
45 {$ERROR libvorbis not supported on this platform. Fix it!}
46 {$ENDIF}
48 (***********************************************************************)
49 (* Header : codec.h *)
50 (***********************************************************************)
52 type
61 { The below bitrate declarations are *hints*.
62 Combinations of the three values carry the following implications:
64 all three set to the same value:
65 implies a fixed rate bitstream
66 only nominal set:
67 implies a VBR stream that averages the nominal bitrate. No hard
68 upper/lower limit
69 upper and or lower set:
70 implies a VBR bitstream that obeys the bitrate limits. nominal
71 may also be set to give a nominal rate.
72 none set:
73 the coder does not care to speculate.
74 }
83 { vorbis_dsp_state buffers the current vorbis audio analysis/synthesis state. The DSP state belongs to a specific logical bitstream }
115 { vorbis_block is a single block of data to be processed as part of
116 the analysis/synthesis stream; it belongs to a specific logical
117 bitstream, but is independant from other vorbis_blocks belonging to
118 that logical bitstream. }
128 { necessary stream state for linking to the framing abstraction }
143 { local storage to avoid remallocing; it's up to the mapping to structure it }
150 { bitmetrics for the frame }
159 { vorbis_info contains all the setup information specific to the
160 specific compression/decompression mode in progress (eg,
161 psychoacoustic settings, channel setup, options, codebook
162 etc). vorbis_info and substructures are in backends.h. }
164 { the comments are not part of vorbis_info so that vorbis_info can be static storage }
168 { unlimited user comment fields. libvorbis writes 'libvorbis' whatever vendor is set to in encode }
176 { libvorbis encodes in two abstraction layers; first we perform DSP
177 and produce a packet (see docs/analysis.txt). The packet is then
178 coded into a framed OggSquish bitstream by the second layer (see
179 docs/framing.txt). Decode is the reverse process; we sync/frame
180 the bitstream and extract individual packets, then decode the
181 packet back into PCM audio.
183 The extra framing/packetizing is used in streaming formats, such as
184 files. Over the net (such as with UDP), the framing and
185 packetization aren't necessary as they're provided by the transport
186 and the streaming layer is not used }
188 { Vorbis PRIMITIVES: general }
190 procedure vorbis_info_init(var vi: vorbis_info); cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
191 procedure vorbis_info_clear(var vi: vorbis_info); cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
192 function vorbis_info_blocksize(var vi: vorbis_info; zo: cint): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
193 procedure vorbis_comment_init(var vc: vorbis_comment); cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
194 procedure vorbis_comment_add(var vc: vorbis_comment; comment: pchar); cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
195 procedure vorbis_comment_add_tag(var vc: vorbis_comment; tag: pchar; contents: pchar); cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
196 function vorbis_comment_query(var vc: vorbis_comment; tag: pchar; count: cint): pchar; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
197 function vorbis_comment_query_count(var vc: vorbis_comment; tag: pchar): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
198 procedure vorbis_comment_clear(var vc: vorbis_comment); cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
200 function vorbis_block_init(var v: vorbis_dsp_state; var vb: vorbis_block): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
201 function vorbis_block_clear(var vb: vorbis_block): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
202 procedure vorbis_dsp_clear(var v: vorbis_dsp_state); cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
203 function vorbis_granule_time(var v: vorbis_dsp_state; granulepos: ogg_int64_t): cdouble; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
205 { vorbislib PRIMITIVES: analysis/DSP layer }
207 function vorbis_analysis_init(var v: vorbis_dsp_state; var vi: vorbis_info): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
208 function vorbis_commentheader_out(var vc: vorbis_comment; var op: ogg_packet): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
209 function vorbis_analysis_headerout(var v:vorbis_dsp_state; var vc: vorbis_comment; var op: ogg_packet; var op_comm: ogg_packet; var op_code: ogg_packet): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
210 function vorbis_analysis_buffer(var v: vorbis_dsp_state; vals: cint): ppcfloat; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
211 function vorbis_analysis_wrote(var v: vorbis_dsp_state; vals: cint): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
212 function vorbis_analysis_blockout(var v: vorbis_dsp_state; var vb: vorbis_block): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
213 function vorbis_analysis(var vb: vorbis_block; var op: ogg_packet): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
215 function vorbis_bitrate_addblock(var vb: vorbis_block): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
216 function vorbis_bitrate_flushpacket(var vd: vorbis_dsp_state; var op: ogg_packet): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
218 { vorbislib PRIMITIVES: synthesis layer }
220 function vorbis_synthesis_headerin(var vi: vorbis_info; var vc: vorbis_comment; var op: ogg_packet): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
222 function vorbis_synthesis_init(var v: vorbis_dsp_state; var vi: vorbis_info): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
223 function vorbis_synthesis_restart(var v: vorbis_dsp_state): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
224 function vorbis_synthesis(var vb: vorbis_block; var op: ogg_packet): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
225 function vorbis_synthesis_trackonly(var vb: vorbis_block; var op: ogg_packet): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
226 function vorbis_synthesis_blockin(var v: vorbis_dsp_state; var vb: vorbis_block): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
227 function vorbis_synthesis_pcmout(var v: vorbis_dsp_state; var pcm: ppcfloat): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
228 function vorbis_synthesis_lapout(var v: vorbis_dsp_state; var pcm: ppcfloat): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
229 function vorbis_synthesis_read(var v: vorbis_dsp_state; samples: cint): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
230 function vorbis_packet_blocksize(var vi: vorbis_info; var op: ogg_packet): clong; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
232 function vorbis_synthesis_halfrate(var v: vorbis_info; flag: cint): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
233 function vorbis_synthesis_halfrate_p(var v: vorbis_info): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbislib{$ENDIF};
235 { vorbislib ERRORS and return codes }
236 Const
254 (***********************************************************************)
255 (* Header : vorbisfile.h *)
256 (***********************************************************************)
258 type
260 {* The function prototypes for the callbacks are basically the same as for
262 * the stdio functions fread, fseek, fclose, ftell.
263 * The one difference is that the FILE * arguments have been replaced with
264 * a void * - this is to be used as a pointer to whatever internal data these
265 * functions might need. In the stdio case, it's just a FILE * cast to a void *
266 *
267 * If you use other functions, check the docs for these functions and return
268 * the right values. For seek_func(), you *MUST* return -1 if the stream is
269 * unseekable
270 *}
285 const
292 type
301 { If the FILE handle isn't seekable (eg, a pipe), only the current stream appears }
306 pcmlengths : pogg_int64_t; { overloaded to maintain binary compatability; x2 size, stores both beginning and end values }
310 { Decoding working state local storage }
327 function ov_clear(var vf: OggVorbis_File): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
328 function ov_open(f: pointer; var vf: OggVorbis_File; initial: pointer; ibytes: clong): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
329 function ov_open_callbacks(datasource: pointer; var vf: OggVorbis_File; initial: pointer; ibytes: clong; callbacks: ov_callbacks): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
331 function ov_test(f: pointer; var vf: OggVorbis_File; initial: pointer; ibytes: clong): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
332 function ov_test_callbacks(datasource: pointer; var vf: OggVorbis_File; initial: pointer; ibytes: clong; callbacks: ov_callbacks): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
333 function ov_test_open(var vf: OggVorbis_File): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
335 function ov_bitrate(var vf: OggVorbis_File; i: cint): clong; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
336 function ov_bitrate_instant(var vf: OggVorbis_File): clong; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
337 function ov_streams(var vf: OggVorbis_File): clong; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
338 function ov_seekable(var vf: OggVorbis_File): clong; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
339 function ov_serialnumber(var vf: OggVorbis_File; i: cint): clong; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
341 function ov_raw_total(var vf: OggVorbis_File; i: cint): ogg_int64_t; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
342 function ov_pcm_total(var vf: OggVorbis_File; i: cint): ogg_int64_t; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
343 function ov_time_total(var vf: OggVorbis_File; i: cint): cdouble; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
345 function ov_raw_seek(var vf: OggVorbis_File; pos: ogg_int64_t): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
346 function ov_pcm_seek(var vf: OggVorbis_File; pos: ogg_int64_t): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
347 function ov_pcm_seek_page(var vf: OggVorbis_File; pos: ogg_int64_t): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
348 function ov_time_seek(var vf: OggVorbis_File; pos: cdouble): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
349 function ov_time_seek_page(var vf: OggVorbis_File; pos: cdouble): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
351 function ov_raw_seek_lap(var vf: OggVorbis_File; pos: ogg_int64_t): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
352 function ov_pcm_seek_lap(var vf: OggVorbis_File; pos: ogg_int64_t): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
353 function ov_pcm_seek_page_lap(var vf: OggVorbis_File; pos: ogg_int64_t): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
354 function ov_time_seek_lap(var vf: OggVorbis_File; pos: cdouble): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
355 function ov_time_seek_page_lap(var vf: OggVorbis_File; pos: cdouble): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
357 function ov_raw_tell(var vf: OggVorbis_File): ogg_int64_t; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
358 function ov_pcm_tell(var vf: OggVorbis_File): ogg_int64_t; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
359 function ov_time_tell(var vf: OggVorbis_File): cdouble; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
361 function ov_info(var vf: OggVorbis_File; link: cint): pvorbis_info; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
362 function ov_comment(var vf: OggVorbis_File; link: cint): pvorbis_comment; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
364 function ov_read_float(var vf: OggVorbis_File; var pcm_channels: ppcfloat; samples: cint; bitstream: pcint): clong; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
365 function ov_read(var vf: OggVorbis_File; buffer: pointer; length: cint; bigendianp: cbool; word: cint; sgned: cbool; bitstream: pcint): clong; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
366 function ov_crosslap(var vf1: OggVorbis_File; var vf2: OggVorbis_File): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
368 function ov_halfrate(var vf: OggVorbis_File; flag: cint): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
369 function ov_halfrate_p(var vf: OggVorbis_File): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisfilelib{$ENDIF};
372 {
373 Developer of the A52 helpers for FreePascal
374 Copyright (C) 2006 by Ivo Steinmann
375 }
377 function ov_read_ext(var vf: OggVorbis_File; buffer: pointer; length: cint; bigendianp: cbool; word: cint; sgned: cbool): clong;
379 (***********************************************************************)
380 (* Header : vorbisenc.h *)
381 (***********************************************************************)
383 const
396 type
411 // function vorbis_encode_init(var vi: vorbis_info; channels, rate, max_bitrate, nominal_bitrate, min_bitrate: clong): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisenclib{$ENDIF};
412 // function vorbis_encode_setup_managed(var vi: vorbis_info; channels, rate, max_bitrate, nominal_bitrate, min_bitrate: clong): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisenclib{$ENDIF};
413 // function vorbis_encode_setup_vbr(var vi: vorbis_info; channels, rate: clong; quality: cfloat): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisenclib{$ENDIF};
414 // (* quality level from 0. (lo) to 1. (hi) *)
415 // function vorbis_encode_init_vbr(var vi: vorbis_info; channels, rate: clong; base_quality: cfloat): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisenclib{$ENDIF};
416 // function vorbis_encode_setup_init(var vi: vorbis_info): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisenclib{$ENDIF};
417 // function vorbis_encode_ctl(var vi: vorbis_info; number: cint; arg: pointer): cint; cdecl; external {$IFDEF OGG_DYNAMIC}vorbisenclib{$ENDIF};
419 implementation
421 //k8: sighs. you HAVE to have a 16-byte aligned buffer, otherwise
422 // 32-bit SSE2-enabled builds *WILL* fail.
423 // it means that you *CANNOT* simply use a passed pointer.
424 // therefore this fuckery with internal buffer (because
425 // i am not sure that FPC will align stack variables
426 // correctly).
427 function ov_read_ext(var vf: OggVorbis_File; buffer: pointer; length: cint; bigendianp: cbool; word: cint; sgned: cbool): clong;
428 var
435 begin
436 // check blocksize here!
437 {if length mod 4 <> 0 then
438 Exit(0);}
447 begin
451 //res := ov_read(vf, buffer + ofs, num, bigendianp, word, sgned, nil);
456 Break;
458 //ofs := ofs + res;
459 //num := num - res;