Sophie

Sophie

distrib > * > 2008.0 > x86_64 > by-pkgid > 272b48f491de09f85ebae4bf969500e2 > files > 6

vorbis-tools-1.1.1-5.1mdv2008.0.src.rpm

Index: vorbis-tools-1.1.1/configure.ac
===================================================================
--- vorbis-tools-1.1.1/configure.ac
+++ vorbis-tools-1.1.1/configure.ac	2006-11-30 19:01:11.000000000 +0100
@@ -171,15 +171,25 @@
 if test "x$build_flac" = xyes; then
   AC_CHECK_LIB(m,log,FLAC_LIBS="-lm")
   AC_CHECK_LIB(FLAC, [FLAC__stream_decoder_process_single],
-    [have_libFLAC=yes; FLAC_LIBS="-lFLAC $FLAC_LIBS"],
+    [have_libFLAC=yes; FLAC_LIBS="-lFLAC $FLAC_LIBS $OGG_LIBS"],
     AC_MSG_WARN([libFLAC missing])
-    have_libFLAC=no, [$FLAC_LIBS]
-  )
-  AC_CHECK_LIB(OggFLAC, [OggFLAC__stream_decoder_new],
-    [FLAC_LIBS="-lOggFLAC $FLAC_LIBS $OGG_LIBS"],
-    AC_MSG_WARN([libOggFLAC missing])
     have_libFLAC=no, [$FLAC_LIBS $OGG_LIBS]
   )
+
+  # in FLAC-1.1.3, libOggFLAC was merged into libFLAC
+  # FLAC_API_VERSION_CURRENT first appears in FLAC-1.1.3
+  AC_TRY_RUN([
+#include <FLAC/export.h>
+int main () { return FLAC_API_VERSION_CURRENT<8; }
+],legacy_flac=no,legacy_flac=yes,legacy_flac=no)
+
+  if test "x$legacy_flac" = xyes; then
+    AC_CHECK_LIB(OggFLAC, [OggFLAC__stream_decoder_new],
+      [FLAC_LIBS="-lOggFLAC $FLAC_LIBS"],
+      AC_MSG_WARN([libOggFLAC missing])
+      have_libFLAC=no, [$FLAC_LIBS]
+    )
+  fi
   AC_CHECK_HEADER(FLAC/stream_decoder.h,,
     AC_MSG_WARN(libFLAC headers missing)
     have_libFLAC=no,[ ])
@@ -192,6 +202,7 @@
   fi
 fi
 AM_CONDITIONAL(HAVE_LIBFLAC, test "x$have_libFLAC" = "xyes")
+AM_CONDITIONAL(LEGACY_FLAC, test "x$legacy_flac" = "xyes")
 AC_SUBST(FLAC_LIBS)
 
 dnl ------------------- Speex ------------------------
Index: vorbis-tools-1.1.1/ogg123/Makefile.am
===================================================================
--- vorbis-tools-1.1.1/ogg123/Makefile.am
+++ vorbis-tools-1.1.1/ogg123/Makefile.am	2006-11-30 19:01:11.000000000 +0100
@@ -1,7 +1,11 @@
 ## Process this file with automake to produce Makefile.in
 if HAVE_LIBFLAC
+if LEGACY_FLAC
 flac_sources = flac_format.c easyflac.c easyflac.h 
 else
+flac_sources = flac_format.c
+endif
+else
 flac_sources =
 endif
 if HAVE_LIBSPEEX
Index: vorbis-tools-1.1.1/ogg123/flac_format.c
===================================================================
--- vorbis-tools-1.1.1/ogg123/flac_format.c
+++ vorbis-tools-1.1.1/ogg123/flac_format.c	2006-11-30 19:01:11.000000000 +0100
@@ -25,13 +25,23 @@
 #include "audio.h"
 #include "format.h"
 #include "i18n.h"
+#if !defined(FLAC_API_VERSION_CURRENT) || (FLAC_API_VERSION_CURRENT < 8)
+#define NEED_EASYFLAC 1
+#endif
+#if NEED_EASYFLAC
 #include "easyflac.h"
+#else
+#include <FLAC/stream_decoder.h>
+#endif
 #include "vorbis_comments.h"
 
-#define DEFAULT_FLAC_FRAME_SIZE 4608
-
 typedef struct {
+#if NEED_EASYFLAC
   EasyFLAC__StreamDecoder *decoder;
+#else
+  FLAC__StreamDecoder *decoder;
+  int is_oggflac;
+#endif
   short channels;
   int rate;
   int bits_per_sample;
@@ -67,10 +77,18 @@
 
 
 /* Private functions declarations */
-FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
-FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
-void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
-void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
+#if NEED_EASYFLAC
+static FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
+static FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
+static void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
+static void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
+#else
+static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
+static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
+static void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
+static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
+static FLAC__bool eof_callback(const FLAC__StreamDecoder *decoder, void *client_data);
+#endif
 
 void resize_buffer(flac_private_t *flac, int newchannels, int newsamples);
 /*void copy_comments (vorbis_comment *v_comments, FLAC__StreamMetadata_VorbisComment *f_comments);*/
@@ -155,6 +173,7 @@
   private->buf_start = 0;
   
   /* Setup FLAC decoder */
+#if NEED_EASYFLAC
   if (oggflac_can_decode(source)) {
     decoder->format = &oggflac_format;
     private->decoder = EasyFLAC__stream_decoder_new(1);
@@ -172,13 +191,39 @@
   EasyFLAC__set_metadata_respond(private->decoder, FLAC__METADATA_TYPE_STREAMINFO);
   EasyFLAC__set_metadata_respond(private->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
   EasyFLAC__init(private->decoder);
+#else
+  if (oggflac_can_decode(source)) {
+    private->is_oggflac = 1;
+    decoder->format = &oggflac_format;
+  } else {
+    private->is_oggflac = 0;
+    decoder->format = &flac_format;
+  }
+  private->decoder = FLAC__stream_decoder_new();
+
+  FLAC__stream_decoder_set_md5_checking(private->decoder, false);
+  FLAC__stream_decoder_set_metadata_respond(private->decoder, FLAC__METADATA_TYPE_STREAMINFO);
+  FLAC__stream_decoder_set_metadata_respond(private->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
+  if(private->is_oggflac)
+    FLAC__stream_decoder_init_ogg_stream(private->decoder, read_callback, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, eof_callback, write_callback, metadata_callback, error_callback, decoder);
+  else
+    FLAC__stream_decoder_init_stream(private->decoder, read_callback, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, eof_callback, write_callback, metadata_callback, error_callback, decoder);
+#endif
   
   /* Callback will set the total samples and sample rate */
+#if NEED_EASYFLAC
   EasyFLAC__process_until_end_of_metadata(private->decoder);
+#else
+  FLAC__stream_decoder_process_until_end_of_metadata(private->decoder);
+#endif
 
   /* Callback will set the number of channels and resize the 
      audio buffer */
+#if NEED_EASYFLAC
   EasyFLAC__process_single(private->decoder);
+#else
+  FLAC__stream_decoder_process_single(private->decoder);
+#endif
 
   /* FLAC API returns signed samples on all streams */
   decoder->actual_fmt.signed_sample = 1;
@@ -241,11 +286,19 @@
       realsamples += copy;
     }
     else if (!priv->eos) {
+#if NEED_EASYFLAC
       ret = EasyFLAC__process_single(priv->decoder);
       if (!ret ||
 	  EasyFLAC__get_state(priv->decoder)
 	  == FLAC__STREAM_DECODER_END_OF_STREAM)
 	priv->eos = 1;  /* Bail out! */
+#else
+      ret = FLAC__stream_decoder_process_single(priv->decoder);
+      if (!ret ||
+	  FLAC__stream_decoder_get_state(priv->decoder)
+	  == FLAC__STREAM_DECODER_END_OF_STREAM)
+	priv->eos = 1;  /* Bail out! */
+#endif
     } else
       break;
   }
@@ -311,8 +364,13 @@
     free(priv->buf[i]);
   
   free(priv->buf);
+#if NEED_EASYFLAC
   EasyFLAC__finish(priv->decoder);
   EasyFLAC__stream_decoder_delete(priv->decoder);
+#else
+  FLAC__stream_decoder_finish(priv->decoder);
+  FLAC__stream_decoder_delete(priv->decoder);
+#endif
 
   free(decoder->private);
   free(decoder);
@@ -342,7 +400,11 @@
 
 
 
+#if NEED_EASYFLAC
 FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data)
+#else
+FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
+#endif
 {
   decoder_t *e_decoder = client_data;
   flac_private_t *priv = e_decoder->private;
@@ -363,7 +425,11 @@
 }
 
 
+#if NEED_EASYFLAC
 FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
+#else
+FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
+#endif
 {
   decoder_t *e_decoder = client_data;
   flac_private_t *priv = e_decoder->private;
@@ -389,7 +455,11 @@
 }
 
 
+#if NEED_EASYFLAC
 void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
+#else
+void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
+#endif
 {
   decoder_t *e_decoder = client_data;
   flac_private_t *priv = e_decoder->private;
@@ -409,12 +479,24 @@
 }
 
 
+#if NEED_EASYFLAC
 void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
+#else
+void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
+#endif
 {
 
 
 }
 
+#if !NEED_EASYFLAC
+FLAC__bool eof_callback(const FLAC__StreamDecoder *decoder, void *client_data)
+{
+  // can't get this info from the data source, so we'll let the read callback handle it
+  return false;
+}
+#endif
+
 
 void resize_buffer(flac_private_t *flac, int newchannels, int newsamples)
 {
@@ -457,7 +539,11 @@
     
 
   
+#if NEED_EASYFLAC
   if (EasyFLAC__is_oggflac(priv->decoder))
+#else
+  if (priv->is_oggflac)
+#endif
     cb->printf_metadata(decoder->callback_arg, 2,
 			_("Ogg FLAC stream: %d bits, %d channel, %ld Hz"),
 			priv->bits_per_sample,
Index: vorbis-tools-1.1.1/oggenc/Makefile.am
===================================================================
--- vorbis-tools-1.1.1/oggenc/Makefile.am
+++ vorbis-tools-1.1.1/oggenc/Makefile.am	2006-11-30 19:01:11.000000000 +0100
@@ -1,7 +1,11 @@
 ## Process this file with automake to produce Makefile.in
 if HAVE_LIBFLAC
+if LEGACY_FLAC
 flac_sources = flac.c flac.h easyflac.c easyflac.h
 else
+flac_sources = flac.c flac.h
+endif
+else
 flac_sources =
 endif
 
Index: vorbis-tools-1.1.1/oggenc/flac.c
===================================================================
--- vorbis-tools-1.1.1/oggenc/flac.c
+++ vorbis-tools-1.1.1/oggenc/flac.c	2006-11-30 19:01:11.000000000 +0100
@@ -20,15 +20,21 @@
 #include "platform.h"
 #include "resample.h"
 
-#define DEFAULT_FLAC_FRAME_SIZE 4608
+#if NEED_EASYFLAC
+static FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
+static FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
+static void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
+static void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
+#else
+static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data);
+static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
+static void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
+static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
+static FLAC__bool eof_callback(const FLAC__StreamDecoder *decoder, void *client_data);
+#endif
 
-FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data);
-FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
-void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
-void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
-
-void resize_buffer(flacfile *flac, int newchannels, int newsamples);
-void copy_comments (vorbis_comment *v_comments, FLAC__StreamMetadata_VorbisComment *f_comments);
+static void resize_buffer(flacfile *flac, int newchannels, int newsamples);
+static void copy_comments (vorbis_comment *v_comments, FLAC__StreamMetadata_VorbisComment *f_comments);
 
 
 int flac_id(unsigned char *buf, int len)
@@ -76,6 +82,7 @@
 	flac->in = in;
 
 	/* Setup FLAC decoder */
+#if NEED_EASYFLAC
 	flac->decoder = EasyFLAC__stream_decoder_new(oggflac_id(oldbuf, buflen));
 	EasyFLAC__set_client_data(flac->decoder, flac);
 	EasyFLAC__set_read_callback(flac->decoder, &easyflac_read_callback);
@@ -85,13 +92,31 @@
 	EasyFLAC__set_metadata_respond(flac->decoder, FLAC__METADATA_TYPE_STREAMINFO);
 	EasyFLAC__set_metadata_respond(flac->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
 	EasyFLAC__init(flac->decoder);
+#else
+	flac->decoder = FLAC__stream_decoder_new();
+	FLAC__stream_decoder_set_md5_checking(flac->decoder, false);
+	FLAC__stream_decoder_set_metadata_respond(flac->decoder, FLAC__METADATA_TYPE_STREAMINFO);
+	FLAC__stream_decoder_set_metadata_respond(flac->decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
+	if(oggflac_id(oldbuf, buflen))
+		FLAC__stream_decoder_init_ogg_stream(flac->decoder, read_callback, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, eof_callback, write_callback, metadata_callback, error_callback, flac);
+	else
+		FLAC__stream_decoder_init_stream(flac->decoder, read_callback, /*seek_callback=*/0, /*tell_callback=*/0, /*length_callback=*/0, eof_callback, write_callback, metadata_callback, error_callback, flac);
+#endif
 	
 	/* Callback will set the total samples and sample rate */
+#if NEED_EASYFLAC
 	EasyFLAC__process_until_end_of_metadata(flac->decoder);
+#else
+	FLAC__stream_decoder_process_until_end_of_metadata(flac->decoder);
+#endif
 
 	/* Callback will set the number of channels and resize the 
 	   audio buffer */
+#if NEED_EASYFLAC
 	EasyFLAC__process_single(flac->decoder);
+#else
+	FLAC__stream_decoder_process_single(flac->decoder);
+#endif
 	
 	/* Copy format info for caller */
 	opt->rate = flac->rate;
@@ -133,11 +158,19 @@
 		}
 		else if (!flac->eos)
 		{
+#if NEED_EASYFLAC
 			ret = EasyFLAC__process_single(flac->decoder);
 			if (!ret ||
 			    EasyFLAC__get_state(flac->decoder)
 			    == FLAC__STREAM_DECODER_END_OF_STREAM)
 				flac->eos = 1;  /* Bail out! */
+#else
+			ret = FLAC__stream_decoder_process_single(flac->decoder);
+			if (!ret ||
+			    FLAC__stream_decoder_get_state(flac->decoder)
+			    == FLAC__STREAM_DECODER_END_OF_STREAM)
+				flac->eos = 1;  /* Bail out! */
+#endif
 		} else
 			break;
 	}
@@ -157,13 +190,22 @@
 	free(flac->buf);
 	free(flac->oldbuf);
 	free(flac->comments);
+#if NEED_EASYFLAC
 	EasyFLAC__finish(flac->decoder);
 	EasyFLAC__stream_decoder_delete(flac->decoder);
+#else
+	FLAC__stream_decoder_finish(flac->decoder);
+	FLAC__stream_decoder_delete(flac->decoder);
+#endif
 	free(flac);
 }
 
 
+#if NEED_EASYFLAC
 FLAC__StreamDecoderReadStatus easyflac_read_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data)
+#else
+FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data)
+#endif
 {
 	flacfile *flac = (flacfile *) client_data;
 	int i = 0;
@@ -200,7 +242,11 @@
 	return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;	 
 }
 
+#if NEED_EASYFLAC
 FLAC__StreamDecoderWriteStatus easyflac_write_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
+#else
+FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data)
+#endif
 {
 	flacfile *flac = (flacfile *) client_data;
 	int samples = frame->header.blocksize;
@@ -221,7 +267,11 @@
 	return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
 }
 
+#if NEED_EASYFLAC
 void easyflac_metadata_callback(const EasyFLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
+#else
+void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data)
+#endif
 {
 	flacfile *flac = (flacfile *) client_data;
 
@@ -240,11 +290,24 @@
 	}
 }
 
+#if NEED_EASYFLAC
 void easyflac_error_callback(const EasyFLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
+#else
+void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
+#endif
+{
+	flacfile *flac = (flacfile *) client_data;
+
+}
+
+#if !NEED_EASYFLAC
+FLAC__bool eof_callback(const FLAC__StreamDecoder *decoder, void *client_data)
 {
 	flacfile *flac = (flacfile *) client_data;
 
+	return feof(flac->in)? true : false;
 }
+#endif
 
 
 void resize_buffer(flacfile *flac, int newchannels, int newsamples)
@@ -292,4 +355,3 @@
 		free(comment);
 	}
 }
-
Index: vorbis-tools-1.1.1/oggenc/flac.h
===================================================================
--- vorbis-tools-1.1.1/oggenc/flac.h
+++ vorbis-tools-1.1.1/oggenc/flac.h	2006-11-30 19:01:11.000000000 +0100
@@ -5,10 +5,21 @@
 #include "encode.h"
 #include "audio.h"
 #include <stdio.h>
+#include <FLAC/stream_decoder.h>
+#if !defined(FLAC_API_VERSION_CURRENT) || (FLAC_API_VERSION_CURRENT < 8)
+#include <OggFLAC/stream_decoder.h>
+#define NEED_EASYFLAC 1
+#endif
+#if NEED_EASYFLAC
 #include "easyflac.h"
+#endif
 
 typedef struct {
+#if NEED_EASYFLAC
 	EasyFLAC__StreamDecoder *decoder;
+#else
+	FLAC__StreamDecoder *decoder;
+#endif
 	short channels;
 	int rate;
 	long totalsamples; /* per channel, of course */