summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Moffitt <jack@xiph.org>2000-09-03 08:34:52 +0000
committerJack Moffitt <jack@xiph.org>2000-09-03 08:34:52 +0000
commit0275b35a2cc5f64b3aa8c89d8d4509568542b813 (patch)
tree8bcedebdc2fe887f8b1de863c17b1ca904dfb987
parentbede8906a08321a164c62f829c68cbfd33ed5c8e (diff)
downloadlibvorbis-git-0275b35a2cc5f64b3aa8c89d8d4509568542b813.tar.gz
builds with libogg instead of internal ogg functions now
configure.in modified to accept --with-ogg=DIR parameter, in case you want to build from somewhere other than default system paths svn path=/branches/branch_jackoggsvorbis/vorbis/; revision=626
-rwxr-xr-xconfigure290
-rw-r--r--configure.in76
-rw-r--r--examples/Makefile.in87
-rw-r--r--examples/chaining_example.c69
-rw-r--r--examples/decoder_example.c4
-rw-r--r--examples/encoder_example.c4
-rw-r--r--examples/seeking_example.c65
-rw-r--r--examples/vorbisfile_example.c91
-rw-r--r--include/vorbis/codec.h4
-rw-r--r--lib/Makefile.in24
-rw-r--r--lib/analysis.c18
-rw-r--r--lib/block.c8
-rw-r--r--lib/bookinternal.h4
-rw-r--r--lib/codebook.c92
-rw-r--r--lib/envelope.c4
-rw-r--r--lib/floor0.c40
-rw-r--r--lib/info.c558
-rw-r--r--lib/mapping0.c25
-rw-r--r--lib/res0.c32
-rw-r--r--lib/sharedbook.c4
-rw-r--r--lib/synthesis.c14
21 files changed, 1162 insertions, 351 deletions
diff --git a/configure b/configure
index 36214655..d98e8904 100755
--- a/configure
+++ b/configure
@@ -11,6 +11,8 @@
ac_help=
ac_default_prefix=/usr/local
# Any additions from configure.in:
+ac_help="$ac_help
+ --with-ogg=DIR Set where the Ogg library is located"
# Initialize some variables set by options.
# The variables have the same names as the options, with
@@ -521,7 +523,13 @@ else
fi
-#AC_CONFIG_HEADER(config.h)
+
+# Check whether --with-ogg or --without-ogg was given.
+if test "${with_ogg+set}" = set; then
+ withval="$with_ogg"
+ :
+fi
+
cp configure.guess config.guess
cp configure.sub config.sub
@@ -552,7 +560,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:556: checking host system type" >&5
+echo "configure:564: checking host system type" >&5
host_alias=$host
case "$host_alias" in
@@ -579,7 +587,7 @@ case $host in
CC=cc
fi
echo $ac_n "checking for ALwritesamps in -laudio""... $ac_c" 1>&6
-echo "configure:583: checking for ALwritesamps in -laudio" >&5
+echo "configure:591: checking for ALwritesamps in -laudio" >&5
ac_lib_var=`echo audio'_'ALwritesamps | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -587,7 +595,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-laudio $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 591 "configure"
+#line 599 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -598,7 +606,7 @@ int main() {
ALwritesamps()
; return 0; }
EOF
-if { (eval echo configure:602: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:610: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -626,19 +634,13 @@ else
fi
;;
-# BeOS does not use -lm
-# *-*-beos)
-# LIBS=""
-# ;;
-# added better check below
-
esac
cflags_save="$CFLAGS"
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:642: checking for $ac_word" >&5
+echo "configure:644: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -668,7 +670,7 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:672: checking for $ac_word" >&5
+echo "configure:674: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -719,7 +721,7 @@ fi
# Extract the first word of "cl", so it can be a program name with args.
set dummy cl; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:723: checking for $ac_word" >&5
+echo "configure:725: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -751,7 +753,7 @@ fi
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:755: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:757: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -762,12 +764,12 @@ cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext << EOF
-#line 766 "configure"
+#line 768 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
-if { (eval echo configure:771: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:773: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@@ -793,12 +795,12 @@ if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:797: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:799: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:802: checking whether we are using GNU C" >&5
+echo "configure:804: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -807,7 +809,7 @@ else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:811: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:813: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@@ -826,7 +828,7 @@ ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:830: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:832: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -861,7 +863,7 @@ fi
CFLAGS="$cflags_save"
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:865: checking how to run the C preprocessor" >&5
+echo "configure:867: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -876,13 +878,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 880 "configure"
+#line 882 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:886: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:888: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -893,13 +895,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 897 "configure"
+#line 899 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:903: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:905: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -910,13 +912,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 914 "configure"
+#line 916 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:920: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:922: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -943,7 +945,7 @@ echo "$ac_t""$CPP" 1>&6
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:947: checking for $ac_word" >&5
+echo "configure:949: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -973,7 +975,7 @@ fi
# Extract the first word of "ar", so it can be a program name with args.
set dummy ar; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:977: checking for $ac_word" >&5
+echo "configure:979: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1002,7 +1004,7 @@ fi
# Extract the first word of "install", so it can be a program name with args.
set dummy install; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1006: checking for $ac_word" >&5
+echo "configure:1008: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_INSTALL'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1029,11 +1031,8 @@ else
fi
-#not everyone uses libm (eg, BeOS)
-#AC_CHECK_LIB(m, cos, LIBS="-lm"; AC_DEFINE(HAVE_LIBM), LIBS="")
-# We no longer use config.h
echo $ac_n "checking for cos in -lm""... $ac_c" 1>&6
-echo "configure:1037: checking for cos in -lm" >&5
+echo "configure:1036: checking for cos in -lm" >&5
ac_lib_var=`echo m'_'cos | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1041,7 +1040,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lm $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1045 "configure"
+#line 1044 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1052,7 +1051,7 @@ int main() {
cos()
; return 0; }
EOF
-if { (eval echo configure:1056: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1055: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1094,9 +1093,10 @@ else
case $host in
*86-*-linux*)
DEBUG="-g -Wall -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char"
- OPT="-O20 -ffast-math -D_REENTRANT -fsigned-char"
- PROFILE="-pg -g -O20 -ffast-math -D_REENTRANT -fsigned-char"
-
+ OPT="-O20 -ffast-math -mno-ieee-fp -D_REENTRANT -fsigned-char"
+# PROFILE="-Wall -W -pg -O20 -ffast-math -D_REENTRANT -fsigned-char -fno-inline -static"
+ PROFILE="-Wall -W -pg -O20 -ffast-math -mno-ieee-fp -D_REENTRANT -fsigned-char -fno-inline -static"
+
# glibc < 2.1.3 has a serious FP bug in the math inline header
# that will cripple Vorbis. Look to see if the magic FP stack
# clobber is missing in the mathinline header, thus indicating
@@ -1284,11 +1284,8 @@ fi
-#AC_CHECK_LIB(pthread, pthread_create,
-# pthread_lib="-lpthread"; AC_DEFINE(HAVE_LIBPTHREAD), :)
-# We no longer use config.h
echo $ac_n "checking for pthread_create in -lpthread""... $ac_c" 1>&6
-echo "configure:1292: checking for pthread_create in -lpthread" >&5
+echo "configure:1289: checking for pthread_create in -lpthread" >&5
ac_lib_var=`echo pthread'_'pthread_create | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1296,7 +1293,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpthread $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1300 "configure"
+#line 1297 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1307,7 +1304,7 @@ int main() {
pthread_create()
; return 0; }
EOF
-if { (eval echo configure:1311: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1308: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1329,54 +1326,12 @@ else
fi
-#dnl Linuxthreads require you to define _REENTRANT in all threaded
-#dnl code. Bogus, bogus...
-#
-#if test -n "$pthread_lib"; then
-# case $host in
-# i?86-*-linux*)
-# AC_DEFINE(_REENTRANT)
-# ;;
-# esac
-#fi
-# We no longer use config.h
-
-#if test -n "$x_libraries"; then
-# XOGG="yes"
-#
-# dnl If we find libgtk installed, great; otherwise assume we have
-# dnl to build it ourselves.
-#
-# AC_CHECK_LIB(gtk, gtk_main, :, LIBGTKDIR="libgtk", $X_LIBS -lglib -lgdk -lX11 -lXext -lm)
-#
-# dnl libpthread is required for xogg.
-#
-# if test -z "$pthread_lib"; then XOGG=""; fi
-#
-# dnl If we don't have libgtk installed, and we don't have a libgtk
-# dnl subdirectory to build the library ourself, we can't build xogg.
-#
-# if test -n "$LIBGTKDIR" -a ! -d "$LIBGTKDIR"; then
-# XOGG=""
-# LIBGTKDIR=""
-# fi
-#fi
-
dummy="__noconf"
-#if test -d "$LIBGTKDIR"; then
-# enable_shared="no"; export enable_shared
-# dummy="libgtk"
-# AC_CONFIG_SUBDIRS("$dummy")
-# X_LIBS="-L${srcdir}/libgtk/gtk/.libs -L${srcdir}/libgtk/gdk/.libs -L${srcdir}/libgtk/glib/.libs $X_LIBS"
-#fi
-
-# check macro modified from Jon Shiring's to compensate for autoconf's lagging
-# behind the times on type madness
echo $ac_n "checking for int16_t""... $ac_c" 1>&6
-echo "configure:1380: checking for int16_t" >&5
+echo "configure:1335: checking for int16_t" >&5
if eval "test \"`echo '$''{'has_int16_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1385,7 +1340,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 1389 "configure"
+#line 1344 "configure"
#include "confdefs.h"
#ifdef __BEOS__
@@ -1396,7 +1351,7 @@ int16_t foo;
int main() {return 0;}
EOF
-if { (eval echo configure:1400: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1355: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
has_int16_t=yes
else
@@ -1413,7 +1368,7 @@ fi
echo "$ac_t""$has_int16_t" 1>&6
echo $ac_n "checking for int32_t""... $ac_c" 1>&6
-echo "configure:1417: checking for int32_t" >&5
+echo "configure:1372: checking for int32_t" >&5
if eval "test \"`echo '$''{'has_int32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1422,7 +1377,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 1426 "configure"
+#line 1381 "configure"
#include "confdefs.h"
#ifdef __BEOS__
@@ -1433,7 +1388,7 @@ int32_t foo;
int main() {return 0;}
EOF
-if { (eval echo configure:1437: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1392: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
has_int32_t=yes
else
@@ -1450,7 +1405,7 @@ fi
echo "$ac_t""$has_int32_t" 1>&6
echo $ac_n "checking for uint32_t""... $ac_c" 1>&6
-echo "configure:1454: checking for uint32_t" >&5
+echo "configure:1409: checking for uint32_t" >&5
if eval "test \"`echo '$''{'has_uint32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1459,7 +1414,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 1463 "configure"
+#line 1418 "configure"
#include "confdefs.h"
#ifdef __BEOS__
@@ -1470,7 +1425,7 @@ uint32_t foo;
int main() {return 0;}
EOF
-if { (eval echo configure:1474: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1429: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
has_uint32_t=yes
else
@@ -1487,7 +1442,7 @@ fi
echo "$ac_t""$has_uint32_t" 1>&6
echo $ac_n "checking for u_int32_t""... $ac_c" 1>&6
-echo "configure:1491: checking for u_int32_t" >&5
+echo "configure:1446: checking for u_int32_t" >&5
if eval "test \"`echo '$''{'has_u_int32_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1496,7 +1451,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 1500 "configure"
+#line 1455 "configure"
#include "confdefs.h"
#ifdef __BEOS__
@@ -1507,7 +1462,7 @@ u_int32_t foo;
int main() {return 0;}
EOF
-if { (eval echo configure:1511: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1466: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
has_u_int32_t=yes
else
@@ -1524,7 +1479,7 @@ fi
echo "$ac_t""$has_u_int32_t" 1>&6
echo $ac_n "checking for int64_t""... $ac_c" 1>&6
-echo "configure:1528: checking for int64_t" >&5
+echo "configure:1483: checking for int64_t" >&5
if eval "test \"`echo '$''{'has_int64_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1533,7 +1488,7 @@ else
else
cat > conftest.$ac_ext <<EOF
-#line 1537 "configure"
+#line 1492 "configure"
#include "confdefs.h"
#ifdef __BEOS__
@@ -1544,7 +1499,7 @@ int64_t foo;
int main() {return 0;}
EOF
-if { (eval echo configure:1548: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1503: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
has_int64_t=yes
else
@@ -1561,7 +1516,7 @@ fi
echo "$ac_t""$has_int64_t" 1>&6
echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:1565: checking size of short" >&5
+echo "configure:1520: checking size of short" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1569,7 +1524,7 @@ else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 1573 "configure"
+#line 1528 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -1580,7 +1535,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:1584: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_short=`cat conftestval`
else
@@ -1600,7 +1555,7 @@ EOF
echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:1604: checking size of int" >&5
+echo "configure:1559: checking size of int" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1608,7 +1563,7 @@ else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 1612 "configure"
+#line 1567 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -1619,7 +1574,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:1623: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1578: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_int=`cat conftestval`
else
@@ -1639,7 +1594,7 @@ EOF
echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:1643: checking size of long" >&5
+echo "configure:1598: checking size of long" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1647,7 +1602,7 @@ else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 1651 "configure"
+#line 1606 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -1658,7 +1613,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:1662: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1617: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_long=`cat conftestval`
else
@@ -1678,7 +1633,7 @@ EOF
echo $ac_n "checking size of long long""... $ac_c" 1>&6
-echo "configure:1682: checking size of long long" >&5
+echo "configure:1637: checking size of long long" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1686,7 +1641,7 @@ else
{ echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; }
else
cat > conftest.$ac_ext <<EOF
-#line 1690 "configure"
+#line 1645 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@@ -1697,7 +1652,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:1701: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1656: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_long_long=`cat conftestval`
else
@@ -1774,22 +1729,19 @@ if test -z "$SIZE64"; then
echo "configure: warning: No 64 bit type found on this platform!" 1>&2
fi
-#AC_CHECK_HEADER(alloca.h,AC_DEFINE(USE_ALLOCA_H),:)
-#AC_CHECK_HEADER(memory.h,AC_DEFINE(USE_MEMORY_H),:)
-# We no longer use config.h
ac_safe=`echo "alloca.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for alloca.h""... $ac_c" 1>&6
-echo "configure:1783: checking for alloca.h" >&5
+echo "configure:1735: checking for alloca.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1788 "configure"
+#line 1740 "configure"
#include "confdefs.h"
#include <alloca.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1793: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1745: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1813,17 +1765,17 @@ fi
ac_safe=`echo "memory.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for memory.h""... $ac_c" 1>&6
-echo "configure:1817: checking for memory.h" >&5
+echo "configure:1769: checking for memory.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1822 "configure"
+#line 1774 "configure"
#include "confdefs.h"
#include <memory.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1827: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1779: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1847,12 +1799,12 @@ fi
echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:1851: checking for working const" >&5
+echo "configure:1803: checking for working const" >&5
if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1856 "configure"
+#line 1808 "configure"
#include "confdefs.h"
int main() {
@@ -1901,7 +1853,7 @@ ccp = (char const *const *) p;
; return 0; }
EOF
-if { (eval echo configure:1905: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1857: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_const=yes
else
@@ -1922,12 +1874,12 @@ EOF
fi
echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:1926: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:1878: checking whether time.h and sys/time.h may both be included" >&5
if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1931 "configure"
+#line 1883 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
@@ -1936,7 +1888,7 @@ int main() {
struct tm *tp;
; return 0; }
EOF
-if { (eval echo configure:1940: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1892: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_time=yes
else
@@ -1957,12 +1909,12 @@ EOF
fi
echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6
-echo "configure:1961: checking whether struct tm is in sys/time.h or time.h" >&5
+echo "configure:1913: checking whether struct tm is in sys/time.h or time.h" >&5
if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1966 "configure"
+#line 1918 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <time.h>
@@ -1970,7 +1922,7 @@ int main() {
struct tm *tp; tp->tm_sec;
; return 0; }
EOF
-if { (eval echo configure:1974: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1926: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_struct_tm=time.h
else
@@ -1992,7 +1944,7 @@ fi
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:1996: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:1948: checking whether ${MAKE-make} sets \${MAKE}" >&5
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2019,7 +1971,7 @@ else
fi
echo $ac_n "checking for 8-bit clean memcmp""... $ac_c" 1>&6
-echo "configure:2023: checking for 8-bit clean memcmp" >&5
+echo "configure:1975: checking for 8-bit clean memcmp" >&5
if eval "test \"`echo '$''{'ac_cv_func_memcmp_clean'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2027,7 +1979,7 @@ else
ac_cv_func_memcmp_clean=no
else
cat > conftest.$ac_ext <<EOF
-#line 2031 "configure"
+#line 1983 "configure"
#include "confdefs.h"
main()
@@ -2037,7 +1989,7 @@ main()
}
EOF
-if { (eval echo configure:2041: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1993: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_memcmp_clean=yes
else
@@ -2055,12 +2007,12 @@ echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6
test $ac_cv_func_memcmp_clean = no && LIBOBJS="$LIBOBJS memcmp.${ac_objext}"
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:2059: checking return type of signal handlers" >&5
+echo "configure:2011: checking return type of signal handlers" >&5
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2064 "configure"
+#line 2016 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -2077,7 +2029,7 @@ int main() {
int i;
; return 0; }
EOF
-if { (eval echo configure:2081: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:2033: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
@@ -2098,12 +2050,12 @@ EOF
for ac_func in gettimeofday select strcspn strerror strspn sigaction
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2102: checking for $ac_func" >&5
+echo "configure:2054: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2107 "configure"
+#line 2059 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2126,7 +2078,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2130: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2082: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2151,6 +2103,52 @@ fi
done
+if test -n $with_ogg; then
+ CFLAGS="$CFLAGS -I$with_ogg/include -L$with_ogg/lib"
+fi
+echo $ac_n "checking for oggpack_read in -logg""... $ac_c" 1>&6
+echo "configure:2111: checking for oggpack_read in -logg" >&5
+ac_lib_var=`echo ogg'_'oggpack_read | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-logg $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2119 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char oggpack_read();
+
+int main() {
+oggpack_read()
+; return 0; }
+EOF
+if { (eval echo configure:2130: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ LIBS="$LIBS -logg"
+else
+ echo "$ac_t""no" 1>&6
+{ echo "configure: error: You must have libogg to compile vorbis!!!" 1>&2; exit 1; }
+fi
+
+
+
@@ -2161,8 +2159,6 @@ done
-#AC_SUBST(XOGG)
-#AC_SUBST(LIBGTKDIR)
subdirs="vorbis-tools/libao"
@@ -2280,7 +2276,7 @@ done
ac_given_srcdir=$srcdir
-trap 'rm -fr `echo "Makefile lib/Makefile examples/Makefile include/vorbis/os_types.h\
+trap 'rm -fr `echo "Makefile lib/Makefile examples/Makefile\
vorbis-tools/Makefile\
vq/Makefile huff/Makefile xmms/Makefile kmpg/Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
@@ -2376,7 +2372,7 @@ EOF
cat >> $CONFIG_STATUS <<EOF
-CONFIG_FILES=\${CONFIG_FILES-"Makefile lib/Makefile examples/Makefile include/vorbis/os_types.h\
+CONFIG_FILES=\${CONFIG_FILES-"Makefile lib/Makefile examples/Makefile\
vorbis-tools/Makefile\
vq/Makefile huff/Makefile xmms/Makefile kmpg/Makefile"}
EOF
diff --git a/configure.in b/configure.in
index 67fa0821..47964bcc 100644
--- a/configure.in
+++ b/configure.in
@@ -1,7 +1,9 @@
-# $Id: configure.in,v 1.20.2.3 2000/09/02 05:19:24 xiphmont Exp $
+# $Id: configure.in,v 1.20.2.3.2.1 2000/09/03 08:34:51 jack Exp $
AC_INIT(lib/mdct.c)
-#AC_CONFIG_HEADER(config.h)
+
+dnl Do some additional argument setup
+AC_ARG_WITH(ogg, [ --with-ogg=DIR Set where the Ogg library is located])
cp configure.guess config.guess
cp configure.sub config.sub
@@ -17,12 +19,6 @@ case $host in
fi
AC_CHECK_LIB(audio, ALwritesamps)
;;
-# BeOS does not use -lm
-# *-*-beos)
-# LIBS=""
-# ;;
-# added better check below
-
esac
cflags_save="$CFLAGS"
@@ -35,9 +31,6 @@ AC_PROG_RANLIB
AC_CHECK_PROG(AR,ar,ar)
AC_CHECK_PROG(INSTALL,install,install)
-#not everyone uses libm (eg, BeOS)
-#AC_CHECK_LIB(m, cos, LIBS="-lm"; AC_DEFINE(HAVE_LIBM), LIBS="")
-# We no longer use config.h
AC_CHECK_LIB(m, cos, LIBS="-lm", LIBS="")
dnl Set some target options
@@ -124,44 +117,8 @@ AC_HEADER_STDC
dnl AC_PATH_X
dnl AC_PATH_XTRA
-#AC_CHECK_LIB(pthread, pthread_create,
-# pthread_lib="-lpthread"; AC_DEFINE(HAVE_LIBPTHREAD), :)
-# We no longer use config.h
AC_CHECK_LIB(pthread, pthread_create, pthread_lib="-lpthread", :)
-#dnl Linuxthreads require you to define _REENTRANT in all threaded
-#dnl code. Bogus, bogus...
-#
-#if test -n "$pthread_lib"; then
-# case $host in
-# i?86-*-linux*)
-# AC_DEFINE(_REENTRANT)
-# ;;
-# esac
-#fi
-# We no longer use config.h
-
-#if test -n "$x_libraries"; then
-# XOGG="yes"
-#
-# dnl If we find libgtk installed, great; otherwise assume we have
-# dnl to build it ourselves.
-#
-# AC_CHECK_LIB(gtk, gtk_main, :, LIBGTKDIR="libgtk", $X_LIBS -lglib -lgdk -lX11 -lXext -lm)
-#
-# dnl libpthread is required for xogg.
-#
-# if test -z "$pthread_lib"; then XOGG=""; fi
-#
-# dnl If we don't have libgtk installed, and we don't have a libgtk
-# dnl subdirectory to build the library ourself, we can't build xogg.
-#
-# if test -n "$LIBGTKDIR" -a ! -d "$LIBGTKDIR"; then
-# XOGG=""
-# LIBGTKDIR=""
-# fi
-#fi
-
dnl This seems to be the only way to make autoconf only *sometimes* configure
dnl a subdirectory with AC_CONFIG_SUBDIRS. "__noconf" is assumed to not
dnl exist as a directory, so configure won't try to recursively enter it, unless
@@ -170,15 +127,8 @@ dnl if clause.
dummy="__noconf"
-#if test -d "$LIBGTKDIR"; then
-# enable_shared="no"; export enable_shared
-# dummy="libgtk"
-# AC_CONFIG_SUBDIRS("$dummy")
-# X_LIBS="-L${srcdir}/libgtk/gtk/.libs -L${srcdir}/libgtk/gdk/.libs -L${srcdir}/libgtk/glib/.libs $X_LIBS"
-#fi
-
-# check macro modified from Jon Shiring's to compensate for autoconf's lagging
-# behind the times on type madness
+dnl check macro modified from Jon Shiring's to compensate for autoconf's lagging
+dnl behind the times on type madness
AC_MSG_CHECKING(for int16_t)
AC_CACHE_VAL(has_int16_t,
@@ -322,9 +272,6 @@ if test -z "$SIZE64"; then
AC_MSG_WARN(No 64 bit type found on this platform!)
fi
-#AC_CHECK_HEADER(alloca.h,AC_DEFINE(USE_ALLOCA_H),:)
-#AC_CHECK_HEADER(memory.h,AC_DEFINE(USE_MEMORY_H),:)
-# We no longer use config.h
AC_CHECK_HEADER(alloca.h,CFLAGS="$CFLAGS -DUSE_ALLOCA_H",:)
AC_CHECK_HEADER(memory.h,CFLAGS="$CFLAGS -DUSE_MEMORY_H",:)
@@ -337,6 +284,13 @@ AC_FUNC_MEMCMP
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(gettimeofday select strcspn strerror strspn sigaction)
+dnl Check for libogg
+if test -n $with_ogg; then
+ CFLAGS="$CFLAGS -I$with_ogg/include -L$with_ogg/lib"
+fi
+AC_CHECK_LIB(ogg, oggpack_read, LIBS="$LIBS -logg", AC_MSG_ERROR([You must have libogg to compile vorbis!!!]))
+
+
AC_SUBST(SIZE16)
AC_SUBST(SIZE32)
AC_SUBST(USIZE32)
@@ -347,13 +301,11 @@ AC_SUBST(DEBUG)
AC_SUBST(PROFILE)
AC_SUBST(CC)
AC_SUBST(RANLIB)
-#AC_SUBST(XOGG)
-#AC_SUBST(LIBGTKDIR)
AC_SUBST(pthread_lib)
AC_CONFIG_SUBDIRS(vorbis-tools/libao)
-AC_OUTPUT(Makefile lib/Makefile examples/Makefile include/vorbis/os_types.h\
+AC_OUTPUT(Makefile lib/Makefile examples/Makefile\
vorbis-tools/Makefile\
vq/Makefile huff/Makefile xmms/Makefile kmpg/Makefile)
diff --git a/examples/Makefile.in b/examples/Makefile.in
new file mode 100644
index 00000000..e4162328
--- /dev/null
+++ b/examples/Makefile.in
@@ -0,0 +1,87 @@
+# vorbis makefile configured for use with gcc on any platform
+
+# $Id: Makefile.in,v 1.13.4.1 2000/09/03 08:34:51 jack Exp $
+
+###############################################################################
+# #
+# To build a production vorbis (preferrably using gmake), just type 'make'. #
+# To build with debugging or profiling information, use 'make debug' or #
+# 'make profile' respectively. 'make clean' is a good idea between builds #
+# with different target names, or before a final build. #
+# #
+###############################################################################
+
+
+# DO NOT EDIT BELOW! ##########################################################
+# (unless, of course, you know what you are doing :) ##########################
+
+@SET_MAKE@
+FLAGS=-I. -I../include @CFLAGS@
+OPT=@OPT@ $(FLAGS)
+DEBUG=@DEBUG@ $(FLAGS)
+PROFILE=@PROFILE@ $(FLAGS)
+CC=@CC@
+LD=@CC@
+LDFLAGS=@LDFLAGS@ $(FLAGS)
+AR=@AR@
+RANLIB=@RANLIB@
+LIBS=@LIBS@
+
+HFILES = ../include/vorbis/codec.h ../include/vorbis/vorbisfile.h \
+ ../include/vorbis/backends.h \
+ ../include/vorbis/codebook.h
+OFILES = encoder_example.o decoder_example.o chaining_example.o \
+ vorbisfile_example.o seeking_test.o
+BINFILES = encoder_example decoder_example chaining_example \
+ vorbisfile_example seeking_test
+
+all:
+ $(MAKE) target CFLAGS="$(OPT)"
+
+debug:
+ $(MAKE) target CFLAGS="$(DEBUG)"
+
+profile:
+ $(MAKE) target CFLAGS="$(PROFILE)"
+
+target: $(BINFILES)
+
+encoder_example.o: ../include/vorbis/modes.h
+
+encoder_example: $(OFILES) ../lib/libvorbis.a
+ $(CC) $(CFLAGS) $(LDFLAGS) encoder_example.o ../lib/libvorbis.a -o \
+ encoder_example $(LIBS)
+
+decoder_example: $(OFILES) ../lib/libvorbis.a
+ $(CC) $(CFLAGS) $(LDFLAGS) decoder_example.o ../lib/libvorbis.a -o \
+ decoder_example $(LIBS)
+
+chaining_example: $(OFILES) ../lib/libvorbis.a ../lib/vorbisfile.a
+ $(CC) $(CFLAGS) $(LDFLAGS) chaining_example.o \
+ ../lib/vorbisfile.a ../lib/libvorbis.a \
+ -o chaining_example $(LIBS)
+vorbisfile_example: $(OFILES) ../lib/libvorbis.a ../lib/vorbisfile.a
+ $(CC) $(CFLAGS) $(LDFLAGS) vorbisfile_example.o \
+ ../lib/vorbisfile.a ../lib/libvorbis.a \
+ -o vorbisfile_example $(LIBS)
+
+seeking_test: $(OFILES) ../lib/libvorbis.a ../lib/vorbisfile.a
+ $(CC) $(CFLAGS) $(LDFLAGS) seeking_test.o \
+ ../lib/vorbisfile.a ../lib/libvorbis.a \
+ -o seeking_test $(LIBS)
+
+selftest:
+
+$(OFILES): $(HFILES)
+
+.c.o:
+ $(CC) $(CFLAGS) -c $<
+
+clean:
+ -rm -f *.o *.a test* *~ *.out ogg config.* \
+ encoder_example decoder_example chaining_example \
+ vorbisfile_example seeking_test
+
+distclean: clean
+ -rm -f Makefile
+
diff --git a/examples/chaining_example.c b/examples/chaining_example.c
new file mode 100644
index 00000000..1bcd65c9
--- /dev/null
+++ b/examples/chaining_example.c
@@ -0,0 +1,69 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000 *
+ * by Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: illustrate simple use of chained bitstream and vorbisfile.a
+ last mod: $Id: chaining_example.c,v 1.5.8.1 2000/09/03 08:34:51 jack Exp $
+
+ ********************************************************************/
+
+#include <vorbis/codec.h>
+#include <vorbis/vorbisfile.h>
+
+int main(){
+ OggVorbis_File ov;
+ int i;
+
+ /* open the file/pipe on stdin */
+ if(ov_open(stdin,&ov,NULL,-1)==-1){
+ printf("Could not open input as an OggVorbis file.\n\n");
+ exit(1);
+ }
+
+ /* print details about each logical bitstream in the input */
+ if(ov_seekable(&ov)){
+ printf("Input bitstream contained %ld logical bitstream section(s).\n",
+ ov_streams(&ov));
+ printf("Total bitstream playing time: %ld seconds\n\n",
+ (long)ov_time_total(&ov,-1));
+
+ }else{
+ printf("Standard input was not seekable.\n"
+ "First logical bitstream information:\n\n");
+ }
+
+ for(i=0;i<ov_streams(&ov);i++){
+ vorbis_info *vi=ov_info(&ov,i);
+ printf("\tlogical bitstream section %d information:\n",i+1);
+ printf("\t\t%ldHz %d channels bitrate %ldkbps serial number=%ld\n",
+ vi->rate,vi->channels,ov_bitrate(&ov,i)/1000,
+ ov_serialnumber(&ov,i));
+ printf("\t\tcompressed length: %ld bytes ",(long)(ov_raw_total(&ov,i)));
+ printf(" play time: %lds\n",(long)ov_time_total(&ov,i));
+ }
+
+ ov_clear(&ov);
+ return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/decoder_example.c b/examples/decoder_example.c
index 35fb4a0d..796f79af 100644
--- a/examples/decoder_example.c
+++ b/examples/decoder_example.c
@@ -12,7 +12,7 @@
********************************************************************
function: simple example decoder
- last mod: $Id: decoder_example.c,v 1.11.2.3 2000/09/02 05:19:24 xiphmont Exp $
+ last mod: $Id: decoder_example.c,v 1.11.2.3.2.1 2000/09/03 08:34:51 jack Exp $
********************************************************************/
@@ -25,7 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
-#include "vorbis/codec.h"
+#include <vorbis/codec.h>
#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */
#include <io.h>
diff --git a/examples/encoder_example.c b/examples/encoder_example.c
index 8cc892f5..7d66b131 100644
--- a/examples/encoder_example.c
+++ b/examples/encoder_example.c
@@ -12,7 +12,7 @@
********************************************************************
function: simple example encoder
- last mod: $Id: encoder_example.c,v 1.13.2.1 2000/08/31 08:59:58 xiphmont Exp $
+ last mod: $Id: encoder_example.c,v 1.13.2.1.2.1 2000/09/03 08:34:51 jack Exp $
********************************************************************/
@@ -25,7 +25,7 @@
#include <stdlib.h>
#include <time.h>
#include <math.h>
-#include "vorbis/mode_C.h"
+#include <vorbis/mode_C.h>
#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */
#include <io.h>
diff --git a/examples/seeking_example.c b/examples/seeking_example.c
new file mode 100644
index 00000000..79525cb3
--- /dev/null
+++ b/examples/seeking_example.c
@@ -0,0 +1,65 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000 *
+ * by Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: illustrate seeking, and test it too
+ last mod: $Id: seeking_example.c,v 1.3.6.1 2000/09/03 08:34:51 jack Exp $
+
+ ********************************************************************/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <vorbis/codec.h>
+#include <vorbis/vorbisfile.h>
+
+int main(){
+ OggVorbis_File ov;
+ int i;
+
+ /* open the file/pipe on stdin */
+ if(ov_open(stdin,&ov,NULL,-1)==-1){
+ printf("Could not open input as an OggVorbis file.\n\n");
+ exit(1);
+ }
+
+ /* print details about each logical bitstream in the input */
+ if(ov_seekable(&ov)){
+ double length=ov_time_total(&ov,-1);
+ printf("testing seeking to random places in %g seconds....\n",length);
+ for(i=0;i<100;i++){
+ double val=(double)rand()/RAND_MAX*length;
+ ov_time_seek(&ov,val);
+ printf("\r\t%d [%gs]... ",i,val);
+ fflush(stdout);
+ }
+
+ printf("\r \nOK.\n\n");
+ }else{
+ printf("Standard input was not seekable.\n");
+ }
+
+ ov_clear(&ov);
+ return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/vorbisfile_example.c b/examples/vorbisfile_example.c
new file mode 100644
index 00000000..bc0dfbf3
--- /dev/null
+++ b/examples/vorbisfile_example.c
@@ -0,0 +1,91 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000 *
+ * by Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: simple example decoder using vorbisfile
+ last mod: $Id: vorbisfile_example.c,v 1.1.8.1 2000/09/03 08:34:51 jack Exp $
+
+ ********************************************************************/
+
+/* Takes a vorbis bitstream from stdin and writes raw stereo PCM to
+ stdout using vorbisfile. Using vorbisfile is much simpler than
+ dealing with libvorbis. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <vorbis/codec.h>
+#include <vorbis/vorbisfile.h>
+
+#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */
+#include <io.h>
+#include <fcntl.h>
+#endif
+
+char pcmout[4096]; /* take 4k out of the data segment, not the stack */
+
+int main(int argc, char **argv){
+ OggVorbis_File vf;
+ int eof=0;
+ int current_section;
+
+#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
+ /* Beware the evil ifdef. We avoid these where we can, but this one we
+ cannot. Don't add any more, you'll probably go to hell if you do. */
+ _setmode( _fileno( stdin ), _O_BINARY );
+ _setmode( _fileno( stdout ), _O_BINARY );
+#endif
+
+ if(ov_open(stdin, &vf, NULL, 0) < 0) {
+ fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
+ exit(1);
+ }
+
+ /* Throw the comments plus a few lines about the bitstream we're
+ decoding */
+ {
+ char **ptr=ov_comment(&vf,-1)->user_comments;
+ vorbis_info *vi=ov_info(&vf,-1);
+ while(*ptr){
+ fprintf(stderr,"%s\n",*ptr);
+ ++ptr;
+ }
+ fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate);
+ fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor);
+ }
+
+ while(!eof){
+ long ret=ov_read(&vf,pcmout,sizeof(pcmout),0,2,1,&current_section);
+ switch(ret){
+ case 0:
+ /* EOF */
+ eof=1;
+ break;
+ case -1:
+ /* error in the stream. Not a problem, just reporting it in
+ case we (the app) cares. In this case, we don't. */
+ break;
+ default:
+ /* we don't bother dealing with sample rate changes, etc, but
+ you'll have to*/
+ fwrite(pcmout,1,ret,stdout);
+ break;
+ }
+ }
+
+ /* cleanup */
+ ov_clear(&vf);
+
+ fprintf(stderr,"Done.\n");
+ return(0);
+}
+
diff --git a/include/vorbis/codec.h b/include/vorbis/codec.h
index 9a1a8c5a..cd853e6f 100644
--- a/include/vorbis/codec.h
+++ b/include/vorbis/codec.h
@@ -12,7 +12,7 @@
********************************************************************
function: libvorbis codec headers
- last mod: $Id: codec.h,v 1.27.2.2.2.1 2000/09/03 06:34:10 jack Exp $
+ last mod: $Id: codec.h,v 1.27.2.2.2.2 2000/09/03 08:34:51 jack Exp $
********************************************************************/
@@ -26,7 +26,7 @@ extern "C"
#define MAX_BARK 27
-#include <ogg/os_types.h>
+#include <ogg/ogg.h>
#include "vorbis/codebook.h"
typedef void vorbis_look_transform;
diff --git a/lib/Makefile.in b/lib/Makefile.in
index c82532d3..0e9b7a9b 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -1,5 +1,5 @@
# vorbis makefile configured for use with gcc on any platform
-# $Id: Makefile.in,v 1.33.4.1 2000/08/31 08:05:47 xiphmont Exp $
+# $Id: Makefile.in,v 1.33.4.1.2.1 2000/09/03 08:34:51 jack Exp $
###############################################################################
# #
@@ -24,25 +24,25 @@ LD=@CC@
LDFLAGS=@LDFLAGS@ $(FLAGS)
AR=@AR@
RANLIB=@RANLIB@
-LIBS=@LIBS@
+LIBS=@LIBS@
HFILES = ../include/vorbis/codec.h \
- ../include/vorbis/internal.h ../include/vorbis/backends.h \
+ ../include/vorbis/backends.h \
../include/vorbis/codebook.h \
- bitwise.h envelope.h lpc.h lsp.h bookinternal.h misc.h\
+ envelope.h lpc.h lsp.h bookinternal.h misc.h\
psy.h smallft.h window.h scales.h os.h mdct.h registry.h\
masking.h sharedbook.h iir.h
-LFILES = framing.o mdct.o smallft.o block.o envelope.o window.o\
- lsp.o lpc.o analysis.o synthesis.o psy.o info.o bitwise.o\
+LFILES = mdct.o smallft.o block.o envelope.o window.o\
+ lsp.o lpc.o analysis.o synthesis.o psy.o info.o\
time0.o floor0.o res0.o mapping0.o registry.o\
codebook.o sharedbook.o iir.o
VF_HFILES = ../include/vorbis/vorbisfile.h ../include/vorbis/codec.h \
- ../include/vorbis/internal.h ../include/vorbis/codebook.h \
+ ../include/vorbis/codebook.h \
os.h misc.h
VF_LFILES = vorbisfile.o
PSY_FILES = mdct.o psy.o lpc.o smallft.o window.o psytune.o floor0.o \
- bitwise.o lsp.o codebook.o sharedbook.o
+ lsp.o codebook.o sharedbook.o
all:
$(MAKE) target CFLAGS="$(OPT)"
@@ -60,18 +60,12 @@ target: libvorbis.a vorbisfile.a psytune
selftest:
$(MAKE) clean
- $(CC) $(DEBUG) $(LDFLAGS) -D_V_SELFTEST framing.c -o test_framing
- $(CC) $(DEBUG) $(LDFLAGS) -D_V_SELFTEST bitwise.c\
- -o test_bitwise $(LIBS)
- $(CC) $(DEBUG) $(LDFLAGS) -c bitwise.c
$(CC) $(DEBUG) $(LDFLAGS) -D_V_SELFTEST sharedbook.c\
-o test_sharedbook $(LIBS)
$(CC) $(DEBUG) $(LDFLAGS) -c sharedbook.c
$(CC) $(DEBUG) $(LDFLAGS) -D_V_SELFTEST codebook.c \
- sharedbook.o bitwise.o -o test_codebook $(LIBS)
+ sharedbook.o -o test_codebook $(LIBS)
@echo
- @./test_framing
- @./test_bitwise
@./test_sharedbook
@./test_codebook
diff --git a/lib/analysis.c b/lib/analysis.c
index 09f69484..5171eb80 100644
--- a/lib/analysis.c
+++ b/lib/analysis.c
@@ -12,15 +12,15 @@
********************************************************************
function: single-block PCM analysis mode dispatch
- last mod: $Id: analysis.c,v 1.33.2.2 2000/09/02 09:39:19 xiphmont Exp $
+ last mod: $Id: analysis.c,v 1.33.2.2.2.1 2000/09/03 08:34:51 jack Exp $
********************************************************************/
#include <stdio.h>
#include <string.h>
#include <math.h>
+#include <ogg/ogg.h>
#include "vorbis/codec.h"
-#include "bitwise.h"
#include "registry.h"
#include "scales.h"
#include "os.h"
@@ -38,9 +38,9 @@ int vorbis_analysis(vorbis_block *vb,ogg_packet *op){
vb->res_bits=0;
/* first things first. Make sure encode is ready */
- _oggpack_reset(&vb->opb);
+ oggpack_reset(&vb->opb);
/* Encode the packet type */
- _oggpack_write(&vb->opb,0,1);
+ oggpack_write(&vb->opb,0,1);
/* currently lazy. Short block dispatches to 0, long to 1. */
@@ -49,10 +49,10 @@ int vorbis_analysis(vorbis_block *vb,ogg_packet *op){
vb->mode=mode;
/* Encode frame mode, pre,post windowsize, then dispatch */
- _oggpack_write(&vb->opb,mode,vd->modebits);
+ oggpack_write(&vb->opb,mode,vd->modebits);
if(vb->W){
- _oggpack_write(&vb->opb,vb->lW,1);
- _oggpack_write(&vb->opb,vb->nW,1);
+ oggpack_write(&vb->opb,vb->lW,1);
+ oggpack_write(&vb->opb,vb->nW,1);
fprintf(stderr,"*");
}else{
fprintf(stderr,".");
@@ -63,8 +63,8 @@ int vorbis_analysis(vorbis_block *vb,ogg_packet *op){
/* set up the packet wrapper */
- op->packet=_oggpack_buffer(&vb->opb);
- op->bytes=_oggpack_bytes(&vb->opb);
+ op->packet=oggpack_get_buffer(&vb->opb);
+ op->bytes=oggpack_bytes(&vb->opb);
op->b_o_s=0;
op->e_o_s=vb->eofflag;
op->frameno=vb->frameno;
diff --git a/lib/block.c b/lib/block.c
index f2411e40..8fdb1bcb 100644
--- a/lib/block.c
+++ b/lib/block.c
@@ -12,7 +12,7 @@
********************************************************************
function: PCM data vector blocking, windowing and dis/reassembly
- last mod: $Id: block.c,v 1.38.2.2 2000/09/02 05:19:24 xiphmont Exp $
+ last mod: $Id: block.c,v 1.38.2.2.2.1 2000/09/03 08:34:51 jack Exp $
Handle windowing, overlap-add, etc of the PCM vectors. This is made
more amusing by Vorbis' current two allowed block sizes.
@@ -26,13 +26,13 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ogg/ogg.h>
#include "vorbis/codec.h"
#include "window.h"
#include "envelope.h"
#include "mdct.h"
#include "lpc.h"
-#include "bitwise.h"
#include "registry.h"
#include "sharedbook.h"
#include "bookinternal.h"
@@ -98,7 +98,7 @@ int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb){
vb->localalloc=0;
vb->localstore=NULL;
if(v->analysisp)
- _oggpack_writeinit(&vb->opb);
+ oggpack_writeinit(&vb->opb);
return(0);
}
@@ -152,7 +152,7 @@ void _vorbis_block_ripcord(vorbis_block *vb){
int vorbis_block_clear(vorbis_block *vb){
if(vb->vd)
if(vb->vd->analysisp)
- _oggpack_writeclear(&vb->opb);
+ oggpack_writeclear(&vb->opb);
_vorbis_block_ripcord(vb);
if(vb->localstore)free(vb->localstore);
diff --git a/lib/bookinternal.h b/lib/bookinternal.h
index 6f0627d2..0daa0dbc 100644
--- a/lib/bookinternal.h
+++ b/lib/bookinternal.h
@@ -12,15 +12,15 @@
********************************************************************
function: basic codebook pack/unpack/code/decode operations
- last mod: $Id: bookinternal.h,v 1.8.6.2 2000/09/02 05:19:24 xiphmont Exp $
+ last mod: $Id: bookinternal.h,v 1.8.6.2.2.1 2000/09/03 08:34:52 jack Exp $
********************************************************************/
#ifndef _V_INT_CODEBOOK_H_
#define _V_INT_CODEBOOK_H_
+#include <ogg/ogg.h>
#include "vorbis/codebook.h"
-#include "bitwise.h"
extern int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *b);
extern int vorbis_staticbook_unpack(oggpack_buffer *b,static_codebook *c);
diff --git a/lib/codebook.c b/lib/codebook.c
index 260c15c8..d3d4c2d3 100644
--- a/lib/codebook.c
+++ b/lib/codebook.c
@@ -12,16 +12,16 @@
********************************************************************
function: basic codebook pack/unpack/code/decode operations
- last mod: $Id: codebook.c,v 1.17.4.2 2000/09/02 05:19:24 xiphmont Exp $
+ last mod: $Id: codebook.c,v 1.17.4.2.2.1 2000/09/03 08:34:52 jack Exp $
********************************************************************/
#include <stdlib.h>
#include <string.h>
#include <math.h>
+#include <ogg/ogg.h>
#include "vorbis/codec.h"
#include "vorbis/codebook.h"
-#include "bitwise.h"
#include "scales.h"
#include "sharedbook.h"
#include "bookinternal.h"
@@ -35,9 +35,9 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){
int ordered=0;
/* first the basic parameters */
- _oggpack_write(opb,0x564342,24);
- _oggpack_write(opb,c->dim,16);
- _oggpack_write(opb,c->entries,24);
+ oggpack_write(opb,0x564342,24);
+ oggpack_write(opb,c->dim,16);
+ oggpack_write(opb,c->entries,24);
/* pack the codewords. There are two packings; length ordered and
length random. Decide between the two now. */
@@ -52,25 +52,25 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){
deterministically */
long count=0;
- _oggpack_write(opb,1,1); /* ordered */
- _oggpack_write(opb,c->lengthlist[0]-1,5); /* 1 to 32 */
+ oggpack_write(opb,1,1); /* ordered */
+ oggpack_write(opb,c->lengthlist[0]-1,5); /* 1 to 32 */
for(i=1;i<c->entries;i++){
long this=c->lengthlist[i];
long last=c->lengthlist[i-1];
if(this>last){
for(j=last;j<this;j++){
- _oggpack_write(opb,i-count,_ilog(c->entries-count));
+ oggpack_write(opb,i-count,_ilog(c->entries-count));
count=i;
}
}
}
- _oggpack_write(opb,i-count,_ilog(c->entries-count));
+ oggpack_write(opb,i-count,_ilog(c->entries-count));
}else{
/* length random. Again, we don't code the codeword itself, just
the length. This time, though, we have to encode each length */
- _oggpack_write(opb,0,1); /* unordered */
+ oggpack_write(opb,0,1); /* unordered */
/* algortihmic mapping has use for 'unused entries', which we tag
here. The algorithmic mapping happens as usual, but the unused
@@ -79,17 +79,17 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){
if(c->lengthlist[i]==0)break;
if(i==c->entries){
- _oggpack_write(opb,0,1); /* no unused entries */
+ oggpack_write(opb,0,1); /* no unused entries */
for(i=0;i<c->entries;i++)
- _oggpack_write(opb,c->lengthlist[i]-1,5);
+ oggpack_write(opb,c->lengthlist[i]-1,5);
}else{
- _oggpack_write(opb,1,1); /* we have unused entries; thus we tag */
+ oggpack_write(opb,1,1); /* we have unused entries; thus we tag */
for(i=0;i<c->entries;i++){
if(c->lengthlist[i]==0){
- _oggpack_write(opb,0,1);
+ oggpack_write(opb,0,1);
}else{
- _oggpack_write(opb,1,1);
- _oggpack_write(opb,c->lengthlist[i]-1,5);
+ oggpack_write(opb,1,1);
+ oggpack_write(opb,c->lengthlist[i]-1,5);
}
}
}
@@ -97,7 +97,7 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){
/* is the entry number the desired return value, or do we have a
mapping? If we have a mapping, what type? */
- _oggpack_write(opb,c->maptype,4);
+ oggpack_write(opb,c->maptype,4);
switch(c->maptype){
case 0:
/* no mapping */
@@ -112,10 +112,10 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){
}
/* values that define the dequantization */
- _oggpack_write(opb,c->q_min,32);
- _oggpack_write(opb,c->q_delta,32);
- _oggpack_write(opb,c->q_quant-1,4);
- _oggpack_write(opb,c->q_sequencep,1);
+ oggpack_write(opb,c->q_min,32);
+ oggpack_write(opb,c->q_delta,32);
+ oggpack_write(opb,c->q_quant-1,4);
+ oggpack_write(opb,c->q_sequencep,1);
{
int quantvals;
@@ -133,7 +133,7 @@ int vorbis_staticbook_pack(const static_codebook *c,oggpack_buffer *opb){
/* quantized values */
for(i=0;i<quantvals;i++)
- _oggpack_write(opb,labs(c->quantlist[i]),c->q_quant);
+ oggpack_write(opb,labs(c->quantlist[i]),c->q_quant);
}
break;
@@ -152,26 +152,26 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
memset(s,0,sizeof(static_codebook));
/* make sure alignment is correct */
- if(_oggpack_read(opb,24)!=0x564342)goto _eofout;
+ if(oggpack_read(opb,24)!=0x564342)goto _eofout;
/* first the basic parameters */
- s->dim=_oggpack_read(opb,16);
- s->entries=_oggpack_read(opb,24);
+ s->dim=oggpack_read(opb,16);
+ s->entries=oggpack_read(opb,24);
if(s->entries==-1)goto _eofout;
/* codeword ordering.... length ordered or unordered? */
- switch(_oggpack_read(opb,1)){
+ switch(oggpack_read(opb,1)){
case 0:
/* unordered */
s->lengthlist=malloc(sizeof(long)*s->entries);
/* allocated but unused entries? */
- if(_oggpack_read(opb,1)){
+ if(oggpack_read(opb,1)){
/* yes, unused entries */
for(i=0;i<s->entries;i++){
- if(_oggpack_read(opb,1)){
- long num=_oggpack_read(opb,5);
+ if(oggpack_read(opb,1)){
+ long num=oggpack_read(opb,5);
if(num==-1)goto _eofout;
s->lengthlist[i]=num+1;
}else
@@ -180,7 +180,7 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
}else{
/* all entries used; no tagging */
for(i=0;i<s->entries;i++){
- long num=_oggpack_read(opb,5);
+ long num=oggpack_read(opb,5);
if(num==-1)goto _eofout;
s->lengthlist[i]=num+1;
}
@@ -190,11 +190,11 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
case 1:
/* ordered */
{
- long length=_oggpack_read(opb,5)+1;
+ long length=oggpack_read(opb,5)+1;
s->lengthlist=malloc(sizeof(long)*s->entries);
for(i=0;i<s->entries;){
- long num=_oggpack_read(opb,_ilog(s->entries-i));
+ long num=oggpack_read(opb,_ilog(s->entries-i));
if(num==-1)goto _eofout;
for(j=0;j<num;j++,i++)
s->lengthlist[i]=length;
@@ -208,7 +208,7 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
}
/* Do we have a mapping to unpack? */
- switch((s->maptype=_oggpack_read(opb,4))){
+ switch((s->maptype=oggpack_read(opb,4))){
case 0:
/* no mapping */
break;
@@ -216,10 +216,10 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
/* implicitly populated value mapping */
/* explicitly populated value mapping */
- s->q_min=_oggpack_read(opb,32);
- s->q_delta=_oggpack_read(opb,32);
- s->q_quant=_oggpack_read(opb,4)+1;
- s->q_sequencep=_oggpack_read(opb,1);
+ s->q_min=oggpack_read(opb,32);
+ s->q_delta=oggpack_read(opb,32);
+ s->q_quant=oggpack_read(opb,4)+1;
+ s->q_sequencep=oggpack_read(opb,1);
{
int quantvals;
@@ -235,7 +235,7 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
/* quantized values */
s->quantlist=malloc(sizeof(float)*quantvals);
for(i=0;i<quantvals;i++)
- s->quantlist[i]=_oggpack_read(opb,s->q_quant);
+ s->quantlist[i]=oggpack_read(opb,s->q_quant);
if(s->quantlist[quantvals-1]==-1)goto _eofout;
}
@@ -255,7 +255,7 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
/* returns the number of bits ************************************************/
int vorbis_book_encode(codebook *book, int a, oggpack_buffer *b){
- _oggpack_write(b,book->codelist[a],book->c->lengthlist[a]);
+ oggpack_write(b,book->codelist[a],book->c->lengthlist[a]);
return(book->c->lengthlist[a]);
}
@@ -317,17 +317,17 @@ int vorbis_book_encodevs(codebook *book,float *a,oggpack_buffer *b,
long vorbis_book_decode(codebook *book, oggpack_buffer *b){
long ptr=0;
decode_aux *t=book->decode_tree;
- int lok = _oggpack_look(b, t->tabn);
+ int lok = oggpack_look(b, t->tabn);
if (lok >= 0) {
ptr = t->tab[lok];
- _oggpack_adv(b, t->tabl[lok]);
+ oggpack_adv(b, t->tabl[lok]);
if (ptr <= 0)
return -ptr;
}
do{
- switch(_oggpack_read1(b)){
+ switch(oggpack_read1(b)){
case 0:
ptr=t->ptr0[ptr];
break;
@@ -495,7 +495,7 @@ int main(){
oggpack_buffer write;
oggpack_buffer read;
long ptr=0,i;
- _oggpack_writeinit(&write);
+ oggpack_writeinit(&write);
fprintf(stderr,"Testing codebook abstraction...:\n");
@@ -510,11 +510,11 @@ int main(){
fprintf(stderr,"\tpacking/coding %ld... ",ptr);
/* pack the codebook, write the testvector */
- _oggpack_reset(&write);
+ oggpack_reset(&write);
vorbis_book_init_encode(&c,testlist[ptr]); /* get it into memory
we can write */
vorbis_staticbook_pack(testlist[ptr],&write);
- fprintf(stderr,"Codebook size %ld bytes... ",_oggpack_bytes(&write));
+ fprintf(stderr,"Codebook size %ld bytes... ",oggpack_bytes(&write));
for(i=0;i<TESTSIZE;i+=c.dim){
int best=_best(&c,qv+i,1);
vorbis_book_encodev(&c,best,qv+i,&write);
@@ -525,7 +525,7 @@ int main(){
fprintf(stderr,"\tunpacking/decoding %ld... ",ptr);
/* transfer the write data to a read buffer and unpack/read */
- _oggpack_readinit(&read,_oggpack_buffer(&write),_oggpack_bytes(&write));
+ oggpack_readinit(&read,oggpack_get_buffer(&write),oggpack_bytes(&write));
if(vorbis_staticbook_unpack(&read,&s)){
fprintf(stderr,"Error unpacking codebook.\n");
exit(1);
diff --git a/lib/envelope.c b/lib/envelope.c
index 1d0090a5..0eada7ab 100644
--- a/lib/envelope.c
+++ b/lib/envelope.c
@@ -12,7 +12,7 @@
********************************************************************
function: PCM data envelope analysis and manipulation
- last mod: $Id: envelope.c,v 1.21.2.2 2000/08/31 09:00:00 xiphmont Exp $
+ last mod: $Id: envelope.c,v 1.21.2.2.2.1 2000/09/03 08:34:52 jack Exp $
Preecho calculation.
@@ -22,12 +22,12 @@
#include <string.h>
#include <stdio.h>
#include <math.h>
+#include <ogg/ogg.h>
#include "vorbis/codec.h"
#include "os.h"
#include "scales.h"
#include "envelope.h"
-#include "bitwise.h"
#include "misc.h"
/* We use a Chebyshev bandbass for the preecho trigger bandpass; it's
diff --git a/lib/floor0.c b/lib/floor0.c
index b3006b54..3587ee1b 100644
--- a/lib/floor0.c
+++ b/lib/floor0.c
@@ -12,15 +12,15 @@
********************************************************************
function: floor backend 0 implementation
- last mod: $Id: floor0.c,v 1.23.2.3 2000/09/02 05:19:25 xiphmont Exp $
+ last mod: $Id: floor0.c,v 1.23.2.3.2.1 2000/09/03 08:34:52 jack Exp $
********************************************************************/
#include <stdlib.h>
#include <string.h>
#include <math.h>
+#include <ogg/ogg.h>
#include "vorbis/codec.h"
-#include "bitwise.h"
#include "registry.h"
#include "lpc.h"
#include "lsp.h"
@@ -91,25 +91,25 @@ static void floor0_free_look(vorbis_look_floor *i){
static void floor0_pack (vorbis_info_floor *i,oggpack_buffer *opb){
vorbis_info_floor0 *info=(vorbis_info_floor0 *)i;
int j;
- _oggpack_write(opb,info->order,8);
- _oggpack_write(opb,info->rate,16);
- _oggpack_write(opb,info->barkmap,16);
- _oggpack_write(opb,info->ampbits,6);
- _oggpack_write(opb,info->ampdB,8);
- _oggpack_write(opb,info->numbooks-1,4);
+ oggpack_write(opb,info->order,8);
+ oggpack_write(opb,info->rate,16);
+ oggpack_write(opb,info->barkmap,16);
+ oggpack_write(opb,info->ampbits,6);
+ oggpack_write(opb,info->ampdB,8);
+ oggpack_write(opb,info->numbooks-1,4);
for(j=0;j<info->numbooks;j++)
- _oggpack_write(opb,info->books[j],8);
+ oggpack_write(opb,info->books[j],8);
}
static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){
int j;
vorbis_info_floor0 *info=malloc(sizeof(vorbis_info_floor0));
- info->order=_oggpack_read(opb,8);
- info->rate=_oggpack_read(opb,16);
- info->barkmap=_oggpack_read(opb,16);
- info->ampbits=_oggpack_read(opb,6);
- info->ampdB=_oggpack_read(opb,8);
- info->numbooks=_oggpack_read(opb,4)+1;
+ info->order=oggpack_read(opb,8);
+ info->rate=oggpack_read(opb,16);
+ info->barkmap=oggpack_read(opb,16);
+ info->ampbits=oggpack_read(opb,6);
+ info->ampdB=oggpack_read(opb,8);
+ info->numbooks=oggpack_read(opb,4)+1;
if(info->order<1)goto err_out;
if(info->rate<1)goto err_out;
@@ -117,7 +117,7 @@ static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){
if(info->numbooks<1)goto err_out;
for(j=0;j<info->numbooks;j++){
- info->books[j]=_oggpack_read(opb,8);
+ info->books[j]=oggpack_read(opb,8);
if(info->books[j]<0 || info->books[j]>=vi->books)goto err_out;
}
return(info);
@@ -321,7 +321,7 @@ static int floor0_forward(vorbis_block *vb,vorbis_look_floor *i,
if(val<0)val=0; /* likely */
if(val>maxval)val=maxval; /* not bloody likely */
- _oggpack_write(&vb->opb,val,info->ampbits);
+ oggpack_write(&vb->opb,val,info->ampbits);
if(val>0)
amp=(float)val/maxval*info->ampdB;
else
@@ -333,7 +333,7 @@ static int floor0_forward(vorbis_block *vb,vorbis_look_floor *i,
/* the spec supports using one of a number of codebooks. Right
now, encode using this lib supports only one */
codebook *b=vb->vd->fullbooks+info->books[0];
- _oggpack_write(&vb->opb,0,_ilog(info->numbooks));
+ oggpack_write(&vb->opb,0,_ilog(info->numbooks));
/* LSP <-> LPC is orthogonal and LSP quantizes more stably */
vorbis_lpc_to_lsp(out,out,look->m);
@@ -397,11 +397,11 @@ static int floor0_inverse(vorbis_block *vb,vorbis_look_floor *i,float *out){
vorbis_info_floor0 *info=look->vi;
int j,k;
- int ampraw=_oggpack_read(&vb->opb,info->ampbits);
+ int ampraw=oggpack_read(&vb->opb,info->ampbits);
if(ampraw>0){ /* also handles the -1 out of data case */
long maxval=(1<<info->ampbits)-1;
float amp=(float)ampraw/maxval*info->ampdB;
- int booknum=_oggpack_read(&vb->opb,_ilog(info->numbooks));
+ int booknum=oggpack_read(&vb->opb,_ilog(info->numbooks));
if(booknum!=-1){
codebook *b=vb->vd->fullbooks+info->books[booknum];
diff --git a/lib/info.c b/lib/info.c
new file mode 100644
index 00000000..be2b7b37
--- /dev/null
+++ b/lib/info.c
@@ -0,0 +1,558 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
+ * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE. *
+ * PLEASE READ THESE TERMS DISTRIBUTING. *
+ * *
+ * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-2000 *
+ * by Monty <monty@xiph.org> and The XIPHOPHORUS Company *
+ * http://www.xiph.org/ *
+ * *
+ ********************************************************************
+
+ function: maintain the info structure, info <-> header packets
+ last mod: $Id: info.c,v 1.30.4.1 2000/09/03 08:34:52 jack Exp $
+
+ ********************************************************************/
+
+/* general handling of the header and the vorbis_info structure (and
+ substructures) */
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <ogg/ogg.h>
+#include "vorbis/codec.h"
+#include "vorbis/backends.h"
+#include "sharedbook.h"
+#include "bookinternal.h"
+#include "registry.h"
+#include "window.h"
+#include "psy.h"
+#include "misc.h"
+#include "os.h"
+
+/* helpers */
+static int ilog2(unsigned int v){
+ int ret=0;
+ while(v>1){
+ ret++;
+ v>>=1;
+ }
+ return(ret);
+}
+
+static void _v_writestring(oggpack_buffer *o,char *s){
+ while(*s){
+ oggpack_write(o,*s++,8);
+ }
+}
+
+static void _v_readstring(oggpack_buffer *o,char *buf,int bytes){
+ while(bytes--){
+ *buf++=oggpack_read(o,8);
+ }
+}
+
+void vorbis_comment_init(vorbis_comment *vc){
+ memset(vc,0,sizeof(vorbis_comment));
+}
+
+void vorbis_comment_add(vorbis_comment *vc,char *comment){
+ vc->user_comments=realloc(vc->user_comments,
+ (vc->comments+2)*sizeof(char *));
+ vc->comment_lengths=realloc(vc->comment_lengths,
+ (vc->comments+2)*sizeof(int));
+ vc->user_comments[vc->comments]=strdup(comment);
+ vc->comment_lengths[vc->comments]=strlen(comment);
+ vc->comments++;
+ vc->user_comments[vc->comments]=NULL;
+}
+
+void vorbis_comment_add_tag(vorbis_comment *vc, char *tag, char *contents){
+ char *comment=alloca(strlen(tag)+strlen(contents)+2); /* +2 for = and \0 */
+ strcpy(comment, tag);
+ strcat(comment, "=");
+ strcat(comment, contents);
+ vorbis_comment_add(vc, comment);
+}
+
+/* This is more or less the same as strncasecmp - but that doesn't exist
+ * everywhere, and this is a fairly trivial function, so we include it */
+static int tagcompare(const char *s1, const char *s2, int n){
+ int c=0;
+ while(c < n){
+ if(toupper(s1[c]) != toupper(s2[c]))
+ return !0;
+ c++;
+ }
+ return 0;
+}
+
+char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){
+ long i;
+ int found = 0;
+ int taglen = strlen(tag)+1; /* +1 for the = we append */
+ char *fulltag = alloca(taglen+ 1);
+
+ strcpy(fulltag, tag);
+ strcat(fulltag, "=");
+
+ for(i=0;i<vc->comments;i++){
+ if(!tagcompare(vc->user_comments[i], fulltag, taglen)){
+ if(count == found)
+ /* We return a pointer to the data, not a copy */
+ return vc->user_comments[i] + taglen;
+ else
+ found++;
+ }
+ }
+ return NULL; /* didn't find anything */
+}
+
+int vorbis_comment_query_count(vorbis_comment *vc, char *tag){
+ int i,count=0;
+ int taglen = strlen(tag)+1; /* +1 for the = we append */
+ char *fulltag = alloca(taglen+1);
+ strcpy(fulltag,tag);
+ strcat(fulltag, "=");
+
+ for(i=0;i<vc->comments;i++){
+ if(!tagcompare(vc->user_comments[i], fulltag, taglen))
+ count++;
+ }
+
+ return count;
+}
+
+void vorbis_comment_clear(vorbis_comment *vc){
+ if(vc){
+ long i;
+ for(i=0;i<vc->comments;i++)
+ if(vc->user_comments[i])free(vc->user_comments[i]);
+ if(vc->user_comments)free(vc->user_comments);
+ if(vc->comment_lengths)free(vc->comment_lengths);
+ if(vc->vendor)free(vc->vendor);
+ }
+ memset(vc,0,sizeof(vorbis_comment));
+}
+
+/* used by synthesis, which has a full, alloced vi */
+void vorbis_info_init(vorbis_info *vi){
+ memset(vi,0,sizeof(vorbis_info));
+}
+
+void vorbis_info_clear(vorbis_info *vi){
+ int i;
+
+ for(i=0;i<vi->modes;i++)
+ if(vi->mode_param[i])free(vi->mode_param[i]);
+ /*if(vi->mode_param)free(vi->mode_param);*/
+
+ for(i=0;i<vi->maps;i++) /* unpack does the range checking */
+ _mapping_P[vi->map_type[i]]->free_info(vi->map_param[i]);
+ /*if(vi->map_param)free(vi->map_param);*/
+
+ for(i=0;i<vi->times;i++) /* unpack does the range checking */
+ _time_P[vi->time_type[i]]->free_info(vi->time_param[i]);
+ /*if(vi->time_param)free(vi->time_param);*/
+
+ for(i=0;i<vi->floors;i++) /* unpack does the range checking */
+ _floor_P[vi->floor_type[i]]->free_info(vi->floor_param[i]);
+ /*if(vi->floor_param)free(vi->floor_param);*/
+
+ for(i=0;i<vi->residues;i++) /* unpack does the range checking */
+ _residue_P[vi->residue_type[i]]->free_info(vi->residue_param[i]);
+ /*if(vi->residue_param)free(vi->residue_param);*/
+
+ /* the static codebooks *are* freed if you call info_clear, because
+ decode side does alloc a 'static' codebook. Calling clear on the
+ full codebook does not clear the static codebook (that's our
+ responsibility) */
+ for(i=0;i<vi->books;i++){
+ /* just in case the decoder pre-cleared to save space */
+ if(vi->book_param[i]){
+ vorbis_staticbook_clear(vi->book_param[i]);
+ free(vi->book_param[i]);
+ }
+ }
+ /*if(vi->book_param)free(vi->book_param);*/
+
+ for(i=0;i<vi->psys;i++)
+ _vi_psy_free(vi->psy_param[i]);
+ /*if(vi->psy_param)free(vi->psy_param);*/
+
+ memset(vi,0,sizeof(vorbis_info));
+}
+
+/* Header packing/unpacking ********************************************/
+
+static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){
+ vi->version=oggpack_read(opb,32);
+ if(vi->version!=0)return(-1);
+
+ vi->channels=oggpack_read(opb,8);
+ vi->rate=oggpack_read(opb,32);
+
+ vi->bitrate_upper=oggpack_read(opb,32);
+ vi->bitrate_nominal=oggpack_read(opb,32);
+ vi->bitrate_lower=oggpack_read(opb,32);
+
+ vi->blocksizes[0]=1<<oggpack_read(opb,4);
+ vi->blocksizes[1]=1<<oggpack_read(opb,4);
+
+ if(vi->rate<1)goto err_out;
+ if(vi->channels<1)goto err_out;
+ if(vi->blocksizes[0]<8)goto err_out;
+ if(vi->blocksizes[1]<vi->blocksizes[0])goto err_out;
+
+ if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
+
+ return(0);
+ err_out:
+ vorbis_info_clear(vi);
+ return(-1);
+}
+
+static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){
+ int i;
+ int vendorlen=oggpack_read(opb,32);
+ if(vendorlen<0)goto err_out;
+ vc->vendor=calloc(vendorlen+1,1);
+ _v_readstring(opb,vc->vendor,vendorlen);
+ vc->comments=oggpack_read(opb,32);
+ if(vc->comments<0)goto err_out;
+ vc->user_comments=calloc(vc->comments+1,sizeof(char **));
+ vc->comment_lengths=calloc(vc->comments+1, sizeof(int));
+
+ for(i=0;i<vc->comments;i++){
+ int len=oggpack_read(opb,32);
+ if(len<0)goto err_out;
+ vc->comment_lengths[i]=len;
+ vc->user_comments[i]=calloc(len+1,1);
+ _v_readstring(opb,vc->user_comments[i],len);
+ }
+ if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
+
+ return(0);
+ err_out:
+ vorbis_comment_clear(vc);
+ return(-1);
+}
+
+/* all of the real encoding details are here. The modes, books,
+ everything */
+static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
+ int i;
+
+ /* codebooks */
+ vi->books=oggpack_read(opb,8)+1;
+ /*vi->book_param=calloc(vi->books,sizeof(static_codebook *));*/
+ for(i=0;i<vi->books;i++){
+ vi->book_param[i]=calloc(1,sizeof(static_codebook));
+ if(vorbis_staticbook_unpack(opb,vi->book_param[i]))goto err_out;
+ }
+
+ /* time backend settings */
+ vi->times=oggpack_read(opb,6)+1;
+ /*vi->time_type=malloc(vi->times*sizeof(int));*/
+ /*vi->time_param=calloc(vi->times,sizeof(void *));*/
+ for(i=0;i<vi->times;i++){
+ vi->time_type[i]=oggpack_read(opb,16);
+ if(vi->time_type[i]<0 || vi->time_type[i]>=VI_TIMEB)goto err_out;
+ vi->time_param[i]=_time_P[vi->time_type[i]]->unpack(vi,opb);
+ if(!vi->time_param[i])goto err_out;
+ }
+
+ /* floor backend settings */
+ vi->floors=oggpack_read(opb,6)+1;
+ /*vi->floor_type=malloc(vi->floors*sizeof(int));*/
+ /*vi->floor_param=calloc(vi->floors,sizeof(void *));*/
+ for(i=0;i<vi->floors;i++){
+ vi->floor_type[i]=oggpack_read(opb,16);
+ if(vi->floor_type[i]<0 || vi->floor_type[i]>=VI_FLOORB)goto err_out;
+ vi->floor_param[i]=_floor_P[vi->floor_type[i]]->unpack(vi,opb);
+ if(!vi->floor_param[i])goto err_out;
+ }
+
+ /* residue backend settings */
+ vi->residues=oggpack_read(opb,6)+1;
+ /*vi->residue_type=malloc(vi->residues*sizeof(int));*/
+ /*vi->residue_param=calloc(vi->residues,sizeof(void *));*/
+ for(i=0;i<vi->residues;i++){
+ vi->residue_type[i]=oggpack_read(opb,16);
+ if(vi->residue_type[i]<0 || vi->residue_type[i]>=VI_RESB)goto err_out;
+ vi->residue_param[i]=_residue_P[vi->residue_type[i]]->unpack(vi,opb);
+ if(!vi->residue_param[i])goto err_out;
+ }
+
+ /* map backend settings */
+ vi->maps=oggpack_read(opb,6)+1;
+ /*vi->map_type=malloc(vi->maps*sizeof(int));*/
+ /*vi->map_param=calloc(vi->maps,sizeof(void *));*/
+ for(i=0;i<vi->maps;i++){
+ vi->map_type[i]=oggpack_read(opb,16);
+ if(vi->map_type[i]<0 || vi->map_type[i]>=VI_MAPB)goto err_out;
+ vi->map_param[i]=_mapping_P[vi->map_type[i]]->unpack(vi,opb);
+ if(!vi->map_param[i])goto err_out;
+ }
+
+ /* mode settings */
+ vi->modes=oggpack_read(opb,6)+1;
+ /*vi->mode_param=calloc(vi->modes,sizeof(void *));*/
+ for(i=0;i<vi->modes;i++){
+ vi->mode_param[i]=calloc(1,sizeof(vorbis_info_mode));
+ vi->mode_param[i]->blockflag=oggpack_read(opb,1);
+ vi->mode_param[i]->windowtype=oggpack_read(opb,16);
+ vi->mode_param[i]->transformtype=oggpack_read(opb,16);
+ vi->mode_param[i]->mapping=oggpack_read(opb,8);
+
+ if(vi->mode_param[i]->windowtype>=VI_WINDOWB)goto err_out;
+ if(vi->mode_param[i]->transformtype>=VI_WINDOWB)goto err_out;
+ if(vi->mode_param[i]->mapping>=vi->maps)goto err_out;
+ }
+
+ if(oggpack_read(opb,1)!=1)goto err_out; /* top level EOP check */
+
+ return(0);
+ err_out:
+ vorbis_info_clear(vi);
+ return(-1);
+}
+
+/* The Vorbis header is in three packets; the initial small packet in
+ the first page that identifies basic parameters, a second packet
+ with bitstream comments and a third packet that holds the
+ codebook. */
+
+int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op){
+ oggpack_buffer opb;
+
+ if(op){
+ oggpack_readinit(&opb,op->packet,op->bytes);
+
+ /* Which of the three types of header is this? */
+ /* Also verify header-ness, vorbis */
+ {
+ char buffer[6];
+ int packtype=oggpack_read(&opb,8);
+ memset(buffer,0,6);
+ _v_readstring(&opb,buffer,6);
+ if(memcmp(buffer,"vorbis",6)){
+ /* not a vorbis header */
+ return(-1);
+ }
+ switch(packtype){
+ case 0x01: /* least significant *bit* is read first */
+ if(!op->b_o_s){
+ /* Not the initial packet */
+ return(-1);
+ }
+ if(vi->rate!=0){
+ /* previously initialized info header */
+ return(-1);
+ }
+
+ return(_vorbis_unpack_info(vi,&opb));
+
+ case 0x03: /* least significant *bit* is read first */
+ if(vi->rate==0){
+ /* um... we didn't get the initial header */
+ return(-1);
+ }
+
+ return(_vorbis_unpack_comment(vc,&opb));
+
+ case 0x05: /* least significant *bit* is read first */
+ if(vi->rate==0 || vc->vendor==NULL){
+ /* um... we didn;t get the initial header or comments yet */
+ return(-1);
+ }
+
+ return(_vorbis_unpack_books(vi,&opb));
+
+ default:
+ /* Not a valid vorbis header type */
+ return(-1);
+ break;
+ }
+ }
+ }
+ return(-1);
+}
+
+/* pack side **********************************************************/
+
+static int _vorbis_pack_info(oggpack_buffer *opb,vorbis_info *vi){
+ /* preamble */
+ oggpack_write(opb,0x01,8);
+ _v_writestring(opb,"vorbis");
+
+ /* basic information about the stream */
+ oggpack_write(opb,0x00,32);
+ oggpack_write(opb,vi->channels,8);
+ oggpack_write(opb,vi->rate,32);
+
+ oggpack_write(opb,vi->bitrate_upper,32);
+ oggpack_write(opb,vi->bitrate_nominal,32);
+ oggpack_write(opb,vi->bitrate_lower,32);
+
+ oggpack_write(opb,ilog2(vi->blocksizes[0]),4);
+ oggpack_write(opb,ilog2(vi->blocksizes[1]),4);
+ oggpack_write(opb,1,1);
+
+ return(0);
+}
+
+static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
+ char temp[]="Xiphophorus libVorbis I 20000508";
+
+ /* preamble */
+ oggpack_write(opb,0x03,8);
+ _v_writestring(opb,"vorbis");
+
+ /* vendor */
+ oggpack_write(opb,strlen(temp),32);
+ _v_writestring(opb,temp);
+
+ /* comments */
+
+ oggpack_write(opb,vc->comments,32);
+ if(vc->comments){
+ int i;
+ for(i=0;i<vc->comments;i++){
+ if(vc->user_comments[i]){
+ oggpack_write(opb,vc->comment_lengths[i],32);
+ _v_writestring(opb,vc->user_comments[i]);
+ }else{
+ oggpack_write(opb,0,32);
+ }
+ }
+ }
+ oggpack_write(opb,1,1);
+
+ return(0);
+}
+
+static int _vorbis_pack_books(oggpack_buffer *opb,vorbis_info *vi){
+ int i;
+ oggpack_write(opb,0x05,8);
+ _v_writestring(opb,"vorbis");
+
+ /* books */
+ oggpack_write(opb,vi->books-1,8);
+ for(i=0;i<vi->books;i++)
+ if(vorbis_staticbook_pack(vi->book_param[i],opb))goto err_out;
+
+ /* times */
+ oggpack_write(opb,vi->times-1,6);
+ for(i=0;i<vi->times;i++){
+ oggpack_write(opb,vi->time_type[i],16);
+ _time_P[vi->time_type[i]]->pack(vi->time_param[i],opb);
+ }
+
+ /* floors */
+ oggpack_write(opb,vi->floors-1,6);
+ for(i=0;i<vi->floors;i++){
+ oggpack_write(opb,vi->floor_type[i],16);
+ _floor_P[vi->floor_type[i]]->pack(vi->floor_param[i],opb);
+ }
+
+ /* residues */
+ oggpack_write(opb,vi->residues-1,6);
+ for(i=0;i<vi->residues;i++){
+ oggpack_write(opb,vi->residue_type[i],16);
+ _residue_P[vi->residue_type[i]]->pack(vi->residue_param[i],opb);
+ }
+
+ /* maps */
+ oggpack_write(opb,vi->maps-1,6);
+ for(i=0;i<vi->maps;i++){
+ oggpack_write(opb,vi->map_type[i],16);
+ _mapping_P[vi->map_type[i]]->pack(vi,vi->map_param[i],opb);
+ }
+
+ /* modes */
+ oggpack_write(opb,vi->modes-1,6);
+ for(i=0;i<vi->modes;i++){
+ oggpack_write(opb,vi->mode_param[i]->blockflag,1);
+ oggpack_write(opb,vi->mode_param[i]->windowtype,16);
+ oggpack_write(opb,vi->mode_param[i]->transformtype,16);
+ oggpack_write(opb,vi->mode_param[i]->mapping,8);
+ }
+ oggpack_write(opb,1,1);
+
+ return(0);
+err_out:
+ return(-1);
+}
+
+int vorbis_analysis_headerout(vorbis_dsp_state *v,
+ vorbis_comment *vc,
+ ogg_packet *op,
+ ogg_packet *op_comm,
+ ogg_packet *op_code){
+ vorbis_info *vi=v->vi;
+ oggpack_buffer opb;
+
+ /* first header packet **********************************************/
+
+ oggpack_writeinit(&opb);
+ if(_vorbis_pack_info(&opb,vi))goto err_out;
+
+ /* build the packet */
+ if(v->header)free(v->header);
+ v->header=malloc(oggpack_bytes(&opb));
+ memcpy(v->header,opb.buffer,oggpack_bytes(&opb));
+ op->packet=v->header;
+ op->bytes=oggpack_bytes(&opb);
+ op->b_o_s=1;
+ op->e_o_s=0;
+ op->frameno=0;
+
+ /* second header packet (comments) **********************************/
+
+ oggpack_reset(&opb);
+ if(_vorbis_pack_comment(&opb,vc))goto err_out;
+
+ if(v->header1)free(v->header1);
+ v->header1=malloc(oggpack_bytes(&opb));
+ memcpy(v->header1,opb.buffer,oggpack_bytes(&opb));
+ op_comm->packet=v->header1;
+ op_comm->bytes=oggpack_bytes(&opb);
+ op_comm->b_o_s=0;
+ op_comm->e_o_s=0;
+ op_comm->frameno=0;
+
+ /* third header packet (modes/codebooks) ****************************/
+
+ oggpack_reset(&opb);
+ if(_vorbis_pack_books(&opb,vi))goto err_out;
+
+ if(v->header2)free(v->header2);
+ v->header2=malloc(oggpack_bytes(&opb));
+ memcpy(v->header2,opb.buffer,oggpack_bytes(&opb));
+ op_code->packet=v->header2;
+ op_code->bytes=oggpack_bytes(&opb);
+ op_code->b_o_s=0;
+ op_code->e_o_s=0;
+ op_code->frameno=0;
+
+ oggpack_writeclear(&opb);
+ return(0);
+ err_out:
+ oggpack_writeclear(&opb);
+ memset(op,0,sizeof(ogg_packet));
+ memset(op_comm,0,sizeof(ogg_packet));
+ memset(op_code,0,sizeof(ogg_packet));
+
+ if(v->header)free(v->header);
+ if(v->header1)free(v->header1);
+ if(v->header2)free(v->header2);
+ v->header=NULL;
+ v->header1=NULL;
+ v->header2=NULL;
+ return(-1);
+}
+
diff --git a/lib/mapping0.c b/lib/mapping0.c
index 0f7c050a..6756c214 100644
--- a/lib/mapping0.c
+++ b/lib/mapping0.c
@@ -12,16 +12,16 @@
********************************************************************
function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.15.2.2 2000/09/02 05:19:25 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.15.2.2.2.1 2000/09/03 08:34:52 jack Exp $
********************************************************************/
#include <stdlib.h>
#include <string.h>
#include <math.h>
+#include <ogg/ogg.h>
#include "vorbis/codec.h"
#include "vorbis/backends.h"
-#include "bitwise.h"
#include "bookinternal.h"
#include "registry.h"
#include "psy.h"
@@ -147,16 +147,16 @@ static void mapping0_pack(vorbis_info *vi,vorbis_info_mapping *vm,oggpack_buffer
int i;
vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)vm;
- _oggpack_write(opb,info->submaps-1,4);
+ oggpack_write(opb,info->submaps-1,4);
/* we don't write the channel submappings if we only have one... */
if(info->submaps>1){
for(i=0;i<vi->channels;i++)
- _oggpack_write(opb,info->chmuxlist[i],4);
+ oggpack_write(opb,info->chmuxlist[i],4);
}
for(i=0;i<info->submaps;i++){
- _oggpack_write(opb,info->timesubmap[i],8);
- _oggpack_write(opb,info->floorsubmap[i],8);
- _oggpack_write(opb,info->residuesubmap[i],8);
+ oggpack_write(opb,info->timesubmap[i],8);
+ oggpack_write(opb,info->floorsubmap[i],8);
+ oggpack_write(opb,info->residuesubmap[i],8);
}
}
@@ -166,20 +166,20 @@ static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb)
vorbis_info_mapping0 *info=calloc(1,sizeof(vorbis_info_mapping0));
memset(info,0,sizeof(vorbis_info_mapping0));
- info->submaps=_oggpack_read(opb,4)+1;
+ info->submaps=oggpack_read(opb,4)+1;
if(info->submaps>1){
for(i=0;i<vi->channels;i++){
- info->chmuxlist[i]=_oggpack_read(opb,4);
+ info->chmuxlist[i]=oggpack_read(opb,4);
if(info->chmuxlist[i]>=info->submaps)goto err_out;
}
}
for(i=0;i<info->submaps;i++){
- info->timesubmap[i]=_oggpack_read(opb,8);
+ info->timesubmap[i]=oggpack_read(opb,8);
if(info->timesubmap[i]>=vi->times)goto err_out;
- info->floorsubmap[i]=_oggpack_read(opb,8);
+ info->floorsubmap[i]=oggpack_read(opb,8);
if(info->floorsubmap[i]>=vi->floors)goto err_out;
- info->residuesubmap[i]=_oggpack_read(opb,8);
+ info->residuesubmap[i]=oggpack_read(opb,8);
if(info->residuesubmap[i]>=vi->residues)goto err_out;
}
@@ -196,7 +196,6 @@ static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb)
#include "envelope.h"
#include "mdct.h"
#include "psy.h"
-#include "bitwise.h"
#include "scales.h"
/* no time mapping implementation for now */
diff --git a/lib/res0.c b/lib/res0.c
index a962b829..99a4332d 100644
--- a/lib/res0.c
+++ b/lib/res0.c
@@ -12,7 +12,7 @@
********************************************************************
function: residue backend 0 implementation
- last mod: $Id: res0.c,v 1.17.2.3 2000/09/02 09:39:20 xiphmont Exp $
+ last mod: $Id: res0.c,v 1.17.2.3.2.1 2000/09/03 08:34:52 jack Exp $
********************************************************************/
@@ -25,8 +25,8 @@
#include <string.h>
#include <math.h>
#include <stdio.h>
+#include <ogg/ogg.h>
#include "vorbis/codec.h"
-#include "bitwise.h"
#include "registry.h"
#include "bookinternal.h"
#include "sharedbook.h"
@@ -70,19 +70,19 @@ void res0_free_look(vorbis_look_residue *i){
void res0_pack(vorbis_info_residue *vr,oggpack_buffer *opb){
vorbis_info_residue0 *info=(vorbis_info_residue0 *)vr;
int j,acc=0;
- _oggpack_write(opb,info->begin,24);
- _oggpack_write(opb,info->end,24);
+ oggpack_write(opb,info->begin,24);
+ oggpack_write(opb,info->end,24);
- _oggpack_write(opb,info->grouping-1,24); /* residue vectors to group and
+ oggpack_write(opb,info->grouping-1,24); /* residue vectors to group and
code with a partitioned book */
- _oggpack_write(opb,info->partitions-1,6); /* possible partition choices */
- _oggpack_write(opb,info->groupbook,8); /* group huffman book */
+ oggpack_write(opb,info->partitions-1,6); /* possible partition choices */
+ oggpack_write(opb,info->groupbook,8); /* group huffman book */
for(j=0;j<info->partitions;j++){
- _oggpack_write(opb,info->secondstages[j],4); /* zero *is* a valid choice */
+ oggpack_write(opb,info->secondstages[j],4); /* zero *is* a valid choice */
acc+=info->secondstages[j];
}
for(j=0;j<acc;j++)
- _oggpack_write(opb,info->booklist[j],8);
+ oggpack_write(opb,info->booklist[j],8);
}
@@ -91,20 +91,20 @@ vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){
int j,acc=0;
vorbis_info_residue0 *info=calloc(1,sizeof(vorbis_info_residue0));
- info->begin=_oggpack_read(opb,24);
- info->end=_oggpack_read(opb,24);
- info->grouping=_oggpack_read(opb,24)+1;
- info->partitions=_oggpack_read(opb,6)+1;
- info->groupbook=_oggpack_read(opb,8);
+ info->begin=oggpack_read(opb,24);
+ info->end=oggpack_read(opb,24);
+ info->grouping=oggpack_read(opb,24)+1;
+ info->partitions=oggpack_read(opb,6)+1;
+ info->groupbook=oggpack_read(opb,8);
for(j=0;j<info->partitions;j++){
- int cascade=info->secondstages[j]=_oggpack_read(opb,4);
+ int cascade=info->secondstages[j]=oggpack_read(opb,4);
if(cascade>1)goto errout; /* temporary! when cascading gets
reworked and actually used, we don't
want old code to DTWT */
acc+=cascade;
}
for(j=0;j<acc;j++)
- info->booklist[j]=_oggpack_read(opb,8);
+ info->booklist[j]=oggpack_read(opb,8);
if(info->groupbook>=vi->books)goto errout;
for(j=0;j<acc;j++)
diff --git a/lib/sharedbook.c b/lib/sharedbook.c
index 54c7ca51..905f414c 100644
--- a/lib/sharedbook.c
+++ b/lib/sharedbook.c
@@ -12,17 +12,17 @@
********************************************************************
function: basic shared codebook operations
- last mod: $Id: sharedbook.c,v 1.7.4.3 2000/09/02 05:19:25 xiphmont Exp $
+ last mod: $Id: sharedbook.c,v 1.7.4.3.2.1 2000/09/03 08:34:52 jack Exp $
********************************************************************/
#include <stdlib.h>
#include <math.h>
#include <string.h>
+#include <ogg/ogg.h>
#include "os.h"
#include "vorbis/codec.h"
#include "vorbis/codebook.h"
-#include "bitwise.h"
#include "scales.h"
#include "sharedbook.h"
diff --git a/lib/synthesis.c b/lib/synthesis.c
index d9108eac..bd36170a 100644
--- a/lib/synthesis.c
+++ b/lib/synthesis.c
@@ -12,14 +12,14 @@
********************************************************************
function: single-block PCM synthesis
- last mod: $Id: synthesis.c,v 1.17.4.1 2000/08/31 09:00:02 xiphmont Exp $
+ last mod: $Id: synthesis.c,v 1.17.4.1.2.1 2000/09/03 08:34:52 jack Exp $
********************************************************************/
#include <stdio.h>
+#include <ogg/ogg.h>
#include "vorbis/codec.h"
#include "registry.h"
-#include "bitwise.h"
#include "misc.h"
#include "os.h"
@@ -31,23 +31,23 @@ int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){
/* first things first. Make sure decode is ready */
_vorbis_block_ripcord(vb);
- _oggpack_readinit(opb,op->packet,op->bytes);
+ oggpack_readinit(opb,op->packet,op->bytes);
/* Check the packet type */
- if(_oggpack_read(opb,1)!=0){
+ if(oggpack_read(opb,1)!=0){
/* Oops. This is not an audio data packet */
return(-1);
}
/* read our mode and pre/post windowsize */
- mode=_oggpack_read(opb,vd->modebits);
+ mode=oggpack_read(opb,vd->modebits);
if(mode==-1)return(-1);
vb->mode=mode;
vb->W=vi->mode_param[mode]->blockflag;
if(vb->W){
- vb->lW=_oggpack_read(opb,1);
- vb->nW=_oggpack_read(opb,1);
+ vb->lW=oggpack_read(opb,1);
+ vb->nW=oggpack_read(opb,1);
if(vb->nW==-1) return(-1);
}else{
vb->lW=0;