/*
* Interface to MP3 LAME encoding engine
*
* Copyright (c) 1999 Mark Taylor
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* $Id: lame.h,v 1.192 2017/08/31 14:14:46 robert Exp $ */
#ifndef LAME_LAME_H
#define LAME_LAME_H
/* for size_t typedef */
#include <stddef.h>
/* for va_list typedef */
#include <stdarg.h>
/* for FILE typedef, TODO: remove when removing lame_mp3_tags_fid */
#include <stdio.h>
#if defined(__cplusplus)
extern "C" {
#endif
typedef void (*lame_report_function)(const char *format, va_list ap);
#if defined(WIN32) || defined(_WIN32)
#undef CDECL
#define CDECL __cdecl
#else
#define CDECL
#endif
#define DEPRECATED_OR_OBSOLETE_CODE_REMOVED 1
typedef enum vbr_mode_e {
vbr_off=0,
vbr_mt, /* obsolete, same as vbr_mtrh */
vbr_rh,
vbr_abr,
vbr_mtrh,
vbr_max_indicator, /* Don't use this! It's used for sanity checks. */
vbr_default=vbr_mtrh /* change this to change the default VBR mode of LAME */
} vbr_mode;
/* MPEG modes */
typedef enum MPEG_mode_e {
STEREO = 0,
JOINT_STEREO,
DUAL_CHANNEL, /* LAME doesn't supports this! */
MONO,
NOT_SET,
MAX_INDICATOR /* Don't use this! It's used for sanity checks. */
} MPEG_mode;
/* Padding types */
typedef enum Padding_type_e {
PAD_NO = 0,
PAD_ALL,
PAD_ADJUST,
PAD_MAX_INDICATOR /* Don't use this! It's used for sanity checks. */
} Padding_type;
/*presets*/
typedef enum preset_mode_e {
/*values from 8 to 320 should be reserved for abr bitrates*/
/*for abr I'd suggest to directly use the targeted bitrate as a value*/
ABR_8 = 8,
ABR_320 = 320,
V9 = 410, /*Vx to match Lame and VBR_xx to match FhG*/
VBR_10 = 410,
V8 = 420,
VBR_20 = 420,
V7 = 430,
VBR_30 = 430,
V6 = 440,
VBR_40 = 440,
V5 = 450,
VBR_50 = 450,
V4 = 460,
VBR_60 = 460,
V3 = 470,
VBR_70 = 470,
V2 = 480,
VBR_80 = 480,
V1 = 490,
VBR_90 = 490,
V0 = 500,
VBR_100 = 500,
/*still there for compatibility*/
R3MIX = 1000,
STANDARD = 1001,
EXTREME = 1002,
INSANE = 1003,
STANDARD_FAST = 1004,
EXTREME_FAST = 1005,
MEDIUM = 1006,
MEDIUM_FAST = 1007
} preset_mode;
/*asm optimizations*/
typedef enum asm_optimizations_e {
MMX = 1,
AMD_3DNOW = 2,
SSE = 3
} asm_optimizations;
/* psychoacoustic model */
typedef enum Psy_model_e {
PSY_GPSYCHO = 1,
PSY_NSPSYTUNE = 2
} Psy_model;
/* buffer considerations */
typedef enum buffer_constraint_e {
MDB_DEFAULT=0,
MDB_STRICT_ISO=1,
MDB_MAXIMUM=2
} buffer_constraint;
struct lame_global_struct;
typedef struct lame_global_struct lame_global_flags;
typedef lame_global_flags *lame_t;
/***********************************************************************
*
* The LAME API
* These functions should be called, in this order, for each
* MP3 file to be encoded. See the file "API" for more documentation
*
***********************************************************************/
/*
* REQUIRED:
* initialize the encoder. sets default for all encoder parameters,
* returns NULL if some malloc()'s failed
* otherwise returns pointer to structure needed for all future
* API calls.
*/
lame_global_flags * CDECL lame_init(void);
#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
#else
/* obsolete version */
int CDECL lame_init_old(lame_global_flags *);
#endif
/*
* OPTIONAL:
* set as needed to override defaults
*/
/********************************************************************
* input stream description
***********************************************************************/
/* number of samples. default = 2^32-1 */
int CDECL lame_set_num_samples(lame_global_flags *, unsigned long);
unsigned long CDECL lame_get_num_samples(const lame_global_flags *);
/* input sample rate in Hz. default = 44100hz */
int CDECL lame_set_in_samplerate(lame_global_flags *, int);
int CDECL lame_get_in_samplerate(const lame_global_flags *);
/* number of channels in input stream. default=2 */
int CDECL lame_set_num_channels(lame_global_flags *, int);
int CDECL lame_get_num_channels(const lame_global_flags *);
/*
scale the input by this amount before encoding. default=1
(not used by decoding routines)
*/
int CDECL lame_set_scale(lame_global_flags *, float);
float CDECL lame_get_scale(const lame_global_flags *);
/*
scale the channel 0 (left) input by this amount before encoding. default=1
(not used by decoding routines)
*/
int CDECL lame_set_scale_left(lame_global_flags *, float);
float CDECL lame_get_scale_left(const lame_global_flags *);
/*
scale the channel 1 (right) input by this amount before encoding. default=1
(not used by decoding routines)
*/
int CDECL lame_set_scale_right(lame_global_flags *, float);
float CDECL lame_get_scale_right(const lame_global_flags *);
/*
output sample rate in Hz. default = 0, which means LAME picks best value
based on the amount of compression. MPEG only allows:
MPEG1 32, 44.1, 48khz
MPEG2 16, 22.05, 24
MPEG2.5 8, 11.025, 12
(not used by decoding routines)
*/
int CDECL lame_set_out_samplerate(lame_global_flags *, int);
int CDECL lame_get_out_samplerate(const lame_global_flags *);
/********************************************************************
* general control parameters
***********************************************************************/
/* 1=cause LAME to collect data for an MP3 frame analyzer. default=0 */
int CDECL lame_set_analysis(lame_global_flags *, int);
int CDECL lame_get_analysis(const lame_global_flags *);
/*
1 = write a Xing VBR header frame.
default = 1
this variable must have been added by a Hungarian notation Windows programmer :-)
*/
int CDECL lame_set_bWriteVbrTag(lame_global_flags *, int);
int CDECL lame_get_bWriteVbrTag(const lame_global_flags *);
/* 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_get_decode_only(const lame_global_flags *);
#if DEPRECATED_OR_OBSOLETE_CODE_REMOVED
#else
/* 1=encode a Vorbis .ogg file. default=0 */
/* DEPRECATED */
int CDECL lame_set_ogg(lame_global_flags *, int);
int CDECL lame_get_ogg(const lame_global_flags *);
#endif
/*
internal algorithm selection. True quality is determined by the bitrate
but this variable will effect quality by selecting expensive or cheap algorithms.
quality=0..9. 0=best (very slow). 9=worst.
recommended: 2 near-best quality, not too slow
5 good quality, fast
7 ok quality, really fast
*/
int CDECL lame_set_quality(lame_global_flags *, int);
int CDECL lame_get_quality(const lame_global_flags *);
/*
mode = 0,1,2,3 = stereo, jstereo, dual channel (not supported), mono
default: lame picks based on compression ration and input channels
*/
int CDECL lame_set_mode(lame_global_flags *, MPEG_mode);
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
compression ratio
DEPRECATED
*/
int CDECL lame_set_mode_automs(lame_global_flags *, int);
int CDECL lame_get_mode_automs(const lame_global_flags *);
#endif
/*
force_ms. Force M/S for all frames. For testing