From 17aa2b4ee261c8e696de42e64c091a324f13e5c9 Mon Sep 17 00:00:00 2001 From: Christophe Massiot Date: Fri, 29 Apr 2005 15:57:24 +0000 Subject: [PATCH] * ALL: We are now using libtwolame instead of libtoolame. The reason is that twolame is thread-safe and maintained. Update your batch files for --enable-twolame instead of --enable-toolame. See http://twolame.sf.net for more information. --- configure.ac | 60 ++++++------- extras/contrib/src/Makefile | 20 ++--- extras/contrib/src/packages.mak | 5 +- modules/codec/Modules.am | 2 +- modules/codec/{toolame.c => twolame.c} | 111 ++++++++++++------------- 5 files changed, 99 insertions(+), 99 deletions(-) rename modules/codec/{toolame.c => twolame.c} (71%) diff --git a/configure.ac b/configure.ac index 0e3a66eb39..089a329bfe 100644 --- a/configure.ac +++ b/configure.ac @@ -453,7 +453,7 @@ AC_CHECK_LIB(m,cos,[ VLC_ADD_LDFLAGS([adjust distort a52tofloat32 dtstofloat32 x264 goom],[-lm]) ]) AC_CHECK_LIB(m,pow,[ - VLC_ADD_LDFLAGS([ffmpeg ffmpegaltivec stream_out_transrate i420_rgb faad toolame equalizer vlc freetype],[-lm]) + VLC_ADD_LDFLAGS([ffmpeg ffmpegaltivec stream_out_transrate i420_rgb faad twolame equalizer vlc freetype],[-lm]) ]) AC_CHECK_LIB(m,sqrt,[ VLC_ADD_LDFLAGS([headphone_channel_mixer normvol speex],[-lm]) @@ -2211,46 +2211,48 @@ then fi dnl -dnl toolame encoder plugin +dnl twolame encoder plugin dnl -AC_ARG_ENABLE(toolame, -[ --enable-toolame toolame codec (default disabled)]) -if test "${enable_toolame}" = "yes" +AC_ARG_ENABLE(twolame, +[ --enable-twolame twolame codec (default disabled)]) +if test "${enable_twolame}" = "yes" then - AC_ARG_WITH(toolame-tree, - [ --with-toolame-tree=PATH toolame tree for static linking]) - if test -n "${with_toolame_tree}" + AC_ARG_WITH(twolame-tree, + [ --with-twolame-tree=PATH twolame tree for static linking]) + if test -n "${with_twolame_tree}" then - AC_MSG_CHECKING(for libtoolame.a in ${with_toolame_tree}) - real_toolame_tree="`cd ${with_toolame_tree} 2>/dev/null && pwd`" - if test -z "${real_toolame_tree}" + AC_MSG_CHECKING(for libtwolame.a in ${with_twolame_tree}) + real_twolame_tree="`cd ${with_twolame_tree} 2>/dev/null && pwd`" + if test -z "${real_twolame_tree}" then dnl The given directory can't be found AC_MSG_RESULT(no) - AC_MSG_ERROR([cannot cd to ${with_toolame_tree}]) + AC_MSG_ERROR([cannot cd to ${with_twolame_tree}]) fi - if test -f "${real_toolame_tree}/libtoolame/libtoolame.a" + if test -f "${real_twolame_tree}/src/libtwolame/.libs/libtwolame.a" then - dnl Use a custom toolame - AC_MSG_RESULT(${real_toolame_tree}/libtoolame/libtoolame.a) - VLC_ADD_BUILTINS([toolame]) - VLC_ADD_LDFLAGS([toolame],[${real_toolame_tree}/libtoolame/libtoolame.a]) - VLC_ADD_CPPFLAGS([toolame],[-I${real_toolame_tree}/libtoolame]) + dnl Use a custom twolame + AC_MSG_RESULT(${real_twolame_tree}/src/libtwolame/.libs/libtwolame.a) + VLC_ADD_BUILTINS([twolame]) + VLC_ADD_LDFLAGS([twolame],[${real_twolame_tree}/src/libtwolame/.libs/libtw +olame.a]) + VLC_ADD_CPPFLAGS([twolame],[-I${real_twolame_tree}/src/libtwolame]) else - dnl The given libtoolame wasn't built + dnl The given libtwolame wasn't built AC_MSG_RESULT(no) - AC_MSG_ERROR([cannot find ${real_toolame_tree}/libtoolame/libtoolame.a, make sure you compiled libtoolame in ${with_toolame_tree}]) + AC_MSG_ERROR([cannot find ${real_twolame_tree}/src/libtwolame/.libs/libtwo +lame.a, make sure you compiled libtwolame in ${with_twolame_tree}]) fi else - CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_toolame}" - LDFLAGS="${LDFLAGS_save} ${LDFLAGS_toolame}" - AC_CHECK_HEADERS(toolame.h, , - [ AC_MSG_ERROR([Cannot find development header for libtoolame...]) ]) - AC_CHECK_LIB(toolame, toolame_init, [ - VLC_ADD_PLUGINS([toolame]) - VLC_ADD_LDFLAGS([toolame],[-ltoolame]) ], - [ AC_MSG_ERROR([Cannot find libtoolame library...]) ]) - LDFLAGS="${LDFLAGS_save}" + CPPFLAGS="${CPPFLAGS_save} ${CPPFLAGS_twolame}" + LDFLAGS="${LDFLAGS_save} ${LDFLAGS_twolame}" + AC_CHECK_HEADERS(twolame.h, , + [ AC_MSG_ERROR([Cannot find development header for libtwolame...]) ]) + AC_CHECK_LIB(twolame, twolame_init, [ + VLC_ADD_PLUGINS([twolame]) + VLC_ADD_LDFLAGS([twolame],[-ltwolame]) ], + [ AC_MSG_ERROR([Cannot find libtwolame library...]) ]) + LDFLAGS="${LDFLAGS_save}" CPPFLAGS="${CPPFLAGS_save}" fi fi diff --git a/extras/contrib/src/Makefile b/extras/contrib/src/Makefile index f5048c2988..10118e73bd 100644 --- a/extras/contrib/src/Makefile +++ b/extras/contrib/src/Makefile @@ -1006,23 +1006,23 @@ CLEAN_PKG += mash-code DISTCLEAN_PKG += mash-src-$(MASH_VERSION).tar.gz # *************************************************************************** -# toolame +# twolame # *************************************************************************** -toolame-$(TOOLAME_VERSION).tar.bz2: - $(WGET) $(TOOLAME_URL) +twolame-$(TWOLAME_VERSION).tar.gz: + $(WGET) $(TWOLAME_URL) -toolame: toolame-$(TOOLAME_VERSION).tar.bz2 - $(EXTRACT_BZ2) +twolame: twolame-$(TWOLAME_VERSION).tar.gz + $(EXTRACT_GZ) -.toolame: toolame - (cd toolame; ./configure --prefix=$(PREFIX) && make && make install) +.twolame: twolame + (cd twolame; ./configure --prefix=$(PREFIX) && make && make install) $(INSTALL_NAME) touch $@ -CLEAN_FILE += .toolame -CLEAN_PKG += toolame -DISTCLEAN_PKG += toolame-$(TOOLAME_VERSION).tar.bz2 +CLEAN_FILE += .twolame +CLEAN_PKG += twolame +DISTCLEAN_PKG += twolame-$(TWOLAME_VERSION).tar.bz2 # *************************************************************************** # libpng diff --git a/extras/contrib/src/packages.mak b/extras/contrib/src/packages.mak index 8c11c1c5fd..4610e73746 100644 --- a/extras/contrib/src/packages.mak +++ b/extras/contrib/src/packages.mak @@ -107,8 +107,6 @@ VCDIMAGER_VERSION=0.7.21 VCDIMAGER_URL=$(GNU)/vcdimager/vcdimager-$(VCDIMAGER_VERSION).tar.gz CDIO_VERSION=0.72 CDIO_URL=$(GNU)/libcdio/libcdio-$(CDIO_VERSION).tar.gz -TOOLAME_VERSION=02m-beta8 -TOOLAME_URL=$(VIDEOLAN)/testing/contrib/toolame-$(TOOLAME_VERSION).tar.bz2 PNG_VERSION=1.2.5 PNG_URL=$(VIDEOLAN)/testing/contrib/libpng-$(PNG_VERSION).tar.bz2 GPGERROR_VERSION=1.0 @@ -125,4 +123,5 @@ LIBIDL_VERSION=0.6.8 LIBIDL_URL=http://andrewtv.org/libIDL/libIDL-$(LIBIDL_VERSION).tar.gz MOZILLA_VERSION=1.7.5 MOZILLA_URL=http://ftp.mozilla.org/pub/mozilla.org/mozilla/releases/mozilla$(MOZILLA_VERSION)/source/mozilla-source-$(MOZILLA_VERSION).tar.bz2 - +TWOLAME_VERSION=0.3.2 +TWOLAME_URL=$(SF)/twolame/twolame-$(TWOLAME_VERSION).tar.gz diff --git a/modules/codec/Modules.am b/modules/codec/Modules.am index c74dbe0f65..6dc1b21877 100644 --- a/modules/codec/Modules.am +++ b/modules/codec/Modules.am @@ -20,7 +20,7 @@ SOURCES_faad = faad.c SOURCES_dvbsub = dvbsub.c SOURCES_mash = mash.cpp SOURCES_x264 = x264.c -SOURCES_toolame = toolame.c +SOURCES_twolame = twolame.c SOURCES_dirac = dirac.c SOURCES_png = png.c SOURCES_svcdsub = svcdsub.c diff --git a/modules/codec/toolame.c b/modules/codec/twolame.c similarity index 71% rename from modules/codec/toolame.c rename to modules/codec/twolame.c index a14dc8d60b..4339d82f68 100644 --- a/modules/codec/toolame.c +++ b/modules/codec/twolame.c @@ -1,8 +1,8 @@ /***************************************************************************** - * toolame.c: libtoolame encoder (MPEG-1/2 layer II) module - * (using libtoolame from http://users.tpg.com.au/adslblvi/) + * twolame.c: libtwolame encoder (MPEG-1/2 layer II) module + * (using libtwolame from http://users.tpg.com.au/adslblvi/) ***************************************************************************** - * Copyright (C) 2004 VideoLAN + * Copyright (C) 2004-2005 VideoLAN * $Id$ * * Authors: Christophe Massiot @@ -30,7 +30,7 @@ #include #include -#include +#include #define MPEG_FRAME_SIZE 1152 #define MAX_CODED_FRAME_SIZE 1792 @@ -45,7 +45,7 @@ static block_t *Encode ( encoder_t *, aout_buffer_t * ); /***************************************************************************** * Module descriptor *****************************************************************************/ -#define ENC_CFG_PREFIX "sout-toolame-" +#define ENC_CFG_PREFIX "sout-twolame-" #define ENC_QUALITY_TEXT N_("Encoding quality") #define ENC_QUALITY_LONGTEXT N_( \ @@ -58,10 +58,13 @@ static block_t *Encode ( encoder_t *, aout_buffer_t * ); #define ENC_VBR_TEXT N_("VBR mode") #define ENC_VBR_LONGTEXT N_( \ "By default the encoding is CBR." ) +#define ENC_PSY_TEXT N_("Psycho-acoustic model") +#define ENC_PSY_LONGTEXT N_( \ + "Integer from -1 (no model) to 4." ) vlc_module_begin(); - set_shortname( "toolame"); - set_description( _("Libtoolame audio encoder") ); + set_shortname( "twolame"); + set_description( _("Libtwolame audio encoder") ); set_capability( "encoder", 50 ); set_callbacks( OpenEncoder, CloseEncoder ); set_category( CAT_INPUT ); @@ -73,29 +76,30 @@ vlc_module_begin(); ENC_MODE_LONGTEXT, VLC_FALSE ); add_bool( ENC_CFG_PREFIX "vbr", 0, NULL, ENC_VBR_TEXT, ENC_VBR_LONGTEXT, VLC_FALSE ); + add_integer( ENC_CFG_PREFIX "psy", 3, NULL, ENC_PSY_TEXT, + ENC_PSY_LONGTEXT, VLC_FALSE ); vlc_module_end(); static const char *ppsz_enc_options[] = { - "quality", "mode", "vbr", NULL + "quality", "mode", "vbr", "psy", NULL }; /***************************************************************************** - * encoder_sys_t : toolame encoder descriptor + * encoder_sys_t : twolame encoder descriptor *****************************************************************************/ struct encoder_sys_t { /* * Input properties */ - int16_t p_left[MPEG_FRAME_SIZE]; - int16_t p_right[MPEG_FRAME_SIZE]; + int16_t p_buffer[MPEG_FRAME_SIZE * 2]; int i_nb_samples; - audio_date_t pts; + mtime_t i_pts; /* - * libtoolame properties + * libtwolame properties */ - toolame_options *p_toolame; + twolame_options *p_twolame; unsigned char p_out_buffer[MAX_CODED_FRAME_SIZE]; }; @@ -136,57 +140,62 @@ static int OpenEncoder( vlc_object_t *p_this ) sout_CfgParse( p_enc, ENC_CFG_PREFIX, ppsz_enc_options, p_enc->p_cfg ); - p_sys->p_toolame = toolame_init(); + p_sys->p_twolame = twolame_init(); /* Set options */ - toolame_setSampleFreq( p_sys->p_toolame, p_enc->fmt_out.audio.i_rate ); + twolame_set_in_samplerate( p_sys->p_twolame, p_enc->fmt_out.audio.i_rate ); + twolame_set_out_samplerate( p_sys->p_twolame, p_enc->fmt_out.audio.i_rate ); var_Get( p_enc, ENC_CFG_PREFIX "vbr", &val ); if ( val.b_bool ) { - FLOAT i_quality; + float i_quality; var_Get( p_enc, ENC_CFG_PREFIX "quality", &val ); i_quality = val.i_int; if ( i_quality > 50.0 ) i_quality = 50.0; if ( i_quality < 0.0 ) i_quality = 0.0; - toolame_setVBR( p_sys->p_toolame, 1 ); - toolame_setVBRLevel( p_sys->p_toolame, i_quality ); + twolame_set_VBR( p_sys->p_twolame, 1 ); + twolame_set_VBR_q( p_sys->p_twolame, i_quality ); } else { - toolame_setBitrate( p_sys->p_toolame, p_enc->fmt_out.i_bitrate / 1000 ); + twolame_set_bitrate( p_sys->p_twolame, p_enc->fmt_out.i_bitrate / 1000 ); } if ( p_enc->fmt_in.audio.i_channels == 1 ) { - toolame_setMode( p_sys->p_toolame, MPG_MD_MONO ); + twolame_set_num_channels( p_sys->p_twolame, 1 ); + twolame_set_mode( p_sys->p_twolame, TWOLAME_MONO ); } else { + twolame_set_num_channels( p_sys->p_twolame, 2 ); var_Get( p_enc, ENC_CFG_PREFIX "mode", &val ); switch ( val.i_int ) { case 1: - toolame_setMode( p_sys->p_toolame, MPG_MD_DUAL_CHANNEL ); + twolame_set_mode( p_sys->p_twolame, TWOLAME_DUAL_CHANNEL ); break; case 2: - toolame_setMode( p_sys->p_toolame, MPG_MD_JOINT_STEREO ); + twolame_set_mode( p_sys->p_twolame, TWOLAME_JOINT_STEREO ); break; case 0: default: - toolame_setMode( p_sys->p_toolame, MPG_MD_STEREO ); + twolame_set_mode( p_sys->p_twolame, TWOLAME_STEREO ); break; } } - if ( toolame_init_params( p_sys->p_toolame ) ) + var_Get( p_enc, ENC_CFG_PREFIX "psy", &val ); + twolame_set_psymodel( p_sys->p_twolame, val.i_int ); + + if ( twolame_init_params( p_sys->p_twolame ) ) { - msg_Err( p_enc, "toolame initialization failed" ); + msg_Err( p_enc, "twolame initialization failed" ); return -VLC_EGENERIC; } p_sys->i_nb_samples = 0; - aout_DateInit( &p_sys->pts, p_enc->fmt_out.audio.i_rate ); return VLC_SUCCESS; } @@ -196,17 +205,14 @@ static int OpenEncoder( vlc_object_t *p_this ) **************************************************************************** * This function spits out MPEG packets. ****************************************************************************/ -static void Uninterleave( encoder_t *p_enc, int16_t *p_in, int i_nb_samples ) +static void Bufferize( encoder_t *p_enc, int16_t *p_in, int i_nb_samples ) { - int16_t *p_left = p_enc->p_sys->p_left + p_enc->p_sys->i_nb_samples; - int16_t *p_right = p_enc->p_sys->p_right + p_enc->p_sys->i_nb_samples; + int16_t *p_buffer = p_enc->p_sys->p_buffer + + (p_enc->p_sys->i_nb_samples + * p_enc->fmt_in.audio.i_channels); - while ( i_nb_samples > 0 ) - { - *p_left++ = *p_in++; - *p_right++ = *p_in++; - i_nb_samples--; - } + memcpy( p_buffer, p_in, i_nb_samples * p_enc->fmt_in.audio.i_channels + * sizeof(int16_t) ); } static block_t *Encode( encoder_t *p_enc, aout_buffer_t *p_aout_buf ) @@ -215,44 +221,37 @@ static block_t *Encode( encoder_t *p_enc, aout_buffer_t *p_aout_buf ) int16_t *p_buffer = (int16_t *)p_aout_buf->p_buffer; int i_nb_samples = p_aout_buf->i_nb_samples; block_t *p_chain = NULL; - mtime_t i_computed_pts = p_aout_buf->start_date - - (mtime_t)1000000 * (mtime_t)p_sys->i_nb_samples / - (mtime_t)p_enc->fmt_in.audio.i_rate; - if ( aout_DateGet( &p_sys->pts ) - i_computed_pts > 10000 || - aout_DateGet( &p_sys->pts ) - i_computed_pts < -10000 ) - { - msg_Dbg( p_enc, "resetting audio date" ); - aout_DateSet( &p_sys->pts, i_computed_pts ); - } + p_sys->i_pts = p_aout_buf->start_date - + (mtime_t)1000000 * (mtime_t)p_sys->i_nb_samples / + (mtime_t)p_enc->fmt_out.audio.i_rate; while ( p_sys->i_nb_samples + i_nb_samples >= MPEG_FRAME_SIZE ) { int i_used; block_t *p_block; - Uninterleave( p_enc, p_buffer, MPEG_FRAME_SIZE - p_sys->i_nb_samples ); + Bufferize( p_enc, p_buffer, MPEG_FRAME_SIZE - p_sys->i_nb_samples ); i_nb_samples -= MPEG_FRAME_SIZE - p_sys->i_nb_samples; p_buffer += (MPEG_FRAME_SIZE - p_sys->i_nb_samples) * 2; - toolame_encode_buffer( p_sys->p_toolame, p_sys->p_left, - p_sys->p_right, MPEG_FRAME_SIZE, - p_sys->p_out_buffer, MAX_CODED_FRAME_SIZE, - &i_used ); + i_used = twolame_encode_buffer_interleaved( p_sys->p_twolame, + p_sys->p_buffer, MPEG_FRAME_SIZE, + p_sys->p_out_buffer, MAX_CODED_FRAME_SIZE ); p_sys->i_nb_samples = 0; p_block = block_New( p_enc, i_used ); p_enc->p_vlc->pf_memcpy( p_block->p_buffer, p_sys->p_out_buffer, i_used ); p_block->i_length = (mtime_t)1000000 * - (mtime_t)MPEG_FRAME_SIZE / (mtime_t)p_enc->fmt_in.audio.i_rate; - p_block->i_dts = p_block->i_pts = aout_DateGet( &p_sys->pts ); - aout_DateIncrement( &p_sys->pts, MPEG_FRAME_SIZE ); + (mtime_t)MPEG_FRAME_SIZE / (mtime_t)p_enc->fmt_out.audio.i_rate; + p_block->i_dts = p_block->i_pts = p_sys->i_pts; + p_sys->i_pts += p_block->i_length; block_ChainAppend( &p_chain, p_block ); } if ( i_nb_samples ) { - Uninterleave( p_enc, p_buffer, i_nb_samples ); + Bufferize( p_enc, p_buffer, i_nb_samples ); p_sys->i_nb_samples += i_nb_samples; } @@ -260,14 +259,14 @@ static block_t *Encode( encoder_t *p_enc, aout_buffer_t *p_aout_buf ) } /***************************************************************************** - * CloseEncoder: toolame encoder destruction + * CloseEncoder: twolame encoder destruction *****************************************************************************/ static void CloseEncoder( vlc_object_t *p_this ) { encoder_t *p_enc = (encoder_t *)p_this; encoder_sys_t *p_sys = p_enc->p_sys; - toolame_deinit( p_sys->p_toolame ); + twolame_close( &p_sys->p_twolame ); free( p_sys ); } -- 2.39.2