[xiph-cvs] cvs commit: vorbis-tools/vorbiscomment Makefile.am vcedit.c vcedit.h vcomment.c getopt.c getopt.h getopt1.c

Stan Seibert volsung at xiph.org
Sat Dec 15 07:26:37 PST 2001



volsung     01/12/15 07:26:35

  Modified:    .        Tag: volsung_kc_20011011 Makefile.am acinclude.m4
                        autogen.sh configure.in vorbis-tools.spec
               debian   Tag: volsung_kc_20011011 Makefile.am changelog
                        control rules vorbis-tools.undocumented
               ogg123   Tag: volsung_kc_20011011 Makefile.am ogg123.1
               oggenc   Tag: volsung_kc_20011011 Makefile.am audio.c
                        encode.c encode.h oggenc.c oggenc.dsp platform.h
               oggenc/man Tag: volsung_kc_20011011 Makefile.am oggenc.1
               ogginfo  Tag: volsung_kc_20011011 Makefile.am ogginfo.1
                        ogginfo.c
               vcut     Tag: volsung_kc_20011011 vcut.c vcut.h
               vorbiscomment Tag: volsung_kc_20011011 Makefile.am vcedit.c
                        vcedit.h vcomment.c
  Added:       .        Tag: volsung_kc_20011011 HACKING
               debian   Tag: volsung_kc_20011011 vorbis-tools.manpages
               include  Tag: volsung_kc_20011011 .cvsignore Makefile.am
                        getopt.h utf8.h
               ogginfo  Tag: volsung_kc_20011011 .cvsignore
               share    Tag: volsung_kc_20011011 .cvsignore Makefile.am
                        charmaps.h charset.c charset.h charset_test.c
                        charsetmap.h getopt.c getopt1.c iconvert.c
                        makemap.c utf8.c
               vcut     Tag: volsung_kc_20011011 .cvsignore Makefile.am
  Removed:     debian   Tag: volsung_kc_20011011 vorbis-tools.examples
                        vorbis-tools.postinst vorbis-tools.postrm
                        vorbis-tools.preinst vorbis-tools.prerm
               ogg123   Tag: volsung_kc_20011011 getopt.c getopt.h
                        getopt1.c
               oggenc   Tag: volsung_kc_20011011 getopt.c getopt.h
                        getopt1.c
               vorbiscomment Tag: volsung_kc_20011011 getopt.c getopt.h
                        getopt1.c
  Log:
  Merger of HEAD onto branch for testing.  After testing, will merge back
  down to HEAD.

Revision  Changes    Path
No                   revision

No                   revision

1.6.4.1   +1 -1      vorbis-tools/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/Makefile.am,v
retrieving revision 1.6
retrieving revision 1.6.4.1
diff -u -r1.6 -r1.6.4.1
--- Makefile.am	2001/06/18 02:24:25	1.6
+++ Makefile.am	2001/12/15 15:26:22	1.6.4.1
@@ -2,7 +2,7 @@
 
 AUTOMAKE_OPTIONS = foreign dist-zip
 
-SUBDIRS = oggenc ogg123 vorbiscomment ogginfo debian
+SUBDIRS = include share oggenc ogg123 vorbiscomment vcut ogginfo debian
 
 EXTRA_DIST = README AUTHORS COPYING vorbis-tools.spec acinclude.m4
 

1.9.4.1   +197 -87   vorbis-tools/acinclude.m4

Index: acinclude.m4
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/acinclude.m4,v
retrieving revision 1.9
retrieving revision 1.9.4.1
diff -u -r1.9 -r1.9.4.1
--- acinclude.m4	2001/06/19 16:34:05	1.9
+++ acinclude.m4	2001/12/15 15:26:22	1.9.4.1
@@ -1,4 +1,3 @@
-# ogg.m4
 # Configure paths for libogg
 # Jack Moffitt <jack at icecast.org> 10-21-2000
 # Shamelessly stolen from Owen Taylor and Manish Singh
@@ -10,21 +9,29 @@
 [dnl 
 dnl Get the cflags and libraries
 dnl
-AC_ARG_WITH(ogg-prefix,[  --with-ogg-prefix=PFX   Prefix where libogg is installed (optional)], ogg_prefix="$withval", ogg_prefix="")
+AC_ARG_WITH(ogg,[  --with-ogg=PFX   Prefix where libogg is installed (optional)], ogg_prefix="$withval", ogg_prefix="")
+AC_ARG_WITH(ogg-libraries,[  --with-ogg-libraries=DIR   Directory where libogg library is installed (optional)], ogg_libraries="$withval", ogg_libraries="")
+AC_ARG_WITH(ogg-includes,[  --with-ogg-includes=DIR   Directory where libogg header files are installed (optional)], ogg_includes="$withval", ogg_includes="")
 AC_ARG_ENABLE(oggtest, [  --disable-oggtest       Do not try to compile and run a test Ogg program],, enable_oggtest=yes)
 
-  if test "x$ogg_prefix" != "xNONE" ; then
-    ogg_args="$ogg_args --prefix=$ogg_prefix"
-    OGG_CFLAGS="-I$ogg_prefix/include"
+  if test "x$ogg_libraries" != "x" ; then
+    OGG_LIBS="-L$ogg_libraries"
+  elif test "x$ogg_prefix" != "x" ; then
     OGG_LIBS="-L$ogg_prefix/lib"
-  elif test "$prefix" != ""; then
-    ogg_args="$ogg_args --prefix=$prefix"
-    OGG_CFLAGS="-I$prefix/include"
+  elif test "x$prefix" != "xNONE" ; then
     OGG_LIBS="-L$prefix/lib"
   fi
 
   OGG_LIBS="$OGG_LIBS -logg"
 
+  if test "x$ogg_includes" != "x" ; then
+    OGG_CFLAGS="-I$ogg_includes"
+  elif test "x$ogg_prefix" != "x" ; then
+    OGG_CFLAGS="-I$ogg_prefix/include"
+  elif test "$prefix" != "xNONE"; then
+    OGG_CFLAGS="-I$prefix/include"
+  fi
+
   AC_MSG_CHECKING(for Ogg)
   no_ogg=""
 
@@ -94,8 +101,69 @@
   AC_SUBST(OGG_LIBS)
   rm -f conf.oggtest
 ])
+
+dnl Shamelessly stolen from Joerg Schilling's star.
+dnl Copyright 1998 J. Schilling
+
+dnl Checks if mmap() works to get shared memory
+dnl Defines HAVE_SMMAP on success.
+AC_DEFUN(AC_FUNC_SMMAP,
+[AC_CACHE_CHECK([if mmap works to get shared memory], ac_cv_func_smmap,
+                [AC_TRY_RUN([
+#include <sys/types.h>
+#include <sys/mman.h>
+
+char *
+mkshare()
+{
+        int     size = 8192;
+        int     f;
+        char    *addr;
+
+        if ((f = open("/dev/zero", 2)) < 0)
+                exit(1);
+        addr = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, f, 0);
+        if (addr == (char *)-1)
+                exit(1);
+        close(f);
+
+        return (addr);
+}
+
+main()
+{
+        char    *addr;
+        
+        addr = mkshare(8192);
+        *addr = 'I';
+
+        switch (fork()) {
+
+        case -1:
+                printf("help\n"); exit(1);
+
+        case 0: /* child */
+                *addr = 'N';
+                _exit(0);
+                break;
+        default: /* parent */
+                wait(0);
+                sleep(1);
+                break;
+        }
+
+        if (*addr != 'N')
+                exit(1);
+        exit(0);
+}
+], 
+                [ac_cv_func_smmap=yes],
+                [ac_cv_func_smmap=no],
+                [ac_cv_func_smmap=no])])
+if test $ac_cv_func_smmap = yes; then
+  AC_DEFINE(HAVE_SMMAP)
+fi])
 
-# vorbis.m4
 # Configure paths for libvorbis
 # Jack Moffitt <jack at icecast.org> 10-21-2000
 # Shamelessly stolen from Owen Taylor and Manish Singh
@@ -107,23 +175,32 @@
 [dnl 
 dnl Get the cflags and libraries
 dnl
-AC_ARG_WITH(vorbis-prefix,[  --with-vorbis-prefix=PFX   Prefix where libvorbis is installed (optional)], vorbis_prefix="$withval", vorbis_prefix="")
+AC_ARG_WITH(vorbis,[  --with-vorbis=PFX   Prefix where libvorbis is installed (optional)], vorbis_prefix="$withval", vorbis_prefix="")
+AC_ARG_WITH(vorbis-libraries,[  --with-vorbis-libraries=DIR   Directory where libvorbis library is installed (optional)], vorbis_libraries="$withval", vorbis_libraries="")
+AC_ARG_WITH(vorbis-includes,[  --with-vorbis-includes=DIR   Directory where libvorbis header files are installed (optional)], vorbis_includes="$withval", vorbis_includes="")
 AC_ARG_ENABLE(vorbistest, [  --disable-vorbistest       Do not try to compile and run a test Vorbis program],, enable_vorbistest=yes)
 
-  if test "x$vorbis_prefix" != "xNONE" ; then
-    vorbis_args="$vorbis_args --prefix=$vorbis_prefix"
-    VORBIS_CFLAGS="-I$vorbis_prefix/include"
-    VORBIS_LIBDIR="-L$vorbis_prefix/lib"
-  elif test "$prefix" != ""; then
-    vorbis_args="$vorbis_args --prefix=$prefix"
-    VORBIS_CFLAGS="-I$prefix/include"
-    VORBIS_LIBDIR="-L$prefix/lib"
+  if test "x$vorbis_libraries" != "x" ; then
+    VORBIS_LIBS="-L$vorbis_libraries"
+  elif test "x$vorbis_prefix" != "x" ; then
+    VORBIS_LIBS="-L$vorbis_prefix/lib"
+  elif test "x$prefix" != "xNONE"; then
+    VORBIS_LIBS="-L$prefix/lib"
   fi
 
-  VORBIS_LIBS="$VORBIS_LIBDIR -lvorbis -lm"
+  VORBIS_LIBS="$VORBIS_LIBS -lvorbis -lm"
   VORBISFILE_LIBS="-lvorbisfile"
   VORBISENC_LIBS="-lvorbisenc"
 
+  if test "x$vorbis_includes" != "x" ; then
+    VORBIS_CFLAGS="-I$vorbis_includes"
+  elif test "x$vorbis_prefix" != "x" ; then
+    VORBIS_CFLAGS="-I$vorbis_prefix/include"
+  elif test "x$prefix" != "xNONE"; then
+    VORBIS_CFLAGS="-I$prefix/include"
+  fi
+
+
   AC_MSG_CHECKING(for Vorbis)
   no_vorbis=""
 
@@ -131,7 +208,7 @@
   if test "x$enable_vorbistest" = "xyes" ; then
     ac_save_CFLAGS="$CFLAGS"
     ac_save_LIBS="$LIBS"
-    CFLAGS="$CFLAGS $VORBIS_CFLAGS"
+    CFLAGS="$CFLAGS $VORBIS_CFLAGS $OGG_CFLAGS"
     LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS"
 dnl
 dnl Now check if the installed Vorbis is sufficiently new.
@@ -209,19 +286,28 @@
 [dnl 
 dnl Get the cflags and libraries
 dnl
-AC_ARG_WITH(ao-prefix,[  --with-ao-prefix=PFX   Prefix where libao is installed (optional)], ao_prefix="$withval", ao_prefix="")
+AC_ARG_WITH(ao,[  --with-ao=PFX   Prefix where libao is installed (optional)], ao_prefix="$withval", ao_prefix="")
+AC_ARG_WITH(ao-libraries,[  --with-ao-libraries=DIR   Directory where libao library is installed (optional)], ao_libraries="$withval", ao_libraries="")
+AC_ARG_WITH(ao-includes,[  --with-ao-includes=DIR   Directory where libao header files are installed (optional)], ao_includes="$withval", ao_includes="")
 AC_ARG_ENABLE(aotest, [  --disable-aotest       Do not try to compile and run a test ao program],, enable_aotest=yes)
 
-  if test "x$ao_prefix" != "xNONE" ; then
-    ao_args="$ao_args --prefix=$ao_prefix"
-    AO_CFLAGS="-I$ao_prefix/include"
+
+  if test "x$ao_libraries" != "x" ; then
+    AO_LIBS="-L$ao_libraries"
+  elif test "x$ao_prefix" != "x"; then
     AO_LIBS="-L$ao_prefix/lib"
-  elif test "$prefix" != ""; then
-    ao_args="$ao_args --prefix=$prefix"
-    AO_CFLAGS="-I$prefix/include"
+  elif test "x$prefix" != "xNONE"; then
     AO_LIBS="-L$prefix/lib"
   fi
 
+  if test "x$ao_includes" != "x" ; then
+    AO_CFLAGS="-I$ao_includes"
+  elif test "x$ao_prefix" != "x"; then
+    AO_CFLAGS="-I$ao_prefix/include"
+  elif test "x$prefix" != "xNONE"; then
+    AO_CFLAGS="-I$prefix/include"
+  fi
+
   # see where dl* and friends live
   AC_CHECK_FUNCS(dlopen, [AO_DL_LIBS=""], [
     AC_CHECK_LIB(dl, dlopen, [AO_DL_LIBS="-ldl"], [
@@ -300,65 +386,89 @@
   AC_SUBST(AO_LIBS)
   rm -f conf.aotest
 ])
-
-dnl Shamelessly stolen from Joerg Schilling's star.
-dnl Copyright 1998 J. Schilling
-
-dnl Checks if mmap() works to get shared memory
-dnl Defines HAVE_SMMAP on success.
-AC_DEFUN(AC_FUNC_SMMAP,
-[AC_CACHE_CHECK([if mmap works to get shared memory], ac_cv_func_smmap,
-                [AC_TRY_RUN([
-#include <sys/types.h>
-#include <sys/mman.h>
-
-char *
-mkshare()
-{
-        int     size = 8192;
-        int     f;
-        char    *addr;
 
-        if ((f = open("/dev/zero", 2)) < 0)
-                exit(1);
-        addr = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, f, 0);
-        if (addr == (char *)-1)
-                exit(1);
-        close(f);
-
-        return (addr);
-}
-
-main()
-{
-        char    *addr;
-        
-        addr = mkshare(8192);
-        *addr = 'I';
-
-        switch (fork()) {
-
-        case -1:
-                printf("help\n"); exit(1);
-
-        case 0: /* child */
-                *addr = 'N';
-                _exit(0);
-                break;
-        default: /* parent */
-                wait(0);
-                sleep(1);
-                break;
-        }
+dnl This macros shamelessly stolen from
+dnl http://gcc.gnu.org/ml/gcc-bugs/2001-06/msg01398.html.
+dnl Written by Bruno Haible.
+
+AC_DEFUN([AM_ICONV],
+[
+  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
+  dnl those with the standalone portable GNU libiconv installed).
+
+  AC_ARG_WITH([libiconv-prefix],
+[  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib], [
+    for dir in `echo "$withval" | tr : ' '`; do
+      if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
+      if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
+    done
+   ])
+
+  AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
+    am_cv_func_iconv="no, consider installing GNU libiconv"
+    am_cv_lib_iconv=no
+    AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+      [iconv_t cd = iconv_open("","");
+       iconv(cd,NULL,NULL,NULL,NULL);
+       iconv_close(cd);],
+      am_cv_func_iconv=yes)
+    if test "$am_cv_func_iconv" != yes; then
+      am_save_LIBS="$LIBS"
+      LIBS="$LIBS -liconv"
+      AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+        [iconv_t cd = iconv_open("","");
+         iconv(cd,NULL,NULL,NULL,NULL);
+         iconv_close(cd);],
+        am_cv_lib_iconv=yes
+        am_cv_func_iconv=yes)
+      LIBS="$am_save_LIBS"
+    fi
+  ])
+  if test "$am_cv_func_iconv" = yes; then
+    AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
+    AC_MSG_CHECKING([for iconv declaration])
+    AC_CACHE_VAL(am_cv_proto_iconv, [
+      AC_TRY_COMPILE([
+#include <stdlib.h>
+#include <iconv.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+#else
+size_t iconv();
+#endif
+], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
+      am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
+    am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
+    AC_MSG_RESULT([$]{ac_t:-
+         }[$]am_cv_proto_iconv)
+    AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
+      [Define as const if the declaration of iconv() needs const.])
+  fi
+  LIBICONV=
+  if test "$am_cv_lib_iconv" = yes; then
+    LIBICONV="-liconv"
+  fi
+  AC_SUBST(LIBICONV)
+])
 
-        if (*addr != 'N')
-                exit(1);
-        exit(0);
-}
-], 
-                [ac_cv_func_smmap=yes],
-                [ac_cv_func_smmap=no],
-                [ac_cv_func_smmap=no])])
-if test $ac_cv_func_smmap = yes; then
-  AC_DEFINE(HAVE_SMMAP)
-fi])
+dnl From Bruno Haible.
+dnl
+AC_DEFUN([AM_LANGINFO_CODESET],
+[
+  AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
+    [AC_TRY_LINK([#include <langinfo.h>],
+      [char* cs = nl_langinfo(CODESET);],
+      am_cv_langinfo_codeset=yes,
+      am_cv_langinfo_codeset=no)
+    ])
+  if test $am_cv_langinfo_codeset = yes; then
+    AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
+      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
+  fi
+])

1.2.6.1   +2 -2      vorbis-tools/autogen.sh

Index: autogen.sh
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/autogen.sh,v
retrieving revision 1.2
retrieving revision 1.2.6.1
diff -u -r1.2 -r1.2.6.1
--- autogen.sh	2000/10/31 19:09:23	1.2
+++ autogen.sh	2001/12/15 15:26:22	1.2.6.1
@@ -53,8 +53,8 @@
 #autoheader
 echo "  libtoolize --automake"
 libtoolize --automake
-echo "  automake --add-missing"
-automake --add-missing 
+echo "  automake --add-missing $AUTOMAKE_FLAGS"
+automake --add-missing $AUTOMAKE_FLAGS 
 echo "  autoconf"
 autoconf
 

1.21.2.1.2.3 +14 -5     vorbis-tools/configure.in

Index: configure.in
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/configure.in,v
retrieving revision 1.21.2.1.2.2
retrieving revision 1.21.2.1.2.3
diff -u -r1.21.2.1.2.2 -r1.21.2.1.2.3
--- configure.in	2001/11/23 15:36:46	1.21.2.1.2.2
+++ configure.in	2001/12/15 15:26:22	1.21.2.1.2.3
@@ -5,7 +5,7 @@
 dnl ------------------------------------------------
 
 AC_INIT(oggenc/encode.c)
-AM_INIT_AUTOMAKE(vorbis-tools,1.0rc1)
+AM_INIT_AUTOMAKE(vorbis-tools,1.0rc2)
 
 dnl --------------------------------------------------  
 dnl Check for programs
@@ -103,24 +103,31 @@
 SOCKET_LIBS=
 AC_CHECK_HEADER(curl/curl.h, , AC_MSG_ERROR(libcurl headers needed!))
 AC_CHECK_HEADER(curl/easy.h, , AC_MSG_ERROR(libcurl headers needed!))
