vorbis.pas 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. {
  2. Translation of the vorbis headers for FreePascal
  3. Copyright (C) 2006 by Ivo Steinmann
  4. }
  5. (********************************************************************
  6. * *
  7. * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
  8. * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
  9. * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
  10. * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
  11. * *
  12. * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
  13. * by the XIPHOPHORUS Company http://www.xiph.org/ *
  14. * *
  15. ********************************************************************)
  16. unit vorbis;
  17. {$mode objfpc}
  18. {$MINENUMSIZE 4}
  19. {$PACKRECORDS C}
  20. interface
  21. uses
  22. ctypes, ogg;
  23. {$IFDEF WINDOWS}
  24. {$DEFINE DYNLINK}
  25. {$ENDIF}
  26. {$IFDEF DYNLINK}
  27. const
  28. {$IF Defined(WINDOWS)}
  29. vorbislib = 'vorbis.dll';
  30. vorbisfilelib = 'vorbisfile.dll';
  31. vorbisenclib = 'vorbisenc.dll';
  32. {$ELSEIF Defined(UNIX)}
  33. vorbislib = 'libvorbis.so';
  34. vorbisfilelib = 'libvorbisfile.so';
  35. vorbisenclib = 'libvorbisenc.so';
  36. {$ELSE}
  37. {$MESSAGE ERROR 'DYNLINK not supported'}
  38. {$IFEND}
  39. {$ELSE}
  40. {$LINKLIB vorbis}
  41. {$LINKLIB vorbisfile}
  42. {$LINKLIB vorbisenc}
  43. {$ENDIF}
  44. (***********************************************************************)
  45. (* Header : codec.h *)
  46. (***********************************************************************)
  47. type
  48. csize_t = culong;
  49. ppcfloat = ^pcfloat;
  50. pvorbis_info = ^vorbis_info;
  51. vorbis_info = record
  52. version : cint;
  53. channels : cint;
  54. rate : clong;
  55. { The below bitrate declarations are *hints*.
  56. Combinations of the three values carry the following implications:
  57. all three set to the same value:
  58. implies a fixed rate bitstream
  59. only nominal set:
  60. implies a VBR stream that averages the nominal bitrate. No hard
  61. upper/lower limit
  62. upper and or lower set:
  63. implies a VBR bitstream that obeys the bitrate limits. nominal
  64. may also be set to give a nominal rate.
  65. none set:
  66. the coder does not care to speculate.
  67. }
  68. bitrate_upper : clong;
  69. bitrate_nominal : clong;
  70. bitrate_lower : clong;
  71. bitrate_window : clong;
  72. codec_setup : pointer;
  73. end;
  74. { vorbis_dsp_state buffers the current vorbis audio analysis/synthesis state. The DSP state belongs to a specific logical bitstream }
  75. pvorbis_dsp_state = ^vorbis_dsp_state;
  76. vorbis_dsp_state = record
  77. analysisp : cint;
  78. vi : pvorbis_info;
  79. pcm : ppcfloat;
  80. pcmret : ppcfloat;
  81. pcm_storage : cint;
  82. pcm_current : cint;
  83. pcm_returned : cint;
  84. preextrapolate : cint;
  85. eofflag : cint;
  86. lW : clong;
  87. W : clong;
  88. nW : clong;
  89. centerW : clong;
  90. granulepos : ogg_int64_t;
  91. sequence : ogg_int64_t;
  92. glue_bits : ogg_int64_t;
  93. time_bits : ogg_int64_t;
  94. floor_bits : ogg_int64_t;
  95. res_bits : ogg_int64_t;
  96. backend_state : pointer;
  97. end;
  98. { vorbis_block is a single block of data to be processed as part of
  99. the analysis/synthesis stream; it belongs to a specific logical
  100. bitstream, but is independant from other vorbis_blocks belonging to
  101. that logical bitstream. }
  102. palloc_chain = ^alloc_chain;
  103. alloc_chain = record
  104. ptr : pointer;
  105. next : palloc_chain;
  106. end;
  107. pvorbis_block = ^vorbis_block;
  108. vorbis_block = record
  109. { necessary stream state for linking to the framing abstraction }
  110. pcm : ppcfloat; { this is a pointer into local storage }
  111. opb : oggpack_buffer;
  112. lW : clong;
  113. W : clong;
  114. nW : clong;
  115. pcmend : cint;
  116. mode : cint;
  117. eofflag : cint;
  118. granulepos : ogg_int64_t;
  119. sequence : ogg_int64_t;
  120. vd : pvorbis_dsp_state; { For read-only access of configuration }
  121. { local storage to avoid remallocing; it's up to the mapping to structure it }
  122. localstore : pointer;
  123. localtop : clong;
  124. localalloc : clong;
  125. totaluse : clong;
  126. reap : palloc_chain;
  127. { bitmetrics for the frame }
  128. glue_bits : clong;
  129. time_bits : clong;
  130. floor_bits : clong;
  131. res_bits : clong;
  132. internal : pointer;
  133. end;
  134. { vorbis_info contains all the setup information specific to the
  135. specific compression/decompression mode in progress (eg,
  136. psychoacoustic settings, channel setup, options, codebook
  137. etc). vorbis_info and substructures are in backends.h. }
  138. { the comments are not part of vorbis_info so that vorbis_info can be static storage }
  139. pvorbis_comment = ^vorbis_comment;
  140. vorbis_comment = record
  141. { unlimited user comment fields. libvorbis writes 'libvorbis' whatever vendor is set to in encode }
  142. user_comments : ^pcchar;
  143. comment_lengths : pcint;
  144. comments : cint;
  145. vendor : pcchar;
  146. end;
  147. { libvorbis encodes in two abstraction layers; first we perform DSP
  148. and produce a packet (see docs/analysis.txt). The packet is then
  149. coded into a framed OggSquish bitstream by the second layer (see
  150. docs/framing.txt). Decode is the reverse process; we sync/frame
  151. the bitstream and extract individual packets, then decode the
  152. packet back into PCM audio.
  153. The extra framing/packetizing is used in streaming formats, such as
  154. files. Over the net (such as with UDP), the framing and
  155. packetization aren't necessary as they're provided by the transport
  156. and the streaming layer is not used }
  157. { Vorbis PRIMITIVES: general }
  158. procedure vorbis_info_init(var vi: vorbis_info); cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  159. procedure vorbis_info_clear(var vi: vorbis_info); cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  160. function vorbis_info_blocksize(var vi: vorbis_info; zo: cint): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  161. procedure vorbis_comment_init(var vc: vorbis_comment); cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  162. procedure vorbis_comment_add(var vc: vorbis_comment; comment: pchar); cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  163. procedure vorbis_comment_add_tag(var vc: vorbis_comment; tag: pchar; contents: pchar); cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  164. function vorbis_comment_query(var vc: vorbis_comment; tag: pchar; count: cint): pchar; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  165. function vorbis_comment_query_count(var vc: vorbis_comment; tag: pchar): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  166. procedure vorbis_comment_clear(var vc: vorbis_comment); cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  167. function vorbis_block_init(var v: vorbis_dsp_state; var vb: vorbis_block): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  168. function vorbis_block_clear(var vb: vorbis_block): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  169. procedure vorbis_dsp_clear(var v: vorbis_dsp_state); cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  170. function vorbis_granule_time(var v: vorbis_dsp_state; granulepos: ogg_int64_t): cdouble; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  171. { vorbislib PRIMITIVES: analysis/DSP layer }
  172. function vorbis_analysis_init(var v: vorbis_dsp_state; var vi: vorbis_info): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  173. function vorbis_commentheader_out(var vc: vorbis_comment; var op: ogg_packet): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  174. 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 DYNLINK}vorbislib{$ENDIF};
  175. function vorbis_analysis_buffer(var v: vorbis_dsp_state; vals: cint): ppcfloat; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  176. function vorbis_analysis_wrote(var v: vorbis_dsp_state; vals: cint): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  177. function vorbis_analysis_blockout(var v: vorbis_dsp_state; var vb: vorbis_block): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  178. function vorbis_analysis(var vb: vorbis_block; var op: ogg_packet): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  179. function vorbis_bitrate_addblock(var vb: vorbis_block): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  180. function vorbis_bitrate_flushpacket(var vd: vorbis_dsp_state; var op: ogg_packet): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  181. { vorbislib PRIMITIVES: synthesis layer }
  182. function vorbis_synthesis_headerin(var vi: vorbis_info; var vc: vorbis_comment; var op: ogg_packet): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  183. function vorbis_synthesis_init(var v: vorbis_dsp_state; var vi: vorbis_info): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  184. function vorbis_synthesis_restart(var v: vorbis_dsp_state): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  185. function vorbis_synthesis(var vb: vorbis_block; var op: ogg_packet): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  186. function vorbis_synthesis_trackonly(var vb: vorbis_block; var op: ogg_packet): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  187. function vorbis_synthesis_blockin(var v: vorbis_dsp_state; var vb: vorbis_block): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  188. function vorbis_synthesis_pcmout(var v: vorbis_dsp_state; var pcm: ppcfloat): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  189. function vorbis_synthesis_lapout(var v: vorbis_dsp_state; var pcm: ppcfloat): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  190. function vorbis_synthesis_read(var v: vorbis_dsp_state; samples: cint): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  191. function vorbis_packet_blocksize(var vi: vorbis_info; var op: ogg_packet): clong; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  192. function vorbis_synthesis_halfrate(var v: vorbis_info; flag: cint): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  193. function vorbis_synthesis_halfrate_p(var v: vorbis_info): cint; cdecl; external {$IFDEF DYNLINK}vorbislib{$ENDIF};
  194. { vorbislib ERRORS and return codes }
  195. Const
  196. OV_FALSE = -1;
  197. OV_EOF = -2;
  198. OV_HOLE = -3;
  199. OV_EREAD = -128;
  200. OV_EFAULT = -129;
  201. OV_EIMPL = -130;
  202. OV_EINVAL = -131;
  203. OV_ENOTVORBIS = -132;
  204. OV_EBADHEADER = -133;
  205. OV_EVERSION = -134;
  206. OV_ENOTAUDIO = -135;
  207. OV_EBADPACKET = -136;
  208. OV_EBADLINK = -137;
  209. OV_ENOSEEK = -138;
  210. (***********************************************************************)
  211. (* Header : vorbisfile.h *)
  212. (***********************************************************************)
  213. type
  214. {* The function prototypes for the callbacks are basically the same as for
  215. * the stdio functions fread, fseek, fclose, ftell.
  216. * The one difference is that the FILE * arguments have been replaced with
  217. * a void * - this is to be used as a pointer to whatever internal data these
  218. * functions might need. In the stdio case, it's just a FILE * cast to a void *
  219. *
  220. * If you use other functions, check the docs for these functions and return
  221. * the right values. For seek_func(), you *MUST* return -1 if the stream is
  222. * unseekable
  223. *}
  224. read_func = function(ptr: pointer; size, nmemb: csize_t; datasource: pointer): csize_t; cdecl;
  225. seek_func = function(datasource: pointer; offset: ogg_int64_t; whence: cint): cint; cdecl;
  226. close_func = function(datasource: pointer): cint; cdecl;
  227. tell_func = function(datasource: pointer): clong; cdecl;
  228. pov_callbacks = ^ov_callbacks;
  229. ov_callbacks = record
  230. read : read_func;
  231. seek : seek_func;
  232. close : close_func;
  233. tell : tell_func;
  234. end;
  235. const
  236. NOTOPEN = 0;
  237. PARTOPEN = 1;
  238. OPENED = 2;
  239. STREAMSET = 3;
  240. INITSET = 4;
  241. type
  242. POggVorbis_File = ^OggVorbis_File;
  243. OggVorbis_File = record
  244. datasource : pointer; { pointer to a FILE *, etc. }
  245. seekable : cint;
  246. offset : ogg_int64_t;
  247. end_ : ogg_int64_t;
  248. oy : ogg_sync_state;
  249. { If the FILE handle isn't seekable (eg, a pipe), only the current stream appears }
  250. links : cint;
  251. offsets : pogg_int64_t;
  252. dataoffsets : pogg_int64_t;
  253. serialnos : pclong;
  254. pcmlengths : pogg_int64_t; { overloaded to maintain binary compatability; x2 size, stores both beginning and end values }
  255. vi : pvorbis_info;
  256. vc : pvorbis_comment;
  257. { Decoding working state local storage }
  258. pcm_offset : ogg_int64_t;
  259. ready_state : cint;
  260. current_serialno: clong;
  261. current_link : cint;
  262. bittrack : cdouble;
  263. samptrack : cdouble;
  264. os : ogg_stream_state; { take physical pages, weld into a logical stream of packets }
  265. vd : vorbis_dsp_state; { central working state for the packet->PCM decoder }
  266. vb : vorbis_block; { local working space for packet->PCM decode }
  267. callbacks : ov_callbacks;
  268. end;
  269. function ov_clear(var vf: OggVorbis_File): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  270. function ov_open(f: pointer; var vf: OggVorbis_File; initial: pointer; ibytes: clong): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  271. function ov_open_callbacks(datasource: pointer; var vf: OggVorbis_File; initial: pointer; ibytes: clong; callbacks: ov_callbacks): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  272. function ov_test(f: pointer; var vf: OggVorbis_File; initial: pointer; ibytes: clong): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  273. function ov_test_callbacks(datasource: pointer; var vf: OggVorbis_File; initial: pointer; ibytes: clong; callbacks: ov_callbacks): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  274. function ov_test_open(var vf: OggVorbis_File): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  275. function ov_bitrate(var vf: OggVorbis_File; i: cint): clong; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  276. function ov_bitrate_instant(var vf: OggVorbis_File): clong; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  277. function ov_streams(var vf: OggVorbis_File): clong; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  278. function ov_seekable(var vf: OggVorbis_File): clong; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  279. function ov_serialnumber(var vf: OggVorbis_File; i: cint): clong; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  280. function ov_raw_total(var vf: OggVorbis_File; i: cint): ogg_int64_t; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  281. function ov_pcm_total(var vf: OggVorbis_File; i: cint): ogg_int64_t; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  282. function ov_time_total(var vf: OggVorbis_File; i: cint): cdouble; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  283. function ov_raw_seek(var vf: OggVorbis_File; pos: ogg_int64_t): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  284. function ov_pcm_seek(var vf: OggVorbis_File; pos: ogg_int64_t): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  285. function ov_pcm_seek_page(var vf: OggVorbis_File; pos: ogg_int64_t): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  286. function ov_time_seek(var vf: OggVorbis_File; pos: cdouble): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  287. function ov_time_seek_page(var vf: OggVorbis_File; pos: cdouble): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  288. function ov_raw_seek_lap(var vf: OggVorbis_File; pos: ogg_int64_t): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  289. function ov_pcm_seek_lap(var vf: OggVorbis_File; pos: ogg_int64_t): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  290. function ov_pcm_seek_page_lap(var vf: OggVorbis_File; pos: ogg_int64_t): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  291. function ov_time_seek_lap(var vf: OggVorbis_File; pos: cdouble): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  292. function ov_time_seek_page_lap(var vf: OggVorbis_File; pos: cdouble): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  293. function ov_raw_tell(var vf: OggVorbis_File): ogg_int64_t; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  294. function ov_pcm_tell(var vf: OggVorbis_File): ogg_int64_t; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  295. function ov_time_tell(var vf: OggVorbis_File): cdouble; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  296. function ov_info(var vf: OggVorbis_File; link: cint): pvorbis_info; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  297. function ov_comment(var vf: OggVorbis_File; link: cint): pvorbis_comment; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  298. function ov_read_float(var vf: OggVorbis_File; var pcm_channels: ppcfloat; samples: cint; bitstream: pcint): clong; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  299. function ov_read(var vf: OggVorbis_File; buffer: pointer; length: cint; bigendianp: cbool; word: cint; sgned: cbool; bitstream: pcint): clong; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  300. function ov_crosslap(var vf1: OggVorbis_File; var vf2: OggVorbis_File): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  301. function ov_halfrate(var vf: OggVorbis_File; flag: cint): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  302. function ov_halfrate_p(var vf: OggVorbis_File): cint; cdecl; external {$IFDEF DYNLINK}vorbisfilelib{$ENDIF};
  303. {
  304. Developer of the A52 helpers for FreePascal
  305. Copyright (C) 2006 by Ivo Steinmann
  306. }
  307. function ov_read_ext(var vf: OggVorbis_File; buffer: pointer; length: cint; bigendianp: cbool; word: cint; sgned: cbool): clong;
  308. (***********************************************************************)
  309. (* Header : vorbisenc.h *)
  310. (***********************************************************************)
  311. const
  312. OV_ECTL_RATEMANAGE_GET = $10;
  313. OV_ECTL_RATEMANAGE_SET = $11;
  314. OV_ECTL_RATEMANAGE_AVG = $12;
  315. OV_ECTL_RATEMANAGE_HARD = $13;
  316. OV_ECTL_LOWPASS_GET = $20;
  317. OV_ECTL_LOWPASS_SET = $21;
  318. OV_ECTL_IBLOCK_GET = $30;
  319. OV_ECTL_IBLOCK_SET = $31;
  320. type
  321. povectl_ratemanage_arg = ^ovectl_ratemanage_arg;
  322. ovectl_ratemanage_arg = record
  323. management_active : cint;
  324. bitrate_hard_min : clong;
  325. bitrate_hard_max : clong;
  326. bitrate_hard_window : cdouble;
  327. bitrate_av_lo : clong;
  328. bitrate_av_hi : clong;
  329. bitrate_av_window : cdouble;
  330. bitrate_av_window_center : cdouble;
  331. end;
  332. function vorbis_encode_init(var vi: vorbis_info; channels, rate, max_bitrate, nominal_bitrate, min_bitrate: clong): cint; cdecl; external {$IFDEF DYNLINK}vorbisenclib{$ENDIF};
  333. function vorbis_encode_setup_managed(var vi: vorbis_info; channels, rate, max_bitrate, nominal_bitrate, min_bitrate: clong): cint; cdecl; external {$IFDEF DYNLINK}vorbisenclib{$ENDIF};
  334. function vorbis_encode_setup_vbr(var vi: vorbis_info; channels, rate: clong; quality: cfloat): cint; cdecl; external {$IFDEF DYNLINK}vorbisenclib{$ENDIF};
  335. (* quality level from 0. (lo) to 1. (hi) *)
  336. function vorbis_encode_init_vbr(var vi: vorbis_info; channels, rate: clong; base_quality: cfloat): cint; cdecl; external {$IFDEF DYNLINK}vorbisenclib{$ENDIF};
  337. function vorbis_encode_setup_init(var vi: vorbis_info): cint; cdecl; external {$IFDEF DYNLINK}vorbisenclib{$ENDIF};
  338. function vorbis_encode_ctl(var vi: vorbis_info; number: cint; arg: pointer): cint; cdecl; external {$IFDEF DYNLINK}vorbisenclib{$ENDIF};
  339. implementation
  340. function ov_read_ext(var vf: OggVorbis_File; buffer: pointer; length: cint; bigendianp: cbool; word: cint; sgned: cbool): clong;
  341. var
  342. ofs: cint;
  343. Num: cint;
  344. Res: cint;
  345. begin
  346. // check blocksize here!
  347. {if length mod 4 <> 0 then
  348. Exit(0);}
  349. ofs := 0;
  350. num := length;
  351. while num > 0 do
  352. begin
  353. res := ov_read(vf, pointer(ptrint(buffer) + ofs), num, bigendianp, word, sgned, nil);
  354. if res < 0 then
  355. Exit(res);
  356. if res = 0 then
  357. Break;
  358. ofs := ofs + res;
  359. num := num - res;
  360. end;
  361. Result := ofs;
  362. end;
  363. end.