changeset 9321:6fa743f3094b

libfaad2 v1.0, v1.1, v1.2 detection, and API change workaround in ad_faad.c based on patch by Andre Schulz <andre@0wnage.de>
author arpi
date Fri, 07 Feb 2003 21:04:35 +0000
parents c5bb811fa7fc
children ac6899c5e320
files configure libmpcodecs/ad_faad.c
diffstat 2 files changed, 44 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/configure	Fri Feb 07 20:11:07 2003 +0000
+++ b/configure	Fri Feb 07 21:04:35 2003 +0000
@@ -3751,7 +3751,7 @@
 echores "$_vorbis"
 
 
-echocheck "FAAD (AAC) support"
+echocheck "faad2 (AAC) support"
 if test "$_faad" = auto ; then
   _faad=no
   cat > $TMPC << EOF
@@ -3766,7 +3766,34 @@
 else
   _def_faad='#undef HAVE_FAAD'
 fi
-echores "$_faad"
+
+if test "$_faad" = yes; then
+cat > $TMPC <<EOF
+#include <faad.h>
+#ifndef FAAD_MIN_STREAMSIZE
+#error Too old version
+#endif
+int main(void) {
+#ifdef FAAD2_VERSION
+  printf("%s",FAAD2_VERSION);
+#else
+  printf("1.0");
+#endif
+  return 0;
+}
+EOF
+  if cc_check $_ld_faad -lm && "$TMPO" >> "$TMPLOG" ; then
+    _faad_version=`"$TMPO"`
+    _faad_tempversion=`"$TMPO" | sed -e 's/^\([0-9]\+\)\.\([0-9]\+\).*/\1\2/'`
+    _def_faad_version="#define FAADVERSION $_faad_tempversion"
+    echores "yes ($_faad_version)"
+  else
+    _faad=no
+    echores "no (failed to get version)"
+  fi
+else
+  echores "$_faad"
+fi
 
 if test "$_win32" = auto ; then
   if x86 ; then
@@ -5251,6 +5278,7 @@
 
 /* enable FAAD (AAC) support */
 $_def_faad
+$_def_faad_version
 
 /* enable streaming */
 $_def_streaming
--- a/libmpcodecs/ad_faad.c	Fri Feb 07 20:11:07 2003 +0000
+++ b/libmpcodecs/ad_faad.c	Fri Feb 07 21:04:35 2003 +0000
@@ -85,8 +85,13 @@
     sh->a_in_buffer_len = demux_read_data(sh->ds, sh->a_in_buffer, sh->a_in_buffer_size);
 
     /* init the codec */
+#if (FAADVERSION <= 11)
     faac_init = faacDecInit(faac_hdec, sh->a_in_buffer,
        &faac_samplerate, &faac_channels);
+#else
+    faac_init = faacDecInit(faac_hdec, sh->a_in_buffer,
+       sh->a_in_buffer_len, &faac_samplerate, &faac_channels);
+#endif
 
     sh->a_in_buffer_len -= (faac_init > 0)?faac_init:0; // how many bytes init consumed
     // XXX FIXME: shouldn't we memcpy() here in a_in_buffer ?? --A'rpi
@@ -164,7 +169,12 @@
   if(!sh->codecdata_len){
    // raw aac stream:
    do {
+#if (FAADVERSION <= 11)
     faac_sample_buffer = faacDecDecode(faac_hdec, &faac_finfo, sh->a_in_buffer+j);
+#else
+    faac_sample_buffer = faacDecDecode(faac_hdec, &faac_finfo, sh->a_in_buffer+j, sh->a_in_buffer_len);
+#endif
+	
     /* update buffer index after faacDecDecode */
     if(faac_finfo.bytesconsumed >= sh->a_in_buffer_len) {
       sh->a_in_buffer_len=0;
@@ -184,7 +194,11 @@
     unsigned char* bufptr=NULL;
     int buflen=ds_get_packet(sh->ds, &bufptr);
     if(buflen<=0) break;
+#if (FAADVERSION <= 11)
     faac_sample_buffer = faacDecDecode(faac_hdec, &faac_finfo, bufptr);
+#else
+    faac_sample_buffer = faacDecDecode(faac_hdec, &faac_finfo, bufptr, buflen);
+#endif
 //    printf("FAAC decoded %d of %d  (err: %d)  \n",faac_finfo.bytesconsumed,buflen,faac_finfo.error);
   }