lame.h 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323
  1. /*
  2. * Interface to MP3 LAME encoding engine
  3. *
  4. * Copyright (c) 1999 Mark Taylor
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Library General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Library General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Library General Public
  17. * License along with this library; if not, write to the
  18. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. */
  21. /* $Id: lame.h,v 1.189.2.1 2012/01/08 23:49:58 robert Exp $ */
  22. #ifndef LAME_LAME_H
  23. #define LAME_LAME_H
  24. /* for size_t typedef */
  25. #include <stddef.h>
  26. /* for va_list typedef */
  27. #include <stdarg.h>
  28. /* for FILE typedef, TODO: remove when removing lame_mp3_tags_fid */
  29. #include <stdio.h>
  30. #if defined(__cplusplus)
  31. extern "C" {
  32. #endif
  33. typedef void (*lame_report_function)(const char *format, va_list ap);
  34. #if defined(WIN32) || defined(_WIN32)
  35. #undef CDECL
  36. #define CDECL __cdecl
  37. #else
  38. #define CDECL
  39. #endif
  40. #define DEPRECATED_OR_OBSOLETE_CODE_REMOVED 1
  41. typedef enum vbr_mode_e {
  42. vbr_off=0,
  43. vbr_mt, /* obsolete, same as vbr_mtrh */
  44. vbr_rh,
  45. vbr_abr,
  46. vbr_mtrh,
  47. vbr_max_indicator, /* Don't use this! It's used for sanity checks. */
  48. vbr_default=vbr_mtrh /* change this to change the default VBR mode of LAME */
  49. } vbr_mode;
  50. /* MPEG modes */
  51. typedef enum MPEG_mode_e {
  52. STEREO = 0,
  53. JOINT_STEREO,
  54. DUAL_CHANNEL, /* LAME doesn't supports this! */
  55. MONO,
  56. NOT_SET,
  57. MAX_INDICATOR /* Don't use this! It's used for sanity checks. */
  58. } MPEG_mode;
  59. /* Padding types */
  60. typedef enum Padding_type_e {
  61. PAD_NO = 0,
  62. PAD_ALL,
  63. PAD_ADJUST,
  64. PAD_MAX_INDICATOR /* Don't use this! It's used for sanity checks. */
  65. } Padding_type;
  66. /*presets*/
  67. typedef enum preset_mode_e {
  68. /*values from 8 to 320 should be reserved for abr bitrates*/
  69. /*for abr I'd suggest to directly use the targeted bitrate as a value*/
  70. ABR_8 = 8,
  71. ABR_320 = 320,
  72. V9 = 410, /*Vx to match Lame and VBR_xx to match FhG*/
  73. VBR_10 = 410,
  74. V8 = 420,
  75. VBR_20 = 420,
  76. V7 = 430,
  77. VBR_30 = 430,
  78. V6 = 440,
  79. VBR_40 = 440,
  80. V5 = 450,
  81. VBR_50 = 450,
  82. V4 = 460,
  83. VBR_60 = 460,
  84. V3 = 470,
  85. VBR_70 = 470,
  86. V2 = 480,
  87. VBR_80 = 480,
  88. V1 = 490,
  89. VBR_90 = 490,
  90. V0 = 500,
  91. VBR_100 = 500,
  92. /*still there for compatibility*/
  93. R3MIX = 1000,
  94. STANDARD = 1001,
  95. EXTREME = 1002,
  96. INSANE = 1003,
  97. STANDARD_FAST = 1004,
  98. EXTREME_FAST = 1005,
  99. MEDIUM = 1006,
  100. MEDIUM_FAST = 1007
  101. } preset_mode;
  102. /*asm optimizations*/
  103. typedef enum asm_optimizations_e {
  104. MMX = 1,
  105. AMD_3DNOW = 2,
  106. SSE = 3
  107. } asm_optimizations;
  108. /* psychoacoustic model */
  109. typedef enum Psy_model_e {
  110. PSY_GPSYCHO = 1,
  111. PSY_NSPSYTUNE = 2
  112. } Psy_model;
  113. /* buffer considerations */
  114. typedef enum buffer_constraint_e {
  115. MDB_DEFAULT=0,
  116. MDB_STRICT_ISO=1,
  117. MDB_MAXIMUM=2
  118. } buffer_constraint;
  119. struct lame_global_struct;
  120. typedef struct lame_global_struct lame_global_flags;
  121. typedef lame_global_flags *lame_t;
  122. /***********************************************************************
  123. *
  124. * The LAME API
  125. * These functions should be called, in this order, for each
  126. * MP3 file to be encoded. See the file "API" for more documentation
  127. *
  128. ***********************************************************************/
  129. /*
  130. * REQUIRED:
  131. * initialize the encoder. sets default for all encoder parameters,
  132. * returns NULL if some malloc()'s failed
  133. * otherwise returns pointer to structure needed for all future
  134. * API calls.
  135. */
  136. lame_global_flags * CDECL lame_init(void);
  137. #if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
  138. #else
  139. /* obsolete version */
  140. int CDECL lame_init_old(lame_global_flags *);
  141. #endif
  142. /*
  143. * OPTIONAL:
  144. * set as needed to override defaults
  145. */
  146. /********************************************************************
  147. * input stream description
  148. ***********************************************************************/
  149. /* number of samples. default = 2^32-1 */
  150. int CDECL lame_set_num_samples(lame_global_flags *, unsigned long);
  151. unsigned long CDECL lame_get_num_samples(const lame_global_flags *);
  152. /* input sample rate in Hz. default = 44100hz */
  153. int CDECL lame_set_in_samplerate(lame_global_flags *, int);
  154. int CDECL lame_get_in_samplerate(const lame_global_flags *);
  155. /* number of channels in input stream. default=2 */
  156. int CDECL lame_set_num_channels(lame_global_flags *, int);
  157. int CDECL lame_get_num_channels(const lame_global_flags *);
  158. /*
  159. scale the input by this amount before encoding. default=1
  160. (not used by decoding routines)
  161. */
  162. int CDECL lame_set_scale(lame_global_flags *, float);
  163. float CDECL lame_get_scale(const lame_global_flags *);
  164. /*
  165. scale the channel 0 (left) input by this amount before encoding. default=1
  166. (not used by decoding routines)
  167. */
  168. int CDECL lame_set_scale_left(lame_global_flags *, float);
  169. float CDECL lame_get_scale_left(const lame_global_flags *);
  170. /*
  171. scale the channel 1 (right) input by this amount before encoding. default=1
  172. (not used by decoding routines)
  173. */
  174. int CDECL lame_set_scale_right(lame_global_flags *, float);
  175. float CDECL lame_get_scale_right(const lame_global_flags *);
  176. /*
  177. output sample rate in Hz. default = 0, which means LAME picks best value
  178. based on the amount of compression. MPEG only allows:
  179. MPEG1 32, 44.1, 48khz
  180. MPEG2 16, 22.05, 24
  181. MPEG2.5 8, 11.025, 12
  182. (not used by decoding routines)
  183. */
  184. int CDECL lame_set_out_samplerate(lame_global_flags *, int);
  185. int CDECL lame_get_out_samplerate(const lame_global_flags *);
  186. /********************************************************************
  187. * general control parameters
  188. ***********************************************************************/
  189. /* 1=cause LAME to collect data for an MP3 frame analyzer. default=0 */
  190. int CDECL lame_set_analysis(lame_global_flags *, int);
  191. int CDECL lame_get_analysis(const lame_global_flags *);
  192. /*
  193. 1 = write a Xing VBR header frame.
  194. default = 1
  195. this variable must have been added by a Hungarian notation Windows programmer :-)
  196. */
  197. int CDECL lame_set_bWriteVbrTag(lame_global_flags *, int);
  198. int CDECL lame_get_bWriteVbrTag(const lame_global_flags *);
  199. /* 1=decode only. use lame/mpglib to convert mp3/ogg to wav. default=0 */
  200. int CDECL lame_set_decode_only(lame_global_flags *, int);
  201. int CDECL lame_get_decode_only(const lame_global_flags *);
  202. #if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
  203. #else
  204. /* 1=encode a Vorbis .ogg file. default=0 */
  205. /* DEPRECATED */
  206. int CDECL lame_set_ogg(lame_global_flags *, int);
  207. int CDECL lame_get_ogg(const lame_global_flags *);
  208. #endif
  209. /*
  210. internal algorithm selection. True quality is determined by the bitrate
  211. but this variable will effect quality by selecting expensive or cheap algorithms.
  212. quality=0..9. 0=best (very slow). 9=worst.
  213. recommended: 2 near-best quality, not too slow
  214. 5 good quality, fast
  215. 7 ok quality, really fast
  216. */
  217. int CDECL lame_set_quality(lame_global_flags *, int);
  218. int CDECL lame_get_quality(const lame_global_flags *);
  219. /*
  220. mode = 0,1,2,3 = stereo, jstereo, dual channel (not supported), mono
  221. default: lame picks based on compression ration and input channels
  222. */
  223. int CDECL lame_set_mode(lame_global_flags *, MPEG_mode);
  224. MPEG_mode CDECL lame_get_mode(const lame_global_flags *);
  225. #if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
  226. #else
  227. /*
  228. mode_automs. Use a M/S mode with a switching threshold based on
  229. compression ratio
  230. DEPRECATED
  231. */
  232. int CDECL lame_set_mode_automs(lame_global_flags *, int);
  233. int CDECL lame_get_mode_automs(const lame_global_flags *);
  234. #endif
  235. /*
  236. force_ms. Force M/S for all frames. For testing only.
  237. default = 0 (disabled)
  238. */
  239. int CDECL lame_set_force_ms(lame_global_flags *, int);
  240. int CDECL lame_get_force_ms(const lame_global_flags *);
  241. /* use free_format? default = 0 (disabled) */
  242. int CDECL lame_set_free_format(lame_global_flags *, int);
  243. int CDECL lame_get_free_format(const lame_global_flags *);
  244. /* perform ReplayGain analysis? default = 0 (disabled) */
  245. int CDECL lame_set_findReplayGain(lame_global_flags *, int);
  246. int CDECL lame_get_findReplayGain(const lame_global_flags *);
  247. /* decode on the fly. Search for the peak sample. If the ReplayGain
  248. * analysis is enabled then perform the analysis on the decoded data
  249. * stream. default = 0 (disabled)
  250. * NOTE: if this option is set the build-in decoder should not be used */
  251. int CDECL lame_set_decode_on_the_fly(lame_global_flags *, int);
  252. int CDECL lame_get_decode_on_the_fly(const lame_global_flags *);
  253. #if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
  254. #else
  255. /* DEPRECATED: now does the same as lame_set_findReplayGain()
  256. default = 0 (disabled) */
  257. int CDECL lame_set_ReplayGain_input(lame_global_flags *, int);
  258. int CDECL lame_get_ReplayGain_input(const lame_global_flags *);
  259. /* DEPRECATED: now does the same as
  260. lame_set_decode_on_the_fly() && lame_set_findReplayGain()
  261. default = 0 (disabled) */
  262. int CDECL lame_set_ReplayGain_decode(lame_global_flags *, int);
  263. int CDECL lame_get_ReplayGain_decode(const lame_global_flags *);
  264. /* DEPRECATED: now does the same as lame_set_decode_on_the_fly()
  265. default = 0 (disabled) */
  266. int CDECL lame_set_findPeakSample(lame_global_flags *, int);
  267. int CDECL lame_get_findPeakSample(const lame_global_flags *);
  268. #endif
  269. /* counters for gapless encoding */
  270. int CDECL lame_set_nogap_total(lame_global_flags*, int);
  271. int CDECL lame_get_nogap_total(const lame_global_flags*);
  272. int CDECL lame_set_nogap_currentindex(lame_global_flags* , int);
  273. int CDECL lame_get_nogap_currentindex(const lame_global_flags*);
  274. /*
  275. * OPTIONAL:
  276. * Set printf like error/debug/message reporting functions.
  277. * The second argument has to be a pointer to a function which looks like
  278. * void my_debugf(const char *format, va_list ap)
  279. * {
  280. * (void) vfprintf(stdout, format, ap);
  281. * }
  282. * If you use NULL as the value of the pointer in the set function, the
  283. * lame buildin function will be used (prints to stderr).
  284. * To quiet any output you have to replace the body of the example function
  285. * with just "return;" and use it in the set function.
  286. */
  287. int CDECL lame_set_errorf(lame_global_flags *, lame_report_function);
  288. int CDECL lame_set_debugf(lame_global_flags *, lame_report_function);
  289. int CDECL lame_set_msgf (lame_global_flags *, lame_report_function);
  290. /* set one of brate compression ratio. default is compression ratio of 11. */
  291. int CDECL lame_set_brate(lame_global_flags *, int);
  292. int CDECL lame_get_brate(const lame_global_flags *);
  293. int CDECL lame_set_compression_ratio(lame_global_flags *, float);
  294. float CDECL lame_get_compression_ratio(const lame_global_flags *);
  295. int CDECL lame_set_preset( lame_global_flags* gfp, int );
  296. int CDECL lame_set_asm_optimizations( lame_global_flags* gfp, int, int );
  297. /********************************************************************
  298. * frame params
  299. ***********************************************************************/
  300. /* mark as copyright. default=0 */
  301. int CDECL lame_set_copyright(lame_global_flags *, int);
  302. int CDECL lame_get_copyright(const lame_global_flags *);
  303. /* mark as original. default=1 */
  304. int CDECL lame_set_original(lame_global_flags *, int);
  305. int CDECL lame_get_original(const lame_global_flags *);
  306. /* error_protection. Use 2 bytes from each frame for CRC checksum. default=0 */
  307. int CDECL lame_set_error_protection(lame_global_flags *, int);
  308. int CDECL lame_get_error_protection(const lame_global_flags *);
  309. #if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
  310. #else
  311. /* padding_type. 0=pad no frames 1=pad all frames 2=adjust padding(default) */
  312. int CDECL lame_set_padding_type(lame_global_flags *, Padding_type);
  313. Padding_type CDECL lame_get_padding_type(const lame_global_flags *);
  314. #endif
  315. /* MP3 'private extension' bit Meaningless. default=0 */
  316. int CDECL lame_set_extension(lame_global_flags *, int);
  317. int CDECL lame_get_extension(const lame_global_flags *);
  318. /* enforce strict ISO compliance. default=0 */
  319. int CDECL lame_set_strict_ISO(lame_global_flags *, int);
  320. int CDECL lame_get_strict_ISO(const lame_global_flags *);
  321. /********************************************************************
  322. * quantization/noise shaping
  323. ***********************************************************************/
  324. /* disable the bit reservoir. For testing only. default=0 */
  325. int CDECL lame_set_disable_reservoir(lame_global_flags *, int);
  326. int CDECL lame_get_disable_reservoir(const lame_global_flags *);
  327. /* select a different "best quantization" function. default=0 */
  328. int CDECL lame_set_quant_comp(lame_global_flags *, int);
  329. int CDECL lame_get_quant_comp(const lame_global_flags *);
  330. int CDECL lame_set_quant_comp_short(lame_global_flags *, int);
  331. int CDECL lame_get_quant_comp_short(const lame_global_flags *);
  332. int CDECL lame_set_experimentalX(lame_global_flags *, int); /* compatibility*/
  333. int CDECL lame_get_experimentalX(const lame_global_flags *);
  334. /* another experimental option. for testing only */
  335. int CDECL lame_set_experimentalY(lame_global_flags *, int);
  336. int CDECL lame_get_experimentalY(const lame_global_flags *);
  337. /* another experimental option. for testing only */
  338. int CDECL lame_set_experimentalZ(lame_global_flags *, int);
  339. int CDECL lame_get_experimentalZ(const lame_global_flags *);
  340. /* Naoki's psycho acoustic model. default=0 */
  341. int CDECL lame_set_exp_nspsytune(lame_global_flags *, int);
  342. int CDECL lame_get_exp_nspsytune(const lame_global_flags *);
  343. void CDECL lame_set_msfix(lame_global_flags *, double);
  344. float CDECL lame_get_msfix(const lame_global_flags *);
  345. /********************************************************************
  346. * VBR control
  347. ***********************************************************************/
  348. /* Types of VBR. default = vbr_off = CBR */
  349. int CDECL lame_set_VBR(lame_global_flags *, vbr_mode);
  350. vbr_mode CDECL lame_get_VBR(const lame_global_flags *);
  351. /* VBR quality level. 0=highest 9=lowest */
  352. int CDECL lame_set_VBR_q(lame_global_flags *, int);
  353. int CDECL lame_get_VBR_q(const lame_global_flags *);
  354. /* VBR quality level. 0=highest 9=lowest, Range [0,...,10[ */
  355. int CDECL lame_set_VBR_quality(lame_global_flags *, float);
  356. float CDECL lame_get_VBR_quality(const lame_global_flags *);
  357. /* Ignored except for VBR=vbr_abr (ABR mode) */
  358. int CDECL lame_set_VBR_mean_bitrate_kbps(lame_global_flags *, int);
  359. int CDECL lame_get_VBR_mean_bitrate_kbps(const lame_global_flags *);
  360. int CDECL lame_set_VBR_min_bitrate_kbps(lame_global_flags *, int);
  361. int CDECL lame_get_VBR_min_bitrate_kbps(const lame_global_flags *);
  362. int CDECL lame_set_VBR_max_bitrate_kbps(lame_global_flags *, int);
  363. int CDECL lame_get_VBR_max_bitrate_kbps(const lame_global_flags *);
  364. /*
  365. 1=strictly enforce VBR_min_bitrate. Normally it will be violated for
  366. analog silence
  367. */
  368. int CDECL lame_set_VBR_hard_min(lame_global_flags *, int);
  369. int CDECL lame_get_VBR_hard_min(const lame_global_flags *);
  370. /* for preset */
  371. #if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
  372. #else
  373. int CDECL lame_set_preset_expopts(lame_global_flags *, int);
  374. #endif
  375. /********************************************************************
  376. * Filtering control
  377. ***********************************************************************/
  378. /* freq in Hz to apply lowpass. Default = 0 = lame chooses. -1 = disabled */
  379. int CDECL lame_set_lowpassfreq(lame_global_flags *, int);
  380. int CDECL lame_get_lowpassfreq(const lame_global_flags *);
  381. /* width of transition band, in Hz. Default = one polyphase filter band */
  382. int CDECL lame_set_lowpasswidth(lame_global_flags *, int);
  383. int CDECL lame_get_lowpasswidth(const lame_global_flags *);
  384. /* freq in Hz to apply highpass. Default = 0 = lame chooses. -1 = disabled */
  385. int CDECL lame_set_highpassfreq(lame_global_flags *, int);
  386. int CDECL lame_get_highpassfreq(const lame_global_flags *);
  387. /* width of transition band, in Hz. Default = one polyphase filter band */
  388. int CDECL lame_set_highpasswidth(lame_global_flags *, int);
  389. int CDECL lame_get_highpasswidth(const lame_global_flags *);
  390. /********************************************************************
  391. * psycho acoustics and other arguments which you should not change
  392. * unless you know what you are doing
  393. ***********************************************************************/
  394. /* only use ATH for masking */
  395. int CDECL lame_set_ATHonly(lame_global_flags *, int);
  396. int CDECL lame_get_ATHonly(const lame_global_flags *);
  397. /* only use ATH for short blocks */
  398. int CDECL lame_set_ATHshort(lame_global_flags *, int);
  399. int CDECL lame_get_ATHshort(const lame_global_flags *);
  400. /* disable ATH */
  401. int CDECL lame_set_noATH(lame_global_flags *, int);
  402. int CDECL lame_get_noATH(const lame_global_flags *);
  403. /* select ATH formula */
  404. int CDECL lame_set_ATHtype(lame_global_flags *, int);
  405. int CDECL lame_get_ATHtype(const lame_global_flags *);
  406. /* lower ATH by this many db */
  407. int CDECL lame_set_ATHlower(lame_global_flags *, float);
  408. float CDECL lame_get_ATHlower(const lame_global_flags *);
  409. /* select ATH adaptive adjustment type */
  410. int CDECL lame_set_athaa_type( lame_global_flags *, int);
  411. int CDECL lame_get_athaa_type( const lame_global_flags *);
  412. #if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
  413. #else
  414. /* select the loudness approximation used by the ATH adaptive auto-leveling */
  415. int CDECL lame_set_athaa_loudapprox( lame_global_flags *, int);
  416. int CDECL lame_get_athaa_loudapprox( const lame_global_flags *);
  417. #endif
  418. /* adjust (in dB) the point below which adaptive ATH level adjustment occurs */
  419. int CDECL lame_set_athaa_sensitivity( lame_global_flags *, float);
  420. float CDECL lame_get_athaa_sensitivity( const lame_global_flags* );
  421. #if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
  422. #else
  423. /* OBSOLETE: predictability limit (ISO tonality formula) */
  424. int CDECL lame_set_cwlimit(lame_global_flags *, int);
  425. int CDECL lame_get_cwlimit(const lame_global_flags *);
  426. #endif
  427. /*
  428. allow blocktypes to differ between channels?
  429. default: 0 for jstereo, 1 for stereo
  430. */
  431. int CDECL lame_set_allow_diff_short(lame_global_flags *, int);
  432. int CDECL lame_get_allow_diff_short(const lame_global_flags *);
  433. /* use temporal masking effect (default = 1) */
  434. int CDECL lame_set_useTemporal(lame_global_flags *, int);
  435. int CDECL lame_get_useTemporal(const lame_global_flags *);
  436. /* use temporal masking effect (default = 1) */
  437. int CDECL lame_set_interChRatio(lame_global_flags *, float);
  438. float CDECL lame_get_interChRatio(const lame_global_flags *);
  439. /* disable short blocks */
  440. int CDECL lame_set_no_short_blocks(lame_global_flags *, int);
  441. int CDECL lame_get_no_short_blocks(const lame_global_flags *);
  442. /* force short blocks */
  443. int CDECL lame_set_force_short_blocks(lame_global_flags *, int);
  444. int CDECL lame_get_force_short_blocks(const lame_global_flags *);
  445. /* Input PCM is emphased PCM (for instance from one of the rarely
  446. emphased CDs), it is STRONGLY not recommended to use this, because
  447. psycho does not take it into account, and last but not least many decoders
  448. ignore these bits */
  449. int CDECL lame_set_emphasis(lame_global_flags *, int);
  450. int CDECL lame_get_emphasis(const lame_global_flags *);
  451. /************************************************************************/
  452. /* internal variables, cannot be set... */
  453. /* provided because they may be of use to calling application */
  454. /************************************************************************/
  455. /* version 0=MPEG-2 1=MPEG-1 (2=MPEG-2.5) */
  456. int CDECL lame_get_version(const lame_global_flags *);
  457. /* encoder delay */
  458. int CDECL lame_get_encoder_delay(const lame_global_flags *);
  459. /*
  460. padding appended to the input to make sure decoder can fully decode
  461. all input. Note that this value can only be calculated during the
  462. call to lame_encoder_flush(). Before lame_encoder_flush() has
  463. been called, the value of encoder_padding = 0.
  464. */
  465. int CDECL lame_get_encoder_padding(const lame_global_flags *);
  466. /* size of MPEG frame */
  467. int CDECL lame_get_framesize(const lame_global_flags *);
  468. /* number of PCM samples buffered, but not yet encoded to mp3 data. */
  469. int CDECL lame_get_mf_samples_to_encode( const lame_global_flags* gfp );
  470. /*
  471. size (bytes) of mp3 data buffered, but not yet encoded.
  472. this is the number of bytes which would be output by a call to
  473. lame_encode_flush_nogap. NOTE: lame_encode_flush() will return
  474. more bytes than this because it will encode the reamining buffered
  475. PCM samples before flushing the mp3 buffers.
  476. */
  477. int CDECL lame_get_size_mp3buffer( const lame_global_flags* gfp );
  478. /* number of frames encoded so far */
  479. int CDECL lame_get_frameNum(const lame_global_flags *);
  480. /*
  481. lame's estimate of the total number of frames to be encoded
  482. only valid if calling program set num_samples
  483. */
  484. int CDECL lame_get_totalframes(const lame_global_flags *);
  485. /* RadioGain value. Multiplied by 10 and rounded to the nearest. */
  486. int CDECL lame_get_RadioGain(const lame_global_flags *);
  487. /* AudiophileGain value. Multipled by 10 and rounded to the nearest. */
  488. int CDECL lame_get_AudiophileGain(const lame_global_flags *);
  489. /* the peak sample */
  490. float CDECL lame_get_PeakSample(const lame_global_flags *);
  491. /* Gain change required for preventing clipping. The value is correct only if
  492. peak sample searching was enabled. If negative then the waveform
  493. already does not clip. The value is multiplied by 10 and rounded up. */
  494. int CDECL lame_get_noclipGainChange(const lame_global_flags *);
  495. /* user-specified scale factor required for preventing clipping. Value is
  496. correct only if peak sample searching was enabled and no user-specified
  497. scaling was performed. If negative then either the waveform already does
  498. not clip or the value cannot be determined */
  499. float CDECL lame_get_noclipScale(const lame_global_flags *);
  500. /*
  501. * REQUIRED:
  502. * sets more internal configuration based on data provided above.
  503. * returns -1 if something failed.
  504. */
  505. int CDECL lame_init_params(lame_global_flags *);
  506. /*
  507. * OPTIONAL:
  508. * get the version number, in a string. of the form:
  509. * "3.63 (beta)" or just "3.63".
  510. */
  511. const char* CDECL get_lame_version ( void );
  512. const char* CDECL get_lame_short_version ( void );
  513. const char* CDECL get_lame_very_short_version ( void );
  514. const char* CDECL get_psy_version ( void );
  515. const char* CDECL get_lame_url ( void );
  516. const char* CDECL get_lame_os_bitness ( void );
  517. /*
  518. * OPTIONAL:
  519. * get the version numbers in numerical form.
  520. */
  521. typedef struct {
  522. /* generic LAME version */
  523. int major;
  524. int minor;
  525. int alpha; /* 0 if not an alpha version */
  526. int beta; /* 0 if not a beta version */
  527. /* version of the psy model */
  528. int psy_major;
  529. int psy_minor;
  530. int psy_alpha; /* 0 if not an alpha version */
  531. int psy_beta; /* 0 if not a beta version */
  532. /* compile time features */
  533. const char *features; /* Don't make assumptions about the contents! */
  534. } lame_version_t;
  535. void CDECL get_lame_version_numerical(lame_version_t *);
  536. /*
  537. * OPTIONAL:
  538. * print internal lame configuration to message handler
  539. */
  540. void CDECL lame_print_config(const lame_global_flags* gfp);
  541. void CDECL lame_print_internals( const lame_global_flags *gfp);
  542. /*
  543. * input pcm data, output (maybe) mp3 frames.
  544. * This routine handles all buffering, resampling and filtering for you.
  545. *
  546. * return code number of bytes output in mp3buf. Can be 0
  547. * -1: mp3buf was too small
  548. * -2: malloc() problem
  549. * -3: lame_init_params() not called
  550. * -4: psycho acoustic problems
  551. *
  552. * The required mp3buf_size can be computed from num_samples,
  553. * samplerate and encoding rate, but here is a worst case estimate:
  554. *
  555. * mp3buf_size in bytes = 1.25*num_samples + 7200
  556. *
  557. * I think a tighter bound could be: (mt, March 2000)
  558. * MPEG1:
  559. * num_samples*(bitrate/8)/samplerate + 4*1152*(bitrate/8)/samplerate + 512
  560. * MPEG2:
  561. * num_samples*(bitrate/8)/samplerate + 4*576*(bitrate/8)/samplerate + 256
  562. *
  563. * but test first if you use that!
  564. *
  565. * set mp3buf_size = 0 and LAME will not check if mp3buf_size is
  566. * large enough.
  567. *
  568. * NOTE:
  569. * if gfp->num_channels=2, but gfp->mode = 3 (mono), the L & R channels
  570. * will be averaged into the L channel before encoding only the L channel
  571. * This will overwrite the data in buffer_l[] and buffer_r[].
  572. *
  573. */
  574. int CDECL lame_encode_buffer (
  575. lame_global_flags* gfp, /* global context handle */
  576. const short int buffer_l [], /* PCM data for left channel */
  577. const short int buffer_r [], /* PCM data for right channel */
  578. const int nsamples, /* number of samples per channel */
  579. unsigned char* mp3buf, /* pointer to encoded MP3 stream */
  580. const int mp3buf_size ); /* number of valid octets in this
  581. stream */
  582. /*
  583. * as above, but input has L & R channel data interleaved.
  584. * NOTE:
  585. * num_samples = number of samples in the L (or R)
  586. * channel, not the total number of samples in pcm[]
  587. */
  588. int CDECL lame_encode_buffer_interleaved(
  589. lame_global_flags* gfp, /* global context handlei */
  590. short int pcm[], /* PCM data for left and right
  591. channel, interleaved */
  592. int num_samples, /* number of samples per channel,
  593. _not_ number of samples in
  594. pcm[] */
  595. unsigned char* mp3buf, /* pointer to encoded MP3 stream */
  596. int mp3buf_size ); /* number of valid octets in this
  597. stream */
  598. /* as lame_encode_buffer, but for 'float's.
  599. * !! NOTE: !! data must still be scaled to be in the same range as
  600. * short int, +/- 32768
  601. */
  602. int CDECL lame_encode_buffer_float(
  603. lame_global_flags* gfp, /* global context handle */
  604. const float pcm_l [], /* PCM data for left channel */
  605. const float pcm_r [], /* PCM data for right channel */
  606. const int nsamples, /* number of samples per channel */
  607. unsigned char* mp3buf, /* pointer to encoded MP3 stream */
  608. const int mp3buf_size ); /* number of valid octets in this
  609. stream */
  610. /* as lame_encode_buffer, but for 'float's.
  611. * !! NOTE: !! data must be scaled to +/- 1 full scale
  612. */
  613. int CDECL lame_encode_buffer_ieee_float(
  614. lame_t gfp,
  615. const float pcm_l [], /* PCM data for left channel */
  616. const float pcm_r [], /* PCM data for right channel */
  617. const int nsamples,
  618. unsigned char * mp3buf,
  619. const int mp3buf_size);
  620. int CDECL lame_encode_buffer_interleaved_ieee_float(
  621. lame_t gfp,
  622. const float pcm[], /* PCM data for left and right
  623. channel, interleaved */
  624. const int nsamples,
  625. unsigned char * mp3buf,
  626. const int mp3buf_size);
  627. /* as lame_encode_buffer, but for 'double's.
  628. * !! NOTE: !! data must be scaled to +/- 1 full scale
  629. */
  630. int CDECL lame_encode_buffer_ieee_double(
  631. lame_t gfp,
  632. const double pcm_l [], /* PCM data for left channel */
  633. const double pcm_r [], /* PCM data for right channel */
  634. const int nsamples,
  635. unsigned char * mp3buf,
  636. const int mp3buf_size);
  637. int CDECL lame_encode_buffer_interleaved_ieee_double(
  638. lame_t gfp,
  639. const double pcm[], /* PCM data for left and right
  640. channel, interleaved */
  641. const int nsamples,
  642. unsigned char * mp3buf,
  643. const int mp3buf_size);
  644. /* as lame_encode_buffer, but for long's
  645. * !! NOTE: !! data must still be scaled to be in the same range as
  646. * short int, +/- 32768
  647. *
  648. * This scaling was a mistake (doesn't allow one to exploit full
  649. * precision of type 'long'. Use lame_encode_buffer_long2() instead.
  650. *
  651. */
  652. int CDECL lame_encode_buffer_long(
  653. lame_global_flags* gfp, /* global context handle */
  654. const long buffer_l [], /* PCM data for left channel */
  655. const long buffer_r [], /* PCM data for right channel */
  656. const int nsamples, /* number of samples per channel */
  657. unsigned char* mp3buf, /* pointer to encoded MP3 stream */
  658. const int mp3buf_size ); /* number of valid octets in this
  659. stream */
  660. /* Same as lame_encode_buffer_long(), but with correct scaling.
  661. * !! NOTE: !! data must still be scaled to be in the same range as
  662. * type 'long'. Data should be in the range: +/- 2^(8*size(long)-1)
  663. *
  664. */
  665. int CDECL lame_encode_buffer_long2(
  666. lame_global_flags* gfp, /* global context handle */
  667. const long buffer_l [], /* PCM data for left channel */
  668. const long buffer_r [], /* PCM data for right channel */
  669. const int nsamples, /* number of samples per channel */
  670. unsigned char* mp3buf, /* pointer to encoded MP3 stream */
  671. const int mp3buf_size ); /* number of valid octets in this
  672. stream */
  673. /* as lame_encode_buffer, but for int's
  674. * !! NOTE: !! input should be scaled to the maximum range of 'int'
  675. * If int is 4 bytes, then the values should range from
  676. * +/- 2147483648.
  677. *
  678. * This routine does not (and cannot, without loosing precision) use
  679. * the same scaling as the rest of the lame_encode_buffer() routines.
  680. *
  681. */
  682. int CDECL lame_encode_buffer_int(
  683. lame_global_flags* gfp, /* global context handle */
  684. const int buffer_l [], /* PCM data for left channel */
  685. const int buffer_r [], /* PCM data for right channel */
  686. const int nsamples, /* number of samples per channel */
  687. unsigned char* mp3buf, /* pointer to encoded MP3 stream */
  688. const int mp3buf_size ); /* number of valid octets in this
  689. stream */
  690. /*
  691. * REQUIRED:
  692. * lame_encode_flush will flush the intenal PCM buffers, padding with
  693. * 0's to make sure the final frame is complete, and then flush
  694. * the internal MP3 buffers, and thus may return a
  695. * final few mp3 frames. 'mp3buf' should be at least 7200 bytes long
  696. * to hold all possible emitted data.
  697. *
  698. * will also write id3v1 tags (if any) into the bitstream
  699. *
  700. * return code = number of bytes output to mp3buf. Can be 0
  701. */
  702. int CDECL lame_encode_flush(
  703. lame_global_flags * gfp, /* global context handle */
  704. unsigned char* mp3buf, /* pointer to encoded MP3 stream */
  705. int size); /* number of valid octets in this stream */
  706. /*
  707. * OPTIONAL:
  708. * lame_encode_flush_nogap will flush the internal mp3 buffers and pad
  709. * the last frame with ancillary data so it is a complete mp3 frame.
  710. *
  711. * 'mp3buf' should be at least 7200 bytes long
  712. * to hold all possible emitted data.
  713. *
  714. * After a call to this routine, the outputed mp3 data is complete, but
  715. * you may continue to encode new PCM samples and write future mp3 data
  716. * to a different file. The two mp3 files will play back with no gaps
  717. * if they are concatenated together.
  718. *
  719. * This routine will NOT write id3v1 tags into the bitstream.
  720. *
  721. * return code = number of bytes output to mp3buf. Can be 0
  722. */
  723. int CDECL lame_encode_flush_nogap(
  724. lame_global_flags * gfp, /* global context handle */
  725. unsigned char* mp3buf, /* pointer to encoded MP3 stream */
  726. int size); /* number of valid octets in this stream */
  727. /*
  728. * OPTIONAL:
  729. * Normally, this is called by lame_init_params(). It writes id3v2 and
  730. * Xing headers into the front of the bitstream, and sets frame counters
  731. * and bitrate histogram data to 0. You can also call this after
  732. * lame_encode_flush_nogap().
  733. */
  734. int CDECL lame_init_bitstream(
  735. lame_global_flags * gfp); /* global context handle */
  736. /*
  737. * OPTIONAL: some simple statistics
  738. * a bitrate histogram to visualize the distribution of used frame sizes
  739. * a stereo mode histogram to visualize the distribution of used stereo
  740. * modes, useful in joint-stereo mode only
  741. * 0: LR left-right encoded
  742. * 1: LR-I left-right and intensity encoded (currently not supported)
  743. * 2: MS mid-side encoded
  744. * 3: MS-I mid-side and intensity encoded (currently not supported)
  745. *
  746. * attention: don't call them after lame_encode_finish
  747. * suggested: lame_encode_flush -> lame_*_hist -> lame_close
  748. */
  749. void CDECL lame_bitrate_hist(
  750. const lame_global_flags * gfp,
  751. int bitrate_count[14] );
  752. void CDECL lame_bitrate_kbps(
  753. const lame_global_flags * gfp,
  754. int bitrate_kbps [14] );
  755. void CDECL lame_stereo_mode_hist(
  756. const lame_global_flags * gfp,
  757. int stereo_mode_count[4] );
  758. void CDECL lame_bitrate_stereo_mode_hist (
  759. const lame_global_flags * gfp,
  760. int bitrate_stmode_count[14][4] );
  761. void CDECL lame_block_type_hist (
  762. const lame_global_flags * gfp,
  763. int btype_count[6] );
  764. void CDECL lame_bitrate_block_type_hist (
  765. const lame_global_flags * gfp,
  766. int bitrate_btype_count[14][6] );
  767. #if (DEPRECATED_OR_OBSOLETE_CODE_REMOVED && 0)
  768. #else
  769. /*
  770. * OPTIONAL:
  771. * lame_mp3_tags_fid will rewrite a Xing VBR tag to the mp3 file with file
  772. * pointer fid. These calls perform forward and backwards seeks, so make
  773. * sure fid is a real file. Make sure lame_encode_flush has been called,
  774. * and all mp3 data has been written to the file before calling this
  775. * function.
  776. * NOTE:
  777. * if VBR tags are turned off by the user, or turned off by LAME because
  778. * the output is not a regular file, this call does nothing
  779. * NOTE:
  780. * LAME wants to read from the file to skip an optional ID3v2 tag, so
  781. * make sure you opened the file for writing and reading.
  782. * NOTE:
  783. * You can call lame_get_lametag_frame instead, if you want to insert
  784. * the lametag yourself.
  785. */
  786. void CDECL lame_mp3_tags_fid(lame_global_flags *, FILE* fid);
  787. #endif
  788. /*
  789. * OPTIONAL:
  790. * lame_get_lametag_frame copies the final LAME-tag into 'buffer'.
  791. * The function returns the number of bytes copied into buffer, or
  792. * the required buffer size, if the provided buffer is too small.
  793. * Function failed, if the return value is larger than 'size'!
  794. * Make sure lame_encode flush has been called before calling this function.
  795. * NOTE:
  796. * if VBR tags are turned off by the user, or turned off by LAME,
  797. * this call does nothing and returns 0.
  798. * NOTE:
  799. * LAME inserted an empty frame in the beginning of mp3 audio data,
  800. * which you have to replace by the final LAME-tag frame after encoding.
  801. * In case there is no ID3v2 tag, usually this frame will be the very first
  802. * data in your mp3 file. If you put some other leading data into your
  803. * file, you'll have to do some bookkeeping about where to write this buffer.
  804. */
  805. size_t CDECL lame_get_lametag_frame(
  806. const lame_global_flags *, unsigned char* buffer, size_t size);
  807. /*
  808. * REQUIRED:
  809. * final call to free all remaining buffers
  810. */
  811. int CDECL lame_close (lame_global_flags *);
  812. #if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
  813. #else
  814. /*
  815. * OBSOLETE:
  816. * lame_encode_finish combines lame_encode_flush() and lame_close() in
  817. * one call. However, once this call is made, the statistics routines
  818. * will no longer work because the data will have been cleared, and
  819. * lame_mp3_tags_fid() cannot be called to add data to the VBR header
  820. */
  821. int CDECL lame_encode_finish(
  822. lame_global_flags* gfp,
  823. unsigned char* mp3buf,
  824. int size );
  825. #endif
  826. /*********************************************************************
  827. *
  828. * decoding
  829. *
  830. * a simple interface to mpglib, part of mpg123, is also included if
  831. * libmp3lame is compiled with HAVE_MPGLIB
  832. *
  833. *********************************************************************/
  834. struct hip_global_struct;
  835. typedef struct hip_global_struct hip_global_flags;
  836. typedef hip_global_flags *hip_t;
  837. typedef struct {
  838. int header_parsed; /* 1 if header was parsed and following data was
  839. computed */
  840. int stereo; /* number of channels */
  841. int samplerate; /* sample rate */
  842. int bitrate; /* bitrate */
  843. int mode; /* mp3 frame type */
  844. int mode_ext; /* mp3 frame type */
  845. int framesize; /* number of samples per mp3 frame */
  846. /* this data is only computed if mpglib detects a Xing VBR header */
  847. unsigned long nsamp; /* number of samples in mp3 file. */
  848. int totalframes; /* total number of frames in mp3 file */
  849. /* this data is not currently computed by the mpglib routines */
  850. int framenum; /* frames decoded counter */
  851. } mp3data_struct;
  852. /* required call to initialize decoder */
  853. hip_t CDECL hip_decode_init(void);
  854. /* cleanup call to exit decoder */
  855. int CDECL hip_decode_exit(hip_t gfp);
  856. /* HIP reporting functions */
  857. void CDECL hip_set_errorf(hip_t gfp, lame_report_function f);
  858. void CDECL hip_set_debugf(hip_t gfp, lame_report_function f);
  859. void CDECL hip_set_msgf (hip_t gfp, lame_report_function f);
  860. /*********************************************************************
  861. * input 1 mp3 frame, output (maybe) pcm data.
  862. *
  863. * nout = hip_decode(hip, mp3buf,len,pcm_l,pcm_r);
  864. *
  865. * input:
  866. * len : number of bytes of mp3 data in mp3buf
  867. * mp3buf[len] : mp3 data to be decoded
  868. *
  869. * output:
  870. * nout: -1 : decoding error
  871. * 0 : need more data before we can complete the decode
  872. * >0 : returned 'nout' samples worth of data in pcm_l,pcm_r
  873. * pcm_l[nout] : left channel data
  874. * pcm_r[nout] : right channel data
  875. *
  876. *********************************************************************/
  877. int CDECL hip_decode( hip_t gfp
  878. , unsigned char * mp3buf
  879. , size_t len
  880. , short pcm_l[]
  881. , short pcm_r[]
  882. );
  883. /* same as hip_decode, and also returns mp3 header data */
  884. int CDECL hip_decode_headers( hip_t gfp
  885. , unsigned char* mp3buf
  886. , size_t len
  887. , short pcm_l[]
  888. , short pcm_r[]
  889. , mp3data_struct* mp3data
  890. );
  891. /* same as hip_decode, but returns at most one frame */
  892. int CDECL hip_decode1( hip_t gfp
  893. , unsigned char* mp3buf
  894. , size_t len
  895. , short pcm_l[]
  896. , short pcm_r[]
  897. );
  898. /* same as hip_decode1, but returns at most one frame and mp3 header data */
  899. int CDECL hip_decode1_headers( hip_t gfp
  900. , unsigned char* mp3buf
  901. , size_t len
  902. , short pcm_l[]
  903. , short pcm_r[]
  904. , mp3data_struct* mp3data
  905. );
  906. /* same as hip_decode1_headers, but also returns enc_delay and enc_padding
  907. from VBR Info tag, (-1 if no info tag was found) */
  908. int CDECL hip_decode1_headersB( hip_t gfp
  909. , unsigned char* mp3buf
  910. , size_t len
  911. , short pcm_l[]
  912. , short pcm_r[]
  913. , mp3data_struct* mp3data
  914. , int *enc_delay
  915. , int *enc_padding
  916. );
  917. /* OBSOLETE:
  918. * lame_decode... functions are there to keep old code working
  919. * but it is strongly recommended to replace calls by hip_decode...
  920. * function calls, see above.
  921. */
  922. #if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
  923. #else
  924. int CDECL lame_decode_init(void);
  925. int CDECL lame_decode(
  926. unsigned char * mp3buf,
  927. int len,
  928. short pcm_l[],
  929. short pcm_r[] );
  930. int CDECL lame_decode_headers(
  931. unsigned char* mp3buf,
  932. int len,
  933. short pcm_l[],
  934. short pcm_r[],
  935. mp3data_struct* mp3data );
  936. int CDECL lame_decode1(
  937. unsigned char* mp3buf,
  938. int len,
  939. short pcm_l[],
  940. short pcm_r[] );
  941. int CDECL lame_decode1_headers(
  942. unsigned char* mp3buf,
  943. int len,
  944. short pcm_l[],
  945. short pcm_r[],
  946. mp3data_struct* mp3data );
  947. int CDECL lame_decode1_headersB(
  948. unsigned char* mp3buf,
  949. int len,
  950. short pcm_l[],
  951. short pcm_r[],
  952. mp3data_struct* mp3data,
  953. int *enc_delay,
  954. int *enc_padding );
  955. int CDECL lame_decode_exit(void);
  956. #endif /* obsolete lame_decode API calls */
  957. /*********************************************************************
  958. *
  959. * id3tag stuff
  960. *
  961. *********************************************************************/
  962. /*
  963. * id3tag.h -- Interface to write ID3 version 1 and 2 tags.
  964. *
  965. * Copyright (C) 2000 Don Melton.
  966. *
  967. * This library is free software; you can redistribute it and/or
  968. * modify it under the terms of the GNU Library General Public
  969. * License as published by the Free Software Foundation; either
  970. * version 2 of the License, or (at your option) any later version.
  971. *
  972. * This library is distributed in the hope that it will be useful,
  973. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  974. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  975. * Library General Public License for more details.
  976. *
  977. * You should have received a copy of the GNU Library General Public
  978. * License along with this library; if not, write to the Free Software
  979. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  980. */
  981. /* utility to obtain alphabetically sorted list of genre names with numbers */
  982. void CDECL id3tag_genre_list(
  983. void (*handler)(int, const char *, void *),
  984. void* cookie);
  985. void CDECL id3tag_init (lame_t gfp);
  986. /* force addition of version 2 tag */
  987. void CDECL id3tag_add_v2 (lame_t gfp);
  988. /* add only a version 1 tag */
  989. void CDECL id3tag_v1_only (lame_t gfp);
  990. /* add only a version 2 tag */
  991. void CDECL id3tag_v2_only (lame_t gfp);
  992. /* pad version 1 tag with spaces instead of nulls */
  993. void CDECL id3tag_space_v1 (lame_t gfp);
  994. /* pad version 2 tag with extra 128 bytes */
  995. void CDECL id3tag_pad_v2 (lame_t gfp);
  996. /* pad version 2 tag with extra n bytes */
  997. void CDECL id3tag_set_pad (lame_t gfp, size_t n);
  998. void CDECL id3tag_set_title(lame_t gfp, const char* title);
  999. void CDECL id3tag_set_artist(lame_t gfp, const char* artist);
  1000. void CDECL id3tag_set_album(lame_t gfp, const char* album);
  1001. void CDECL id3tag_set_year(lame_t gfp, const char* year);
  1002. void CDECL id3tag_set_comment(lame_t gfp, const char* comment);
  1003. /* return -1 result if track number is out of ID3v1 range
  1004. and ignored for ID3v1 */
  1005. int CDECL id3tag_set_track(lame_t gfp, const char* track);
  1006. /* return non-zero result if genre name or number is invalid
  1007. result 0: OK
  1008. result -1: genre number out of range
  1009. result -2: no valid ID3v1 genre name, mapped to ID3v1 'Other'
  1010. but taken as-is for ID3v2 genre tag */
  1011. int CDECL id3tag_set_genre(lame_t gfp, const char* genre);
  1012. /* return non-zero result if field name is invalid */
  1013. int CDECL id3tag_set_fieldvalue(lame_t gfp, const char* fieldvalue);
  1014. /* return non-zero result if image type is invalid */
  1015. int CDECL id3tag_set_albumart(lame_t gfp, const char* image, size_t size);
  1016. /* lame_get_id3v1_tag copies ID3v1 tag into buffer.
  1017. * Function returns number of bytes copied into buffer, or number
  1018. * of bytes rquired if buffer 'size' is too small.
  1019. * Function fails, if returned value is larger than 'size'.
  1020. * NOTE:
  1021. * This functions does nothing, if user/LAME disabled ID3v1 tag.
  1022. */
  1023. size_t CDECL lame_get_id3v1_tag(lame_t gfp, unsigned char* buffer, size_t size);
  1024. /* lame_get_id3v2_tag copies ID3v2 tag into buffer.
  1025. * Function returns number of bytes copied into buffer, or number
  1026. * of bytes rquired if buffer 'size' is too small.
  1027. * Function fails, if returned value is larger than 'size'.
  1028. * NOTE:
  1029. * This functions does nothing, if user/LAME disabled ID3v2 tag.
  1030. */
  1031. size_t CDECL lame_get_id3v2_tag(lame_t gfp, unsigned char* buffer, size_t size);
  1032. /* normaly lame_init_param writes ID3v2 tags into the audio stream
  1033. * Call lame_set_write_id3tag_automatic(gfp, 0) before lame_init_param
  1034. * to turn off this behaviour and get ID3v2 tag with above function
  1035. * write it yourself into your file.
  1036. */
  1037. void CDECL lame_set_write_id3tag_automatic(lame_global_flags * gfp, int);
  1038. int CDECL lame_get_write_id3tag_automatic(lame_global_flags const* gfp);
  1039. /* experimental */
  1040. int CDECL id3tag_set_textinfo_latin1(lame_t gfp, char const *id, char const *text);
  1041. /* experimental */
  1042. int CDECL id3tag_set_comment_latin1(lame_t gfp, char const *lang, char const *desc, char const *text);
  1043. #if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
  1044. #else
  1045. /* experimental */
  1046. int CDECL id3tag_set_textinfo_ucs2(lame_t gfp, char const *id, unsigned short const *text);
  1047. /* experimental */
  1048. int CDECL id3tag_set_comment_ucs2(lame_t gfp, char const *lang,
  1049. unsigned short const *desc, unsigned short const *text);
  1050. /* experimental */
  1051. int CDECL id3tag_set_fieldvalue_ucs2(lame_t gfp, const unsigned short *fieldvalue);
  1052. #endif
  1053. /* experimental */
  1054. int CDECL id3tag_set_fieldvalue_utf16(lame_t gfp, const unsigned short *fieldvalue);
  1055. /* experimental */
  1056. int CDECL id3tag_set_textinfo_utf16(lame_t gfp, char const *id, unsigned short const *text);
  1057. /* experimental */
  1058. int CDECL id3tag_set_comment_utf16(lame_t gfp, char const *lang, unsigned short const *desc, unsigned short const *text);
  1059. /***********************************************************************
  1060. *
  1061. * list of valid bitrates [kbps] & sample frequencies [Hz].
  1062. * first index: 0: MPEG-2 values (sample frequencies 16...24 kHz)
  1063. * 1: MPEG-1 values (sample frequencies 32...48 kHz)
  1064. * 2: MPEG-2.5 values (sample frequencies 8...12 kHz)
  1065. ***********************************************************************/
  1066. extern const int bitrate_table [3][16];
  1067. extern const int samplerate_table [3][ 4];
  1068. /* access functions for use in DLL, global vars are not exported */
  1069. int CDECL lame_get_bitrate(int mpeg_version, int table_index);
  1070. int CDECL lame_get_samplerate(int mpeg_version, int table_index);
  1071. /* maximum size of albumart image (128KB), which affects LAME_MAXMP3BUFFER
  1072. as well since lame_encode_buffer() also returns ID3v2 tag data */
  1073. #define LAME_MAXALBUMART (128 * 1024)
  1074. /* maximum size of mp3buffer needed if you encode at most 1152 samples for
  1075. each call to lame_encode_buffer. see lame_encode_buffer() below
  1076. (LAME_MAXMP3BUFFER is now obsolete) */
  1077. #define LAME_MAXMP3BUFFER (16384 + LAME_MAXALBUMART)
  1078. typedef enum {
  1079. LAME_OKAY = 0,
  1080. LAME_NOERROR = 0,
  1081. LAME_GENERICERROR = -1,
  1082. LAME_NOMEM = -10,
  1083. LAME_BADBITRATE = -11,
  1084. LAME_BADSAMPFREQ = -12,
  1085. LAME_INTERNALERROR = -13,
  1086. FRONTEND_READERROR = -80,
  1087. FRONTEND_WRITEERROR = -81,
  1088. FRONTEND_FILETOOLARGE = -82
  1089. } lame_errorcodes_t;
  1090. #if defined(__cplusplus)
  1091. }
  1092. #endif
  1093. #endif /* LAME_LAME_H */