-AC_CHECK_LIB(curl, curl_easy_perform, , AC_MSG_ERROR(libcurl needed!))
+AC_CHECK_LIB(curl, curl_easy_perform, CURL_LIBS="-lcurl", AC_MSG_ERROR(libcurl needed!))
 AC_CHECK_HEADER(pthread.h, , AC_MSG_ERROR(pthread header needed!))
 AC_CHECK_LIB(pthread, pthread_mutex_init, THREAD_LIBS="-lpthread", AC_MSG_ERROR(pthread library needed!))
 AC_CHECK_LIB(socket, socket, SOCKET_LIBS="-lsocket")
 AC_CHECK_LIB(nsl, gethostbyname, SOCKET_LIBS="-lnsl $SOCKET_LIBS")
+SHARE_LIBS='$(top_srcdir)/share/libutf8.a $(top_srcdir)/share/libgetopt.a'
 
 dnl --------------------------------------------------
 dnl Check for library functions
 dnl --------------------------------------------------
 
-AC_FUNC_SMMAP
+AM_ICONV
 AC_CHECK_FUNCS(atexit on_exit)
+AM_LANGINFO_CODESET
 
 dnl --------------------------------------------------
 dnl Work around FHS stupidity
 dnl --------------------------------------------------
 
-AM_CONDITIONAL(PREFIX_IS_USR, test x$prefix = x"/usr")
+if test "$prefix" = "/usr"; then
+    MANDIR='$(datadir)/man'
+else
+    MANDIR='$(prefix)/man'
+fi
+AC_SUBST(MANDIR)
 
 dnl --------------------------------------------------
 dnl Do substitutions
@@ -130,5 +137,7 @@
 AC_SUBST(PROFILE)
 AC_SUBST(THREAD_LIBS)
 AC_SUBST(SOCKET_LIBS)
+AC_SUBST(SHARE_LIBS)
+AC_SUBST(CURL_LIBS)
 
-AC_OUTPUT(Makefile oggenc/Makefile oggenc/man/Makefile ogg123/Makefile vorbiscomment/Makefile ogginfo/Makefile debian/Makefile)
+AC_OUTPUT(Makefile include/Makefile share/Makefile oggenc/Makefile oggenc/man/Makefile ogg123/Makefile vorbiscomment/Makefile vcut/Makefile ogginfo/Makefile debian/Makefile)

1.19.4.1  +18 -13    vorbis-tools/vorbis-tools.spec

Index: vorbis-tools.spec
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/vorbis-tools.spec,v
retrieving revision 1.19
retrieving revision 1.19.4.1
diff -u -r1.19 -r1.19.4.1
--- vorbis-tools.spec	2001/06/18 03:48:13	1.19
+++ vorbis-tools.spec	2001/12/15 15:26:22	1.19.4.1
@@ -1,5 +1,5 @@
 %define name	vorbis-tools
-%define version	1.0rc1
+%define version	1.0rc2
 %define release 1
 
 Summary:	Several Ogg Vorbis Tools
@@ -12,9 +12,10 @@
 Vendor:		Xiphophorus <team at xiph.org>
 Source:		ftp://ftp.xiph.org/pub/vorbis-tools/%{name}-%{version}.tar.gz
 BuildRoot:	%{_tmppath}/%{name}-root
-Requires:       libogg >= 1.0beta4
-Requires:       libvorbis >= 1.0beta4
-Requires:       libao >= 0.6.0
+Requires:       libogg >= 1.0rc2
+Requires:       libvorbis >= 1.0rc2
+Requires:       libao >= 0.8.0
+Prefix:		%{_prefix}
 
 %description
 vorbis-tools contains oggenc (and encoder) and ogg123 (a playback tool)
@@ -24,9 +25,9 @@
 
 %build
 if [ ! -f configure ]; then
-  CFLAGS="$RPM_OPT_FLAGS" ./autogen.sh --prefix=/usr
+  CFLAGS="$RPM_OPT_FLAGS" ./autogen.sh --prefix=%{_prefix}
 else
-  CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr
+  CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{_prefix}
 fi
 make
 
@@ -39,13 +40,13 @@
 %doc COPYING
 %doc README
 %doc ogg123/ogg123rc-example
-/usr/bin/oggenc
-/usr/bin/ogg123
-/usr/bin/ogginfo
-/usr/bin/vorbiscomment
-/usr/share/man/man1/ogg123.1*
-/usr/share/man/man1/oggenc.1*
-/usr/share/man/man1/ogginfo.1*
+%{_bindir}/oggenc
+%{_bindir}/ogg123
+%{_bindir}/ogginfo
+%{_bindir}/vorbiscomment
+%{_datadir}/man/man1/ogg123.1*
+%{_datadir}/man/man1/oggenc.1*
+%{_datadir}/man/man1/ogginfo.1*
 
 %clean 
 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
@@ -55,6 +56,10 @@
 %postun
 
 %changelog
+* Sun Oct 07 2001 Jack Moffitt <jack at xiph.org>
+- Updated for configurable prefix
+* Sun Aug 12 2001 Greg Maxwell <greg at linuxpower.cx>
+- updated for rc2
 * Sun Jun 17 2001 Jack Moffitt <jack at icecast.org>
 - updated for rc1
 - added ogginfo

No                   revision

No                   revision

1.2.2.1   +0 -0      vorbis-tools/HACKING

Index: HACKING
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/HACKING,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -r1.2 -r1.2.2.1

No                   revision

No                   revision

1.2.4.1   +2 -3      vorbis-tools/debian/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/debian/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -r1.2 -r1.2.4.1
--- Makefile.am	2001/02/26 15:30:19	1.2
+++ Makefile.am	2001/12/15 15:26:23	1.2.4.1
@@ -3,6 +3,5 @@
 AUTOMAKE_OPTIONS = foreign
 
 EXTRA_DIST = README.Debian changelog control copyright rules vorbis-tools.dirs\
-	vorbis-tools.docs vorbis-tools.examples vorbis-tools.files\
-	vorbis-tools.mime vorbis-tools.postinst vorbis-tools.postrm\
-	vorbis-tools.preinst vorbis-tools.prerm vorbis-tools.undocumented
+	vorbis-tools.docs vorbis-tools.files vorbis-tools.manpages  \
+	vorbis-tools.mime vorbis-tools.undocumented

1.9.4.1   +7 -0      vorbis-tools/debian/changelog

