2
* Interface to MP3 LAME encoding engine
4
* Copyright (c) 1999 Mark Taylor
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2, or (at your option)
11
* This program 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
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; see the file COPYING. If not, write to
18
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21
/* $Id: lame.h,v 1.154 2004/04/11 15:39:53 glessard Exp $ */
29
#if defined(__cplusplus)
41
typedef enum vbr_mode_e {
43
vbr_mt, /* obsolete, same as vbr_mtrh */
47
vbr_max_indicator, /* Don't use this! It's used for sanity checks. */
48
vbr_default=vbr_rh /* change this to change the default VBR mode of LAME */
53
typedef enum MPEG_mode_e {
56
DUAL_CHANNEL, /* LAME doesn't supports this! */
59
MAX_INDICATOR /* Don't use this! It's used for sanity checks. */
63
typedef enum Padding_type_e {
67
PAD_MAX_INDICATOR /* Don't use this! It's used for sanity checks. */
73
typedef enum preset_mode_e {
74
/*values from 8 to 320 should be reserved for abr bitrates*/
75
/*for abr I'd suggest to directly use the targeted bitrate as a value*/
79
V9 = 410, /*Vx to match Lame and VBR_xx to match FhG*/
102
/*still there for compatibility*/
107
STANDARD_FAST = 1004,
114
/*asm optimizations*/
115
typedef enum asm_optimizations_e {
122
/* psychoacoustic model */
123
typedef enum Psy_model_e {
129
struct lame_global_struct;
130
typedef struct lame_global_struct lame_global_flags;
131
typedef lame_global_flags *lame_t;
136
/***********************************************************************
139
* These functions should be called, in this order, for each
140
* MP3 file to be encoded. See the file "API" for more documentation
142
***********************************************************************/
147
* initialize the encoder. sets default for all encoder parameters,
148
* returns NULL if some malloc()'s failed
149
* otherwise returns pointer to structure needed for all future
152
lame_global_flags * CDECL lame_init(void);
153
/* obsolete version */
154
int CDECL lame_init_old(lame_global_flags *);
159
* set as needed to override defaults
162
/********************************************************************
163
* input stream description
164
***********************************************************************/
165
/* number of samples. default = 2^32-1 */
166
int CDECL lame_set_num_samples(lame_global_flags *, unsigned long);
167
unsigned long CDECL lame_get_num_samples(const lame_global_flags *);
169
/* input sample rate in Hz. default = 44100hz */
170
int CDECL lame_set_in_samplerate(lame_global_flags *, int);
171
int CDECL lame_get_in_samplerate(const lame_global_flags *);
173
/* number of channels in input stream. default=2 */
174
int CDECL lame_set_num_channels(lame_global_flags *, int);
175
int CDECL lame_get_num_channels(const lame_global_flags *);
178
scale the input by this amount before encoding. default=0 (disabled)
179
(not used by decoding routines)
181
int CDECL lame_set_scale(lame_global_flags *, float);
182
float CDECL lame_get_scale(const lame_global_flags *);
185
scale the channel 0 (left) input by this amount before encoding.
187
(not used by decoding routines)
189
int CDECL lame_set_scale_left(lame_global_flags *, float);
190
float CDECL lame_get_scale_left(const lame_global_flags *);
193
scale the channel 1 (right) input by this amount before encoding.
195
(not used by decoding routines)
197
int CDECL lame_set_scale_right(lame_global_flags *, float);
198
float CDECL lame_get_scale_right(const lame_global_flags *);
201
output sample rate in Hz. default = 0, which means LAME picks best value
202
based on the amount of compression. MPEG only allows:
203
MPEG1 32, 44.1, 48khz
205
MPEG2.5 8, 11.025, 12
206
(not used by decoding routines)
208
int CDECL lame_set_out_samplerate(lame_global_flags *, int);
209
int CDECL lame_get_out_samplerate(const lame_global_flags *);
212
/********************************************************************
213
* general control parameters
214
***********************************************************************/
215
/* 1=cause LAME to collect data for an MP3 frame analyzer. default=0 */
216
int CDECL lame_set_analysis(lame_global_flags *, int);
217
int CDECL lame_get_analysis(const lame_global_flags *);
220
1 = write a Xing VBR header frame.
222
this variable must have been added by a Hungarian notation Windows programmer :-)
224
int CDECL lame_set_bWriteVbrTag(lame_global_flags *, int);
225
int CDECL lame_get_bWriteVbrTag(const lame_global_flags *);
227
/* 1=decode only. use lame/mpglib to convert mp3/ogg to wav. default=0 */
228
int CDECL lame_set_decode_only(lame_global_flags *, int);
229
int CDECL lame_get_decode_only(const lame_global_flags *);
231
/* 1=encode a Vorbis .ogg file. default=0 */
233
int CDECL lame_set_ogg(lame_global_flags *, int);
234
int CDECL lame_get_ogg(const lame_global_flags *);
237
internal algorithm selection. True quality is determined by the bitrate
238
but this variable will effect quality by selecting expensive or cheap algorithms.
239
quality=0..9. 0=best (very slow). 9=worst.
240
recommended: 2 near-best quality, not too slow
242
7 ok quality, really fast
244
int CDECL lame_set_quality(lame_global_flags *, int);
245
int CDECL lame_get_quality(const lame_global_flags *);
248
mode = 0,1,2,3 = stereo, jstereo, dual channel (not supported), mono
249
default: lame picks based on compression ration and input channels
251
int CDECL lame_set_mode(lame_global_flags *, MPEG_mode);
252
MPEG_mode CDECL lame_get_mode(const lame_global_flags *);
255
mode_automs. Use a M/S mode with a switching threshold based on
259
int CDECL lame_set_mode_automs(lame_global_flags *, int);
260
int CDECL lame_get_mode_automs(const lame_global_flags *);
263
force_ms. Force M/S for all frames. For testing only.
264
default = 0 (disabled)
266
int CDECL lame_set_force_ms(lame_global_flags *, int);
267
int CDECL lame_get_force_ms(const lame_global_flags *);
269
/* use free_format? default = 0 (disabled) */
270
int CDECL lame_set_free_format(lame_global_flags *, int);
271
int CDECL lame_get_free_format(const lame_global_flags *);
273
/* perform ReplayGain analysis? default = 0 (disabled) */
274
int CDECL lame_set_findReplayGain(lame_global_flags *, int);
275
int CDECL lame_get_findReplayGain(const lame_global_flags *);
277
/* decode on the fly. Search for the peak sample. If the ReplayGain
278
* analysis is enabled then perform the analysis on the decoded data
279
* stream. default = 0 (disabled)
280
* NOTE: if this option is set the build-in decoder should not be used */
281
int CDECL lame_set_decode_on_the_fly(lame_global_flags *, int);
282
int CDECL lame_get_decode_on_the_fly(const lame_global_flags *);
284
/* DEPRECATED: now does the same as lame_set_findReplayGain()
285
default = 0 (disabled) */
286
int CDECL lame_set_ReplayGain_input(lame_global_flags *, int);
287
int CDECL lame_get_ReplayGain_input(const lame_global_flags *);
289
/* DEPRECATED: now does the same as
290
lame_set_decode_on_the_fly() && lame_set_findReplayGain()
291
default = 0 (disabled) */
292
int CDECL lame_set_ReplayGain_decode(lame_global_flags *, int);
293
int CDECL lame_get_ReplayGain_decode(const lame_global_flags *);
295
/* DEPRECATED: now does the same as lame_set_decode_on_the_fly()
296
default = 0 (disabled) */
297
int CDECL lame_set_findPeakSample(lame_global_flags *, int);
298
int CDECL lame_get_findPeakSample(const lame_global_flags *);
300
/* counters for gapless encoding */
301
int CDECL lame_set_nogap_total(lame_global_flags*, int);
302
int CDECL lame_get_nogap_total(const lame_global_flags*);
304
int CDECL lame_set_nogap_currentindex(lame_global_flags* , int);
305
int CDECL lame_get_nogap_currentindex(const lame_global_flags*);
310
* Set printf like error/debug/message reporting functions.
311
* The second argument has to be a pointer to a function which looks like
312
* void my_debugf(const char *format, va_list ap)
314
* (void) vfprintf(stdout, format, ap);
316
* If you use NULL as the value of the pointer in the set function, the
317
* lame buildin function will be used (prints to stderr).
318
* To quiet any output you have to replace the body of the example function
319
* with just "return;" and use it in the set function.
321
int CDECL lame_set_errorf(lame_global_flags *,
322
void (*func)(const char *, va_list));
323
int CDECL lame_set_debugf(lame_global_flags *,
324
void (*func)(const char *, va_list));
325
int CDECL lame_set_msgf (lame_global_flags *,
326
void (*func)(const char *, va_list));
330
/* set one of brate compression ratio. default is compression ratio of 11. */
331
int CDECL lame_set_brate(lame_global_flags *, int);
332
int CDECL lame_get_brate(const lame_global_flags *);
333
int CDECL lame_set_compression_ratio(lame_global_flags *, float);
334
float CDECL lame_get_compression_ratio(const lame_global_flags *);
337
int CDECL lame_set_preset( lame_global_flags* gfp, int );
338
int CDECL lame_set_asm_optimizations( lame_global_flags* gfp, int, int );
342
/********************************************************************
344
***********************************************************************/
345
/* mark as copyright. default=0 */
346
int CDECL lame_set_copyright(lame_global_flags *, int);
347
int CDECL lame_get_copyright(const lame_global_flags *);
349
/* mark as original. default=1 */
350
int CDECL lame_set_original(lame_global_flags *, int);
351
int CDECL lame_get_original(const lame_global_flags *);
353
/* error_protection. Use 2 bytes from each frame for CRC checksum. default=0 */
354
int CDECL lame_set_error_protection(lame_global_flags *, int);
355
int CDECL lame_get_error_protection(const lame_global_flags *);
357
/* padding_type. 0=pad no frames 1=pad all frames 2=adjust padding(default) */
358
int CDECL lame_set_padding_type(lame_global_flags *, Padding_type);
359
Padding_type CDECL lame_get_padding_type(const lame_global_flags *);
361
/* MP3 'private extension' bit Meaningless. default=0 */
362
int CDECL lame_set_extension(lame_global_flags *, int);
363
int CDECL lame_get_extension(const lame_global_flags *);
365
/* enforce strict ISO compliance. default=0 */
366
int CDECL lame_set_strict_ISO(lame_global_flags *, int);
367
int CDECL lame_get_strict_ISO(const lame_global_flags *);
370
/********************************************************************
371
* quantization/noise shaping
372
***********************************************************************/
374
/* disable the bit reservoir. For testing only. default=0 */
375
int CDECL lame_set_disable_reservoir(lame_global_flags *, int);
376
int CDECL lame_get_disable_reservoir(const lame_global_flags *);
378
/* select a different "best quantization" function. default=0 */
379
int CDECL lame_set_quant_comp(lame_global_flags *, int);
380
int CDECL lame_get_quant_comp(const lame_global_flags *);
381
int CDECL lame_set_quant_comp_short(lame_global_flags *, int);
382
int CDECL lame_get_quant_comp_short(const lame_global_flags *);
384
int CDECL lame_set_experimentalX(lame_global_flags *, int); /* compatibility*/
385
int CDECL lame_get_experimentalX(const lame_global_flags *);
387
/* another experimental option. for testing only */
388
int CDECL lame_set_experimentalY(lame_global_flags *, int);
389
int CDECL lame_get_experimentalY(const lame_global_flags *);
391
/* another experimental option. for testing only */
392
int CDECL lame_set_experimentalZ(lame_global_flags *, int);
393
int CDECL lame_get_experimentalZ(const lame_global_flags *);
395
/* Naoki's psycho acoustic model. default=0 */
396
int CDECL lame_set_exp_nspsytune(lame_global_flags *, int);
397
int CDECL lame_get_exp_nspsytune(const lame_global_flags *);
399
void CDECL lame_set_msfix(lame_global_flags *, double);
400
float CDECL lame_get_msfix(const lame_global_flags *);
402
int lame_set_exp_nspsytune2_int( lame_global_flags*, int, int);
403
float lame_set_exp_nspsytune2_real( lame_global_flags*, int, float);
404
void * lame_set_exp_nspsytune2_pointer( lame_global_flags*, int, void *);
406
/********************************************************************
408
***********************************************************************/
409
/* Types of VBR. default = vbr_off = CBR */
410
int CDECL lame_set_VBR(lame_global_flags *, vbr_mode);
411
vbr_mode CDECL lame_get_VBR(const lame_global_flags *);
413
/* VBR quality level. 0=highest 9=lowest */
414
int CDECL lame_set_VBR_q(lame_global_flags *, int);
415
int CDECL lame_get_VBR_q(const lame_global_flags *);
417
/* Ignored except for VBR=vbr_abr (ABR mode) */
418
int CDECL lame_set_VBR_mean_bitrate_kbps(lame_global_flags *, int);
419
int CDECL lame_get_VBR_mean_bitrate_kbps(const lame_global_flags *);
421
int CDECL lame_set_VBR_min_bitrate_kbps(lame_global_flags *, int);
422
int CDECL lame_get_VBR_min_bitrate_kbps(const lame_global_flags *);
424
int CDECL lame_set_VBR_max_bitrate_kbps(lame_global_flags *, int);
425
int CDECL lame_get_VBR_max_bitrate_kbps(const lame_global_flags *);
428
1=strictly enforce VBR_min_bitrate. Normally it will be violated for
431
int CDECL lame_set_VBR_hard_min(lame_global_flags *, int);
432
int CDECL lame_get_VBR_hard_min(const lame_global_flags *);
435
int CDECL lame_set_preset_expopts(lame_global_flags *, int);
438
/********************************************************************
440
***********************************************************************/
441
/* freq in Hz to apply lowpass. Default = 0 = lame chooses. -1 = disabled */
442
int CDECL lame_set_lowpassfreq(lame_global_flags *, int);
443
int CDECL lame_get_lowpassfreq(const lame_global_flags *);
444
/* width of transition band, in Hz. Default = one polyphase filter band */
445
int CDECL lame_set_lowpasswidth(lame_global_flags *, int);
446
int CDECL lame_get_lowpasswidth(const lame_global_flags *);
448
/* freq in Hz to apply highpass. Default = 0 = lame chooses. -1 = disabled */
449
int CDECL lame_set_highpassfreq(lame_global_flags *, int);
450
int CDECL lame_get_highpassfreq(const lame_global_flags *);
451
/* width of transition band, in Hz. Default = one polyphase filter band */
452
int CDECL lame_set_highpasswidth(lame_global_flags *, int);
453
int CDECL lame_get_highpasswidth(const lame_global_flags *);
456
/********************************************************************
457
* psycho acoustics and other arguments which you should not change
458
* unless you know what you are doing
459
***********************************************************************/
461
/* only use ATH for masking */
462
int CDECL lame_set_ATHonly(lame_global_flags *, int);
463
int CDECL lame_get_ATHonly(const lame_global_flags *);
465
/* only use ATH for short blocks */
466
int CDECL lame_set_ATHshort(lame_global_flags *, int);
467
int CDECL lame_get_ATHshort(const lame_global_flags *);
470
int CDECL lame_set_noATH(lame_global_flags *, int);
471
int CDECL lame_get_noATH(const lame_global_flags *);
473
/* select ATH formula */
474
int CDECL lame_set_ATHtype(lame_global_flags *, int);
475
int CDECL lame_get_ATHtype(const lame_global_flags *);
477
/* lower ATH by this many db */
478
int CDECL lame_set_ATHlower(lame_global_flags *, float);
479
float CDECL lame_get_ATHlower(const lame_global_flags *);
481
/* select ATH adaptive adjustment type */
482
int CDECL lame_set_athaa_type( lame_global_flags *, int);
483
int CDECL lame_get_athaa_type( const lame_global_flags *);
485
/* select the loudness approximation used by the ATH adaptive auto-leveling */
486
int CDECL lame_set_athaa_loudapprox( lame_global_flags *, int);
487
int CDECL lame_get_athaa_loudapprox( const lame_global_flags *);
489
/* adjust (in dB) the point below which adaptive ATH level adjustment occurs */
490
int CDECL lame_set_athaa_sensitivity( lame_global_flags *, float);
491
float CDECL lame_get_athaa_sensitivity( const lame_global_flags* );
493
/* predictability limit (ISO tonality formula) */
494
int CDECL lame_set_cwlimit(lame_global_flags *, int);
495
int CDECL lame_get_cwlimit(const lame_global_flags *);
498
allow blocktypes to differ between channels?
499
default: 0 for jstereo, 1 for stereo
501
int CDECL lame_set_allow_diff_short(lame_global_flags *, int);
502
int CDECL lame_get_allow_diff_short(const lame_global_flags *);
504
/* use temporal masking effect (default = 1) */
505
int CDECL lame_set_useTemporal(lame_global_flags *, int);
506
int CDECL lame_get_useTemporal(const lame_global_flags *);
508
/* use temporal masking effect (default = 1) */
509
int CDECL lame_set_interChRatio(lame_global_flags *, float);
510
float CDECL lame_get_interChRatio(const lame_global_flags *);
512
/* disable short blocks */
513
int CDECL lame_set_no_short_blocks(lame_global_flags *, int);
514
int CDECL lame_get_no_short_blocks(const lame_global_flags *);
516
/* force short blocks */
517
int CDECL lame_set_force_short_blocks(lame_global_flags *, int);
518
int CDECL lame_get_force_short_blocks(const lame_global_flags *);
520
/* Input PCM is emphased PCM (for instance from one of the rarely
521
emphased CDs), it is STRONGLY not recommended to use this, because
522
psycho does not take it into account, and last but not least many decoders
524
int CDECL lame_set_emphasis(lame_global_flags *, int);
525
int CDECL lame_get_emphasis(const lame_global_flags *);
529
/************************************************************************/
530
/* internal variables, cannot be set... */
531
/* provided because they may be of use to calling application */
532
/************************************************************************/
533
/* version 0=MPEG-2 1=MPEG-1 (2=MPEG-2.5) */
534
int CDECL lame_get_version(const lame_global_flags *);
537
int CDECL lame_get_encoder_delay(const lame_global_flags *);
540
padding appended to the input to make sure decoder can fully decode
541
all input. Note that this value can only be calculated during the
542
call to lame_encoder_flush(). Before lame_encoder_flush() has
543
been called, the value of encoder_padding = 0.
545
int CDECL lame_get_encoder_padding(const lame_global_flags *);
547
/* size of MPEG frame */
548
int CDECL lame_get_framesize(const lame_global_flags *);
550
/* number of PCM samples buffered, but not yet encoded to mp3 data. */
551
int CDECL lame_get_mf_samples_to_encode( const lame_global_flags* gfp );
554
size (bytes) of mp3 data buffered, but not yet encoded.
555
this is the number of bytes which would be output by a call to
556
lame_encode_flush_nogap. NOTE: lame_encode_flush() will return
557
more bytes than this because it will encode the reamining buffered
558
PCM samples before flushing the mp3 buffers.
560
int CDECL lame_get_size_mp3buffer( const lame_global_flags* gfp );
562
/* number of frames encoded so far */
563
int CDECL lame_get_frameNum(const lame_global_flags *);
566
lame's estimate of the total number of frames to be encoded
567
only valid if calling program set num_samples
569
int CDECL lame_get_totalframes(const lame_global_flags *);
571
/* RadioGain value. Multiplied by 10 and rounded to the nearest. */
572
int CDECL lame_get_RadioGain(const lame_global_flags *);
574
/* AudiophileGain value. Multipled by 10 and rounded to the nearest. */
575
int CDECL lame_get_AudiophileGain(const lame_global_flags *);
577
/* the peak sample */
578
float CDECL lame_get_PeakSample(const lame_global_flags *);
580
/* is decoding on the fly performed */
581
int CDECL lame_get_decode_on_the_fly(const lame_global_flags *);
583
/* is ReplayGain analysis performed */
584
int CDECL lame_get_findReplayGain(const lame_global_flags *);
586
/* Gain change required for preventing clipping. The value is correct only if
587
peak sample searching was enabled. If negative then the waveform
588
already does not clip. The value is multiplied by 10 and rounded up. */
589
int CDECL lame_get_noclipGainChange(const lame_global_flags *);
591
/* user-specified scale factor required for preventing clipping. Value is
592
correct only if peak sample searching was enabled and no user-specified
593
scaling was performed. If negative then either the waveform already does
594
not clip or the value cannot be determined */
595
float CDECL lame_get_noclipScale(const lame_global_flags *);
605
* sets more internal configuration based on data provided above.
606
* returns -1 if something failed.
608
int CDECL lame_init_params(lame_global_flags * const );
613
* get the version number, in a string. of the form:
614
* "3.63 (beta)" or just "3.63".
616
const char* CDECL get_lame_version ( void );
617
const char* CDECL get_lame_short_version ( void );
618
const char* CDECL get_lame_very_short_version ( void );
619
const char* CDECL get_psy_version ( void );
620
const char* CDECL get_lame_url ( void );
624
* get the version numbers in numerical form.
627
/* generic LAME version */
630
int alpha; /* 0 if not an alpha version */
631
int beta; /* 0 if not a beta version */
633
/* version of the psy model */
636
int psy_alpha; /* 0 if not an alpha version */
637
int psy_beta; /* 0 if not a beta version */
639
/* compile time features */
640
const char *features; /* Don't make assumptions about the contents! */
642
void CDECL get_lame_version_numerical ( lame_version_t *const );
647
* print internal lame configuration to message handler
649
void CDECL lame_print_config(const lame_global_flags* gfp);
651
void CDECL lame_print_internals( const lame_global_flags *gfp);
655
* input pcm data, output (maybe) mp3 frames.
656
* This routine handles all buffering, resampling and filtering for you.
658
* return code number of bytes output in mp3buf. Can be 0
659
* -1: mp3buf was too small
660
* -2: malloc() problem
661
* -3: lame_init_params() not called
662
* -4: psycho acoustic problems
664
* The required mp3buf_size can be computed from num_samples,
665
* samplerate and encoding rate, but here is a worst case estimate:
667
* mp3buf_size in bytes = 1.25*num_samples + 7200
669
* I think a tighter bound could be: (mt, March 2000)
671
* num_samples*(bitrate/8)/samplerate + 4*1152*(bitrate/8)/samplerate + 512
673
* num_samples*(bitrate/8)/samplerate + 4*576*(bitrate/8)/samplerate + 256
675
* but test first if you use that!
677
* set mp3buf_size = 0 and LAME will not check if mp3buf_size is
681
* if gfp->num_channels=2, but gfp->mode = 3 (mono), the L & R channels
682
* will be averaged into the L channel before encoding only the L channel
683
* This will overwrite the data in buffer_l[] and buffer_r[].
686
int CDECL lame_encode_buffer (
687
lame_global_flags* gfp, /* global context handle */
688
const short int buffer_l [], /* PCM data for left channel */
689
const short int buffer_r [], /* PCM data for right channel */
690
const int nsamples, /* number of samples per channel */
691
unsigned char* mp3buf, /* pointer to encoded MP3 stream */
692
const int mp3buf_size ); /* number of valid octets in this
696
* as above, but input has L & R channel data interleaved.
698
* num_samples = number of samples in the L (or R)
699
* channel, not the total number of samples in pcm[]
701
int CDECL lame_encode_buffer_interleaved(
702
lame_global_flags* gfp, /* global context handlei */
703
short int pcm[], /* PCM data for left and right
704
channel, interleaved */
705
int num_samples, /* number of samples per channel,
706
_not_ number of samples in
708
unsigned char* mp3buf, /* pointer to encoded MP3 stream */
709
int mp3buf_size ); /* number of valid octets in this
713
/* as lame_encode_buffer, but for 'float's.
714
* !! NOTE: !! data must still be scaled to be in the same range as
715
* short int, +/- 32768
717
int CDECL lame_encode_buffer_float(
718
lame_global_flags* gfp, /* global context handle */
719
const float buffer_l [], /* PCM data for left channel */
720
const float buffer_r [], /* PCM data for right channel */
721
const int nsamples, /* number of samples per channel */
722
unsigned char* mp3buf, /* pointer to encoded MP3 stream */
723
const int mp3buf_size ); /* number of valid octets in this
727
/* as lame_encode_buffer, but for long's
728
* !! NOTE: !! data must still be scaled to be in the same range as
729
* short int, +/- 32768
731
* This scaling was a mistake (doesn't allow one to exploit full
732
* precision of type 'long'. Use lame_encode_buffer_long2() instead.
735
int CDECL lame_encode_buffer_long(
736
lame_global_flags* gfp, /* global context handle */
737
const long buffer_l [], /* PCM data for left channel */
738
const long buffer_r [], /* PCM data for right channel */
739
const int nsamples, /* number of samples per channel */
740
unsigned char* mp3buf, /* pointer to encoded MP3 stream */
741
const int mp3buf_size ); /* number of valid octets in this
744
/* Same as lame_encode_buffer_long(), but with correct scaling.
745
* !! NOTE: !! data must still be scaled to be in the same range as
746
* type 'long'. Data should be in the range: +/- 2^(8*size(long)-1)
749
int CDECL lame_encode_buffer_long2(
750
lame_global_flags* gfp, /* global context handle */
751
const long buffer_l [], /* PCM data for left channel */
752
const long buffer_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
758
/* as lame_encode_buffer, but for int's
759
* !! NOTE: !! input should be scaled to the maximum range of 'int'
760
* If int is 4 bytes, then the values should range from
763
* This routine does not (and cannot, without loosing precision) use
764
* the same scaling as the rest of the lame_encode_buffer() routines.
767
int CDECL lame_encode_buffer_int(
768
lame_global_flags* gfp, /* global context handle */
769
const int buffer_l [], /* PCM data for left channel */
770
const int buffer_r [], /* PCM data for right channel */
771
const int nsamples, /* number of samples per channel */
772
unsigned char* mp3buf, /* pointer to encoded MP3 stream */
773
const int mp3buf_size ); /* number of valid octets in this
782
* lame_encode_flush will flush the intenal PCM buffers, padding with
783
* 0's to make sure the final frame is complete, and then flush
784
* the internal MP3 buffers, and thus may return a
785
* final few mp3 frames. 'mp3buf' should be at least 7200 bytes long
786
* to hold all possible emitted data.
788
* will also write id3v1 tags (if any) into the bitstream
790
* return code = number of bytes output to mp3buf. Can be 0
792
int CDECL lame_encode_flush(
793
lame_global_flags * gfp, /* global context handle */
794
unsigned char* mp3buf, /* pointer to encoded MP3 stream */
795
int size); /* number of valid octets in this stream */
799
* lame_encode_flush_nogap will flush the internal mp3 buffers and pad
800
* the last frame with ancillary data so it is a complete mp3 frame.
802
* 'mp3buf' should be at least 7200 bytes long
803
* to hold all possible emitted data.
805
* After a call to this routine, the outputed mp3 data is complete, but
806
* you may continue to encode new PCM samples and write future mp3 data
807
* to a different file. The two mp3 files will play back with no gaps
808
* if they are concatenated together.
810
* This routine will NOT write id3v1 tags into the bitstream.
812
* return code = number of bytes output to mp3buf. Can be 0
814
int CDECL lame_encode_flush_nogap(
815
lame_global_flags * gfp, /* global context handle */
816
unsigned char* mp3buf, /* pointer to encoded MP3 stream */
817
int size); /* number of valid octets in this stream */
821
* Normally, this is called by lame_init_params(). It writes id3v2 and
822
* Xing headers into the front of the bitstream, and sets frame counters
823
* and bitrate histogram data to 0. You can also call this after
824
* lame_encode_flush_nogap().
826
int CDECL lame_init_bitstream(
827
lame_global_flags * gfp); /* global context handle */
832
* OPTIONAL: some simple statistics
833
* a bitrate histogram to visualize the distribution of used frame sizes
834
* a stereo mode histogram to visualize the distribution of used stereo
835
* modes, useful in joint-stereo mode only
836
* 0: LR left-right encoded
837
* 1: LR-I left-right and intensity encoded (currently not supported)
838
* 2: MS mid-side encoded
839
* 3: MS-I mid-side and intensity encoded (currently not supported)
841
* attention: don't call them after lame_encode_finish
842
* suggested: lame_encode_flush -> lame_*_hist -> lame_close
845
void CDECL lame_bitrate_hist(
846
const lame_global_flags *const gfp,
847
int bitrate_count[14] );
848
void CDECL lame_bitrate_kbps(
849
const lame_global_flags *const gfp,
850
int bitrate_kbps [14] );
851
void CDECL lame_stereo_mode_hist(
852
const lame_global_flags *const gfp,
853
int stereo_mode_count[4] );
855
void CDECL lame_bitrate_stereo_mode_hist (
856
const lame_global_flags * const gfp,
857
int bitrate_stmode_count [14] [4] );
859
void CDECL lame_block_type_hist (
860
const lame_global_flags * const gfp,
861
int btype_count[6] );
863
void CDECL lame_bitrate_block_type_hist (
864
const lame_global_flags * const gfp,
865
int bitrate_btype_count[14][6] );
870
* lame_mp3_tags_fid will append a Xing VBR tag to the mp3 file with file
871
* pointer fid. These calls perform forward and backwards seeks, so make
872
* sure fid is a real file. Make sure lame_encode_flush has been called,
873
* and all mp3 data has been written to the file before calling this
876
* if VBR tags are turned off by the user, or turned off by LAME because
877
* the output is not a regular file, this call does nothing
879
void CDECL lame_mp3_tags_fid(lame_global_flags *,FILE* fid);
884
* final call to free all remaining buffers
886
int CDECL lame_close (lame_global_flags *);
890
* lame_encode_finish combines lame_encode_flush() and lame_close() in
891
* one call. However, once this call is made, the statistics routines
892
* will no longer work because the data will have been cleared, and
893
* lame_mp3_tags_fid() cannot be called to add data to the VBR header
895
int CDECL lame_encode_finish(
896
lame_global_flags* gfp,
897
unsigned char* mp3buf,
906
/*********************************************************************
910
* a simple interface to mpglib, part of mpg123, is also included if
911
* libmp3lame is compiled with HAVE_MPGLIB
913
*********************************************************************/
915
int header_parsed; /* 1 if header was parsed and following data was
917
int stereo; /* number of channels */
918
int samplerate; /* sample rate */
919
int bitrate; /* bitrate */
920
int mode; /* mp3 frame type */
921
int mode_ext; /* mp3 frame type */
922
int framesize; /* number of samples per mp3 frame */
924
/* this data is only computed if mpglib detects a Xing VBR header */
925
unsigned long nsamp; /* number of samples in mp3 file. */
926
int totalframes; /* total number of frames in mp3 file */
928
/* this data is not currently computed by the mpglib routines */
929
int framenum; /* frames decoded counter */
933
/* required call to initialize decoder
934
* NOTE: the decoder should not be used when encoding is performed
935
* with decoding on the fly */
936
int CDECL lame_decode_init(void);
938
/*********************************************************************
939
* input 1 mp3 frame, output (maybe) pcm data.
941
* nout = lame_decode(mp3buf,len,pcm_l,pcm_r);
944
* len : number of bytes of mp3 data in mp3buf
945
* mp3buf[len] : mp3 data to be decoded
948
* nout: -1 : decoding error
949
* 0 : need more data before we can complete the decode
950
* >0 : returned 'nout' samples worth of data in pcm_l,pcm_r
951
* pcm_l[nout] : left channel data
952
* pcm_r[nout] : right channel data
954
*********************************************************************/
955
int CDECL lame_decode(
956
unsigned char * mp3buf,
961
/* same as lame_decode, and also returns mp3 header data */
962
int CDECL lame_decode_headers(
963
unsigned char* mp3buf,
967
mp3data_struct* mp3data );
969
/* same as lame_decode, but returns at most one frame */
970
int CDECL lame_decode1(
971
unsigned char* mp3buf,
976
/* same as lame_decode1, but returns at most one frame and mp3 header data */
977
int CDECL lame_decode1_headers(
978
unsigned char* mp3buf,
982
mp3data_struct* mp3data );
984
/* same as lame_decode1_headers, but also returns enc_delay and enc_padding
985
from VBR Info tag, (-1 if no info tag was found) */
986
int CDECL lame_decode1_headersB(
987
unsigned char* mp3buf,
991
mp3data_struct* mp3data,
996
/* cleanup call to exit decoder */
997
int CDECL lame_decode_exit(void);
1001
/*********************************************************************
1005
*********************************************************************/
1008
* id3tag.h -- Interface to write ID3 version 1 and 2 tags.
1010
* Copyright (C) 2000 Don Melton.
1012
* This library is free software; you can redistribute it and/or
1013
* modify it under the terms of the GNU Library General Public
1014
* License as published by the Free Software Foundation; either
1015
* version 2 of the License, or (at your option) any later version.
1017
* This library is distributed in the hope that it will be useful,
1018
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1019
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1020
* Library General Public License for more details.
1022
* You should have received a copy of the GNU Library General Public
1023
* License along with this library; if not, write to the Free Software
1024
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
1027
/* utility to obtain alphabetically sorted list of genre names with numbers */
1028
extern void id3tag_genre_list(
1029
void (*handler)(int, const char *, void *),
1032
extern void id3tag_init (lame_global_flags *gfp);
1034
/* force addition of version 2 tag */
1035
extern void id3tag_add_v2 (lame_global_flags *gfp);
1037
/* add only a version 1 tag */
1038
extern void id3tag_v1_only (lame_global_flags *gfp);
1040
/* add only a version 2 tag */
1041
extern void id3tag_v2_only (lame_global_flags *gfp);
1043
/* pad version 1 tag with spaces instead of nulls */
1044
extern void id3tag_space_v1 (lame_global_flags *gfp);
1046
/* pad version 2 tag with extra 128 bytes */
1047
extern void id3tag_pad_v2 (lame_global_flags *gfp);
1049
extern void id3tag_set_title(
1050
lame_global_flags* gfp,
1051
const char* title );
1052
extern void id3tag_set_artist(
1053
lame_global_flags* gfp,
1054
const char* artist );
1055
extern void id3tag_set_album(
1056
lame_global_flags* gfp,
1057
const char* album );
1058
extern void id3tag_set_year(
1059
lame_global_flags* gfp,
1061
extern void id3tag_set_comment(
1062
lame_global_flags* gfp,
1063
const char* comment );
1064
extern void id3tag_set_track(
1065
lame_global_flags* gfp,
1066
const char* track );
1068
/* return non-zero result if genre name or number is invalid */
1069
extern int id3tag_set_genre(
1070
lame_global_flags* gfp,
1071
const char* genre );
1073
/***********************************************************************
1075
* list of valid bitrates [kbps] & sample frequencies [Hz].
1076
* first index: 0: MPEG-2 values (sample frequencies 16...24 kHz)
1077
* 1: MPEG-1 values (sample frequencies 32...48 kHz)
1078
* 2: MPEG-2.5 values (sample frequencies 8...12 kHz)
1079
***********************************************************************/
1080
extern const int bitrate_table [3] [16];
1081
extern const int samplerate_table [3] [ 4];
1085
/* maximum size of mp3buffer needed if you encode at most 1152 samples for
1086
each call to lame_encode_buffer. see lame_encode_buffer() below
1087
(LAME_MAXMP3BUFFER is now obsolete) */
1088
#define LAME_MAXMP3BUFFER 16384
1094
LAME_GENERICERROR = -1,
1096
LAME_BADBITRATE = -11,
1097
LAME_BADSAMPFREQ = -12,
1098
LAME_INTERNALERROR = -13,
1100
FRONTEND_READERROR = -80,
1101
FRONTEND_WRITEERROR = -81,
1102
FRONTEND_FILETOOLARGE = -82
1104
} lame_errorcodes_t;
1106
#if defined(__cplusplus)
1109
#endif /* LAME_LAME_H */