pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/32059: 64-bit bug and fix for audio/faad2 pkg



>Number:         32059
>Category:       pkg
>Synopsis:       64-bit bug and fix for audio/faad2 pkg
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Nov 12 23:36:00 +0000 2005
>Originator:     Parag Patel
>Release:        NetBSD 2.1.0_STABLE
>Organization:
CodeGen, Inc.
>Environment:
System: NetBSD hammerhead.parag.codegen.com 2.1.0_STABLE NetBSD 2.1.0_STABLE 
(GENERIC) #0: Sat Nov 5 05:11:30 UTC 2005 
parag%hammerhead.parag.codegen.com@localhost:/usr/src/sys/arch/amd64/compile/GENERIC
 amd64
Architecture: x86_64
Machine: amd64
>Description:
        The pkg audio/faad2 fails to run correctly on amd64 and likely on other 
        64-bit systems.  Instead of converting the source m4a file, it fills the
        screen with "Warning: Pulse coding not allowed in short blocks".

>How-To-Repeat:
        Build audio/faad2 on a 64-bit machine, esp. on amd64 and try to run it
        on a known good m4a (AAC) format sound file.

>Fix:
        This seems to be a known problem on Linux/amd64:
            <http://forums.suselinuxsupport.de/index.php?act=ST&f=3&t=16372>
        This pointed to a couple of patches:
            <http://bugs.gentoo.org/attachment.cgi?id=58582&action=view>
        and
            <http://votewithabullet.org:11000/random/patch-faad2-amd64.patch>

        The second patched cleanly and seems to work, with AAC files nicely
        converted to WAV.  I slightly altered the patch so that it would apply
        cleanly under pkgsrc, and I append this patch (and its SHA1 sig) below.

SHA1 (patch-am) = f879880cd86fd01ccfe1d92b7ecfedd16ba78160


diff -urN include/faad.h faad2-patched/include/faad.h
--- include/faad.h      2004-02-06 02:23:28.000000000 -0800
+++ faad2-patched/include/faad.h        2005-07-02 13:03:03.799075488 -0700
@@ -43,6 +43,10 @@
   #endif
 #endif
 
+/* needed for standard integer types */
+#define __STDC_LIMIT_MACROS
+#include <stdint.h>
+
 #define FAAD2_VERSION "2.0     "
 
 /* object types for AAC */
@@ -112,86 +116,86 @@
 typedef struct mp4AudioSpecificConfig
 {
     /* Audio Specific Info */
-    unsigned char objectTypeIndex;
-    unsigned char samplingFrequencyIndex;
-    unsigned long samplingFrequency;
-    unsigned char channelsConfiguration;
+    uint8_t objectTypeIndex;
+    uint8_t samplingFrequencyIndex;
+    uint32_t samplingFrequency;
+    uint8_t channelsConfiguration;
 
     /* GA Specific Info */
-    unsigned char frameLengthFlag;
-    unsigned char dependsOnCoreCoder;
-    unsigned short coreCoderDelay;
-    unsigned char extensionFlag;
-    unsigned char aacSectionDataResilienceFlag;
-    unsigned char aacScalefactorDataResilienceFlag;
-    unsigned char aacSpectralDataResilienceFlag;
-    unsigned char epConfig;
+    uint8_t frameLengthFlag;
+    uint8_t dependsOnCoreCoder;
+    uint16_t coreCoderDelay;
+    uint8_t extensionFlag;
+    uint8_t aacSectionDataResilienceFlag;
+    uint8_t aacScalefactorDataResilienceFlag;
+    uint8_t aacSpectralDataResilienceFlag;
+    uint8_t epConfig;
 
-    char sbr_present_flag;
-    char forceUpSampling;
+    int8_t sbr_present_flag;
+    int8_t forceUpSampling;
 } mp4AudioSpecificConfig;
 
 typedef struct faacDecConfiguration
 {
-    unsigned char defObjectType;
-    unsigned long defSampleRate;
-    unsigned char outputFormat;
-    unsigned char downMatrix;
-    unsigned char useOldADTSFormat;
-    unsigned char dontUpSampleImplicitSBR;
+    uint8_t defObjectType;
+    uint8_t defSampleRate;
+    uint8_t outputFormat;
+    uint8_t downMatrix;
+    uint8_t useOldADTSFormat;
+    uint8_t dontUpSampleImplicitSBR;
 } faacDecConfiguration, *faacDecConfigurationPtr;
 
 typedef struct faacDecFrameInfo
 {
-    unsigned long bytesconsumed;
-    unsigned long samples;
-    unsigned char channels;
-    unsigned char error;
-    unsigned long samplerate;
+    uint32_t bytesconsumed;
+    uint32_t samples;
+    uint8_t channels;
+    uint8_t error;
+    uint32_t samplerate;
 
     /* SBR: 0: off, 1: on; upsample, 2: on; downsampled, 3: off; upsampled */
-    unsigned char sbr;
+    uint8_t sbr;
 
     /* MPEG-4 ObjectType */
-    unsigned char object_type;
+    uint8_t object_type;
 
     /* AAC header type; MP4 will be signalled as RAW also */
-    unsigned char header_type;
+    uint8_t header_type;
 
     /* multichannel configuration */
-    unsigned char num_front_channels;
-    unsigned char num_side_channels;
-    unsigned char num_back_channels;
-    unsigned char num_lfe_channels;
-    unsigned char channel_position[64];
+    uint8_t num_front_channels;
+    uint8_t num_side_channels;
+    uint8_t num_back_channels;
+    uint8_t num_lfe_channels;
+    uint8_t channel_position[64];
 } faacDecFrameInfo;
 
