diff --git a/lutin_ogg.py b/lutin_ogg.py
new file mode 100644
index 0000000..0b4af7a
--- /dev/null
+++ b/lutin_ogg.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+import lutinModule as module
+import lutinTools as tools
+import lutinDebug as debug
+
+def get_desc():
+ return "ogg : Ogg-tremor library for ogg audio decoding"
+
+
+def create(target):
+ myModule = module.Module(__file__, 'ogg', 'LIBRARY')
+
+ myModule.add_src_file([
+ 'ogg/framing.c',
+ 'ogg/bitwise.c',
+ 'tremor/floor0.c',
+ 'tremor/vorbisfile.c',
+ 'tremor/synthesis.c',
+ 'tremor/res012.c',
+ 'tremor/block.c',
+ 'tremor/mdct.c',
+ 'tremor/sharedbook.c',
+ 'tremor/codebook.c',
+ 'tremor/floor1.c',
+ 'tremor/window.c',
+ 'tremor/registry.c',
+ 'tremor/info.c',
+ 'tremor/mapping0.c'
+ ])
+
+
+ myModule.add_export_path(tools.get_current_path(__file__))
+ myModule.add_path(tools.get_current_path(__file__)+"/ogg/")
+ myModule.add_path(tools.get_current_path(__file__)+"/tremor/")
+
+ # add the currrent module at the
+ return myModule
+
+
+
+
+
+
+
+
+
diff --git a/ogg/config_types.h.in b/ogg/config_types.h.in
new file mode 100644
index 0000000..750e29d
--- /dev/null
+++ b/ogg/config_types.h.in
@@ -0,0 +1,25 @@
+#ifndef __CONFIG_TYPES_H__
+#define __CONFIG_TYPES_H__
+
+/* these are filled in by configure */
+#define INCLUDE_INTTYPES_H @INCLUDE_INTTYPES_H@
+#define INCLUDE_STDINT_H @INCLUDE_STDINT_H@
+#define INCLUDE_SYS_TYPES_H @INCLUDE_SYS_TYPES_H@
+
+#if INCLUDE_INTTYPES_H
+# include
+#endif
+#if INCLUDE_STDINT_H
+# include
+#endif
+#if INCLUDE_SYS_TYPES_H
+# include
+#endif
+
+typedef @SIZE16@ ogg_int16_t;
+typedef @USIZE16@ ogg_uint16_t;
+typedef @SIZE32@ ogg_int32_t;
+typedef @USIZE32@ ogg_uint32_t;
+typedef @SIZE64@ ogg_int64_t;
+
+#endif
diff --git a/ogg/framing.c b/ogg/framing.c
index 4452cbd..3a2f0a6 100644
--- a/ogg/framing.c
+++ b/ogg/framing.c
@@ -12,7 +12,7 @@
function: code raw packets into framed OggSquish stream and
decode Ogg streams back into raw packets
- last mod: $Id: framing.c 18052 2011-08-04 17:57:02Z giles $
+ last mod: $Id: framing.c 18758 2013-01-08 16:29:56Z tterribe $
note: The CRC code is directly derived from public domain code by
Ross Williams (ross@guest.adelaide.edu.au). See docs/framing.html
@@ -21,6 +21,7 @@
********************************************************************/
#include
+#include
#include
#include
@@ -236,39 +237,51 @@ int ogg_stream_destroy(ogg_stream_state *os){
/* Helpers for ogg_stream_encode; this keeps the structure and
what's happening fairly clear */
-static int _os_body_expand(ogg_stream_state *os,int needed){
- if(os->body_storage<=os->body_fill+needed){
+static int _os_body_expand(ogg_stream_state *os,long needed){
+ if(os->body_storage-needed<=os->body_fill){
+ long body_storage;
void *ret;
- ret=_ogg_realloc(os->body_data,(os->body_storage+needed+1024)*
- sizeof(*os->body_data));
+ if(os->body_storage>LONG_MAX-needed){
+ ogg_stream_clear(os);
+ return -1;
+ }
+ body_storage=os->body_storage+needed;
+ if(body_storagebody_data,body_storage*sizeof(*os->body_data));
if(!ret){
ogg_stream_clear(os);
return -1;
}
- os->body_storage+=(needed+1024);
+ os->body_storage=body_storage;
os->body_data=ret;
}
return 0;
}
-static int _os_lacing_expand(ogg_stream_state *os,int needed){
- if(os->lacing_storage<=os->lacing_fill+needed){
+static int _os_lacing_expand(ogg_stream_state *os,long needed){
+ if(os->lacing_storage-needed<=os->lacing_fill){
+ long lacing_storage;
void *ret;
- ret=_ogg_realloc(os->lacing_vals,(os->lacing_storage+needed+32)*
- sizeof(*os->lacing_vals));
+ if(os->lacing_storage>LONG_MAX-needed){
+ ogg_stream_clear(os);
+ return -1;
+ }
+ lacing_storage=os->lacing_storage+needed;
+ if(lacing_storagelacing_vals,lacing_storage*sizeof(*os->lacing_vals));
if(!ret){
ogg_stream_clear(os);
return -1;
}
os->lacing_vals=ret;
- ret=_ogg_realloc(os->granule_vals,(os->lacing_storage+needed+32)*
+ ret=_ogg_realloc(os->granule_vals,lacing_storage*
sizeof(*os->granule_vals));
if(!ret){
ogg_stream_clear(os);
return -1;
}
os->granule_vals=ret;
- os->lacing_storage+=(needed+32);
+ os->lacing_storage=lacing_storage;
}
return 0;
}
@@ -304,12 +317,17 @@ void ogg_page_checksum_set(ogg_page *og){
int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov, int count,
long e_o_s, ogg_int64_t granulepos){
- int bytes = 0, lacing_vals, i;
+ long bytes = 0, lacing_vals;
+ int i;
if(ogg_stream_check(os)) return -1;
if(!iov) return 0;
- for (i = 0; i < count; ++i) bytes += (int)iov[i].iov_len;
+ for (i = 0; i < count; ++i){
+ if(iov[i].iov_len>LONG_MAX) return -1;
+ if(bytes>LONG_MAX-(long)iov[i].iov_len) return -1;
+ bytes += (long)iov[i].iov_len;
+ }
lacing_vals=bytes/255+1;
if(os->body_returned){
diff --git a/ogg/os_types.h b/ogg/os_types.h
index 58f717b..804fd76 100644
--- a/ogg/os_types.h
+++ b/ogg/os_types.h
@@ -9,22 +9,139 @@
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
- */
+ function: #ifdef jail to whip a few platforms into the UNIX ideal.
+ last mod: $Id: os_types.h 19098 2014-02-26 19:06:45Z giles $
+
+ ********************************************************************/
#ifndef _OS_TYPES_H
#define _OS_TYPES_H
-#include
-
+/* make it easy on the folks that want to compile the libs with a
+ different malloc than stdlib */
#define _ogg_malloc malloc
#define _ogg_calloc calloc
#define _ogg_realloc realloc
#define _ogg_free free
-typedef int16_t ogg_int16_t;
-typedef uint16_t ogg_uint16_t;
-typedef int32_t ogg_int32_t;
-typedef uint32_t ogg_uint32_t;
-typedef int64_t ogg_int64_t;
+#if defined(_WIN32)
+
+# if defined(__CYGWIN__)
+# include
+ typedef int16_t ogg_int16_t;
+ typedef uint16_t ogg_uint16_t;
+ typedef int32_t ogg_int32_t;
+ typedef uint32_t ogg_uint32_t;
+ typedef int64_t ogg_int64_t;
+ typedef uint64_t ogg_uint64_t;
+# elif defined(__MINGW32__)
+# include
+ typedef short ogg_int16_t;
+ typedef unsigned short ogg_uint16_t;
+ typedef int ogg_int32_t;
+ typedef unsigned int ogg_uint32_t;
+ typedef long long ogg_int64_t;
+ typedef unsigned long long ogg_uint64_t;
+# elif defined(__MWERKS__)
+ typedef long long ogg_int64_t;
+ typedef int ogg_int32_t;
+ typedef unsigned int ogg_uint32_t;
+ typedef short ogg_int16_t;
+ typedef unsigned short ogg_uint16_t;
+# else
+ /* MSVC/Borland */
+ typedef __int64 ogg_int64_t;
+ typedef __int32 ogg_int32_t;
+ typedef unsigned __int32 ogg_uint32_t;
+ typedef __int16 ogg_int16_t;
+ typedef unsigned __int16 ogg_uint16_t;
+# endif
+
+#elif defined(__MACOS__)
+
+# include
+ typedef SInt16 ogg_int16_t;
+ typedef UInt16 ogg_uint16_t;
+ typedef SInt32 ogg_int32_t;
+ typedef UInt32 ogg_uint32_t;
+ typedef SInt64 ogg_int64_t;
+
+#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
+
+# include
+ typedef int16_t ogg_int16_t;
+ typedef uint16_t ogg_uint16_t;
+ typedef int32_t ogg_int32_t;
+ typedef uint32_t ogg_uint32_t;
+ typedef int64_t ogg_int64_t;
+
+#elif defined(__HAIKU__)
+
+ /* Haiku */
+# include
+ typedef short ogg_int16_t;
+ typedef unsigned short ogg_uint16_t;
+ typedef int ogg_int32_t;
+ typedef unsigned int ogg_uint32_t;
+ typedef long long ogg_int64_t;
+
+#elif defined(__BEOS__)
+
+ /* Be */
+# include
+ typedef int16_t ogg_int16_t;
+ typedef uint16_t ogg_uint16_t;
+ typedef int32_t ogg_int32_t;
+ typedef uint32_t ogg_uint32_t;
+ typedef int64_t ogg_int64_t;
+
+#elif defined (__EMX__)
+
+ /* OS/2 GCC */
+ typedef short ogg_int16_t;
+ typedef unsigned short ogg_uint16_t;
+ typedef int ogg_int32_t;
+ typedef unsigned int ogg_uint32_t;
+ typedef long long ogg_int64_t;
+
+#elif defined (DJGPP)
+
+ /* DJGPP */
+ typedef short ogg_int16_t;
+ typedef int ogg_int32_t;
+ typedef unsigned int ogg_uint32_t;
+ typedef long long ogg_int64_t;
+
+#elif defined(R5900)
+
+ /* PS2 EE */
+ typedef long ogg_int64_t;
+ typedef int ogg_int32_t;
+ typedef unsigned ogg_uint32_t;
+ typedef short ogg_int16_t;
+
+#elif defined(__SYMBIAN32__)
+
+ /* Symbian GCC */
+ typedef signed short ogg_int16_t;
+ typedef unsigned short ogg_uint16_t;
+ typedef signed int ogg_int32_t;
+ typedef unsigned int ogg_uint32_t;
+ typedef long long int ogg_int64_t;
+
+#elif defined(__TMS320C6X__)
+
+ /* TI C64x compiler */
+ typedef signed short ogg_int16_t;
+ typedef unsigned short ogg_uint16_t;
+ typedef signed int ogg_int32_t;
+ typedef unsigned int ogg_uint32_t;
+ typedef long long int ogg_int64_t;
+
+#else
+
+# include
#endif
+
+#endif /* _OS_TYPES_H */
diff --git a/tremor/Makefile.am b/tremor/Makefile.am
new file mode 100644
index 0000000..0a4bb2c
--- /dev/null
+++ b/tremor/Makefile.am
@@ -0,0 +1,50 @@
+AUTOMAKE_OPTIONS = foreign
+
+INCLUDES = -I./ @OGG_CFLAGS@
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = vorbisidec.pc
+
+lib_LTLIBRARIES = libvorbisidec.la
+
+libvorbisidec_la_SOURCES = mdct.c block.c window.c \
+ synthesis.c info.c \
+ floor1.c floor0.c vorbisfile.c \
+ res012.c mapping0.c registry.c codebook.c \
+ sharedbook.c \
+ codebook.h misc.h mdct_lookup.h\
+ os.h mdct.h block.h ivorbisfile.h lsp_lookup.h\
+ registry.h window.h window_lookup.h\
+ codec_internal.h backends.h \
+ asm_arm.h ivorbiscodec.h
+libvorbisidec_la_LDFLAGS = -version-info @V_LIB_CURRENT@:@V_LIB_REVISION@:@V_LIB_AGE@
+libvorbisidec_la_LIBADD = @OGG_LIBS@
+
+EXTRA_PROGRAMS = ivorbisfile_example iseeking_example
+CLEANFILES = $(EXTRA_PROGRAMS) $(lib_LTLIBRARIES)
+
+ivorbisfile_example_SOURCES = ivorbisfile_example.c
+ivorbisfile_example_LDFLAGS = -static
+ivorbisfile_example_LDADD = libvorbisidec.la @OGG_LIBS@
+
+iseeking_example_SOURCES = iseeking_example.c
+iseeking_example_LDFLAGS = -static
+iseeking_example_LDADD = libvorbisidec.la @OGG_LIBS@
+
+includedir = $(prefix)/include/tremor
+
+include_HEADERS = ivorbiscodec.h ivorbisfile.h config_types.h
+
+EXTRA_DIST = vorbisidec.pc.in \
+ $(srcdir)/doc/*.html $(srcdir)/win32/VS*/libtremor/*.vcproj
+
+example:
+ -ln -fs . vorbis
+ $(MAKE) ivorbisfile_example
+ $(MAKE) iseeking_example
+
+debug:
+ $(MAKE) all CFLAGS="@DEBUG@"
+
+profile:
+ $(MAKE) all CFLAGS="@PROFILE@"
diff --git a/tremor/README b/tremor/README
new file mode 100644
index 0000000..1321175
--- /dev/null
+++ b/tremor/README
@@ -0,0 +1,46 @@
+This README covers the Ogg Vorbis 'Tremor' integer playback codec
+source as of date 2002 09 02, version 1.0.0.
+
+ ******
+
+The C source in this package will build on any ANSI C compiler and
+function completely and properly on any platform. The included build
+system assumes GNU build system and make tools (m4, automake,
+autoconf, libtool and gmake). GCC is not required, although GCC is
+the most tested compiler. To build using GNU tools, type in the
+source directory:
+
+./autogen.sh
+make
+
+Currently, the source implements playback in pure C on all platforms
+except ARM, where a [currently] small amount of assembly (see
+asm_arm.h) is used to implement 64 bit math operations and fast LSP
+computation. If building on ARM without the benefit of GNU build
+system tools, be sure that '_ARM_ASSEM_' is #defined by the build
+system if this assembly is desired, else the resulting library will
+use whatever 64 bit math builtins the compiler implements.
+
+No math library is required by this source. No floating point
+operations are used at any point in either setup or decode. This
+decoder library will properly decode any past, current or future
+Vorbis I file or stream.
+
+ ********
+
+The build system produces a static and [when supported by the OS]
+dynamic library named 'libvorbisidec'. This library exposes an API
+nearly identical to the BSD reference library's 'libvorbisfile',
+including all the features familiar to users of vorbisfile. This API
+is similar enough that the proper header file to include is named
+'ivorbisfile.h' [included in the source build directory]. Lower level
+libvorbis-style headers and structures are in 'ivorbiscodec.h'
+[included in the source build directory]. A simple example program,
+ivorbisfile_example.c, can be built with 'make example'.
+
+ ********
+
+Detailed Tremor API Documentation begins at doc/index.html
+
+Monty
+xiph.org
diff --git a/tremor/Version_script.in b/tremor/Version_script.in
new file mode 100644
index 0000000..7f22f2f
--- /dev/null
+++ b/tremor/Version_script.in
@@ -0,0 +1,62 @@
+#
+# Export file for libvorbisidec
+#
+# Only the symbols listed in the global section will be callable from
+# applications linking to libvorbisidec.
+#
+
+@PACKAGE@.so.1
+{
+ global:
+ ov_clear;
+ ov_open;
+ ov_open_callbacks;
+ ov_test;
+ ov_test_callbacks;
+ ov_test_open;
+ ov_bitrate;
+ ov_bitrate_instant;
+ ov_streams;
+ ov_seekable;
+ ov_serialnumber;
+ ov_raw_total;
+ ov_pcm_total;
+ ov_time_total;
+ ov_raw_seek;
+ ov_pcm_seek;
+ ov_pcm_seek_page;
+ ov_time_seek;
+ ov_time_seek_page;
+ ov_raw_tell;
+ ov_pcm_tell;
+ ov_time_tell;
+ ov_info;
+ ov_comment;
+ ov_read;
+
+ vorbis_info_init;
+ vorbis_info_clear;
+ vorbis_info_blocksize;
+ vorbis_comment_init;
+ vorbis_comment_add;
+ vorbis_comment_add_tag;
+ vorbis_comment_query;
+ vorbis_comment_query_count;
+ vorbis_comment_clear;
+ vorbis_block_init;
+ vorbis_block_clear;
+ vorbis_dsp_clear;
+ vorbis_synthesis_idheader;
+ vorbis_synthesis_headerin;
+ vorbis_synthesis_init;
+ vorbis_synthesis_restart;
+ vorbis_synthesis;
+ vorbis_synthesis_trackonly;
+ vorbis_synthesis_blockin;
+ vorbis_synthesis_pcmout;
+ vorbis_synthesis_read;
+ vorbis_packet_blocksize;
+
+ local:
+ *;
+};
diff --git a/tremor/authors b/tremor/authors
deleted file mode 100644
index 2bb6518..0000000
--- a/tremor/authors
+++ /dev/null
@@ -1,2 +0,0 @@
-Anti-Grain Geometry - Version 2.4
-Copyright (C) 2002-2005 Maxim Shemanarev (McSeem)
diff --git a/tremor/autogen.sh b/tremor/autogen.sh
new file mode 100755
index 0000000..73c8fca
--- /dev/null
+++ b/tremor/autogen.sh
@@ -0,0 +1,120 @@
+#!/bin/sh
+# Run this to set up the build system: configure, makefiles, etc.
+# (based on the version in enlightenment's cvs)
+
+package="vorbisdec"
+
+olddir=`pwd`
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+cd "$srcdir"
+DIE=0
+
+echo "checking for autoconf... "
+(autoconf --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "You must have autoconf installed to compile $package."
+ echo "Download the appropriate package for your distribution,"
+ echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
+ DIE=1
+}
+
+VERSIONGREP="sed -e s/.*[^0-9\.]\([0-9]\.[0-9]\).*/\1/"
+VERSIONMKINT="sed -e s/[^0-9]//"
+
+# do we need automake?
+if test -r Makefile.am; then
+ AM_OPTIONS=`fgrep AUTOMAKE_OPTIONS Makefile.am`
+ AM_NEEDED=`echo $AM_OPTIONS | $VERSIONGREP`
+ if test x"$AM_NEEDED" = "x$AM_OPTIONS"; then
+ AM_NEEDED=""
+ fi
+ if test -z $AM_NEEDED; then
+ echo -n "checking for automake... "
+ AUTOMAKE=automake
+ ACLOCAL=aclocal
+ if ($AUTOMAKE --version < /dev/null > /dev/null 2>&1); then
+ echo "yes"
+ else
+ echo "no"
+ AUTOMAKE=
+ fi
+ else
+ echo -n "checking for automake $AM_NEEDED or later... "
+ for am in automake-$AM_NEEDED automake$AM_NEEDED automake; do
+ ($am --version < /dev/null > /dev/null 2>&1) || continue
+ ver=`$am --version < /dev/null | head -n 1 | $VERSIONGREP | $VERSIONMKINT`
+ verneeded=`echo $AM_NEEDED | $VERSIONMKINT`
+ if test $ver -ge $verneeded; then
+ AUTOMAKE=$am
+ echo $AUTOMAKE
+ break
+ fi
+ done
+ test -z $AUTOMAKE && echo "no"
+ echo -n "checking for aclocal $AM_NEEDED or later... "
+ for ac in aclocal-$AM_NEEDED aclocal$AM_NEEDED aclocal; do
+ ($ac --version < /dev/null > /dev/null 2>&1) || continue
+ ver=`$ac --version < /dev/null | head -n 1 | $VERSIONGREP | $VERSIONMKINT`
+ verneeded=`echo $AM_NEEDED | $VERSIONMKINT`
+ if test $ver -ge $verneeded; then
+ ACLOCAL=$ac
+ echo $ACLOCAL
+ break
+ fi
+ done
+ test -z $ACLOCAL && echo "no"
+ fi
+ test -z $AUTOMAKE || test -z $ACLOCAL && {
+ echo
+ echo "You must have automake installed to compile $package."
+ echo "Download the appropriate package for your distribution,"
+ echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
+ exit 1
+ }
+fi
+
+echo -n "checking for libtool... "
+for LIBTOOLIZE in libtoolize glibtoolize nope; do
+ ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 && break
+done
+if test x$LIBTOOLIZE = xnope; then
+ echo "nope."
+ LIBTOOLIZE=libtoolize
+else
+ echo $LIBTOOLIZE
+fi
+($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "You must have libtool installed to compile $package."
+ echo "Download the appropriate package for your system,"
+ echo "or get the source from one of the GNU ftp sites"
+ echo "listed in http://www.gnu.org/order/ftp.html"
+ DIE=1
+}
+
+if test "$DIE" -eq 1; then
+ exit 1
+fi
+
+if test -z "$*"; then
+ echo "I am going to run ./configure with no arguments - if you wish "
+ echo "to pass any to it, please specify them on the $0 command line."
+fi
+
+echo "Generating configuration files for $package, please wait...."
+
+echo " $ACLOCAL $ACLOCAL_FLAGS"
+$ACLOCAL $ACLOCAL_FLAGS || exit 1
+echo " $LIBTOOLIZE --automake"
+$LIBTOOLIZE --automake || exit 1
+echo " autoheader"
+autoheader || exit 1
+echo " $AUTOMAKE --add-missing $AUTOMAKE_FLAGS"
+$AUTOMAKE --add-missing $AUTOMAKE_FLAGS || exit 1
+echo " autoconf"
+autoconf || exit 1
+
+cd $olddir
+$srcdir/configure --enable-maintainer-mode "$@" && echo
diff --git a/tremor/configure.in b/tremor/configure.in
new file mode 100644
index 0000000..e7f5690
--- /dev/null
+++ b/tremor/configure.in
@@ -0,0 +1,146 @@
+dnl Process this file with autoconf to produce a configure script
+
+dnl ------------------------------------------------
+dnl Initialization and Versioning
+dnl ------------------------------------------------
+
+AC_INIT(mdct.c)
+
+AC_CANONICAL_HOST
+AC_CANONICAL_TARGET
+
+AM_CONFIG_HEADER([config.h])
+
+AM_INIT_AUTOMAKE(libvorbisidec,1.2.1)
+
+dnl AM_MAINTAINER_MODE only provides the option to configure to enable it
+AM_MAINTAINER_MODE
+
+dnl Library versioning
+
+V_LIB_CURRENT=1
+V_LIB_REVISION=3
+V_LIB_AGE=0
+AC_SUBST(V_LIB_CURRENT)
+AC_SUBST(V_LIB_REVISION)
+AC_SUBST(V_LIB_AGE)
+
+dnl --------------------------------------------------
+dnl Check for programs
+dnl --------------------------------------------------
+
+dnl save $CFLAGS since AC_PROG_CC likes to insert "-g -O2"
+dnl if $CFLAGS is blank
+cflags_save="$CFLAGS"
+AC_PROG_CC
+AC_PROG_CPP
+CFLAGS="$cflags_save"
+
+AM_PROG_LIBTOOL
+
+dnl --------------------------------------------------
+dnl Set build flags based on environment
+dnl --------------------------------------------------
+
+dnl Set some target options
+
+cflags_save="$CFLAGS"
+ldflags_save="$LDFLAGS"
+if test -z "$GCC"; then
+ case $host in
+ arm-*-*)
+ DEBUG="-g -D_ARM_ASSEM_"
+ CFLAGS="-O -D_ARM_ASSEM_"
+ PROFILE="-p -g -O -D_ARM_ASSEM_" ;;
+ *)
+ DEBUG="-g"
+ CFLAGS="-O"
+ PROFILE="-g -p" ;;
+ esac
+else
+
+ case $host in
+ arm-*-*)
+ DEBUG="-g -Wall -D__NO_MATH_INLINES -fsigned-char -D_ARM_ASSEM_"
+ CFLAGS="-O2 -D_ARM_ASSEM_ -fsigned-char"
+ PROFILE="-W -pg -g -O2 -D_ARM_ASSEM_ -fsigned-char -fno-inline-functions";;
+
+ *)
+ DEBUG="-g -Wall -D__NO_MATH_INLINES -fsigned-char"
+ CFLAGS="-O2 -Wall -fsigned-char"
+ PROFILE="-Wall -pg -g -O2 -fsigned-char -fno-inline-functions";;
+ esac
+fi
+CFLAGS="$CFLAGS $cflags_save -D_REENTRANT"
+LDFLAGS="$LDFLAGS $ldflags_save"
+
+
+# Test whenever ld supports -version-script
+AC_PROG_LD
+AC_PROG_LD_GNU
+if test "x$lt_cv_prog_gnu_ld" = "xyes"; then
+ SHLIB_VERSION_ARG="-Wl,--version-script=Version_script"
+ LDFLAGS="$LDFLAGS $SHLIB_VERSION_ARG"
+fi
+
+dnl --------------------------------------------------
+dnl Options
+dnl --------------------------------------------------
+
+AC_ARG_ENABLE(
+ low-accuracy,
+ [ --enable-low-accuracy enable 32 bit only multiply operations],
+ CFLAGS="$CFLAGS -D_LOW_ACCURACY_"
+)
+
+dnl --------------------------------------------------
+dnl Check for headers
+dnl --------------------------------------------------
+
+AC_CHECK_HEADER(memory.h,CFLAGS="$CFLAGS -DUSE_MEMORY_H",:)
+
+dnl --------------------------------------------------
+dnl Check for typedefs, structures, etc
+dnl --------------------------------------------------
+
+dnl none
+
+dnl --------------------------------------------------
+dnl Check for libraries
+dnl --------------------------------------------------
+
+PKG_PROG_PKG_CONFIG
+
+HAVE_OGG=no
+if test "x$PKG_CONFIG" != "x"
+then
+ PKG_CHECK_MODULES(OGG, ogg >= 1.0, HAVE_OGG=yes, HAVE_OGG=no)
+fi
+if test "x$HAVE_OGG" = "xno"
+then
+ dnl fall back to the old school test
+ XIPH_PATH_OGG(, AC_MSG_ERROR(must have Ogg installed!))
+ libs_save=$LIBS
+ LIBS="$OGG_LIBS"
+ AC_CHECK_FUNC(oggpack_writealign, , AC_MSG_ERROR(Ogg >= 1.0 required !))
+ LIBS=$libs_save
+fi
+
+dnl --------------------------------------------------
+dnl Check for library functions
+dnl --------------------------------------------------
+
+AC_FUNC_ALLOCA
+AC_FUNC_MEMCMP
+
+dnl --------------------------------------------------
+dnl Do substitutions
+dnl --------------------------------------------------
+
+LIBS="$LIBS"
+
+AC_SUBST(LIBS)
+AC_SUBST(DEBUG)
+AC_SUBST(PROFILE)
+
+AC_OUTPUT(Makefile Version_script vorbisidec.pc)
diff --git a/tremor/debian/Makefile.am b/tremor/debian/Makefile.am
new file mode 100644
index 0000000..45a0f01
--- /dev/null
+++ b/tremor/debian/Makefile.am
@@ -0,0 +1,6 @@
+## Process this file with automake to produce Makefile.in
+
+AUTOMAKE_OPTIONS = foreign
+
+EXTRA_DIST = changelog control copyright libvorbisidec1.install\
+ libvorbisidec-dev.install rules
diff --git a/tremor/debian/changelog b/tremor/debian/changelog
new file mode 100644
index 0000000..0cb4935
--- /dev/null
+++ b/tremor/debian/changelog
@@ -0,0 +1,9 @@
+libvorbisidec (1.2.0-1) unstable; urgency=low
+
+ * Initial Release.
+
+ -- Christopher L Cheney Wed, 09 Oct 2002 22:00:00 -0500
+
+Local variables:
+mode: debian-changelog
+End:
diff --git a/tremor/debian/control b/tremor/debian/control
new file mode 100644
index 0000000..f286e91
--- /dev/null
+++ b/tremor/debian/control
@@ -0,0 +1,22 @@
+Source: libvorbisidec
+Section: libs
+Priority: optional
+Maintainer: Christopher L Cheney
+Build-Depends: autotools-dev, debhelper (>> 4.0.18), devscripts, gawk
+Standards-Version: 3.5.7.0
+
+Package: libvorbisidec1
+Architecture: any
+Section: libs
+Depends: ${shlibs:Depends}
+Description: Ogg Bitstream Library
+ Libogg is a library for manipulating ogg bitstreams. It handles
+ both making ogg bitstreams and getting packets from ogg bitstreams.
+
+Package: libvorbisidec-dev
+Architecture: any
+Section: devel
+Depends: libvorbisidec1 (= ${Source-Version}), libc6-dev
+Description: Ogg Bitstream Library Development
+ The libogg-dev package contains the header files and documentation
+ needed to develop applications with libogg.
diff --git a/tremor/debian/copyright b/tremor/debian/copyright
new file mode 100644
index 0000000..ef98ddd
--- /dev/null
+++ b/tremor/debian/copyright
@@ -0,0 +1,37 @@
+This package was debianized by Christopher L Cheney on
+Wed, 09 Oct 2002 22:00:00 -0500.
+
+It was downloaded from cvs.
+
+Upstream Author(s): Monty
+
+Copyright:
+Copyright (c) 2002, Xiph.org Foundation
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+- Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+- Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+- Neither the name of the Xiph.Org Foundation nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
diff --git a/tremor/debian/libvorbisidec-dev.install b/tremor/debian/libvorbisidec-dev.install
new file mode 100644
index 0000000..5c3ccf9
--- /dev/null
+++ b/tremor/debian/libvorbisidec-dev.install
@@ -0,0 +1,8 @@
+debian/tmp/usr/include/tremor/config_types.h
+debian/tmp/usr/include/tremor/ivorbiscodec.h
+debian/tmp/usr/include/tremor/ivorbisfile.h
+debian/tmp/usr/include/tremor/ogg.h
+debian/tmp/usr/include/tremor/os_types.h
+debian/tmp/usr/lib/libvorbisidec.a
+debian/tmp/usr/lib/libvorbisidec.la
+debian/tmp/usr/lib/libvorbisidec.so
diff --git a/tremor/debian/libvorbisidec1.install b/tremor/debian/libvorbisidec1.install
new file mode 100644
index 0000000..b824d1e
--- /dev/null
+++ b/tremor/debian/libvorbisidec1.install
@@ -0,0 +1 @@
+debian/tmp/usr/lib/libvorbisidec.so.*
diff --git a/tremor/debian/rules b/tremor/debian/rules
new file mode 100755
index 0000000..c684884
--- /dev/null
+++ b/tremor/debian/rules
@@ -0,0 +1,151 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# This is the debhelper compatibility version to use.
+export DH_COMPAT=4
+
+# This has to be exported to make some magic below work.
+export DH_OPTIONS
+
+# These are used for cross-compiling and for saving the configure script
+# from having to guess our platform (since we know it already)
+DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+objdir = $(CURDIR)/obj-$(DEB_BUILD_GNU_TYPE)
+
+ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -g
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+ INSTALL_PROGRAM += -s
+endif
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+
+ # make build directory
+ mkdir $(objdir)
+
+ # run configure with build tree $(objdir)
+ # change ../configure to ../autogen.sh for CVS build
+ cd $(objdir) && \
+ ../configure --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) \
+ --prefix=/usr
+
+ touch configure-stamp
+
+build: build-stamp
+build-stamp: configure-stamp
+ dh_testdir
+
+ cd $(objdir) && \
+ $(MAKE)
+
+ touch build-stamp
+
+autotools:
+ OLDDATESUB=`./config.sub -t | tr -d -` ;\
+ OLDDATEGUESS=`./config.guess -t | tr -d -` ;\
+ NEWDATESUB=`/usr/share/misc/config.sub -t | tr -d -` ;\
+ NEWDATEGUESS=`/usr/share/misc/config.guess -t | tr -d -` ;\
+ if [ $$OLDDATESUB -lt $$NEWDATESUB -o \
+ $$OLDDATEGUESS -lt $$NEWDATEGUESS ]; then \
+ dch -a -p "GNU config automated update: config.sub\
+ ($$OLDDATESUB to $$NEWDATESUB), config.guess\
+ ($$OLDDATEGUESS to $$NEWDATEGUESS)" ;\
+ cp -f /usr/share/misc/config.sub config.sub ;\
+ cp -f /usr/share/misc/config.guess config.guess ;\
+ echo WARNING: GNU config scripts updated from master copies 1>&2 ;\
+ fi
+
+debian-clean:
+ dh_testdir
+ dh_testroot
+
+ dh_clean
+
+clean: autotools
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ # Remove build tree
+ rm -rf $(objdir)
+
+ # if Makefile exists run distclean
+ if test -f Makefile; then \
+ $(MAKE) distclean; \
+ fi
+
+ #if test -d CVS; then \
+ $(MAKE) cvs-clean ;\
+ fi
+
+ dh_clean
+
+install: DH_OPTIONS=
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ cd $(objdir) && \
+ $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
+
+ dh_install --list-missing
+
+# This single target is used to build all the packages, all at once, or
+# one at a time. So keep in mind: any options passed to commands here will
+# affect _all_ packages. Anything you want to only affect one package
+# should be put in another target, such as the install target.
+binary-common:
+ dh_testdir
+ dh_testroot
+# dh_installxfonts
+ dh_installchangelogs
+ dh_installdocs
+ dh_installexamples
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+# dh_undocumented
+ dh_installman
+ dh_strip
+ dh_link
+ dh_compress
+ dh_fixperms
+ dh_makeshlibs -V
+ dh_installdeb
+# dh_perl
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+# Build architecture independant packages using the common target.
+binary-indep: build install
+# $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
+
+# Build architecture dependant packages using the common target.
+binary-arch: build install
+ $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common
+
+# Any other binary targets build just one binary package at a time.
+binary-%: build install
+ $(MAKE) -f debian/rules binary-common DH_OPTIONS=-p$*
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/tremor/doc/OggVorbis_File.html b/tremor/doc/OggVorbis_File.html
new file mode 100644
index 0000000..9201d18
--- /dev/null
+++ b/tremor/doc/OggVorbis_File.html
@@ -0,0 +1,132 @@
+
+
+
+Tremor - datatype - OggVorbis_File
+
+
+
+
+
+
+
Tremor documentation
+
Tremor version 1.0 - 20020403
+
+
+
+
OggVorbis_File
+
+
declared in "ivorbisfile.h"
+
+
+The OggVorbis_File structure defines an Ogg Vorbis file.
+
+
+This structure is used in all libvorbisidec routines. Before it can be used,
+it must be initialized by ov_open() or ov_open_callbacks().
+
+
+After use, the OggVorbis_File structure must be deallocated with a
+call to ov_clear().
+
+
+Once a file or data source is opened successfully by libvorbisidec
+(using ov_open() or ov_open_callbacks()), it is owned by
+libvorbisidec. The file should not be used by any other applications or
+functions outside of the libvorbisidec API. The file must not be closed
+directly by the application at any time after a successful open;
+libvorbisidec expects to close the file within ov_clear().
+
+If the call to ov_open() or ov_open_callbacks()fails,
+libvorbisidec does not assume ownership of the file and the
+application is expected to close it if necessary.
+
+
+
+
+
+
typedef struct {
+ void *datasource; /* Pointer to a FILE *, etc. */
+ int seekable;
+ ogg_int64_t offset;
+ ogg_int64_t end;
+ ogg_sync_state oy;
+
+ /* If the FILE handle isn't seekable (eg, a pipe), only the current
+ stream appears */
+ int links;
+ ogg_int64_t *offsets;
+ ogg_int64_t *dataoffsets;
+ long *serialnos;
+ ogg_int64_t *pcmlengths;
+ vorbis_info *vi;
+ vorbis_comment *vc;
+
+ /* Decoding working state local storage */
+ ogg_int64_t pcm_offset;
+ int ready_state;
+ long current_serialno;
+ int current_link;
+
+ ogg_int64_t bittrack;
+ ogg_int64_t samptrack;
+
+ ogg_stream_state os; /* take physical pages, weld into a logical
+ stream of packets */
+ vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
+ vorbis_block vb; /* local working space for packet->PCM decode */
+
+ ov_callbacks callbacks;
+
+} OggVorbis_File;
+
+
+
+
+
Relevant Struct Members
+
+
datasource
+
+
Pointer to file or other ogg source. When using stdio based
+file/stream access, this field contains a FILE pointer. When using
+custom IO via callbacks, libvorbisidec treats this void pointer as a
+black box only to be passed to the callback routines provided by the
+application.
+
+
seekable
+
Read-only int indicating whether file is seekable. E.g., a physical file is seekable, a pipe isn't.
+
links
+
Read-only int indicating the number of logical bitstreams within the physical bitstream.
+
ov_callbacks
+
Collection of file manipulation routines to be used on this data source. When using stdio/FILE access via ov_open(), the callbacks will be filled in with stdio calls or wrappers to stdio calls.
+
+
+
Notes
+
+
Tremor requires a native 64 bit integer type to compile and
+function; The GNU build system will locate and typedef
+ogg_int64_t to the appropriate native type. If not using the
+GNU build tools, you will need to define ogg_int64_t as a
+64-bit type inside your system's project file/Makefile, etc. On win32,
+for example, this should be defined as __int64.
+
+
+The C source in the Tremor package will build on any ANSI C compiler
+and function completely and properly on any platform. The included
+build system assumes GNU build system and make tools (m4, automake,
+autoconf, libtool and gmake). GCC is not required, although GCC is
+the most tested compiler. To build using GNU tools, type in the
+source directory:
+
+
+
+./autogen.sh
+gmake
+
+
+or if GNU make is the standard make on the build system:
+
+./autogen.sh
+make
+
+
+
+Currently, the source implements playback in pure C on all platforms
+except ARM, where a [currently] small amount of assembly (see the file
+asm_arm.h) is used to implement 64 bit math operations and
+fast LSP computation. If building on ARM without the benefit of GNU
+build system tools, be sure that _ARM_ASSEM_ is #defined by
+the build system if this assembly is desired, else the resulting
+library will use whatever 64 bit math builtins the compiler
+implements.
+
+
+No math library is required by this source. No floating point
+operations are used at any point in either setup or decode. This
+decoder library will properly decode any past, current or future
+Vorbis I file or stream.
+
+
+The GNU build system produces static and, when supported by the OS,
+dynamic libraries named 'libvorbisidec'. This library exposes an API
+nearly identical to the BSD reference library's 'libvorbisfile',
+including all the features familiar to users of vorbisfile. This API
+is similar enough that the proper header file to include is named
+'ivorbisfile.h', included in the source build directory.
+Lower level libvorbis-style headers and structures are
+in 'ivorbiscodec.h', also included in the source build directory. A
+simple example program, ivorbisfile_example.c, can be built with 'make
+ivorbisfile_example'.
+
Tremor requires a native 64 bit integer type to compile and
+function; The GNU build system will locate and typedef
+ogg_int64_t to the appropriate native type. If not using the
+GNU build tools, you will need to define ogg_int64_t as a
+64-bit type inside your system's project file/Makefile, etc. On win32,
+for example, this should be defined as __int64.
+
+
+Although stdio is convenient and nearly universally implemented as per
+ANSI C, it is not suited to all or even most potential uses of Vorbis.
+For additional flexibility, embedded applications may provide their
+own I/O functions for use with Tremor when stdio is unavailable or not
+suitable. One common example is decoding a Vorbis stream from a
+memory buffer.
+
+The read-like function provided in the read_func field is
+used to fetch the requested amount of data. It expects the fetch
+operation to function similar to file-access, that is, a multiple read
+operations will retrieve contiguous sequential pieces of data,
+advancing a position cursor after each read.
+
+The following behaviors are also expected:
+
+
a return of '0' indicates end-of-data (if the by-thread errno is unset)
+
short reads mean nothing special (short reads are not treated as error conditions)
+
a return of zero with the by-thread errno set to nonzero indicates a read error
+
+
+
+
Seek function
+
+The seek-like function provided in the seek_func field is
+used to request non-sequential data access by libvorbisidec, moving
+the access cursor to the requested position.
+
+libvorbisidec expects the following behavior:
+
+
The seek function must always return -1 (failure) if the given
+data abstraction is not seekable. It may choose to always return -1
+if the application desires libvorbisidec to treat the Vorbis data
+strictly as a stream (which makes for a less expensive open
+operation).
+
+
If the seek function initially indicates seekability, it must
+always succeed upon being given a valid seek request.
+
+
The seek function must implement all of SEEK_SET, SEEK_CUR and
+SEEK_END. The implementation of SEEK_END should set the access cursor
+one past the last byte of accessible data, as would stdio
+fseek()
+
+
+
Close function
+
+The close function should deallocate any access state used by the
+passed in instance of the data access abstraction and invalidate the
+instance handle. The close function is assumed to succeed.
+
+One common use of callbacks and the close function is to change the
+behavior of libvorbisidec with respect to file closure for applications
+that mustfclose data files themselves. By passing
+the normal stdio calls as callback functions, but passing a
+close_func that does nothing, an application may call ov_clear() and then fclose() the
+file originally passed to libvorbisidec.
+
+
Tell function
+
+The tell function is intended to mimic the
+behavior of ftell() and must return the byte position of the
+next data byte that would be read. If the data access cursor is at
+the end of the 'file' (pointing to one past the last byte of data, as
+it would be after calling fseek(file,SEEK_END,0)), the tell
+function must return the data position (and thus the total file size),
+not an error.
+
+The tell function need not be provided if the data IO abstraction is
+not seekable.
+
+
+
+
diff --git a/tremor/doc/datastructures.html b/tremor/doc/datastructures.html
new file mode 100644
index 0000000..2b3da07
--- /dev/null
+++ b/tremor/doc/datastructures.html
@@ -0,0 +1,61 @@
+
+
+
+Tremor - Base Data Structures
+
+
+
+
+
+
+
Tremor documentation
+
Tremor version 1.0 - 20020403
+
+
+
+
Base Data Structures
+
There are several data structures used to hold file and bitstream information during libvorbisidec decoding. These structures are declared in "ivorbisfile.h" and "ivorbiscodec.h".
+
+
When using libvorbisidec, it's not necessary to know about most of the contents of these data structures, but it may be helpful to understand what they contain.
+
This structure represents the basic file information. It contains
+ a pointer to the physical file or bitstream and various information about that bitstream.
This structure contains the file comments. It contains
+ a pointer to unlimited user comments, information about the number of comments, and a vendor description.
+All libivorbisdec decoding routines are declared in "ivorbisfile.h".
+
+
+After initialization, decoding audio
+is as simple as calling ov_read(). This
+function works similarly to reading from a normal file using
+read().
+
+However, a few differences are worth noting:
+
+
multiple stream links
+
+A Vorbis stream may consist of multiple sections (called links) that
+encode differing numbers of channels or sample rates. It is vitally
+important to pay attention to the link numbers returned by ov_read and handle audio changes that may
+occur at link boundaries. Such multi-section files do exist in the
+wild and are not merely a specification curiosity.
+
+
returned data amount
+
+ov_read does not attempt to completely fill
+a large, passed in data buffer; it merely guarantees that the passed
+back data does not overflow the passed in buffer size. Large buffers
+may be filled by iteratively looping over calls to ov_read (incrementing the buffer pointer)
+until the original buffer is filled.
+
+
file cursor position
+
+Vorbis files do not necessarily start at a sample number or time offset
+of zero. Do not be surprised if a file begins at a positive offset of
+several minutes or hours, such as would happen if a large stream (such
+as a concert recording) is chopped into multiple seperate files.
+
+
This function makes up the main chunk of a decode loop. It takes an
+OggVorbis_File structure, which must have been initialized by a previous
+call to ov_open().
+
+The Tremor libvorbisidec library exposes an API intended to be as
+similar as possible to the familiar 'vorbisfile' library included with
+the open source Vorbis reference libraries distributed for free by
+Xiph.org. Differences are summarized below.
+
+
OggVorbis_File structure
+
+The bittrack and samptrack fields in the OggVorbis_File structure are changed to
+64 bit integers in Tremor, from doubles in vorbisfile.
+
+
Time-related seek and tell function calls
+
+The ov_time_total() and ov_time_tell() functions return milliseconds as
+64 bit integers in Tremor. In vorbisfile, these functions returned
+seconds as doubles.
+
+In Tremor, the ov_time_seek() and ov_time_seek_page() calls take
+seeking positions in milliseconds as 64 bit integers, rather than in
+seconds as doubles as in Vorbisfile.
+
+
Reading decoded data
+
+Tremor ov_read() always returns data as
+signed 16 bit interleaved PCM in host byte order. As such, it does not
+take arguments to request specific signedness, byte order or bit depth
+as in Vorbisfile.
+The following is a run-through of the decoding example program supplied
+with libvorbisidec, ivorbisfile_example.c.
+This program takes a vorbis bitstream from stdin and writes raw pcm to stdout.
+
+
+First, relevant headers, including vorbis-specific "ivorbiscodec.h" and "ivorbisfile.h" have to be included.
+
+
+We also have to make a concession to Windows users here. If we are using windows for decoding, we must declare these libraries so that we can set stdin/stdout to binary.
+
+Next, a buffer for the pcm audio output is declared.
+
+
+
+
+
+
+char pcmout[4096];
+
+
+
+
+
+
Inside main(), we declare our primary OggVorbis_File structure. We also declare a few other helpful variables to track out progress within the file.
+Also, we make our final concession to Windows users by setting the stdin and stdout to binary mode.
+
ov_open() must be
+called to initialize the OggVorbis_File structure with default values.
+ov_open() also checks to ensure that we're reading Vorbis format and not something else.
+
+
+
+
+
+
+ if(ov_open(stdin, &vf, NULL, 0) < 0) {
+ fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
+ exit(1);
+ }
+
+
+
+
+
+
+
+We're going to pull the channel and bitrate info from the file using ov_info() and show them to the user.
+We also want to pull out and show the user a comment attached to the file using ov_comment().
+
+
+
+ while(!eof){
+ long ret=ov_read(&vf,pcmout,sizeof(pcmout),¤t_section);
+ if (ret == 0) {
+ /* EOF */
+ eof=1;
+ } else if (ret < 0) {
+ /* error in the stream. Not a problem, just reporting it in
+ case we (the app) cares. In this case, we don't. */
+ } else {
+ /* we don't bother dealing with sample rate changes, etc, but
+ you'll have to*/
+ fwrite(pcmout,1,ret,stdout);
+ }
+ }
+
+
+
+
+
+
+
+
+The code is reading blocks of data using ov_read().
+Based on the value returned, we know if we're at the end of the file or have invalid data. If we have valid data, we write it to the pcm output.
+
+
+Now that we've finished playing, we can pack up and go home. It's important to call ov_clear() when we're finished.
+
+
+
+The Tremor Vorbis I stream and file decoder provides an embeddable,
+integer-only library [libvorbisidec] intended for decoding all current
+and future Vorbis I compliant streams. The Tremor libvorbisidec
+library exposes an API intended to be as similar as possible to the
+familiar 'vorbisfile' library included with the open source Vorbis
+reference libraries distributed for free by Xiph.org.
+
+Tremor can be used along with any ANSI compliant stdio implementation
+for file/stream access, or use custom stream i/o routines provided by
+the embedded environment. Both uses are described in detail in this
+documentation.
+
+
In order to decode audio using
+libvorbisidec, a bitstream containing Vorbis audio must be properly
+initialized before decoding and cleared when decoding is finished.
+The simplest possible case is to use fopen() to open a Vorbis
+file and then pass the FILE * to an ov_open() call. A successful return code from ov_open() indicates the file is ready for use.
+Once the file is no longer needed, ov_clear() is used to close the file and
+deallocate decoding resources. Do not call fclose() on the
+file; libvorbisidec does this in the ov_clear() call.
+
+
+All libvorbisidec initialization and deallocation routines are declared in "ivorbisfile.h".
+
Initializes the Ogg Vorbis bitstream with a pointer to a bitstream and default values. This must be called before other functions in the library may be
+ used.
Initializes the Ogg Vorbis bitstream with a pointer to a bitstream, default values, and custom file/bitstream manipulation routines. Used instead of ov_open() when working with other than stdio based I/O.
Partially opens a file just far enough to determine if the file
+is an Ogg Vorbis file or not. A successful return indicates that the
+file appears to be an Ogg Vorbis file, but the OggVorbis_File struct is not yet fully
+initialized for actual decoding. After a successful return, the file
+may be closed using ov_clear() or fully
+opened for decoding using ov_test_open().
This call is intended to
+be used as a less expensive file open test than a full ov_open().
+Note that libvorbisidec owns the passed in file resource is it returns success; do not fclose() files owned by libvorbisidec.
Closes the
+ bitstream and cleans up loose ends. Must be called when
+ finished with the bitstream. After return, the OggVorbis_File struct is
+ invalid and may not be used before being initialized again
+ before begin reinitialized.
+
+
This function returns the average bitrate for the specified logical bitstream. This may be different from the ov_info->nominal_bitrate value, as it is based on the actual average for this bitstream if the file is seekable.
+
Nonseekable files will return the nominal bitrate setting or the average of the upper and lower bounds, if any of these values are set.
+
+
+
+
+
+
+
+long ov_bitrate(OggVorbis_File *vf,int i);
+
+
+
+
+
+
Parameters
+
+
vf
+
A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec
+functions.
+
i
+
Link to the desired logical bitstream. For nonseekable files, this argument is ignored. To retrieve the bitrate for the entire bitstream, this parameter should be set to -1.
+
+
+
+
Return Values
+
+
OV_EINVAL indicates that an invalid argument value was submitted or that the stream represented by vf is not open.
+
OV_FALSE means the call returned a 'false' status, which in this case most likely indicates that the file is nonseekable and the upper, lower, and nominal bitrates were unset.
+
n indicates the bitrate for the given logical bitstream or the entire
+ physical bitstream. If the file is open for random (seekable) access, it will
+ find the *actual* average bitrate. If the file is streaming (nonseekable), it
+ returns the nominal bitrate (if set) or else the average of the
+ upper/lower bounds (if set).
+The ov_callbacks structure contains file manipulation function prototypes necessary for opening, closing, seeking, and location.
+
+
+The ov_callbacks structure does not need to be user-defined if you are
+working with stdio-based file manipulation; the ov_open() call provides default callbacks for
+stdio. ov_callbacks are defined and passed to ov_open_callbacks() when
+implementing non-stdio based stream manipulation (such as playback
+from a memory buffer).
+
+
+
+
+
+
typedef struct {
+ size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource);
+ int (*seek_func) (void *datasource, ogg_int64_t offset, int whence);
+ int (*close_func) (void *datasource);
+ long (*tell_func) (void *datasource);
+} ov_callbacks;
+
+
+
+
+
Relevant Struct Members
+
+
read_func
+
Pointer to custom data reading function.
+
seek_func
+
Pointer to custom data seeking function. If the data source is not seekable (or the application wants the data source to be treated as unseekable at all times), the provided seek callback should always return -1 (failure).
After a bitstream has been opened using ov_open()/ov_open_callbacks() and decoding is complete, the application must call ov_clear() to clear
+the decoder's buffers and close the file.
A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec
+functions. After ov_clear has been called, the structure is deallocated and can no longer be used.
A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec
+functions.
+
i
+
Link to the desired logical bitstream. For nonseekable files, this argument is ignored. To retrieve the vorbis_comment struct for the current bitstream, this parameter should be set to -1.
+
+
+
+
Return Values
+
+
Returns the vorbis_comment struct for the specified bitstream.
+
NULL if the specified bitstream does not exist or the file has been initialized improperly.
A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec
+functions.
+
i
+
Link to the desired logical bitstream. For nonseekable files, this argument is ignored. To retrieve the vorbis_info struct for the current bitstream, this parameter should be set to -1.
+
+
+
+
Return Values
+
+
Returns the vorbis_info struct for the specified bitstream. Returns vorbis_info for current bitstream if the file is nonseekable or i=-1.
+
NULL if the specified bitstream does not exist or the file has been initialized improperly.
This is the main function used to open and initialize an OggVorbis_File
+structure. It sets up all the related decoding structure.
+
The first argument must be a file pointer to an already opened file
+or pipe (it need not be seekable--though this obviously restricts what
+can be done with the bitstream). vf should be a pointer to the
+OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec
+functions. Once this has been called, the same OggVorbis_File
+struct should be passed to all the libvorbisidec functions.
+
Also, you should be aware that ov_open(), once successful, takes complete possession of the file resource. After you have opened a file using ov_open(), you MUST close it using ov_clear(), not fclose() or any other function.
+
+It is often useful to call ov_open()
+simply to determine whether a given file is a vorbis bitstream. If the
+ov_open()
+call fails, then the file is not recognizable as such.
+When you use ov_open()
+for
+this, you should fclose() the file pointer if, and only if, the
+ov_open()
+call fails. If it succeeds, you must call ov_clear() to clear
+the decoder's buffers and close the file for you.
+
+(Note that ov_test() provides a less expensive way to test a file for Vorbisness.)
File pointer to an already opened file
+or pipe (it need not be seekable--though this obviously restricts what
+can be done with the bitstream).
+
vf
+
A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec
+functions. Once this has been called, the same OggVorbis_File
+struct should be passed to all the libvorbisidec functions.
+
initial
+
Typically set to NULL. This parameter is useful if some data has already been
+read from the file and the stream is not seekable. It is used in conjunction with ibytes. In this case, initial
+should be a pointer to a buffer containing the data read.
+
ibytes
+
Typically set to 0. This parameter is useful if some data has already been
+read from the file and the stream is not seekable. In this case, ibytes
+should contain the length (in bytes) of the buffer. Used together with initial
+
+
+
+
Return Values
+
+
0 indicates success
+
+
less than zero for failure:
+
+
OV_EREAD - A read from media returned an error.
+
OV_ENOTVORBIS - Bitstream is not Vorbis data.
+
OV_EVERSION - Vorbis version mismatch.
+
OV_EBADHEADER - Invalid Vorbis bitstream header.
+
OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
+
+
+
+
+
Notes
+
If your decoder is threaded, it is recommended that you NOT call
+ov_open()
+in the main control thread--instead, call ov_open() IN your decode/playback
+thread. This is important because ov_open() may be a fairly time-consuming
+call, given that the full structure of the file is determined at this point,
+which may require reading large parts of the file under certain circumstances
+(determining all the logical bitstreams in one physical bitstream, for
+example). See Thread Safety for other information on using libvorbisidec with threads.
+
+
+
This is an alternative function used to open and initialize an OggVorbis_File
+structure when using a data source other than a file. It allows you to specify custom file manipulation routines and sets up all the related decoding structure.
+
Once this has been called, the same OggVorbis_File
+struct should be passed to all the libvorbisidec functions.
+
+It is often useful to call ov_open_callbacks()
+simply to determine whether a given file is a vorbis bitstream. If the
+ov_open_callbacks()
+call fails, then the file is not recognizable as such. When you use ov_open_callbacks()
+for
+this, you should fclose() the file pointer if, and only if, the
+ov_open_callbacks()
+call fails. If it succeeds, you must call ov_clear() to clear
+the decoder's buffers and close the file for you.
+
+See also Callbacks and Non-stdio I/O for information on designing and specifying the required callback functions.
File pointer to an already opened file
+or pipe (it need not be seekable--though this obviously restricts what
+can be done with the bitstream).
+
vf
+
A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec
+functions. Once this has been called, the same OggVorbis_File
+struct should be passed to all the libvorbisidec functions.
+
initial
+
Typically set to NULL. This parameter is useful if some data has already been
+read from the file and the stream is not seekable. It is used in conjunction with ibytes. In this case, initial
+should be a pointer to a buffer containing the data read.
+
ibytes
+
Typically set to 0. This parameter is useful if some data has already been
+read from the file and the stream is not seekable. In this case, ibytes
+should contain the length (in bytes) of the buffer. Used together with initial.
+
callbacks
+
Pointer to a completed ov_callbacks struct which indicates desired custom file manipulation routines.
+
+
+
+
Return Values
+
+
0 for success
+
less than zero for failure:
+
+
OV_EREAD - A read from media returned an error.
+
OV_ENOTVORBIS - Bitstream is not Vorbis data.
+
OV_EVERSION - Vorbis version mismatch.
+
OV_EBADHEADER - Invalid Vorbis bitstream header.
+
OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
+
+
+
+
+
Notes
+
If your decoder is threaded, it is recommended that you NOT call
+ov_open_callbacks()
+in the main control thread--instead, call ov_open_callbacks() IN your decode/playback
+thread. This is important because ov_open_callbacks() may be a fairly time-consuming
+call, given that the full structure of the file is determined at this point,
+which may require reading large parts of the file under certain circumstances
+(determining all the logical bitstreams in one physical bitstream, for
+example).
+See Thread Safety for other information on using libvorbisidec with threads.
+
+
Seeks to the closest page preceding the specified location (in pcm samples) within the physical bitstream. This function only works for seekable streams.
+
This function is faster than ov_pcm_seek because the function can begin decoding at a page boundary rather than seeking through any remaining samples before the specified location. However, it is less accurate.
+
This also updates everything needed within the
+decoder, so you can immediately call ov_read() and get data from
+the newly seeked to position.
+
+ This is the main function used to decode a Vorbis file within a
+ loop. It returns up to the specified number of bytes of decoded audio
+ in host-endian, signed 16 bit PCM format. If the audio is
+ multichannel, the channels are interleaved in the output buffer.
+ If the passed in buffer is large, ov_read() will not fill
+ it; the passed in buffer size is treated as a limit and
+ not a request.
+
+
+Note that up to this point, the Tremor API could more or less hide the
+ multiple logical bitstream nature of chaining from the toplevel
+ application if the toplevel application didn't particularly care.
+ However, when reading audio back, the application must be aware
+ that multiple bitstream sections do not necessarily use the same
+ number of channels or sampling rate.
ov_read() passes
+ back the index of the sequential logical bitstream currently being
+ decoded (in *bitstream) along with the PCM data in order
+ that the toplevel application can handle channel and/or sample
+ rate changes. This number will be incremented at chaining
+ boundaries even for non-seekable streams. For seekable streams, it
+ represents the actual chaining index within the physical bitstream.
+
+
+
+
+
+
+
+long ov_read(OggVorbis_File *vf, char *buffer, int length, int *bitstream);
+
+
+
+
+
+
Parameters
+
+
vf
+
A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec
+functions.
+
buffer
+
A pointer to an output buffer. The decoded output is inserted into this buffer.
+
length
+
Number of bytes to be read into the buffer. Should be the same size as the buffer. A typical value is 4096.
+
bitstream
+
A pointer to the number of the current logical bitstream.
+
+
+
+
Return Values
+
+
+
OV_HOLE
+
indicates there was an interruption in the data.
+ (one of: garbage between pages, loss of sync followed by
+ recapture, or a corrupt page)
+
OV_EBADLINK
+
indicates that an invalid stream section was supplied to
+ libvorbisidec, or the requested link is corrupt.
+
0
+
indicates EOF
+
n
+
indicates actual number of bytes read. ov_read() will
+ decode at most one vorbis packet per invocation, so the value
+ returned will generally be less than length.
+
A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec
+functions.
+
i
+
Link to the desired logical bitstream. For nonseekable files, this argument is ignored. To retrieve the serial number of the current bitstream, this parameter should be set to -1.
+
+
+
+
Return Values
+
+
+-1 if the specified logical bitstream i does not exist.
+
+
Returns the serial number of the logical bitstream i or the serial number of the current bitstream if the file is nonseekable.
+This partially opens a vorbis file to test for Vorbis-ness. It loads
+the headers for the first chain, and tests for seekability (but does not seek).
+Use ov_test_open() to finish opening the file
+or ov_clear to close/free it.
+
File pointer to an already opened file
+or pipe (it need not be seekable--though this obviously restricts what
+can be done with the bitstream).
+
vf
+
A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec
+functions. Once this has been called, the same OggVorbis_File
+struct should be passed to all the libvorbisidec functions.
+
initial
+
Typically set to NULL. This parameter is useful if some data has already been
+read from the file and the stream is not seekable. It is used in conjunction with ibytes. In this case, initial
+should be a pointer to a buffer containing the data read.
+
ibytes
+
Typically set to 0. This parameter is useful if some data has already been
+read from the file and the stream is not seekable. In this case, ibytes
+should contain the length (in bytes) of the buffer. Used together with initial
+
+
+
+
Return Values
+
+
0 for success
+
+
less than zero for failure:
+
+
OV_EREAD - A read from media returned an error.
+
OV_ENOTVORBIS - Bitstream is not Vorbis data.
+
OV_EVERSION - Vorbis version mismatch.
+
OV_EBADHEADER - Invalid Vorbis bitstream header.
+
OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
This is an alternative function used to open and test an OggVorbis_File
+structure when using a data source other than a file. It allows you to specify custom file manipulation routines and sets up all the related decoding structures.
+
Once this has been called, the same OggVorbis_File
+struct should be passed to all the libvorbisidec functions.
+
File pointer to an already opened file
+or pipe (it need not be seekable--though this obviously restricts what
+can be done with the bitstream).
+
vf
+
A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec
+functions. Once this has been called, the same OggVorbis_File
+struct should be passed to all the libvorbisidec functions.
+
initial
+
Typically set to NULL. This parameter is useful if some data has already been
+read from the file and the stream is not seekable. It is used in conjunction with ibytes. In this case, initial
+should be a pointer to a buffer containing the data read.
+
ibytes
+
Typically set to 0. This parameter is useful if some data has already been
+read from the file and the stream is not seekable. In this case, ibytes
+should contain the length (in bytes) of the buffer. Used together with initial.
+
callbacks
+
Pointer to a completed ov_callbacks struct which indicates desired custom file manipulation routines.
+
+
+
+
Return Values
+
+
0 for success
+
less than zero for failure:
+
+
OV_EREAD - A read from media returned an error.
+
OV_ENOTVORBIS - Bitstream is not Vorbis data.
+
OV_EVERSION - Vorbis version mismatch.
+
OV_EBADHEADER - Invalid Vorbis bitstream header.
+
OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec
+functions. Once this has been called, the same OggVorbis_File
+struct should be passed to all the libvorbisidec functions.
+
+
+
+
Return Values
+
+
+0 for success
+
+
less than zero for failure:
+
+
OV_EREAD - A read from media returned an error.
+
OV_ENOTVORBIS - Bitstream is not Vorbis data.
+
OV_EVERSION - Vorbis version mismatch.
+
OV_EBADHEADER - Invalid Vorbis bitstream header.
+
OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
For seekable
+streams, this seeks to the given time. For implementing seeking in a player,
+this is the only function generally needed. This also updates everything needed within the
+decoder, so you can immediately call ov_read() and get data from
+the newly seeked to position. This function does not work for unseekable streams.
+
+
For seekable
+streams, this seeks to closest full page preceding the given time. This function is faster than ov_time_seek because it doesn't seek through the last few samples to reach an exact time, but it is also less accurate. This should be used when speed is important.
+
This function also updates everything needed within the
+decoder, so you can immediately call ov_read() and get data from
+the newly seeked to position.
+
This function does not work for unseekable streams.
+
+
The makeup of the Tremor libvorbisidec library API is relatively
+simple. It revolves around a single file resource. This file resource is
+passed to libvorbisidec, where it is opened, manipulated, and closed,
+in the form of an OggVorbis_File
+struct.
+
+The Tremor API consists of the following functional categories:
+
+
+The following return codes are #defined in "ivorbiscodec.h"
+may be returned by libvorbisidec. Descriptions of a code relevant to
+a specific function are found in the reference description of that
+function.
+
+
+
+
OV_FALSE
+
Not true, or no data available
+
+
OV_HOLE
+
Tremor encoutered missing or corrupt data in the bitstream. Recovery
+is normally automatic and this return code is for informational purposes only.
+
+
OV_EREAD
+
Read error while fetching compressed data for decode
+
+
OV_EFAULT
+
Internal inconsistency in decode state. Continuing is likely not possible.
+
+
OV_EIMPL
+
Feature not implemented
+
+
OV_EINVAL
+
Either an invalid argument, or incompletely initialized argument passed to libvorbisidec call
+
+
OV_ENOTVORBIS
+
The given file/data was not recognized as Ogg Vorbis data.
+
+
OV_EBADHEADER
+
The file/data is apparently an Ogg Vorbis stream, but contains a corrupted or undecipherable header.
+
+
OV_EVERSION
+
The bitstream format revision of the given stream is not supported.
+
+
OV_EBADLINK
+
The given link exists in the Vorbis data stream, but is not decipherable due to garbacge or corruption.
Seeking functions allow you to specify a specific point in the stream to begin or continue decoding.
+
+All libvorbisidec seeking routines are declared in "ivorbisfile.h".
+
+
Certain seeking functions are best suited to different situations.
+When speed is important and exact positioning isn't required,
+page-level seeking should be used. Note also that Vorbis files do not
+necessarily start at a sample number or time offset of zero. Do not
+be surprised if a file begins at a positive offset of several minutes
+or hours, such as would happen if a large stream (such as a concert
+recording) is chopped into multiple separate files. Requesting to
+seek to a position before the beginning of such a file will seek to
+the position where audio begins.
This function seeks to the specific time location in the bitstream, specified in integer milliseconds. Note that this differs from the reference vorbisfile implementation, which takes seconds as a float.
+
+Tremor's libvorbisidec may be used safely in a threading environment
+so long as thread access to individual OggVorbis_File instances is serialized.
+
+
+
Only one thread at a time may enter a function that takes a given OggVorbis_File instance, even if the
+functions involved appear to be read-only.
+
+
Multiple threads may enter
+libvorbisidec at a given time, so long as each thread's function calls
+are using different OggVorbis_File
+instances.
+
+
Any one OggVorbis_File instance may be used safely from multiple threads so long as only one thread at a time is making calls using that instance.
+The vorbis_comment structure defines an Ogg Vorbis comment.
+
+Only the fields the program needs must be defined. If a field isn't
+defined by the application, it will either be blank (if it's a string value)
+or set to some reasonable default (usually 0).
+
+
+
+
+
+
typedef struct vorbis_comment{
+ /* unlimited user comment fields. */
+ char **user_comments;
+ int *comment_lengths;
+ int comments;
+ char *vendor;
+
+} vorbis_comment;
+
+
+
+
+
Parameters
+
+
user_comments
+
Unlimited user comment array. The individual strings in the array are 8 bit clean, by the Vorbis specification, and as such the comment_lengths array should be consulted to determine string length. For convenience, each string is also NULL-terminated by the decode library (although Vorbis comments are not NULL terminated within the bitstream itself).
+
comment_lengths
+
An int array that stores the length of each comment string
+
comments
+
Int signifying number of user comments in user_comments field.
+
vendor
+
Information about the creator of the file. Stored in a standard C 0-terminated string.
+The vorbis_info structure contains basic information about the audio in a vorbis bitstream.
+
+
+
+
+
+
typedef struct vorbis_info{
+ int version;
+ int channels;
+ long rate;
+
+ long bitrate_upper;
+ long bitrate_nominal;
+ long bitrate_lower;
+ long bitrate_window;
+
+ void *codec_setup;
+
+} vorbis_info;
+
+
+
+
+
Relevant Struct Members
+
+
version
+
Vorbis encoder version used to create this bitstream.
+
channels
+
Int signifying number of channels in bitstream.
+
rate
+
Sampling rate of the bitstream.
+
bitrate_upper
+
Specifies the upper limit in a VBR bitstream. If the value matches the bitrate_nominal and bitrate_lower parameters, the stream is fixed bitrate. May be unset if no limit exists.
+
bitrate_nominal
+
Specifies the average bitrate for a VBR bitstream. May be unset. If the bitrate_upper and bitrate_lower parameters match, the stream is fixed bitrate.
+
bitrate_lower
+
Specifies the lower limit in a VBR bitstream. If the value matches the bitrate_nominal and bitrate_upper parameters, the stream is fixed bitrate. May be unset if no limit exists.
+
bitrate_window
+
Currently unset.
+
+
codec_setup
+
Internal structure that contains the detailed/unpacked configuration for decoding the current Vorbis bitstream.