1
mirror of https://github.com/mpv-player/mpv synced 2024-10-02 16:25:33 +02:00

encoding to mp2 with libtoolame

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13427 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
nicodvb 2004-09-21 19:50:54 +00:00
parent 91413c4747
commit db4e77d0a5
6 changed files with 180 additions and 0 deletions

View File

@ -5102,6 +5102,28 @@ for people with extremely good hearing and similar equipment.
.IPs preset=help
print additional options and informations on presets settings.
.RE
.PD 1
.
.
.SS toolame (\-toolameopts)
.
.TP
.B br=<0\-384>
specify bitrate in kBit (CBR only)
.TP
.B mode=<stereo | jstereo | mono | dual>
(default: mono for 1-channel audio, stereo otherwise)
.TP
.B psy=<0\-3>
psychoacoustic model, default is 2
.TP
.B errprot=<0 | 1>
include error protection
.TP
.B debug=<0\-10>
debug level
.RE
.PD 1
.
.

View File

@ -36,6 +36,10 @@ CODEC_LIBS = $(AV_LIB) $(FAME_LIB) $(MAD_LIB) $(VORBIS_LIB) $(THEORA_LIB) $(FAAD
COMMON_LIBS = libmpcodecs/libmpcodecs.a mp3lib/libMP3.a liba52/liba52.a libmpeg2/libmpeg2.a $(W32_LIB) $(DS_LIB) libaf/libaf.a libmpdemux/libmpdemux.a input/libinput.a postproc/libswscale.a osdep/libosdep.a $(DVDREAD_LIB) $(CODEC_LIBS) $(FREETYPE_LIB) $(TERMCAP_LIB) $(CDPARANOIA_LIB) $(MPLAYER_NETWORK_LIB) $(WIN32_LIB) $(GIF_LIB) $(MACOSX_FRAMEWORKS) $(SMBSUPPORT_LIB) $(FRIBIDI_LIB) $(FONTCONFIG_LIB) $(ENCA_LIB)
CFLAGS = $(OPTFLAGS) -Ilibmpdemux -Iloader -Ilibvo $(FREETYPE_INC) $(EXTRA_INC) $(CDPARANOIA_INC) $(SDL_INC) $(X11_INC) $(FRIBIDI_INC) $(DVB_INC) $(XVID_INC) $(FONTCONFIG_INC) $(CACA_INC) # -Wall
ifeq ($(TOOLAME),yes)
CFLAGS += $(TOOLAME_EXTRAFLAGS)
CODEC_LIBS += $(TOOLAME_LIB)
endif
PARTS = libmpdemux libmpcodecs mp3lib liba52 libmpeg2 libavcodec libavformat libao2 drivers osdep postproc input libvo libaf
ifeq ($(INTERNAL_FAAD),yes)

View File

@ -55,6 +55,10 @@ m_option_t lameopts_conf[]={
extern m_option_t lavcopts_conf[];
#endif
#ifdef HAVE_TOOLAME
extern m_option_t toolameopts_conf[];
#endif
#ifdef USE_WIN32DLL
extern m_option_t vfwopts_conf[];
#endif
@ -127,6 +131,11 @@ m_option_t oac_conf[]={
{"lavc", &out_audio_codec, CONF_TYPE_FLAG, 0, 0, ACODEC_LAVC, NULL},
#else
{"lavc", "MPlayer was compiled without libavcodec. See README or DOCS.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
#endif
#ifdef HAVE_TOOLAME
{"toolame", &out_audio_codec, CONF_TYPE_FLAG, 0, 0, ACODEC_TOOLAME, NULL},
#else
{"toolame", "MPlayer was compiled without libtoolame. See README or DOCS.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
#endif
{"help", "\nAvailable codecs:\n"
" copy - frame copy, without re-encoding (useful for AC3)\n"
@ -136,6 +145,9 @@ m_option_t oac_conf[]={
#endif
#ifdef USE_LIBAVCODEC
" lavc - FFmpeg audio encoder (MP2, AC3, ...)\n"
#endif
#ifdef HAVE_TOOLAME
" toolame - Toolame MP2 audio encoder\n"
#endif
"\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
{NULL, NULL, 0, 0, 0, 0, NULL}
@ -241,6 +253,11 @@ m_option_t mencoder_opts[]={
#else
{"lavcopts", "MPlayer was compiled without libavcodec. See README or DOCS.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
#endif
#ifdef HAVE_TOOLAME
{"toolameopts", toolameopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
#else
{"toolameopts", "MPlayer was compiled without libtoolame. See README or DOCS.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
#endif
#ifdef USE_WIN32DLL
{"vfwopts", vfwopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
#endif

38
configure vendored
View File

@ -212,6 +212,7 @@ Codecs:
--disable-internal-faad disable internal FAAD2 (AAC) support [autodetect]
--disable-libdv disable libdv 0.9.5 en/decoding support [autodetect]
--disable-mad disable libmad (MPEG audio) support [autodetect]
--disable-toolame disable Toolame (MPEG layer 2 audio) support in mencoder [autodetect]
--enable-xmms build with XMMS inputplugin support [disabled]
--disable-mp3lib disable builtin mp3lib [enabled]
--disable-liba52 disable builtin liba52 [enabled]
@ -326,6 +327,7 @@ multiple paths separated by ':'):
--with-dtslibdir=DIR libdts library in DIR (*)
--with-dtsincdir=DIR libdts header in DIR (*)
--with-livelibdir=DIR LIVE.COM Streaming Media libraries in DIR
--with-toolamedir=DIR path to Toolame library and include file
--with-xmmsplugindir=DIR XMMS plugins in DIR
--with-xmmslibdir=DIR libxmms.so.1 in DIR
--with-bio2jack=DIR libbio2jack.a in DIR
@ -1258,6 +1260,7 @@ _esd=auto
_jack=auto
_liblzo=auto
_mad=auto
_toolame=auto
_vorbis=auto
_theora=auto
_mp3lib=yes
@ -1429,6 +1432,7 @@ for ac_option do
--disable-jack) _jack=no ;;
--enable-mad) _mad=yes ;;
--disable-mad) _mad=no ;;
--disable-toolame) _toolame=no ;;
--enable-liblzo) _liblzo=yes ;;
--disable-liblzo) _liblzo=no ;;
--enable-vorbis) _vorbis=yes ;;
@ -1625,6 +1629,9 @@ for ac_option do
--with-livelibdir=*)
_livelibdir=`echo $ac_option | cut -d '=' -f 2`
;;
--with-toolamedir=*)
_toolamedir=`echo $ac_option | cut -d '=' -f 2`
;;
--with-mlibdir=*)
_mlibdir=`echo $ac_option | cut -d '=' -f 2`
_mlib=yes
@ -4844,6 +4851,33 @@ else
fi
echores "$_mad"
echocheck "Toolame"
if test "$_toolame" = auto ; then
cat > $TMPC <<EOF
#include <toolame.h>
int main(void) { toolame_init(); return 0; }
EOF
_toolame=no
_toolame_extraflags=""
_toolame_lib="-ltoolame"
if test -n "$_toolamedir"; then
_toolame_extraflags="-I$_toolamedir -L$_toolamedir"
fi
cc_check $_toolame_extraflags $_toolame_lib -lm && _toolame=yes
fi
if test "$_toolame" = yes ; then
_def_toolame='#define HAVE_TOOLAME 1'
_codecmodules="$_codecmodules toolame"
else
_def_toolame='#undef HAVE_TOOLAME'
_toolame_lib=""
_nocodecmodules="toolame $_nocodecmodules"
fi
if test -z "$_toolamedir" ; then
echores "$_toolame"
else
echores "$_toolame (using $_toolamedir)"
fi
echocheck "OggVorbis support"
if test "$_vorbis" = auto ; then
@ -6351,6 +6385,9 @@ XMMS_PLUGINS = $_xmms
XMMS_LIB = $_xmms_lib
MACOSX = $_macosx
MACOSX_FRAMEWORKS = $_macosx_frameworks
TOOLAME=$_toolame
TOOLAME_EXTRAFLAGS=$_toolame_extraflags
TOOLAME_LIB=$_toolame_lib
# --- Some stuff for autoconfigure ----
$_target_arch
@ -6966,6 +7003,7 @@ $_def_xdpms
$_def_aa
$_def_caca
$_def_tga
$_def_toolame
/* used by GUI: */
$_def_xshape

View File

@ -39,6 +39,11 @@ ifeq ($(JPEG),yes)
VIDEO_SRCS += vd_ijpg.c
endif
ifeq ($(TOOLAME),yes)
AUDIO_SRCS += ae_toolame.c
EXTRA_INC += $(TOOLAME_EXTRAFLAGS)
endif
SRCS=$(AUDIO_SRCS) $(VIDEO_SRCS) $(VFILTER_SRCS) $(NATIVE_SRCS) img_format.c
OBJS=$(SRCS:.c=.o)

View File

@ -16,6 +16,7 @@
#define ACODEC_VBRMP3 2
#define ACODEC_NULL 3
#define ACODEC_LAVC 4
#define ACODEC_TOOLAME 5
#include <stdio.h>
#include <stdlib.h>
@ -95,6 +96,11 @@ extern int avcodec_inited;
static uint32_t lavc_find_atag(char *codec);
#endif
#ifdef HAVE_TOOLAME
#include "libmpcodecs/ae_toolame.h"
static mpae_toolame_ctx *mpae_toolame;
#endif
int vo_doublebuffering=0;
int vo_directrendering=0;
int vo_config_count=0;
@ -987,6 +993,70 @@ case ACODEC_LAVC:
break;
#endif
#ifdef HAVE_TOOLAME
case ACODEC_TOOLAME:
{
int cn = audio_output_channels ? audio_output_channels : sh_audio->channels;
int sr = force_srate ? force_srate : sh_audio->samplerate;
int br;
mpae_toolame = mpae_init_toolame(cn, sr);
if(mpae_toolame == NULL)
{
mp_msg(MSGT_MENCODER, MSGL_FATAL, "Couldn't open toolame codec, exiting\n");
exit(1);
}
br = mpae_toolame->bitrate;
mux_a->wf = malloc(sizeof(WAVEFORMATEX)+256);
mux_a->wf->wFormatTag = 0x50;
mux_a->wf->nChannels = cn;
mux_a->wf->nSamplesPerSec = sr;
mux_a->wf->nAvgBytesPerSec = 1000 * (br / 8);
mux_a->h.dwRate = mux_a->wf->nAvgBytesPerSec;
mux_a->h.dwScale = (mux_a->wf->nAvgBytesPerSec * 1152)/ mux_a->wf->nSamplesPerSec; /* for cbr */
if ((mux_a->wf->nAvgBytesPerSec *
1152) % mux_a->wf->nSamplesPerSec) {
mux_a->h.dwScale = 1152;
mux_a->h.dwRate = sr;
mux_a->h.dwSampleSize = 0; // Blocksize not constant
} else {
mux_a->h.dwSampleSize = mux_a->h.dwScale;
}
mux_a->wf->nBlockAlign = mux_a->h.dwScale;
mux_a->h.dwSuggestedBufferSize = audio_preload*mux_a->wf->nAvgBytesPerSec;
mux_a->h.dwSuggestedBufferSize -= mux_a->h.dwSuggestedBufferSize % mux_a->wf->nBlockAlign;
mux_a->wf->cbSize = 12;
mux_a->wf->wBitsPerSample = 0; /* does not apply */
((MPEGLAYER3WAVEFORMAT *) (mux_a->wf))->wID = 1;
((MPEGLAYER3WAVEFORMAT *) (mux_a->wf))->fdwFlags = 2;
((MPEGLAYER3WAVEFORMAT *) (mux_a->wf))->nBlockSize = mux_a->wf->nBlockAlign;
((MPEGLAYER3WAVEFORMAT *) (mux_a->wf))->nFramesPerBlock = 1;
((MPEGLAYER3WAVEFORMAT *) (mux_a->wf))->nCodecDelay = 0;
// Fix allocation
mux_a->wf = realloc(mux_a->wf, sizeof(WAVEFORMATEX)+mux_a->wf->cbSize);
// setup filter:
if (!init_audio_filters(
sh_audio,
sh_audio->samplerate, sh_audio->channels,
sh_audio->sample_format, sh_audio->samplesize,
mux_a->wf->nSamplesPerSec, mux_a->wf->nChannels,
AFMT_S16_NE, 2,
mux_a->h.dwSuggestedBufferSize,
mux_a->h.dwSuggestedBufferSize*2)) {
mp_msg(MSGT_CPLAYER, MSGL_ERR, "Couldn't find matching filter / ao format!\n");
exit(1);
}
break;
}
#endif
}
if (verbose>1) print_wave_header(mux_a->wf);
@ -1145,6 +1215,30 @@ if(sh_audio){
}
if (mux_v->timer == 0) mux_a->h.dwInitialFrames++;
}
#endif
#ifdef HAVE_TOOLAME
if((mux_a->codec == ACODEC_TOOLAME) && (mpae_toolame != NULL)){
int size, rd_len;
uint8_t buf[1152*2*2];
size = 1152 * 2 * mux_a->wf->nChannels;
rd_len = dec_audio(sh_audio, buf, size);
if(rd_len != size)
break;
// Encode one frame
mux_a->buffer_len += mpae_encode_toolame(mpae_toolame, mux_a->buffer + mux_a->buffer_len, 1152, (void*)buf, mux_a->buffer_size-mux_a->buffer_len);
if (mux_a->h.dwSampleSize) { /* CBR */
if (mux_a->buffer_len < mux_a->wf->nBlockAlign) {
len = 0;
} else {
len = mux_a->wf->nBlockAlign*(mux_a->buffer_len/mux_a->wf->nBlockAlign);
}
} else { /* VBR */
len = mux_a->buffer_len;
}
if (mux_v->timer == 0) mux_a->h.dwInitialFrames++;
}
#endif
if(mux_a->h.dwSampleSize){
// CBR - copy 0.5 sec of audio