Index: changelog
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/debian/changelog,v
retrieving revision 1.9
retrieving revision 1.9.4.1
diff -u -r1.9 -r1.9.4.1
--- changelog	2001/06/18 02:29:15	1.9
+++ changelog	2001/12/15 15:26:23	1.9.4.1
@@ -1,3 +1,10 @@
+vorbis-tools (1.0rc2-1) unstable; urgency=low
+
+  * New upstream. (Closes: #98059, #99050)
+  * Build with empty diff.gz to fix bug. (Closes: #104473)
+
+ -- Christopher L Cheney <ccheney at debian.org>  Mon, 13 Aug 2001 00:00:00 -0500
+
 vorbis-tools (1.0rc1-1) unstable; urgency=low
 
   * New upstream. (Closes: #87697, #87907, #98937)

1.12.4.1  +2 -2      vorbis-tools/debian/control

Index: control
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/debian/control,v
retrieving revision 1.12
retrieving revision 1.12.4.1
diff -u -r1.12 -r1.12.4.1
--- control	2001/06/18 02:29:15	1.12
+++ control	2001/12/15 15:26:24	1.12.4.1
@@ -2,8 +2,8 @@
 Section: sound
 Priority: optional
 Maintainer: Christopher L Cheney <ccheney at debian.org>
-Build-Depends: debhelper (>> 3.0.0), libao-dev (>> 0.7.0), libogg-dev (>> 1.0rc1), libvorbis-dev (>> 1.0rc1)
-Standards-Version: 3.5.5.0
+Build-Depends: debhelper (>> 3.0.0), libao-dev (>> 0.8.0), libogg-dev (>> 1.0rc2), libvorbis-dev (>> 1.0rc2)
+Standards-Version: 3.5.6.0
 
 Package: vorbis-tools
 Architecture: any

1.5.4.1   +5 -5      vorbis-tools/debian/rules

Index: rules
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/debian/rules,v
retrieving revision 1.5
retrieving revision 1.5.4.1
diff -u -r1.5 -r1.5.4.1
--- rules	2001/06/18 02:07:46	1.5
+++ rules	2001/12/15 15:26:24	1.5.4.1
@@ -47,8 +47,6 @@
         # Add here commands to install the package into debian/tmp.
         $(MAKE) install DESTDIR=`pwd`/debian/tmp
 
-	dh_movefiles
-
 # Build architecture-independent files here.
 binary-indep: build install
 # We have nothing to do by default.
@@ -57,10 +55,12 @@
 binary-arch: build install
         dh_testdir
         dh_testroot
-	dh_installmime
+	dh_movefiles
+
         dh_installdocs
-	dh_installexamples
-	dh_installmanpages
+#	dh_installexamples
+	dh_installmime
+	dh_installman
         dh_undocumented
         dh_installchangelogs 
         dh_link

1.4.4.1   +1 -0      vorbis-tools/debian/vorbis-tools.undocumented

Index: vorbis-tools.undocumented
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/debian/vorbis-tools.undocumented,v
retrieving revision 1.4
retrieving revision 1.4.4.1
diff -u -r1.4 -r1.4.4.1
--- vorbis-tools.undocumented	2001/02/26 15:30:19	1.4
+++ vorbis-tools.undocumented	2001/12/15 15:26:24	1.4.4.1
@@ -1 +1,2 @@
+vcut.1
 vorbiscomment.1

No                   revision

No                   revision

1.1.2.1   +0 -0      vorbis-tools/debian/vorbis-tools.manpages

Index: vorbis-tools.manpages
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/debian/vorbis-tools.manpages,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1

No                   revision

No                   revision

1.1.2.1   +0 -0      vorbis-tools/include/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/include/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1

1.1.2.1   +0 -0      vorbis-tools/include/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/include/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1

1.1.2.1   +0 -0      vorbis-tools/include/getopt.h

Index: getopt.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/include/getopt.h,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1

1.2.2.1   +0 -0      vorbis-tools/include/utf8.h

Index: utf8.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/include/utf8.h,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -r1.2 -r1.2.2.1

No                   revision

No                   revision

1.14.2.4.2.5 +4 -5      vorbis-tools/ogg123/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/Makefile.am,v
retrieving revision 1.14.2.4.2.4
retrieving revision 1.14.2.4.2.5
diff -u -r1.14.2.4.2.4 -r1.14.2.4.2.5
--- Makefile.am	2001/12/14 05:45:14	1.14.2.4.2.4
+++ Makefile.am	2001/12/15 15:26:26	1.14.2.4.2.5
@@ -11,16 +11,15 @@
 INCLUDES = @OGG_CFLAGS@ @VORBIS_CFLAGS@ @AO_CFLAGS@
 
 ogg123_LDADD = @VORBISFILE_LIBS@ @VORBIS_LIBS@ @OGG_LIBS@ @AO_LIBS@ \
-		@SOCKET_LIBS@ @THREAD_LIBS@ -lcurl
-
+		@SOCKET_LIBS@ @SHARE_LIBS@ @CURL_LIBS@
+ogg123_DEPENDENCIES = @SHARE_LIBS@
 ogg123_SOURCES = audio.c buffer.c callbacks.c \
                  cfgfile_options.c cmdline_options.c \
-                 file_transport.c format.c http_transport.c getopt.c \
-                 getopt1.c         \
+                 file_transport.c format.c http_transport.c \
                  ogg123.c oggvorbis_format.c status.c transport.c     \
                  audio.h buffer.h callbacks.h \
                  cfgfile_options.h cmdline_options.h \
-                 format.h getopt.h ogg123.h status.h transport.h
+                 format.h ogg123.h status.h transport.h
 
 EXTRA_DIST = $(man_MANS) $(doc_DATA)
 

1.6.2.2.2.1 +7 -11     vorbis-tools/ogg123/ogg123.1

Index: ogg123.1
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogg123/ogg123.1,v
retrieving revision 1.6.2.2
retrieving revision 1.6.2.2.2.1
diff -u -r1.6.2.2 -r1.6.2.2.2.1
--- ogg123.1	2001/08/12 18:34:46	1.6.2.2
+++ ogg123.1	2001/12/15 15:26:26	1.6.2.2.2.1
@@ -53,7 +53,7 @@
 Specify output file for file devices.  The filename "-" writes to standard
 out.  If the file already exists,
 .B ogg123
-will abort.
+will overwrite it.
 .IP "-h, --help"
 Show command help.
 .IP "-k n, --skip n"
@@ -200,9 +200,9 @@
 .RE
 .PP
 
-Use the WAV driver with the default output file, "output.wav":
+Use the WAV driver with the output file, "test.wav":
 .RS
-.B ogg123 -d wav test.ogg
+.B ogg123 -d wav -f test.wav test.ogg
 .RE
 .PP
 
@@ -246,16 +246,12 @@
 
 .SH NOTES
 
-Configuration for many parameters can be specified in 
+The use of
 .B /etc/ogg123rc
 and
-.B ~/.ogg123rc.
-To see the available configuration options, use:
-.RS
-.B ogg123 -c
-.RS
-This needs more documentation.
-
+.B ~/.ogg123rc
+has been removed in favor of the configuration system provided by
+libao.  The ability to override libao will be added in a future version.
 
 .SH FILES
 

No                   revision

No                   revision

1.8.6.1   +7 -5      vorbis-tools/oggenc/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/Makefile.am,v
retrieving revision 1.8
retrieving revision 1.8.6.1
diff -u -r1.8 -r1.8.6.1
--- Makefile.am	2001/01/25 06:54:52	1.8
+++ Makefile.am	2001/12/15 15:26:27	1.8.6.1
@@ -6,12 +6,14 @@
 
 bin_PROGRAMS = oggenc
 
-INCLUDES = @OGG_CFLAGS@ @VORBIS_CFLAGS@
+INCLUDES = @OGG_CFLAGS@ @VORBIS_CFLAGS@ -I$(top_srcdir)/include
 
-oggenc_LDADD = @VORBISENC_LIBS@ @VORBIS_LIBS@ @OGG_LIBS@
-oggenc_SOURCES = oggenc.c audio.c encode.c getopt.c getopt1.c\
-		platform.c\
-		audio.h encode.h platform.h getopt.h
+oggenc_LDADD = @VORBISENC_LIBS@ @VORBIS_LIBS@ @OGG_LIBS@ @LIBICONV@ \
+               @SHARE_LIBS@
+oggenc_DEPENDENCIES = @SHARE_LIBS@
+
+oggenc_SOURCES = oggenc.c audio.c encode.c platform.c \
+                 audio.h encode.h platform.h
 
 EXTRA_DIST = oggenc.dsp build_oggenc.bat
 

1.12.4.2  +26 -18    vorbis-tools/oggenc/audio.c

Index: audio.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/audio.c,v
retrieving revision 1.12.4.1
retrieving revision 1.12.4.2
diff -u -r1.12.4.1 -r1.12.4.2
--- audio.c	2001/12/08 02:19:14	1.12.4.1
+++ audio.c	2001/12/15 15:26:27	1.12.4.2
@@ -285,9 +285,10 @@
         {
                 /* From here on, this is very similar to the wav code. Oh well. */
                 
-		if(format.rate != 44100)
-			fprintf(stderr,"Warning: Vorbis is currently untuned for input\n"
-					       "at other than 44.1kHz, quality may be degraded.\n");
+		if(format.rate != 44100 && format.rate != 48000)
+			fprintf(stderr, "Warning: Vorbis is not currently tuned for this input (%.3f kHz).\n"
+				" At other than 44.1/48 kHz quality will be degraded.\n",
+				(float)format.rate * 1.0e-3);
 
                 opt->rate = format.rate;
                 opt->channels = format.channels;
@@ -335,7 +336,7 @@
 
 int wav_open(FILE *in, oe_enc_opt *opt, unsigned char *oldbuf, int buflen)
 {
-	unsigned char buf[18];
+	unsigned char buf[16];
         unsigned int len;
         int samplesize;
         wav_fmt format;
@@ -350,7 +351,7 @@
         if(!find_wav_chunk(in, "fmt ", &len))
                 return 0; /* EOF */
 
-	if(len>18 || len < 16) 
+	if(len < 16) 
         {
                 fprintf(stderr, "Warning: Unrecognised format chunk in WAV header\n");
                 return 0; /* Weird format chunk */
@@ -367,12 +368,17 @@
                                 "Warning: INVALID format chunk in wav header.\n"
                                 " Trying to read anyway (may not work)...\n");
 
-	if(fread(buf,1,len,in) < len)
+	if(fread(buf,1,16,in) < 16)
         {
                 fprintf(stderr, "Warning: Unexpected EOF in reading WAV header\n");
                 return 0;
         }
 
+	/* Deal with stupid broken apps. Don't use these programs.
+	 */
+	if(len - 16 > 0 && !seek_forward(in, len-16))
+	    return 0;
+
         format.format =      READ_U16_LE(buf); 
         format.channels =    READ_U16_LE(buf+2); 
         format.samplerate =  READ_U32_LE(buf+4);
@@ -406,10 +412,11 @@
         if( format.align == format.channels*samplesize &&
                         format.samplesize == samplesize*8)
         {
-		if(format.samplerate != 44100)
-			fprintf(stderr, "Warning: Vorbis is currently not tuned for input\n"
-							" at other than 44.1kHz. Quality may be somewhat\n"
-							" degraded.\n");
+		if(format.samplerate != 44100 && format.samplerate != 48000)
+			fprintf(stderr, "Warning: Vorbis is not currently tuned for this input (%.3f kHz).\n"
+					" At other than 44.1/48 kHz quality will be degraded.\n",
+					(float)format.samplerate * 1.0e-3);
+
                 /* OK, good - we have the one supported format,
                    now we want to find the size of the file */
                 opt->rate = format.samplerate;
@@ -423,9 +430,8 @@
                 wav->samplesize = format.samplesize;
 
                 if(len)
-		{
+        {
                         opt->total_samples_per_channel = len/(format.channels*samplesize);
-			wav->totalsamples = len/(format.channels*samplesize);
                 }
                 else
                 {
@@ -434,15 +440,16 @@
                         if(fseek(in, 0, SEEK_END) == -1)
                         {
                                 opt->total_samples_per_channel = 0; /* Give up */
-				wav->totalsamples = 0;
                         }
                         else
                         {
-				opt->total_samples_per_channel = (ftell(in) - pos)/(format.channels*2);
-				wav->totalsamples = len/(format.channels*2);
+				opt->total_samples_per_channel = (ftell(in) - pos)/
+                    (format.channels*samplesize);
                                 fseek(in,pos, SEEK_SET);
                         }
                 }
+		wav->totalsamples = opt->total_samples_per_channel;
+
                 opt->readdata = (void *)wav;
                 return 1;
         }
@@ -546,9 +553,10 @@
         wav_fmt format; /* fake wave header ;) */
         wavfile *wav = malloc(sizeof(wavfile));
 
-	if(opt->rate != 44100)
-		fprintf(stderr,"Warning: Vorbis is currently untuned for input\n"
-				       "at other than 44.1kHz, quality may be degraded.\n");
+	if(opt->rate != 44100 && opt->rate != 48000)
+		fprintf(stderr, "Warning: Vorbis is not currently tuned for this input (%.3f kHz).\n"
+				" At other than 44.1/48 kHz quality will be significantly degraded.\n",
+				(float)opt->rate * 1.0e-3);
 
         /* construct fake wav header ;) */
         format.format =      2; 

1.7.8.1   +49 -8     vorbis-tools/oggenc/encode.c

Index: encode.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/encode.c,v
retrieving revision 1.7
retrieving revision 1.7.8.1
diff -u -r1.7 -r1.7.8.1
--- encode.c	2000/11/05 04:52:21	1.7
+++ encode.c	2001/12/15 15:26:27	1.7.8.1
@@ -45,12 +45,33 @@
 
         /* get start time. */
         timer = timer_start();
+    opt->start_encode(opt->infilename, opt->filename, opt->bitrate, 
+            opt->quality);
 
         /* Have vorbisenc choose a mode for us */
         vorbis_info_init(&vi);
-	vorbis_encode_init(&vi, opt->channels, opt->rate, -1, 
-			opt->bitrate*1000, -1);
 
+	if(opt->quality >= 0.0f)
+	{
+		if(vorbis_encode_init_vbr(&vi, opt->channels, opt->rate, opt->quality))
+		{
+			fprintf(stderr, "Mode initialisation failed: invalid parameters for quality\n");
+			vorbis_info_clear(&vi);
+			return 1;
+		}
+	}
+	else
+	{
+		if(vorbis_encode_init(&vi, opt->channels, opt->rate, 
+                    opt->min_bitrate>0?opt->min_bitrate*1000:-1,
+				    opt->bitrate*1000, 
+                    opt->max_bitrate>0?opt->max_bitrate*1000:-1))
+		{
+			fprintf(stderr, "Mode initialisation failed: invalid parameters for bitrate\n");
+			vorbis_info_clear(&vi);
+			return 1;
+		}
+	}
 
         /* Now, set up the analysis engine, stream encoder, and other
            preparation before the encoding begins.
@@ -83,7 +104,7 @@
                 {
                         if(!result) break;
                         ret = oe_write_page(&og, opt->out);
-			if(!ret)
+			if(ret != og.header_len + og.body_len)
                         {
                                 opt->error("Failed writing header to output stream\n");
                                 ret = 1;
@@ -148,7 +169,7 @@
                                 if(!result) break;
 
                                 ret = oe_write_page(&og, opt->out);
-				if(!ret)
+				if(ret != og.header_len + og.body_len)
                                 {
                                         opt->error("Failed writing data to output stream\n");
                                         ret = 1;
@@ -163,6 +184,9 @@
                 }
         }
 
+	ret = 0; /* Success, set return value to 0 since other things reuse it
+			  * for nefarious purposes. */
+
         /* Cleanup time */
 cleanup:
 
@@ -191,8 +215,7 @@
         minutes = ((int)remain_time)/60;
         seconds = (int)(remain_time - (double)((int)remain_time/60)*60);
 
-	fprintf(stderr, "\rEncoding %s%s%s [%5.1f%%] [%2dm%.2ds remaining] %c", 
-			fn?"\"":"", fn?fn:"standard input", fn?"\"":"",
+	fprintf(stderr, "\r\t[%5.1f%%] [%2dm%.2ds remaining] %c", 
                         done*100.0/total, minutes, seconds, spinner[spinpoint++%4]);
 }
 
@@ -201,8 +224,8 @@
         static char *spinner="|/-\\";
         static int spinpoint =0;
         
-	fprintf(stderr, "\rEncoding %s%s%s %c", 
-			fn?"\"":"", fn?fn:"standard input", fn?"\"":"",
+	fprintf(stderr, "\r\tEncoding [%2dm%.2ds so far] %c", 
+            ((int)time)/60, (int)(time - (double)((int)time/60)*60),
                         spinner[spinpoint++%4]);
 }
 
@@ -253,5 +276,23 @@
         fprintf(stderr, "\n%s\n", errmsg);
 }
 
+void start_encode_full(char *fn, char *outfn, int bitrate, float quality)
+{
+    if(quality >= 0.0f)
+        fprintf(stderr, "Encoding %s%s%s to \n         %s%s%s at quality %f\n",
+			    fn?"\"":"", fn?fn:"standard input", fn?"\"":"",
+                outfn?"\"":"", outfn?outfn:"standard output", outfn?"\"":"",
+                quality);
+    else
+        fprintf(stderr, "Encoding %s%s%s to \n         "
+                "%s%s%s at bitrate %d kbps\n",
+			    fn?"\"":"", fn?fn:"standard input", fn?"\"":"",
+                outfn?"\"":"", outfn?outfn:"standard output", outfn?"\"":"",
+                bitrate);
+}
+
+void start_encode_null(char *fn, char *outfn, int bitrate, float quality)
+{
+}
 
 

1.7.4.1   +21 -1     vorbis-tools/oggenc/encode.h

Index: encode.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/encode.h,v
retrieving revision 1.7
retrieving revision 1.7.4.1
diff -u -r1.7 -r1.7.4.1
--- encode.h	2001/05/27 09:49:35	1.7
+++ encode.h	2001/12/15 15:26:27	1.7.4.1
@@ -11,6 +11,8 @@
                 long samples, double time);
 typedef void (*enc_end_func)(char *fn, double time, int rate, 
                 long samples, long bytes);
+typedef void (*enc_start_func)(char *fn, char *outfn, int bitrate, 
+        float quality);
 typedef void (*error_func)(char *errormessage);
 
 
@@ -21,6 +23,8 @@
 void update_statistics_full(char *fn, long total, long done, double time);
 void update_statistics_notime(char *fn, long total, long done, double time);
 void update_statistics_null(char *fn, long total, long done, double time);
+void start_encode_full(char *fn, char *outfn, int bitrate, float quality);
+void start_encode_null(char *fn, char *outfn, int bitrate, float quality);
 void final_statistics(char *fn, double time, int rate, long total_samples,
                 long bytes);
 void final_statistics_null(char *fn, double time, int rate, long total_samples,
@@ -29,6 +33,8 @@
 
 typedef struct
 {
+	char *encoding;
+
         char **title;
         int title_count;
         char **artist;
@@ -41,6 +47,8 @@
         int track_count;
         char **dates;
         int date_count;
+	char **genre;
+	int genre_count;
 
         int quiet;
 
@@ -50,8 +58,15 @@
         int raw_channels;
 
         char *namefmt;
+    char *namefmt_remove;
+    char *namefmt_replace;
         char *outfile;
-	int kbps;
+	/* All 3 in kbps */
+	int min_bitrate;
+	int nominal_bitrate;
+	int max_bitrate;
+	/* Float from 0 to 1 (low->high) */
+	float quality;
         unsigned int serial;
 } oe_options;
 
@@ -63,6 +78,7 @@
         audio_read_func read_samples;
         progress_func progress_update;
         enc_end_func end_encode;
+	enc_start_func start_encode;
         error_func error;
         
         void *readdata;
@@ -72,9 +88,13 @@
         long rate;
         int samplesize;
         int bitrate;
+	int min_bitrate;
+	int max_bitrate;
+	float quality;
 
         FILE *out;
         char *filename;
+	char *infilename;
 } oe_enc_opt;
 
 

1.15.4.1  +243 -80   vorbis-tools/oggenc/oggenc.c

Index: oggenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/oggenc.c,v
retrieving revision 1.15
retrieving revision 1.15.4.1
diff -u -r1.15 -r1.15.4.1
--- oggenc.c	2001/06/18 00:32:47	1.15
+++ oggenc.c	2001/12/15 15:26:27	1.15.4.1
@@ -15,23 +15,29 @@
 #include <getopt.h>
 #include <string.h>
 #include <time.h>
+#include <locale.h>
 
 #include "platform.h"
 #include "encode.h"
 #include "audio.h"
+#include "utf8.h"
 
-#define VERSION_STRING "OggEnc v0.7 (libvorbis rc1)\n"
-#define COPYRIGHT "(c) 2000 Michael Smith <msmith at labyrinth.net.au)\n"
+#define VERSION_STRING "OggEnc v0.8 (libvorbis rc2)\n"
+#define COPYRIGHT "(c) 2001 Michael Smith <msmith at labyrinth.net.au)\n"
+
 #define CHUNK 4096 /* We do reads, etc. in multiples of this */
 
 struct option long_options[] = {
-	{"quiet",0,0,'q'},
+	{"quiet",0,0,'Q'},
         {"help",0,0,'h'},
         {"comment",1,0,'c'},
         {"artist",1,0,'a'},
         {"album",1,0,'l'},
         {"title",1,0,'t'},
+    {"genre",1,0,'G'},
         {"names",1,0,'n'},
+    {"name-remove",1,0,'X'},
+    {"name-replace",1,0,'P'},
         {"output",1,0,'o'},
         {"version",0,0,'v'},
         {"raw",0,0,'r'},
@@ -39,26 +45,37 @@
         {"raw-chan",1,0,'C'},
         {"raw-rate",1,0,'R'},
         {"bitrate",1,0,'b'},
+	{"min-bitrate",1,0,'m'},
+	{"max-bitrate",1,0,'M'},
+	{"quality",1,0,'q'},
         {"date",1,0,'d'},
         {"tracknum",1,0,'N'},
         {"serial",1,0,'s'},
         {NULL,0,0,0}
 };
         
-char *generate_name_string(char *format, char *artist, char *title, char *album, char *track, char *date);
-void parse_options(int argc, char **argv, oe_options *opt);
-void build_comments(vorbis_comment *vc, oe_options *opt, int filenum, 
-		char **artist, char **album, char **title, char **tracknum, char **date);
-void usage(void);
+static char *generate_name_string(char *format, char *remove_list, 
+        char *replace_list, char *artist, char *title, char *album, 
+        char *track, char *date, char *genre);
+static void parse_options(int argc, char **argv, oe_options *opt);
+static void build_comments(vorbis_comment *vc, oe_options *opt, int filenum, 
+		char **artist,char **album, char **title, char **tracknum, char **date,
+        char **genre);
+static void usage(void);
 
 int main(int argc, char **argv)
 {
-	oe_options opt = {NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, 
-		0, 0,16,44100,2, NULL,NULL,128,0}; /* Default values */
+	/* Default values */
+	oe_options opt = {"ISO-8859-1", NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 
+		0, NULL, 0, NULL, 0, 0, 0,16,44100,2, NULL,DEFAULT_NAMEFMT_REMOVE, 
+        DEFAULT_NAMEFMT_REPLACE, NULL, -1,128,-1, -1.0f,0};
         int i;
 
         char **infiles;
         int numfiles;
+	int errors=0;
+
+	setlocale(LC_ALL, "");
 
         parse_options(argc, argv, &opt);
 
@@ -107,25 +124,27 @@
                 FILE *in, *out = NULL;
                 int foundformat = 0;
                 int closeout = 0, closein = 0;
-		char *artist=NULL, *album=NULL, *title=NULL, *track=NULL, *date=NULL;
+		char *artist=NULL, *album=NULL, *title=NULL, *track=NULL;
+        char *date=NULL, *genre=NULL;
                 input_format *format;
 
-
-
                 /* Set various encoding defaults */
 
                 enc_opts.serialno = opt.serial++;
                 enc_opts.progress_update = update_statistics_full;
+        enc_opts.start_encode = start_encode_full;
                 enc_opts.end_encode = final_statistics;
                 enc_opts.error = encode_error;
                 
                 /* OK, let's build the vorbis_comments structure */
-		build_comments(&vc, &opt, i, &artist, &album, &title, &track, &date);
+		build_comments(&vc, &opt, i, &artist, &album, &title, &track, 
+                &date, &genre);
 
                 if(!strcmp(infiles[i], "-"))
                 {
                         setbinmode(stdin);
                         in = stdin;
+            infiles[i] = NULL;
                         if(!opt.outfile)
                         {
                                 setbinmode(stdout);
@@ -140,6 +159,7 @@
                         {
                                 fprintf(stderr, "ERROR: Cannot open input file \"%s\"\n", infiles[i]);
                                 free(out_fn);
+				errors++;
                                 continue;
                         }
 
@@ -163,8 +183,9 @@
                         format = open_audio_file(in, &enc_opts);
                         if(format)
                         {
-				fprintf(stderr, "Opening with %s module: %s\n", 
-						format->format, format->description);
+                if(!opt.quiet)
+				    fprintf(stderr, "Opening with %s module: %s\n", 
+					    	format->format, format->description);
                                 foundformat=1;
                         }
 
@@ -172,7 +193,10 @@
 
                 if(!foundformat)
                 {
-			fprintf(stderr, "ERROR: Input file \"%s\" is not a supported format\n", infiles[i]);
+			fprintf(stderr, "ERROR: Input file \"%s\" is not a supported format\n", infiles[i]?infiles[i]:"(stdin)");
+    		if(closein)
+				fclose(in);
+			errors++;
                         continue;
                 }
 
@@ -191,7 +215,9 @@
                         }
                         else if(opt.namefmt)
                         {
-				out_fn = generate_name_string(opt.namefmt, artist, title, album, track,date);
+				out_fn = generate_name_string(opt.namefmt, opt.namefmt_remove, 
+                        opt.namefmt_replace, artist, title, album, track,date,
+                        genre);
                         }
                         else if(opt.title)
                         {
@@ -199,7 +225,7 @@
                                 strcpy(out_fn, title);
                                 strcat(out_fn, ".ogg");
                         }
-			else
+			else if(infiles[i])
                         {
                                 /* Create a filename from existing filename, replacing extension with .ogg */
                                 char *start, *end;
@@ -213,6 +239,10 @@
                                 out_fn[end-start] = 0;
                                 strcat(out_fn, ".ogg");
                         }
+            else {
+                fprintf(stderr, "WARNING: No filename, defaulting to \"default.ogg\"\n");
+                out_fn = strdup("default.ogg");
+            }
 
 
                         out = fopen(out_fn, "wb");
@@ -221,6 +251,7 @@
                                 if(closein)
                                         fclose(in);
                                 fprintf(stderr, "ERROR: Cannot open output file \"%s\"\n", out_fn);
+				errors++;
                                 free(out_fn);
                                 continue;
                         }	
@@ -231,18 +262,24 @@
                 enc_opts.out = out;
                 enc_opts.comments = &vc;
                 enc_opts.filename = out_fn;
-		enc_opts.bitrate = opt.kbps; /* defaulted at the start, so this is ok */
+		enc_opts.infilename = infiles[i];
+		enc_opts.bitrate = opt.nominal_bitrate; 
+		enc_opts.min_bitrate = opt.min_bitrate;
+		enc_opts.max_bitrate = opt.max_bitrate;
+		enc_opts.quality = opt.quality;
 
                 if(!enc_opts.total_samples_per_channel)
                         enc_opts.progress_update = update_statistics_notime;
 
                 if(opt.quiet)
                 {
+            enc_opts.start_encode = start_encode_null;
                         enc_opts.progress_update = update_statistics_null;
                         enc_opts.end_encode = final_statistics_null;
                 }
 
-		oe_encode(&enc_opts); /* Should we care about return val? */
+		if(oe_encode(&enc_opts))
+			errors++;
 
                 if(out_fn) free(out_fn);
                 vorbis_comment_clear(&vc);
@@ -255,11 +292,11 @@
                         fclose(out);
         }/* Finished this file, loop around to next... */
 
-	return 0;
+	return errors?1:0;
 
 }
 
-void usage(void)
+static void usage(void)
 {
         fprintf(stdout, 
                 VERSION_STRING
@@ -269,15 +306,23 @@
                 "\n"
                 "OPTIONS:\n"
                 " General:\n"
-		" -q, --quiet          Produce no output to stderr\n"
+		" -Q, --quiet          Produce no output to stderr\n"
                 " -h, --help           Print this help text\n"
                 " -r, --raw            Raw mode. Input files are read directly as PCM data\n"
                 " -B, --raw-bits=n     Set bits/sample for raw input. Default is 16\n"
                 " -C, --raw-chan=n     Set number of channels for raw input. Default is 2\n"
                 " -R, --raw-rate=n     Set samples/sec for raw input. Default is 44100\n"
-		" -b, --bitrate        Choose a bitrate to encode at. Internally,\n"
-		"                      a mode approximating this value is chosen.\n"
-		"                      Takes an argument in kbps. Default is 128kbps\n"
+		" -b, --bitrate        Choose a nominal bitrate to encode at. Attempt\n"
+		"                      to encode at a bitrate averaging this. Takes an\n"
+		"                      argument in kbps.\n"
+/* these options are not supported by the rc2 vorbisenc. don't mention them. */
+/*		" -m, --min-bitrate    Specify a minimum bitrate (in kbps). Useful for\n"
+		"                      encoding for a fixed-size channel.\n"
+		" -M, --max-bitrate    Specify a maximum bitrate in kbps. Useful in\n"
+		"                      for streaming applications.\n"
+		" -q, --quality        Specify quality between 0 (low) and 10 (high),\n"
+		"                      instead of specifying a particular bitrate.\n"
+		"                      This is the normal mode of operation.\n"		*/
                 " -s, --serial         Specify a serial number for the stream. If encoding\n"
                 "                      multiple files, this will be incremented for each\n"
                 "                      stream after the first.\n"
@@ -288,6 +333,14 @@
                 "                      %%n, %%d replaces by artist, title, album, track number,\n"
                 "                      and date, respectively (see below for specifying these).\n"
                 "                      %%%% gives a literal %%.\n"
+        " -X, --name-remove=s  Remove the specified characters from parameters to the\n"
+        "                      -n format string. Useful to ensure legal filenames.\n"
+        " -P, --name-replace=s Replace characters remove by --name-remove with the\n"
+        "                      characters specified. If this string shorter than the\n"
+        "                      --name-remove list or is not specified, the extra\n"
+        "                      characters are just removed.\n"
+        "                      Default settings for the above two arguments are platform\n"
+        "                      specific.\n"
                 " -c, --comment=c      Add the given string as an extra comment. This may be\n"
                 "                      used multiple times.\n"
                 " -d, --date           Date for track (usually date of performance)\n"
@@ -295,6 +348,7 @@
                 " -t, --title          Title for this track\n"
                 " -l, --album          Name of album\n"
                 " -a, --artist         Name of artist\n"
+        " -g, --genre          Genre of track\n"
                 "                      If multiple input files are given, then multiple\n"
                 "                      instances of the previous five arguments will be used,\n"
                 "                      in the order they are given. If fewer titles are\n"
@@ -306,39 +360,70 @@
                 "                      once, for example, and have it used for all the files)\n"
                 "\n"
                 "INPUT FILES:\n"
-		" OggEnc input files must currently be 16 bit PCM WAV, AIFF, or AIFF/C files.\n"
-		" Files may be mono or stereo (or more channels) and sampling rates \n"
-		" between 8kHz and 56kHz.\n"
-		" You can specify taking the file from stdin by using - as the input filename.\n"
+		" OggEnc input files must currently be 16 or 8 bit PCM WAV, AIFF, or AIFF/C\n"
+		" files. Files may be mono or stereo (or more channels) and any sample rate.\n"
+		" However, the encoder is only tuned for rates of 44.1 and 48 kHz and while\n"
+		" other rates will be accepted quality will be significantly degraded.\n"
                 " Alternatively, the --raw option may be used to use a raw PCM data file, which\n"
-		" must be 16bit stereo little-endian PCM ('headerless wav').\n"
+		" must be 16bit stereo little-endian PCM ('headerless wav'), unless additional\n"
+		" parameters for raw mode are specified.\n"
+		" You can specify taking the file from stdin by using - as the input filename.\n"
                 " In this mode, output is to stdout unless an outfile filename is specified\n"
                 " with -o\n"
-		"\n"
-		"MODES:\n"
-		" OggEnc currently supports 6 different modes. Each of these is a fully VBR\n"
-		" (variable bitrate) mode, but they vary in intended average bitrate. The \n"
-		" bitrate option (--bitrate, -b) will choose the mode closest to the chosen\n"
-		" bitrate. The 6 modes are approximately 112,128,160,192,256, and 350 kbps\n"
-		" (for stereo 44.1kHz input. Halve these numbers for mono input).\n"
-		" The default is the 128 kbps mode.  Lower sampling rates work properly,\n"
-		" but don't scale the bitrate; -b 112 on a stereo 22kHz file will produce a\n"
-		" ~70kbps file, not 112kbps.)\n");
+		"\n");
 }
 
-char *generate_name_string(char *format, 
-		char *artist, char *title, char *album, char *track, char *date)
+static int strncpy_filtered(char *dst, char *src, int len, char *remove_list, 
+        char *replace_list)
 {
-	char *buffer;
-	char *cur;
-	char next;
+    char *hit, *drop_margin;
+    int used=0;
 
-	buffer = calloc(CHUNK,1);
+    if(remove_list == NULL || *remove_list == 0)
+    {
+        strncpy(dst, src, len-1);
+        dst[len-1] = 0;
+        return strlen(dst);
+    }
+
+    drop_margin = remove_list + (replace_list == NULL?0:strlen(replace_list));
+
+    while(*src && used < len-1)
+    {
+        if((hit = strchr(remove_list, *src)) != NULL)
+        {
+            if(hit < drop_margin)
+            {
+                *dst++ = replace_list[hit - remove_list];
+                used++;
+            }
+        }
+        else
+        {
+            *dst++ = *src;
+            used++;
+        }
+        src++;
+    }
+    *dst = 0;
+
+    return used;
+}
 
-	cur = buffer;
+static char *generate_name_string(char *format, char *remove_list,
+        char *replace_list, char *artist, char *title, char *album, 
+        char *track, char *date, char *genre)
+{
+	char *buffer;
+	char next;
+	char *string;
+	int used=0;
+	int buflen;
 
+	buffer = calloc(CHUNK+1,1);
+	buflen = CHUNK;
 
-	while(*format)
+	while(*format && used < buflen)
         {
                 next = *format++;
 
@@ -347,27 +432,37 @@
                         switch(*format++)
                         {
                                 case '%':
-					*cur++ = '%';
+					*(buffer+(used++)) = '%';
                                         break;
                                 case 'a':
-					strcat(buffer, artist?artist:"(none)");
-					cur += strlen(artist?artist:"(none)");
+					string = artist?artist:"(none)";
+					used += strncpy_filtered(buffer+used, string, buflen-used, 
+                            remove_list, replace_list);
                                         break;
                                 case 'd':
-					strcat(buffer, date?date:"(none)");
-					cur += strlen(date?date:"(none)");
+					string = date?date:"(none)";
+					used += strncpy_filtered(buffer+used, string, buflen-used,
+                            remove_list, replace_list);
                                         break;
+                case 'g':
+                    string = genre?genre:"(none)";
+                    used += strncpy_filtered(buffer+used, string, buflen-used,
+                            remove_list, replace_list);
+                    break;
                                 case 't':
-					strcat(buffer, title?title:"(none)");
-					cur += strlen(title?title:"(none)");
+					string = title?title:"(none)";
+					used += strncpy_filtered(buffer+used, string, buflen-used,
+                            remove_list, replace_list);
                                         break;
                                 case 'l':
-					strcat(buffer, album?album:"(none)");
-					cur += strlen(album?album:"(none)");
+					string = album?album:"(none)";
+					used += strncpy_filtered(buffer+used, string, buflen-used,
+                            remove_list, replace_list);
                                         break;
                                 case 'n':
-					strcat(buffer, track?track:"(none)");
-					cur += strlen(track?track:"(none)");
+					string = track?track:"(none)";
+					used += strncpy_filtered(buffer+used, string, buflen-used,
+                            remove_list, replace_list);
                                         break;
                                 default:
                                         fprintf(stderr, "WARNING: Ignoring illegal escape character '%c' in name format\n", *(format - 1));
@@ -375,18 +470,18 @@
                         }
                 }
                 else
-			*cur++ = next;
+			*(buffer + (used++)) = next;
         }
 
         return buffer;
 }
 
-void parse_options(int argc, char **argv, oe_options *opt)
+static void parse_options(int argc, char **argv, oe_options *opt)
 {
         int ret;
         int option_index = 1;
 
-	while((ret = getopt_long(argc, argv, "a:b:B:c:C:d:hl:n:N:o:qrR:s:t:v", 
+	while((ret = getopt_long(argc, argv, "a:b:B:c:C:d:G:hl:m:M:n:N:o:P:q:QrR:s:t:vX:", 
                                         long_options, &option_index)) != -1)
         {
                 switch(ret)
@@ -407,6 +502,14 @@
                                 opt->dates = realloc(opt->dates, (++opt->date_count)*sizeof(char *));
                                 opt->dates[opt->date_count - 1] = strdup(optarg);
                                 break;
+            case 'G':
+                opt->genre = realloc(opt->genre, (++opt->genre_count)*sizeof(char *));
+                opt->genre[opt->genre_count - 1] = strdup(optarg);
+                break;
+			case 'h':
+				usage();
+				exit(0);
+				break;
                         case 'l':
                                 opt->album = realloc(opt->album, (++opt->album_count)*sizeof(char *));
                                 opt->album[opt->album_count - 1] = strdup(optarg);
@@ -422,7 +525,26 @@
                                 opt->title[opt->title_count - 1] = strdup(optarg);
                                 break;
                         case 'b':
-				opt->kbps = atoi(optarg);
+				opt->nominal_bitrate = atoi(optarg);
+				break;
+			case 'm':
+				opt->min_bitrate = atoi(optarg);
+				break;
+			case 'M':
+				opt->max_bitrate = atoi(optarg);
+				break;
+			case 'q':
+				opt->quality = (float)(atof(optarg) * 0.1);
+				if(opt->quality > 1.0f)
+				{
+					opt->quality = 1.0f;
+					fprintf(stderr, "WARNING: quality setting too high, setting to maximum quality.\n");
+				}
+				else if(opt->quality < 0.0f)
+				{
+					opt->quality = 0.0f;
+					fprintf(stderr, "WARNING: negative quality specified, setting to minimum.\n");
+				}
                                 break;
                         case 'n':
                                 if(opt->namefmt)
@@ -432,6 +554,24 @@
                                 }
                                 opt->namefmt = strdup(optarg);
                                 break;
+            case 'X':
+				if(opt->namefmt_remove && opt->namefmt_remove != 
+                        DEFAULT_NAMEFMT_REMOVE)
+				{
+					fprintf(stderr, "WARNING: Multiple name format filters specified, using final\n");
+					free(opt->namefmt_remove);
+				}
+				opt->namefmt_remove = strdup(optarg);
+				break;
+            case 'P':
+				if(opt->namefmt_replace && opt->namefmt_replace != 
+                        DEFAULT_NAMEFMT_REPLACE)
+                {
+					fprintf(stderr, "WARNING: Multiple name format filter replacements specified, using final\n");
+					free(opt->namefmt_replace);
+				}
+				opt->namefmt_replace = strdup(optarg);
+				break;
                         case 'o':
                                 if(opt->outfile)
                                 {
@@ -439,12 +579,8 @@
                                         free(opt->outfile);
                                 }
                                 opt->outfile = strdup(optarg);
-				break;
-			case 'h':
-				usage();
-				exit(0);
                                 break;
-			case 'q':
+			case 'Q':
                                 opt->quiet = 1;
                                 break;
                         case 'r':
@@ -490,12 +626,12 @@
                                 if (opt->rawmode != 1)
                                 {
                                         opt->rawmode = 1;
-					fprintf(stderr, "WARNING: Raw samplerate specified for non-raw data. Assuming input is raw.\n");
+					fprintf(stderr, "WARNING: Raw sample rate specified for non-raw data. Assuming input is raw.\n");
                                 }
                                 if(sscanf(optarg, "%u", &opt->raw_samplerate) != 1)
                                 {
                                         opt->raw_samplerate = 44100; /* Failed, so just set to 44100 */
-					fprintf(stderr, "WARNING: Invalid samplerate specified, assuming 44100.\n");
+					fprintf(stderr, "WARNING: Invalid sample rate specified, assuming 44100.\n");
                                 }
                                 break;
                         case '?':
@@ -508,15 +644,31 @@
         }
 }
 
-void build_comments(vorbis_comment *vc, oe_options *opt, int filenum, 
-		char **artist, char **album, char **title, char **tracknum, char **date)
+static void add_tag(vorbis_comment *vc, oe_options *opt,char *name, char *value)
 {
+	char *utf8;
+	if(utf8_encode(value, &utf8) >= 0)
+	{
+		if(name == NULL)
+			vorbis_comment_add(vc, utf8);
+		else
+			vorbis_comment_add_tag(vc, name, utf8);
+		free(utf8);
+	}
+	else
+		fprintf(stderr, "Couldn't convert comment to UTF-8, cannot add\n");
+}
+
+static void build_comments(vorbis_comment *vc, oe_options *opt, int filenum, 
+		char **artist, char **album, char **title, char **tracknum, 
+        char **date, char **genre)
+{
         int i;
 
         vorbis_comment_init(vc);
 
         for(i = 0; i < opt->comment_count; i++)
-		vorbis_comment_add(vc, opt->comments[i]);
+		add_tag(vc, opt, NULL, opt->comments[i]);
 
         if(opt->title_count)
         {
@@ -530,7 +682,7 @@
                         i = filenum;
 
                 *title = opt->title[i];
-		vorbis_comment_add_tag(vc, "title", opt->title[i]);
+		add_tag(vc, opt, "title", opt->title[i]);
         }
 
         if(opt->artist_count)
@@ -541,9 +693,20 @@
                         i = filenum;
         
                 *artist = opt->artist[i];
-		vorbis_comment_add_tag(vc, "artist", opt->artist[i]);
+		add_tag(vc, opt, "artist", opt->artist[i]);
         }
 
+    if(opt->genre_count)
+    {
+        if(filenum >= opt->genre_count)
+            i = opt->genre_count-1;
+        else
+            i = filenum;
+
+        *genre = opt->genre[i];
+        add_tag(vc, opt, "genre", opt->genre[i]);
+    }
+
         if(opt->date_count)
         {
                 if(filenum >= opt->date_count)
@@ -552,7 +715,7 @@
                         i = filenum;
         
                 *date = opt->dates[i];
-		vorbis_comment_add_tag(vc, "date", opt->dates[i]);
+		add_tag(vc, opt, "date", opt->dates[i]);
         }
         
         if(opt->album_count)
@@ -565,14 +728,14 @@
                         i = filenum;
 
                 *album = opt->album[i];	
-		vorbis_comment_add_tag(vc, "album", opt->album[i]);
+		add_tag(vc, opt, "album", opt->album[i]);
         }
 
         if(filenum < opt->track_count)
         {
                 i = filenum;
                 *tracknum = opt->tracknum[i];
-		vorbis_comment_add_tag(vc, "tracknumber", opt->tracknum[i]);
+		add_tag(vc, opt, "tracknumber", opt->tracknum[i]);
         }
 }
 

1.2.6.1   +87 -17    vorbis-tools/oggenc/oggenc.dsp

Index: oggenc.dsp
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/oggenc.dsp,v
retrieving revision 1.2
retrieving revision 1.2.6.1
diff -u -r1.2 -r1.2.6.1
--- oggenc.dsp	2000/12/24 06:17:40	1.2
+++ oggenc.dsp	2001/12/15 15:26:27	1.2.6.1
@@ -4,7 +4,7 @@
 
 # TARGTYPE "Win32 (x86) Console Application" 0x0103
 
-CFG=oggenc - Win32 Debug
+CFG=oggenc - Win32 Release DLL
 !MESSAGE This is not a valid makefile. To build this project using NMAKE,
 !MESSAGE use the Export Makefile command and run
 !MESSAGE 
@@ -13,12 +13,14 @@
 !MESSAGE You can specify a configuration when running NMAKE
 !MESSAGE by defining the macro CFG on the command line. For example:
 !MESSAGE 
-!MESSAGE NMAKE /f "oggenc.mak" CFG="oggenc - Win32 Debug"
+!MESSAGE NMAKE /f "oggenc.mak" CFG="oggenc - Win32 Release DLL"
 !MESSAGE 
 !MESSAGE Possible choices for configuration are:
 !MESSAGE 
 !MESSAGE "oggenc - Win32 Release" (based on "Win32 (x86) Console Application")
 !MESSAGE "oggenc - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "oggenc - Win32 Debug DLL" (based on "Win32 (x86) Console Application")
+!MESSAGE "oggenc - Win32 Release DLL" (based on "Win32 (x86) Console Application")
 !MESSAGE 
 
 # Begin Project
@@ -37,20 +39,22 @@
 # PROP BASE Target_Dir ""
 # PROP Use_MFC 0
 # PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
+# PROP Output_Dir "Release\static"
+# PROP Intermediate_Dir "Release\static"
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /I "c:\src\ogg\include" /I "c:\src\vorbis\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\include" /I "..\..\vorbis\include" /I "..\..\ogg\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
 # ADD BASE RSC /l 0x409 /d "NDEBUG"
 # ADD RSC /l 0x409 /d "NDEBUG"
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
 LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ogg_static.lib vorbis_static.lib vorbisenc_static.lib /nologo /subsystem:console /machine:I386 /libpath:"c:\src\ogg\win32\Static_Release" /libpath:"c:\src\vorbis\win32\Static_Release"
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 ogg_static.lib vorbis_static.lib vorbisenc_static.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\ogg\win32\Static_Release" /libpath:"..\..\vorbis\win32\Vorbis_Static_Release" /libpath:"..\..\vorbis\win32\VorbisEnc_Static_Release"
+# SUBTRACT LINK32 /pdb:none
 
 !ELSEIF  "$(CFG)" == "oggenc - Win32 Debug"
 
@@ -61,27 +65,89 @@
 # PROP BASE Target_Dir ""
 # PROP Use_MFC 0
 # PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
+# PROP Output_Dir "Debug\static"
+# PROP Intermediate_Dir "Debug\static"
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ  /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "c:\src\ogg\include" /I "c:\src\vorbis\include" /I "." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ  /c
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\..\vorbis\include" /I "..\..\ogg\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /GZ /c
+# SUBTRACT CPP /YX
 # ADD BASE RSC /l 0x409 /d "_DEBUG"
 # ADD RSC /l 0x409 /d "_DEBUG"
 BSC32=bscmake.exe
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
 LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ogg_static.lib vorbis_static.lib vorbisenc_static.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"c:\src\ogg\win32\Static_Debug" /libpath:"c:\src\vorbis\win32\Static_Debug"
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 ogg_static_d.lib vorbis_static_d.lib vorbisenc_static_d.lib /nologo /subsystem:console /verbose /debug /machine:I386 /pdbtype:sept /libpath:"..\..\ogg\win32\Static_Debug" /libpath:"..\..\vorbis\win32\Vorbis_Static_Debug" /libpath:"..\..\vorbis\win32\VorbisEnc_Static_Debug"
+# SUBTRACT LINK32 /pdb:none
 
+!ELSEIF  "$(CFG)" == "oggenc - Win32 Debug DLL"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "oggenc___Win32_Debug_DLL"
+# PROP BASE Intermediate_Dir "oggenc___Win32_Debug_DLL"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug\dynamic"
+# PROP Intermediate_Dir "Debug\dynamic"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\..\vorbis\include" /I "..\..\ogg\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
+# SUBTRACT BASE CPP /YX
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\..\vorbis\include" /I "..\..\ogg\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 ogg_static_d.lib vorbis_static_d.lib vorbisenc_static_d.lib /nologo /subsystem:console /debug /machine:I386 /out:"Debug\static\oggenc.exe" /pdbtype:sept /libpath:"..\..\ogg\win32\Static_Debug" /libpath:"..\..\vorbis\win32\Vorbis_Static_Debug" /libpath:"..\..\vorbis\win32\VorbisEnc_Static_Debug"
+# SUBTRACT BASE LINK32 /pdb:none
+# ADD LINK32 ogg_d.lib vorbis_d.lib vorbisenc_d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\ogg\win32\Dynamic_Debug" /libpath:"..\..\vorbis\win32\Vorbis_Dynamic_Debug" /libpath:"..\..\vorbis\win32\VorbisEnc_Dynamic_Debug"
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF  "$(CFG)" == "oggenc - Win32 Release DLL"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "oggenc___Win32_Release_DLL"
+# PROP BASE Intermediate_Dir "oggenc___Win32_Release_DLL"
+# PROP BASE Ignore_Export_Lib 0
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Release\dynamic"
+# PROP Intermediate_Dir "Release\dynamic"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\..\vorbis\include" /I "..\..\ogg\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
+# SUBTRACT BASE CPP /YX
+# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\..\vorbis\include" /I "..\..\ogg\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 ogg_d.lib vorbis_d.lib vorbisenc_d.lib /nologo /subsystem:console /debug /machine:I386 /out:"Debug\dynamic\oggenc.exe" /pdbtype:sept /libpath:"..\..\ogg\win32\Dynamic_Debug" /libpath:"..\..\vorbis\win32\Vorbis_Dynamic_Debug" /libpath:"..\..\vorbis\win32\VorbisEnc_Dynamic_Debug"
+# SUBTRACT BASE LINK32 /pdb:none
+# ADD LINK32 ogg.lib vorbis.lib vorbisenc.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\ogg\win32\Dynamic_Release" /libpath:"..\..\vorbis\win32\Vorbis_Dynamic_Release" /libpath:"..\..\vorbis\win32\VorbisEnc_Dynamic_Release"
+# SUBTRACT LINK32 /pdb:none
+
 !ENDIF 
 
 # Begin Target
 
 # Name "oggenc - Win32 Release"
 # Name "oggenc - Win32 Debug"
+# Name "oggenc - Win32 Debug DLL"
+# Name "oggenc - Win32 Release DLL"
 # Begin Group "Source Files"
 
 # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
@@ -94,12 +160,16 @@
 SOURCE=.\encode.c
 # End Source File
 # Begin Source File
+
+SOURCE=..\share\getopt.c
+# End Source File
+# Begin Source File
 
-SOURCE=.\getopt.c
+SOURCE=..\share\getopt1.c
 # End Source File
 # Begin Source File
 
-SOURCE=.\getopt1.c
+SOURCE=.\oggenc.c
 # End Source File
 # Begin Source File
 
@@ -107,7 +177,7 @@
 # End Source File
 # Begin Source File
 
-SOURCE=.\oggenc.c
+SOURCE=..\share\utf8.c
 # End Source File
 # End Group
 # Begin Group "Header Files"
@@ -123,7 +193,7 @@
 # End Source File
 # Begin Source File
 
-SOURCE=.\getopt.h
+SOURCE=..\include\getopt.h
 # End Source File
 # Begin Source File
 

1.5.6.1   +5 -0      vorbis-tools/oggenc/platform.h

Index: platform.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/platform.h,v
retrieving revision 1.5
retrieving revision 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- platform.h	2001/02/20 08:12:50	1.5
+++ platform.h	2001/12/15 15:26:27	1.5.6.1
@@ -18,9 +18,14 @@
 
 void setbinmode(FILE *);
 
+#define DEFAULT_NAMEFMT_REMOVE "/\\:<>|"
+#define DEFAULT_NAMEFMT_REPLACE NULL
+
 #else /* Unix, mostly */
 
 #define setbinmode(x) {}
+#define DEFAULT_NAMEFMT_REMOVE "/"
+#define DEFAULT_NAMEFMT_REPLACE NULL
 
 #endif
 

No                   revision

No                   revision

1.3.6.1   +1 -6      vorbis-tools/oggenc/man/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/man/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.3.6.1
diff -u -r1.3 -r1.3.6.1
--- Makefile.am	2001/02/26 05:56:46	1.3
+++ Makefile.am	2001/12/15 15:26:29	1.3.6.1
@@ -2,12 +2,7 @@
 
 AUTOMAKE_OPTIONS = foreign
 
-if PREFIX_IS_USR
-mandir = $(datadir)/man
-else
-mandir = $(prefix)/man
-endif
-
+mandir = @MANDIR@
 man_MANS = oggenc.1
 
 EXTRA_DIST = $(man_MANS)

1.5.6.1   +57 -15    vorbis-tools/oggenc/man/oggenc.1

Index: oggenc.1
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/man/oggenc.1,v
retrieving revision 1.5
retrieving revision 1.5.6.1
diff -u -r1.5 -r1.5.6.1
--- oggenc.1	2001/05/27 20:35:53	1.5
+++ oggenc.1	2001/12/15 15:26:29	1.5.6.1
@@ -1,7 +1,7 @@
 .\" Process this file with
 .\" groff -man -Tascii oggenc.1
 .\"
-.TH oggenc 1 "May 27, 2001" "" "Vorbis Tools beta 4"
+.TH oggenc 1 "2001 August 13" "" "Vorbis Tools release candidate 2"
 
 .SH NAME
 oggenc \- encode audio into the Ogg Vorbis format
@@ -9,12 +9,24 @@
 .SH SYNOPSIS
 .B oggenc
 [
-.B -hrq
+.B -hrQ
 ]
 [
 .B -b
-.I bitrate 
+.I nominal bitrate
 ]
+.\"[
+.\".B -m
+.\".I minimum bitrate
+.\"]
+.\"[
+.\".B -M
+.\".I maximum bitrate
+.\"]
+.\"[
+.\".B -q
+.\".I quality
+.\"]
 [
 .B -o
 .I output_file
@@ -39,6 +51,10 @@
 .B -l
 .I album
 ]
+[
+.B -G
+.I genre
+]
 .I input_files \fR...
 
 .SH DESCRIPTION
@@ -49,7 +65,7 @@
 .I stdin
 and the Vorbis stream is written to
 .I stdout
-unless the 
+unless the
 .B -o
 option is used to redirect the output.  By default, disk files are
 output to Ogg Vorbis files of the same name, with the extension
@@ -67,15 +83,21 @@
 header information. If other options are not specified, defaults to 44.1kHz
 stereo 16 bit. See next three options for how to change this.
 .IP "-B n, --raw-bits=n"
-Sets raw input bits/sample rate. Default is 16
+Sets raw input sample size in bits. Default is 16.
 .IP "-C n, --raw-chan=n"
-Sets raw input number of channels. Default is 2
+Sets raw input number of channels. Default is 2.
 .IP "-R n, --raw-rate=n"
-Sets raw input samplerate. Default is 44100
-.IP "-q, --quiet"
+Sets raw input samplerate. Default is 44100.
+.IP "-Q, --quiet"
 Quiet mode.  No messages are displayed.
 .IP "-b n, --bitrate=n"
-Sets encoding to the bitrate closest to n (in kb/s). Defaults to 128 kb/s for stereo.
+Sets encoding to the bitrate closest to n (in kb/s).
+.\".IP "-m n, --min-bitrate=n [unsupported]"
+.\"Sets minimum bitrate to n (in kb/s).
+.\".IP "-M n, --max-bitrate=n [unsupported]"
+.\"Sets maximum bitrate to n (in kb/s).
+.\".IP "-q n, --quality=n     [unsupported]"
+.\"Sets encoding quality to n, between 0 (low) and 10 (high). This is the default mode of operation.
 .IP "-s, --serial"
 Forces a specific serial number in the output stream. This is primarily useful for testing.
 .IP "-o output_file, --output=output_file"
@@ -83,20 +105,24 @@
 .I output_file (only valid if a single input file is specified)
 
 .IP "-n pattern, --names=pattern"
-Produce filenames as this string, with %a, %t, %l replaced by artist,
+Produce filenames as this string, with %a, %t, %l, %G replaced by artist,
 title, album respectively (see below for specifying these). Also, %%
 gives a literal %.
 
 .IP "-c comment, --comment comment"
-Add the string 
+Add the string
 .I comment
-as an extra comment.  This may be used multiple times, and all 
+as an extra comment.  This may be used multiple times, and all
 instances will be added to each of the input files specified.
 
 .IP "-a artist, --artist artist"
 Set the artist comment field in the comments to
 .I artist.
 
+.IP "-G genre, --genre genre"
+Set the genre comment field in the comments to
+.I genre.
+
 .IP "-d date, --date date"
 Sets the date comment field to the given value. This should be the date of recording.
 
@@ -134,16 +160,28 @@
 .RE
 .PP
 
-Specifying a high-quality mode (approx 256 kbps):
+Specifying a high-quality encoding averaging 256 kbps.
 .RS
 oggenc infile.wav -b 256 out.ogg
 .RE
 .PP
 
+Specifying a maximum and average bitrate.
+.RS
+oggenc infile.wav -b 128 -M 160 out.ogg
+.RE
+.PP
+
+.\"Specifying quality rather than bitrate (to a very high quality mode)
+.\".RS
+.\"oggenc infile.wav -q 9 out.ogg
+.\".RE
+.\".PP
+.\"
 Adding some info about the track:
 .RS
 oggenc somefile.wav -t "The track title" -a "artist who performed this" -l
-"name of album" -c 
+"name of album" -c
 "OTHERFIELD=contents of some other field not explictly supported"
 .RE
 .PP
@@ -151,7 +189,7 @@
 This encodes the three files, each with the
 same artist/album tag, but with different title tags on each one. The
 string given as an argument to -n is used to generate filenames, as shown
-in the section above. This example gives filenames 
+in the section above. This example gives filenames
 like "The Tea Party - Touch.ogg":
 .RS
 oggenc -b 192 -a "The Tea Party" -l "Triptych" -t "Touch" track01.wav -t
@@ -177,6 +215,10 @@
 Manpage Author:
 .br
 Stan Seibert <indigo at aztec.asu.edu>
+
+.SH BUGS
+Options -m, -M, and -q for for flexible bitrate/quality selection exist, but are not
+implemented in the vorbis encoder, and so are not documented here yet.
 
 .SH SEE ALSO
 

No                   revision

No                   revision

1.2.4.1   +3 -2      vorbis-tools/ogginfo/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogginfo/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -r1.2 -r1.2.4.1
--- Makefile.am	2001/06/18 03:48:13	1.2
+++ Makefile.am	2001/12/15 15:26:29	1.2.4.1
@@ -3,12 +3,13 @@
 AUTOMAKE_OPTIONS = foreign
 
 bin_PROGRAMS = ogginfo
-mandir = $(datadir)/man
+mandir = @MANDIR@
 man_MANS = ogginfo.1
 
 INCLUDES = @OGG_CFLAGS@ @VORBIS_CFLAGS@
 
-ogginfo_LDADD = @VORBISFILE_LIBS@ @VORBIS_LIBS@ @OGG_LIBS@
+ogginfo_LDADD = @VORBIS_LIBS@ @OGG_LIBS@ @LIBICONV@ @SHARE_LIBS@
+ogginfo_DEPENDENCIES = @SHARE_LIBS@
 
 ogginfo_SOURCES = ogginfo.c
 

1.1.4.1   +78 -137   vorbis-tools/ogginfo/ogginfo.1

Index: ogginfo.1
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogginfo/ogginfo.1,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -r1.1 -r1.1.4.1
--- ogginfo.1	2001/06/18 03:48:13	1.1
+++ ogginfo.1	2001/12/15 15:26:29	1.1.4.1
@@ -1,137 +1,78 @@
-.\" Process this file with
-.\" groff -man -Tascii ogginfo.1
-.\"
-.TH ogg123 1 "June 17, 2001" "" "Vorbis Tools"
-
-.SH NAME
-ogginfo \- gives information about Ogg files.
-
-.SH SYNOPSIS
-.B ogginfo
-.I file1.ogg
-.B ...
-.I fileN.ogg
-
-.SH DESCRIPTION
-.B ogginfo
-reads one or more Ogg files and decodes the comments contained within, writing
-them to standard output, in a "attribute=value" format, one per line.
-The first attribute printed will always be the
-.B filename
-of the stream. 
-.B ogginfo
-cannot accept URLs. 
-.B ogginfo
-will also print the 
-.B length
-of the file in seconds, and the
-.B playtime
-in a humanly-readable MM:SS format.
-
-
-.SH OPTIONS
-None.
-
-.SH EXAMPLES
-
-The
-.B ogginfo
-command line accepts as many filenames as your shell will allow.
-
-.PP
-Information about one file:
-.RS
-.B ogginfo track14.ogg
-.RE
-
-
-
-Will print:
-
-.RS
-.br
-.B
-filename=track14.ogg
-.br
-.B
-title=If I Had $1000000
-.br
-.B
-artist=Barenaked Ladies 
-.br
-.B
-album=Gordon
-.br
-.B
-tracknumber=14
-.br
-.B
-length=267.040000
-.br
-.B
-playtime=4:27
-.RE
-
-.PP
-Information on multiple files:
-.RS
-.B ogginfo track1.ogg track2.ogg
-.RE
-
-.PP
-Will print:
-
-.RS
-.br
-.B
-filename=track1.ogg
-.br
-.B
-title=The Vorbis Theme
-.br
-.B
-artist=Monty and The Wet Trouts
-.br
-.B
-album=Musical Penguins 3
-.br
-.B
-tracknumber=1
-.br
-.B
-length=67.38383
-.br
-.B
-playtime=1:07
-.br
-.B
-filename=track2.ogg
-.br
-.B
-title=Being for the Benefit of Mr. Fish
-.br
-.B
-artist=Monty and The Wet Trouts
-.br
-.B
-album=Musical Penguins 3
-.br
-.B
-tracknumber=2
-.br
-.B
-length=449.0000
-.br
-.B
-playtime=7:29
-.RE
-
-.SH BUGS
-
-The man page is longer than the source.
-
-.SH AUTHOR
-
-.TP
-.br
-JAmes Atwill <ogg at linuxstuff.org>
+.\" Process this file with
+.\" groff -man -Tascii ogginfo.1
+.\"
+.TH ogginfo 1 "July 8, 2001" "" "Vorbis Tools"
+
+.SH NAME
+ogginfo \- gives information about Ogg files.
+
+.SH SYNOPSIS
+.B ogginfo
+.I file1.ogg
+.B ...
+.I fileN.ogg
+
+.SH DESCRIPTION
+.B ogginfo
+reads one or more Ogg files and decodes the comments contained within, writing
+them to standard output, in a "attribute=value" format, one per line.
+The first attribute printed will always be the
+.B filename
+of the stream. 
+.B ogginfo
+cannot accept URLs.
+
+In addition to the comments,
+.B ogginfo
+will also print the following attributes for each logical bitstream within the file:
+.RS
+.IP serial
+The serial number of the logical bitstream.
+.IP header_integrity
+"pass" if the header is intact, and "fail" if it is corrupted.
+.IP stream_integrity
+"pass" if the stream contains no bad packets or holes (not counting the last 
+packet), and "fail" otherwise.
+.IP stream_truncated
+"true" if the last good packet in the stream is not marked as the last packet
+and "false" if the stream is complete.
+.IP vendor
+The vendor string of the encoder used to make this stream.
+.IP bitrate_upper
+The upper bitrate limit of the stream, or "none" if not set.
+.IP bitrate_nominal
+The "target" bitrate of the stream, or "none" if not set.
+.IP bitrate_lower
+The lower bitrate limit of the stream, or "none" if not set.
+.IP bitrate_average
+The average bitrate of the stream.
+.IP length
+Length of of the file in seconds.
+.IP playtime
+Playing time in a humanly-readable MM:SS format.
+.RE
+
+At the end of each file,
+.B ogginfo
+will also print:
+.RS
+.IP total_playtime
+The total playing time for the entire file in seconds.
+.RE
+
+.SH OPTIONS
+None.
+
+.SH BUGS
+
+Although
+.B ogginfo 
+properly handles chained bitstreams, it cannot handle multiplexed
+logical bitstreams
+
+.SH AUTHORS
+
+.br
+JAmes Atwill <ogg at linuxstuff.org>
+.br
+Stan Seibert <indigo at aztec.asu.edu>

1.1.4.1   +316 -33   vorbis-tools/ogginfo/ogginfo.c

Index: ogginfo.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogginfo/ogginfo.c,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -r1.1 -r1.1.4.1
--- ogginfo.c	2001/06/18 02:24:25	1.1
+++ ogginfo.c	2001/12/15 15:26:29	1.1.4.1
@@ -1,4 +1,12 @@
-// gcc ogginfo.c -o ogginfo -lvorbisfile -lvorbis -Wall
+/* ogginfo
+ *
+ * This program is distributed under the GNU General Public License, version 2.
+ * A copy of this license is included with this source.
+ *
+ * Copyright 2001, JAmes Atwill <ogg at linuxstuff.org>
+ *
+ * Portions from libvorbis examples, (c) Monty <monty at xiph.org>
+ */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -6,10 +14,8 @@
 #include <string.h>
 #include <ogg/ogg.h>
 #include <vorbis/codec.h>
-#include <vorbis/vorbisfile.h>
-#include <ao/ao.h>
 
-void doinfo(char *);
+int dointegritycheck(char *filename);
 
 int main(int ac,char **av)
 {
@@ -21,53 +27,330 @@
   }
 
   for(i=1;i!=ac;i++) {
-    doinfo(av[i]);
+    printf("filename=%s\n",av[i]);
+    dointegritycheck(av[i]);
+    if (i < ac - 1)
+      printf("\n---\n\n");
   }
-  return(0);
-  
+
+  return(0);  
 }
 
