aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2005-08-25 08:07:28 +0000
committerEric Wong <normalperson@yhbt.net>2005-08-25 08:07:28 +0000
commit1a3254f73ca3527388854d6af8e2b5e06e5c13e0 (patch)
treed0aa17b231a6754433cb53ba5aa32d4fd14c2091
parent65ec1dc3208885f09706b7059c3d4eb2955a566c (diff)
downloadmpd-1a3254f73ca3527388854d6af8e2b5e06e5c13e0.tar.gz
mpd-1a3254f73ca3527388854d6af8e2b5e06e5c13e0.tar.xz
mpd-1a3254f73ca3527388854d6af8e2b5e06e5c13e0.zip
patch for using Tremor to decode Ogg-Vorbis
* autotools support is included, the floating point Vorbis decoder remains the default. * close bug #353 * Thanks to Hannes Reich for the patch git-svn-id: https://svn.musicpd.org/mpd/trunk@3453 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--configure.ac62
-rw-r--r--src/inputPlugins/ogg_plugin.c15
2 files changed, 73 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac
index 3eddbe76e..e2bab18d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,6 +50,10 @@ AC_ARG_ENABLE(id3,[ --disable-id3 disable id3 support],,enable_id3=yes)
AC_ARG_ENABLE(mpd_mad,[ --enable-mpd-mad use mpd libmad],use_mpd_mad=yes,)
AC_ARG_ENABLE(mpd_id3tag,[ --enable-mpd-id3tag use mpd libid3tag],use_mpd_id3tag=yes,)
+AC_ARG_WITH(tremor,[[ --with-tremor[=PFX] Use Tremor(vorbisidec) integer Ogg-Vorbis decoder (with optional prefix)]], use_tremor=yes; test x$withval != xyes && tremor_prefix="$withval",)
+AC_ARG_WITH(tremor-libraries,[ --with-tremor-libraries=DIR Directory where Tremor library is installed (optional)], tremor_libraries="$withval", tremor_libraries="")
+AC_ARG_WITH(tremor-includes,[ --with-tremor-includes=DIR Directory where Tremor header files are installed (optional)], tremor_includes="$withval", tremor_includes="")
+
AC_ARG_WITH(iconv,[ --with-iconv=PFX Prefix where iconv is installed (optional)], iconv_prefix="$withval", iconv_prefix="")
AC_ARG_WITH(iconv-libraries,[ --with-iconv-libraries=DIR Directory where libiconv library is installed (optional)], iconv_libraries="$withval", iconv_libraries="")
AC_ARG_WITH(iconv-includes,[ --with-iconv-includes=DIR Directory where libiconv header files are installed (optional)], iconv_includes="$withval", iconv_includes="")
@@ -428,13 +432,43 @@ int main() {
CPPFLAGS=$oldcppflags
fi
-if test x$enable_ogg = xyes; then
+if test x$enable_ogg = xyes && test x$use_tremor != xyes; then
XIPH_PATH_OGG(MPD_LIBS="$MPD_LIBS $OGG_LIBS" MPD_CFLAGS="$MPD_CFLAGS $OGG_CFLAGS",enable_ogg=no)
fi
+if test x$use_tremor = xyes; then
+ if test "x$tremor_libraries" != "x" ; then
+ TREMOR_LIBS="-L$tremor_libraries"
+ elif test "x$tremor_prefix" != "x" ; then
+ TREMOR_LIBS="-L$tremor_prefix/lib"
+ elif test "x$prefix" != "xNONE"; then
+ TREMOR_LIBS="-L$libdir"
+ fi
+ TREMOR_LIBS="$TREMOR_LIBS -lvorbisidec"
+ if test "x$tremor_includes" != "x" ; then
+ TREMOR_CFLAGS="-I$tremor_includes"
+ elif test "x$tremor_prefix" != "x" ; then
+ TREMOR_CFLAGS="-I$tremor_prefix/include"
+ elif test "x$prefix" != "xNONE"; then
+ TREMOR_CFLAGS="-I$includedir"
+ fi
+ ac_save_CFLAGS="$CFLAGS"
+ ac_save_LIBS="$LIBS"
+ CFLAGS="$CFLAGS $TREMOR_CFLAGS"
+ LIBS="$LIBS $TREMOR_LIBS"
+ AC_CHECK_LIB(vorbisidec,ov_read,,enable_ogg=no;AC_MSG_WARN([vorbisidec lib needed for ogg support with tremor -- disabling ogg support]))
+ CFLAGS="$ac_save_CFLAGS"
+ LIBS="$ac_save_LIBS"
+fi
+
if test x$enable_ogg = xyes; then
- enable_vorbistest=no
- XIPH_PATH_VORBIS(,enable_ogg=no)
+ if test x$use_tremor = xyes; then
+ VORBIS_LIBS="$TREMOR_LIBS"
+ VORBIS_CFLAGS="$TREMOR_CFLAGS"
+ else
+ enable_vorbistest=no
+ XIPH_PATH_VORBIS(,enable_ogg=no)
+ fi
if test x$enable_ogg = xyes; then
dnl
@@ -443,20 +477,29 @@ dnl vorbistest in XIPH_PATH_OGG is broken on my debian system
dnl so here i used my own hacked up version till i get vorbis-dev gets
dnl upgraded in debian (hopefully when 1.0.1 comes out)
dnl
+dnl This version also tests Tremor, which has no vorbistest of its own.
+dnl
AC_MSG_CHECKING(that Vorbis is usable)
ac_save_CFLAGS="$CFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $VORBIS_CFLAGS $OGG_CFLAGS"
+ if test x$use_tremor = xyes; then
+ CFLAGS="$CFLAGS -DTREMOR"
+ fi
LIBS="$LIBS $VORBIS_LIBS $VORBISENC_LIBS $OGG_LIBS"
AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef TREMOR
+#include <tremor/ivorbisfile.h>
+#else
#include <vorbis/codec.h>
#include <vorbis/vorbisenc.h>
+#endif
int main ()
{
@@ -465,7 +508,9 @@ int main ()
vorbis_info vi;
vorbis_info_init (&vi);
+#ifndef TREMOR
vorbis_encode_init (&vi, 2, 44100, -1, 128, -1);
+#endif
/*vorbis_analysis_init (&vd, &vi);
vorbis_block_init (&vd, &vb);*/
/* this function was added in 1.0rc3, so this is what we're testing for */
@@ -474,7 +519,7 @@ int main ()
return 0;
}
-], AC_MSG_RESULT(yes), AC_MSG_RESULT(no) enable_ogg=no,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
+], AC_MSG_RESULT(yes), AC_MSG_RESULT(no); enable_ogg=no,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
CFLAGS="$ac_save_CFLAGS"
LIBS="$ac_save_LIBS"
fi
@@ -491,6 +536,10 @@ if test x$enable_ogg = xyes; then
AC_DEFINE(HAVE_OGG,1,[Define for ogg vorbis support])
fi
+if test x$use_tremor = xyes; then
+ AC_DEFINE(HAVE_TREMOR,1,[Define to use tremor (libvorbisidec) for ogg support])
+fi
+
if test x$enable_flac = xyes; then
oldmpdcflags="$MPD_CFLAGS"
oldmpdlibs="$MPD_LIBS"
@@ -621,6 +670,11 @@ fi
if test x$enable_ogg = xyes; then
echo " Ogg Vorbis support ............enabled"
+ if test x$use_tremor = xyes; then
+ echo " using tremor.................yes"
+ else
+ echo " using tremor.................no"
+ fi
else
echo " Ogg Vorbis support ............disabled"
fi
diff --git a/src/inputPlugins/ogg_plugin.c b/src/inputPlugins/ogg_plugin.c
index 137c4176c..f74e3e56a 100644
--- a/src/inputPlugins/ogg_plugin.c
+++ b/src/inputPlugins/ogg_plugin.c
@@ -32,7 +32,22 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
+
+#ifndef HAVE_TREMOR
#include <vorbis/vorbisfile.h>
+#else
+#include <tremor/ivorbisfile.h>
+/* Macros to make Tremor's API look like libogg. Tremor always
+ returns host-byte-order 16-bit signed data, and uses integer
+ milliseconds where libogg uses double seconds.
+*/
+#define ov_read(VF, BUFFER, LENGTH, BIGENDIANP, WORD, SGNED, BITSTREAM) \
+ ov_read(VF, BUFFER, LENGTH, BITSTREAM)
+#define ov_time_total(VF, I) ((double)ov_time_total(VF, I)/1000)
+#define ov_time_tell(VF) ((double)ov_time_tell(VF)/1000)
+#define ov_time_seek_page(VF, S) (ov_time_seek_page(VF, (S)*1000))
+#endif /* HAVE_TREMOR */
+
#include <errno.h>
#ifdef WORDS_BIGENDIAN