mirror of
https://github.com/nu774/fdkaac.git
synced 2025-06-05 23:29:14 +02:00
Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
fae0942597 | |||
fcfed4cd0c | |||
1acf5c2d4d | |||
25f5bd4f23 | |||
e8f61c26ff | |||
a7c2411335 | |||
b54538f79e | |||
a7e00a4219 | |||
b667da2b01 | |||
a79a11ef99 | |||
70554c0791 | |||
a854b113ae | |||
f7a24bf87b |
111
COPYING
111
COPYING
@ -1,17 +1,108 @@
|
||||
Copyright (C) 2013 nu774
|
||||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: fdkaac
|
||||
Upstream-Contact: nu774 <honeycomb77@gmail.com>
|
||||
Source: https://github.com/nu774/fdkaac
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
Files: *
|
||||
Copyright: 2013-2014 nu774 <honeycomb77@gmail.com>
|
||||
License: Zlib
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
Files: missings/getopt.c
|
||||
Copyright: 2002 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
2000 The NetBSD Foundation, Inc.
|
||||
License: BSD-4-clause
|
||||
|
||||
Files: missings/getopt.h
|
||||
Copyright: 2000 The NetBSD Foundation, Inc.
|
||||
License: BSD-4-clause
|
||||
|
||||
Files: src/parson.*
|
||||
Copyright: 2012 Krzysztof Gabis
|
||||
License: MIT
|
||||
|
||||
Files: src/lpc.h
|
||||
Copyright: 1994-2007 the Xiph.Org Foundation
|
||||
License: BSD
|
||||
|
||||
Files: src/lpc.c
|
||||
Copyright: 1994-2007 the Xiph.Org Foundation
|
||||
1992, 1993, 1994 Jutta Degener and Carsten Bormann, Technische Universität Berlin
|
||||
License: BSD-style
|
||||
|
||||
|
||||
License: Zlib
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
.
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
|
||||
License: MIT
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
.
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
License: BSD-4-clause
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
This product includes software developed by the NetBSD
|
||||
Foundation, Inc. and its contributors.
|
||||
4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
.
|
||||
THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
License: BSD-style
|
||||
Any use of this software is permitted provided that this notice is not
|
||||
removed and that neither the authors nor the Technische Universita"t
|
||||
Berlin are deemed to have made any representations as to the
|
||||
suitability of this software for any purpose nor are held responsible
|
||||
for any defects of this software. THERE IS ABSOLUTELY NO WARRANTY FOR
|
||||
THIS SOFTWARE.
|
||||
|
40
ChangeLog
40
ChangeLog
@ -1,14 +1,48 @@
|
||||
2014-01-18 nu774 <honeycomb77@gmail.com>
|
||||
2014-08-13 nu774 <honeycomb77@gmail.com>
|
||||
|
||||
* update ChangeLog [HEAD]
|
||||
|
||||
* bump version [v0.6.0]
|
||||
|
||||
2014-08-12 nu774 <honeycomb77@gmail.com>
|
||||
|
||||
* apply limiter when input is float
|
||||
|
||||
* refactor pcm reader framework
|
||||
|
||||
2014-07-30 nu774 <honeycomb77@gmail.com>
|
||||
|
||||
* update ChangeLog [origin/master]
|
||||
|
||||
* win32compat: fix aacenc_printf() not to write junk characters [v0.5.4]
|
||||
|
||||
2014-05-12 nu774 <honeycomb77@gmail.com>
|
||||
|
||||
* write INSTALL
|
||||
|
||||
2014-03-14 nu774 <honeycomb77@gmail.com>
|
||||
|
||||
* update COPYING (patch from darealshinji)
|
||||
|
||||
2014-02-17 nu774 <honeycomb77@gmail.com>
|
||||
|
||||
* update ChangeLog
|
||||
|
||||
* bump version [v0.5.3]
|
||||
|
||||
* fix: CAF chan chunk using channel bitmap was not correctly handled
|
||||
|
||||
2014-01-18 nu774 <honeycomb77@gmail.com>
|
||||
|
||||
* update ChangeLog
|
||||
|
||||
* bump version [v0.5.2]
|
||||
|
||||
* fix reading of caf file without chan chunk
|
||||
|
||||
2013-11-17 nu774 <honeycomb77@gmail.com>
|
||||
|
||||
* Merge pull request #9 from rbrito/fix-typo [origin/master]
|
||||
* Merge pull request #9 from rbrito/fix-typo
|
||||
|
||||
2013-11-18 Rogério Brito <rbrito@ime.usp.br>
|
||||
|
||||
@ -104,7 +138,7 @@
|
||||
|
||||
2013-10-26 nu774 <honeycomb77@gmail.com>
|
||||
|
||||
* re-fix #ifdef cond for lrint() [old]
|
||||
* re-fix #ifdef cond for lrint()
|
||||
|
||||
* tag mapping: add recorded date and tempo, remove performer->artist
|
||||
|
||||
|
385
INSTALL
385
INSTALL
@ -1,370 +1,31 @@
|
||||
Installation Instructions
|
||||
*************************
|
||||
Prerequiste
|
||||
-----------
|
||||
|
||||
Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation,
|
||||
Inc.
|
||||
To build fdkaac, you need the followings:
|
||||
- libfdk-aac (https://github.com/mstorsjo/fdk-aac)
|
||||
- GNU autoconf, GNU automake
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved. This file is offered as-is,
|
||||
without warranty of any kind.
|
||||
libfdk-aac is always required, and probably you have to build it yourself.
|
||||
Others are required only when you build by configure and make on Unix-like
|
||||
enviromnent (including Cygwin or MinGW), and usually you can install them
|
||||
through package manager of your system if they are not already present.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
Unix-like environment
|
||||
---------------------
|
||||
|
||||
Briefly, the shell commands `./configure; make; make install' should
|
||||
configure, build, and install this package. The following
|
||||
more-detailed instructions are generic; see the `README' file for
|
||||
instructions specific to this package. Some packages provide this
|
||||
`INSTALL' file but do not implement all of the features documented
|
||||
below. The lack of an optional feature in a given package is not
|
||||
necessarily a bug. More recommendations for GNU packages can be found
|
||||
in *note Makefile Conventions: (standards)Makefile Conventions.
|
||||
You can build and install libfdkaac and fdkaac in the following step.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
1) extract the source, and cd to the source directory
|
||||
2) autoreconf -i
|
||||
3) ./configure
|
||||
4) make
|
||||
5) sudo make install
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.
|
||||
Depending on your requirements, you might want to add some extra arguments to
|
||||
configure script.
|
||||
You have to install libfdk-aac first, and do the same for fdkaac.
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You need `configure.ac' if
|
||||
you want to change it or regenerate `configure' using a newer version
|
||||
of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system.
|
||||
|
||||
Running `configure' might take a while. While running, it prints
|
||||
some messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package, generally using the just-built uninstalled binaries.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation. When installing into a prefix owned by root, it is
|
||||
recommended that the package be configured and built as a regular
|
||||
user, and only the `make install' phase executed with root
|
||||
privileges.
|
||||
|
||||
5. Optionally, type `make installcheck' to repeat any self-tests, but
|
||||
this time using the binaries in their final installed location.
|
||||
This target does not install anything. Running this target as a
|
||||
regular user, particularly if the prior `make install' required
|
||||
root privileges, verifies that the installation completed
|
||||
correctly.
|
||||
|
||||
6. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
7. Often, you can also type `make uninstall' to remove the installed
|
||||
files again. In practice, not all packages have tested that
|
||||
uninstallation works correctly, even though it is required by the
|
||||
GNU Coding Standards.
|
||||
|
||||
8. Some packages, particularly those that use Automake, provide `make
|
||||
distcheck', which can by used by developers to test that all other
|
||||
targets like `make install' and `make uninstall' work correctly.
|
||||
This target is generally not run by end users.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c99 CFLAGS=-g LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you can use GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'. This
|
||||
is known as a "VPATH" build.
|
||||
|
||||
With a non-GNU `make', it is safer to compile the package for one
|
||||
architecture at a time in the source code directory. After you have
|
||||
installed the package for one architecture, use `make distclean' before
|
||||
reconfiguring for another architecture.
|
||||
|
||||
On MacOS X 10.5 and later systems, you can create libraries and
|
||||
executables that work on multiple system types--known as "fat" or
|
||||
"universal" binaries--by specifying multiple `-arch' options to the
|
||||
compiler but only a single `-arch' option to the preprocessor. Like
|
||||
this:
|
||||
|
||||
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||
CPP="gcc -E" CXXCPP="g++ -E"
|
||||
|
||||
This is not guaranteed to produce working output in all cases, you
|
||||
may have to build one architecture at a time and combine the results
|
||||
using the `lipo' tool if you have problems.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' installs the package's commands under
|
||||
`/usr/local/bin', include files under `/usr/local/include', etc. You
|
||||
can specify an installation prefix other than `/usr/local' by giving
|
||||
`configure' the option `--prefix=PREFIX', where PREFIX must be an
|
||||
absolute file name.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
|
||||
PREFIX as the prefix for installing programs and libraries.
|
||||
Documentation and other data files still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=DIR' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them. In general, the
|
||||
default for these options is expressed in terms of `${prefix}', so that
|
||||
specifying just `--prefix' will affect all of the other directory
|
||||
specifications that were not explicitly provided.
|
||||
|
||||
The most portable way to affect installation locations is to pass the
|
||||
correct locations to `configure'; however, many packages provide one or
|
||||
both of the following shortcuts of passing variable assignments to the
|
||||
`make install' command line to change installation locations without
|
||||
having to reconfigure or recompile.
|
||||
|
||||
The first method involves providing an override variable for each
|
||||
affected directory. For example, `make install
|
||||
prefix=/alternate/directory' will choose an alternate location for all
|
||||
directory configuration variables that were expressed in terms of
|
||||
`${prefix}'. Any directories that were specified during `configure',
|
||||
but not in terms of `${prefix}', must each be overridden at install
|
||||
time for the entire installation to be relocated. The approach of
|
||||
makefile variable overrides for each directory variable is required by
|
||||
the GNU Coding Standards, and ideally causes no recompilation.
|
||||
However, some platforms have known limitations with the semantics of
|
||||
shared libraries that end up requiring recompilation when using this
|
||||
method, particularly noticeable in packages that use GNU Libtool.
|
||||
|
||||
The second method involves providing the `DESTDIR' variable. For
|
||||
example, `make install DESTDIR=/alternate/directory' will prepend
|
||||
`/alternate/directory' before all installation names. The approach of
|
||||
`DESTDIR' overrides is not required by the GNU Coding Standards, and
|
||||
does not work on platforms that have drive letters. On the other hand,
|
||||
it does better at avoiding recompilation issues, and works well even
|
||||
when some directory options were not specified in terms of `${prefix}'
|
||||
at `configure' time.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Some packages offer the ability to configure how verbose the
|
||||
execution of `make' will be. For these packages, running `./configure
|
||||
--enable-silent-rules' sets the default to minimal output, which can be
|
||||
overridden with `make V=1'; while running `./configure
|
||||
--disable-silent-rules' sets the default to verbose, which can be
|
||||
overridden with `make V=0'.
|
||||
|
||||
Particular systems
|
||||
==================
|
||||
|
||||
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
|
||||
CC is not installed, it is recommended to use the following options in
|
||||
order to use an ANSI C compiler:
|
||||
|
||||
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
|
||||
|
||||
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
|
||||
|
||||
HP-UX `make' updates targets which have the same time stamps as
|
||||
their prerequisites, which makes it generally unusable when shipped
|
||||
generated files such as `configure' are involved. Use GNU `make'
|
||||
instead.
|
||||
|
||||
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
|
||||
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
|
||||
a workaround. If GNU CC is not installed, it is therefore recommended
|
||||
to try
|
||||
|
||||
./configure CC="cc"
|
||||
|
||||
and if that doesn't work, try
|
||||
|
||||
./configure CC="cc -nodtk"
|
||||
|
||||
On Solaris, don't put `/usr/ucb' early in your `PATH'. This
|
||||
directory contains several dysfunctional programs; working variants of
|
||||
these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
|
||||
in your `PATH', put it _after_ `/usr/bin'.
|
||||
|
||||
On Haiku, software installed for all users goes in `/boot/common',
|
||||
not `/usr/local'. It is recommended to use the following options:
|
||||
|
||||
./configure --prefix=/boot/common
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, `configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS
|
||||
KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the option `--target=TYPE' to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
causes the specified `gcc' to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
|
||||
an Autoconf bug. Until the bug is fixed you can use this workaround:
|
||||
|
||||
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of all of the options to `configure', and exit.
|
||||
|
||||
`--help=short'
|
||||
`--help=recursive'
|
||||
Print a summary of the options unique to this package's
|
||||
`configure', and exit. The `short' variant lists options used
|
||||
only in the top level, while the `recursive' variant lists options
|
||||
also present in any nested packages.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`--prefix=DIR'
|
||||
Use DIR as the installation prefix. *note Installation Names::
|
||||
for more details, including other options available for fine-tuning
|
||||
the installation locations.
|
||||
|
||||
`--no-create'
|
||||
`-n'
|
||||
Run the configure checks, but stop before creating any output
|
||||
files.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
Windows, MSVC
|
||||
-------------
|
||||
|
||||
Extract libfdk-aac under fdkaac directory, and open MSVC/fdkaac.sln.
|
||||
|
@ -99,12 +99,14 @@ copy ..\fdk-aac\libSYS\include\machine_type.h include\fdk-aac\ </Command>
|
||||
<ClCompile Include="..\src\caf_reader.c" />
|
||||
<ClCompile Include="..\src\compat_win32.c" />
|
||||
<ClCompile Include="..\src\extrapolater.c" />
|
||||
<ClCompile Include="..\src\limiter.c" />
|
||||
<ClCompile Include="..\src\lpc.c" />
|
||||
<ClCompile Include="..\src\lpcm.c" />
|
||||
<ClCompile Include="..\src\m4af.c" />
|
||||
<ClCompile Include="..\src\main.c" />
|
||||
<ClCompile Include="..\src\metadata.c" />
|
||||
<ClCompile Include="..\src\parson.c" />
|
||||
<ClCompile Include="..\src\pcm_float_converter.c" />
|
||||
<ClCompile Include="..\src\pcm_native_converter.c" />
|
||||
<ClCompile Include="..\src\pcm_readhelper.c" />
|
||||
<ClCompile Include="..\src\pcm_sint16_converter.c" />
|
||||
<ClCompile Include="..\src\progress.c" />
|
||||
@ -113,7 +115,6 @@ copy ..\fdk-aac\libSYS\include\machine_type.h include\fdk-aac\ </Command>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\missings\getopt.h" />
|
||||
<ClInclude Include="..\src\aacenc.h" />
|
||||
<ClInclude Include="..\src\caf_reader.h" />
|
||||
<ClInclude Include="..\src\catypes.h" />
|
||||
<ClInclude Include="..\src\compat.h" />
|
||||
<ClInclude Include="..\src\lpc.h" />
|
||||
@ -124,7 +125,6 @@ copy ..\fdk-aac\libSYS\include\machine_type.h include\fdk-aac\ </Command>
|
||||
<ClInclude Include="..\src\parson.h" />
|
||||
<ClInclude Include="..\src\pcm_reader.h" />
|
||||
<ClInclude Include="..\src\progress.h" />
|
||||
<ClInclude Include="..\src\wav_reader.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="fdk-aac.vcxproj">
|
||||
|
@ -27,10 +27,10 @@
|
||||
<ClCompile Include="..\src\extrapolater.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\lpc.c">
|
||||
<ClCompile Include="..\src\limiter.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\lpcm.c">
|
||||
<ClCompile Include="..\src\lpc.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\m4af.c">
|
||||
@ -39,6 +39,12 @@
|
||||
<ClCompile Include="..\src\main.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\pcm_float_converter.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\pcm_native_converter.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\pcm_readhelper.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -59,9 +65,6 @@
|
||||
<ClInclude Include="..\src\aacenc.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\caf_reader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\catypes.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
@ -86,9 +89,6 @@
|
||||
<ClInclude Include="..\src\progress.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\wav_reader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\missings\getopt.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
@ -7,12 +7,14 @@ fdkaac_SOURCES = \
|
||||
src/aacenc.c \
|
||||
src/caf_reader.c \
|
||||
src/extrapolater.c \
|
||||
src/limiter.c \
|
||||
src/lpc.c \
|
||||
src/lpcm.c \
|
||||
src/m4af.c \
|
||||
src/main.c \
|
||||
src/metadata.c \
|
||||
src/parson.c \
|
||||
src/pcm_float_converter.c \
|
||||
src/pcm_native_converter.c \
|
||||
src/pcm_readhelper.c \
|
||||
src/pcm_sint16_converter.c \
|
||||
src/progress.c \
|
||||
|
268
m4/iconv.m4
Normal file
268
m4/iconv.m4
Normal file
@ -0,0 +1,268 @@
|
||||
# iconv.m4 serial 18 (gettext-0.18.2)
|
||||
dnl Copyright (C) 2000-2002, 2007-2014 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Bruno Haible.
|
||||
|
||||
AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
|
||||
[
|
||||
dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
|
||||
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
|
||||
AC_REQUIRE([AC_LIB_RPATH])
|
||||
|
||||
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
|
||||
dnl accordingly.
|
||||
AC_LIB_LINKFLAGS_BODY([iconv])
|
||||
])
|
||||
|
||||
AC_DEFUN([AM_ICONV_LINK],
|
||||
[
|
||||
dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
|
||||
dnl those with the standalone portable GNU libiconv installed).
|
||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
||||
|
||||
dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
|
||||
dnl accordingly.
|
||||
AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
|
||||
|
||||
dnl Add $INCICONV to CPPFLAGS before performing the following checks,
|
||||
dnl because if the user has installed libiconv and not disabled its use
|
||||
dnl via --without-libiconv-prefix, he wants to use it. The first
|
||||
dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed.
|
||||
am_save_CPPFLAGS="$CPPFLAGS"
|
||||
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
|
||||
|
||||
AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [
|
||||
am_cv_func_iconv="no, consider installing GNU libiconv"
|
||||
am_cv_lib_iconv=no
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[
|
||||
#include <stdlib.h>
|
||||
#include <iconv.h>
|
||||
]],
|
||||
[[iconv_t cd = iconv_open("","");
|
||||
iconv(cd,NULL,NULL,NULL,NULL);
|
||||
iconv_close(cd);]])],
|
||||
[am_cv_func_iconv=yes])
|
||||
if test "$am_cv_func_iconv" != yes; then
|
||||
am_save_LIBS="$LIBS"
|
||||
LIBS="$LIBS $LIBICONV"
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[
|
||||
#include <stdlib.h>
|
||||
#include <iconv.h>
|
||||
]],
|
||||
[[iconv_t cd = iconv_open("","");
|
||||
iconv(cd,NULL,NULL,NULL,NULL);
|
||||
iconv_close(cd);]])],
|
||||
[am_cv_lib_iconv=yes]
|
||||
[am_cv_func_iconv=yes])
|
||||
LIBS="$am_save_LIBS"
|
||||
fi
|
||||
])
|
||||
if test "$am_cv_func_iconv" = yes; then
|
||||
AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [
|
||||
dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11,
|
||||
dnl Solaris 10.
|
||||
am_save_LIBS="$LIBS"
|
||||
if test $am_cv_lib_iconv = yes; then
|
||||
LIBS="$LIBS $LIBICONV"
|
||||
fi
|
||||
AC_RUN_IFELSE(
|
||||
[AC_LANG_SOURCE([[
|
||||
#include <iconv.h>
|
||||
#include <string.h>
|
||||
int main ()
|
||||
{
|
||||
int result = 0;
|
||||
/* Test against AIX 5.1 bug: Failures are not distinguishable from successful
|
||||
returns. */
|
||||
{
|
||||
iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");
|
||||
if (cd_utf8_to_88591 != (iconv_t)(-1))
|
||||
{
|
||||
static const char input[] = "\342\202\254"; /* EURO SIGN */
|
||||
char buf[10];
|
||||
const char *inptr = input;
|
||||
size_t inbytesleft = strlen (input);
|
||||
char *outptr = buf;
|
||||
size_t outbytesleft = sizeof (buf);
|
||||
size_t res = iconv (cd_utf8_to_88591,
|
||||
(char **) &inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
if (res == 0)
|
||||
result |= 1;
|
||||
iconv_close (cd_utf8_to_88591);
|
||||
}
|
||||
}
|
||||
/* Test against Solaris 10 bug: Failures are not distinguishable from
|
||||
successful returns. */
|
||||
{
|
||||
iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");
|
||||
if (cd_ascii_to_88591 != (iconv_t)(-1))
|
||||
{
|
||||
static const char input[] = "\263";
|
||||
char buf[10];
|
||||
const char *inptr = input;
|
||||
size_t inbytesleft = strlen (input);
|
||||
char *outptr = buf;
|
||||
size_t outbytesleft = sizeof (buf);
|
||||
size_t res = iconv (cd_ascii_to_88591,
|
||||
(char **) &inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
if (res == 0)
|
||||
result |= 2;
|
||||
iconv_close (cd_ascii_to_88591);
|
||||
}
|
||||
}
|
||||
/* Test against AIX 6.1..7.1 bug: Buffer overrun. */
|
||||
{
|
||||
iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");
|
||||
if (cd_88591_to_utf8 != (iconv_t)(-1))
|
||||
{
|
||||
static const char input[] = "\304";
|
||||
static char buf[2] = { (char)0xDE, (char)0xAD };
|
||||
const char *inptr = input;
|
||||
size_t inbytesleft = 1;
|
||||
char *outptr = buf;
|
||||
size_t outbytesleft = 1;
|
||||
size_t res = iconv (cd_88591_to_utf8,
|
||||
(char **) &inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)
|
||||
result |= 4;
|
||||
iconv_close (cd_88591_to_utf8);
|
||||
}
|
||||
}
|
||||
#if 0 /* This bug could be worked around by the caller. */
|
||||
/* Test against HP-UX 11.11 bug: Positive return value instead of 0. */
|
||||
{
|
||||
iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");
|
||||
if (cd_88591_to_utf8 != (iconv_t)(-1))
|
||||
{
|
||||
static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";
|
||||
char buf[50];
|
||||
const char *inptr = input;
|
||||
size_t inbytesleft = strlen (input);
|
||||
char *outptr = buf;
|
||||
size_t outbytesleft = sizeof (buf);
|
||||
size_t res = iconv (cd_88591_to_utf8,
|
||||
(char **) &inptr, &inbytesleft,
|
||||
&outptr, &outbytesleft);
|
||||
if ((int)res > 0)
|
||||
result |= 8;
|
||||
iconv_close (cd_88591_to_utf8);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
|
||||
provided. */
|
||||
if (/* Try standardized names. */
|
||||
iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
|
||||
/* Try IRIX, OSF/1 names. */
|
||||
&& iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
|
||||
/* Try AIX names. */
|
||||
&& iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
|
||||
/* Try HP-UX names. */
|
||||
&& iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
|
||||
result |= 16;
|
||||
return result;
|
||||
}]])],
|
||||
[am_cv_func_iconv_works=yes],
|
||||
[am_cv_func_iconv_works=no],
|
||||
[
|
||||
changequote(,)dnl
|
||||
case "$host_os" in
|
||||
aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;
|
||||
*) am_cv_func_iconv_works="guessing yes" ;;
|
||||
esac
|
||||
changequote([,])dnl
|
||||
])
|
||||
LIBS="$am_save_LIBS"
|
||||
])
|
||||
case "$am_cv_func_iconv_works" in
|
||||
*no) am_func_iconv=no am_cv_lib_iconv=no ;;
|
||||
*) am_func_iconv=yes ;;
|
||||
esac
|
||||
else
|
||||
am_func_iconv=no am_cv_lib_iconv=no
|
||||
fi
|
||||
if test "$am_func_iconv" = yes; then
|
||||
AC_DEFINE([HAVE_ICONV], [1],
|
||||
[Define if you have the iconv() function and it works.])
|
||||
fi
|
||||
if test "$am_cv_lib_iconv" = yes; then
|
||||
AC_MSG_CHECKING([how to link with libiconv])
|
||||
AC_MSG_RESULT([$LIBICONV])
|
||||
else
|
||||
dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
|
||||
dnl either.
|
||||
CPPFLAGS="$am_save_CPPFLAGS"
|
||||
LIBICONV=
|
||||
LTLIBICONV=
|
||||
fi
|
||||
AC_SUBST([LIBICONV])
|
||||
AC_SUBST([LTLIBICONV])
|
||||
])
|
||||
|
||||
dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to
|
||||
dnl avoid warnings like
|
||||
dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required".
|
||||
dnl This is tricky because of the way 'aclocal' is implemented:
|
||||
dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN.
|
||||
dnl Otherwise aclocal's initial scan pass would miss the macro definition.
|
||||
dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions.
|
||||
dnl Otherwise aclocal would emit many "Use of uninitialized value $1"
|
||||
dnl warnings.
|
||||
m4_define([gl_iconv_AC_DEFUN],
|
||||
m4_version_prereq([2.64],
|
||||
[[AC_DEFUN_ONCE(
|
||||
[$1], [$2])]],
|
||||
[m4_ifdef([gl_00GNULIB],
|
||||
[[AC_DEFUN_ONCE(
|
||||
[$1], [$2])]],
|
||||
[[AC_DEFUN(
|
||||
[$1], [$2])]])]))
|
||||
gl_iconv_AC_DEFUN([AM_ICONV],
|
||||
[
|
||||
AM_ICONV_LINK
|
||||
if test "$am_cv_func_iconv" = yes; then
|
||||
AC_MSG_CHECKING([for iconv declaration])
|
||||
AC_CACHE_VAL([am_cv_proto_iconv], [
|
||||
AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[
|
||||
#include <stdlib.h>
|
||||
#include <iconv.h>
|
||||
extern
|
||||
#ifdef __cplusplus
|
||||
"C"
|
||||
#endif
|
||||
#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
|
||||
size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
|
||||
#else
|
||||
size_t iconv();
|
||||
#endif
|
||||
]],
|
||||
[[]])],
|
||||
[am_cv_proto_iconv_arg1=""],
|
||||
[am_cv_proto_iconv_arg1="const"])
|
||||
am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
|
||||
am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
|
||||
AC_MSG_RESULT([
|
||||
$am_cv_proto_iconv])
|
||||
AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1],
|
||||
[Define as const if the declaration of iconv() needs const.])
|
||||
dnl Also substitute ICONV_CONST in the gnulib generated <iconv.h>.
|
||||
m4_ifdef([gl_ICONV_H_DEFAULTS],
|
||||
[AC_REQUIRE([gl_ICONV_H_DEFAULTS])
|
||||
if test -n "$am_cv_proto_iconv_arg1"; then
|
||||
ICONV_CONST="const"
|
||||
fi
|
||||
])
|
||||
fi
|
||||
])
|
119
m4/lib-ld.m4
Normal file
119
m4/lib-ld.m4
Normal file
@ -0,0 +1,119 @@
|
||||
# lib-ld.m4 serial 6
|
||||
dnl Copyright (C) 1996-2003, 2009-2014 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl Subroutines of libtool.m4,
|
||||
dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid
|
||||
dnl collision with libtool.m4.
|
||||
|
||||
dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no.
|
||||
AC_DEFUN([AC_LIB_PROG_LD_GNU],
|
||||
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld],
|
||||
[# I'd rather use --version here, but apparently some GNU lds only accept -v.
|
||||
case `$LD -v 2>&1 </dev/null` in
|
||||
*GNU* | *'with BFD'*)
|
||||
acl_cv_prog_gnu_ld=yes
|
||||
;;
|
||||
*)
|
||||
acl_cv_prog_gnu_ld=no
|
||||
;;
|
||||
esac])
|
||||
with_gnu_ld=$acl_cv_prog_gnu_ld
|
||||
])
|
||||
|
||||
dnl From libtool-2.4. Sets the variable LD.
|
||||
AC_DEFUN([AC_LIB_PROG_LD],
|
||||
[AC_REQUIRE([AC_PROG_CC])dnl
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
||||
|
||||
AC_ARG_WITH([gnu-ld],
|
||||
[AS_HELP_STRING([--with-gnu-ld],
|
||||
[assume the C compiler uses GNU ld [default=no]])],
|
||||
[test "$withval" = no || with_gnu_ld=yes],
|
||||
[with_gnu_ld=no])dnl
|
||||
|
||||
# Prepare PATH_SEPARATOR.
|
||||
# The user is always right.
|
||||
if test "${PATH_SEPARATOR+set}" != set; then
|
||||
# Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
|
||||
# contains only /bin. Note that ksh looks also at the FPATH variable,
|
||||
# so we have to set that as well for the test.
|
||||
PATH_SEPARATOR=:
|
||||
(PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
|
||||
&& { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
|
||||
|| PATH_SEPARATOR=';'
|
||||
}
|
||||
fi
|
||||
|
||||
ac_prog=ld
|
||||
if test "$GCC" = yes; then
|
||||
# Check if gcc -print-prog-name=ld gives a path.
|
||||
AC_MSG_CHECKING([for ld used by $CC])
|
||||
case $host in
|
||||
*-*-mingw*)
|
||||
# gcc leaves a trailing carriage return which upsets mingw
|
||||
ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
|
||||
*)
|
||||
ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
|
||||
esac
|
||||
case $ac_prog in
|
||||
# Accept absolute paths.
|
||||
[[\\/]]* | ?:[[\\/]]*)
|
||||
re_direlt='/[[^/]][[^/]]*/\.\./'
|
||||
# Canonicalize the pathname of ld
|
||||
ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'`
|
||||
while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do
|
||||
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
|
||||
done
|
||||
test -z "$LD" && LD="$ac_prog"
|
||||
;;
|
||||
"")
|
||||
# If it fails, then pretend we aren't using GCC.
|
||||
ac_prog=ld
|
||||
;;
|
||||
*)
|
||||
# If it is relative, then search for the first ld in PATH.
|
||||
with_gnu_ld=unknown
|
||||
;;
|
||||
esac
|
||||
elif test "$with_gnu_ld" = yes; then
|
||||
AC_MSG_CHECKING([for GNU ld])
|
||||
else
|
||||
AC_MSG_CHECKING([for non-GNU ld])
|
||||
fi
|
||||
AC_CACHE_VAL([acl_cv_path_LD],
|
||||
[if test -z "$LD"; then
|
||||
acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
|
||||
for ac_dir in $PATH; do
|
||||
IFS="$acl_save_ifs"
|
||||
test -z "$ac_dir" && ac_dir=.
|
||||
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
|
||||
acl_cv_path_LD="$ac_dir/$ac_prog"
|
||||
# Check to see if the program is GNU ld. I'd rather use --version,
|
||||
# but apparently some variants of GNU ld only accept -v.
|
||||
# Break only if it was the GNU/non-GNU ld that we prefer.
|
||||
case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in
|
||||
*GNU* | *'with BFD'*)
|
||||
test "$with_gnu_ld" != no && break
|
||||
;;
|
||||
*)
|
||||
test "$with_gnu_ld" != yes && break
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
IFS="$acl_save_ifs"
|
||||
else
|
||||
acl_cv_path_LD="$LD" # Let the user override the test with a path.
|
||||
fi])
|
||||
LD="$acl_cv_path_LD"
|
||||
if test -n "$LD"; then
|
||||
AC_MSG_RESULT([$LD])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
fi
|
||||
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
|
||||
AC_LIB_PROG_LD_GNU
|
||||
])
|
777
m4/lib-link.m4
Normal file
777
m4/lib-link.m4
Normal file
@ -0,0 +1,777 @@
|
||||
# lib-link.m4 serial 26 (gettext-0.18.2)
|
||||
dnl Copyright (C) 2001-2014 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Bruno Haible.
|
||||
|
||||
AC_PREREQ([2.54])
|
||||
|
||||
dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
|
||||
dnl the libraries corresponding to explicit and implicit dependencies.
|
||||
dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
|
||||
dnl augments the CPPFLAGS variable.
|
||||
dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
|
||||
dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
|
||||
AC_DEFUN([AC_LIB_LINKFLAGS],
|
||||
[
|
||||
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
|
||||
AC_REQUIRE([AC_LIB_RPATH])
|
||||
pushdef([Name],[m4_translit([$1],[./+-], [____])])
|
||||
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
|
||||
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
|
||||
AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
|
||||
AC_LIB_LINKFLAGS_BODY([$1], [$2])
|
||||
ac_cv_lib[]Name[]_libs="$LIB[]NAME"
|
||||
ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
|
||||
ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
|
||||
ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
|
||||
])
|
||||
LIB[]NAME="$ac_cv_lib[]Name[]_libs"
|
||||
LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
|
||||
INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
|
||||
LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
|
||||
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
|
||||
AC_SUBST([LIB]NAME)
|
||||
AC_SUBST([LTLIB]NAME)
|
||||
AC_SUBST([LIB]NAME[_PREFIX])
|
||||
dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
|
||||
dnl results of this search when this library appears as a dependency.
|
||||
HAVE_LIB[]NAME=yes
|
||||
popdef([NAME])
|
||||
popdef([Name])
|
||||
])
|
||||
|
||||
dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message])
|
||||
dnl searches for libname and the libraries corresponding to explicit and
|
||||
dnl implicit dependencies, together with the specified include files and
|
||||
dnl the ability to compile and link the specified testcode. The missing-message
|
||||
dnl defaults to 'no' and may contain additional hints for the user.
|
||||
dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME}
|
||||
dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and
|
||||
dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
|
||||
dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
|
||||
dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
|
||||
dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
|
||||
AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
|
||||
[
|
||||
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
|
||||
AC_REQUIRE([AC_LIB_RPATH])
|
||||
pushdef([Name],[m4_translit([$1],[./+-], [____])])
|
||||
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
|
||||
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
|
||||
|
||||
dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
|
||||
dnl accordingly.
|
||||
AC_LIB_LINKFLAGS_BODY([$1], [$2])
|
||||
|
||||
dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
|
||||
dnl because if the user has installed lib[]Name and not disabled its use
|
||||
dnl via --without-lib[]Name-prefix, he wants to use it.
|
||||
ac_save_CPPFLAGS="$CPPFLAGS"
|
||||
AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
|
||||
|
||||
AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
|
||||
ac_save_LIBS="$LIBS"
|
||||
dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
|
||||
dnl because these -l options might require -L options that are present in
|
||||
dnl LIBS. -l options benefit only from the -L options listed before it.
|
||||
dnl Otherwise, add it to the front of LIBS, because it may be a static
|
||||
dnl library that depends on another static library that is present in LIBS.
|
||||
dnl Static libraries benefit only from the static libraries listed after
|
||||
dnl it.
|
||||
case " $LIB[]NAME" in
|
||||
*" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
|
||||
*) LIBS="$LIB[]NAME $LIBS" ;;
|
||||
esac
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM([[$3]], [[$4]])],
|
||||
[ac_cv_lib[]Name=yes],
|
||||
[ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
|
||||
LIBS="$ac_save_LIBS"
|
||||
])
|
||||
if test "$ac_cv_lib[]Name" = yes; then
|
||||
HAVE_LIB[]NAME=yes
|
||||
AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
|
||||
AC_MSG_CHECKING([how to link with lib[]$1])
|
||||
AC_MSG_RESULT([$LIB[]NAME])
|
||||
else
|
||||
HAVE_LIB[]NAME=no
|
||||
dnl If $LIB[]NAME didn't lead to a usable library, we don't need
|
||||
dnl $INC[]NAME either.
|
||||
CPPFLAGS="$ac_save_CPPFLAGS"
|
||||
LIB[]NAME=
|
||||
LTLIB[]NAME=
|
||||
LIB[]NAME[]_PREFIX=
|
||||
fi
|
||||
AC_SUBST([HAVE_LIB]NAME)
|
||||
AC_SUBST([LIB]NAME)
|
||||
AC_SUBST([LTLIB]NAME)
|
||||
AC_SUBST([LIB]NAME[_PREFIX])
|
||||
popdef([NAME])
|
||||
popdef([Name])
|
||||
])
|
||||
|
||||
dnl Determine the platform dependent parameters needed to use rpath:
|
||||
dnl acl_libext,
|
||||
dnl acl_shlibext,
|
||||
dnl acl_libname_spec,
|
||||
dnl acl_library_names_spec,
|
||||
dnl acl_hardcode_libdir_flag_spec,
|
||||
dnl acl_hardcode_libdir_separator,
|
||||
dnl acl_hardcode_direct,
|
||||
dnl acl_hardcode_minus_L.
|
||||
AC_DEFUN([AC_LIB_RPATH],
|
||||
[
|
||||
dnl Tell automake >= 1.10 to complain if config.rpath is missing.
|
||||
m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
|
||||
AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
|
||||
AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
|
||||
AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
|
||||
AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
|
||||
AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
|
||||
CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
|
||||
${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
|
||||
. ./conftest.sh
|
||||
rm -f ./conftest.sh
|
||||
acl_cv_rpath=done
|
||||
])
|
||||
wl="$acl_cv_wl"
|
||||
acl_libext="$acl_cv_libext"
|
||||
acl_shlibext="$acl_cv_shlibext"
|
||||
acl_libname_spec="$acl_cv_libname_spec"
|
||||
acl_library_names_spec="$acl_cv_library_names_spec"
|
||||
acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
|
||||
acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
|
||||
acl_hardcode_direct="$acl_cv_hardcode_direct"
|
||||
acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
|
||||
dnl Determine whether the user wants rpath handling at all.
|
||||
AC_ARG_ENABLE([rpath],
|
||||
[ --disable-rpath do not hardcode runtime library paths],
|
||||
:, enable_rpath=yes)
|
||||
])
|
||||
|
||||
dnl AC_LIB_FROMPACKAGE(name, package)
|
||||
dnl declares that libname comes from the given package. The configure file
|
||||
dnl will then not have a --with-libname-prefix option but a
|
||||
dnl --with-package-prefix option. Several libraries can come from the same
|
||||
dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
|
||||
dnl macro call that searches for libname.
|
||||
AC_DEFUN([AC_LIB_FROMPACKAGE],
|
||||
[
|
||||
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
|
||||
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
|
||||
define([acl_frompackage_]NAME, [$2])
|
||||
popdef([NAME])
|
||||
pushdef([PACK],[$2])
|
||||
pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
|
||||
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
|
||||
define([acl_libsinpackage_]PACKUP,
|
||||
m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1])
|
||||
popdef([PACKUP])
|
||||
popdef([PACK])
|
||||
])
|
||||
|
||||
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
|
||||
dnl the libraries corresponding to explicit and implicit dependencies.
|
||||
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
|
||||
dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
|
||||
dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
|
||||
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
|
||||
[
|
||||
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
|
||||
pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-],
|
||||
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
|
||||
pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
|
||||
pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-],
|
||||
[ABCDEFGHIJKLMNOPQRSTUVWXYZ____])])
|
||||
pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
|
||||
dnl Autoconf >= 2.61 supports dots in --with options.
|
||||
pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)])
|
||||
dnl By default, look in $includedir and $libdir.
|
||||
use_additional=yes
|
||||
AC_LIB_WITH_FINAL_PREFIX([
|
||||
eval additional_includedir=\"$includedir\"
|
||||
eval additional_libdir=\"$libdir\"
|
||||
])
|
||||
AC_ARG_WITH(P_A_C_K[-prefix],
|
||||
[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
|
||||
--without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
|
||||
[
|
||||
if test "X$withval" = "Xno"; then
|
||||
use_additional=no
|
||||
else
|
||||
if test "X$withval" = "X"; then
|
||||
AC_LIB_WITH_FINAL_PREFIX([
|
||||
eval additional_includedir=\"$includedir\"
|
||||
eval additional_libdir=\"$libdir\"
|
||||
])
|
||||
else
|
||||
additional_includedir="$withval/include"
|
||||
additional_libdir="$withval/$acl_libdirstem"
|
||||
if test "$acl_libdirstem2" != "$acl_libdirstem" \
|
||||
&& ! test -d "$withval/$acl_libdirstem"; then
|
||||
additional_libdir="$withval/$acl_libdirstem2"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
])
|
||||
dnl Search the library and its dependencies in $additional_libdir and
|
||||
dnl $LDFLAGS. Using breadth-first-seach.
|
||||
LIB[]NAME=
|
||||
LTLIB[]NAME=
|
||||
INC[]NAME=
|
||||
LIB[]NAME[]_PREFIX=
|
||||
dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
|
||||
dnl computed. So it has to be reset here.
|
||||
HAVE_LIB[]NAME=
|
||||
rpathdirs=
|
||||
ltrpathdirs=
|
||||
names_already_handled=
|
||||
names_next_round='$1 $2'
|
||||
while test -n "$names_next_round"; do
|
||||
names_this_round="$names_next_round"
|
||||
names_next_round=
|
||||
for name in $names_this_round; do
|
||||
already_handled=
|
||||
for n in $names_already_handled; do
|
||||
if test "$n" = "$name"; then
|
||||
already_handled=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$already_handled"; then
|
||||
names_already_handled="$names_already_handled $name"
|
||||
dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
|
||||
dnl or AC_LIB_HAVE_LINKFLAGS call.
|
||||
uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`
|
||||
eval value=\"\$HAVE_LIB$uppername\"
|
||||
if test -n "$value"; then
|
||||
if test "$value" = yes; then
|
||||
eval value=\"\$LIB$uppername\"
|
||||
test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
|
||||
eval value=\"\$LTLIB$uppername\"
|
||||
test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
|
||||
else
|
||||
dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
|
||||
dnl that this library doesn't exist. So just drop it.
|
||||
:
|
||||
fi
|
||||
else
|
||||
dnl Search the library lib$name in $additional_libdir and $LDFLAGS
|
||||
dnl and the already constructed $LIBNAME/$LTLIBNAME.
|
||||
found_dir=
|
||||
found_la=
|
||||
found_so=
|
||||
found_a=
|
||||
eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
|
||||
if test -n "$acl_shlibext"; then
|
||||
shrext=".$acl_shlibext" # typically: shrext=.so
|
||||
else
|
||||
shrext=
|
||||
fi
|
||||
if test $use_additional = yes; then
|
||||
dir="$additional_libdir"
|
||||
dnl The same code as in the loop below:
|
||||
dnl First look for a shared library.
|
||||
if test -n "$acl_shlibext"; then
|
||||
if test -f "$dir/$libname$shrext"; then
|
||||
found_dir="$dir"
|
||||
found_so="$dir/$libname$shrext"
|
||||
else
|
||||
if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
|
||||
ver=`(cd "$dir" && \
|
||||
for f in "$libname$shrext".*; do echo "$f"; done \
|
||||
| sed -e "s,^$libname$shrext\\\\.,," \
|
||||
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
|
||||
| sed 1q ) 2>/dev/null`
|
||||
if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
|
||||
found_dir="$dir"
|
||||
found_so="$dir/$libname$shrext.$ver"
|
||||
fi
|
||||
else
|
||||
eval library_names=\"$acl_library_names_spec\"
|
||||
for f in $library_names; do
|
||||
if test -f "$dir/$f"; then
|
||||
found_dir="$dir"
|
||||
found_so="$dir/$f"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
dnl Then look for a static library.
|
||||
if test "X$found_dir" = "X"; then
|
||||
if test -f "$dir/$libname.$acl_libext"; then
|
||||
found_dir="$dir"
|
||||
found_a="$dir/$libname.$acl_libext"
|
||||
fi
|
||||
fi
|
||||
if test "X$found_dir" != "X"; then
|
||||
if test -f "$dir/$libname.la"; then
|
||||
found_la="$dir/$libname.la"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if test "X$found_dir" = "X"; then
|
||||
for x in $LDFLAGS $LTLIB[]NAME; do
|
||||
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
|
||||
case "$x" in
|
||||
-L*)
|
||||
dir=`echo "X$x" | sed -e 's/^X-L//'`
|
||||
dnl First look for a shared library.
|
||||
if test -n "$acl_shlibext"; then
|
||||
if test -f "$dir/$libname$shrext"; then
|
||||
found_dir="$dir"
|
||||
found_so="$dir/$libname$shrext"
|
||||
else
|
||||
if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
|
||||
ver=`(cd "$dir" && \
|
||||
for f in "$libname$shrext".*; do echo "$f"; done \
|
||||
| sed -e "s,^$libname$shrext\\\\.,," \
|
||||
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
|
||||
| sed 1q ) 2>/dev/null`
|
||||
if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
|
||||
found_dir="$dir"
|
||||
found_so="$dir/$libname$shrext.$ver"
|
||||
fi
|
||||
else
|
||||
eval library_names=\"$acl_library_names_spec\"
|
||||
for f in $library_names; do
|
||||
if test -f "$dir/$f"; then
|
||||
found_dir="$dir"
|
||||
found_so="$dir/$f"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
dnl Then look for a static library.
|
||||
if test "X$found_dir" = "X"; then
|
||||
if test -f "$dir/$libname.$acl_libext"; then
|
||||
found_dir="$dir"
|
||||
found_a="$dir/$libname.$acl_libext"
|
||||
fi
|
||||
fi
|
||||
if test "X$found_dir" != "X"; then
|
||||
if test -f "$dir/$libname.la"; then
|
||||
found_la="$dir/$libname.la"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if test "X$found_dir" != "X"; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if test "X$found_dir" != "X"; then
|
||||
dnl Found the library.
|
||||
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
|
||||
if test "X$found_so" != "X"; then
|
||||
dnl Linking with a shared library. We attempt to hardcode its
|
||||
dnl directory into the executable's runpath, unless it's the
|
||||
dnl standard /usr/lib.
|
||||
if test "$enable_rpath" = no \
|
||||
|| test "X$found_dir" = "X/usr/$acl_libdirstem" \
|
||||
|| test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
|
||||
dnl No hardcoding is needed.
|
||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
|
||||
else
|
||||
dnl Use an explicit option to hardcode DIR into the resulting
|
||||
dnl binary.
|
||||
dnl Potentially add DIR to ltrpathdirs.
|
||||
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
|
||||
haveit=
|
||||
for x in $ltrpathdirs; do
|
||||
if test "X$x" = "X$found_dir"; then
|
||||
haveit=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$haveit"; then
|
||||
ltrpathdirs="$ltrpathdirs $found_dir"
|
||||
fi
|
||||
dnl The hardcoding into $LIBNAME is system dependent.
|
||||
if test "$acl_hardcode_direct" = yes; then
|
||||
dnl Using DIR/libNAME.so during linking hardcodes DIR into the
|
||||
dnl resulting binary.
|
||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
|
||||
else
|
||||
if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
|
||||
dnl Use an explicit option to hardcode DIR into the resulting
|
||||
dnl binary.
|
||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
|
||||
dnl Potentially add DIR to rpathdirs.
|
||||
dnl The rpathdirs will be appended to $LIBNAME at the end.
|
||||
haveit=
|
||||
for x in $rpathdirs; do
|
||||
if test "X$x" = "X$found_dir"; then
|
||||
haveit=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$haveit"; then
|
||||
rpathdirs="$rpathdirs $found_dir"
|
||||
fi
|
||||
else
|
||||
dnl Rely on "-L$found_dir".
|
||||
dnl But don't add it if it's already contained in the LDFLAGS
|
||||
dnl or the already constructed $LIBNAME
|
||||
haveit=
|
||||
for x in $LDFLAGS $LIB[]NAME; do
|
||||
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
|
||||
if test "X$x" = "X-L$found_dir"; then
|
||||
haveit=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$haveit"; then
|
||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
|
||||
fi
|
||||
if test "$acl_hardcode_minus_L" != no; then
|
||||
dnl FIXME: Not sure whether we should use
|
||||
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
|
||||
dnl here.
|
||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
|
||||
else
|
||||
dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
|
||||
dnl here, because this doesn't fit in flags passed to the
|
||||
dnl compiler. So give up. No hardcoding. This affects only
|
||||
dnl very old systems.
|
||||
dnl FIXME: Not sure whether we should use
|
||||
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
|
||||
dnl here.
|
||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if test "X$found_a" != "X"; then
|
||||
dnl Linking with a static library.
|
||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
|
||||
else
|
||||
dnl We shouldn't come here, but anyway it's good to have a
|
||||
dnl fallback.
|
||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
|
||||
fi
|
||||
fi
|
||||
dnl Assume the include files are nearby.
|
||||
additional_includedir=
|
||||
case "$found_dir" in
|
||||
*/$acl_libdirstem | */$acl_libdirstem/)
|
||||
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
|
||||
if test "$name" = '$1'; then
|
||||
LIB[]NAME[]_PREFIX="$basedir"
|
||||
fi
|
||||
additional_includedir="$basedir/include"
|
||||
;;
|
||||
*/$acl_libdirstem2 | */$acl_libdirstem2/)
|
||||
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
|
||||
if test "$name" = '$1'; then
|
||||
LIB[]NAME[]_PREFIX="$basedir"
|
||||
fi
|
||||
additional_includedir="$basedir/include"
|
||||
;;
|
||||
esac
|
||||
if test "X$additional_includedir" != "X"; then
|
||||
dnl Potentially add $additional_includedir to $INCNAME.
|
||||
dnl But don't add it
|
||||
dnl 1. if it's the standard /usr/include,
|
||||
dnl 2. if it's /usr/local/include and we are using GCC on Linux,
|
||||
dnl 3. if it's already present in $CPPFLAGS or the already
|
||||
dnl constructed $INCNAME,
|
||||
dnl 4. if it doesn't exist as a directory.
|
||||
if test "X$additional_includedir" != "X/usr/include"; then
|
||||
haveit=
|
||||
if test "X$additional_includedir" = "X/usr/local/include"; then
|
||||
if test -n "$GCC"; then
|
||||
case $host_os in
|
||||
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
if test -z "$haveit"; then
|
||||
for x in $CPPFLAGS $INC[]NAME; do
|
||||
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
|
||||
if test "X$x" = "X-I$additional_includedir"; then
|
||||
haveit=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$haveit"; then
|
||||
if test -d "$additional_includedir"; then
|
||||
dnl Really add $additional_includedir to $INCNAME.
|
||||
INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
dnl Look for dependencies.
|
||||
if test -n "$found_la"; then
|
||||
dnl Read the .la file. It defines the variables
|
||||
dnl dlname, library_names, old_library, dependency_libs, current,
|
||||
dnl age, revision, installed, dlopen, dlpreopen, libdir.
|
||||
save_libdir="$libdir"
|
||||
case "$found_la" in
|
||||
*/* | *\\*) . "$found_la" ;;
|
||||
*) . "./$found_la" ;;
|
||||
esac
|
||||
libdir="$save_libdir"
|
||||
dnl We use only dependency_libs.
|
||||
for dep in $dependency_libs; do
|
||||
case "$dep" in
|
||||
-L*)
|
||||
additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
|
||||
dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
|
||||
dnl But don't add it
|
||||
dnl 1. if it's the standard /usr/lib,
|
||||
dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
|
||||
dnl 3. if it's already present in $LDFLAGS or the already
|
||||
dnl constructed $LIBNAME,
|
||||
dnl 4. if it doesn't exist as a directory.
|
||||
if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
|
||||
&& test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
|
||||
haveit=
|
||||
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
|
||||
|| test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
|
||||
if test -n "$GCC"; then
|
||||
case $host_os in
|
||||
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
if test -z "$haveit"; then
|
||||
haveit=
|
||||
for x in $LDFLAGS $LIB[]NAME; do
|
||||
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
|
||||
if test "X$x" = "X-L$additional_libdir"; then
|
||||
haveit=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$haveit"; then
|
||||
if test -d "$additional_libdir"; then
|
||||
dnl Really add $additional_libdir to $LIBNAME.
|
||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
|
||||
fi
|
||||
fi
|
||||
haveit=
|
||||
for x in $LDFLAGS $LTLIB[]NAME; do
|
||||
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
|
||||
if test "X$x" = "X-L$additional_libdir"; then
|
||||
haveit=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$haveit"; then
|
||||
if test -d "$additional_libdir"; then
|
||||
dnl Really add $additional_libdir to $LTLIBNAME.
|
||||
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
-R*)
|
||||
dir=`echo "X$dep" | sed -e 's/^X-R//'`
|
||||
if test "$enable_rpath" != no; then
|
||||
dnl Potentially add DIR to rpathdirs.
|
||||
dnl The rpathdirs will be appended to $LIBNAME at the end.
|
||||
haveit=
|
||||
for x in $rpathdirs; do
|
||||
if test "X$x" = "X$dir"; then
|
||||
haveit=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$haveit"; then
|
||||
rpathdirs="$rpathdirs $dir"
|
||||
fi
|
||||
dnl Potentially add DIR to ltrpathdirs.
|
||||
dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
|
||||
haveit=
|
||||
for x in $ltrpathdirs; do
|
||||
if test "X$x" = "X$dir"; then
|
||||
haveit=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$haveit"; then
|
||||
ltrpathdirs="$ltrpathdirs $dir"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
-l*)
|
||||
dnl Handle this in the next round.
|
||||
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
|
||||
;;
|
||||
*.la)
|
||||
dnl Handle this in the next round. Throw away the .la's
|
||||
dnl directory; it is already contained in a preceding -L
|
||||
dnl option.
|
||||
names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
|
||||
;;
|
||||
*)
|
||||
dnl Most likely an immediate library name.
|
||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
|
||||
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
else
|
||||
dnl Didn't find the library; assume it is in the system directories
|
||||
dnl known to the linker and runtime loader. (All the system
|
||||
dnl directories known to the linker should also be known to the
|
||||
dnl runtime loader, otherwise the system is severely misconfigured.)
|
||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
|
||||
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
if test "X$rpathdirs" != "X"; then
|
||||
if test -n "$acl_hardcode_libdir_separator"; then
|
||||
dnl Weird platform: only the last -rpath option counts, the user must
|
||||
dnl pass all path elements in one option. We can arrange that for a
|
||||
dnl single library, but not when more than one $LIBNAMEs are used.
|
||||
alldirs=
|
||||
for found_dir in $rpathdirs; do
|
||||
alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
|
||||
done
|
||||
dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
|
||||
acl_save_libdir="$libdir"
|
||||
libdir="$alldirs"
|
||||
eval flag=\"$acl_hardcode_libdir_flag_spec\"
|
||||
libdir="$acl_save_libdir"
|
||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
|
||||
else
|
||||
dnl The -rpath options are cumulative.
|
||||
for found_dir in $rpathdirs; do
|
||||
acl_save_libdir="$libdir"
|
||||
libdir="$found_dir"
|
||||
eval flag=\"$acl_hardcode_libdir_flag_spec\"
|
||||
libdir="$acl_save_libdir"
|
||||
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
if test "X$ltrpathdirs" != "X"; then
|
||||
dnl When using libtool, the option that works for both libraries and
|
||||
dnl executables is -R. The -R options are cumulative.
|
||||
for found_dir in $ltrpathdirs; do
|
||||
LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
|
||||
done
|
||||
fi
|
||||
popdef([P_A_C_K])
|
||||
popdef([PACKLIBS])
|
||||
popdef([PACKUP])
|
||||
popdef([PACK])
|
||||
popdef([NAME])
|
||||
])
|
||||
|
||||
dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
|
||||
dnl unless already present in VAR.
|
||||
dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
|
||||
dnl contains two or three consecutive elements that belong together.
|
||||
AC_DEFUN([AC_LIB_APPENDTOVAR],
|
||||
[
|
||||
for element in [$2]; do
|
||||
haveit=
|
||||
for x in $[$1]; do
|
||||
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
|
||||
if test "X$x" = "X$element"; then
|
||||
haveit=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$haveit"; then
|
||||
[$1]="${[$1]}${[$1]:+ }$element"
|
||||
fi
|
||||
done
|
||||
])
|
||||
|
||||
dnl For those cases where a variable contains several -L and -l options
|
||||
dnl referring to unknown libraries and directories, this macro determines the
|
||||
dnl necessary additional linker options for the runtime path.
|
||||
dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
|
||||
dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
|
||||
dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
|
||||
dnl otherwise linking without libtool is assumed.
|
||||
AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
|
||||
[
|
||||
AC_REQUIRE([AC_LIB_RPATH])
|
||||
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
|
||||
$1=
|
||||
if test "$enable_rpath" != no; then
|
||||
if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
|
||||
dnl Use an explicit option to hardcode directories into the resulting
|
||||
dnl binary.
|
||||
rpathdirs=
|
||||
next=
|
||||
for opt in $2; do
|
||||
if test -n "$next"; then
|
||||
dir="$next"
|
||||
dnl No need to hardcode the standard /usr/lib.
|
||||
if test "X$dir" != "X/usr/$acl_libdirstem" \
|
||||
&& test "X$dir" != "X/usr/$acl_libdirstem2"; then
|
||||
rpathdirs="$rpathdirs $dir"
|
||||
fi
|
||||
next=
|
||||
else
|
||||
case $opt in
|
||||
-L) next=yes ;;
|
||||
-L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
|
||||
dnl No need to hardcode the standard /usr/lib.
|
||||
if test "X$dir" != "X/usr/$acl_libdirstem" \
|
||||
&& test "X$dir" != "X/usr/$acl_libdirstem2"; then
|
||||
rpathdirs="$rpathdirs $dir"
|
||||
fi
|
||||
next= ;;
|
||||
*) next= ;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
if test "X$rpathdirs" != "X"; then
|
||||
if test -n ""$3""; then
|
||||
dnl libtool is used for linking. Use -R options.
|
||||
for dir in $rpathdirs; do
|
||||
$1="${$1}${$1:+ }-R$dir"
|
||||
done
|
||||
else
|
||||
dnl The linker is used for linking directly.
|
||||
if test -n "$acl_hardcode_libdir_separator"; then
|
||||
dnl Weird platform: only the last -rpath option counts, the user
|
||||
dnl must pass all path elements in one option.
|
||||
alldirs=
|
||||
for dir in $rpathdirs; do
|
||||
alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
|
||||
done
|
||||
acl_save_libdir="$libdir"
|
||||
libdir="$alldirs"
|
||||
eval flag=\"$acl_hardcode_libdir_flag_spec\"
|
||||
libdir="$acl_save_libdir"
|
||||
$1="$flag"
|
||||
else
|
||||
dnl The -rpath options are cumulative.
|
||||
for dir in $rpathdirs; do
|
||||
acl_save_libdir="$libdir"
|
||||
libdir="$dir"
|
||||
eval flag=\"$acl_hardcode_libdir_flag_spec\"
|
||||
libdir="$acl_save_libdir"
|
||||
$1="${$1}${$1:+ }$flag"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
AC_SUBST([$1])
|
||||
])
|
224
m4/lib-prefix.m4
Normal file
224
m4/lib-prefix.m4
Normal file
@ -0,0 +1,224 @@
|
||||
# lib-prefix.m4 serial 7 (gettext-0.18)
|
||||
dnl Copyright (C) 2001-2005, 2008-2014 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
dnl From Bruno Haible.
|
||||
|
||||
dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
|
||||
dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
|
||||
dnl require excessive bracketing.
|
||||
ifdef([AC_HELP_STRING],
|
||||
[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
|
||||
[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
|
||||
|
||||
dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
|
||||
dnl to access previously installed libraries. The basic assumption is that
|
||||
dnl a user will want packages to use other packages he previously installed
|
||||
dnl with the same --prefix option.
|
||||
dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
|
||||
dnl libraries, but is otherwise very convenient.
|
||||
AC_DEFUN([AC_LIB_PREFIX],
|
||||
[
|
||||
AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
|
||||
AC_REQUIRE([AC_PROG_CC])
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
|
||||
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
|
||||
dnl By default, look in $includedir and $libdir.
|
||||
use_additional=yes
|
||||
AC_LIB_WITH_FINAL_PREFIX([
|
||||
eval additional_includedir=\"$includedir\"
|
||||
eval additional_libdir=\"$libdir\"
|
||||
])
|
||||
AC_LIB_ARG_WITH([lib-prefix],
|
||||
[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
|
||||
--without-lib-prefix don't search for libraries in includedir and libdir],
|
||||
[
|
||||
if test "X$withval" = "Xno"; then
|
||||
use_additional=no
|
||||
else
|
||||
if test "X$withval" = "X"; then
|
||||
AC_LIB_WITH_FINAL_PREFIX([
|
||||
eval additional_includedir=\"$includedir\"
|
||||
eval additional_libdir=\"$libdir\"
|
||||
])
|
||||
else
|
||||
additional_includedir="$withval/include"
|
||||
additional_libdir="$withval/$acl_libdirstem"
|
||||
fi
|
||||
fi
|
||||
])
|
||||
if test $use_additional = yes; then
|
||||
dnl Potentially add $additional_includedir to $CPPFLAGS.
|
||||
dnl But don't add it
|
||||
dnl 1. if it's the standard /usr/include,
|
||||
dnl 2. if it's already present in $CPPFLAGS,
|
||||
dnl 3. if it's /usr/local/include and we are using GCC on Linux,
|
||||
dnl 4. if it doesn't exist as a directory.
|
||||
if test "X$additional_includedir" != "X/usr/include"; then
|
||||
haveit=
|
||||
for x in $CPPFLAGS; do
|
||||
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
|
||||
if test "X$x" = "X-I$additional_includedir"; then
|
||||
haveit=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$haveit"; then
|
||||
if test "X$additional_includedir" = "X/usr/local/include"; then
|
||||
if test -n "$GCC"; then
|
||||
case $host_os in
|
||||
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
if test -z "$haveit"; then
|
||||
if test -d "$additional_includedir"; then
|
||||
dnl Really add $additional_includedir to $CPPFLAGS.
|
||||
CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
dnl Potentially add $additional_libdir to $LDFLAGS.
|
||||
dnl But don't add it
|
||||
dnl 1. if it's the standard /usr/lib,
|
||||
dnl 2. if it's already present in $LDFLAGS,
|
||||
dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
|
||||
dnl 4. if it doesn't exist as a directory.
|
||||
if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
|
||||
haveit=
|
||||
for x in $LDFLAGS; do
|
||||
AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
|
||||
if test "X$x" = "X-L$additional_libdir"; then
|
||||
haveit=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z "$haveit"; then
|
||||
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
|
||||
if test -n "$GCC"; then
|
||||
case $host_os in
|
||||
linux*) haveit=yes;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
if test -z "$haveit"; then
|
||||
if test -d "$additional_libdir"; then
|
||||
dnl Really add $additional_libdir to $LDFLAGS.
|
||||
LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
])
|
||||
|
||||
dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
|
||||
dnl acl_final_exec_prefix, containing the values to which $prefix and
|
||||
dnl $exec_prefix will expand at the end of the configure script.
|
||||
AC_DEFUN([AC_LIB_PREPARE_PREFIX],
|
||||
[
|
||||
dnl Unfortunately, prefix and exec_prefix get only finally determined
|
||||
dnl at the end of configure.
|
||||
if test "X$prefix" = "XNONE"; then
|
||||
acl_final_prefix="$ac_default_prefix"
|
||||
else
|
||||
acl_final_prefix="$prefix"
|
||||
fi
|
||||
if test "X$exec_prefix" = "XNONE"; then
|
||||
acl_final_exec_prefix='${prefix}'
|
||||
else
|
||||
acl_final_exec_prefix="$exec_prefix"
|
||||
fi
|
||||
acl_save_prefix="$prefix"
|
||||
prefix="$acl_final_prefix"
|
||||
eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
|
||||
prefix="$acl_save_prefix"
|
||||
])
|
||||
|
||||
dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
|
||||
dnl variables prefix and exec_prefix bound to the values they will have
|
||||
dnl at the end of the configure script.
|
||||
AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
|
||||
[
|
||||
acl_save_prefix="$prefix"
|
||||
prefix="$acl_final_prefix"
|
||||
acl_save_exec_prefix="$exec_prefix"
|
||||
exec_prefix="$acl_final_exec_prefix"
|
||||
$1
|
||||
exec_prefix="$acl_save_exec_prefix"
|
||||
prefix="$acl_save_prefix"
|
||||
])
|
||||
|
||||
dnl AC_LIB_PREPARE_MULTILIB creates
|
||||
dnl - a variable acl_libdirstem, containing the basename of the libdir, either
|
||||
dnl "lib" or "lib64" or "lib/64",
|
||||
dnl - a variable acl_libdirstem2, as a secondary possible value for
|
||||
dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or
|
||||
dnl "lib/amd64".
|
||||
AC_DEFUN([AC_LIB_PREPARE_MULTILIB],
|
||||
[
|
||||
dnl There is no formal standard regarding lib and lib64.
|
||||
dnl On glibc systems, the current practice is that on a system supporting
|
||||
dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
|
||||
dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine
|
||||
dnl the compiler's default mode by looking at the compiler's library search
|
||||
dnl path. If at least one of its elements ends in /lib64 or points to a
|
||||
dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI.
|
||||
dnl Otherwise we use the default, namely "lib".
|
||||
dnl On Solaris systems, the current practice is that on a system supporting
|
||||
dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under
|
||||
dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or
|
||||
dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib.
|
||||
AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
acl_libdirstem=lib
|
||||
acl_libdirstem2=
|
||||
case "$host_os" in
|
||||
solaris*)
|
||||
dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment
|
||||
dnl <http://docs.sun.com/app/docs/doc/816-5138/dev-env?l=en&a=view>.
|
||||
dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link."
|
||||
dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the
|
||||
dnl symlink is missing, so we set acl_libdirstem2 too.
|
||||
AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit],
|
||||
[AC_EGREP_CPP([sixtyfour bits], [
|
||||
#ifdef _LP64
|
||||
sixtyfour bits
|
||||
#endif
|
||||
], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no])
|
||||
])
|
||||
if test $gl_cv_solaris_64bit = yes; then
|
||||
acl_libdirstem=lib/64
|
||||
case "$host_cpu" in
|
||||
sparc*) acl_libdirstem2=lib/sparcv9 ;;
|
||||
i*86 | x86_64) acl_libdirstem2=lib/amd64 ;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`
|
||||
if test -n "$searchpath"; then
|
||||
acl_save_IFS="${IFS= }"; IFS=":"
|
||||
for searchdir in $searchpath; do
|
||||
if test -d "$searchdir"; then
|
||||
case "$searchdir" in
|
||||
*/lib64/ | */lib64 ) acl_libdirstem=lib64 ;;
|
||||
*/../ | */.. )
|
||||
# Better ignore directories of this form. They are misleading.
|
||||
;;
|
||||
*) searchdir=`cd "$searchdir" && pwd`
|
||||
case "$searchdir" in
|
||||
*/lib64 ) acl_libdirstem=lib64 ;;
|
||||
esac ;;
|
||||
esac
|
||||
fi
|
||||
done
|
||||
IFS="$acl_save_IFS"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"
|
||||
])
|
@ -14,7 +14,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include "caf_reader.h"
|
||||
#include "pcm_reader.h"
|
||||
#include "m4af.h"
|
||||
|
||||
typedef struct caf_reader_t {
|
||||
|
@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 nu774
|
||||
* For conditions of distribution and use, see copyright notice in COPYING
|
||||
*/
|
||||
#ifndef CAF_READER_H
|
||||
#define CAF_READER_H
|
||||
|
||||
#include "lpcm.h"
|
||||
#include "pcm_reader.h"
|
||||
#include "metadata.h"
|
||||
|
||||
pcm_reader_t *caf_open(pcm_io_context_t *io,
|
||||
aacenc_tag_callback_t tag_callback, void *tag_ctx);
|
||||
|
||||
#endif
|
@ -157,7 +157,7 @@ int aacenc_fprintf(FILE *fp, const char *fmt, ...)
|
||||
codepage_decode_wchar(CP_UTF8, s, &ws);
|
||||
free(s);
|
||||
fflush(fp);
|
||||
WriteConsoleW(fh, ws, cnt, &nw, 0);
|
||||
WriteConsoleW(fh, ws, wcslen(ws), &nw, 0);
|
||||
free(ws);
|
||||
}
|
||||
return cnt;
|
||||
|
@ -86,11 +86,11 @@ static int fetch(extrapolater_t *self, unsigned nframes)
|
||||
|
||||
if (realloc_buffer(bp, nframes * sfmt->bytes_per_frame) == 0) {
|
||||
rc = pcm_read_frames(self->src, bp->data, nframes);
|
||||
bp->count = rc > 0 ? rc : 0;
|
||||
if (rc > 0) bp->count = rc;
|
||||
}
|
||||
if (rc > 0)
|
||||
self->nbuffer ^= 1;
|
||||
return bp->count;
|
||||
return rc <= 0 ? 0 : bp->count;
|
||||
}
|
||||
|
||||
static int extrapolate(extrapolater_t *self, const buffer_t *bp,
|
||||
@ -126,7 +126,13 @@ static int process0(extrapolater_t *self, void *buffer, unsigned nframes)
|
||||
reverse_buffer(buffer, nframes, nchannels);
|
||||
reverse_buffer(bp->data, bp->count, nchannels);
|
||||
}
|
||||
self->process = bp->count ? process1 : process2;
|
||||
if (bp->count)
|
||||
self->process = process1;
|
||||
else {
|
||||
memset(bp->data, 0, nframes * sfmt->bytes_per_frame);
|
||||
bp->count = nframes;
|
||||
self->process = process2;
|
||||
}
|
||||
return nframes;
|
||||
}
|
||||
|
||||
@ -137,8 +143,27 @@ static int process1(extrapolater_t *self, void *buffer, unsigned nframes)
|
||||
|
||||
assert(bp->count <= nframes);
|
||||
memcpy(buffer, bp->data, bp->count * sfmt->bytes_per_frame);
|
||||
if (!fetch(self, nframes))
|
||||
if (!fetch(self, nframes)) {
|
||||
buffer_t *bbp = &self->buffer[self->nbuffer];
|
||||
if (bp->count < 2 * LPC_ORDER) {
|
||||
size_t total = bp->count + bbp->count;
|
||||
if (bbp->count &&
|
||||
realloc_buffer(bbp, total * sfmt->bytes_per_frame) == 0 &&
|
||||
realloc_buffer(bp, total * sfmt->bytes_per_frame) == 0)
|
||||
{
|
||||
memcpy(bbp->data + bbp->count * sfmt->channels_per_frame,
|
||||
bp->data, bp->count * sfmt->bytes_per_frame);
|
||||
memcpy(bp->data, bbp->data, total * sfmt->bytes_per_frame);
|
||||
bp->count = total;
|
||||
}
|
||||
}
|
||||
if (bp->count >= 2 * LPC_ORDER)
|
||||
extrapolate(self, bp, bbp->data, nframes);
|
||||
else
|
||||
memset(bbp->data, 0, nframes * sfmt->bytes_per_frame);
|
||||
bbp->count = nframes;
|
||||
self->process = process2;
|
||||
}
|
||||
return bp->count;
|
||||
}
|
||||
|
||||
@ -146,27 +171,15 @@ static int process2(extrapolater_t *self, void *buffer, unsigned nframes)
|
||||
{
|
||||
const pcm_sample_description_t *sfmt = pcm_get_format(self->src);
|
||||
buffer_t *bp = &self->buffer[self->nbuffer];
|
||||
buffer_t *bbp = &self->buffer[self->nbuffer ^ 1];
|
||||
|
||||
if (bp->count < 2 * LPC_ORDER) {
|
||||
size_t total = bp->count + bbp->count;
|
||||
if (bbp->count &&
|
||||
realloc_buffer(bbp, total * sfmt->bytes_per_frame) == 0)
|
||||
{
|
||||
memcpy(bbp->data + bbp->count * sfmt->channels_per_frame,
|
||||
bp->data, bp->count * sfmt->bytes_per_frame);
|
||||
bbp->count = total;
|
||||
bp->count = 0;
|
||||
bp = bbp;
|
||||
self->nbuffer ^= 1;
|
||||
}
|
||||
}
|
||||
if (bp->count < nframes)
|
||||
nframes = bp->count;
|
||||
memcpy(buffer, bp->data, nframes * sfmt->bytes_per_frame);
|
||||
if (bp->count > nframes)
|
||||
memmove(bp->data, bp->data + nframes * sfmt->channels_per_frame,
|
||||
(bp->count - nframes) * sfmt->bytes_per_frame);
|
||||
bp->count -= nframes;
|
||||
if (bp->count == 0)
|
||||
self->process = process3;
|
||||
|
||||
if (bp->count >= 2 * LPC_ORDER)
|
||||
extrapolate(self, bp, buffer, nframes);
|
||||
else
|
||||
memset(buffer, 0, nframes * sfmt->bytes_per_frame);
|
||||
return nframes;
|
||||
}
|
||||
|
||||
|
186
src/limiter.c
Normal file
186
src/limiter.c
Normal file
@ -0,0 +1,186 @@
|
||||
/*
|
||||
* Copyright (C) 2013 nu774
|
||||
* For conditions of distribution and use, see copyright notice in COPYING
|
||||
*/
|
||||
#if HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#if HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include "pcm_reader.h"
|
||||
#include "lpc.h"
|
||||
|
||||
typedef struct buffer_t {
|
||||
void *data;
|
||||
unsigned count;
|
||||
unsigned capacity;
|
||||
unsigned head;
|
||||
} buffer_t;
|
||||
|
||||
typedef struct limiter_t {
|
||||
pcm_reader_vtbl_t *vtbl;
|
||||
pcm_reader_t *src;
|
||||
pcm_sample_description_t format;
|
||||
int64_t position;
|
||||
buffer_t buffers[1];
|
||||
} limiter_t;
|
||||
|
||||
static inline pcm_reader_t *get_source(pcm_reader_t *reader)
|
||||
{
|
||||
return ((limiter_t *)reader)->src;
|
||||
}
|
||||
|
||||
static const
|
||||
pcm_sample_description_t *get_format(pcm_reader_t *reader)
|
||||
{
|
||||
return pcm_get_format(get_source(reader));
|
||||
}
|
||||
|
||||
static int64_t get_length(pcm_reader_t *reader)
|
||||
{
|
||||
return pcm_get_length(get_source(reader));
|
||||
}
|
||||
|
||||
static int64_t get_position(pcm_reader_t *reader)
|
||||
{
|
||||
return ((limiter_t *)reader)->position;
|
||||
}
|
||||
|
||||
static int reserve_buffer(buffer_t *bp, size_t required, unsigned unit)
|
||||
{
|
||||
if (bp->capacity < required) {
|
||||
unsigned newsize = 1;
|
||||
void *p;
|
||||
while (newsize < required)
|
||||
newsize <<= 1;
|
||||
p = realloc(bp->data, newsize * unit);
|
||||
if (!p) return -1;
|
||||
bp->data = p;
|
||||
bp->capacity = newsize;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_frames(pcm_reader_t *reader, void *buffer, unsigned nframes)
|
||||
{
|
||||
limiter_t *self = (limiter_t *)reader;
|
||||
unsigned i, n, res, nch = self->format.channels_per_frame;
|
||||
size_t bytes = nframes * pcm_get_format(self->src)->bytes_per_frame;
|
||||
buffer_t *ibp = &self->buffers[nch];
|
||||
float *obp = buffer;
|
||||
|
||||
do {
|
||||
if (reserve_buffer(ibp, bytes, 1) < 0)
|
||||
return -1;
|
||||
res = pcm_read_frames(self->src, ibp->data, nframes);
|
||||
for (n = 0; n < nch; ++n) {
|
||||
float *ip = (float *)ibp->data, *x;
|
||||
buffer_t *bp = &self->buffers[n];
|
||||
unsigned end, limit;
|
||||
if (reserve_buffer(bp, bp->count + res, sizeof(float)) < 0)
|
||||
return -1;
|
||||
x = bp->data;
|
||||
for (i = 0; i < res; ++i)
|
||||
x[bp->count++] = pcm_clip(ip[i * nch + n], -3.0, 3.0);
|
||||
limit = bp->count;
|
||||
if (limit > 0 && res > 0) {
|
||||
float last = x[limit - 1];
|
||||
for (; limit > 0 && x[limit-1] * last > 0; --limit)
|
||||
;
|
||||
}
|
||||
end = bp->head;
|
||||
while (end < limit) {
|
||||
unsigned start, peak_pos;
|
||||
float peak;
|
||||
for (peak_pos = end; peak_pos < limit; ++peak_pos)
|
||||
if (x[peak_pos] > 1.0f || x[peak_pos] < -1.0f)
|
||||
break;
|
||||
if (peak_pos == limit)
|
||||
break;
|
||||
start = peak_pos;
|
||||
peak = fabs(x[peak_pos]);
|
||||
while (start > bp->head && x[peak_pos] * x[start] >= 0.0f)
|
||||
--start;
|
||||
++start;
|
||||
for (end = peak_pos + 1; end < limit; ++end) {
|
||||
float y;
|
||||
if (x[peak_pos] * x[end] < 0.0f)
|
||||
break;
|
||||
y = fabs(x[end]);
|
||||
if (y > peak) {
|
||||
peak = y;
|
||||
peak_pos = end;
|
||||
}
|
||||
}
|
||||
if (peak < 2.0f) {
|
||||
float a = (peak - 1.0f) / (peak * peak);
|
||||
if (x[peak_pos] > 0.0f) a = -a;
|
||||
for (i = start; i < end; ++i)
|
||||
x[i] = x[i] + a * x[i] * x[i];
|
||||
} else {
|
||||
float u = peak, v = 1.0f;
|
||||
float a = (u - 2.0f * v) / (u * u * u);
|
||||
float b = (3.0f * v - 2.0f * u) / (u * u);
|
||||
if (x[peak_pos] < 0.0f) b = -b;
|
||||
for (i = start; i < end; ++i)
|
||||
x[i] = x[i] + b * x[i] * x[i] + a * x[i] * x[i] * x[i];
|
||||
}
|
||||
}
|
||||
bp->head = limit;
|
||||
}
|
||||
res = nframes;
|
||||
for (n = 0; n < nch; ++n)
|
||||
if (self->buffers[n].head < res)
|
||||
res = self->buffers[n].head;
|
||||
for (i = 0; i < res; ++i)
|
||||
for (n = 0; n < nch; ++n)
|
||||
*obp++ = ((float *)self->buffers[n].data)[i];
|
||||
if (res) {
|
||||
for (n = 0; n < nch; ++n) {
|
||||
buffer_t *bp = &self->buffers[n];
|
||||
float *p = bp->data;
|
||||
memmove(p, p + res, (bp->count - res) * sizeof(float));
|
||||
bp->count -= res;
|
||||
bp->head -= res;
|
||||
}
|
||||
}
|
||||
} while (res == 0 && self->buffers[0].count);
|
||||
self->position += res;
|
||||
return res;
|
||||
}
|
||||
|
||||
static void teardown(pcm_reader_t **reader)
|
||||
{
|
||||
int i;
|
||||
limiter_t *self = (limiter_t *)*reader;
|
||||
pcm_teardown(&self->src);
|
||||
for (i = 0; i < self->format.channels_per_frame + 1; ++i)
|
||||
free(self->buffers[i].data);
|
||||
free(self);
|
||||
*reader = 0;
|
||||
}
|
||||
|
||||
static pcm_reader_vtbl_t my_vtable = {
|
||||
get_format, get_length, get_position, read_frames, teardown
|
||||
};
|
||||
|
||||
pcm_reader_t *limiter_open(pcm_reader_t *reader)
|
||||
{
|
||||
limiter_t *self;
|
||||
int n = pcm_get_format(reader)->channels_per_frame;
|
||||
size_t size = sizeof(limiter_t) + offsetof(limiter_t, buffers[n + 1]);
|
||||
|
||||
if ((self = calloc(1, size)) == 0)
|
||||
return 0;
|
||||
self->src = reader;
|
||||
self->vtbl = &my_vtable;
|
||||
self->format = *pcm_get_format(reader);
|
||||
self->format.bits_per_channel = 32;
|
||||
return (pcm_reader_t *)self;
|
||||
}
|
226
src/lpcm.c
226
src/lpcm.c
@ -1,226 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 nu774
|
||||
* For conditions of distribution and use, see copyright notice in COPYING
|
||||
*/
|
||||
#if HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#if HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include "lpcm.h"
|
||||
#include "m4af_endian.h"
|
||||
|
||||
static
|
||||
inline float pcm_i2f(int32_t n)
|
||||
{
|
||||
union {
|
||||
int32_t ivalue;
|
||||
float fvalue;
|
||||
} u;
|
||||
u.ivalue = n;
|
||||
return u.fvalue;
|
||||
}
|
||||
static
|
||||
inline double pcm_i2d(int64_t n)
|
||||
{
|
||||
union {
|
||||
int64_t ivalue;
|
||||
double fvalue;
|
||||
} u;
|
||||
u.ivalue = n;
|
||||
return u.fvalue;
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_quantize_s32(int32_t n)
|
||||
{
|
||||
n = ((n >> 15) + 1) >> 1;
|
||||
return (n == 0x8000) ? 0x7fff : n;
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_quantize_f64(double v)
|
||||
{
|
||||
return (int16_t)lrint(pcm_clip(v * 32768.0, -32768.0, 32767.0));
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_s8_to_s16(int8_t n)
|
||||
{
|
||||
return n << 8;
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_u8_to_s16(uint8_t n)
|
||||
{
|
||||
return (n << 8) ^ 0x8000;
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_s16le_to_s16(int16_t n)
|
||||
{
|
||||
return m4af_ltoh16(n);
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_s16be_to_s16(int16_t n)
|
||||
{
|
||||
return m4af_btoh16(n);
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_u16le_to_s16(uint16_t n)
|
||||
{
|
||||
return m4af_ltoh16(n) ^ 0x8000;
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_u16be_to_s16(uint16_t n)
|
||||
{
|
||||
return m4af_btoh16(n) ^ 0x8000;
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_s24le_to_s32(uint8_t *p)
|
||||
{
|
||||
return p[0]<<8 | p[1]<<16 | p[2]<<24;
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_s24be_to_s32(uint8_t *p)
|
||||
{
|
||||
return p[0]<<24 | p[1]<<16 | p[2]<<8;
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_u24le_to_s32(uint8_t *p)
|
||||
{
|
||||
return pcm_s24le_to_s32(p) ^ 0x80000000;
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_u24be_to_s32(uint8_t *p)
|
||||
{
|
||||
return pcm_s24be_to_s32(p) ^ 0x80000000;
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_s24le_to_s16(uint8_t *p)
|
||||
{
|
||||
return pcm_quantize_s32(pcm_s24le_to_s32(p));
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_s24be_to_s16(uint8_t *p)
|
||||
{
|
||||
return pcm_quantize_s32(pcm_s24be_to_s32(p));
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_u24le_to_s16(uint8_t *p)
|
||||
{
|
||||
return pcm_quantize_s32(pcm_u24le_to_s32(p));
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_u24be_to_s16(uint8_t *p)
|
||||
{
|
||||
return pcm_quantize_s32(pcm_u24be_to_s32(p));
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_s32le_to_s16(int32_t n)
|
||||
{
|
||||
return pcm_quantize_s32(m4af_ltoh32(n));
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_s32be_to_s16(int32_t n)
|
||||
{
|
||||
return pcm_quantize_s32(m4af_btoh32(n));
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_u32le_to_s16(int32_t n)
|
||||
{
|
||||
return pcm_quantize_s32(m4af_ltoh32(n) ^ 0x80000000);
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_u32be_to_s16(int32_t n)
|
||||
{
|
||||
return pcm_quantize_s32(m4af_btoh32(n) ^ 0x80000000);
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_f32le_to_s16(int32_t n)
|
||||
{
|
||||
return pcm_quantize_f64(pcm_i2f(m4af_ltoh32(n)));
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_f32be_to_s16(int32_t n)
|
||||
{
|
||||
return pcm_quantize_f64(pcm_i2f(m4af_btoh32(n)));
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_f64le_to_s16(int64_t n)
|
||||
{
|
||||
return pcm_quantize_f64(pcm_i2d(m4af_ltoh64(n)));
|
||||
}
|
||||
static
|
||||
inline int16_t pcm_f64be_to_s16(int64_t n)
|
||||
{
|
||||
return pcm_quantize_f64(pcm_i2d(m4af_btoh64(n)));
|
||||
}
|
||||
|
||||
int pcm_convert_to_native_sint16(const pcm_sample_description_t *format,
|
||||
const void *input, uint32_t nframes,
|
||||
int16_t *result)
|
||||
{
|
||||
#define CONVERT(type, conv) \
|
||||
do { \
|
||||
unsigned i; \
|
||||
type *ip = (type *)input; \
|
||||
for (i = 0; i < count; ++i) { \
|
||||
result[i] = conv(ip[i]); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define CONVERT_BYTES(conv) \
|
||||
do { \
|
||||
unsigned i, bytes_per_channel; \
|
||||
uint8_t *ip = (uint8_t *)input; \
|
||||
bytes_per_channel = PCM_BYTES_PER_CHANNEL(format); \
|
||||
for (i = 0; i < count; ++i) { \
|
||||
result[i] = conv(ip); \
|
||||
ip += bytes_per_channel; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
uint32_t count = nframes * format->channels_per_frame;
|
||||
if (!count)
|
||||
return 0;
|
||||
switch (PCM_BYTES_PER_CHANNEL(format) | format->sample_type<<4) {
|
||||
case 1 | PCM_TYPE_SINT<<4:
|
||||
CONVERT(int8_t, pcm_s8_to_s16); break;
|
||||
case 1 | PCM_TYPE_UINT<<4:
|
||||
CONVERT(uint8_t, pcm_u8_to_s16); break;
|
||||
case 2 | PCM_TYPE_SINT<<4:
|
||||
CONVERT(int16_t, pcm_s16le_to_s16); break;
|
||||
case 2 | PCM_TYPE_UINT<<4:
|
||||
CONVERT(uint16_t, pcm_u16le_to_s16); break;
|
||||
case 2 | PCM_TYPE_SINT_BE<<4:
|
||||
CONVERT(int16_t, pcm_s16be_to_s16); break;
|
||||
case 2 | PCM_TYPE_UINT_BE<<4:
|
||||
CONVERT(int16_t, pcm_u16be_to_s16); break;
|
||||
case 3 | PCM_TYPE_SINT<<4:
|
||||
CONVERT_BYTES(pcm_s24le_to_s16); break;
|
||||
case 3 | PCM_TYPE_UINT<<4:
|
||||
CONVERT_BYTES(pcm_u24le_to_s16); break;
|
||||
case 3 | PCM_TYPE_SINT_BE<<4:
|
||||
CONVERT_BYTES(pcm_s24be_to_s16); break;
|
||||
case 3 | PCM_TYPE_UINT_BE<<4:
|
||||
CONVERT_BYTES(pcm_u24be_to_s16); break;
|
||||
case 4 | PCM_TYPE_SINT<<4:
|
||||
CONVERT(int32_t, pcm_s32le_to_s16); break;
|
||||
case 4 | PCM_TYPE_UINT<<4:
|
||||
CONVERT(uint32_t, pcm_u32le_to_s16); break;
|
||||
case 4 | PCM_TYPE_FLOAT<<4:
|
||||
CONVERT(int32_t, pcm_f32le_to_s16); break;
|
||||
case 4 | PCM_TYPE_SINT_BE<<4:
|
||||
CONVERT(int32_t, pcm_s32be_to_s16); break;
|
||||
case 4 | PCM_TYPE_UINT_BE<<4:
|
||||
CONVERT(uint32_t, pcm_u32be_to_s16); break;
|
||||
case 4 | PCM_TYPE_FLOAT_BE<<4:
|
||||
CONVERT(int32_t, pcm_f32be_to_s16); break;
|
||||
case 8 | PCM_TYPE_FLOAT<<4:
|
||||
CONVERT(int64_t, pcm_f64le_to_s16); break;
|
||||
case 8 | PCM_TYPE_FLOAT_BE<<4:
|
||||
CONVERT(int64_t, pcm_f64be_to_s16); break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -61,7 +61,4 @@ inline double pcm_clip(double n, double min_value, double max_value)
|
||||
return n;
|
||||
}
|
||||
|
||||
int pcm_convert_to_native_sint16(const pcm_sample_description_t *format,
|
||||
const void *input, uint32_t nframes,
|
||||
int16_t *result);
|
||||
#endif
|
||||
|
14
src/m4af.c
14
src/m4af.c
@ -42,6 +42,7 @@ typedef struct m4af_chunk_entry_t {
|
||||
typedef struct m4af_track_t {
|
||||
uint32_t codec;
|
||||
uint32_t timescale;
|
||||
uint16_t num_channels;
|
||||
int64_t creation_time;
|
||||
int64_t modification_time;
|
||||
int64_t duration;
|
||||
@ -211,6 +212,7 @@ m4af_ctx_t *m4af_create(uint32_t codec, uint32_t timescale,
|
||||
ctx->track[0].timescale = timescale;
|
||||
ctx->track[0].creation_time = timestamp;
|
||||
ctx->track[0].modification_time = timestamp;
|
||||
ctx->track[0].num_channels = 2;
|
||||
return ctx;
|
||||
}
|
||||
|
||||
@ -254,6 +256,12 @@ void m4af_teardown(m4af_ctx_t **ctxp)
|
||||
*ctxp = 0;
|
||||
}
|
||||
|
||||
void m4af_set_num_channels(m4af_ctx_t *ctx, uint32_t track_idx,
|
||||
uint16_t channels)
|
||||
{
|
||||
ctx->track[track_idx].num_channels = channels;
|
||||
}
|
||||
|
||||
void m4af_set_fixed_frame_duration(m4af_ctx_t *ctx, uint32_t track_idx,
|
||||
uint32_t length)
|
||||
{
|
||||
@ -816,11 +824,13 @@ void m4af_write_mp4a_box(m4af_ctx_t *ctx, uint32_t track_idx)
|
||||
"\0\001" /* data_reference_index: 1 */
|
||||
"\0\0\0\0" /* reserved[0] */
|
||||
"\0\0\0\0" /* reserved[1] */
|
||||
"\0\002" /* channelcount: 2 */
|
||||
,16);
|
||||
m4af_write16(ctx, track->num_channels);
|
||||
m4af_write(ctx,
|
||||
"\0\020" /* samplesize: 16 */
|
||||
"\0\0" /* pre_defined */
|
||||
"\0\0" /* reserved */
|
||||
,24);
|
||||
,6);
|
||||
if (track->codec == M4AF_FOURCC('m','p','4','a')) {
|
||||
m4af_write32(ctx, track->timescale << 16);
|
||||
m4af_write_esds_box(ctx, track_idx);
|
||||
|
@ -104,6 +104,9 @@ void m4af_set_priming(m4af_ctx_t *ctx, uint32_t track_idx,
|
||||
|
||||
void m4af_set_priming_mode(m4af_ctx_t *ctx, int mode);
|
||||
|
||||
void m4af_set_num_channels(m4af_ctx_t *ctx, uint32_t track_idx,
|
||||
uint16_t channels);
|
||||
|
||||
void m4af_set_fixed_frame_duration(m4af_ctx_t *ctx, uint32_t track_idx,
|
||||
uint32_t length);
|
||||
|
||||
|
26
src/main.c
26
src/main.c
@ -33,8 +33,7 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "compat.h"
|
||||
#include "wav_reader.h"
|
||||
#include "caf_reader.h"
|
||||
#include "pcm_reader.h"
|
||||
#include "aacenc.h"
|
||||
#include "m4af.h"
|
||||
#include "progress.h"
|
||||
@ -699,7 +698,7 @@ pcm_reader_t *open_input(aacenc_param_ex_t *params)
|
||||
if ((params->input_fp = aacenc_fopen(params->input_filename, "rb")) == 0) {
|
||||
aacenc_fprintf(stderr, "ERROR: %s: %s\n", params->input_filename,
|
||||
strerror(errno));
|
||||
goto END;
|
||||
goto FAIL;
|
||||
}
|
||||
io.cookie = params->input_fp;
|
||||
if (fstat(fileno(params->input_fp), &stb) == 0
|
||||
@ -713,7 +712,7 @@ pcm_reader_t *open_input(aacenc_param_ex_t *params)
|
||||
pcm_sample_description_t desc = { 0 };
|
||||
if (parse_raw_spec(params->raw_format, &desc) < 0) {
|
||||
fprintf(stderr, "ERROR: invalid raw-format spec\n");
|
||||
goto END;
|
||||
goto FAIL;
|
||||
}
|
||||
desc.sample_rate = params->raw_rate;
|
||||
desc.channels_per_frame = params->raw_channels;
|
||||
@ -721,7 +720,7 @@ pcm_reader_t *open_input(aacenc_param_ex_t *params)
|
||||
desc.bytes_per_frame = params->raw_channels * bytes_per_channel;
|
||||
if ((reader = raw_open(&io, &desc)) == 0) {
|
||||
fprintf(stderr, "ERROR: failed to open raw input\n");
|
||||
goto END;
|
||||
goto FAIL;
|
||||
}
|
||||
} else {
|
||||
int c;
|
||||
@ -731,7 +730,7 @@ pcm_reader_t *open_input(aacenc_param_ex_t *params)
|
||||
case 'R':
|
||||
if ((reader = wav_open(&io, params->ignore_length)) == 0) {
|
||||
fprintf(stderr, "ERROR: broken / unsupported input file\n");
|
||||
goto END;
|
||||
goto FAIL;
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
@ -741,18 +740,21 @@ pcm_reader_t *open_input(aacenc_param_ex_t *params)
|
||||
aacenc_translate_generic_text_tag,
|
||||
¶ms->source_tag_ctx)) == 0) {
|
||||
fprintf(stderr, "ERROR: broken / unsupported input file\n");
|
||||
goto END;
|
||||
goto FAIL;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "ERROR: unsupported input file\n");
|
||||
goto END;
|
||||
goto FAIL;
|
||||
}
|
||||
}
|
||||
if ((reader = pcm_open_sint16_converter(reader)) != 0)
|
||||
reader = pcm_open_native_converter(reader);
|
||||
if (reader && PCM_IS_FLOAT(pcm_get_format(reader)))
|
||||
reader = limiter_open(reader);
|
||||
if (reader && (reader = pcm_open_sint16_converter(reader)) != 0)
|
||||
reader = extrapolater_open(reader);
|
||||
return reader;
|
||||
END:
|
||||
FAIL:
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -822,10 +824,10 @@ int main(int argc, char **argv)
|
||||
if ((m4af = m4af_create(M4AF_CODEC_MP4A, scale, &m4af_io,
|
||||
params.output_fp)) < 0)
|
||||
goto END;
|
||||
m4af_set_num_channels(m4af, 0, sample_format->channels_per_frame);
|
||||
m4af_set_decoder_specific_info(m4af, 0,
|
||||
aacinfo.confBuf, aacinfo.confSize);
|
||||
m4af_set_fixed_frame_duration(m4af, 0,
|
||||
framelen >> scale_shift);
|
||||
m4af_set_fixed_frame_duration(m4af, 0, framelen >> scale_shift);
|
||||
m4af_set_vbr_mode(m4af, 0, params.bitrate_mode);
|
||||
m4af_set_priming_mode(m4af, params.gapless_mode + 1);
|
||||
m4af_begin_write(m4af);
|
||||
|
85
src/pcm_float_converter.c
Normal file
85
src/pcm_float_converter.c
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (C) 2013 nu774
|
||||
* For conditions of distribution and use, see copyright notice in COPYING
|
||||
*/
|
||||
#if HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#include "pcm_reader.h"
|
||||
|
||||
typedef struct pcm_float_converter_t {
|
||||
pcm_reader_vtbl_t *vtbl;
|
||||
pcm_reader_t *src;
|
||||
pcm_sample_description_t format;
|
||||
} pcm_float_converter_t;
|
||||
|
||||
static inline pcm_reader_t *get_source(pcm_reader_t *reader)
|
||||
{
|
||||
return ((pcm_float_converter_t *)reader)->src;
|
||||
}
|
||||
|
||||
static const
|
||||
pcm_sample_description_t *get_format(pcm_reader_t *reader)
|
||||
{
|
||||
return &((pcm_float_converter_t *)reader)->format;
|
||||
}
|
||||
|
||||
static int64_t get_length(pcm_reader_t *reader)
|
||||
{
|
||||
return pcm_get_length(get_source(reader));
|
||||
}
|
||||
|
||||
static int64_t get_position(pcm_reader_t *reader)
|
||||
{
|
||||
return pcm_get_position(get_source(reader));
|
||||
}
|
||||
|
||||
static int read_frames(pcm_reader_t *reader, void *buffer, unsigned nframes)
|
||||
{
|
||||
unsigned i;
|
||||
pcm_float_converter_t *self = (pcm_float_converter_t *)reader;
|
||||
const pcm_sample_description_t *sfmt = pcm_get_format(self->src);
|
||||
nframes = pcm_read_frames(self->src, buffer, nframes);
|
||||
if (!(sfmt->sample_type & PCM_TYPE_FLOAT)) {
|
||||
int32_t *ip = buffer;
|
||||
float *op = buffer;
|
||||
unsigned i, count = nframes * sfmt->channels_per_frame;
|
||||
for (i = 0; i < count; ++i)
|
||||
op[i] = ip[i] / 2147483648.0f;
|
||||
}
|
||||
return nframes;
|
||||
}
|
||||
|
||||
static void teardown(pcm_reader_t **reader)
|
||||
{
|
||||
pcm_float_converter_t *self = (pcm_float_converter_t *)*reader;
|
||||
pcm_teardown(&self->src);
|
||||
free(self);
|
||||
*reader = 0;
|
||||
}
|
||||
|
||||
static pcm_reader_vtbl_t my_vtable = {
|
||||
get_format, get_length, get_position, read_frames, teardown
|
||||
};
|
||||
|
||||
pcm_reader_t *pcm_open_float_converter(pcm_reader_t *reader)
|
||||
{
|
||||
pcm_float_converter_t *self = 0;
|
||||
pcm_sample_description_t *fmt;
|
||||
|
||||
if ((self = calloc(1, sizeof(pcm_float_converter_t))) == 0)
|
||||
return 0;
|
||||
self->src = reader;
|
||||
self->vtbl = &my_vtable;
|
||||
memcpy(&self->format, pcm_get_format(reader), sizeof(self->format));
|
||||
fmt = &self->format;
|
||||
fmt->bits_per_channel = 32;
|
||||
fmt->sample_type = PCM_TYPE_FLOAT;
|
||||
fmt->bytes_per_frame = 4 * fmt->channels_per_frame;
|
||||
return (pcm_reader_t *)self;
|
||||
}
|
272
src/pcm_native_converter.c
Normal file
272
src/pcm_native_converter.c
Normal file
@ -0,0 +1,272 @@
|
||||
/*
|
||||
* Copyright (C) 2013 nu774
|
||||
* For conditions of distribution and use, see copyright notice in COPYING
|
||||
*/
|
||||
#if HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#include "m4af_endian.h"
|
||||
#include "pcm_reader.h"
|
||||
|
||||
static
|
||||
inline float pcm_i2f(int32_t n)
|
||||
{
|
||||
union {
|
||||
int32_t ivalue;
|
||||
float fvalue;
|
||||
} u;
|
||||
u.ivalue = n;
|
||||
return u.fvalue;
|
||||
}
|
||||
static
|
||||
inline double pcm_i2d(int64_t n)
|
||||
{
|
||||
union {
|
||||
int64_t ivalue;
|
||||
double fvalue;
|
||||
} u;
|
||||
u.ivalue = n;
|
||||
return u.fvalue;
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_s8_to_s32(int8_t n)
|
||||
{
|
||||
return n << 24;
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_u8_to_s32(uint8_t n)
|
||||
{
|
||||
return (n << 24) ^ 0x80000000;
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_s16le_to_s32(int16_t n)
|
||||
{
|
||||
return m4af_ltoh16(n) << 16;
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_s16be_to_s32(int16_t n)
|
||||
{
|
||||
return m4af_btoh16(n) << 16;
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_u16le_to_s32(uint16_t n)
|
||||
{
|
||||
return (m4af_ltoh16(n) << 16) ^ 0x80000000;
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_u16be_to_s32(uint16_t n)
|
||||
{
|
||||
return (m4af_btoh16(n) << 16) ^ 0x80000000;
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_s24le_to_s32(uint8_t *p)
|
||||
{
|
||||
return p[0]<<8 | p[1]<<16 | p[2]<<24;
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_s24be_to_s32(uint8_t *p)
|
||||
{
|
||||
return p[0]<<24 | p[1]<<16 | p[2]<<8;
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_u24le_to_s32(uint8_t *p)
|
||||
{
|
||||
return pcm_s24le_to_s32(p) ^ 0x80000000;
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_u24be_to_s32(uint8_t *p)
|
||||
{
|
||||
return pcm_s24be_to_s32(p) ^ 0x80000000;
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_s32le_to_s32(int32_t n)
|
||||
{
|
||||
return m4af_ltoh32(n);
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_s32be_to_s32(int32_t n)
|
||||
{
|
||||
return m4af_btoh32(n);
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_u32le_to_s32(int32_t n)
|
||||
{
|
||||
return m4af_ltoh32(n) ^ 0x80000000;
|
||||
}
|
||||
static
|
||||
inline int32_t pcm_u32be_to_s32(int32_t n)
|
||||
{
|
||||
return m4af_btoh32(n) ^ 0x80000000;
|
||||
}
|
||||
static
|
||||
inline float pcm_f32le_to_f32(int32_t n)
|
||||
{
|
||||
return pcm_i2f(m4af_ltoh32(n));
|
||||
}
|
||||
static
|
||||
inline float pcm_f32be_to_f32(int32_t n)
|
||||
{
|
||||
return pcm_i2f(m4af_btoh32(n));
|
||||
}
|
||||
static
|
||||
inline float pcm_f64le_to_f32(int64_t n)
|
||||
{
|
||||
return pcm_i2d(m4af_ltoh64(n));
|
||||
}
|
||||
static
|
||||
inline float pcm_f64be_to_f32(int64_t n)
|
||||
{
|
||||
return pcm_i2d(m4af_btoh64(n));
|
||||
}
|
||||
|
||||
static
|
||||
int pcm_convert_to_native(const pcm_sample_description_t *format,
|
||||
const void *input, uint32_t nframes,
|
||||
void *result)
|
||||
{
|
||||
#define CONVERT(type, rtype, conv) \
|
||||
do { \
|
||||
unsigned i; \
|
||||
type *ip = (type *)input; \
|
||||
for (i = 0; i < count; ++i) { \
|
||||
((rtype *)result)[i] = conv(ip[i]); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define CONVERT_BYTES(rtype, conv) \
|
||||
do { \
|
||||
unsigned i, bytes_per_channel; \
|
||||
uint8_t *ip = (uint8_t *)input; \
|
||||
bytes_per_channel = PCM_BYTES_PER_CHANNEL(format); \
|
||||
for (i = 0; i < count; ++i) { \
|
||||
((rtype *)result)[i] = conv(ip); \
|
||||
ip += bytes_per_channel; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
uint32_t count = nframes * format->channels_per_frame;
|
||||
if (!count)
|
||||
return 0;
|
||||
switch (PCM_BYTES_PER_CHANNEL(format) | format->sample_type<<4) {
|
||||
case 1 | PCM_TYPE_SINT<<4:
|
||||
CONVERT(int8_t, int32_t, pcm_s8_to_s32); break;
|
||||
case 1 | PCM_TYPE_UINT<<4:
|
||||
CONVERT(uint8_t, int32_t, pcm_u8_to_s32); break;
|
||||
case 2 | PCM_TYPE_SINT<<4:
|
||||
CONVERT(int16_t, int32_t, pcm_s16le_to_s32); break;
|
||||
case 2 | PCM_TYPE_UINT<<4:
|
||||
CONVERT(uint16_t, int32_t, pcm_u16le_to_s32); break;
|
||||
case 2 | PCM_TYPE_SINT_BE<<4:
|
||||
CONVERT(int16_t, int32_t, pcm_s16be_to_s32); break;
|
||||
case 2 | PCM_TYPE_UINT_BE<<4:
|
||||
CONVERT(int16_t, int32_t, pcm_u16be_to_s32); break;
|
||||
case 3 | PCM_TYPE_SINT<<4:
|
||||
CONVERT_BYTES(int32_t, pcm_s24le_to_s32); break;
|
||||
case 3 | PCM_TYPE_UINT<<4:
|
||||
CONVERT_BYTES(int32_t, pcm_u24le_to_s32); break;
|
||||
case 3 | PCM_TYPE_SINT_BE<<4:
|
||||
CONVERT_BYTES(int32_t, pcm_s24be_to_s32); break;
|
||||
case 3 | PCM_TYPE_UINT_BE<<4:
|
||||
CONVERT_BYTES(int32_t, pcm_u24be_to_s32); break;
|
||||
case 4 | PCM_TYPE_SINT<<4:
|
||||
CONVERT(int32_t, int32_t, pcm_s32le_to_s32); break;
|
||||
case 4 | PCM_TYPE_UINT<<4:
|
||||
CONVERT(uint32_t, int32_t, pcm_u32le_to_s32); break;
|
||||
case 4 | PCM_TYPE_FLOAT<<4:
|
||||
CONVERT(int32_t, float, pcm_f32le_to_f32); break;
|
||||
case 4 | PCM_TYPE_SINT_BE<<4:
|
||||
CONVERT(int32_t, int32_t, pcm_s32be_to_s32); break;
|
||||
case 4 | PCM_TYPE_UINT_BE<<4:
|
||||
CONVERT(uint32_t, int32_t, pcm_u32be_to_s32); break;
|
||||
case 4 | PCM_TYPE_FLOAT_BE<<4:
|
||||
CONVERT(int32_t, float, pcm_f32be_to_f32); break;
|
||||
case 8 | PCM_TYPE_FLOAT<<4:
|
||||
CONVERT(int64_t, float, pcm_f64le_to_f32); break;
|
||||
case 8 | PCM_TYPE_FLOAT_BE<<4:
|
||||
CONVERT(int64_t, float, pcm_f64be_to_f32); break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef struct pcm_native_converter_t {
|
||||
pcm_reader_vtbl_t *vtbl;
|
||||
pcm_reader_t *src;
|
||||
pcm_sample_description_t format;
|
||||
void *pivot;
|
||||
unsigned capacity;
|
||||
} pcm_native_converter_t;
|
||||
|
||||
static inline pcm_reader_t *get_source(pcm_reader_t *reader)
|
||||
{
|
||||
return ((pcm_native_converter_t *)reader)->src;
|
||||
}
|
||||
|
||||
static const
|
||||
pcm_sample_description_t *get_format(pcm_reader_t *reader)
|
||||
{
|
||||
return &((pcm_native_converter_t *)reader)->format;
|
||||
}
|
||||
|
||||
static int64_t get_length(pcm_reader_t *reader)
|
||||
{
|
||||
return pcm_get_length(get_source(reader));
|
||||
}
|
||||
|
||||
static int64_t get_position(pcm_reader_t *reader)
|
||||
{
|
||||
return pcm_get_position(get_source(reader));
|
||||
}
|
||||
|
||||
static int read_frames(pcm_reader_t *reader, void *buffer, unsigned nframes)
|
||||
{
|
||||
pcm_native_converter_t *self = (pcm_native_converter_t *)reader;
|
||||
const pcm_sample_description_t *sfmt = pcm_get_format(self->src);
|
||||
unsigned bytes = nframes * sfmt->bytes_per_frame;
|
||||
|
||||
if (self->capacity < bytes) {
|
||||
void *p = realloc(self->pivot, bytes);
|
||||
if (!p) return -1;
|
||||
self->pivot = p;
|
||||
self->capacity = bytes;
|
||||
}
|
||||
nframes = pcm_read_frames(self->src, self->pivot, nframes);
|
||||
if (pcm_convert_to_native(sfmt, self->pivot, nframes, buffer) < 0)
|
||||
return -1;
|
||||
return nframes;
|
||||
}
|
||||
|
||||
static void teardown(pcm_reader_t **reader)
|
||||
{
|
||||
pcm_native_converter_t *self = (pcm_native_converter_t *)*reader;
|
||||
pcm_teardown(&self->src);
|
||||
free(self->pivot);
|
||||
free(self);
|
||||
*reader = 0;
|
||||
}
|
||||
|
||||
static pcm_reader_vtbl_t my_vtable = {
|
||||
get_format, get_length, get_position, read_frames, teardown
|
||||
};
|
||||
|
||||
pcm_reader_t *pcm_open_native_converter(pcm_reader_t *reader)
|
||||
{
|
||||
pcm_native_converter_t *self = 0;
|
||||
pcm_sample_description_t *fmt;
|
||||
|
||||
if ((self = calloc(1, sizeof(pcm_native_converter_t))) == 0)
|
||||
return 0;
|
||||
self->src = reader;
|
||||
self->vtbl = &my_vtable;
|
||||
memcpy(&self->format, pcm_get_format(reader), sizeof(self->format));
|
||||
fmt = &self->format;
|
||||
fmt->sample_type = PCM_IS_FLOAT(fmt) ? PCM_TYPE_FLOAT : PCM_TYPE_SINT;
|
||||
fmt->bytes_per_frame = 4 * fmt->channels_per_frame;
|
||||
return (pcm_reader_t *)self;
|
||||
}
|
@ -6,6 +6,7 @@
|
||||
#define PCM_READER_H
|
||||
|
||||
#include "lpcm.h"
|
||||
#include "metadata.h"
|
||||
|
||||
typedef struct pcm_reader_t pcm_reader_t;
|
||||
|
||||
@ -54,11 +55,7 @@ int64_t pcm_get_position(pcm_reader_t *r)
|
||||
return r->vtbl->get_position(r);
|
||||
}
|
||||
|
||||
static inline
|
||||
int64_t pcm_read_frames(pcm_reader_t *r, void *data, unsigned nframes)
|
||||
{
|
||||
return r->vtbl->read_frames(r, data, nframes);
|
||||
}
|
||||
int pcm_read_frames(pcm_reader_t *r, void *data, unsigned nframes);
|
||||
|
||||
static inline
|
||||
void pcm_teardown(pcm_reader_t **r)
|
||||
@ -111,8 +108,17 @@ int pcm_scanb(pcm_io_context_t *io, const char *fmt, ...);
|
||||
int apple_chan_chunk(pcm_io_context_t *io, uint32_t chunk_size,
|
||||
pcm_sample_description_t *fmt, uint8_t *mapping);
|
||||
|
||||
pcm_reader_t *wav_open(pcm_io_context_t *io, int ignore_length);
|
||||
pcm_reader_t *raw_open(pcm_io_context_t *io,
|
||||
const pcm_sample_description_t *desc);
|
||||
pcm_reader_t *caf_open(pcm_io_context_t *io,
|
||||
aacenc_tag_callback_t tag_callback, void *tag_ctx);
|
||||
|
||||
pcm_reader_t *pcm_open_native_converter(pcm_reader_t *reader);
|
||||
pcm_reader_t *pcm_open_float_converter(pcm_reader_t *reader);
|
||||
pcm_reader_t *pcm_open_sint16_converter(pcm_reader_t *reader);
|
||||
|
||||
pcm_reader_t *extrapolater_open(pcm_reader_t *reader);
|
||||
pcm_reader_t *limiter_open(pcm_reader_t *reader);
|
||||
|
||||
#endif
|
||||
|
@ -19,15 +19,35 @@
|
||||
#include "m4af_endian.h"
|
||||
#include "catypes.h"
|
||||
|
||||
int pcm_read_frames(pcm_reader_t *r, void *data, unsigned nframes)
|
||||
{
|
||||
int n;
|
||||
unsigned count = 0;
|
||||
uint8_t *bp = data;
|
||||
unsigned bpf = pcm_get_format(r)->bytes_per_frame;
|
||||
|
||||
do {
|
||||
n = r->vtbl->read_frames(r, bp, nframes - count);
|
||||
if (n > 0) {
|
||||
count += n;
|
||||
bp += n * bpf;
|
||||
}
|
||||
} while (n > 0 && count < nframes);
|
||||
return count;
|
||||
}
|
||||
|
||||
int pcm_read(pcm_io_context_t *io, void *buffer, uint32_t size)
|
||||
{
|
||||
int rc;
|
||||
uint32_t count = 0;
|
||||
uint8_t *bp = buffer;
|
||||
|
||||
do {
|
||||
rc = io->vtbl->read(io->cookie, buffer, size - count);
|
||||
if (rc > 0)
|
||||
rc = io->vtbl->read(io->cookie, bp, size - count);
|
||||
if (rc > 0) {
|
||||
count += rc;
|
||||
bp += rc;
|
||||
}
|
||||
} while (rc > 0 && count < size);
|
||||
return count > 0 ? count : rc;
|
||||
}
|
||||
|
@ -43,10 +43,10 @@ static int64_t get_position(pcm_reader_t *reader)
|
||||
|
||||
static int read_frames(pcm_reader_t *reader, void *buffer, unsigned nframes)
|
||||
{
|
||||
unsigned i, count;
|
||||
pcm_sint16_converter_t *self = (pcm_sint16_converter_t *)reader;
|
||||
const pcm_sample_description_t *sfmt = pcm_get_format(self->src);
|
||||
unsigned bytes = nframes * sfmt->bytes_per_frame;
|
||||
|
||||
if (self->capacity < bytes) {
|
||||
void *p = realloc(self->pivot, bytes);
|
||||
if (!p) return -1;
|
||||
@ -54,8 +54,25 @@ static int read_frames(pcm_reader_t *reader, void *buffer, unsigned nframes)
|
||||
self->capacity = bytes;
|
||||
}
|
||||
nframes = pcm_read_frames(self->src, self->pivot, nframes);
|
||||
if (pcm_convert_to_native_sint16(sfmt, self->pivot, nframes, buffer) < 0)
|
||||
return -1;
|
||||
count = nframes * sfmt->channels_per_frame;
|
||||
if (PCM_IS_FLOAT(sfmt)) {
|
||||
float *ip = self->pivot;
|
||||
int16_t *op = buffer;
|
||||
for (i = 0; i < count; ++i)
|
||||
op[i] = pcm_clip(ip[i] * 32768.0, -32768.0, 32767.0);
|
||||
} else {
|
||||
int32_t *ip = self->pivot;
|
||||
int16_t *op = buffer;
|
||||
if (sfmt->bits_per_channel <= 16) {
|
||||
for (i = 0; i < count; ++i)
|
||||
op[i] = ip[i] >> 16;
|
||||
} else {
|
||||
for (i = 0; i < count; ++i) {
|
||||
int n = ((ip[i] >> 15) + 1) >> 1;
|
||||
op[i] = (n == 0x8000) ? 0x7fff : n;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nframes;
|
||||
}
|
||||
|
||||
@ -83,12 +100,8 @@ pcm_reader_t *pcm_open_sint16_converter(pcm_reader_t *reader)
|
||||
self->vtbl = &my_vtable;
|
||||
memcpy(&self->format, pcm_get_format(reader), sizeof(self->format));
|
||||
fmt = &self->format;
|
||||
#if WORDS_BIGENDIAN
|
||||
fmt->sample_type = PCM_TYPE_SINT_BE;
|
||||
#else
|
||||
fmt->sample_type = PCM_TYPE_SINT;
|
||||
#endif
|
||||
fmt->bits_per_channel = 16;
|
||||
fmt->sample_type = PCM_TYPE_SINT;
|
||||
fmt->bytes_per_frame = 2 * fmt->channels_per_frame;
|
||||
return (pcm_reader_t *)self;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include "wav_reader.h"
|
||||
#include "pcm_reader.h"
|
||||
|
||||
#define RIFF_FOURCC(a,b,c,d) ((a)|((b)<<8)|((c)<<16)|((d)<<24))
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 nu774
|
||||
* For conditions of distribution and use, see copyright notice in COPYING
|
||||
*/
|
||||
#ifndef WAV_READER_H
|
||||
#define WAV_READER_H
|
||||
|
||||
#include "lpcm.h"
|
||||
#include "pcm_reader.h"
|
||||
|
||||
pcm_reader_t *wav_open(pcm_io_context_t *io, int ignore_length);
|
||||
pcm_reader_t *raw_open(pcm_io_context_t *io,
|
||||
const pcm_sample_description_t *desc);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user