Commit ffa2798b authored by ivo's avatar ivo

ReplayGain support for ogg123. It requires libvorbis 1.2.1 or later, but the...

ReplayGain support for ogg123.  It requires libvorbis 1.2.1 or later, but the code checks for it properly and doesn't compile the feature if associated function is not available.  Patch by William Poetra Yoga Hadisoeseno.  Closes #381

svn path=/trunk/vorbis-tools/; revision=15373
parent 554648b6
......@@ -11,7 +11,10 @@ vorbis-tools 1.3.0 -- Unreleased
* ogg123: backported fix from libfishsound to patch the Speex decoder (#1347)
* ogg123: fixed CPU issue when outputting to a closed pipe (#1357)
* ogg123: return value to stop decoding after buffer is shut down (#1357)
* ogg123: support for ReplayGain (#381)
* oggdec: gettextized help text (#1385)
* oggdec: gettextized all strings
* oggdec: call ov_open_callbacks instead of ov_open; it works on Windows now
* oggenc: fixed a core dump while resampling from FLAC (#1316)
* oggenc: fixed a typo in the Skeleton handling routine
* oggenc: fixed remapping channels bug (#1326)
......
......@@ -141,13 +141,21 @@ then
VORBISFILE_LIBS="-lvorbisfile"
AC_SUBST(VORBISENC_LIBS)
AC_SUBST(VORBISFILE_LIBS)
libs_save=$LIBS
LIBS="$OGG_LIBS $VORBIS_LIBS $VORBISFILE_LIBS"
AC_CHECK_FUNC(ov_read_filter, have_ov_read_filter=yes, have_ov_read_filter=no)
LIBS=$libs_save
if test "x$have_ov_read_filter" = "xyes"
then
AC_DEFINE(HAVE_OV_READ_FILTER,1,[Defined if we have ov_read_filter()])
fi
fi
if test "x$HAVE_VORBIS" = "xno"
then
dnl fall back to the old school test
XIPH_PATH_VORBIS(,AC_MSG_ERROR(Vorbis needed!))
fi
AM_CONDITIONAL(HAVE_OV_READ_FILTER, test "x$have_ov_read_filter" = "xyes")
SHARE_LIBS='$(top_builddir)/share/libutf8.a $(top_builddir)/share/libgetopt.a'
......
......@@ -9,6 +9,11 @@ speex_sources = speex_format.c
else
speex_sources =
endif
if HAVE_OV_READ_FILTER
vgfilter_sources = vgfilter.c vgfilter.h
else
vgfilter_sources =
endif
datadir = @datadir@
localedir = $(datadir)/locale
......@@ -37,7 +42,7 @@ ogg123_SOURCES = audio.c buffer.c callbacks.c \
cfgfile_options.h cmdline_options.h \
format.h ogg123.h playlist.h status.h \
transport.h remote.h vorbis_comments.h \
$(flac_sources) $(speex_sources)
$(flac_sources) $(speex_sources) $(vgfilter_sources)
man_MANS = ogg123.1
doc_DATA = ogg123rc-example
......
......@@ -32,6 +32,9 @@
#include "utf8.h"
#include "i18n.h"
#ifdef HAVE_OV_READ_FILTER
#include "vgfilter.h"
#endif
typedef struct ovf_private_t {
OggVorbis_File vf;
......@@ -42,6 +45,9 @@ typedef struct ovf_private_t {
int bos; /* At beginning of logical bitstream */
decoder_stats_t stats;
#ifdef HAVE_OV_READ_FILTER
vgain_state vg;
#endif
} ovf_private_t;
/* Forward declarations */
......@@ -91,6 +97,11 @@ decoder_t* ovf_init (data_source_t *source, ogg123_options_t *ogg123_opts,
private->stats.current_time = 0.0;
private->stats.instant_bitrate = 0;
private->stats.avg_bitrate = 0;
#ifdef HAVE_OV_READ_FILTER
private->vg.scale_factor = 1.0;
private->vg.max_scale = 1.0;
#endif
} else {
fprintf(stderr, _("ERROR: Out of memory.\n"));
exit(1);
......@@ -128,6 +139,9 @@ int ovf_read (decoder_t *decoder, void *ptr, int nbytes, int *eos,
decoder->actual_fmt.rate = priv->vi->rate;
decoder->actual_fmt.channels = priv->vi->channels;
#ifdef HAVE_OV_READ_FILTER
vg_init(&priv->vg, priv->vc);
#endif
print_vorbis_stream_info(decoder);
print_vorbis_comments(priv->vc, cb, decoder->callback_arg);
......@@ -140,9 +154,16 @@ int ovf_read (decoder_t *decoder, void *ptr, int nbytes, int *eos,
while (nbytes >= audio_fmt->word_size * audio_fmt->channels) {
old_section = priv->current_section;
#ifdef HAVE_OV_READ_FILTER
ret = ov_read_filter(&priv->vf, ptr, nbytes, audio_fmt->big_endian,
audio_fmt->word_size, audio_fmt->signed_sample,
&priv->current_section,
vg_filter, &priv->vg);
#else
ret = ov_read(&priv->vf, ptr, nbytes, audio_fmt->big_endian,
audio_fmt->word_size, audio_fmt->signed_sample,
&priv->current_section);
#endif
if (ret == 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment