shithub: aacdec

Download patch

ref: bfa3eb8e2b42be7b4c7bc0c5be7edc32735d2d3a
parent: 502d0c44f4fcbabffa6dfcf90e0b3498005e6389
author: menno <menno>
date: Fri Sep 19 15:08:17 EDT 2003

Fixes in linux compilation

--- a/bootstrap
+++ b/bootstrap
@@ -2,7 +2,7 @@
 
 aclocal -I .
 autoheader
-libtoolize --automake
-automake --add-missing
+libtoolize --automake --copy
+automake --add-missing --copy
 autoconf
 echo "Ready to run ./configure"
--- a/common/mp4v2/Makefile.am
+++ b/common/mp4v2/Makefile.am
@@ -4,6 +4,8 @@
 
 lib_LTLIBRARIES = libmp4v2.la
 
+include_HEADERS = mp4.h mpeg4ip.h
+
 libmp4v2_la_SOURCES = \
     atom_co64.cpp \
     atom_cprt.cpp \
@@ -100,7 +102,6 @@
     mp4file.h \
     mp4file_io.cpp \
     mp4info.cpp \
-    mp4meta.h \
     mp4meta.cpp \
     mp4property.cpp \
     mp4property.h \
@@ -115,7 +116,8 @@
     qosqualifiers.cpp \
     qosqualifiers.h \
     rtphint.cpp \
-    rtphint.h 
+    rtphint.h \
+    systems.h
 
 EXTRA_DIST = API_CHANGES \
     INTERNALS \
--- a/configure.in
+++ b/configure.in
@@ -1,5 +1,5 @@
 AC_INIT()
-AM_INIT_AUTOMAKE(faad,2.0)
+AM_INIT_AUTOMAKE(faad2,2.0)
 
 AM_PROG_LIBTOOL
 AC_SUBST(LIBTOOL_DEPS)
@@ -15,6 +15,7 @@
 
 AM_CONFIG_HEADER(config.h)
 
+AC_ARG_WITH( xmms,[    --with-xmms  compile XMMS plugin],WITHXMMS=$withval, WITHXMMS=no)
 
 dnl Checks for header files required for mp4.h
 AC_HEADER_STDC
@@ -22,6 +23,8 @@
 AC_CHECK_HEADERS(mathf.h)
 AC_CHECK_HEADERS(float.h)
 AC_CHECK_FUNCS(strchr memcpy)
+AC_CHECK_HEADERS(sys/time.h)
+AC_HEADER_TIME
 
 AC_C_INLINE
 AC_C_BIGENDIAN
@@ -69,11 +72,36 @@
   AC_SUBST(MPEG4IP_PLAYER_PLUGIN_DIR)
 else
   AM_CONDITIONAL(HAVE_MPEG4IP, false)
-  AC_OUTPUT_COMMANDS(,[cd common/mp4v2; aclocal -I .; autoheader; libtoolize --automake; automake --add-missing; autoconf; cd -])
 fi
 
-AC_OUTPUT_COMMANDS(,[cd plugins/xmms; libtoolize; aclocal; autoconf; automake --add-missing; cd -])
+if test x$WITHXMMS = xyes; then
+  xmmsplugin=yes
+  AC_CHECK_PROGS(XMMS_CONFIG, xmms-config,"no_found")
+  if test "$XMMS_CONFIG" = "no_found"; then
+   AC_MSG_ERROR("*** xmms-config not found - omitting xmms plugin build")
+   xmmsplugin=no
+   AM_CONDITIONAL(HAVE_XMMS, false)
+  else
+   AM_CONDITIONAL(HAVE_XMMS, true)
+  fi
+else
+ AM_CONDITIONAL(HAVE_XMMS, false)
+ xmmsplugin=no
+fi
 
-AC_CONFIG_SUBDIRS(common/mp4v2 plugins/xmms)
-
-AC_OUTPUT(libfaad/Makefile common/Makefile  frontend/Makefile Makefile plugins/Makefile plugins/mpeg4ip/Makefile)
+if test x$external_mp4v2 = xyes; then
+  if test x$xmmsplugin = xyes; then
+    AC_CONFIG_SUBDIRS(common/mp4v2 plugins/xmms)
+    AC_OUTPUT(libfaad/Makefile common/Makefile frontend/Makefile Makefile plugins/Makefile plugins/mpeg4ip/Makefile plugins/xmms/Makefile plugins/xmms/src/Makefile)
+  else
+    AC_CONFIG_SUBDIRS(common/mp4v2)
+    AC_OUTPUT(libfaad/Makefile common/Makefile  frontend/Makefile Makefile plugins/Makefile plugins/mpeg4ip/Makefile)
+  fi
+else
+  if test x$xmmsplugin = xyes; then
+    AC_CONFIG_SUBDIRS(plugins/xmms)
+    AC_OUTPUT(libfaad/Makefile frontend/Makefile common/Makefile Makefile plugins/Makefile  common/mp4v2/Makefile plugins/xmms/Makefile plugins/xmms/src/Makefile)
+  else
+    AC_OUTPUT(libfaad/Makefile frontend/Makefile common/Makefile Makefile plugins/Makefile common/mp4v2/Makefile)
+  fi
+fi
--- a/frontend/Makefile.am
+++ b/frontend/Makefile.am
@@ -1,6 +1,7 @@
 bin_PROGRAMS = faad
 
-faad_SOURCES = main.c audio.c $(top_srcdir)/common/faad/getopt.c
+faad_SOURCES = main.c audio.c $(top_srcdir)/common/faad/getopt.c \
+   audio.h
 
 AM_CFLAGS = -O2
 if HAVE_MPEG4IP
--- a/libfaad/Makefile.am
+++ b/libfaad/Makefile.am
@@ -7,13 +7,12 @@
 pulse.c specrec.c syntax.c tns.c hcr.c huffman.c \
 rvlc.c ssr.c ssr_fb.c ssr_ipqf.c common.c \
 sbr_dct.c sbr_e_nf.c sbr_fbt.c sbr_hfadj.c sbr_hfgen.c \
-sbr_huff.c sbr_qmf.c sbr_syntax.c sbr_tf_grid.c sbr_dec.c 
-
-libfaad_la_INCLUDES = analysis.h bits.h cfft.h cfft_tab.h common.h \
+sbr_huff.c sbr_qmf.c sbr_syntax.c sbr_tf_grid.c sbr_dec.c \
+analysis.h bits.h cfft.h cfft_tab.h common.h \
 decoder.h dither.h drc.h error.h fixed.h filtbank.h \
 huffman.h ic_predict.h iq_table.h is.h kbd_win.h lt_predict.h mdct.h mp4.h \
 ms.h output.h pns.h pulse.h rvlc.h sine_win.h ssr.h ssr_fb.h ssr_ipqf.h \
-ssr_win.h specrec.h syntax.h tns.h \
+ssr_win.h specrec.h syntax.h structs.h tns.h \
 sbr_dct.h sbr_dec.h sbr_e_nf.h sbr_fbt.h sbr_hfadj.h sbr_hfgen.h \
 sbr_huff.h sbr_noise.h sbr_qmf.h sbr_syntax.h sbr_tf_grid.h \
 codebook/hcb.h \
@@ -22,5 +21,6 @@
 codebook/hcb_9.h codebook/hcb_10.h codebook/hcb_11.h codebook/hcb_sf.h
 
 
-AM_CFLAGS = -O2
-AM_LDFLAGS = -lm
+AM_CFLAGS = -O2 -g
+LDFLAGS = -lm
+
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,5 +1,13 @@
 if HAVE_MPEG4IP
-SUBDIRS = mpeg4ip xmms
+  if HAVE_XMMS
+    SUBDIRS = mpeg4ip xmms
+  else
+    SUBDIRS = mpeg4ip
+  endif
 else
-SUBDIRS = xmms
+  if HAVE_XMMS
+    SUBDIRS = xmms
+  else
+    SUBDIRS =
+  endif
 endif
--- a/plugins/xmms/src/Makefile.am
+++ b/plugins/xmms/src/Makefile.am
@@ -1,12 +1,10 @@
-libdir = `xmms-config --input-plugin-dir`
-
 lib_LTLIBRARIES = libaac.la
 
 if USE_STATIC_FAAD2
-INCLUDES = -I$(top_srcdir)/libfaad-include
-libaac_la_LDFLAGS = -module -avoid-version `xmms-config --libs` -lpthread -lid3 -lstdc++ -lz
-libaac_la_LIBADD = $(top_srcdir)/libfaad/libfaad.la
+  INCLUDES = -I../../../include
+  libaac_la_LDFLAGS = -module -avoid-version `xmms-config --libs` -lpthread -lid3 -lstdc++ -lz
+  libaac_la_LIBADD = ../../../libfaad/libfaad.la
 else
-libaac_la_LDFLAGS = -module -avoid-version `xmms-config --libs` -lpthread -lfaad -lz -lid3 -lstdc++
+  libaac_la_LDFLAGS = -module -avoid-version `xmms-config --libs` -lpthread -lfaad -lz -lid3 -lstdc++
 endif
 libaac_la_SOURCES = libaac.c id3.cpp dialog_gtk1.c aac_utils.c
--- a/plugins/xmms/src/libaac.c
+++ b/plugins/xmms/src/libaac.c
@@ -1,7 +1,7 @@
 /*
-**			  AAC plugin for XMMS 1.2.7
-**				by ciberfred
-**		------------------------------------------------
+**            AAC plugin for XMMS 1.2.7
+**              by ciberfred
+**      ------------------------------------------------
 **
 ** need libfaad2     package from http://www.audiocoding.com
 ** and id3lib-3.8.x  package from http://id3lib.sourceforge.org
@@ -22,29 +22,29 @@
 #include "xmms/titlestring.h"
 #include "aac_utils.h"
 
-#define AAC_DESCRIPTION	"MPEG2/4 AAC player - 1.2.7"
-#define AAC_VERSION	"AAC player - 15 June 2003 (v0.4)"
-#define AAC_ABOUT	"Writen from scratch by ciberfred from France\n"
+#define AAC_DESCRIPTION "MPEG2/4 AAC player - 1.2.7"
+#define AAC_VERSION "AAC player - 15 June 2003 (v0.4)"
+#define AAC_ABOUT   "Writen from scratch by ciberfred from France\n"
 #define PATH2CONFIGFILE "/.xmms/Plugins/aacConfig.txt"
-#define BUFFER_SIZE	FAAD_MIN_STREAMSIZE*64
-
-static void	aac_init(void);
-static void	aac_play(char*);
-static void	aac_stop(void);
-static void	aac_pause(short);
-static int	aac_getTime(void);
-static void	aac_seek(int);
-static void	aac_cleanup(void);
-static void	aac_about(void);
-static void	aac_configuration(void);
-static void	*aac_decode(void*);
+#define BUFFER_SIZE FAAD_MIN_STREAMSIZE*64
 
-static void	aac_getSongInfo(char*);
-static int	aac_isFile(char*);
+static void aac_init(void);
+static void aac_play(char*);
+static void aac_stop(void);
+static void aac_pause(short);
+static int  aac_getTime(void);
+static void aac_seek(int);
+static void aac_cleanup(void);
+static void aac_about(void);
+static void aac_configuration(void);
+static void *aac_decode(void*);
 
-extern void	readID3tag(char*);
+static void aac_getSongInfo(char*);
+static int  aac_isFile(char*);
+
+extern void readID3tag(char*);
 extern GtkWidget *createDialogInfo(void);
-extern void	clearWindowDatas(void);
+extern void clearWindowDatas(void);
 
 static GtkWidget *infoBoxWindow = NULL;
 extern char *title, *artist, *album, *track, *genre;
@@ -57,39 +57,39 @@
 
 InputPlugin aac_ip =
   {
-    0,		// handle
-    0,		// filename
+    0,      // handle
+    0,      // filename
     AAC_DESCRIPTION,// description
-    aac_init,	// init_func
-    aac_about,	// aboutbox
-    aac_configuration,		// configuration
-    aac_isFile,	// ???
-    0,		// scan dir
-    aac_play,	// when play button
-    aac_stop,	// when stop
-    aac_pause,	// when pause
-    aac_seek,	// when seek
-    0,		// set equalizer
-    aac_getTime,	// ???
-    0,		// get volume
-    0,		// set volume
-    aac_cleanup,	// the cleanup function :)
-    0,		// obsolete (???)
-    0,		// send visualisation data
-    0,		// set player window info
-    0,		// set song title text
-    0,	// get song title text to show on Playlist
+    aac_init,   // init_func
+    aac_about,  // aboutbox
+    aac_configuration,      // configuration
+    aac_isFile, // ???
+    0,      // scan dir
+    aac_play,   // when play button
+    aac_stop,   // when stop
+    aac_pause,  // when pause
+    aac_seek,   // when seek
+    0,      // set equalizer
+    aac_getTime,    // ???
+    0,      // get volume
+    0,      // set volume
+    aac_cleanup,    // the cleanup function :)
+    0,      // obsolete (???)
+    0,      // send visualisation data
+    0,      // set player window info
+    0,      // set song title text
+    0,  // get song title text to show on Playlist
     aac_getSongInfo,// file info box
-    0		// pointer to outputPlugin
+    0       // pointer to outputPlugin
   };
-static gboolean 	bPlaying = FALSE;
-static gboolean		bOutputOpen = FALSE;
-static pthread_t	decodeThread;
-static gboolean		bSeek = FALSE;
-static gint		seekPosition = -1; // track position
-static pthread_mutex_t	mutex = PTHREAD_MUTEX_INITIALIZER;
-static unsigned long	*positionTable = 0;
-int			aacType;
+static gboolean     bPlaying = FALSE;
+static gboolean     bOutputOpen = FALSE;
+static pthread_t    decodeThread;
+static gboolean     bSeek = FALSE;
+static gint     seekPosition = -1; // track position
+static pthread_mutex_t  mutex = PTHREAD_MUTEX_INITIALIZER;
+static unsigned long    *positionTable = 0;
+int         aacType;
 /*****************************************************************************/
 
 InputPlugin *get_iplugin_info(void)
@@ -100,7 +100,7 @@
 
 static void aac_init(void)
 {
-  ConfigFile*	cfg;
+  ConfigFile*   cfg;
 
   memset(&decodeThread, 0, sizeof(pthread_t));
   cfg = xmms_cfg_open_default_file();
@@ -169,19 +169,19 @@
 
 static void *aac_decode(void *args)
 {
-  char 			*filename = args;
-  char			*xmmstitle=NULL;
-  FILE 			*file = NULL;
-  faacDecHandle		decoder = 0;
-  unsigned char		*buffer = 0;
-  unsigned long		bufferconsumed = 0;
-  unsigned long		samplerate = 0;
-  unsigned long		lenght=0;
-  char			channels;
-  unsigned long		buffervalid = 0;
-  TitleInput		*input;
-  char 			*temp = g_strdup(filename);
-  char			*ext  = strrchr(temp, '.');
+  char          *filename = args;
+  char          *xmmstitle=NULL;
+  FILE          *file = NULL;
+  faacDecHandle     decoder = 0;
+  unsigned char     *buffer = 0;
+  unsigned long     bufferconsumed = 0;
+  unsigned long     samplerate = 0;
+  unsigned long     lenght=0;
+  char          channels;
+  unsigned long     buffervalid = 0;
+  TitleInput        *input;
+  char          *temp = g_strdup(filename);
+  char          *ext  = strrchr(temp, '.');
 
   pthread_mutex_lock(&mutex);
   seekPosition=-1;
@@ -197,7 +197,7 @@
       g_print("erreur getAAC\n");
       fclose(file);
       if(positionTable){
-	free(positionTable); positionTable=0;
+    free(positionTable); positionTable=0;
       }
       pthread_mutex_unlock(&mutex);
       pthread_exit(NULL);
@@ -250,16 +250,16 @@
     if(bSeek){
       checkADTSForSeeking(file, &positionTable, &lenght);
       if((aacType = getAacInfo(file)) ==-1){
-	printf("erreur getAAC\n");
-	g_free(buffer); buffer=0;
-	faacDecClose(decoder);
-	fclose(file);
-	aac_ip.output->close_audio();
-	if(positionTable){
-	  free(positionTable); positionTable=0;
-	}
-	pthread_mutex_unlock(&mutex);
-	pthread_exit(NULL);
+    printf("erreur getAAC\n");
+    g_free(buffer); buffer=0;
+    faacDecClose(decoder);
+    fclose(file);
+    aac_ip.output->close_audio();
+    if(positionTable){
+      free(positionTable); positionTable=0;
+    }
+    pthread_mutex_unlock(&mutex);
+    pthread_exit(NULL);
       }
       printf("AAC-%s Type\n", aacType?"MPEG2":"MPEG4");
     }
@@ -275,7 +275,7 @@
   g_free(input->genre);
   g_free(input);
 
-  bufferconsumed = faacDecInit(decoder, buffer, &samplerate, &channels);
+  bufferconsumed = faacDecInit(decoder, buffer, buffervalid, &samplerate, &channels);
   if((bOutputOpen = aac_ip.output->open_audio(FMT_S16_NE, samplerate, channels)) == FALSE){
     printf("Output Error\n");
     g_free(buffer); buffer=0;
@@ -293,11 +293,11 @@
   }else{
     aac_ip.set_info(xmmstitle, -1, -1, samplerate, channels);
   }
-  aac_ip.output->flush(0);  
+  aac_ip.output->flush(0);
   while(bPlaying && buffervalid > 0){
-    faacDecFrameInfo	finfo;
-    unsigned long		samplesdecoded;
-    char			*sample_buffer = NULL;
+    faacDecFrameInfo    finfo;
+    unsigned long       samplesdecoded;
+    char            *sample_buffer = NULL;
 
     if(bSeek && seekPosition!=-1){
       fseek(file, positionTable[seekPosition], SEEK_SET);
@@ -312,7 +312,7 @@
       buffervalid += fread(&buffer[buffervalid], 1, BUFFER_SIZE-buffervalid, file);
       bufferconsumed = 0;
     }
-    sample_buffer = faacDecDecode(decoder, &finfo, buffer);
+    sample_buffer = faacDecDecode(decoder, &finfo, buffer, buffervalid);
     if(finfo.error){
       buffervalid = 0;
       printf("FAAD2 Error %s\n", faacDecGetErrorMessage(finfo.error));
@@ -359,19 +359,19 @@
 
 static void aac_about(void)
 {
-  static GtkWidget	*aboutbox;
+  static GtkWidget  *aboutbox;
 
   if(aboutbox!=NULL)
     return;
 
   aboutbox = xmms_show_message(
-		 "About MPEG2/4-AAC plugin",
-		 "decoding engine : FAAD2 team\n"
-		 "Plugin coder : ciberfred",
- 	         "Ok", FALSE, NULL, NULL);
+         "About MPEG2/4-AAC plugin",
+         "decoding engine : FAAD2 team\n"
+         "Plugin coder : ciberfred",
+             "Ok", FALSE, NULL, NULL);
   gtk_signal_connect(GTK_OBJECT(aboutbox), "destroy",
-		     GTK_SIGNAL_FUNC(gtk_widget_destroyed),
-		     &aboutbox);
+             GTK_SIGNAL_FUNC(gtk_widget_destroyed),
+             &aboutbox);
 }
 
 
@@ -379,7 +379,7 @@
 static  GtkWidget *window;
 static void aac_configuration_save(GtkWidget *widget, gpointer data)
 {
-  ConfigFile	*cfg;
+  ConfigFile    *cfg;
   bSeek = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton));
   cfg = xmms_cfg_open_default_file();
   xmms_cfg_write_boolean(cfg, "AAC", "seeking", bSeek);
@@ -387,7 +387,7 @@
   gtk_widget_destroy(window);
 }
 
-static void	aac_configuration(void)
+static void aac_configuration(void)
 {
   GtkWidget *vbox, *hbox;
   GtkWidget *NotaBene;
@@ -395,8 +395,8 @@
 
   window = gtk_window_new(GTK_WINDOW_DIALOG);
   gtk_signal_connect(GTK_OBJECT(window), "destroy",
-		     GTK_SIGNAL_FUNC(gtk_widget_destroyed),
-		     &window);
+             GTK_SIGNAL_FUNC(gtk_widget_destroyed),
+             &window);
   gtk_window_set_title(GTK_WINDOW(window), "AAC Plugin Configuration");
   gtk_widget_set_usize(window, 220, 200);
 
@@ -407,9 +407,9 @@
   GTK_WIDGET_UNSET_FLAGS (NotaBene, GTK_CAN_FOCUS);
   gtk_text_insert(GTK_TEXT(NotaBene), NULL, NULL, NULL,
                    "Remember that unable seeking"
-		   " is not suitable for playing"
-		   " file from network.\n"
-		   "Seeking must read first all aac file before playing.",-1);
+           " is not suitable for playing"
+           " file from network.\n"
+           "Seeking must read first all aac file before playing.",-1);
   gtk_box_pack_start(GTK_BOX(vbox), NotaBene, FALSE, FALSE, 0);
 
   checkbutton = gtk_check_button_new_with_label("Unable Seeking");
@@ -422,13 +422,13 @@
 
   button2 = gtk_button_new_with_label ("Save");
   gtk_signal_connect_object(GTK_OBJECT(button2), "clicked",
-			    GTK_SIGNAL_FUNC(aac_configuration_save),
-			    GTK_OBJECT(window));
+                GTK_SIGNAL_FUNC(aac_configuration_save),
+                GTK_OBJECT(window));
   gtk_box_pack_start(GTK_BOX(hbox), button2, FALSE, FALSE, 0);
   button2 = gtk_button_new_with_label ("Close");
   gtk_signal_connect_object(GTK_OBJECT(button2), "clicked",
-			    GTK_SIGNAL_FUNC(gtk_widget_destroy),
-			    GTK_OBJECT(window));
+                GTK_SIGNAL_FUNC(gtk_widget_destroy),
+                GTK_OBJECT(window));
   gtk_box_pack_start(GTK_BOX(hbox), button2, FALSE, FALSE, 0);
   gtk_widget_show_all(window);
 }