Debian Codegraph @

external/lame/lame.h

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