-void doinfo(char *filename)
+
+void calc_playtime(double playtime, long *playmin, long *playsec)
 {
-  FILE *fp;
-  OggVorbis_File vf;
+  *playmin = (long)playtime / (long)60;
+  *playsec = (long)playtime - (*playmin*60);
+}
+
+
+void print_header_info(vorbis_comment *vc, vorbis_info *vi)
+{
   int rc,i;
-  vorbis_comment *vc;
-  double playtime;
-  long playmin,playsec;
+
+  for (i=0; i < vc->comments; i++) {
+    printf("%s\n",vc->user_comments[i]);
+  }
+
+  printf("vendor=%s\n", vc->vendor);
+
+  printf("version=%d\n"
+	 "channels=%d\n"
+	 "rate=%ld\n",
+	 vi->version, vi->channels, vi->rate);
+  
+  printf("bitrate_upper=");
+  if (vi->bitrate_upper < 0) 
+    printf("none\n");
+  else 
+    printf("%ld\n", vi->bitrate_upper);
+  
+  printf("bitrate_nominal=");
+  if (vi->bitrate_nominal < 0) 
+    printf("none\n");
+  else 
+    printf("%ld\n", vi->bitrate_nominal);
+  
+  printf("bitrate_lower=");
+  if (vi->bitrate_lower < 0) 
+    printf("none\n");
+  else 
+    printf("%ld\n", vi->bitrate_lower);
+}
+
+
+void print_stream_info (double playtime, ogg_int64_t bits)
+{
+  long playmin, playsec;
+
+  calc_playtime(playtime, &playmin, &playsec);
+  printf("bitrate_average=%ld\n", (long) (bits/playtime));
+  printf("length=%f\n", playtime);
+  printf("playtime=%ld:%02ld\n", playmin, playsec);
+}
 
-  memset(&vf,0,sizeof(OggVorbis_File));
+/* Test the integrity of the stream header.  
+   Return:
+     1 if it is good
+     0 if it is corrupted and os, vi, and vc were initialized
+    -1 if it is corrupted and os, vi, and vc were not initialized 
+       (don't clear them) */
+int test_header (FILE *fp, ogg_sync_state *oy, ogg_stream_state *os,
+		 vorbis_info *vi, vorbis_comment  *vc, long *serialno)
+{
+  ogg_page         og; /* one Ogg bitstream page.  Vorbis packets are inside */
+  ogg_packet       op; /* one raw packet of data for decode */
+  char *buffer;
+  int bytes;
+  int eos=0;
+  int i;
+  
+  /* grab some data at the head of the stream.  We want the first page
+     (which is guaranteed to be small and only contain the Vorbis
+     stream initial header) We need the first page to get the stream
+     serialno. */
+  
+  /* submit a 4k block to libvorbis' Ogg layer */
+  buffer=ogg_sync_buffer(oy,4096);
+  bytes=fread(buffer,1,4096,fp);
+  ogg_sync_wrote(oy,bytes);
+  
+  /* Get the first page. */
+  if(ogg_sync_pageout(oy,&og)!=1){
+    /* error case.  Must not be Vorbis data */
+    return -1;
+  }
+  
+  /* Get the serial number and set up the rest of decode. */
+  /* serialno first; use it to set up a logical stream */
+  *serialno = ogg_page_serialno(&og);
+  ogg_stream_init(os, *serialno);
+  
+  /* extract the initial header from the first page and verify that the
+     Ogg bitstream is in fact Vorbis data */
+  
+  /* I handle the initial header first instead of just having the code
+     read all three Vorbis headers at once because reading the initial
+     header is an easy way to identify a Vorbis bitstream and it's
+     useful to see that functionality seperated out. */
   
-  fp = fopen(filename,"r");
+  vorbis_info_init(vi);
+  vorbis_comment_init(vc);
+  if(ogg_stream_pagein(os,&og)<0){ 
+    /* error; stream version mismatch perhaps */
+    return 0;
+  }
+    
+  if(ogg_stream_packetout(os,&op)!=1){ 
+    /* no page? must not be vorbis */
+    return 0;
+  }
+  
+  if(vorbis_synthesis_headerin(vi,vc,&op)<0){ 
+    /* error case; not a vorbis header */
+    return 0;
+  }
+    
+  /* At this point, we're sure we're Vorbis.  We've set up the logical
+     (Ogg) bitstream decoder.  Get the comment and codebook headers and
+     set up the Vorbis decoder */
+  
+  /* The next two packets in order are the comment and codebook headers.
+     They're likely large and may span multiple pages.  Thus we reead
+     and submit data until we get our two pacakets, watching that no
+     pages are missing.  If a page is missing, error out; losing a
+     header page is the only place where missing data is fatal. */
+  
+  i=0;
+  while(i<2){
+    while(i<2){
+      int result=ogg_sync_pageout(oy,&og);
+      if(result==0)break; /* Need more data */
+      /* Don't complain about missing or corrupt data yet.  We'll
+	 catch it at the packet output phase */
+      if(result==1){
+	ogg_stream_pagein(os,&og); /* we can ignore any errors here
+				       as they'll also become apparent
+				       at packetout */
+	while(i<2){
+	  result=ogg_stream_packetout(os,&op);
+	  if(result==0)break;
+	  if(result<0){
+	    /* Uh oh; data at some point was corrupted or missing!
+	       We can't tolerate that in a header. */
+	    return 0;
+	  }
+	  vorbis_synthesis_headerin(vi,vc,&op);
+	  i++;
+	}
+      }
+    }
+
+    /* no harm in not checking before adding more */
+    buffer=ogg_sync_buffer(oy,4096);
+    bytes=fread(buffer,1,4096,fp);
+    if(bytes==0 && i<2){
+      return 0;
+    }
+    ogg_sync_wrote(oy,bytes);
+  }
+  
+  /* If we made it this far, the header must be good. */
+  return 1;
+}
+
+
+/* Test the integrity of the vorbis stream after the header.
+   Return:
+     >0 if the stream is correct and complete
+     0 if the stream is correct but truncated
+    -1 if the stream is corrupted somewhere in the middle */
+int test_stream (FILE *fp, ogg_sync_state *oy, ogg_stream_state *os, 
+		 ogg_int64_t *final_granulepos, ogg_int64_t *bits)
+{
+  int eos = 0;
+  ogg_page         og; /* one Ogg bitstream page.  Vorbis packets are inside */
+  ogg_packet       op; /* one raw packet of data for decode */
+  int bytes;
+  char *buffer;
+
+  /* Just a straight decode loop until end of stream */
+    while(!eos){
+      while(!eos){
+	int result=ogg_sync_pageout(oy,&og);
+	if(result==0)break; /* need more data */
+	if(result<0){ /* missing or corrupt data at this page position */
+	  return -1;
+	}else{
+	  if (ogg_stream_pagein(os,&og) < 0) {
+	    return -1;
+	  }
+
+	  while(1){
+	    result=ogg_stream_packetout(os,&op);
+
+	    if(result==0)break; /* need more data */
+	    if(result<0){ /* missing or corrupt data at this page position */
+	      return -1;
+	    }else{
+	      /* Normally we would do decode here, but we're just checking
+		 packet integrity */
+	    }
+	  }
+	  if(ogg_page_eos(&og))eos=1;
+	}
+      }
+      if(!eos){
+	buffer = ogg_sync_buffer(oy,4096);
+	bytes = fread(buffer,1,4096,fp);
+	*bits += 8 * bytes;
+	ogg_sync_wrote(oy,bytes);
+	if(bytes == 0) 
+	  eos = 1;
+      }
+    }
+
+    *final_granulepos = ogg_page_granulepos(&og);
+
+    /* Make sure that the last page is marked as the end-of-stream */
+    return ogg_page_eos(&og);
+}
+
+
+/* Tests the integrity of a vorbis stream.  Returns 1 if the header is good
+   (but not necessarily the rest of the stream) and 0 otherwise.
+   
+   Huge chunks of this function are from decoder_example.c (Copyright
+   1994-2001 Xiphophorus Company). */
+int dointegritycheck(char *filename)
+{
+  int header_state = -1; /* Assume the worst */
+  int stream_state = -1;
+
+  ogg_sync_state   oy; /* sync and verify incoming physical bitstream */
+  ogg_stream_state os; /* take physical pages, weld into a logical
+			  stream of packets */
+  vorbis_info      vi; /* struct that stores all the static vorbis bitstream
+			  settings */
+  vorbis_comment   vc; /* struct that stores all the bitstream user comments */
+  
+  FILE *fp;
+  int eof = 0;
+  long serialno;
+  ogg_int64_t bits, final_granulepos;
+  double playtime, total_playtime = 0.0;
+  long total_playmin, total_playsec;
+
+  /********** Decode setup ************/
+
+  fp = fopen(filename,"rb");
   if (!fp) {
     fprintf(stderr,"Unable to open \"%s\": %s\n",
             filename,
             strerror(errno));
+    return 0;
   }
 
-  rc = ov_open(fp,&vf,NULL,0);
+  ogg_sync_init(&oy); /* Now we can read pages */
+  
+  while (!eof) {
+    bits = 0;
 
-  if (rc < 0) {
-    fprintf(stderr,"Unable to understand \"%s\", errorcode=%d\n",
-	    filename,rc);
-    return;
+    if ( (header_state = test_header(fp, &oy, &os, &vi, &vc, 
+				     &serialno)) == 1 ) {
+      stream_state = test_stream(fp, &oy, &os, &final_granulepos, 
+				 &bits);
+    }
+
+    /* Output test results */
+    if (header_state == 1) {
+      printf("\nserial=%d\n", serialno);
+      printf("header_integrity=pass\n");
+      print_header_info(&vc, &vi);
+    } else
+      printf("header_integrity=fail\n");
+    
+    if (stream_state >= 0) {
+      playtime = (double) final_granulepos / vi.rate;
+      total_playtime += playtime;
+      printf("stream_integrity=pass\n");
+      print_stream_info(playtime, bits);
+    } else
+      printf("stream_integrity=fail\n");
+    
+    if (stream_state > 0)
+      printf("stream_truncated=false\n");
+    else
+      printf("stream_truncated=true\n");
+    
+    /* clean up this logical bitstream; before exit we see if we're
+       followed by another [chained] */
+    eof = feof(fp);
   }
   
-  printf("filename=%s\n",filename);
-  vc = ov_comment(&vf,-1);
-
-  for (i=0; i < vc->comments; i++) {
-    printf("%s\n",vc->user_comments[i]);
+  calc_playtime(total_playtime, &total_playmin, &total_playsec);
+  printf("\ntotal_length=%f\n", total_playtime);
+  printf("total_playtime=%ld:%02ld\n", total_playmin, total_playsec);
+
+  if (header_state >= 0) {
+
+    /* We got far enough to initialize these structures */
+    ogg_stream_clear(&os);
+      
+    /* ogg_page and ogg_packet structs always point to storage in
+       libvorbis.  They're never freed or manipulated directly */
+    
+    vorbis_comment_clear(&vc);
+    vorbis_info_clear(&vi);  /* must be called last */
   }
+  
+  /* OK, clean up the framer */
+  ogg_sync_clear(&oy);
+  
+  fclose(fp);
 
-  playtime = ov_time_total(&vf,-1);
+  return header_state > 0 ? 1 : 0;
+}
 
-  playmin = (long)playtime / (long)60;
-  playsec = (long)playtime - (playmin*60);
-  printf("length=%f\n",playtime);
-  printf("playtime=%ld:%02ld\n",playmin,playsec);
 
-  ov_clear(&vf);
 
-  return;
-}

No                   revision

No                   revision

1.1.2.1   +0 -0      vorbis-tools/ogginfo/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/ogginfo/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1

No                   revision

No                   revision

1.1.2.1   +0 -0      vorbis-tools/share/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/share/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1

1.3.2.1   +0 -0      vorbis-tools/share/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/share/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1

1.1.2.1   +0 -0      vorbis-tools/share/charmaps.h

Index: charmaps.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/share/charmaps.h,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1

1.2.2.1   +0 -0      vorbis-tools/share/charset.c

Index: charset.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/share/charset.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -r1.2 -r1.2.2.1

1.2.2.1   +0 -0      vorbis-tools/share/charset.h

Index: charset.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/share/charset.h,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -r1.2 -r1.2.2.1

1.2.2.1   +0 -0      vorbis-tools/share/charset_test.c

Index: charset_test.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/share/charset_test.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -r1.2 -r1.2.2.1

1.1.2.1   +0 -0      vorbis-tools/share/charsetmap.h

Index: charsetmap.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/share/charsetmap.h,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1

1.1.2.1   +0 -0      vorbis-tools/share/getopt.c

Index: getopt.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/share/getopt.c,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1

1.1.2.1   +0 -0      vorbis-tools/share/getopt1.c

Index: getopt1.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/share/getopt1.c,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1

1.2.2.1   +0 -0      vorbis-tools/share/iconvert.c

Index: iconvert.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/share/iconvert.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -r1.2 -r1.2.2.1

1.1.2.1   +0 -0      vorbis-tools/share/makemap.c

Index: makemap.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/share/makemap.c,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1

1.4.2.1   +0 -0      vorbis-tools/share/utf8.c

Index: utf8.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/share/utf8.c,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1

No                   revision

No                   revision

1.1.4.1   +336 -181  vorbis-tools/vcut/vcut.c

Index: vcut.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/vcut/vcut.c,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -r1.1 -r1.1.4.1
--- vcut.c	2001/03/24 14:12:35	1.1
+++ vcut.c	2001/12/15 15:26:33	1.1.4.1
@@ -7,7 +7,7 @@
  * Simple application to cut an ogg at a specified frame, and produce two
  * output files.
  *
- * last modified: $Id: vcut.c,v 1.1 2001/03/24 14:12:35 msmith Exp $
+ * last modified: $Id: vcut.c,v 1.1.4.1 2001/12/15 15:26:33 volsung Exp $
  */
 
 #include <stdio.h>
@@ -18,109 +18,94 @@
 #include <errno.h>
 #include <string.h>
 
-/* Erk. We need some internal headers too (at the moment, anyway) */
-#include "lib/codec_internal.h"
-#include "lib/misc.h"
-
 #include "vcut.h"
 
-int main(int argc, char **argv)
+static vcut_packet *save_packet(ogg_packet *packet)
 {
-	ogg_int64_t cutpoint;
-	FILE *in,*out1,*out2;
-
-	if(argc<5)
-	{
-		fprintf(stderr, 
-				"Usage: vcut infile.ogg outfile1.ogg outfile2.ogg cutpoint\n");
-		exit(1);
-	}
+	vcut_packet *p = malloc(sizeof(vcut_packet));
 
-	in = fopen(argv[1], "rb");
-	if(!in) {
-		fprintf(stderr, "Couldn't open %s for reading\n", argv[1]);
-		exit(1);
-	}
-	out1 = fopen(argv[2], "wb");
-	if(!out1) {
-		fprintf(stderr, "Couldn't open %s for writing\n", argv[2]);
-		exit(1);
-	}
-	out2 = fopen(argv[3], "wb");
-	if(!out2) {
-		fprintf(stderr, "Couldn't open %s for writing\n", argv[3]);
-		exit(1);
-	}
+	p->length = packet->bytes;
+	p->packet = malloc(p->length);
+	memcpy(p->packet, packet->packet, p->length);
 
-	sscanf(argv[4], "%Ld", &cutpoint);
+	return p;
+}
 
-	if(vcut_process(in,out1,out2,cutpoint))
+static void free_packet(vcut_packet *p)
+{
+	if(p)
         {
-		fprintf(stderr, "Processing failed\n");
-		exit(1);
+		if(p->packet)
+			free(p->packet);
+		free(p);
         }
-
-	fclose(in);
-	fclose(out1);
-	fclose(out2);
-
-	return 0;
 }
 
-int vcut_process(FILE *in, FILE *first, FILE *second, ogg_int64_t cutpoint)
+static long get_blocksize(vcut_state *s, vorbis_info *vi, ogg_packet *op)
 {
-	ogg_stream_state  stream_out_first;
-	ogg_stream_state  stream_out_second;
-	vcut_state *s;
-
-	s = vcut_new_state();
-	fprintf(stderr, "Processing: Cutting at %lld\n", cutpoint);
-	s->cutpoint = cutpoint;
+	int this = vorbis_packet_blocksize(vi, op);
+	int ret = (this+s->prevW)/4;
 
-	/* Read headers in, and save them */
-	vcut_process_headers(s, in);
-
-	/* ok, headers are all in, and saved */
-	fprintf(stderr, "Header reading complete\n");
-
-	vorbis_synthesis_init(s->vd,s->vi);
-	vorbis_block_init(s->vd,s->vb);
-
-	ogg_stream_init(&stream_out_first, s->serial); /* first file gets original */
-	srand(time(NULL));
-	ogg_stream_init(&stream_out_second, rand()); /* second gets random */
-
-	vcut_submit_headers_to_stream(&stream_out_first, s);
-	vcut_submit_headers_to_stream(&stream_out_second, s);
-
-	vcut_flush_pages_to_file(&stream_out_first, first);
-	vcut_flush_pages_to_file(&stream_out_second, second);
-
-	vcut_process_first_stream(s, &stream_out_first, in, first);
-	ogg_stream_clear(&stream_out_first);
-	vcut_process_second_stream(s, &stream_out_second, in, second);
-	ogg_stream_clear(&stream_out_second);
+	s->prevW = this;
+	return ret;
+}
 
-	/* Free some memory! */
-	return 0;
+static int update_sync(vcut_state *s, FILE *f)
+{
+	unsigned char *buffer = ogg_sync_buffer(s->sync_in, 4096);
+	int bytes = fread(buffer,1,4096,f);
+	ogg_sync_wrote(s->sync_in, bytes);
+	return bytes;
 }
 
-vcut_state *vcut_new_state()
+/* Returns 0 for success, or -1 on failure. */
+static int write_pages_to_file(ogg_stream_state *stream, 
+		FILE *file, int flush)
 {
-	vcut_state *s = malloc(sizeof(vcut_state));
-	memset(s,0,sizeof(vcut_state));
+	ogg_page page;
 
-	s->sync_in = malloc(sizeof(ogg_sync_state));
-	s->stream_in = malloc(sizeof(ogg_stream_state));
-	s->vd = malloc(sizeof(vorbis_dsp_state));
-	s->vi = malloc(sizeof(vorbis_info));
-	s->vb = malloc(sizeof(vorbis_block));
+	if(flush)
+	{
+		while(ogg_stream_flush(stream, &page))
+		{
+			if(fwrite(page.header,1,page.header_len, file) != page.header_len)
+				return -1;
+			if(fwrite(page.body,1,page.body_len, file) != page.body_len)
+				return -1;
+		}
+	}
+	else
+	{
+		while(ogg_stream_pageout(stream, &page))
+		{
+			if(fwrite(page.header,1,page.header_len, file) != page.header_len)
+				return -1;
+			if(fwrite(page.body,1,page.body_len, file) != page.body_len)
+				return -1;
+		}
+	}
 
-	return s;
+	return 0;
 }
 
 
-void vcut_process_first_stream(vcut_state *s, ogg_stream_state *stream, FILE *in, FILE *f)
+/* Write the first stream to output file until we get to the appropriate
+ * cut point. 
+ *
+ * We need to do the following:
+ *   - Adjust the end of the stream to note the new end of stream.
+ *   - Change the final granulepos to be the cutpoint value, so that we don't
+ *     decode the extra data past this.
+ *   - Save the final two packets in the stream to temporary buffers.
+ *     These two packets then become the first two packets in the 2nd stream
+ *     (we need two packets because of the overlap-add nature of vorbis).
+ *   - For each packet, buffer it (it could be the 2nd last packet, we don't
+ *     know yet (but we could optimise this decision based on known maximum
+ *     block sizes, and call get_blocksize(), because this updates internal
+ *     state needed for sample-accurate block size calculations.
+ */
+static int process_first_stream(vcut_state *s, ogg_stream_state *stream, 
+		FILE *in, FILE *f)
 {
         int eos=0;
         ogg_page page;
@@ -134,54 +119,56 @@
                 {
                         int result = ogg_sync_pageout(s->sync_in, &page);
                         if(result==0) break;
-			else if(result<0) fprintf(stderr, "Page error. May not work\n");
+			else if(result<0) fprintf(stderr, "Page error. Corrupt input.\n");
                         else
                         {
                                 granpos = ogg_page_granulepos(&page);
-				fprintf(stderr, "Input page: %lld\n", granpos);
                                 ogg_stream_pagein(s->stream_in, &page);
 
-				fprintf(stderr, "granpos: %lld, cutpoint; %lld\n", granpos, s->cutpoint);
                                 if(granpos < s->cutpoint)
                                 {
                                         while(1)
                                         {
                                                 result=ogg_stream_packetout(s->stream_in, &packet);
 
-						/* throw away result */
-						vcut_get_blocksize(s,s->vb,&packet);
+						/* throw away result, but update state */
+						get_blocksize(s,s->vi,&packet);
 
                                                 if(result==0) break;
                                                 else if(result==-1)
                                                         fprintf(stderr, "Bitstream error, continuing\n");
                                                 else
                                                 {
-							/* Free these somewhere: FIXME!!! */
-							s->packets[0] = vcut_save_packet(&packet);
-							// Count pcm?? 
+							/* We need to save the last packet in the first
+							 * stream - but we don't know when we're going
+							 * to get there. So we have to keep every packet
+							 * just in case.
+							 */
+							if(s->packets[0])
+								free_packet(s->packets[0]);
+							s->packets[0] = save_packet(&packet);
+
                                                         ogg_stream_packetin(stream, &packet);
-							vcut_write_pages_to_file(stream, f);
+							if(write_pages_to_file(stream, f,0))
+								return -1;
                                                 }
                                         }
                                         prevgranpos = granpos;
                                 }
                                 else
-				{
-					fprintf(stderr, "Page passes cutpoint\n");
-					eos=1; /* This way we break out */
-				}
-
+					eos=1; /* First stream ends somewhere in this page.
+							  We break of out this loop here. */
 
                                 if(ogg_page_eos(&page))
                                 {
-					fprintf(stderr, "Found EOS page\n");
+					fprintf(stderr, "Found EOS before cut point.\n");
                                         eos=1;
                                 }
                         }
                 }
                 if(!eos)
                 {
-			if(vcut_update_sync(s,in)==0) 
+			if(update_sync(s,in)==0) 
                         {
                                 fprintf(stderr, "Setting eos: update sync returned 0\n");
                                 eos=1;
@@ -189,51 +176,80 @@
                 }
         }
 
+	/* Now, check to see if we reached a real EOS */
+	if(granpos < s->cutpoint)
+	{
+		fprintf(stderr, 
+				"Cutpoint not within stream. Second file will be empty\n");
+		write_pages_to_file(stream, f,0);
+
+		return -1;
+	}
+
         while((result = ogg_stream_packetout(s->stream_in, &packet))!=0)
         {
-		int bs = vcut_get_blocksize(s, s->vb, &packet);
+		int bs;
+		
+		bs = get_blocksize(s, s->vi, &packet);
                 prevgranpos += bs;
 
-		fprintf(stderr, "prevgranpos += %d -> %lld\n", bs, prevgranpos);
                 if(prevgranpos > s->cutpoint)
                 {
-			fprintf(stderr, "Passed cutpoint: %lld\n", s->cutpoint);
-			s->packets[1] = vcut_save_packet(&packet);
-			packet.granulepos = s->cutpoint; /* Set it! */
+			s->packets[1] = save_packet(&packet);
+			packet.granulepos = s->cutpoint; /* Set it! This 'truncates' the 
+											  * final packet, as needed. */
                         packet.e_o_s = 1;
                         ogg_stream_packetin(stream, &packet);
                         break;
                 }
-		/* Free these? */
-		s->packets[0] = vcut_save_packet(&packet);
+		if(s->packets[0])
+			free_packet(s->packets[0]);
+		s->packets[0] = save_packet(&packet);
                 ogg_stream_packetin(stream, &packet);
-		vcut_write_pages_to_file(stream,f);
+		if(write_pages_to_file(stream,f, 0))
+			return -1;
         }
 
-	vcut_write_pages_to_file(stream,f);
+	/* Check that we got at least two packets here, which we need later */
+	if(!s->packets[0] || !s->packets[1])
+	{
+		fprintf(stderr, "Unhandled special case: first file too short?\n");
+		return -1;
+	}
 
+	if(write_pages_to_file(stream,f, 0))
+		return -1;
+
         /* Remaining samples in first packet */
         s->initialgranpos = prevgranpos - s->cutpoint; 
-	fprintf(stderr, "Trimming %lld samples from end of first stream (placing on second stream\n", s->initialgranpos);
 
-	fprintf(stderr, "Completed first stream!\n");
+	return 0;
 }
 
-void vcut_process_second_stream(vcut_state *s, ogg_stream_state *stream, FILE *in, FILE *f)
+/* Process second stream.
+ *
+ * We need to do more packet manipulation here, because we need to calculate
+ * a new granulepos for every packet, since the old ones are now invalid.
+ * Start by placing the modified first and second packets into the stream.
+ * Then just proceed through the stream modifying packno and granulepos for
+ * each packet, using the granulepos which we track block-by-block.
+ */
+static int process_second_stream(vcut_state *s, ogg_stream_state *stream, 
+		FILE *in, FILE *f)
 {
         ogg_packet packet;
         ogg_page page;
         int eos=0;
         int result;
         ogg_int64_t page_granpos, current_granpos=s->initialgranpos;
-	ogg_int64_t packetnum=0; /* Do we even care? */
+	ogg_int64_t packetnum=0; /* Should this start from 0 or 3 ? */
 
         packet.bytes = s->packets[0]->length;
         packet.packet = s->packets[0]->packet;
         packet.b_o_s = 0;
         packet.e_o_s = 0;
         packet.granulepos = 0;
-	packet.packetno = packetnum++; /* 0 or 3 for the first audio packet? */
+	packet.packetno = packetnum++; 
         ogg_stream_packetin(stream,&packet);
 
         packet.bytes = s->packets[1]->length;
@@ -244,9 +260,20 @@
         packet.packetno = packetnum++;
         ogg_stream_packetin(stream,&packet);
 
+	if(ogg_stream_flush(stream, &page)!=0)
+	{
+		fwrite(page.header,1,page.header_len,f);
+		fwrite(page.body,1,page.body_len,f);
+	}
+
         while(ogg_stream_flush(stream, &page)!=0)
         {
-		fprintf(stderr, "Flushing (should be only one page)\n");
+		/* Might this happen for _really_ high bitrate modes, if we're
+		 * spectacularly unlucky? Doubt it, but let's check for it just
+		 * in case.
+		 */
+		fprintf(stderr, "ERROR: First two audio packets did not fit into one\n"
+				        "       ogg page. File may not decode correctly.\n");
                 fwrite(page.header,1,page.header_len,f);
                 fwrite(page.body,1,page.body_len,f);
         }
@@ -271,67 +298,36 @@
                                         else if(result==-1) fprintf(stderr, "Bitstream error\n");
                                         else
                                         {
-						int bs = vcut_get_blocksize(s, s->vb, &packet);
+						int bs = get_blocksize(s, s->vi, &packet);
                                                 current_granpos += bs;
                                                 if(current_granpos > page_granpos)
                                                 {
-							fprintf(stderr, "INFO: Truncating at granpos=%lld->%lld\n", current_granpos, page_granpos);
                                                         current_granpos = page_granpos;
                                                 }
 
                                                 packet.granulepos = current_granpos;
                                                 packet.packetno = packetnum++;
                                                 ogg_stream_packetin(stream, &packet);
-						vcut_write_pages_to_file(stream,f);
+						if(write_pages_to_file(stream,f, 0))
+							return -1;
                                         }
                                 }
                         }
                 }
                 if(!eos)
                 {
-			if(vcut_update_sync(s, in)==0)
+			if(update_sync(s, in)==0)
                         {
                                 fprintf(stderr, "Update sync returned 0, setting eos\n");
                                 eos=1;
                         }
                 }
         }