-char* FAADAPI faacDecGetErrorMessage(unsigned char errcode);
+int8_t* FAADAPI faacDecGetErrorMessage(uint8_t errcode);
 
-unsigned long FAADAPI faacDecGetCapabilities(void);
+uint32_t FAADAPI faacDecGetCapabilities(void);
 
 faacDecHandle FAADAPI faacDecOpen(void);
 
 faacDecConfigurationPtr FAADAPI faacDecGetCurrentConfiguration(faacDecHandle 
hDecoder);
 
-unsigned char FAADAPI faacDecSetConfiguration(faacDecHandle hDecoder,
+uint8_t FAADAPI faacDecSetConfiguration(faacDecHandle hDecoder,
                                     faacDecConfigurationPtr config);
 
 /* Init the library based on info from the AAC file (ADTS/ADIF) */
 long FAADAPI faacDecInit(faacDecHandle hDecoder,
-                        unsigned char *buffer,
-                        unsigned long buffer_size,
-                        unsigned long *samplerate,
-                        unsigned char *channels);
+                         uint8_t *buffer,
+                         uint32_t buffer_size,
+                         uint32_t *samplerate,
+                         uint8_t *channels);
 
 /* Init the library using a DecoderSpecificInfo */
-char FAADAPI faacDecInit2(faacDecHandle hDecoder, unsigned char *pBuffer,
-                         unsigned long SizeOfDecoderSpecificInfo,
-                         unsigned long *samplerate, unsigned char *channels);
+int8_t FAADAPI faacDecInit2(faacDecHandle hDecoder, uint8_t *pBuffer,
+                            uint32_t SizeOfDecoderSpecificInfo,
+                            uint32_t *samplerate, uint8_t *channels);
 
 /* Init the library for DRM */
-char FAADAPI faacDecInitDRM(faacDecHandle hDecoder, unsigned long samplerate,
-                            unsigned char channels);
+int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate,
+                              uint8_t channels);
 
 void FAADAPI faacDecPostSeekReset(faacDecHandle hDecoder, long frame);
 
@@ -199,12 +203,12 @@
 
 void* FAADAPI faacDecDecode(faacDecHandle hDecoder,
                             faacDecFrameInfo *hInfo,
-                            unsigned char *buffer,
-                            unsigned long buffer_size);
+                            uint8_t *buffer,
+                            uint32_t buffer_size);
 
-char FAADAPI AudioSpecificConfig(unsigned char *pBuffer,
-                                 unsigned long buffer_size,
-                                 mp4AudioSpecificConfig *mp4ASC);
+int8_t FAADAPI AudioSpecificConfig(uint8_t *pBuffer,
+                                   uint32_t buffer_size,
+                                   mp4AudioSpecificConfig *mp4ASC);
 
 #ifdef _WIN32
   #pragma pack(pop)
diff -urN libfaad/common.h faad2-patched/libfaad/common.h
--- libfaad/common.h    2004-02-06 04:55:24.000000000 -0800
+++ faad2-patched/libfaad/common.h      2005-07-02 13:03:03.799075488 -0700
@@ -197,8 +197,16 @@
 #else
 # if HAVE_STDINT_H
 #  include <stdint.h>
-# else
-/* we need these... */
+# elif defined(__x86_64__)
+typedef unsigned long uint64_t;
+typedef unsigned int uint32_t;
+typedef unsigned short uint16_t;
+typedef unsigned char uint8_t;
+typedef long int64_t;
+typedef int int32_t;
+typedef short int16_t;
+typedef char int8_t;
+#else
 typedef unsigned long long uint64_t;
 typedef unsigned long uint32_t;
 typedef unsigned short uint16_t;
diff -urN plugins/mpeg4ip/aa_file.cpp faad2-patched/plugins/mpeg4ip/aa_file.cpp
--- plugins/mpeg4ip/aa_file.cpp 2004-01-05 06:05:12.000000000 -0800
+++ faad2-patched/plugins/mpeg4ip/aa_file.cpp   2005-07-02 13:03:03.799075488 
-0700
@@ -56,8 +56,8 @@
                  aac->m_buffer_size_max,
                  aac->m_ifile);
 
-  unsigned long freq;
-  unsigned char chans;
+  uint32_t freq;
+  uint8_t chans;
 
   faacDecInit(aac->m_info, (unsigned char *)aac->m_buffer,
           aac->m_buffer_size, &freq, &chans);
diff -urN plugins/mpeg4ip/faad2.cpp faad2-patched/plugins/mpeg4ip/faad2.cpp
--- plugins/mpeg4ip/faad2.cpp   2004-01-05 06:05:12.000000000 -0800
+++ faad2-patched/plugins/mpeg4ip/faad2.cpp     2005-07-02 13:03:03.799075488 
-0700
@@ -76,8 +76,8 @@
   }
 
   aac->m_info = faacDecOpen();
-  unsigned long srate;
-  unsigned char chan;
+  uint32_t srate;
+  uint8_t chan;
   if ((userdata == NULL && fmtp == NULL) ||
       (faacDecInit2(aac->m_info,
              (uint8_t *)userdata,
@@ -156,7 +156,7 @@
                void *userdata)
 {
   aac_codec_t *aac = (aac_codec_t *)ptr;
-  unsigned long bytes_consummed;
+  uint32_t bytes_consummed;
   int bits = -1;
   //  struct timezone tz;
 
@@ -188,8 +188,8 @@
      * If not initialized, do so.
      */
     abort();
-    unsigned long freq;
-    unsigned char chans;
+    uint32_t freq;
+    uint8_t chans;
 
     faacDecInit(aac->m_info,
         (unsigned char *)buffer,
@@ -202,7 +202,7 @@
   }
 
   uint8_t *buff;
-  unsigned long samples;
+  uint32_t samples;
   bytes_consummed = buflen;
   //aa_message(LOG_DEBUG, aaclib, "decoding %d bits", buflen * 8);
   faacDecFrameInfo frame_info;
@@ -237,7 +237,7 @@
       aac->m_vft->audio_configure(aac->m_ifptr,
                   aac->m_freq,
                   aac->m_chans,
-                  AUDIO_S16SYS,
+                  AUDIO_FMT_S16,
                   aac->m_output_frame_size);
       uint8_t *now = aac->m_vft->audio_get_buffer(aac->m_ifptr);
       aac->m_audio_inited = 1;
diff -urN plugins/xmms/src/libmp4.c faad2-patched/plugins/xmms/src/libmp4.c
--- plugins/xmms/src/libmp4.c   2003-12-03 10:37:56.000000000 -0800
+++ faad2-patched/plugins/xmms/src/libmp4.c     2005-07-02 13:06:08.253034224 
-0700
@@ -22,6 +22,9 @@
 #define MP4_ABOUT      "Written by ciberfred"
 #define BUFFER_SIZE    FAAD_MIN_STREAMSIZE*64
 
+extern void     getMP4info(char* file);
+extern int      getAACTrack(MP4FileHandle file);
+
 static void    mp4_init(void);
 static void    mp4_about(void);
 static void    mp4_play(char *);
@@ -112,13 +115,13 @@
     gchar*     extention;
 
     extention = strrchr(filename, '.');
-    if (extention &&
-       !strcasecmp(extention, ".mp4") ||       // official extention
-       !strcasecmp(extention, ".m4a") ||       // Apple mp4 extention
-       !strcasecmp(extention, ".aac")          // old MPEG2/4-AAC extention
-       ){
-      return (1);
-    }
+
+    if (extention)
+      if( (!strcasecmp(extention, ".mp4") ||   // official extention
+           !strcasecmp(extention, ".m4a") ||   // Apple mp4 extention
+           !strcasecmp(extention, ".aac")      // old MPEG2/4-AAC extention
+       ))
+  return(1);
   }
   return(0);
 }
-- 
  __
 /__)_ _ _ _    Ask five economists and you'll get five different
/   (// (/(/    explanations (six if one went to Harvard).  -- Edgar R.
         _/     Fiedler




Home | Main Index | Thread Index | Old Index