--- faad2-2.7.orig/debian/control +++ faad2-2.7/debian/control @@ -0,0 +1,66 @@ +Source: faad2 +Section: libs +Priority: optional +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Debian Multimedia Maintainers +Uploaders: Matthew W. S. Bell , + Andres Mejia , + Reinhard Tartler , + Fabian Greffrath +DM-Upload-Allowed: yes +Standards-Version: 3.8.3 +Build-Depends: debhelper (>= 7.0.50~), quilt (>= 0.46-7) +Homepage: http://www.audiocoding.com/ +Vcs-Git: git://git.debian.org/git/pkg-multimedia/faad2.git +Vcs-Browser: http://git.debian.org/?p=pkg-multimedia/faad2.git;a=summary + +Package: libfaad-dev +Section: libdevel +Architecture: any +Depends: libfaad2 (= ${binary:Version}), ${misc:Depends} +Conflicts: libfaad2-dev +Replaces: libfaad2-dev +Description: freeware Advanced Audio Decoder - development files + FAAD2 is the fastest ISO AAC audio decoder available. FAAD2 correctly + decodes all MPEG-4 and MPEG-2 MAIN, LOW, LTP, LD and ER object type AAC + files. + . + This package contains development files. + +Package: libfaad2 +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Conflicts: libfaad2-0 +Replaces: libfaad2-0 +Description: freeware Advanced Audio Decoder - runtime files + FAAD2 is the fastest ISO AAC audio decoder available. FAAD2 correctly + decodes all MPEG-4 and MPEG-2 MAIN, LOW, LTP, LD and ER object type AAC + files. + . + This package contains the shared library. + +Package: faad2-dbg +Architecture: any +Section: debug +Priority: extra +Depends: libfaad2 (= ${binary:Version}), faad (= ${binary:Version}), + ${misc:Depends} +Description: freeware Advanced Audio Decoder - debugging symbols + FAAD2 is the fastest ISO AAC audio decoder available. FAAD2 correctly + decodes all MPEG-4 and MPEG-2 MAIN, LOW, LTP, LD and ER object type AAC + files. + . + This package contains the debugging symbols for all binary packages. + +Package: faad +Section: sound +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Conflicts: faad2 +Replaces: faad2 +Description: freeware Advanced Audio Decoder player + FAAD2 is the fastest ISO AAC audio decoder available. FAAD2 correctly + decodes all MPEG-4 and MPEG-2 MAIN, LOW, LTP, LD and ER object type AAC + files. + . + This package contains a command line interface to play AAC or MP4 files. --- faad2-2.7.orig/debian/faad.manpages +++ faad2-2.7/debian/faad.manpages @@ -0,0 +1 @@ +frontend/faad.man --- faad2-2.7.orig/debian/libfaad2.install +++ faad2-2.7/debian/libfaad2.install @@ -0,0 +1 @@ +usr/lib/libfaad.so.* --- faad2-2.7.orig/debian/watch +++ faad2-2.7/debian/watch @@ -0,0 +1,2 @@ +version=3 +http://sf.net/faac/faad2-(.*)\.tar.gz --- faad2-2.7.orig/debian/faad.install +++ faad2-2.7/debian/faad.install @@ -0,0 +1 @@ +usr/bin --- faad2-2.7.orig/debian/changelog +++ faad2-2.7/debian/changelog @@ -0,0 +1,274 @@ +faad2 (2.7-5ubuntu1) natty; urgency=low + + * debian/patches/fix_ftbfs_with_gcc4.5.patch + - Correctly declare lrintf in libfaad/common.h to avoid a conflict of + declaration in mathcalls.h to fix FTBFS on i386 + + -- Bhavani Shankar Tue, 23 Nov 2010 12:35:27 +0530 + +faad2 (2.7-5) unstable; urgency=low + + * Update my e-mail address. + * Apply SqueezeCenter patches from FreeBSD that enable streaming with + BBCiPlayer and ezstream (LP: #470562). + * Extend file name buffers for longer path names (LP: #475050). + + -- Fabian Greffrath Mon, 16 Aug 2010 16:43:14 +0200 + +faad2 (2.7-4) unstable; urgency=low + + * debian/control: Do not build the shared libmp4ff library packages + anymore (Closes: #550679). The use of mp4ff from faad2 is discouraged + by upstream, see . + * Removed debian/patches/force-include-stdint_h.patch. + * Removed debian/patches/libmp4ff-shared-lib.patch. + * Removed debian/patches/70_automake-1.9.patch. + * Added debian/README.source. + * Bumped Standards-Version to 3.8.3. + * Raised Build-Depends to debhelper (>= 7.0.50~), thanks lintian. + * Removed debian/libmp4ff-dev.install and debian/libmp4ff0.install. + * Removed libmp4ff0 from Depends for faad2-dbg. + + -- Fabian Greffrath Mon, 26 Oct 2009 12:04:41 +0100 + +faad2 (2.7-3) UNRELEASED; urgency=low + + * debian/patches/force-include-stdint_h.patch: New patch to force + inclusion of stdint.h (Closes: #550679). + + -- Fabian Greffrath Thu, 15 Oct 2009 18:00:41 +0200 + +faad2 (2.7-2) unstable; urgency=low + + * upload to unstable. + + -- Reinhard Tartler Wed, 16 Sep 2009 21:07:45 +0200 + +faad2 (2.7-1) experimental; urgency=low + + [ Andres Mejia ] + * New upstream release. (Closes: #515072) + * Verified all patches are either applied upstream, or a different + implementation is used. + + (Closes: #505901) + + (Closes: #503657) + * Switch to quilt. + * Add -DPIC for CFLAGS. + * Don't include dpatch.make in debian/rules. + * Update watch file to default DEHS would use. + * Bump to using debhelper 7. + * Use quilt (>= 0.46-7). + * Update control file. + * Add DM-Upload-Allowed: yes field. + * Don't include dummy package anymore. + * Add in description for libfaad2 that it contains shared library. + * Move libfaad-dev to the front to be 'default' package debhelper acts + on. + * Add ${misc:Depends} for all packages. Remove libc dev packages from + Depends. + * Add debug packages. (Closes: #516680) + * Rewrite debian/rules to use new debhelper and quilt. + * Rename .files to .install. Be more specific what + to include in libfaad-dev. Also include .install files for other packages. + * Add libmp4ff-dev package. + * Don't include version for rename of libfaad package. Place all debug + symbols for binary packages in faad2-dbg. + * Modify description for libmp4ff-dev. + * Update address to FSF in debian/copyright. + * Fix hyphen in manpage. Fixes lintian warning as well. + * Patch faad2 to create a shared lib for libmp4ff. (Closes: #485373) + * Allow to pass in more CFLAGS via DEB_CFLAGS. + * Add in DRM (Digital Radio Mondiale) support. + * Add Build-Depends of automake, autoconf, and autotools-dev. + + [ Fabian Greffrath ] + * Add myself to Uploaders. + * Clean up Build-Depends: libid3-dev was only needed for the obsolete + XMMS plugin, autotools stuff shouldn't be needed at all. + * Untagle library file names in the install rules. + * Revert overriding of CFLAGS, dpkg-buildpackage will choose + appripriate settings. Revert running the entire autoreconf sequence + before calling ./configure. Build without DRM support, it has proven + to break base functionality. + * Clean up watch file. + * Make faad2-dbg and libmp4ff-dev depend on libmp4ff0. + * Improve short description for the libmp4ff\* packages. + * debian/patches/70_automake-1.9.patch: New patch, run automake-1.9 to + regenerate Makefile.in with the changes introduced by + debian/patches/libmp4ff-shared-lib.patch. + * Do not ship .la files in the development packages. + * Add reasonable defaults to CFLAGS/CXXFLAGS. + + -- Fabian Greffrath Wed, 03 Jun 2009 11:02:00 +0200 + +faad2 (2.6.1-3.1) unstable; urgency=high + + * Non-maintainer upload by the security team + * Include upstream patch to fix heap overflow in the frontend code + (Closes: #499899) + + -- Steffen Joeris Fri, 26 Sep 2008 12:02:35 +0000 + +faad2 (2.6.1-3) unstable; urgency=low + + * Closes: #479802: Update man page to reflect on raw PCM is supported on + standard out. Also, have faad fail on trying to send non-raw PCM to + standard out. + * Apply new knowledge about the differences between hyphens, en-dashes, and + em-dashes to man pages. + * Move faad man page to patch system. + * Update standards version. + * Add license declarations and copyright declarations to copyright file. + Tidy up authors. + + -- Matthew W. S. Bell Thu, 19 Jun 2008 02:35:47 +0100 + +faad2 (2.6.1-2) unstable; urgency=low + + * Remove XMMS plugin as XMMS is being removed (Closes: #456724) + + -- Matthew W. S. Bell Fri, 21 Dec 2007 00:04:17 +0000 + +faad2 (2.6.1-1) unstable; urgency=low + + * Import new upstream version containing new license text + (Closes: #451948) + * Change build system to call autoreconf at build time, as + upstream no longer ships generated files + * Update debian/copyright to reflect new license text + * Remove Build-Depends on libsndfile1-dev (Closes: #452362) + + -- Matthew W. S. Bell Wed, 28 Nov 2007 23:45:05 +0000 + +faad2 (2.6-1) unstable; urgency=low + + * Import new 2.6 release. Includes several small off-by-one scale + fixes. + * Update the copyright as new code includes a clarification of the license + text, which indicates that the entire work is under the GPLv2 (closes: + #419339). + + -- Matthew W. S. Bell Mon, 15 Oct 2007 00:16:21 +0100 + +faad2 (2.5-5) unstable; urgency=low + + * Make packages depends bin-NMU safe + + -- Matthew W. S. Bell Fri, 17 Aug 2007 16:07:59 +0100 + +faad2 (2.5-4) unstable; urgency=low + + * Add mp4ff headers to libfaad-dev package (Closes: 409648) + + -- Matthew W. S. Bell Fri, 11 May 2007 19:44:22 +0100 + +faad2 (2.5-3) unstable; urgency=low + + * Add patch to stabilise/sanitise headers (Closes: 404279) + * Port several fixes from Ubuntu + * Add an mp4ff static library + + -- Matthew W. S. Bell Sun, 15 Apr 2007 04:23:35 +0100 + +faad2 (2.5-2) unstable; urgency=low + + * add xmms-mp4 desription read not like nonsense (Closes: #399457) + * Compile without Digital Radio Mondiale support, as it breaks base + functionality + * Update debian/copyright (See: #403117) + + -- Matthew W. S. Bell Mon, 4 Dec 2006 19:56:22 +0000 + +faad2 (2.5-1) unstable; urgency=low + + * Call make install with DESTDIR instead of prefix + * Change configure/Makefile to provide xmms config differently + * Add manual page for faad utility + * Call make uninstall in clean + * Add dummy libfaad2-0 pacakge to satisfy some third-party dependencies + * Upload into main (Closes: #306366) + + -- Matthew W. S. Bell Wed, 18 Oct 2006 23:41:32 +0100 + +faad2 (2.5-0.0) unstable; urgency=low + + * New upstream release. + * Add drm (Digital Radio Mondiale) support. + + -- Christian Marillat Wed, 6 Sep 2006 20:18:25 +0200 + +faad2 (2.0.0+cvs20060416-0.1) unstable; urgency=low + + * Rebuild for amd64. + + -- Christian Marillat Sat, 13 May 2006 08:58:34 +0200 + +faad2 (2.0.0+cvs20060416-0.0) unstable; urgency=low + + * CVS release. + + -- Christian Marillat Sun, 16 Apr 2006 17:15:00 +0200 + +faad2 (2.0.0-0.7) unstable; urgency=low + + * Rebuild for gcc 4.0 + + -- Christian Marillat Sat, 16 Jul 2005 17:34:28 +0200 + +faad2 (2.0.0-0.6) unstable; urgency=low + + * New patch from Gentoo to fix amd64 problem with some files. Thanks to + Carl Schneidinger. + + -- Christian Marillat Fri, 20 May 2005 18:42:23 +0200 + +faad2 (2.0.0-0.5) unstable; urgency=low + + * Apply patch from Arnaud Rouanet to fix the -w option in faad. + + -- Christian Marillat Mon, 21 Mar 2005 10:13:05 +0100 + +faad2 (2.0.0-0.4) unstable; urgency=low + + * New patch 04_mp4ff.h to replace "mp4ff_int_types.h" include by + + -- Christian Marillat Wed, 9 Mar 2005 08:59:35 +0100 + +faad2 (2.0.0-0.3) unstable; urgency=low + + * Add libfaac-dev in Build-Depends. + * Little hack to not build the mpeg4ip plugin. + + -- Christian Marillat Wed, 26 Jan 2005 07:36:25 +0100 + +faad2 (2.0.0-0.2) unstable; urgency=low + + * Build with libmp4 + * Add new package xmms-mp4 + + -- Christian Marillat Mon, 25 Oct 2004 10:19:52 +0200 + +faad2 (2.0.0-0.1) unstable; urgency=low + + * Really apply my patch to link against -lm + + -- Christian Marillat Thu, 29 Jul 2004 15:48:22 +0200 + +faad2 (2.0.0-0.0) unstable; urgency=low + + * New upstream release. + + -- Christian Marillat Sun, 4 Jul 2004 00:26:23 +0200 + +faad2 (2.0-rc3-0.0) unstable; urgency=low + + * New upstream release. + + -- Christian Marillat Tue, 9 Dec 2003 10:57:01 +0100 + +faad2 (1.1-0.0) unstable; urgency=low + + * Initial Release. + + -- Christian Marillat Sun, 29 Dec 2002 23:09:33 +0100 + --- faad2-2.7.orig/debian/compat +++ faad2-2.7/debian/compat @@ -0,0 +1 @@ +7 --- faad2-2.7.orig/debian/copyright +++ faad2-2.7/debian/copyright @@ -0,0 +1,75 @@ +This package was debianized by Aubin Paul on Sun, 8 Dec 2002 12:05:10 -0500. +This package was prepared for inclusion in Debian by Matthew W. S. Bell + in May 2006 + +It was downloaded from http://faac.sourceforge.net/index.php. +Official website is now at http://www.audiocoding.com/ +CVS is still hosted by SourceForge.net + +Debian Authors: Matthew W. S. Bell + Aubin Paul +Copyright: 2006, 2007, 2008 Matthew W. S. Bell + 200 Aubin Paul + +Upstream Authors: menno + Alexander Kurpiers + M. Bakker + Ahead Software AG + Nero AG +Copyright: 2002-2005 M. Bakker + 2003-2005 Ahead Software AG + 2003-2005 Nero AG + +Other Authors: John Edwards + Bill May + Quinnware + VideoLAN +Copyright: 2002 John Edwards + 2003 Bill May + 1997-2002 Quinnware + 2004 VideoLAN + +License Declaration: + +The GPL may be found in the file /usr/share/common-licenses/GPL. + +The upstream source has the follwing license declaration: +--- +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program; if not, write to the Free Software Foundation, Inc., 51 Franklin +St, Fifth Floor, Boston, MA 02110-1301, USA. + +Any non-GPL usage of this software or parts of this software is strictly +forbidden. + +The "appropriate copyright message" mentioned in section 2c of the GPLv2 must +read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" +--- + +The aacDECdrop module has the following license declaration: +--- +This program is distributed under the GNU General Public License, version 2. A +copy of this license is included with this source. +--- + +Some files (extra components and plugins) and the Debian packaging have the +following license declaration: +--- +This program is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation; either version 2 of the License, or (at your option) any later +version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. See the GNU General Public License for more details. +--- --- faad2-2.7.orig/debian/README.source +++ faad2-2.7/debian/README.source @@ -0,0 +1,6 @@ +This package uses quilt to manage all modifications to the upstream source. +The fully patched source can be generated using the patch target provided by +`debian/rules'. + +If you want to know more about how to use quilt to manage Debian patches, read +/usr/share/doc/quilt/README.source. --- faad2-2.7.orig/debian/rules +++ faad2-2.7/debian/rules @@ -0,0 +1,10 @@ +#!/usr/bin/make -f + +CFLAGS += -Wall -g -O$(if $(findstring noopt,$(DEB_BUILD_OPTIONS)),0,2) +CXXFLAGS += -Wall -g -O$(if $(findstring noopt,$(DEB_BUILD_OPTIONS)),0,2) + +%: + dh --with quilt $@ + +override_dh_strip: + dh_strip --dbg-package=faad2-dbg --- faad2-2.7.orig/debian/libfaad-dev.install +++ faad2-2.7/debian/libfaad-dev.install @@ -0,0 +1,4 @@ +usr/include/faad.h +usr/include/neaacdec.h +usr/lib/libfaad.a +usr/lib/libfaad.so --- faad2-2.7.orig/debian/patches/path_max.patch +++ faad2-2.7/debian/patches/path_max.patch @@ -0,0 +1,75 @@ +Description: Extend file name buffers for longer path names + and fix potential buffer overruns for even longer pathnames. +Author: Fabian Greffrath +Forwarded: menno@audiocoding.com + +--- faad2.orig/frontend/main.c ++++ faad2/frontend/main.c +@@ -42,6 +42,11 @@ + #include + #include + #include ++#include ++ ++#ifndef PATH_MAX ++#define PATH_MAX 1023 ++#endif + + #include + #include +@@ -1107,9 +1112,9 @@ int main(int argc, char *argv[]) + int mp4file = 0; + int noGapless = 0; + char *fnp; +- char aacFileName[255]; +- char audioFileName[255]; +- char adtsFileName[255]; ++ char aacFileName[PATH_MAX + 1]; ++ char audioFileName[PATH_MAX + 1]; ++ char adtsFileName[PATH_MAX + 1]; + unsigned char header[8]; + float length = 0; + FILE *hMP4File; +@@ -1157,14 +1162,14 @@ int main(int argc, char *argv[]) + if (optarg) + { + outfile_set = 1; +- strcpy(audioFileName, optarg); ++ strncpy(audioFileName, optarg, PATH_MAX); + } + break; + case 'a': + if (optarg) + { + adts_out = 1; +- strcpy(adtsFileName, optarg); ++ strncpy(adtsFileName, optarg, PATH_MAX); + } + break; + case 's': +@@ -1284,7 +1289,7 @@ int main(int argc, char *argv[]) + #endif + + /* point to the specified file name */ +- strcpy(aacFileName, argv[optind]); ++ strncpy(aacFileName, argv[optind], PATH_MAX); + + #ifdef _WIN32 + begin = GetTickCount(); +@@ -1297,14 +1302,14 @@ int main(int argc, char *argv[]) + */ + if(!writeToStdio && !outfile_set) + { +- strcpy(audioFileName, aacFileName); ++ strncpy(audioFileName, aacFileName, PATH_MAX); + + fnp = (char *)strrchr(audioFileName,'.'); + + if (fnp) + fnp[0] = '\0'; + +- strcat(audioFileName, file_ext[format]); ++ strncat(audioFileName, file_ext[format], PATH_MAX - strlen(audioFileName)); + } + + /* check for mp4 file */ --- faad2-2.7.orig/debian/patches/series +++ faad2-2.7/debian/patches/series @@ -0,0 +1,5 @@ +manpage.patch +bpa-stdin.patch +path_max.patch +incorrect_pointer_size.patch +fix_ftbfs_with_gcc4.5.patch --- faad2-2.7.orig/debian/patches/manpage.patch +++ faad2-2.7/debian/patches/manpage.patch @@ -0,0 +1,16 @@ +Fix hyphen in manpage. +========================================================================== +--- a/frontend/faad.man ++++ b/frontend/faad.man +@@ -24,9 +24,9 @@ + .br + 3: 32\(hybit PCM data. + .br +-4: 32\(hybit floating\hy(point data. ++4: 32\(hybit floating\(hypoint data. + .br +-5: 64\(hybit floating\hy(point data. ++5: 64\(hybit floating\(hypoint data. + .RE + .RE + .TP --- faad2-2.7.orig/debian/patches/incorrect_pointer_size.patch +++ faad2-2.7/debian/patches/incorrect_pointer_size.patch @@ -0,0 +1,35 @@ +Description: faad segfaults on amd64 due to incorrect pointer size + When running faad with a command line similar to: + alessio@alessio-laptop:~$ faad -b 2 -f 2 -w sample.aac + a SIGSEGV gets raised. This issue is due to an incorrect pointer size + used in the write_audio{32,64}bit functions. +Origin: Ubuntu +Bug: https://sourceforge.net/support/tracker.php?aid=3110758 +Bug-Debian: http://bugs.debian.org/603807 +Bug-Ubuntu: https://launchpad.net/bugs/665802 +Reviewed-by: Alessio Treglia +Last-Update: 2010-11-17 +--- + frontend/audio.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- faad2.orig/frontend/audio.c ++++ faad2/frontend/audio.c +@@ -347,7 +347,7 @@ static int write_audio_24bit(audio_file + { + int ret; + unsigned int i; +- long *sample_buffer24 = (long*)sample_buffer; ++ int *sample_buffer24 = (int*)sample_buffer; + char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8); + + aufile->total_samples += samples; +@@ -391,7 +391,7 @@ static int write_audio_32bit(audio_file + { + int ret; + unsigned int i; +- long *sample_buffer32 = (long*)sample_buffer; ++ int *sample_buffer32 = (int*)sample_buffer; + char *data = malloc(samples*aufile->bits_per_sample*sizeof(char)/8); + + aufile->total_samples += samples; --- faad2-2.7.orig/debian/patches/fix_ftbfs_with_gcc4.5.patch +++ faad2-2.7/debian/patches/fix_ftbfs_with_gcc4.5.patch @@ -0,0 +1,31 @@ +Index: faad2-2.7/libfaad/common.h +===================================== +--- faad2-2.7.orig/libfaad/common.h ++++ faad2-2.7/libfaad/common.h +@@ -315,7 +315,7 @@ + + #if defined(_WIN32) && !defined(__MINGW32__) + #define HAS_LRINTF +- static INLINE int lrintf(float f) ++ static INLINE int _lrintf(float f) + { + int i; + __asm +@@ -330,7 +330,7 @@ + #ifndef HAVE_LRINTF + #define HAS_LRINTF + // from http://www.stereopsis.com/FPU.html +- static INLINE int lrintf(float f) ++ static INLINE int _lrintf(float f) + { + int i; + __asm__ __volatile__ ( +@@ -396,7 +396,7 @@ + + #ifndef HAS_LRINTF + /* standard cast */ +-#define lrintf(f) ((int32_t)(f)) ++#define _lrintf(f) ((int32_t)(f)) + #endif + + typedef real_t complex_t[2]; --- faad2-2.7.orig/debian/patches/bpa-stdin.patch +++ faad2-2.7/debian/patches/bpa-stdin.patch @@ -0,0 +1,268 @@ +Description: The patch enables input on stdin for AAC/AAC+ streams. +Origin: http://www.freebsd.org/cgi/cvsweb.cgi/ports/audio/faad/files/patch-frontend_main.c +Bug: http://bugs.slimdevices.com/show_bug.cgi?id=10602 +Forwarded: menno@audiocoding.com +Author: Bryan Alton +Reviewed-By: Mark Knight + +$FreeBSD: ports/audio/faad/files/patch-frontend_main.c,v 1.3 2010/02/25 17:12:54 brooks Exp $ + +--- faad2.orig/frontend/main.c ++++ faad2/frontend/main.c +@@ -137,6 +137,31 @@ static void advance_buffer(aac_buffer *b + b->bytes_into_buffer = 0; + } + ++static void lookforheader(aac_buffer *b) ++{ ++ int i = 0; ++ while (!b->at_eof ) ++ { ++ if (b->bytes_into_buffer > 4) ++ { ++ if( ((b->buffer[0+i] == 0xff) && ((b->buffer[1+i] & 0xf6) == 0xf0)) || ++ (b->buffer[0+i] == 'A' && b->buffer[1+i] == 'D' && b->buffer[2+i] == 'I' && b->buffer[3+i] == 'F')) ++ { ++ fill_buffer(b); ++ break; ++ } else { ++ i++; ++ b->file_offset += 1; ++ b->bytes_consumed += 1; ++ b->bytes_into_buffer -= 1; ++ } ++ } else { ++ fill_buffer(b); ++ i = 0; ++ } ++ } ++} ++ + static int adts_sample_rates[] = {96000,88200,64000,48000,44100,32000,24000,22050,16000,12000,11025,8000,7350,0,0,0}; + + static int adts_parse(aac_buffer *b, int *bitrate, float *length) +@@ -424,6 +449,8 @@ static int decodeAACfile(char *aacfile, + float length = 0; + + int first_time = 1; ++ int retval; ++ int streaminput = 0; + + aac_buffer b; + +@@ -439,17 +466,39 @@ static int decodeAACfile(char *aacfile, + } + } + +- b.infile = fopen(aacfile, "rb"); +- if (b.infile == NULL) ++ if (0 == strcmp(aacfile, "-")) + { +- /* unable to open file */ +- faad_fprintf(stderr, "Error opening file: %s\n", aacfile); +- return 1; ++ b.infile = stdin; ++#ifdef _WIN32 ++ setmode(fileno(stdin), O_BINARY); ++#endif ++ ++ } else ++ { ++ b.infile = fopen(aacfile, "rb"); ++ if (b.infile == NULL) ++ { ++ /* unable to open file */ ++ faad_fprintf(stderr, "Error opening file: %s\n", aacfile); ++ return 1; ++ } + } + +- fseek(b.infile, 0, SEEK_END); +- fileread = ftell(b.infile); +- fseek(b.infile, 0, SEEK_SET); ++ retval = fseek(b.infile, 0, SEEK_END); ++#ifdef _WIN32 ++ if (0 == strcmp(aacfile, "-")) { ++ retval = -1; ++ } ++#endif ++ if (retval ) ++ { ++ faad_fprintf(stderr, "Input not seekable %s\n", aacfile); ++ fileread = -1; ++ streaminput = 1; ++ } else { ++ fileread = ftell(b.infile); ++ fseek(b.infile, 0, SEEK_SET); ++ }; + + if (!(b.buffer = (unsigned char*)malloc(FAAD_MIN_STREAMSIZE*MAX_CHANNELS))) + { +@@ -494,19 +543,39 @@ static int decodeAACfile(char *aacfile, + + /* get AAC infos for printing */ + header_type = 0; ++ if (streaminput == 1 ) ++ lookforheader(&b); ++ + if ((b.buffer[0] == 0xFF) && ((b.buffer[1] & 0xF6) == 0xF0)) + { +- adts_parse(&b, &bitrate, &length); +- fseek(b.infile, tagsize, SEEK_SET); +- +- bread = fread(b.buffer, 1, FAAD_MIN_STREAMSIZE*MAX_CHANNELS, b.infile); +- if (bread != FAAD_MIN_STREAMSIZE*MAX_CHANNELS) +- b.at_eof = 1; +- else +- b.at_eof = 0; +- b.bytes_into_buffer = bread; +- b.bytes_consumed = 0; +- b.file_offset = tagsize; ++ if (streaminput ==1) ++ { ++ int frames, frame_length; ++ int samplerate; ++ float frames_per_sec, bytes_per_frame; ++ samplerate = adts_sample_rates[(b.buffer[2]&0x3c)>>2]; ++ frame_length = ((((unsigned int)b.buffer[3] & 0x3)) << 11) ++ | (((unsigned int)b.buffer[4]) << 3) | (b.buffer[5] >> 5); ++ ++ frames_per_sec = (float)samplerate/1024.0f; ++ bytes_per_frame = (float)frame_length/(float)(1000); ++ bitrate = (int)(8. * bytes_per_frame * frames_per_sec + 0.5); ++ length = 1; ++ faad_fprintf(stderr, "Streamed input format samplerate %d channels %d.\n",samplerate,channels); ++ ++ } else { ++ adts_parse(&b, &bitrate, &length); ++ fseek(b.infile, tagsize, SEEK_SET); ++ ++ bread = fread(b.buffer, 1, FAAD_MIN_STREAMSIZE*MAX_CHANNELS, b.infile); ++ if (bread != FAAD_MIN_STREAMSIZE*MAX_CHANNELS) ++ b.at_eof = 1; ++ else ++ b.at_eof = 0; ++ b.bytes_into_buffer = bread; ++ b.bytes_consumed = 0; ++ b.file_offset = tagsize; ++ } + + header_type = 1; + } else if (memcmp(b.buffer, "ADIF", 4) == 0) { +@@ -538,7 +607,8 @@ static int decodeAACfile(char *aacfile, + if (b.buffer) + free(b.buffer); + NeAACDecClose(hDecoder); +- fclose(b.infile); ++ if (b.infile != stdin) ++ fclose(b.infile); + return 1; + } + advance_buffer(&b, bread); +@@ -564,7 +634,8 @@ static int decodeAACfile(char *aacfile, + if (infoOnly) + { + NeAACDecClose(hDecoder); +- fclose(b.infile); ++ if (b.infile != stdin) ++ fclose(b.infile); + if (b.buffer) + free(b.buffer); + return 0; +@@ -621,7 +692,8 @@ static int decodeAACfile(char *aacfile, + if (b.buffer) + free(b.buffer); + NeAACDecClose(hDecoder); +- fclose(b.infile); ++ if (b.infile != stdin) ++ fclose(b.infile); + return 0; + } + } else { +@@ -662,7 +734,8 @@ static int decodeAACfile(char *aacfile, + fclose(adtsFile); + } + +- fclose(b.infile); ++ if (b.infile != stdin) ++ fclose(b.infile); + + if (!first_time && !adts_out) + close_audio_file(aufile); +@@ -750,6 +823,11 @@ static int decodeMP4file(char *mp4file, + /* initialise the callback structure */ + mp4ff_callback_t *mp4cb = malloc(sizeof(mp4ff_callback_t)); + ++ if (strcmp(mp4file, "-") == 0 ) { ++ faad_fprintf(stderr, "Cannot open stdin for MP4 input \n"); ++ return 1; ++ } ++ + mp4File = fopen(mp4file, "rb"); + mp4cb->read = read_callback; + mp4cb->seek = seek_callback; +@@ -1016,6 +1094,7 @@ int main(int argc, char *argv[]) + int result; + int infoOnly = 0; + int writeToStdio = 0; ++ int readFromStdin = 0; + int object_type = LC; + int def_srate = 0; + int downMatrix = 0; +@@ -1229,15 +1308,30 @@ int main(int argc, char *argv[]) + } + + /* check for mp4 file */ +- mp4file = 0; +- hMP4File = fopen(aacFileName, "rb"); +- if (!hMP4File) +- { +- faad_fprintf(stderr, "Error opening file: %s\n", aacFileName); +- return 1; ++ if (0 == strcmp(aacFileName, "-")) { ++ faad_fprintf(stderr, "Reading from stdin: %s\n", aacFileName); ++ readFromStdin = 1; ++ hMP4File = stdin; ++#ifdef _WIN32 ++ setmode(fileno(stdin), O_BINARY); ++#endif ++ ++ } else { ++ ++ mp4file = 0; ++ hMP4File = fopen(aacFileName, "rb"); ++ if (!hMP4File) ++ { ++ faad_fprintf(stderr, "Error opening file: %s\n", aacFileName); ++ return 1; ++ } + } ++ + fread(header, 1, 8, hMP4File); +- fclose(hMP4File); ++ ++ if (! readFromStdin ) ++ fclose(hMP4File); ++ + if (header[4] == 'f' && header[5] == 't' && header[6] == 'y' && header[7] == 'p') + mp4file = 1; + +@@ -1246,6 +1340,18 @@ int main(int argc, char *argv[]) + result = decodeMP4file(aacFileName, audioFileName, adtsFileName, writeToStdio, + outputFormat, format, downMatrix, noGapless, infoOnly, adts_out, &length); + } else { ++ ++ if (readFromStdin == 1) { ++ ungetc(header[7],hMP4File); ++ ungetc(header[6],hMP4File); ++ ungetc(header[5],hMP4File); ++ ungetc(header[4],hMP4File); ++ ungetc(header[3],hMP4File); ++ ungetc(header[2],hMP4File); ++ ungetc(header[1],hMP4File); ++ ungetc(header[0],hMP4File); ++ } ++ + result = decodeAACfile(aacFileName, audioFileName, adtsFileName, writeToStdio, + def_srate, object_type, outputFormat, format, downMatrix, infoOnly, adts_out, + old_format, &length);