-}			
 
-long vcut_get_blocksize(vcut_state *s, vorbis_block *vb, ogg_packet *op)
-{
-	vorbis_info *vi = vb->vd->vi;
-	oggpack_buffer *opb = &vb->opb;
-	int mode;
-	codec_setup_info *ci = vi->codec_setup;
-	int ret;
-
-	oggpack_readinit(opb,op->packet, op->bytes);
-
-	if(oggpack_read(opb,1)!=0) return 0;
-
-	mode = oggpack_read(opb, 
-			((backend_lookup_state *)vb->vd->backend_state)->modebits);
-
-	ret = (ci->blocksizes[ci->mode_param[mode]->blockflag] + 
-			ci->blocksizes[s->prevW])/4;
-
-	/* remember to init prevW to appropriate thing */
-	s->prevW = ci->mode_param[mode]->blockflag;
-	return ret;
-}
-
-int vcut_update_sync(vcut_state *s, FILE *f)
-{
-	unsigned char *buffer = ogg_sync_buffer(s->sync_in, 4096);
-	int bytes = fread(buffer,1,4096,f);
-	ogg_sync_wrote(s->sync_in, bytes);
-	return bytes;
-}
-
-
+	return 0;
+}			
 
-void vcut_submit_headers_to_stream(ogg_stream_state *stream, vcut_state *s) 
+static void submit_headers_to_stream(ogg_stream_state *stream, vcut_state *s) 
 {
         int i;
         for(i=0;i<3;i++)
@@ -347,8 +343,9 @@
         }
 }
                                                                         
-
-void vcut_process_headers(vcut_state *s, FILE *in)
+/* Pull out and save the 3 header packets from the input file.
+ */
+static int process_headers(vcut_state *s)
 {
         vorbis_comment vc;
         ogg_page page;
@@ -363,12 +360,12 @@
         vorbis_comment_init(&vc);
 
         buffer = ogg_sync_buffer(s->sync_in, 4096);
-	bytes = fread(buffer, 1, 4096, in);
+	bytes = fread(buffer, 1, 4096, s->in);
         ogg_sync_wrote(s->sync_in, bytes);
 
         if(ogg_sync_pageout(s->sync_in, &page)!=1){
                 fprintf(stderr, "Input not ogg.\n");
-		exit(1);
+		return -1;
         }
 
         s->serial = ogg_page_serialno(&page);
@@ -378,22 +375,21 @@
         if(ogg_stream_pagein(s->stream_in, &page) <0)
         {
                 fprintf(stderr, "Error in first page\n");
-		exit(1);
+		return -1;
         }
 
         if(ogg_stream_packetout(s->stream_in, &packet)!=1){
                 fprintf(stderr, "error in first packet\n");
-		exit(1);
+		return -1;
         }
 
         if(vorbis_synthesis_headerin(s->vi, &vc, &packet)<0)
         {
                 fprintf(stderr, "Error in primary header: not vorbis?\n");
-		exit(1);
+		return -1;
         }
 
-	fprintf(stderr, "headerin: read primary header\n");
-	s->headers[0] = vcut_save_packet(&packet);
+	s->headers[0] = save_packet(&packet);
 
         i=0;
         while(i<2)
@@ -410,58 +406,217 @@
                                         if(res==0)break;
                                         if(res<0){
                                                 fprintf(stderr, "Secondary header corrupt\n");
-						exit(1);
+						return -1;
                                         }
-					s->headers[i+1] = vcut_save_packet(&packet);
+					s->headers[i+1] = save_packet(&packet);
                                         vorbis_synthesis_headerin(s->vi,&vc,&packet);
                                         i++;
                                 }
                         }
                 }
                 buffer=ogg_sync_buffer(s->sync_in, 4096);
-		bytes=fread(buffer,1,4096,in);
+		bytes=fread(buffer,1,4096,s->in);
                 if(bytes==0 && i<2)
                 {
                         fprintf(stderr, "EOF in headers\n");
-			exit(1);
+			return -1;
                 }
                 ogg_sync_wrote(s->sync_in, bytes);
         }
+
+	vorbis_comment_clear(&vc);
+
+	return 0;
 }
+
 
-vcut_packet *vcut_save_packet(ogg_packet *packet)
+int main(int argc, char **argv)
 {
-	vcut_packet *p = malloc(sizeof(vcut_packet));
+	ogg_int64_t cutpoint;
+	FILE *in,*out1,*out2;
+	int ret=0;
+	vcut_state *state;
 
-	p->length = packet->bytes;
-	p->packet = malloc(p->length);
-	memcpy(p->packet, packet->packet, p->length);
+	if(argc<5)
+	{
+		fprintf(stderr, 
+				"Usage: vcut infile.ogg outfile1.ogg outfile2.ogg cutpoint\n");
+		exit(1);
+	}
 
-	return p;
+	fprintf(stderr, "WARNING: vcut is still experimental code.\n"
+		"Check that the output files are correct before deleting sources.\n\n");
+
+	in = fopen(argv[1], "rb");
+	if(!in) {
+		fprintf(stderr, "Couldn't open %s for reading\n", argv[1]);
+		exit(1);
+	}
+	out1 = fopen(argv[2], "wb");
+	if(!out1) {
+		fprintf(stderr, "Couldn't open %s for writing\n", argv[2]);
+		exit(1);
+	}
+	out2 = fopen(argv[3], "wb");
+	if(!out2) {
+		fprintf(stderr, "Couldn't open %s for writing\n", argv[3]);
+		exit(1);
+	}
+
+	sscanf(argv[4], "%Ld", &cutpoint);
+
+	fprintf(stderr, "Processing: Cutting at %lld\n", cutpoint);
+
+	state = vcut_new();
+
+	vcut_set_files(state, in,out1,out2);
+	vcut_set_cutpoint(state, cutpoint);
+
+	if(vcut_process(state))
+	{
+		fprintf(stderr, "Processing failed\n");
+		ret = 1;
+	}
+
+	vcut_free(state);
+
+	fclose(in);
+	fclose(out1);
+	fclose(out2);
+
+	return ret;
 }
 
-void vcut_write_pages_to_file(ogg_stream_state *stream, FILE *file)
+int vcut_process(vcut_state *s)
 {
-	ogg_page page;
+	ogg_stream_state  stream_out_first;
+	ogg_stream_state  stream_out_second;
+
+	/* Read headers in, and save them */
+	if(process_headers(s))
+	{
+		fprintf(stderr, "Error reading headers\n");
+		return -1;
+	}
+
+	/* ok, headers are all in, and saved */
+	vorbis_synthesis_init(s->vd,s->vi);
+	vorbis_block_init(s->vd,s->vb);
+
+	ogg_stream_init(&stream_out_first,s->serial); /* first file gets original */
+	srand(time(NULL));
+	ogg_stream_init(&stream_out_second, rand()); /* second gets random */
 
-	while(ogg_stream_pageout(stream, &page))
+	submit_headers_to_stream(&stream_out_first, s);
+	if(write_pages_to_file(&stream_out_first, s->out1, 1))
+		return -1;
+
+	submit_headers_to_stream(&stream_out_second, s);
+	if(write_pages_to_file(&stream_out_second, s->out2, 1))
+		return -1;
+
+	
+	if(process_first_stream(s, &stream_out_first, s->in, s->out1))
         {
-		fwrite(page.header,1,page.header_len, file);
-		fwrite(page.body,1,page.body_len, file);
+		fprintf(stderr, "Error writing first output file\n");
+		return -1;
         }
+
+	ogg_stream_clear(&stream_out_first);
+
+	if(process_second_stream(s, &stream_out_second, s->in, s->out2))
+	{
+		fprintf(stderr, "Error writing second output file\n");
+		return -1;
+	}
+	ogg_stream_clear(&stream_out_second);
+
+	return 0;
 }
 
-void vcut_flush_pages_to_file(ogg_stream_state *stream, FILE *file)
+vcut_state *vcut_new(void)
 {
-	ogg_page page;
+	vcut_state *s = malloc(sizeof(vcut_state));
+	memset(s,0,sizeof(vcut_state));
 
-	while(ogg_stream_flush(stream, &page))
+	s->sync_in = malloc(sizeof(ogg_sync_state));
+	s->stream_in = malloc(sizeof(ogg_stream_state));
+	s->vd = malloc(sizeof(vorbis_dsp_state));
+	s->vi = malloc(sizeof(vorbis_info));
+	s->vb = malloc(sizeof(vorbis_block));
+
+	s->headers = malloc(sizeof(vcut_packet)*3);
+	memset(s->headers, 0, sizeof(vcut_packet)*3);
+	s->packets = malloc(sizeof(vcut_packet)*2);
+	memset(s->packets, 0, sizeof(vcut_packet)*2);
+
+	return s;
+}
+
+/* Full cleanup of internal state and vorbis/ogg structures */
+void vcut_free(vcut_state *s)
+{
+	if(s)
         {
-		fwrite(page.header,1,page.header_len, file);
-		fwrite(page.body,1,page.body_len, file);
+		if(s->packets)
+		{
+			if(s->packets[0])
+				free_packet(s->packets[0]);
+			if(s->packets[1])
+				free_packet(s->packets[1]);
+			free(s->packets);
+		}
+
+		if(s->headers)
+		{
+			int i;
+			for(i=0; i < 3; i++)
+				if(s->headers[i])
+					free_packet(s->headers[i]);
+			free(s->headers);
+		}
+
+		if(s->vb)
+		{
+			vorbis_block_clear(s->vb);
+			free(s->vb);
+		}
+		if(s->vd)
+		{
+			vorbis_dsp_clear(s->vd);
+			free(s->vd);
+		}
+		if(s->vi)
+		{
+			vorbis_info_clear(s->vi);
+			free(s->vi);
+		}
+		if(s->stream_in)
+		{
+			ogg_stream_clear(s->stream_in);
+			free(s->stream_in);
+		}
+		if(s->sync_in)
+		{
+			ogg_sync_clear(s->sync_in);
+			free(s->sync_in);
+		}
+
+		free(s);
         }
 }
 
+void vcut_set_files(vcut_state *s, FILE *in, FILE *out1, FILE *out2)
+{
+	s->in = in;
+	s->out1 = out1;
+	s->out2 = out2;
+}
+
+void vcut_set_cutpoint(vcut_state *s, ogg_int64_t cutpoint)
+{
+	s->cutpoint = cutpoint;
+}
 
 
 

1.1.4.1   +9 -17     vorbis-tools/vcut/vcut.h

Index: vcut.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/vcut/vcut.h,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -r1.1 -r1.1.4.1
--- vcut.h	2001/03/24 14:12:35	1.1
+++ vcut.h	2001/12/15 15:26:33	1.1.4.1
@@ -20,24 +20,16 @@
         ogg_int64_t initialgranpos;
         ogg_int64_t cutpoint;
         unsigned int serial;
-	vcut_packet *headers[3];
-	vcut_packet *packets[2];
-} vcut_state;
-
-int vcut_process(FILE *in, FILE *first, FILE *second, ogg_int64_t cutpoint);
+	vcut_packet **headers; /* 3 */
+	vcut_packet **packets; /* 2 */
 
-long vcut_blocksize(vorbis_block *vb, ogg_packet *op);
-
-vcut_packet *vcut_save_packet(ogg_packet *packet);
+	FILE *in,*out1,*out2;
+} vcut_state;
 
-void vcut_submit_headers_to_stream(ogg_stream_state *stream, vcut_state *s);
-void vcut_process_headers(vcut_state *s, FILE *in);
-void vcut_write_pages_to_file(ogg_stream_state *stream, FILE *file);
-void vcut_flush_pages_to_file(ogg_stream_state *stream, FILE *file);
-int vcut_update_sync(vcut_state *s, FILE *f);
-vcut_state *vcut_new_state(void);
-void vcut_process_first_stream(vcut_state *s, ogg_stream_state *stream, FILE *in, FILE *f);
-void vcut_process_second_stream(vcut_state *s, ogg_stream_state *stream, FILE *in,FILE *f);
-long vcut_get_blocksize(vcut_state *s, vorbis_block *vb, ogg_packet *p);
+int vcut_process(vcut_state *state);
+void vcut_set_files(vcut_state *s, FILE *in, FILE *out1, FILE *out2);
+void vcut_set_cutpoint(vcut_state *s, ogg_int64_t cutpoint);
+vcut_state *vcut_new(void);
+void vcut_free(vcut_state *state);
 
 #endif /* __VCUT_H */

No                   revision

No                   revision

1.1.2.1   +0 -0      vorbis-tools/vcut/.cvsignore

Index: .cvsignore
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/vcut/.cvsignore,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1

1.1.2.1   +0 -0      vorbis-tools/vcut/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/vcut/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1

No                   revision

No                   revision

1.8.4.1   +4 -3      vorbis-tools/vorbiscomment/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/vorbiscomment/Makefile.am,v
retrieving revision 1.8
retrieving revision 1.8.4.1
diff -u -r1.8 -r1.8.4.1
--- Makefile.am	2001/02/19 23:10:42	1.8
+++ Makefile.am	2001/12/15 15:26:34	1.8.4.1
@@ -4,11 +4,12 @@
 
 bin_PROGRAMS = vorbiscomment
 
-INCLUDES = @OGG_CFLAGS@ @VORBIS_CFLAGS@
+INCLUDES = @OGG_CFLAGS@ @VORBIS_CFLAGS@ -I$(top_srcdir)/include
 
-vorbiscomment_LDADD = @VORBIS_LIBS@ @OGG_LIBS@
+vorbiscomment_LDADD = @VORBIS_LIBS@ @OGG_LIBS@ @LIBICONV@ @SHARE_LIBS@
+vorbiscomment_DEPENDENCIES = @SHARE_LIBS@
 
-vorbiscomment_SOURCES = vcedit.c vcedit.h vcomment.c getopt.c getopt.h getopt1.c
+vorbiscomment_SOURCES = vcedit.c vcedit.h vcomment.c
 
 debug:
         $(MAKE) all CFLAGS="@DEBUG@"

1.10.4.1  +196 -56   vorbis-tools/vorbiscomment/vcedit.c

Index: vcedit.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/vorbiscomment/vcedit.c,v
retrieving revision 1.10
retrieving revision 1.10.4.1
diff -u -r1.10 -r1.10.4.1
--- vcedit.c	2001/03/04 06:01:27	1.10
+++ vcedit.c	2001/12/15 15:26:34	1.10.4.1
@@ -6,7 +6,7 @@
  *
  * Comment editing backend, suitable for use by nice frontend interfaces.
  *
- * last modified: $Id: vcedit.c,v 1.10 2001/03/04 06:01:27 msmith Exp $
+ * last modified: $Id: vcedit.c,v 1.10.4.1 2001/12/15 15:26:34 volsung Exp $
  */
 
 #include <stdio.h>
@@ -57,6 +57,11 @@
                 free(state->oy);
                 state->oy=NULL;
         }
+	if(state->vendor)
+	{
+		free(state->vendor);
+		state->vendor=NULL;
+	}
 }
 
 void vcedit_clear(vcedit_state *state)
