lame.h   lame.h 
/* /*
* Interface to MP3 LAME encoding engine * Interface to MP3 LAME encoding engine
* *
* Copyright (c) 1999 Mark Taylor * Copyright (c) 1999 Mark Taylor
* *
* This program is free software; you can redistribute it and/or modify * This library is free software; you can redistribute it and/or
* it under the terms of the GNU General Public License as published by * modify it under the terms of the GNU Lesser General Public
* the Free Software Foundation; either version 2, or (at your option) * License as published by the Free Software Foundation; either
* any later version. * version 2 of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* GNU General Public License for more details. * Library General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU Lesser General Public
* along with this program; see the file COPYING. If not, write to * License along with this library; if not, write to the
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
/* $Id: lame.h,v 1.154 2004/04/11 15:39:53 glessard Exp $ */ /* $Id: lame.h,v 1.170.2.4 2009/01/18 15:44:28 robert Exp $ */
#ifndef LAME_LAME_H #ifndef LAME_LAME_H
#define LAME_LAME_H #define LAME_LAME_H
#include <stdio.h> /* for size_t typedef */
#include <stddef.h>
/* for va_list typedef */
#include <stdarg.h> #include <stdarg.h>
/* for FILE typedef, TODO: remove when removing lame_mp3_tags_fid */
#include <stdio.h>
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
#if defined(WIN32) #if defined(WIN32) || defined(_WIN32)
#undef CDECL #undef CDECL
#define CDECL _cdecl #define CDECL __cdecl
#else #else
#define CDECL #define CDECL
#endif #endif
#define DEPRECATED_OR_OBSOLETE_CODE_REMOVED 1
typedef enum vbr_mode_e { typedef enum vbr_mode_e {
vbr_off=0, vbr_off=0,
vbr_mt, /* obsolete, same as vbr_mtrh */ vbr_mt, /* obsolete, same as vbr_mtrh */
vbr_rh, vbr_rh,
vbr_abr, vbr_abr,
vbr_mtrh, vbr_mtrh,
vbr_max_indicator, /* Don't use this! It's used for sanity checks. */ vbr_max_indicator, /* Don't use this! It's used for sanity checks. */
vbr_default=vbr_rh /* change this to change the default VBR mode of LA ME */ vbr_default=vbr_mtrh /* change this to change the default VBR mode of LAME */
} vbr_mode; } vbr_mode;
/* MPEG modes */ /* MPEG modes */
typedef enum MPEG_mode_e { typedef enum MPEG_mode_e {
STEREO = 0, STEREO = 0,
JOINT_STEREO, JOINT_STEREO,
DUAL_CHANNEL, /* LAME doesn't supports this! */ DUAL_CHANNEL, /* LAME doesn't supports this! */
MONO, MONO,
NOT_SET, NOT_SET,
MAX_INDICATOR /* Don't use this! It's used for sanity checks. */ MAX_INDICATOR /* Don't use this! It's used for sanity checks. */
skipping to change at line 140 skipping to change at line 147
***********************************************************************/ ***********************************************************************/
/* /*
* REQUIRED: * REQUIRED:
* initialize the encoder. sets default for all encoder parameters, * initialize the encoder. sets default for all encoder parameters,
* returns NULL if some malloc()'s failed * returns NULL if some malloc()'s failed
* otherwise returns pointer to structure needed for all future * otherwise returns pointer to structure needed for all future
* API calls. * API calls.
*/ */
lame_global_flags * CDECL lame_init(void); lame_global_flags * CDECL lame_init(void);
#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
#else
/* obsolete version */ /* obsolete version */
int CDECL lame_init_old(lame_global_flags *); int CDECL lame_init_old(lame_global_flags *);
#endif
/* /*
* OPTIONAL: * OPTIONAL:
* set as needed to override defaults * set as needed to override defaults
*/ */
/******************************************************************** /********************************************************************
* input stream description * input stream description
***********************************************************************/ ***********************************************************************/
/* number of samples. default = 2^32-1 */ /* number of samples. default = 2^32-1 */
skipping to change at line 216 skipping to change at line 226
default = 1 default = 1
this variable must have been added by a Hungarian notation Windows progra mmer :-) this variable must have been added by a Hungarian notation Windows progra mmer :-)
*/ */
int CDECL lame_set_bWriteVbrTag(lame_global_flags *, int); int CDECL lame_set_bWriteVbrTag(lame_global_flags *, int);
int CDECL lame_get_bWriteVbrTag(const lame_global_flags *); int CDECL lame_get_bWriteVbrTag(const lame_global_flags *);
/* 1=decode only. use lame/mpglib to convert mp3/ogg to wav. default=0 */ /* 1=decode only. use lame/mpglib to convert mp3/ogg to wav. default=0 */
int CDECL lame_set_decode_only(lame_global_flags *, int); int CDECL lame_set_decode_only(lame_global_flags *, int);
int CDECL lame_get_decode_only(const lame_global_flags *); int CDECL lame_get_decode_only(const lame_global_flags *);
#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
#else
/* 1=encode a Vorbis .ogg file. default=0 */ /* 1=encode a Vorbis .ogg file. default=0 */
/* DEPRECATED */ /* DEPRECATED */
int CDECL lame_set_ogg(lame_global_flags *, int); int CDECL lame_set_ogg(lame_global_flags *, int);
int CDECL lame_get_ogg(const lame_global_flags *); int CDECL lame_get_ogg(const lame_global_flags *);
#endif
/* /*
internal algorithm selection. True quality is determined by the bitrate internal algorithm selection. True quality is determined by the bitrate
but this variable will effect quality by selecting expensive or cheap alg orithms. but this variable will effect quality by selecting expensive or cheap alg orithms.
quality=0..9. 0=best (very slow). 9=worst. quality=0..9. 0=best (very slow). 9=worst.
recommended: 2 near-best quality, not too slow recommended: 2 near-best quality, not too slow
5 good quality, fast 5 good quality, fast
7 ok quality, really fast 7 ok quality, really fast
*/ */
int CDECL lame_set_quality(lame_global_flags *, int); int CDECL lame_set_quality(lame_global_flags *, int);
int CDECL lame_get_quality(const lame_global_flags *); int CDECL lame_get_quality(const lame_global_flags *);
/* /*
mode = 0,1,2,3 = stereo, jstereo, dual channel (not supported), mono mode = 0,1,2,3 = stereo, jstereo, dual channel (not supported), mono
default: lame picks based on compression ration and input channels default: lame picks based on compression ration and input channels
*/ */
int CDECL lame_set_mode(lame_global_flags *, MPEG_mode); int CDECL lame_set_mode(lame_global_flags *, MPEG_mode);
MPEG_mode CDECL lame_get_mode(const lame_global_flags *); MPEG_mode CDECL lame_get_mode(const lame_global_flags *);
#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
#else
/* /*
mode_automs. Use a M/S mode with a switching threshold based on mode_automs. Use a M/S mode with a switching threshold based on
compression ratio compression ratio
DEPRECATED DEPRECATED
*/ */
int CDECL lame_set_mode_automs(lame_global_flags *, int); int CDECL lame_set_mode_automs(lame_global_flags *, int);
int CDECL lame_get_mode_automs(const lame_global_flags *); int CDECL lame_get_mode_automs(const lame_global_flags *);
#endif
/* /*
force_ms. Force M/S for all frames. For testing only. force_ms. Force M/S for all frames. For testing only.
default = 0 (disabled) default = 0 (disabled)
*/ */
int CDECL lame_set_force_ms(lame_global_flags *, int); int CDECL lame_set_force_ms(lame_global_flags *, int);
int CDECL lame_get_force_ms(const lame_global_flags *); int CDECL lame_get_force_ms(const lame_global_flags *);
/* use free_format? default = 0 (disabled) */ /* use free_format? default = 0 (disabled) */
int CDECL lame_set_free_format(lame_global_flags *, int); int CDECL lame_set_free_format(lame_global_flags *, int);
skipping to change at line 269 skipping to change at line 285
int CDECL lame_set_findReplayGain(lame_global_flags *, int); int CDECL lame_set_findReplayGain(lame_global_flags *, int);
int CDECL lame_get_findReplayGain(const lame_global_flags *); int CDECL lame_get_findReplayGain(const lame_global_flags *);
/* decode on the fly. Search for the peak sample. If the ReplayGain /* decode on the fly. Search for the peak sample. If the ReplayGain
* analysis is enabled then perform the analysis on the decoded data * analysis is enabled then perform the analysis on the decoded data
* stream. default = 0 (disabled) * stream. default = 0 (disabled)
* NOTE: if this option is set the build-in decoder should not be used */ * NOTE: if this option is set the build-in decoder should not be used */
int CDECL lame_set_decode_on_the_fly(lame_global_flags *, int); int CDECL lame_set_decode_on_the_fly(lame_global_flags *, int);
int CDECL lame_get_decode_on_the_fly(const lame_global_flags *); int CDECL lame_get_decode_on_the_fly(const lame_global_flags *);
#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
#else
/* DEPRECATED: now does the same as lame_set_findReplayGain() /* DEPRECATED: now does the same as lame_set_findReplayGain()
default = 0 (disabled) */ default = 0 (disabled) */
int CDECL lame_set_ReplayGain_input(lame_global_flags *, int); int CDECL lame_set_ReplayGain_input(lame_global_flags *, int);
int CDECL lame_get_ReplayGain_input(const lame_global_flags *); int CDECL lame_get_ReplayGain_input(const lame_global_flags *);
/* DEPRECATED: now does the same as /* DEPRECATED: now does the same as
lame_set_decode_on_the_fly() && lame_set_findReplayGain() lame_set_decode_on_the_fly() && lame_set_findReplayGain()
default = 0 (disabled) */ default = 0 (disabled) */
int CDECL lame_set_ReplayGain_decode(lame_global_flags *, int); int CDECL lame_set_ReplayGain_decode(lame_global_flags *, int);
int CDECL lame_get_ReplayGain_decode(const lame_global_flags *); int CDECL lame_get_ReplayGain_decode(const lame_global_flags *);
/* DEPRECATED: now does the same as lame_set_decode_on_the_fly() /* DEPRECATED: now does the same as lame_set_decode_on_the_fly()
default = 0 (disabled) */ default = 0 (disabled) */
int CDECL lame_set_findPeakSample(lame_global_flags *, int); int CDECL lame_set_findPeakSample(lame_global_flags *, int);
int CDECL lame_get_findPeakSample(const lame_global_flags *); int CDECL lame_get_findPeakSample(const lame_global_flags *);
#endif
/* counters for gapless encoding */ /* counters for gapless encoding */
int CDECL lame_set_nogap_total(lame_global_flags*, int); int CDECL lame_set_nogap_total(lame_global_flags*, int);
int CDECL lame_get_nogap_total(const lame_global_flags*); int CDECL lame_get_nogap_total(const lame_global_flags*);
int CDECL lame_set_nogap_currentindex(lame_global_flags* , int); int CDECL lame_set_nogap_currentindex(lame_global_flags* , int);
int CDECL lame_get_nogap_currentindex(const lame_global_flags*); int CDECL lame_get_nogap_currentindex(const lame_global_flags*);
/* /*
* OPTIONAL: * OPTIONAL:
skipping to change at line 336 skipping to change at line 355
int CDECL lame_get_copyright(const lame_global_flags *); int CDECL lame_get_copyright(const lame_global_flags *);
/* mark as original. default=1 */ /* mark as original. default=1 */
int CDECL lame_set_original(lame_global_flags *, int); int CDECL lame_set_original(lame_global_flags *, int);
int CDECL lame_get_original(const lame_global_flags *); int CDECL lame_get_original(const lame_global_flags *);
/* error_protection. Use 2 bytes from each frame for CRC checksum. default =0 */ /* error_protection. Use 2 bytes from each frame for CRC checksum. default =0 */
int CDECL lame_set_error_protection(lame_global_flags *, int); int CDECL lame_set_error_protection(lame_global_flags *, int);
int CDECL lame_get_error_protection(const lame_global_flags *); int CDECL lame_get_error_protection(const lame_global_flags *);
#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
#else
/* padding_type. 0=pad no frames 1=pad all frames 2=adjust padding(default ) */ /* padding_type. 0=pad no frames 1=pad all frames 2=adjust padding(default ) */
int CDECL lame_set_padding_type(lame_global_flags *, Padding_type); int CDECL lame_set_padding_type(lame_global_flags *, Padding_type);
Padding_type CDECL lame_get_padding_type(const lame_global_flags *); Padding_type CDECL lame_get_padding_type(const lame_global_flags *);
#endif
/* MP3 'private extension' bit Meaningless. default=0 */ /* MP3 'private extension' bit Meaningless. default=0 */
int CDECL lame_set_extension(lame_global_flags *, int); int CDECL lame_set_extension(lame_global_flags *, int);
int CDECL lame_get_extension(const lame_global_flags *); int CDECL lame_get_extension(const lame_global_flags *);
/* enforce strict ISO compliance. default=0 */ /* enforce strict ISO compliance. default=0 */
int CDECL lame_set_strict_ISO(lame_global_flags *, int); int CDECL lame_set_strict_ISO(lame_global_flags *, int);
int CDECL lame_get_strict_ISO(const lame_global_flags *); int CDECL lame_get_strict_ISO(const lame_global_flags *);
/******************************************************************** /********************************************************************
skipping to change at line 380 skipping to change at line 402
int CDECL lame_set_experimentalZ(lame_global_flags *, int); int CDECL lame_set_experimentalZ(lame_global_flags *, int);
int CDECL lame_get_experimentalZ(const lame_global_flags *); int CDECL lame_get_experimentalZ(const lame_global_flags *);
/* Naoki's psycho acoustic model. default=0 */ /* Naoki's psycho acoustic model. default=0 */
int CDECL lame_set_exp_nspsytune(lame_global_flags *, int); int CDECL lame_set_exp_nspsytune(lame_global_flags *, int);
int CDECL lame_get_exp_nspsytune(const lame_global_flags *); int CDECL lame_get_exp_nspsytune(const lame_global_flags *);
void CDECL lame_set_msfix(lame_global_flags *, double); void CDECL lame_set_msfix(lame_global_flags *, double);
float CDECL lame_get_msfix(const lame_global_flags *); float CDECL lame_get_msfix(const lame_global_flags *);
int lame_set_exp_nspsytune2_int( lame_global_flags*, int, int);
float lame_set_exp_nspsytune2_real( lame_global_flags*, int, float);
void * lame_set_exp_nspsytune2_pointer( lame_global_flags*, int, void *);
/******************************************************************** /********************************************************************
* VBR control * VBR control
***********************************************************************/ ***********************************************************************/
/* Types of VBR. default = vbr_off = CBR */ /* Types of VBR. default = vbr_off = CBR */
int CDECL lame_set_VBR(lame_global_flags *, vbr_mode); int CDECL lame_set_VBR(lame_global_flags *, vbr_mode);
vbr_mode CDECL lame_get_VBR(const lame_global_flags *); vbr_mode CDECL lame_get_VBR(const lame_global_flags *);
/* VBR quality level. 0=highest 9=lowest */ /* VBR quality level. 0=highest 9=lowest */
int CDECL lame_set_VBR_q(lame_global_flags *, int); int CDECL lame_set_VBR_q(lame_global_flags *, int);
int CDECL lame_get_VBR_q(const lame_global_flags *); int CDECL lame_get_VBR_q(const lame_global_flags *);
/* VBR quality level. 0=highest 9=lowest, Range [0,...,10[ */
int CDECL lame_set_VBR_quality(lame_global_flags *, float);
float CDECL lame_get_VBR_quality(const lame_global_flags *);
/* Ignored except for VBR=vbr_abr (ABR mode) */ /* Ignored except for VBR=vbr_abr (ABR mode) */
int CDECL lame_set_VBR_mean_bitrate_kbps(lame_global_flags *, int); int CDECL lame_set_VBR_mean_bitrate_kbps(lame_global_flags *, int);
int CDECL lame_get_VBR_mean_bitrate_kbps(const lame_global_flags *); int CDECL lame_get_VBR_mean_bitrate_kbps(const lame_global_flags *);
int CDECL lame_set_VBR_min_bitrate_kbps(lame_global_flags *, int); int CDECL lame_set_VBR_min_bitrate_kbps(lame_global_flags *, int);
int CDECL lame_get_VBR_min_bitrate_kbps(const lame_global_flags *); int CDECL lame_get_VBR_min_bitrate_kbps(const lame_global_flags *);
int CDECL lame_set_VBR_max_bitrate_kbps(lame_global_flags *, int); int CDECL lame_set_VBR_max_bitrate_kbps(lame_global_flags *, int);
int CDECL lame_get_VBR_max_bitrate_kbps(const lame_global_flags *); int CDECL lame_get_VBR_max_bitrate_kbps(const lame_global_flags *);
/* /*
1=strictly enforce VBR_min_bitrate. Normally it will be violated for 1=strictly enforce VBR_min_bitrate. Normally it will be violated for
analog silence analog silence
*/ */
int CDECL lame_set_VBR_hard_min(lame_global_flags *, int); int CDECL lame_set_VBR_hard_min(lame_global_flags *, int);
int CDECL lame_get_VBR_hard_min(const lame_global_flags *); int CDECL lame_get_VBR_hard_min(const lame_global_flags *);
/* for preset */ /* for preset */
#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
#else
int CDECL lame_set_preset_expopts(lame_global_flags *, int); int CDECL lame_set_preset_expopts(lame_global_flags *, int);
#endif
/******************************************************************** /********************************************************************
* Filtering control * Filtering control
***********************************************************************/ ***********************************************************************/
/* freq in Hz to apply lowpass. Default = 0 = lame chooses. -1 = disabled */ /* freq in Hz to apply lowpass. Default = 0 = lame chooses. -1 = disabled */
int CDECL lame_set_lowpassfreq(lame_global_flags *, int); int CDECL lame_set_lowpassfreq(lame_global_flags *, int);
int CDECL lame_get_lowpassfreq(const lame_global_flags *); int CDECL lame_get_lowpassfreq(const lame_global_flags *);
/* width of transition band, in Hz. Default = one polyphase filter band */ /* width of transition band, in Hz. Default = one polyphase filter band */
int CDECL lame_set_lowpasswidth(lame_global_flags *, int); int CDECL lame_set_lowpasswidth(lame_global_flags *, int);
int CDECL lame_get_lowpasswidth(const lame_global_flags *); int CDECL lame_get_lowpasswidth(const lame_global_flags *);
skipping to change at line 469 skipping to change at line 494
int CDECL lame_get_athaa_type( const lame_global_flags *); int CDECL lame_get_athaa_type( const lame_global_flags *);
/* select the loudness approximation used by the ATH adaptive auto-leveling */ /* select the loudness approximation used by the ATH adaptive auto-leveling */
int CDECL lame_set_athaa_loudapprox( lame_global_flags *, int); int CDECL lame_set_athaa_loudapprox( lame_global_flags *, int);
int CDECL lame_get_athaa_loudapprox( const lame_global_flags *); int CDECL lame_get_athaa_loudapprox( const lame_global_flags *);
/* adjust (in dB) the point below which adaptive ATH level adjustment occur s */ /* adjust (in dB) the point below which adaptive ATH level adjustment occur s */
int CDECL lame_set_athaa_sensitivity( lame_global_flags *, float); int CDECL lame_set_athaa_sensitivity( lame_global_flags *, float);
float CDECL lame_get_athaa_sensitivity( const lame_global_flags* ); float CDECL lame_get_athaa_sensitivity( const lame_global_flags* );
/* predictability limit (ISO tonality formula) */ #if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
#else
/* OBSOLETE: predictability limit (ISO tonality formula) */
int CDECL lame_set_cwlimit(lame_global_flags *, int); int CDECL lame_set_cwlimit(lame_global_flags *, int);
int CDECL lame_get_cwlimit(const lame_global_flags *); int CDECL lame_get_cwlimit(const lame_global_flags *);
#endif
/* /*
allow blocktypes to differ between channels? allow blocktypes to differ between channels?
default: 0 for jstereo, 1 for stereo default: 0 for jstereo, 1 for stereo
*/ */
int CDECL lame_set_allow_diff_short(lame_global_flags *, int); int CDECL lame_set_allow_diff_short(lame_global_flags *, int);
int CDECL lame_get_allow_diff_short(const lame_global_flags *); int CDECL lame_get_allow_diff_short(const lame_global_flags *);
/* use temporal masking effect (default = 1) */ /* use temporal masking effect (default = 1) */
int CDECL lame_set_useTemporal(lame_global_flags *, int); int CDECL lame_set_useTemporal(lame_global_flags *, int);
skipping to change at line 554 skipping to change at line 582
/* RadioGain value. Multiplied by 10 and rounded to the nearest. */ /* RadioGain value. Multiplied by 10 and rounded to the nearest. */
int CDECL lame_get_RadioGain(const lame_global_flags *); int CDECL lame_get_RadioGain(const lame_global_flags *);
/* AudiophileGain value. Multipled by 10 and rounded to the nearest. */ /* AudiophileGain value. Multipled by 10 and rounded to the nearest. */
int CDECL lame_get_AudiophileGain(const lame_global_flags *); int CDECL lame_get_AudiophileGain(const lame_global_flags *);
/* the peak sample */ /* the peak sample */
float CDECL lame_get_PeakSample(const lame_global_flags *); float CDECL lame_get_PeakSample(const lame_global_flags *);
/* is decoding on the fly performed */
int CDECL lame_get_decode_on_the_fly(const lame_global_flags *);
/* is ReplayGain analysis performed */
int CDECL lame_get_findReplayGain(const lame_global_flags *);
/* Gain change required for preventing clipping. The value is correct only if /* Gain change required for preventing clipping. The value is correct only if
peak sample searching was enabled. If negative then the waveform peak sample searching was enabled. If negative then the waveform
already does not clip. The value is multiplied by 10 and rounded up. */ already does not clip. The value is multiplied by 10 and rounded up. */
int CDECL lame_get_noclipGainChange(const lame_global_flags *); int CDECL lame_get_noclipGainChange(const lame_global_flags *);
/* user-specified scale factor required for preventing clipping. Value is /* user-specified scale factor required for preventing clipping. Value is
correct only if peak sample searching was enabled and no user-specified correct only if peak sample searching was enabled and no user-specified
scaling was performed. If negative then either the waveform already does scaling was performed. If negative then either the waveform already does
not clip or the value cannot be determined */ not clip or the value cannot be determined */
float CDECL lame_get_noclipScale(const lame_global_flags *); float CDECL lame_get_noclipScale(const lame_global_flags *);
/* /*
* REQUIRED: * REQUIRED:
* sets more internal configuration based on data provided above. * sets more internal configuration based on data provided above.
* returns -1 if something failed. * returns -1 if something failed.
*/ */
int CDECL lame_init_params(lame_global_flags * const ); int CDECL lame_init_params(lame_global_flags *);
/* /*
* OPTIONAL: * OPTIONAL:
* get the version number, in a string. of the form: * get the version number, in a string. of the form:
* "3.63 (beta)" or just "3.63". * "3.63 (beta)" or just "3.63".
*/ */
const char* CDECL get_lame_version ( void ); const char* CDECL get_lame_version ( void );
const char* CDECL get_lame_short_version ( void ); const char* CDECL get_lame_short_version ( void );
const char* CDECL get_lame_very_short_version ( void ); const char* CDECL get_lame_very_short_version ( void );
const char* CDECL get_psy_version ( void ); const char* CDECL get_psy_version ( void );
const char* CDECL get_lame_url ( void ); const char* CDECL get_lame_url ( void );
const char* CDECL get_lame_os_bitness ( void );
/* /*
* OPTIONAL: * OPTIONAL:
* get the version numbers in numerical form. * get the version numbers in numerical form.
*/ */
typedef struct { typedef struct {
/* generic LAME version */ /* generic LAME version */
int major; int major;
int minor; int minor;
int alpha; /* 0 if not an alpha version */ int alpha; /* 0 if not an alpha version */
skipping to change at line 609 skipping to change at line 632
/* version of the psy model */ /* version of the psy model */
int psy_major; int psy_major;
int psy_minor; int psy_minor;
int psy_alpha; /* 0 if not an alpha version */ int psy_alpha; /* 0 if not an alpha version */
int psy_beta; /* 0 if not a beta version */ int psy_beta; /* 0 if not a beta version */
/* compile time features */ /* compile time features */
const char *features; /* Don't make assumptions about the contents! */ const char *features; /* Don't make assumptions about the contents! */
} lame_version_t; } lame_version_t;
void CDECL get_lame_version_numerical ( lame_version_t *const ); void CDECL get_lame_version_numerical(lame_version_t *);
/* /*
* OPTIONAL: * OPTIONAL:
* print internal lame configuration to message handler * print internal lame configuration to message handler
*/ */
void CDECL lame_print_config(const lame_global_flags* gfp); void CDECL lame_print_config(const lame_global_flags* gfp);
void CDECL lame_print_internals( const lame_global_flags *gfp); void CDECL lame_print_internals( const lame_global_flags *gfp);
/* /*
skipping to change at line 803 skipping to change at line 826
* 0: LR left-right encoded * 0: LR left-right encoded
* 1: LR-I left-right and intensity encoded (currently not supported) * 1: LR-I left-right and intensity encoded (currently not supported)
* 2: MS mid-side encoded * 2: MS mid-side encoded
* 3: MS-I mid-side and intensity encoded (currently not supported) * 3: MS-I mid-side and intensity encoded (currently not supported)
* *
* attention: don't call them after lame_encode_finish * attention: don't call them after lame_encode_finish
* suggested: lame_encode_flush -> lame_*_hist -> lame_close * suggested: lame_encode_flush -> lame_*_hist -> lame_close
*/ */
void CDECL lame_bitrate_hist( void CDECL lame_bitrate_hist(
const lame_global_flags *const gfp, const lame_global_flags * gfp,
int bitrate_count[14] ); int bitrate_count[14] );
void CDECL lame_bitrate_kbps( void CDECL lame_bitrate_kbps(
const lame_global_flags *const gfp, const lame_global_flags * gfp,
int bitrate_kbps [14] ); int bitrate_kbps [14] );
void CDECL lame_stereo_mode_hist( void CDECL lame_stereo_mode_hist(
const lame_global_flags *const gfp, const lame_global_flags * gfp,
int stereo_mode_count[4] ); int stereo_mode_count[4] );
void CDECL lame_bitrate_stereo_mode_hist ( void CDECL lame_bitrate_stereo_mode_hist (
const lame_global_flags * const gfp, const lame_global_flags * gfp,
int bitrate_stmode_count [14] [4] ); int bitrate_stmode_count[14][4] );
void CDECL lame_block_type_hist ( void CDECL lame_block_type_hist (
const lame_global_flags * const gfp, const lame_global_flags * gfp,
int btype_count[6] ); int btype_count[6] );
void CDECL lame_bitrate_block_type_hist ( void CDECL lame_bitrate_block_type_hist (
const lame_global_flags * const gfp, const lame_global_flags * gfp,
int bitrate_btype_count[14][6] ); int bitrate_btype_count[14][6] );
#if (DEPRECATED_OR_OBSOLETE_CODE_REMOVED && 0)
#else
/* /*
* OPTIONAL: * OPTIONAL:
* lame_mp3_tags_fid will append a Xing VBR tag to the mp3 file with file * lame_mp3_tags_fid will rewrite a Xing VBR tag to the mp3 file with file
* pointer fid. These calls perform forward and backwards seeks, so make * pointer fid. These calls perform forward and backwards seeks, so make
* sure fid is a real file. Make sure lame_encode_flush has been called, * sure fid is a real file. Make sure lame_encode_flush has been called,
* and all mp3 data has been written to the file before calling this * and all mp3 data has been written to the file before calling this
* function. * function.
* NOTE: * NOTE:
* if VBR tags are turned off by the user, or turned off by LAME because * if VBR tags are turned off by the user, or turned off by LAME because
* the output is not a regular file, this call does nothing * the output is not a regular file, this call does nothing
* NOTE:
* LAME wants to read from the file to skip an optional ID3v2 tag, so
* make sure you opened the file for writing and reading.
* NOTE:
* You can call lame_get_lametag_frame instead, if you want to insert
* the lametag yourself.
*/ */
void CDECL lame_mp3_tags_fid(lame_global_flags *,FILE* fid); void CDECL lame_mp3_tags_fid(lame_global_flags *, FILE* fid);
#endif
/*
* OPTIONAL:
* lame_get_lametag_frame copies the final LAME-tag into 'buffer'.
* The function returns the number of bytes copied into buffer, or
* the required buffer size, if the provided buffer is too small.
* Function failed, if the return value is larger than 'size'!
* Make sure lame_encode flush has been called before calling this function
.
* NOTE:
* if VBR tags are turned off by the user, or turned off by LAME,
* this call does nothing and returns 0.
* NOTE:
* LAME inserted an empty frame in the beginning of mp3 audio data,
* which you have to replace by the final LAME-tag frame after encoding.
* In case there is no ID3v2 tag, usually this frame will be the very first
* data in your mp3 file. If you put some other leading data into your
* file, you'll have to do some bookkeeping about where to write this buffe
r.
*/
size_t CDECL lame_get_lametag_frame(
const lame_global_flags *, unsigned char* buffer, size_t size);
/* /*
* REQUIRED: * REQUIRED:
* final call to free all remaining buffers * final call to free all remaining buffers
*/ */
int CDECL lame_close (lame_global_flags *); int CDECL lame_close (lame_global_flags *);
#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
#else
/* /*
* OBSOLETE: * OBSOLETE:
* lame_encode_finish combines lame_encode_flush() and lame_close() in * lame_encode_finish combines lame_encode_flush() and lame_close() in
* one call. However, once this call is made, the statistics routines * one call. However, once this call is made, the statistics routines
* will no longer work because the data will have been cleared, and * will no longer work because the data will have been cleared, and
* lame_mp3_tags_fid() cannot be called to add data to the VBR header * lame_mp3_tags_fid() cannot be called to add data to the VBR header
*/ */
int CDECL lame_encode_finish( int CDECL lame_encode_finish(
lame_global_flags* gfp, lame_global_flags* gfp,
unsigned char* mp3buf, unsigned char* mp3buf,
int size ); int size );
#endif
/********************************************************************* /*********************************************************************
* *
* decoding * decoding
* *
* a simple interface to mpglib, part of mpg123, is also included if * a simple interface to mpglib, part of mpg123, is also included if
* libmp3lame is compiled with HAVE_MPGLIB * libmp3lame is compiled with HAVE_MPGLIB
* *
*********************************************************************/ *********************************************************************/
struct hip_global_struct;
typedef struct hip_global_struct hip_global_flags;
typedef hip_global_flags *hip_t;
typedef struct { typedef struct {
int header_parsed; /* 1 if header was parsed and following data was int header_parsed; /* 1 if header was parsed and following data was
computed */ computed */
int stereo; /* number of channels */ int stereo; /* number of channels */
int samplerate; /* sample rate */ int samplerate; /* sample rate */
int bitrate; /* bitrate */ int bitrate; /* bitrate */
int mode; /* mp3 frame type */ int mode; /* mp3 frame type */
int mode_ext; /* mp3 frame type */ int mode_ext; /* mp3 frame type */
int framesize; /* number of samples per mp3 frame */ int framesize; /* number of samples per mp3 frame */
/* this data is only computed if mpglib detects a Xing VBR header */ /* this data is only computed if mpglib detects a Xing VBR header */
unsigned long nsamp; /* number of samples in mp3 file. */ unsigned long nsamp; /* number of samples in mp3 file. */
int totalframes; /* total number of frames in mp3 file */ int totalframes; /* total number of frames in mp3 file */
/* this data is not currently computed by the mpglib routines */ /* this data is not currently computed by the mpglib routines */
int framenum; /* frames decoded counter */ int framenum; /* frames decoded counter */
} mp3data_struct; } mp3data_struct;
/* required call to initialize decoder /* required call to initialize decoder */
* NOTE: the decoder should not be used when encoding is performed hip_t CDECL hip_decode_init(void);
* with decoding on the fly */
int CDECL lame_decode_init(void); /* cleanup call to exit decoder */
int CDECL hip_decode_exit(hip_t gfp);
/********************************************************************* /*********************************************************************
* input 1 mp3 frame, output (maybe) pcm data. * input 1 mp3 frame, output (maybe) pcm data.
* *
* nout = lame_decode(mp3buf,len,pcm_l,pcm_r); * nout = hip_decode(hip, mp3buf,len,pcm_l,pcm_r);
* *
* input: * input:
* len : number of bytes of mp3 data in mp3buf * len : number of bytes of mp3 data in mp3buf
* mp3buf[len] : mp3 data to be decoded * mp3buf[len] : mp3 data to be decoded
* *
* output: * output:
* nout: -1 : decoding error * nout: -1 : decoding error
* 0 : need more data before we can complete the decode * 0 : need more data before we can complete the decode
* >0 : returned 'nout' samples worth of data in pcm_l,pcm_r * >0 : returned 'nout' samples worth of data in pcm_l,pcm_r
* pcm_l[nout] : left channel data * pcm_l[nout] : left channel data
* pcm_r[nout] : right channel data * pcm_r[nout] : right channel data
* *
*********************************************************************/ *********************************************************************/
int CDECL hip_decode( hip_t gfp
, unsigned char * mp3buf
, size_t len
, short pcm_l[]
, short pcm_r[]
);
/* same as hip_decode, and also returns mp3 header data */
int CDECL hip_decode_headers( hip_t gfp
, unsigned char* mp3buf
, size_t len
, short pcm_l[]
, short pcm_r[]
, mp3data_struct* mp3data
);
/* same as hip_decode, but returns at most one frame */
int CDECL hip_decode1( hip_t gfp
, unsigned char* mp3buf
, size_t len
, short pcm_l[]
, short pcm_r[]
);
/* same as hip_decode1, but returns at most one frame and mp3 header data *
/
int CDECL hip_decode1_headers( hip_t gfp
, unsigned char* mp3buf
, size_t len
, short pcm_l[]
, short pcm_r[]
, mp3data_struct* mp3data
);
/* same as hip_decode1_headers, but also returns enc_delay and enc_padding
from VBR Info tag, (-1 if no info tag was found) */
int CDECL hip_decode1_headersB( hip_t gfp
, unsigned char* mp3buf
, size_t len
, short pcm_l[]
, short pcm_r[]
, mp3data_struct* mp3data
, int *enc_delay
, int *enc_padding
);
/* OBSOLETE:
* lame_decode... functions are there to keep old code working
* but it is strongly recommended to replace calls by hip_decode...
* function calls, see above.
*/
#if 1
int CDECL lame_decode_init(void);
int CDECL lame_decode( int CDECL lame_decode(
unsigned char * mp3buf, unsigned char * mp3buf,
int len, int len,
short pcm_l[], short pcm_l[],
short pcm_r[] ); short pcm_r[] );
/* same as lame_decode, and also returns mp3 header data */
int CDECL lame_decode_headers( int CDECL lame_decode_headers(
unsigned char* mp3buf, unsigned char* mp3buf,
int len, int len,
short pcm_l[], short pcm_l[],
short pcm_r[], short pcm_r[],
mp3data_struct* mp3data ); mp3data_struct* mp3data );
/* same as lame_decode, but returns at most one frame */
int CDECL lame_decode1( int CDECL lame_decode1(
unsigned char* mp3buf, unsigned char* mp3buf,
int len, int len,
short pcm_l[], short pcm_l[],
short pcm_r[] ); short pcm_r[] );
/* same as lame_decode1, but returns at most one frame and mp3 header data
*/
int CDECL lame_decode1_headers( int CDECL lame_decode1_headers(
unsigned char* mp3buf, unsigned char* mp3buf,
int len, int len,
short pcm_l[], short pcm_l[],
short pcm_r[], short pcm_r[],
mp3data_struct* mp3data ); mp3data_struct* mp3data );
/* same as lame_decode1_headers, but also returns enc_delay and enc_padding
from VBR Info tag, (-1 if no info tag was found) */
int CDECL lame_decode1_headersB( int CDECL lame_decode1_headersB(
unsigned char* mp3buf, unsigned char* mp3buf,
int len, int len,
short pcm_l[], short pcm_l[],
short pcm_r[], short pcm_r[],
mp3data_struct* mp3data, mp3data_struct* mp3data,
int *enc_delay, int *enc_delay,
int *enc_padding ); int *enc_padding );
/* cleanup call to exit decoder */
int CDECL lame_decode_exit(void); int CDECL lame_decode_exit(void);
#endif /* obsolete lame_decode API calls */
/********************************************************************* /*********************************************************************
* *
* id3tag stuff * id3tag stuff
* *
*********************************************************************/ *********************************************************************/
/* /*
* id3tag.h -- Interface to write ID3 version 1 and 2 tags. * id3tag.h -- Interface to write ID3 version 1 and 2 tags.
* *
* Copyright (C) 2000 Don Melton. * Copyright (C) 2000 Don Melton.
skipping to change at line 973 skipping to change at line 1077
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details. * Library General Public License for more details.
* *
* You should have received a copy of the GNU Library General Public * You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA . * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA .
*/ */
/* utility to obtain alphabetically sorted list of genre names with numbers */ /* utility to obtain alphabetically sorted list of genre names with numbers */
extern void id3tag_genre_list( void CDECL id3tag_genre_list(
void (*handler)(int, const char *, void *), void (*handler)(int, const char *, void *),
void* cookie); void* cookie);
extern void id3tag_init (lame_global_flags *gfp); void CDECL id3tag_init (lame_t gfp);
/* force addition of version 2 tag */ /* force addition of version 2 tag */
extern void id3tag_add_v2 (lame_global_flags *gfp); void CDECL id3tag_add_v2 (lame_t gfp);
/* add only a version 1 tag */ /* add only a version 1 tag */
extern void id3tag_v1_only (lame_global_flags *gfp); void CDECL id3tag_v1_only (lame_t gfp);
/* add only a version 2 tag */ /* add only a version 2 tag */
extern void id3tag_v2_only (lame_global_flags *gfp); void CDECL id3tag_v2_only (lame_t gfp);
/* pad version 1 tag with spaces instead of nulls */ /* pad version 1 tag with spaces instead of nulls */
extern void id3tag_space_v1 (lame_global_flags *gfp); void CDECL id3tag_space_v1 (lame_t gfp);
/* pad version 2 tag with extra 128 bytes */ /* pad version 2 tag with extra 128 bytes */
extern void id3tag_pad_v2 (lame_global_flags *gfp); void CDECL id3tag_pad_v2 (lame_t gfp);
extern void id3tag_set_title( /* pad version 2 tag with extra n bytes */
lame_global_flags* gfp, void CDECL id3tag_set_pad (lame_t gfp, size_t n);
const char* title );
extern void id3tag_set_artist(
lame_global_flags* gfp,
const char* artist );
extern void id3tag_set_album(
lame_global_flags* gfp,
const char* album );
extern void id3tag_set_year(
lame_global_flags* gfp,
const char* year );
extern void id3tag_set_comment(
lame_global_flags* gfp,
const char* comment );
extern void id3tag_set_track(
lame_global_flags* gfp,
const char* track );
/* return non-zero result if genre name or number is invalid */ void CDECL id3tag_set_title(lame_t gfp, const char* title);
extern int id3tag_set_genre( void CDECL id3tag_set_artist(lame_t gfp, const char* artist);
lame_global_flags* gfp, void CDECL id3tag_set_album(lame_t gfp, const char* album);
const char* genre ); void CDECL id3tag_set_year(lame_t gfp, const char* year);
void CDECL id3tag_set_comment(lame_t gfp, const char* comment);
/* return -1 result if track number is out of ID3v1 range
and ignored for ID3v1 */
int CDECL id3tag_set_track(lame_t gfp, const char* track);
/* return non-zero result if genre name or number is invalid
result 0: OK
result -1: genre number out of range
result -2: no valid ID3v1 genre name, mapped to ID3v1 'Other'
but taken as-is for ID3v2 genre tag */
int CDECL id3tag_set_genre(lame_t gfp, const char* genre);
/* return non-zero result if field name is invalid */
int CDECL id3tag_set_fieldvalue(lame_t gfp, const char* fieldvalue);
/* return non-zero result if image type is invalid */
int CDECL id3tag_set_albumart(lame_t gfp, const char* image, size_t size);
/* lame_get_id3v1_tag copies ID3v1 tag into buffer.
* Function returns number of bytes copied into buffer, or number
* of bytes rquired if buffer 'size' is too small.
* Function fails, if returned value is larger than 'size'.
* NOTE:
* This functions does nothing, if user/LAME disabled ID3v1 tag.
*/
size_t CDECL lame_get_id3v1_tag(lame_t gfp, unsigned char* buffer, size_t s
ize);
/* lame_get_id3v2_tag copies ID3v2 tag into buffer.
* Function returns number of bytes copied into buffer, or number
* of bytes rquired if buffer 'size' is too small.
* Function fails, if returned value is larger than 'size'.
* NOTE:
* This functions does nothing, if user/LAME disabled ID3v2 tag.
*/
size_t CDECL lame_get_id3v2_tag(lame_t gfp, unsigned char* buffer, size_t s
ize);
/* normaly lame_init_param writes ID3v2 tags into the audio stream
* Call lame_set_write_id3tag_automatic(gfp, 0) before lame_init_param
* to turn off this behaviour and get ID3v2 tag with above function
* write it yourself into your file.
*/
void CDECL lame_set_write_id3tag_automatic(lame_global_flags * gfp, int);
int CDECL lame_get_write_id3tag_automatic(lame_global_flags const* gfp);
/*********************************************************************** /***********************************************************************
* *
* list of valid bitrates [kbps] & sample frequencies [Hz]. * list of valid bitrates [kbps] & sample frequencies [Hz].
* first index: 0: MPEG-2 values (sample frequencies 16...24 kHz) * first index: 0: MPEG-2 values (sample frequencies 16...24 kHz)
* 1: MPEG-1 values (sample frequencies 32...48 kHz) * 1: MPEG-1 values (sample frequencies 32...48 kHz)
* 2: MPEG-2.5 values (sample frequencies 8...12 kHz) * 2: MPEG-2.5 values (sample frequencies 8...12 kHz)
***********************************************************************/ ***********************************************************************/
extern const int bitrate_table [3] [16]; extern const int bitrate_table [3] [16];
extern const int samplerate_table [3] [ 4]; extern const int samplerate_table [3] [ 4];
/* maximum size of albumart image (128KB), which affects LAME_MAXMP3BUFFER
as well since lame_encode_buffer() also returns ID3v2 tag data */
#define LAME_MAXALBUMART (128 * 1024)
/* maximum size of mp3buffer needed if you encode at most 1152 samples for /* maximum size of mp3buffer needed if you encode at most 1152 samples for
each call to lame_encode_buffer. see lame_encode_buffer() below each call to lame_encode_buffer. see lame_encode_buffer() below
(LAME_MAXMP3BUFFER is now obsolete) */ (LAME_MAXMP3BUFFER is now obsolete) */
#define LAME_MAXMP3BUFFER 16384 #define LAME_MAXMP3BUFFER (16384 + LAME_MAXALBUMART)
typedef enum { typedef enum {
LAME_OKAY = 0, LAME_OKAY = 0,
LAME_NOERROR = 0, LAME_NOERROR = 0,
LAME_GENERICERROR = -1, LAME_GENERICERROR = -1,
LAME_NOMEM = -10, LAME_NOMEM = -10,
LAME_BADBITRATE = -11, LAME_BADBITRATE = -11,
LAME_BADSAMPFREQ = -12, LAME_BADSAMPFREQ = -12,
LAME_INTERNALERROR = -13, LAME_INTERNALERROR = -13,
 End of changes. 64 change blocks. 
87 lines changed or deleted 227 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/