@@ -68,6 +73,109 @@
         }
 }
 
+/* Next two functions pulled straight from libvorbis, apart from one change
+ * - we don't want to overwrite the vendor string.
+ */
+static void _v_writestring(oggpack_buffer *o,char *s, int len)
+{
+	while(len--)
+	{
+		oggpack_write(o,*s++,8);
+	}
+}
+
+static int _commentheader_out(vorbis_comment *vc, char *vendor, ogg_packet *op)
+{
+	oggpack_buffer opb;
+
+	oggpack_writeinit(&opb);
+
+	/* preamble */  
+	oggpack_write(&opb,0x03,8);
+	_v_writestring(&opb,"vorbis", 6);
+
+	/* vendor */
+	oggpack_write(&opb,strlen(vendor),32);
+	_v_writestring(&opb,vendor, strlen(vendor));
+
+	/* 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], 
+                        vc->comment_lengths[i]);
+			}else{
+				oggpack_write(&opb,0,32);
+			}
+		}
+	}
+	oggpack_write(&opb,1,1);
+
+	op->packet = _ogg_malloc(oggpack_bytes(&opb));
+	memcpy(op->packet, opb.buffer, oggpack_bytes(&opb));
+
+	op->bytes=oggpack_bytes(&opb);
+	op->b_o_s=0;
+	op->e_o_s=0;
+	op->granulepos=0;
+
+	return 0;
+}
+
+static int _blocksize(vcedit_state *s, ogg_packet *p)
+{
+	int this = vorbis_packet_blocksize(&s->vi, p);
+	int ret = (this + s->prevW)/4;
+
+	if(!s->prevW)
+	{
+		s->prevW = this;
+		return 0;
+	}
+
+	s->prevW = this;
+	return ret;
+}
+
+static int _fetch_next_packet(vcedit_state *s, ogg_packet *p, ogg_page *page)
+{
+	int result;
+	char *buffer;
+	int bytes;
+
+	result = ogg_stream_packetout(s->os, p);
+
+	if(result > 0)
+		return 1;
+	else
+	{
+		if(s->eosin)
+			return 0;
+		while(ogg_sync_pageout(s->oy, page) <= 0)
+		{
+			buffer = ogg_sync_buffer(s->oy, CHUNKSIZE);
+			bytes = s->read(buffer,1, CHUNKSIZE, s->in);
+			ogg_sync_wrote(s->oy, bytes);
+			if(bytes == 0) 
+				return 0;
+		}
+		if(ogg_page_eos(page))
+			s->eosin = 1;
+		else if(ogg_page_serialno(page) != s->serial)
+		{
+			s->eosin = 1;
+			s->extrapage = 1;
+			return 0;
+		}
+
+		ogg_stream_pagein(s->os, page);
+		return _fetch_next_packet(s, p, page);
+	}
+}
+
 int vcedit_open(vcedit_state *state, FILE *in)
 {
         return vcedit_open_callbacks(state, (void *)in, 
@@ -85,9 +193,7 @@
         ogg_packet  header_comments;
         ogg_packet	header_codebooks;
         ogg_page    og;
-	vorbis_info vi;
 
-
         state->in = in;
         state->read = read_func;
         state->write = write_func;
@@ -114,7 +220,7 @@
         state->os = malloc(sizeof(ogg_stream_state));
         ogg_stream_init(state->os, state->serial);
 
-	vorbis_info_init(&vi);
+	vorbis_info_init(&state->vi);
 
         state->vc = malloc(sizeof(vorbis_comment));
         vorbis_comment_init(state->vc);
@@ -131,7 +237,7 @@
                 goto err;
         }
 
-	if(vorbis_synthesis_headerin(&vi, state->vc, &header_main) < 0)
+	if(vorbis_synthesis_headerin(&state->vi, state->vc, &header_main) < 0)
         {
                 state->lasterror = "Ogg bitstream does not contain vorbis data.";
                 goto err;
@@ -159,7 +265,7 @@
                                                 state->lasterror = "Corrupt secondary header.";
                                                 goto err;
                                         }
-					vorbis_synthesis_headerin(&vi, state->vc, header);
+					vorbis_synthesis_headerin(&state->vi, state->vc, header);
                                         if(i==1)
                                         {
                                                 state->booklen = header->bytes;
@@ -183,8 +289,11 @@
                 ogg_sync_wrote(state->oy, bytes);
         }
 
+	/* Copy the vendor tag */
+	state->vendor = malloc(strlen(state->vc->vendor) +1);
+	strcpy(state->vendor, state->vc->vendor);
+
         /* Headers are done! */
-	vorbis_info_clear(&vi);
         return 0;
 
 err:
@@ -201,10 +310,15 @@
 
         ogg_page ogout, ogin;
         ogg_packet op;
+	ogg_int64_t granpos = 0;
         int result;
         char *buffer;
-	int bytes, eosin=0, eosout=0;
+	int bytes;
+	int needflush=0, needout=0;
 
+	state->eosin = 0;
+	state->extrapage = 0;
+
         header_main.bytes = state->mainlen;
         header_main.packet = state->mainbuf;
         header_main.b_o_s = 1;
@@ -219,7 +333,7 @@
 
         ogg_stream_init(&streamout, state->serial);
 
-	vorbis_commentheader_out(state->vc, &header_comments);
+	_commentheader_out(state->vc, state->vendor, &header_comments);
 
         ogg_stream_packetin(&streamout, &header_main);
         ogg_stream_packetin(&streamout, &header_comments);
@@ -235,62 +349,88 @@
                         goto cleanup;
         }
 
-	while(!eosout)
+	while(_fetch_next_packet(state, &op, &ogin))
         {
-		while(!eosout)
+		int size;
+		size = _blocksize(state, &op);
+		granpos += size;
+
+		if(needflush)
                 {
-			result = ogg_sync_pageout(state->oy, &ogin);
-			if(result==0) break; /* Need more data... */
-			else if(result ==-1)
-				continue;
-			else
+			if(ogg_stream_flush(&streamout, &ogout))
                         {
-				ogg_stream_pagein(state->os, &ogin);
-	
-				while(1)
-				{
-					result = ogg_stream_packetout(state->os, &op);
-					if(result==0)break;
-					else if(result==-1)
-						continue;
-					else
-					{
-						ogg_stream_packetin(&streamout, &op);
-	
-						while(!eosout)
-						{
-							int result=ogg_stream_pageout(&streamout, &ogout);
-							if(result==0)break;
-	
-							if(state->write(ogout.header,1,ogout.header_len, 
-										out) != (size_t) ogout.header_len)
-								goto cleanup;
-							if(state->write(ogout.body,1,ogout.body_len, 
-										out) != (size_t) ogout.body_len)
-								goto cleanup;
-	
-							if(ogg_page_eos(&ogout)) eosout=1;
-						}
-					}
-				}
-				if(ogg_page_eos(&ogin)) eosin = 1;
+				if(state->write(ogout.header,1,ogout.header_len, 
+							out) != (size_t) ogout.header_len)
+					goto cleanup;
+				if(state->write(ogout.body,1,ogout.body_len, 
+							out) != (size_t) ogout.body_len)
+					goto cleanup;
                         }
                 }
-		if(!eosin)
+		else if(needout)
                 {
-			buffer = ogg_sync_buffer(state->oy, CHUNKSIZE);
-			bytes = state->read(buffer,1, CHUNKSIZE, state->in);
-			ogg_sync_wrote(state->oy, bytes);
-			if(bytes == 0) 
+			if(ogg_stream_pageout(&streamout, &ogout))
                         {
-				eosin = 1;
-				break;
+				if(state->write(ogout.header,1,ogout.header_len, 
+							out) != (size_t) ogout.header_len)
+					goto cleanup;
+				if(state->write(ogout.body,1,ogout.body_len, 
+							out) != (size_t) ogout.body_len)
+					goto cleanup;
                         }
                 }
+
+		needflush=needout=0;
+
+		if(op.granulepos == -1)
+		{
+			op.granulepos = granpos;
+			ogg_stream_packetin(&streamout, &op);
+		}
+		else /* granulepos is set, validly. Use it, and force a flush to 
+				account for shortened blocks (vcut) when appropriate */ 
+		{
+			if(granpos > op.granulepos)
+			{
+				granpos = op.granulepos;
+				ogg_stream_packetin(&streamout, &op);
+				needflush=1;
+			}
+			else 
+			{
+				ogg_stream_packetin(&streamout, &op);
+				needout=1;
+			}
+		}		
+	}
+
+	streamout.e_o_s = 1;
+	while(ogg_stream_flush(&streamout, &ogout))
+	{
+		if(state->write(ogout.header,1,ogout.header_len, 
+					out) != (size_t) ogout.header_len)
+			goto cleanup;
+		if(state->write(ogout.body,1,ogout.body_len, 
+					out) != (size_t) ogout.body_len)
+			goto cleanup;
+	}
+
+	/* FIXME: freeing this here probably leaks memory */
+	/* Done with this, now */
+	vorbis_info_clear(&state->vi);
+
+	if (state->extrapage)
+	{
+		if(state->write(ogin.header,1,ogin.header_len,
+		                out) != (size_t) ogin.header_len)
+			goto cleanup;
+		if (state->write(ogin.body,1,ogin.body_len, out) !=
+				(size_t) ogin.body_len)
+			goto cleanup;
         }
 
-	eosin=0; /* clear it, because not all paths to here do */
-	while(!eosin) /* We reached eos, not eof */
+	state->eosin=0; /* clear it, because not all paths to here do */
+	while(!state->eosin) /* We reached eos, not eof */
         {
                 /* We copy the rest of the stream (other logical streams)
                  * through, a page at a time. */
@@ -317,7 +457,7 @@
                 ogg_sync_wrote(state->oy, bytes);
                 if(bytes == 0) 
                 {
-			eosin = 1;
+			state->eosin = 1;
                         break;
                 }
         }
@@ -331,7 +471,7 @@
         free(state->bookbuf);
 
         vcedit_clear_internals(state);
-	if(!(eosin && eosout))
+	if(!state->eosin)
         {
                 state->lasterror =  
                         "Error writing stream to output. "

1.5.4.1   +5 -0      vorbis-tools/vorbiscomment/vcedit.h

Index: vcedit.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/vorbiscomment/vcedit.h,v
retrieving revision 1.5
retrieving revision 1.5.4.1
diff -u -r1.5 -r1.5.4.1
--- vcedit.h	2001/03/04 06:01:27	1.5
+++ vcedit.h	2001/12/15 15:26:34	1.5.4.1
@@ -27,6 +27,7 @@
         ogg_stream_state	*os;
 
         vorbis_comment		*vc;
+	vorbis_info          vi;
 
         vcedit_read_func read;
         vcedit_write_func write;
@@ -38,6 +39,10 @@
         int		mainlen;
         int		booklen;
         char 	    *lasterror;
+	char   *vendor;
+	int prevW;
+	int extrapage;
+	int eosin;
 } vcedit_state;
 
 extern vcedit_state *	vcedit_new_state(void);

1.6.4.1   +95 -20    vorbis-tools/vorbiscomment/vcomment.c

Index: vcomment.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/vorbiscomment/vcomment.c,v
retrieving revision 1.6
retrieving revision 1.6.4.1
diff -u -r1.6 -r1.6.4.1
--- vcomment.c	2001/02/10 06:26:22	1.6
+++ vcomment.c	2001/12/15 15:26:34	1.6.4.1
@@ -12,7 +12,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include <getopt.h>
+#include <locale.h>
+#include "getopt.h"
+#include "utf8.h"
 
 #include "vcedit.h"
 
@@ -32,11 +34,15 @@
         char	*infilename, *outfilename;
         char	*commentfilename;
         FILE	*in, *out, *com;
+	int commentcount;
+	char **comments;
+	int tempoutfile;
 } param_t;
 
 #define MODE_NONE  0
 #define MODE_LIST  1
 #define MODE_WRITE 2
+#define MODE_APPEND 3
 
 /* prototypes */
 void usage(void);
@@ -66,6 +72,7 @@
         vcedit_state *state;
         vorbis_comment *vc;
         param_t	*param;
+	int i;
 
         /* initialize the cmdline interface */
         param = new_param();
@@ -99,7 +106,7 @@
                 return 0;		
         }
 
-	if (param->mode == MODE_WRITE) {
+	if (param->mode == MODE_WRITE || param->mode == MODE_APPEND) {
 
                 state = vcedit_new_state();
 
@@ -112,10 +119,20 @@
 
                 /* grab and clear the exisiting comments */
                 vc = vcedit_comments(state);
-		vorbis_comment_clear(vc);
-		vorbis_comment_init(vc);
+		if(param->mode != MODE_APPEND) 
+		{
+			vorbis_comment_clear(vc);
+			vorbis_comment_init(vc);
+		}
+
+		for(i=0; i < param->commentcount; i++)
+		{
+			if(add_comment(param->comments[i], vc) < 0)
+				fprintf(stderr, "Bad comment: \"%s\"\n", param->comments[i]);
+		}
 
                 /* build the replacement structure */
+		if(param->commentcount==0)
                 {
                         /* FIXME should use a resizeable buffer! */
                         char *buf = (char *)malloc(sizeof(char)*1024);
@@ -162,16 +179,25 @@
 void print_comments(FILE *out, vorbis_comment *vc)
 {
         int i;
+    char *decoded_value;
 
         for (i = 0; i < vc->comments; i++)
-		fprintf(out, "%s\n", vc->user_comments[i]);
+    {
+	    if (utf8_decode(vc->user_comments[i], &decoded_value) >= 0)
+        {
+    		fprintf(out, "%s\n", decoded_value);
+            free(decoded_value);
+        }
+        else
+            fprintf(out, "%s\n", vc->user_comments[i]);
+    }
 }
 
 /**********
 
-   Take a line of the form "TAG=value string", parse it,
-   and add it to the vorbis_comment structure. Error checking
-   is performed.
+   Take a line of the form "TAG=value string", parse it, convert the
+   value to UTF-8, and add it to the
+   vorbis_comment structure. Error checking is performed.
 
    Note that this assumes a null-terminated string, which may cause
    problems with > 8-bit character sets!
@@ -180,7 +206,7 @@
 
 int  add_comment(char *line, vorbis_comment *vc)
 {
-	char	*mark, *value;
+	char	*mark, *value, *utf8_value;
 
         /* strip any terminal newline */
         {
@@ -193,7 +219,7 @@
          * as the comment spec requires. For the moment, we
          * also restrict ourselves to 0-terminated values */
 
-	mark = index(line, '=');
+	mark = strchr(line, '=');
         if (mark == NULL) return -1;
 
         value = line;
@@ -206,10 +232,18 @@
         *mark = '\0';	
         value++;
 
-	/* append the comment and return */
-	vorbis_comment_add_tag(vc, line, value);
-
-	return 0;
+	/* convert the value from the native charset to UTF-8 */
+	if (utf8_encode(value, &utf8_value) >= 0) {
+		
+		/* append the comment and return */
+		vorbis_comment_add_tag(vc, line, utf8_value);
+        free(utf8_value);
+		return 0;
+	} else {
+		fprintf(stderr, "Couldn't convert comment to UTF8, "
+			"cannot add\n");
+		return -1;
+	}
 }
 
 
@@ -226,10 +260,22 @@
         fprintf(stderr, 
                 "Usage: \n"
                 "  vorbiscomment [-l] file.ogg (to list the comments)\n"
+		"  vorbiscomment -a in.ogg out.ogg (to append comments)\n"
                 "  vorbiscomment -w in.ogg out.ogg (to modify comments)\n"
                 "	in the write case, a new set of comments in the form\n"
                 "	'TAG=value' is expected on stdin. This set will\n"
                 "	completely replace the existing set.\n"
+		"   Either of -a and -w can take only a single filename,\n"
+		"   in which case a temporary file will be used.\n"
+		"   -c can be used to take comments from a specified file\n"
+		"   instead of stdin.\n"
+		"   Example: vorbiscomment -a in.ogg -c comments.txt\n"
+		"   will append the comments in comments.txt to in.ogg\n"
+		"   Finally, you may specify any number of tags to add on\n"
+		"   the command line using the -t option. e.g.\n"
+		"   vorbiscomment -a in.ogg -t \"ARTIST=Some Guy\" -t \"TITLE=A Title\"\n"
+		"   (note that when using this, reading comments from the comment\n"
+		"   file or stdin is disabled)\n"
         ); 
 }
 
@@ -256,6 +302,10 @@
         param->in = param->out = NULL;
         param->com = NULL;
 
+	param->commentcount=0;
+	param->comments=NULL;
+	param->tempoutfile=0;
+
         return param;
 }
 
@@ -272,8 +322,10 @@
 {
         int ret;
         int option_index = 1;
+
+	setlocale(LC_ALL, "");
 
-	while ((ret = getopt_long(argc, argv, "lwhqc:",
+	while ((ret = getopt_long(argc, argv, "alwhqc:t:",
                         long_options, &option_index)) != -1) {
                 switch (ret) {
                         case 0:
@@ -286,6 +338,9 @@
                         case 'w':
                                 param->mode = MODE_WRITE;
                                 break;
+			case 'a':
+				param->mode = MODE_APPEND;
+				break;
                         case 'h':
                                 usage();
                                 exit(0);
@@ -296,6 +351,11 @@
                         case 'c':
                                 param->commentfilename = strdup(optarg);
                                 break;
+			case 't':
+				param->comments = realloc(param->comments, 
+						(param->commentcount+1)*sizeof(char *));
+				param->comments[param->commentcount++] = strdup(optarg);
+				break;
                         default:
                                 usage();
                                 exit(1);
@@ -303,14 +363,26 @@
         }
 
         /* remaining bits must be the filenames */
-	if ((param->mode == MODE_LIST && (argc - optind) != 1) ||
-		(param->mode == MODE_WRITE && (argc - optind) != 2)) {
+	if((param->mode == MODE_LIST && (argc-optind) != 1) ||
+	   ((param->mode == MODE_WRITE || param->mode == MODE_APPEND) &&
+	   ((argc-optind) < 1 || (argc-optind) > 2))) {
                         usage();
                         exit(1);
         }
+
         param->infilename = strdup(argv[optind]);
-	if (param->mode == MODE_WRITE)
-		param->outfilename = strdup(argv[optind+1]);
+	if (param->mode == MODE_WRITE || param->mode == MODE_APPEND)
+	{
+		if(argc-optind == 1)
+		{
+			param->tempoutfile = 1;
+			param->outfilename = malloc(strlen(param->infilename)+8);
+			strcpy(param->outfilename, param->infilename);
+			strcat(param->outfilename, ".vctemp");
+		}
+		else
+			param->outfilename = strdup(argv[optind+1]);
+	}
 }
 
 /**********
@@ -341,7 +413,7 @@
                 exit(1);
         }
 
-	if (p->mode == MODE_WRITE) { 
+	if (p->mode == MODE_WRITE || p->mode == MODE_APPEND) { 
 
                 /* open output for write mode */
 
@@ -407,4 +479,7 @@
         if (p->in != NULL) fclose(p->in);
         if (p->out != NULL) fclose(p->out);
         if (p->com != NULL) fclose(p->com);
+
+	if(p->tempoutfile)
+		rename(p->outfilename, p->infilename);
 }

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list