1
0
mirror of https://github.com/nu774/fdkaac.git synced 2025-06-05 23:29:14 +02:00

66 Commits

Author SHA1 Message Date
35527e4041 bump 2024-05-06 00:44:07 +09:00
335ec165da use PKG_CHECK_MODULES for fdk-aac
https://github.com/nu774/fdkaac/issues/60
2024-05-06 00:42:20 +09:00
5cfdded636 add support for recent apple channel layout tags 2024-05-05 20:46:17 +09:00
d9649cc836 condifure.ac: add AC_CONFIG_AUX_DIR()
fix https://github.com/nu774/fdkaac/issues/53
2024-05-05 20:24:17 +09:00
f95566ee8e update help message regarding vbr mode 2023-03-14 00:24:51 +09:00
d705c888cf github workflow: add msys2 2023-03-10 00:18:58 +09:00
31e62aa51c update .gitignore 2023-03-09 23:56:31 +09:00
2ed6139278 github workflow: add mac 2023-03-08 23:43:23 +09:00
4037c42577 update github workflow 2023-03-08 23:10:19 +09:00
4f35b8ad7c add github workflow 2023-03-08 09:46:45 +09:00
3bf454a5a3 bump 2023-02-15 20:57:33 +09:00
22dbf72491 fixes https://github.com/nu774/fdkaac/issues/55 2023-02-15 20:56:33 +09:00
03c3c60191 updateChangeLog 2022-08-04 21:16:14 +09:00
59455af10a bump 2022-08-04 21:14:35 +09:00
ae1f4c3afd fdk-aac.vcxproj: support vs2022 2022-08-04 21:13:18 +09:00
0ce71d066a extrapolater: don't return more samples than required
fixes https://github.com/nu774/fdkaac/issues/54
2022-08-04 21:11:53 +09:00
ecddb7d633 wav/caf parser: add format checks
fixes https://github.com/nu774/fdkaac/issues/54
2022-08-04 21:06:10 +09:00
1a1ee2924f update ChangeLog 2022-07-13 21:03:53 +09:00
cdfb81d7c6 bump 2022-07-13 20:59:03 +09:00
4ec1422bd9 wav/caf parser: ensure fmt/desc chunk
fixes https://github.com/nu774/fdkaac/issues/52
2022-07-13 20:56:49 +09:00
53fe239bf6 vcxproj: support Visual Studio 2022 2021-11-15 01:18:51 +09:00
347e995cfc bump 2021-04-23 22:57:27 +09:00
9d65d3b3bf m4af: fix mvhd/tkhd duration
According to 14496-12, duration of mvhd/tkhd shall be the sum of
duration of edits
2021-04-23 22:53:46 +09:00
fdf5c2f251 bump 2020-09-21 22:41:03 +09:00
ef17c9436e add Windows 10 long pathname manifest 2020-09-21 22:41:03 +09:00
c0919b049a fix indent 2019-09-27 21:05:12 +09:00
353e4fcd7a process 32-bit input if possible (i.e. respect aac:INT_PCM type)
switch AAC-FDK from pcm16 to pcm32:
    typedef LONG INT_PCM;
    #define SAMPLE_BITS 32
2019-09-27 12:10:30 +03:00
130e249ebf vcxproj: support visual studio 2019 2019-04-04 19:55:18 +09:00
65ee26fb61 don't inject timestamp 2018-12-10 14:59:48 +03:00
f2f9c1b4bb bump version 1.0.0 2018-09-04 02:04:36 +09:00
836367a7fe Fix LD/ELD issue: priming samples are too short to be discarded
When discarded, cannot reconstruct the beginning.
Now we changed to activate smartpadding only for LC/HE/HEv2.
(padding is not nice for low delay codec anyway)

LD and ELD are two short
2018-09-04 01:30:08 +09:00
ca65cffdd3 FDKv2 API change: encoderDelay -> nDelay/nDelayCore 2018-09-03 22:59:24 +09:00
36424b121c update MSVC projects for FDKv2 2018-09-03 20:58:17 +09:00
2329b4b1eb use different IntDir for fdk-aac build 2018-09-03 20:27:42 +09:00
4c963ef139 remove zombies from fdk-aac.vcxproj.filters 2018-09-03 20:26:32 +09:00
3f7b6abd20 fix: -L option was not working (resulted in segfault) 2018-09-03 20:25:28 +09:00
4571d9d76a MSVC projects: update for VS2017 2017-03-16 20:51:30 +09:00
4682fe4961 address issue#26
try to link with libcharset when locale_charset() is not present in
libiconv
2017-01-16 15:20:09 +09:00
c37edc6051 remove aacenc_hcr.* from MSVC project 2016-08-27 23:51:48 +09:00
07c06b4c3e update ChangeLog 2016-08-26 21:47:20 +09:00
4242ad726f bump 2016-08-26 21:45:05 +09:00
c8cc3fb57e Ticket #23: quit supporting MPEG-2 AOT
Macro definitions for those AOT have gone from FDK_audio.h
2016-08-26 21:19:03 +09:00
622e065bd8 fix libfdkaac encoder version check for SBR_RATIO availability 2016-08-25 21:22:33 +09:00
cf200f9563 Use our SBR signaling implementation on old libfdkaac 2016-08-25 21:02:41 +09:00
fd2a1e77b3 improve MSVC project
- simplify conditions
- autodetect highest available PlatformToolset
- x64 platform support
2015-10-10 17:44:11 +09:00
17799e39b9 fix indents 2015-09-21 15:24:02 +09:00
19a6b7f10c update compat layer, mainly for MSVC14 issue 2015-09-21 15:19:15 +09:00
80b476bad9 add platformtoolset in vcxproj 2015-07-22 22:14:08 +09:00
e403976bf6 fix build issue on MSVC14 2015-07-22 22:14:00 +09:00
4080ab21e6 remove an unused variable decl 2015-06-12 21:07:59 +09:00
be991a6abe remove an unused variable decl 2015-06-12 21:06:45 +09:00
4c9167c1cb m4af: move internal struct m4af_itmf_entry_t from header 2015-06-12 21:04:49 +09:00
c77dae004d update ChangeLog 2015-02-14 19:35:05 +09:00
8c47bcc8dc bump version 2015-02-14 19:34:01 +09:00
1703d1f8cf take stco->co64 switch due to mdat relocation into account on finalizing m4a 2015-02-14 19:32:00 +09:00
4140443408 fix incorrect iTunSMPB written when interrupted by signals 2015-02-14 19:31:59 +09:00
a1b4f691f5 update ChangeLog 2014-09-13 00:26:27 +09:00
fae0942597 bump version 2014-09-13 00:25:31 +09:00
fcfed4cd0c write actual number of channels to mp4a box 2014-09-12 21:34:37 +09:00
1acf5c2d4d update INSTALL 2014-08-17 00:22:04 +09:00
25f5bd4f23 add m4 macros 2014-08-17 00:21:16 +09:00
e8f61c26ff update ChangeLog 2014-08-13 15:41:41 +09:00
a7c2411335 bump version 2014-08-13 15:40:24 +09:00
b54538f79e apply limiter when input is float 2014-08-13 09:26:26 +09:00
a7e00a4219 refactor pcm reader framework 2014-08-12 23:43:19 +09:00
b667da2b01 update ChangeLog 2014-07-30 14:11:04 +09:00
43 changed files with 2989 additions and 602 deletions

109
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,109 @@
name: CI
on: [push, pull_request]
jobs:
linux:
strategy:
matrix:
version: [20.04, 22.04]
runs-on: ubuntu-${{ matrix.version }}
steps:
- name: Install libfdk-aac
run: |
sudo apt install libfdk-aac-dev
- name: Checkout sources
uses: actions/checkout@v3
- name: Build
run: |
autoreconf -fiv
./configure
make
sudo make install
- name: Test
run: |
fdkaac -b 128 -R -o /dev/null /dev/null
mingw-cross:
strategy:
matrix:
arch: [i686, x86_64]
include:
- arch: i686
os: mingw32
- arch: x86_64
os: mingw64
runs-on: ubuntu-latest
steps:
- name: Install cross compiler
run: |
ARCH=${{ matrix.arch }}
sudo apt-get install g++-mingw-w64-${ARCH//_/-}
- name: Install libfdk-aac binary from repo.msys.org
run: |
wget https://repo.msys2.org/mingw/${{ matrix.os }}/${{ matrix.os }}.db.tar.zst
DESCFILE=$(tar xvf ${{ matrix.os }}.db.tar.zst --wildcards '*-fdk-aac*/desc')
PKGFILE=$(sed -n '/%FILENAME%/{n;p;q}' $DESCFILE)
wget https://repo.msys2.org/mingw/${{ matrix.os }}/${PKGFILE}
sudo tar xvf ${PKGFILE} -C /usr/${{ matrix.arch }}-w64-mingw32 --strip-component=1
- name: Checkout
uses: actions/checkout@v3
- name: Build
run: |
autoreconf -fiv
./configure --host=${{ matrix.arch }}-w64-mingw32 --prefix=/usr/${{ matrix.arch }}-w64-mingw32
make
sudo make install
macos:
runs-on: macos-latest
steps:
- name: Install dependencies
run: |
brew install autoconf automake libtool pkg-config
brew install fdk-aac
- name: Checkout sources
uses: actions/checkout@v3
- name: Build
run: |
autoreconf -fiv
./configure
make
make install
- name: Test
run: |
fdkaac -b 128 -R -o /dev/null /dev/null
msys2:
runs-on: windows-latest
strategy:
matrix:
sys: [ clang32, clang64, mingw32, mingw64, ucrt64 ]
defaults:
run:
shell: msys2 {0}
steps:
- name: Setup msys2
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.sys }}
update: true
install: git
pacboy: >-
autoconf:
automake:
libtool:
make:
cc:p
pkg-config:p
fdk-aac:p
- name: Checkout
uses: actions/checkout@v3
- name: Build
run: |
autoreconf -fiv
./configure
make
make install
- name: Test
run: |
fdkaac -b 128 -R -o /dev/null /dev/null

8
.gitignore vendored
View File

@ -20,3 +20,11 @@ src/.deps/
src/.dirstamp src/.dirstamp
stamp-h1 stamp-h1
fdkaac fdkaac
.vscode
fdk-aac
MSVC/Release
MSVC/Debug
MSVC/x64/Release
MSVC/x64/Debug
MSVC/fdk-aac
MSVC/*.vcxproj.user

176
ChangeLog
View File

@ -1,6 +1,176 @@
2022-08-04 nu774 <honeycomb77@gmail.com>
* bump [HEAD -> master]
* fdk-aac.vcxproj: support vs2022
* extrapolater: don't return more samples than required
* wav/caf parser: add format checks
2022-07-13 nu774 <honeycomb77@gmail.com>
* update ChangeLog [origin/master]
* bump [v1.0.3]
* wav/caf parser: ensure fmt/desc chunk
2021-11-15 nu774 <honeycomb77@gmail.com>
* vcxproj: support Visual Studio 2022
2021-04-23 nu774 <honeycomb77@gmail.com>
* bump [v1.0.2]
* m4af: fix mvhd/tkhd duration
2020-09-21 nu774 <honeycomb77@gmail.com>
* bump [v1.0.1]
* add Windows 10 long pathname manifest
2019-09-27 nu774 <honeycomb77@gmail.com>
* fix indent
2019-09-19 Dima <yudind@gmail.com>
* process 32-bit input if possible (i.e. respect aac:INT_PCM type)
2019-04-04 nu774 <honeycomb77@gmail.com>
* vcxproj: support visual studio 2019
2018-12-10 tico-tico <sergei.ivn@gmx.com>
* don't inject timestamp
2018-09-04 nu774 <honeycomb77@gmail.com>
* bump version 1.0.0 [1.0.0]
* Fix LD/ELD issue: priming samples are too short to be discarded
2018-09-03 nu774 <honeycomb77@gmail.com>
* FDKv2 API change: encoderDelay -> nDelay/nDelayCore
* update MSVC projects for FDKv2
* use different IntDir for fdk-aac build
* remove zombies from fdk-aac.vcxproj.filters
* fix: -L option was not working (resulted in segfault)
2017-03-16 nu774 <honeycomb77@gmail.com>
* MSVC projects: update for VS2017
2017-01-16 nu774 <honeycomb77@gmail.com>
* address issue#26
2016-08-27 nu774 <honeycomb77@gmail.com>
* remove aacenc_hcr.* from MSVC project
2016-08-26 nu774 <honeycomb77@gmail.com>
* update ChangeLog
* bump [v0.6.3]
* Ticket #23: quit supporting MPEG-2 AOT
2016-08-25 nu774 <honeycomb77@gmail.com>
* fix libfdkaac encoder version check for SBR_RATIO availability
* Use our SBR signaling implementation on old libfdkaac
2015-10-10 nu774 <honeycomb77@gmail.com>
* improve MSVC project
2015-09-21 nu774 <honeycomb77@gmail.com>
* fix indents
* update compat layer, mainly for MSVC14 issue
2015-07-22 nu774 <honeycomb77@gmail.com>
* add platformtoolset in vcxproj
* fix build issue on MSVC14
2015-06-12 nu774 <honeycomb77@gmail.com>
* remove an unused variable decl
* remove an unused variable decl
* m4af: move internal struct m4af_itmf_entry_t from header
2015-02-14 nu774 <honeycomb77@gmail.com>
* update ChangeLog
* bump version [v0.6.2]
* take stco->co64 switch due to mdat relocation into account on finalizing m4a
* fix incorrect iTunSMPB written when interrupted by signals
2014-09-13 nu774 <honeycomb77@gmail.com>
* update ChangeLog
* bump version [v0.6.1]
2014-09-12 nu774 <honeycomb77@gmail.com>
* write actual number of channels to mp4a box
2014-08-17 nu774 <honeycomb77@gmail.com>
* update INSTALL
* add m4 macros
2014-08-13 nu774 <honeycomb77@gmail.com>
* update ChangeLog
* 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
* 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> 2014-02-17 nu774 <honeycomb77@gmail.com>
* update ChangeLog [HEAD] * update ChangeLog
* bump version [v0.5.3] * bump version [v0.5.3]
@ -8,7 +178,7 @@
2014-01-18 nu774 <honeycomb77@gmail.com> 2014-01-18 nu774 <honeycomb77@gmail.com>
* update ChangeLog [origin/master] * update ChangeLog
* bump version [v0.5.2] * bump version [v0.5.2]
@ -112,7 +282,7 @@
2013-10-26 nu774 <honeycomb77@gmail.com> 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 * tag mapping: add recorded date and tempo, remove performer->artist

View File

@ -4,7 +4,6 @@ Prerequiste
To build fdkaac, you need the followings: To build fdkaac, you need the followings:
- libfdk-aac (https://github.com/mstorsjo/fdk-aac) - libfdk-aac (https://github.com/mstorsjo/fdk-aac)
- GNU autoconf, GNU automake - GNU autoconf, GNU automake
- GNU gettext (for iconv.m4)
libfdk-aac is always required, and probably you have to build it yourself. 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 Others are required only when you build by configure and make on Unix-like

View File

@ -1,83 +1,81 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32"> <ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{D7D4B982-8B16-4A10-8B1C-9527BD789709}</ProjectGuid> <ProjectGuid>{D7D4B982-8B16-4A10-8B1C-9527BD789709}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<RootNamespace>fdkaac</RootNamespace> <RootNamespace>fdk-aac</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<PlatformToolset Condition="'$(PlatformToolset)' == '' and '$(MSBuildToolsVersion)' == '17.0'">v143</PlatformToolset>
<PlatformToolset Condition="'$(PlatformToolset)' == '' and '$(MSBuildToolsVersion)' == '16.0'">v142</PlatformToolset>
<PlatformToolset Condition="'$(PlatformToolset)' == '' and '$(MSBuildToolsVersion)' == '15.0'">v141_xp</PlatformToolset>
<PlatformToolset Condition="'$(PlatformToolset)' == '' and '$(MSBuildToolsVersion)' == '14.0'">v140_xp</PlatformToolset>
<PlatformToolset Condition="'$(PlatformToolset)' == '' and '$(MSBuildToolsVersion)' == '12.0'">v120_xp</PlatformToolset>
<PlatformToolset Condition="'$(PlatformToolset)' == '' and '$(MSBuildToolsVersion)' == '11.0'">v110_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup>
<IntDir>fdk-aac\$(Platform)\$(Configuration)</IntDir>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="PropertySheets">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup>
<IntDir>$(Configuration)Lib\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IntDir>$(Configuration)Lib\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <PreprocessorDefinitions>WIN32;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <AdditionalIncludeDirectories>../fdk-aac/libaacenc/include;../fdk-aac/libFDK/include;../fdk-aac/libMpegTPEnc/include;../fdk-aac/libPCMutils/include;../fdk-aac/libSACenc/include;../fdk-aac/libSBRenc/include;../fdk-aac/libSYS/include</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../fdk-aac/libaacenc/include;../fdk-aac/libFDK/include;../fdk-aac/libMpegTPEnc/include;../fdk-aac/libPCMutils/include;../fdk-aac/libSBRenc/include;../fdk-aac/libSYS/include</AdditionalIncludeDirectories>
<StringPooling>true</StringPooling>
</ClCompile> </ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization>
<PrecompiledHeader>NotUsing</PrecompiledHeader> </ClCompile>
<Optimization>MaxSpeed</Optimization> </ItemDefinitionGroup>
<FunctionLevelLinking>true</FunctionLevelLinking> <ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<IntrinsicFunctions>true</IntrinsicFunctions> <ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>../fdk-aac/libaacenc/include;../fdk-aac/libFDK/include;../fdk-aac/libMpegTPEnc/include;../fdk-aac/libPCMutils/include;../fdk-aac/libSBRenc/include;../fdk-aac/libSYS/include</AdditionalIncludeDirectories> <AdditionalOptions>/Qvec-report:1 %(AdditionalOptions)</AdditionalOptions>
<StringPooling>true</StringPooling> </ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='x64'">
<ClCompile>
<PreprocessorDefinitions>__x86_64__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\fdk-aac\libAACenc\src\aacenc.cpp" /> <ClCompile Include="..\fdk-aac\libAACenc\src\aacenc.cpp" />
<ClCompile Include="..\fdk-aac\libAACenc\src\aacenc_hcr.cpp" />
<ClCompile Include="..\fdk-aac\libAACenc\src\aacenc_lib.cpp" /> <ClCompile Include="..\fdk-aac\libAACenc\src\aacenc_lib.cpp" />
<ClCompile Include="..\fdk-aac\libAACenc\src\aacenc_pns.cpp" /> <ClCompile Include="..\fdk-aac\libAACenc\src\aacenc_pns.cpp" />
<ClCompile Include="..\fdk-aac\libAACenc\src\aacEnc_ram.cpp" /> <ClCompile Include="..\fdk-aac\libAACenc\src\aacEnc_ram.cpp" />
@ -97,6 +95,7 @@
<ClCompile Include="..\fdk-aac\libAACenc\src\line_pe.cpp" /> <ClCompile Include="..\fdk-aac\libAACenc\src\line_pe.cpp" />
<ClCompile Include="..\fdk-aac\libAACenc\src\metadata_compressor.cpp" /> <ClCompile Include="..\fdk-aac\libAACenc\src\metadata_compressor.cpp" />
<ClCompile Include="..\fdk-aac\libAACenc\src\metadata_main.cpp" /> <ClCompile Include="..\fdk-aac\libAACenc\src\metadata_main.cpp" />
<ClCompile Include="..\fdk-aac\libAACenc\src\mps_main.cpp" />
<ClCompile Include="..\fdk-aac\libAACenc\src\ms_stereo.cpp" /> <ClCompile Include="..\fdk-aac\libAACenc\src\ms_stereo.cpp" />
<ClCompile Include="..\fdk-aac\libAACenc\src\noisedet.cpp" /> <ClCompile Include="..\fdk-aac\libAACenc\src\noisedet.cpp" />
<ClCompile Include="..\fdk-aac\libAACenc\src\pnsparam.cpp" /> <ClCompile Include="..\fdk-aac\libAACenc\src\pnsparam.cpp" />
@ -115,6 +114,8 @@
<ClCompile Include="..\fdk-aac\libFDK\src\FDK_core.cpp" /> <ClCompile Include="..\fdk-aac\libFDK\src\FDK_core.cpp" />
<ClCompile Include="..\fdk-aac\libFDK\src\FDK_crc.cpp" /> <ClCompile Include="..\fdk-aac\libFDK\src\FDK_crc.cpp" />
<ClCompile Include="..\fdk-aac\libFDK\src\FDK_hybrid.cpp" /> <ClCompile Include="..\fdk-aac\libFDK\src\FDK_hybrid.cpp" />
<ClCompile Include="..\fdk-aac\libFDK\src\FDK_lpc.cpp" />
<ClCompile Include="..\fdk-aac\libFDK\src\FDK_matrixCalloc.cpp" />
<ClCompile Include="..\fdk-aac\libFDK\src\FDK_tools_rom.cpp" /> <ClCompile Include="..\fdk-aac\libFDK\src\FDK_tools_rom.cpp" />
<ClCompile Include="..\fdk-aac\libFDK\src\FDK_trigFcts.cpp" /> <ClCompile Include="..\fdk-aac\libFDK\src\FDK_trigFcts.cpp" />
<ClCompile Include="..\fdk-aac\libFDK\src\fft.cpp" /> <ClCompile Include="..\fdk-aac\libFDK\src\fft.cpp" />
@ -128,7 +129,20 @@
<ClCompile Include="..\fdk-aac\libMpegTPEnc\src\tpenc_asc.cpp" /> <ClCompile Include="..\fdk-aac\libMpegTPEnc\src\tpenc_asc.cpp" />
<ClCompile Include="..\fdk-aac\libMpegTPEnc\src\tpenc_latm.cpp" /> <ClCompile Include="..\fdk-aac\libMpegTPEnc\src\tpenc_latm.cpp" />
<ClCompile Include="..\fdk-aac\libMpegTPEnc\src\tpenc_lib.cpp" /> <ClCompile Include="..\fdk-aac\libMpegTPEnc\src\tpenc_lib.cpp" />
<ClCompile Include="..\fdk-aac\libPCMutils\src\pcmutils_lib.cpp" /> <ClCompile Include="..\fdk-aac\libPCMutils\src\pcm_utils.cpp" />
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_bitstream.cpp" />
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_delay.cpp" />
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_dmx_tdom_enh.cpp" />
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_filter.cpp" />
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_framewindowing.cpp" />
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_huff_tab.cpp" />
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_lib.cpp" />
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_nlc_enc.cpp" />
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_onsetdetect.cpp" />
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_paramextract.cpp" />
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_staticgain.cpp" />
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_tree.cpp" />
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_vectorfunctions.cpp" />
<ClCompile Include="..\fdk-aac\libSBRenc\src\bit_sbr.cpp" /> <ClCompile Include="..\fdk-aac\libSBRenc\src\bit_sbr.cpp" />
<ClCompile Include="..\fdk-aac\libSBRenc\src\code_env.cpp" /> <ClCompile Include="..\fdk-aac\libSBRenc\src\code_env.cpp" />
<ClCompile Include="..\fdk-aac\libSBRenc\src\env_bit.cpp" /> <ClCompile Include="..\fdk-aac\libSBRenc\src\env_bit.cpp" />
@ -142,19 +156,18 @@
<ClCompile Include="..\fdk-aac\libSBRenc\src\ps_main.cpp" /> <ClCompile Include="..\fdk-aac\libSBRenc\src\ps_main.cpp" />
<ClCompile Include="..\fdk-aac\libSBRenc\src\resampler.cpp" /> <ClCompile Include="..\fdk-aac\libSBRenc\src\resampler.cpp" />
<ClCompile Include="..\fdk-aac\libSBRenc\src\sbrenc_freq_sca.cpp" /> <ClCompile Include="..\fdk-aac\libSBRenc\src\sbrenc_freq_sca.cpp" />
<ClCompile Include="..\fdk-aac\libSBRenc\src\sbrenc_ram.cpp" />
<ClCompile Include="..\fdk-aac\libSBRenc\src\sbrenc_rom.cpp" />
<ClCompile Include="..\fdk-aac\libSBRenc\src\sbr_encoder.cpp" /> <ClCompile Include="..\fdk-aac\libSBRenc\src\sbr_encoder.cpp" />
<ClCompile Include="..\fdk-aac\libSBRenc\src\sbr_misc.cpp" /> <ClCompile Include="..\fdk-aac\libSBRenc\src\sbr_misc.cpp" />
<ClCompile Include="..\fdk-aac\libSBRenc\src\sbr_ram.cpp" />
<ClCompile Include="..\fdk-aac\libSBRenc\src\sbr_rom.cpp" />
<ClCompile Include="..\fdk-aac\libSBRenc\src\ton_corr.cpp" /> <ClCompile Include="..\fdk-aac\libSBRenc\src\ton_corr.cpp" />
<ClCompile Include="..\fdk-aac\libSBRenc\src\tran_det.cpp" /> <ClCompile Include="..\fdk-aac\libSBRenc\src\tran_det.cpp" />
<ClCompile Include="..\fdk-aac\libSYS\src\conv_string.cpp" />
<ClCompile Include="..\fdk-aac\libSYS\src\genericStds.cpp" /> <ClCompile Include="..\fdk-aac\libSYS\src\genericStds.cpp" />
<ClCompile Include="..\fdk-aac\libSYS\src\syslib_channelMapDescr.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\fdk-aac\libAACenc\include\aacenc_lib.h" /> <ClInclude Include="..\fdk-aac\libAACenc\include\aacenc_lib.h" />
<ClInclude Include="..\fdk-aac\libAACenc\src\aacenc.h" /> <ClInclude Include="..\fdk-aac\libAACenc\src\aacenc.h" />
<ClInclude Include="..\fdk-aac\libAACenc\src\aacenc_hcr.h" />
<ClInclude Include="..\fdk-aac\libAACenc\src\aacenc_pns.h" /> <ClInclude Include="..\fdk-aac\libAACenc\src\aacenc_pns.h" />
<ClInclude Include="..\fdk-aac\libAACenc\src\aacEnc_ram.h" /> <ClInclude Include="..\fdk-aac\libAACenc\src\aacEnc_ram.h" />
<ClInclude Include="..\fdk-aac\libAACenc\src\aacEnc_rom.h" /> <ClInclude Include="..\fdk-aac\libAACenc\src\aacEnc_rom.h" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<Filter Include="Source Files"> <Filter Include="Source Files">
@ -18,9 +18,6 @@
<ClCompile Include="..\fdk-aac\libAACenc\src\aacenc.cpp"> <ClCompile Include="..\fdk-aac\libAACenc\src\aacenc.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\fdk-aac\libAACenc\src\aacenc_hcr.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libAACenc\src\aacenc_lib.cpp"> <ClCompile Include="..\fdk-aac\libAACenc\src\aacenc_lib.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -171,9 +168,6 @@
<ClCompile Include="..\fdk-aac\libMpegTPEnc\src\tpenc_lib.cpp"> <ClCompile Include="..\fdk-aac\libMpegTPEnc\src\tpenc_lib.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\fdk-aac\libPCMutils\src\pcmutils_lib.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSBRenc\src\bit_sbr.cpp"> <ClCompile Include="..\fdk-aac\libSBRenc\src\bit_sbr.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -219,22 +213,73 @@
<ClCompile Include="..\fdk-aac\libSBRenc\src\sbr_misc.cpp"> <ClCompile Include="..\fdk-aac\libSBRenc\src\sbr_misc.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\fdk-aac\libSBRenc\src\sbr_ram.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSBRenc\src\sbr_rom.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSBRenc\src\ton_corr.cpp"> <ClCompile Include="..\fdk-aac\libSBRenc\src\ton_corr.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\fdk-aac\libSBRenc\src\tran_det.cpp"> <ClCompile Include="..\fdk-aac\libSBRenc\src\tran_det.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\fdk-aac\libSYS\src\conv_string.cpp"> <ClCompile Include="..\fdk-aac\libSYS\src\genericStds.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\fdk-aac\libSYS\src\genericStds.cpp"> <ClCompile Include="..\fdk-aac\libPCMutils\src\pcm_utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSBRenc\src\sbrenc_ram.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSBRenc\src\sbrenc_rom.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_bitstream.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_delay.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_dmx_tdom_enh.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_filter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_framewindowing.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_huff_tab.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_lib.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_nlc_enc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_onsetdetect.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_paramextract.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_staticgain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_tree.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSACenc\src\sacenc_vectorfunctions.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libAACenc\src\mps_main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libSYS\src\syslib_channelMapDescr.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libFDK\src\FDK_matrixCalloc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\fdk-aac\libFDK\src\FDK_lpc.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
@ -245,9 +290,6 @@
<ClInclude Include="..\fdk-aac\libAACenc\src\aacenc.h"> <ClInclude Include="..\fdk-aac\libAACenc\src\aacenc.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\fdk-aac\libAACenc\src\aacenc_hcr.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\fdk-aac\libAACenc\src\aacenc_pns.h"> <ClInclude Include="..\fdk-aac\libAACenc\src\aacenc_pns.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>

View File

@ -8,17 +8,27 @@ EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32 Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Debug|Win32.ActiveCfg = Debug|Win32 {E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Debug|Win32.ActiveCfg = Debug|Win32
{E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Debug|Win32.Build.0 = Debug|Win32 {E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Debug|Win32.Build.0 = Debug|Win32
{E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Debug|x64.ActiveCfg = Debug|x64
{E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Debug|x64.Build.0 = Debug|x64
{E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Release|Win32.ActiveCfg = Release|Win32 {E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Release|Win32.ActiveCfg = Release|Win32
{E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Release|Win32.Build.0 = Release|Win32 {E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Release|Win32.Build.0 = Release|Win32
{E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Release|x64.ActiveCfg = Release|x64
{E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}.Release|x64.Build.0 = Release|x64
{D7D4B982-8B16-4A10-8B1C-9527BD789709}.Debug|Win32.ActiveCfg = Debug|Win32 {D7D4B982-8B16-4A10-8B1C-9527BD789709}.Debug|Win32.ActiveCfg = Debug|Win32
{D7D4B982-8B16-4A10-8B1C-9527BD789709}.Debug|Win32.Build.0 = Debug|Win32 {D7D4B982-8B16-4A10-8B1C-9527BD789709}.Debug|Win32.Build.0 = Debug|Win32
{D7D4B982-8B16-4A10-8B1C-9527BD789709}.Debug|x64.ActiveCfg = Debug|x64
{D7D4B982-8B16-4A10-8B1C-9527BD789709}.Debug|x64.Build.0 = Debug|x64
{D7D4B982-8B16-4A10-8B1C-9527BD789709}.Release|Win32.ActiveCfg = Release|Win32 {D7D4B982-8B16-4A10-8B1C-9527BD789709}.Release|Win32.ActiveCfg = Release|Win32
{D7D4B982-8B16-4A10-8B1C-9527BD789709}.Release|Win32.Build.0 = Release|Win32 {D7D4B982-8B16-4A10-8B1C-9527BD789709}.Release|Win32.Build.0 = Release|Win32
{D7D4B982-8B16-4A10-8B1C-9527BD789709}.Release|x64.ActiveCfg = Release|x64
{D7D4B982-8B16-4A10-8B1C-9527BD789709}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -5,93 +5,83 @@
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32"> <ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}</ProjectGuid> <ProjectGuid>{E62D32CF-E308-40BD-9FF0-8266C6CAA9AA}</ProjectGuid>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<RootNamespace>fdkaac</RootNamespace> <RootNamespace>fdkaac</RootNamespace>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<PlatformToolset Condition="'$(PlatformToolset)' == '' and '$(MSBuildToolsVersion)' == '17.0'">v143</PlatformToolset>
<PlatformToolset Condition="'$(PlatformToolset)' == '' and '$(MSBuildToolsVersion)' == '16.0'">v142</PlatformToolset>
<PlatformToolset Condition="'$(PlatformToolset)' == '' and '$(MSBuildToolsVersion)' == '15.0'">v141_xp</PlatformToolset>
<PlatformToolset Condition="'$(PlatformToolset)' == '' and '$(MSBuildToolsVersion)' == '14.0'">v140_xp</PlatformToolset>
<PlatformToolset Condition="'$(PlatformToolset)' == '' and '$(MSBuildToolsVersion)' == '12.0'">v120_xp</PlatformToolset>
<PlatformToolset Condition="'$(PlatformToolset)' == '' and '$(MSBuildToolsVersion)' == '11.0'">v110_xp</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="PropertySheets">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup>
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IntDir>cli_$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Configuration)Cli\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <PreprocessorDefinitions>HAVE_STDINT_H;inline=__inline;_CRT_SECURE_NO_WARNINGS;WIN32;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>HAVE_STDINT_H;inline=__inline;_CRT_SECURE_NO_WARNINGS;WIN32;_CONSOLE;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>./include;../missings;.;..</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>./include;../missings;.;..</AdditionalIncludeDirectories>
<StringPooling>true</StringPooling>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
</Link> </Link>
<Manifest>
<AdditionalManifestFiles>..\fdkaac.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
</Manifest>
<PreBuildEvent> <PreBuildEvent>
<Command>copy ..\fdk-aac\libAACdec\include\aacdecoder_lib.h include\fdk-aac\ <Command>copy ..\fdk-aac\libAACdec\include\aacdecoder_lib.h include\fdk-aac\
copy ..\fdk-aac\libAACenc\include\aacenc_lib.h include\fdk-aac\ copy ..\fdk-aac\libAACenc\include\aacenc_lib.h include\fdk-aac\
copy ..\fdk-aac\libSYS\include\FDK_Audio.h include\fdk-aac\ copy ..\fdk-aac\libSYS\include\FDK_Audio.h include\fdk-aac\
copy ..\fdk-aac\libSYS\include\genericStds.h include\fdk-aac\ copy ..\fdk-aac\libSYS\include\genericStds.h include\fdk-aac\
copy ..\fdk-aac\libSYS\include\machine_type.h include\fdk-aac\ </Command> copy ..\fdk-aac\libSYS\include\machine_type.h include\fdk-aac\
copy ..\fdk-aac\libSYS\include\syslib_channelMapDescr.h include\fdk-aac\
</Command>
</PreBuildEvent> </PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<Optimization>Disabled</Optimization>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization> <Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>HAVE_STDINT_H;inline=__inline;_CRT_SECURE_NO_WARNINGS;WIN32;_CONSOLE;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>./include;../missings;.;..</AdditionalIncludeDirectories>
<StringPooling>true</StringPooling>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
</Link> </Link>
<PreBuildEvent>
<Command>copy ..\fdk-aac\libAACdec\include\aacdecoder_lib.h include\fdk-aac\
copy ..\fdk-aac\libAACenc\include\aacenc_lib.h include\fdk-aac\
copy ..\fdk-aac\libSYS\include\FDK_Audio.h include\fdk-aac\
copy ..\fdk-aac\libSYS\include\genericStds.h include\fdk-aac\
copy ..\fdk-aac\libSYS\include\machine_type.h include\fdk-aac\ </Command>
</PreBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\missings\getopt.c" /> <ClCompile Include="..\missings\getopt.c" />
@ -99,12 +89,14 @@ copy ..\fdk-aac\libSYS\include\machine_type.h include\fdk-aac\ </Command>
<ClCompile Include="..\src\caf_reader.c" /> <ClCompile Include="..\src\caf_reader.c" />
<ClCompile Include="..\src\compat_win32.c" /> <ClCompile Include="..\src\compat_win32.c" />
<ClCompile Include="..\src\extrapolater.c" /> <ClCompile Include="..\src\extrapolater.c" />
<ClCompile Include="..\src\limiter.c" />
<ClCompile Include="..\src\lpc.c" /> <ClCompile Include="..\src\lpc.c" />
<ClCompile Include="..\src\lpcm.c" />
<ClCompile Include="..\src\m4af.c" /> <ClCompile Include="..\src\m4af.c" />
<ClCompile Include="..\src\main.c" /> <ClCompile Include="..\src\main.c" />
<ClCompile Include="..\src\metadata.c" /> <ClCompile Include="..\src\metadata.c" />
<ClCompile Include="..\src\parson.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_readhelper.c" />
<ClCompile Include="..\src\pcm_sint16_converter.c" /> <ClCompile Include="..\src\pcm_sint16_converter.c" />
<ClCompile Include="..\src\progress.c" /> <ClCompile Include="..\src\progress.c" />
@ -113,7 +105,6 @@ copy ..\fdk-aac\libSYS\include\machine_type.h include\fdk-aac\ </Command>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\missings\getopt.h" /> <ClInclude Include="..\missings\getopt.h" />
<ClInclude Include="..\src\aacenc.h" /> <ClInclude Include="..\src\aacenc.h" />
<ClInclude Include="..\src\caf_reader.h" />
<ClInclude Include="..\src\catypes.h" /> <ClInclude Include="..\src\catypes.h" />
<ClInclude Include="..\src\compat.h" /> <ClInclude Include="..\src\compat.h" />
<ClInclude Include="..\src\lpc.h" /> <ClInclude Include="..\src\lpc.h" />
@ -124,7 +115,6 @@ copy ..\fdk-aac\libSYS\include\machine_type.h include\fdk-aac\ </Command>
<ClInclude Include="..\src\parson.h" /> <ClInclude Include="..\src\parson.h" />
<ClInclude Include="..\src\pcm_reader.h" /> <ClInclude Include="..\src\pcm_reader.h" />
<ClInclude Include="..\src\progress.h" /> <ClInclude Include="..\src\progress.h" />
<ClInclude Include="..\src\wav_reader.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="fdk-aac.vcxproj"> <ProjectReference Include="fdk-aac.vcxproj">

View File

@ -27,10 +27,10 @@
<ClCompile Include="..\src\extrapolater.c"> <ClCompile Include="..\src\extrapolater.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\lpc.c"> <ClCompile Include="..\src\limiter.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\lpcm.c"> <ClCompile Include="..\src\lpc.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\m4af.c"> <ClCompile Include="..\src\m4af.c">
@ -39,6 +39,12 @@
<ClCompile Include="..\src\main.c"> <ClCompile Include="..\src\main.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </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"> <ClCompile Include="..\src\pcm_readhelper.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -59,9 +65,6 @@
<ClInclude Include="..\src\aacenc.h"> <ClInclude Include="..\src\aacenc.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\src\caf_reader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\catypes.h"> <ClInclude Include="..\src\catypes.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -86,9 +89,6 @@
<ClInclude Include="..\src\progress.h"> <ClInclude Include="..\src\progress.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\src\wav_reader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\missings\getopt.h"> <ClInclude Include="..\missings\getopt.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>

View File

@ -7,12 +7,14 @@ fdkaac_SOURCES = \
src/aacenc.c \ src/aacenc.c \
src/caf_reader.c \ src/caf_reader.c \
src/extrapolater.c \ src/extrapolater.c \
src/limiter.c \
src/lpc.c \ src/lpc.c \
src/lpcm.c \
src/m4af.c \ src/m4af.c \
src/main.c \ src/main.c \
src/metadata.c \ src/metadata.c \
src/parson.c \ src/parson.c \
src/pcm_float_converter.c \
src/pcm_native_converter.c \
src/pcm_readhelper.c \ src/pcm_readhelper.c \
src/pcm_sint16_converter.c \ src/pcm_sint16_converter.c \
src/progress.c \ src/progress.c \
@ -20,8 +22,13 @@ fdkaac_SOURCES = \
dist_man_MANS = man/fdkaac.1 dist_man_MANS = man/fdkaac.1
fdkaac_CFLAGS = @CFLAGS@ @FDK_AAC_CFLAGS@
fdkaac_LDADD = \ fdkaac_LDADD = \
@LIBICONV@ -lfdk-aac -lm @LIBICONV@ @CHARSET_LIB@ @FDK_AAC_LIBS@ -lm
.rc.o:
$(RC) $< -o $@
if FDK_PLATFORM_POSIX if FDK_PLATFORM_POSIX
fdkaac_SOURCES += \ fdkaac_SOURCES += \
@ -31,6 +38,7 @@ endif
if FDK_PLATFORM_WIN32 if FDK_PLATFORM_WIN32
fdkaac_SOURCES += \ fdkaac_SOURCES += \
src/compat_win32.c src/compat_win32.c
fdkaac_SOURCES += fdkaac.rc
endif endif
if FDK_NO_GETOPT_LONG if FDK_NO_GETOPT_LONG

9
README
View File

@ -52,15 +52,6 @@ OPTIONS
39 39
: MPEG-4 AAC ELD : MPEG-4 AAC ELD
129
: MPEG-2 AAC LC
132
: MPEG-2 HE-AAC (SBR)
156
: MPEG-2 HE-AAC v2 (SBR+PS)
-b, --bitrate \<n\> -b, --bitrate \<n\>
: Target bitrate (for CBR) : Target bitrate (for CBR)

View File

@ -6,16 +6,17 @@ changequote([,])dnl
AC_INIT([fdkaac], [XX_VERSION], [honeycomb77@gmail.com]) AC_INIT([fdkaac], [XX_VERSION], [honeycomb77@gmail.com])
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE AM_INIT_AUTOMAKE
AC_PROG_CC AC_PROG_CC
AM_PROG_CC_C_O AM_PROG_CC_C_O
AC_CHECK_TOOL(RC, windres,)
AC_CHECK_HEADERS([sys/time.h]) AC_CHECK_HEADERS([sys/time.h])
AC_CHECK_HEADERS([localcharset.h langinfo.h endian.h byteswap.h]) AC_CHECK_HEADERS([libcharset.h langinfo.h endian.h byteswap.h])
AC_CHECK_HEADERS([fdk-aac/aacenc_lib.h], , PKG_CHECK_MODULES([FDK_AAC],[fdk-aac])
AC_MSG_ERROR([libfdk-aac is required]))
AC_C_INLINE AC_C_INLINE
AC_C_BIGENDIAN AC_C_BIGENDIAN
@ -38,6 +39,12 @@ AC_CHECK_FUNC(getopt_long)
AM_CONDITIONAL([FDK_NO_GETOPT_LONG],[test "$ac_cv_func_getopt_long" != "yes"]) AM_CONDITIONAL([FDK_NO_GETOPT_LONG],[test "$ac_cv_func_getopt_long" != "yes"])
AC_SEARCH_LIBS([aacEncOpen],[fdk-aac],[],[],[]) AC_SEARCH_LIBS([aacEncOpen],[fdk-aac],[],[],[])
CHARSET_LIB=
AC_CHECK_LIB([iconv], [locale_charset],
[CHARSET_LIB=-liconv],
[AC_CHECK_LIB([charset], [locale_charset], [CHARSET_LIB=-lcharset])])
AC_SUBST([CHARSET_LIB])
AC_CANONICAL_HOST AC_CANONICAL_HOST
X_PLATFORM=posix X_PLATFORM=posix

8
fdkaac.manifest Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<ws2:longPathAware>true</ws2:longPathAware>
</windowsSettings>
</application>
</assembly>

3
fdkaac.rc Normal file
View File

@ -0,0 +1,3 @@
#include <winresrc.h>
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "fdkaac.manifest"

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python3
# Copyright (C) 2013 nu774 # Copyright (C) 2013 nu774
# For conditions of distribution and use, see copyright notice in COPYING # For conditions of distribution and use, see copyright notice in COPYING
@ -39,6 +39,6 @@ with Popen(GITLOG_CMD, shell=False, stdout=PIPE).stdout as pipe:
commits = parse_gitlog(pipe) commits = parse_gitlog(pipe)
commits_by_date_author = groupby(commits, key=lambda x: (x.date, x.author)) commits_by_date_author = groupby(commits, key=lambda x: (x.date, x.author))
for (date, author), commits in commits_by_date_author: for (date, author), commits in commits_by_date_author:
output(u'{0} {1}\n\n'.format(date, author).encode('utf-8')) output(f'{date} {author}\n\n')
for c in commits: for c in commits:
output(u' * {0}{1}\n\n'.format(c.subject, c.ref).encode('utf-8')) output(f' * {c.subject}{c.ref}\n\n')

268
m4/iconv.m4 Normal file
View 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
View 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
View 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
View 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"
])

View File

@ -1,10 +1,13 @@
.TH FDKAAC 1 "November, 2013" .\" Automatically generated by Pandoc 1.17.1
.\"
.TH "FDKAAC" "1" "November, 2013" "" ""
.hy
.SH NAME .SH NAME
.PP .PP
fdkaac \- command line frontend for libfdk\-aac encoder fdkaac \- command line frontend for libfdk\-aac encoder
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
\f[B]fdkaac\f[] [OPTIONS][FILE] \f[B]fdkaac\f[] [OPTIONS] [FILE]
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
\f[B]fdkaac\f[] reads linear PCM audio in either WAV, raw PCM, or CAF \f[B]fdkaac\f[] reads linear PCM audio in either WAV, raw PCM, or CAF
@ -56,21 +59,6 @@ MPEG\-4 AAC LD
MPEG\-4 AAC ELD MPEG\-4 AAC ELD
.RS .RS
.RE .RE
.TP
.B 129
MPEG\-2 AAC LC
.RS
.RE
.TP
.B 132
MPEG\-2 HE\-AAC (SBR)
.RS
.RE
.TP
.B 156
MPEG\-2 HE\-AAC v2 (SBR+PS)
.RS
.RE
.RE .RE
.TP .TP
.B \-b, \-\-bitrate <n> .B \-b, \-\-bitrate <n>

View File

@ -13,6 +13,13 @@
#include <string.h> #include <string.h>
#include "aacenc.h" #include "aacenc.h"
int aacenc_is_explicit_bw_compatible_sbr_signaling_available()
{
LIB_INFO lib_info;
aacenc_get_lib_info(&lib_info);
return lib_info.version > 0x03040900;
}
int aacenc_is_sbr_ratio_available() int aacenc_is_sbr_ratio_available()
{ {
#if AACENCODER_LIB_VL0 < 3 || (AACENCODER_LIB_VL0==3 && AACENCODER_LIB_VL1<4) #if AACENCODER_LIB_VL0 < 3 || (AACENCODER_LIB_VL0==3 && AACENCODER_LIB_VL1<4)
@ -20,15 +27,14 @@ int aacenc_is_sbr_ratio_available()
#else #else
LIB_INFO lib_info; LIB_INFO lib_info;
aacenc_get_lib_info(&lib_info); aacenc_get_lib_info(&lib_info);
return lib_info.version > 0x03040000; return lib_info.version > 0x03040800;
#endif #endif
} }
int aacenc_is_sbr_active(const aacenc_param_t *params) int aacenc_is_sbr_active(const aacenc_param_t *params)
{ {
switch (params->profile) { switch (params->profile) {
case AOT_SBR: case AOT_PS: case AOT_MP2_SBR: case AOT_MP2_PS: case AOT_SBR: case AOT_PS:
case AOT_DABPLUS_SBR: case AOT_DABPLUS_PS:
case AOT_DRM_SBR: case AOT_DRM_MPEG_PS: case AOT_DRM_SBR: case AOT_DRM_MPEG_PS:
return 1; return 1;
} }
@ -39,9 +45,9 @@ int aacenc_is_sbr_active(const aacenc_param_t *params)
int aacenc_is_dual_rate_sbr(const aacenc_param_t *params) int aacenc_is_dual_rate_sbr(const aacenc_param_t *params)
{ {
if (params->profile == AOT_PS || params->profile == AOT_MP2_PS) if (params->profile == AOT_PS)
return 1; return 1;
else if (params->profile == AOT_SBR || params->profile == AOT_MP2_SBR) else if (params->profile == AOT_SBR)
return params->sbr_ratio == 0 || params->sbr_ratio == 2; return params->sbr_ratio == 0 || params->sbr_ratio == 2;
else if (params->profile == AOT_ER_AAC_ELD && params->lowdelay_sbr) else if (params->profile == AOT_ER_AAC_ELD && params->lowdelay_sbr)
return params->sbr_ratio == 2; return params->sbr_ratio == 2;
@ -64,6 +70,70 @@ void aacenc_get_lib_info(LIB_INFO *info)
free(lib_info); free(lib_info);
} }
static const unsigned aacenc_sampling_freq_tab[] = {
96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050,
16000, 12000, 11025, 8000, 7350, 0, 0, 0
};
static
unsigned sampling_freq_index(unsigned rate)
{
unsigned i;
for (i = 0; aacenc_sampling_freq_tab[i]; ++i)
if (aacenc_sampling_freq_tab[i] == rate)
return i;
return 0xf;
}
/*
* Append backward compatible SBR/PS signaling to implicit signaling ASC,
* if SBR/PS is present.
*/
int aacenc_mp4asc(const aacenc_param_t *params,
const uint8_t *asc, uint32_t ascsize,
uint8_t *outasc, uint32_t *outsize)
{
unsigned asc_sfreq = aacenc_sampling_freq_tab[(asc[0]&0x7)<<1 |asc[1]>>7];
unsigned shift = aacenc_is_dual_rate_sbr(params);
switch (params->profile) {
case AOT_SBR:
case AOT_PS:
if (!shift)
break;
if (*outsize < ascsize + 3)
return -1;
memcpy(outasc, asc, ascsize);
/* syncExtensionType:11 (value:0x2b7) */
outasc[ascsize+0] = 0x2b << 1;
outasc[ascsize+1] = 0x7 << 5;
/* extensionAudioObjectType:5 (value:5)*/
outasc[ascsize+1] |= 5;
/* sbrPresentFlag:1 (value:1) */
outasc[ascsize+2] = 0x80;
/* extensionSamplingFrequencyIndex:4 */
outasc[ascsize+2] |= sampling_freq_index(asc_sfreq << shift) << 3;
if (params->profile == AOT_SBR) {
*outsize = ascsize + 3;
return 0;
}
if (*outsize < ascsize + 5)
return -1;
/* syncExtensionType:11 (value:0x548) */
outasc[ascsize+2] |= 0x5;
outasc[ascsize+3] = 0x48;
/* psPresentFlag:1 (value:1) */
outasc[ascsize+4] = 0x80;
*outsize = ascsize + 5;
return 0;
}
if (*outsize < ascsize)
return -1;
memcpy(outasc, asc, ascsize);
*outsize = ascsize;
return 0;
}
static static
int aacenc_channel_mode(const pcm_sample_description_t *format) int aacenc_channel_mode(const pcm_sample_description_t *format)
{ {
@ -140,7 +210,7 @@ int aacenc_init(HANDLE_AACENCODER *encoder, const aacenc_param_t *params,
aacEncoder_SetParam(*encoder, AACENC_SBR_MODE, params->lowdelay_sbr); aacEncoder_SetParam(*encoder, AACENC_SBR_MODE, params->lowdelay_sbr);
#if AACENCODER_LIB_VL0 > 3 || (AACENCODER_LIB_VL0==3 && AACENCODER_LIB_VL1>=4) #if AACENCODER_LIB_VL0 > 3 || (AACENCODER_LIB_VL0==3 && AACENCODER_LIB_VL1>=4)
if (lib_info.version > 0x03040000) if (lib_info.version > 0x03040800)
aacEncoder_SetParam(*encoder, AACENC_SBR_RATIO, params->sbr_ratio); aacEncoder_SetParam(*encoder, AACENC_SBR_RATIO, params->sbr_ratio);
#endif #endif
@ -177,7 +247,7 @@ FAIL:
int aac_encode_frame(HANDLE_AACENCODER encoder, int aac_encode_frame(HANDLE_AACENCODER encoder,
const pcm_sample_description_t *format, const pcm_sample_description_t *format,
const int16_t *input, unsigned iframes, const INT_PCM *input, unsigned iframes,
aacenc_frame_t *output) aacenc_frame_t *output)
{ {
uint32_t ilen = iframes * format->channels_per_frame; uint32_t ilen = iframes * format->channels_per_frame;
@ -188,9 +258,9 @@ int aac_encode_frame(HANDLE_AACENCODER encoder,
void *obufs[1]; void *obufs[1];
INT ibuf_ids[] = { IN_AUDIO_DATA }; INT ibuf_ids[] = { IN_AUDIO_DATA };
INT obuf_ids[] = { OUT_BITSTREAM_DATA }; INT obuf_ids[] = { OUT_BITSTREAM_DATA };
INT ibuf_sizes[] = { ilen * sizeof(int16_t) }; INT ibuf_sizes[] = { ilen * sizeof(INT_PCM) };
INT obuf_sizes[1]; INT obuf_sizes[1];
INT ibuf_el_sizes[] = { sizeof(int16_t) }; INT ibuf_el_sizes[] = { sizeof(INT_PCM) };
INT obuf_el_sizes[] = { 1 }; INT obuf_el_sizes[] = { 1 };
AACENC_ERROR err; AACENC_ERROR err;
unsigned channel_mode, obytes; unsigned channel_mode, obytes;

View File

@ -30,6 +30,8 @@ typedef struct aacenc_frame_t {
uint32_t size, capacity; uint32_t size, capacity;
} aacenc_frame_t; } aacenc_frame_t;
int aacenc_is_explicit_bw_compatible_sbr_signaling_available();
int aacenc_is_sbr_ratio_available(); int aacenc_is_sbr_ratio_available();
int aacenc_is_sbr_active(const aacenc_param_t *params); int aacenc_is_sbr_active(const aacenc_param_t *params);
@ -38,13 +40,17 @@ int aacenc_is_dual_rate_sbr(const aacenc_param_t *params);
void aacenc_get_lib_info(LIB_INFO *info); void aacenc_get_lib_info(LIB_INFO *info);
int aacenc_mp4asc(const aacenc_param_t *params,
const uint8_t *asc, uint32_t ascsize,
uint8_t *outasc, uint32_t *outsize);
int aacenc_init(HANDLE_AACENCODER *encoder, const aacenc_param_t *params, int aacenc_init(HANDLE_AACENCODER *encoder, const aacenc_param_t *params,
const pcm_sample_description_t *format, const pcm_sample_description_t *format,
AACENC_InfoStruct *info); AACENC_InfoStruct *info);
int aac_encode_frame(HANDLE_AACENCODER encoder, int aac_encode_frame(HANDLE_AACENCODER encoder,
const pcm_sample_description_t *format, const pcm_sample_description_t *format,
const int16_t *input, unsigned iframes, const INT_PCM *input, unsigned iframes,
aacenc_frame_t *output); aacenc_frame_t *output);
#endif #endif

View File

@ -14,7 +14,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include "caf_reader.h" #include "pcm_reader.h"
#include "m4af.h" #include "m4af.h"
typedef struct caf_reader_t { typedef struct caf_reader_t {
@ -75,8 +75,10 @@ int caf_desc(caf_reader_t *reader, int64_t chunk_size)
ENSURE(mFormatID == M4AF_FOURCC('l','p','c','m')); ENSURE(mFormatID == M4AF_FOURCC('l','p','c','m'));
ENSURE(mSampleRate && mBytesPerPacket && ENSURE(mSampleRate && mBytesPerPacket &&
mChannelsPerFrame >= 1 && mChannelsPerFrame <= 8 && mChannelsPerFrame >= 1 && mChannelsPerFrame <= 8 &&
mBitsPerChannel && mFramesPerPacket == 1 && mBitsPerChannel > 0 && mBitsPerChannel < 256 &&
mFramesPerPacket == 1 &&
mBytesPerPacket % mChannelsPerFrame == 0 && mBytesPerPacket % mChannelsPerFrame == 0 &&
mBytesPerPacket < 256 &&
mBytesPerPacket >= mChannelsPerFrame * ((mBitsPerChannel + 7) / 8)); mBytesPerPacket >= mChannelsPerFrame * ((mBitsPerChannel + 7) / 8));
desc->sample_rate = mSampleRate; desc->sample_rate = mSampleRate;
@ -103,10 +105,14 @@ int caf_info(caf_reader_t *reader, int64_t chunk_size)
{ {
char *buf, *key, *val, *end; char *buf, *key, *val, *end;
size_t len; size_t len;
int n;
if (chunk_size < 4 || (buf = malloc(chunk_size)) == 0) if (chunk_size < 4 || (buf = malloc(chunk_size+1)) == 0)
return -1; return -1;
pcm_read(&reader->io, buf, chunk_size); n = pcm_read(&reader->io, buf, chunk_size);
if (n != chunk_size)
return -1;
buf[n] = 0;
key = buf + 4; key = buf + 4;
end = buf + chunk_size; end = buf + chunk_size;
do { do {
@ -172,6 +178,7 @@ int caf_parse(caf_reader_t *reader, int64_t *data_length)
{ {
uint32_t fcc; uint32_t fcc;
int64_t chunk_size; int64_t chunk_size;
int desc_seen = 0;
*data_length = 0; *data_length = 0;
@ -181,9 +188,10 @@ int caf_parse(caf_reader_t *reader, int64_t *data_length)
TRY_IO(pcm_skip(&reader->io, 4)); /* mFileVersion, mFileFlags */ TRY_IO(pcm_skip(&reader->io, 4)); /* mFileVersion, mFileFlags */
while ((fcc = caf_next_chunk(reader, &chunk_size)) != 0) { while ((fcc = caf_next_chunk(reader, &chunk_size)) != 0) {
if (fcc == M4AF_FOURCC('d','e','s','c')) if (fcc == M4AF_FOURCC('d','e','s','c')) {
desc_seen = 1;
TRY_IO(caf_desc(reader, chunk_size)); TRY_IO(caf_desc(reader, chunk_size));
else if (fcc == M4AF_FOURCC('i','n','f','o')) } else if (fcc == M4AF_FOURCC('i','n','f','o'))
TRY_IO(caf_info(reader, chunk_size)); TRY_IO(caf_info(reader, chunk_size));
else if (fcc == M4AF_FOURCC('c','h','a','n')) { else if (fcc == M4AF_FOURCC('c','h','a','n')) {
ENSURE(reader->sample_format.channels_per_frame); ENSURE(reader->sample_format.channels_per_frame);
@ -199,7 +207,7 @@ int caf_parse(caf_reader_t *reader, int64_t *data_length)
TRY_IO(pcm_skip(&reader->io, chunk_size)); TRY_IO(pcm_skip(&reader->io, chunk_size));
} }
ENSURE(reader->sample_format.channels_per_frame); ENSURE(reader->sample_format.channels_per_frame);
ENSURE(fcc == M4AF_FOURCC('d','a','t','a')); ENSURE(desc_seen && fcc == M4AF_FOURCC('d','a','t','a'));
return 0; return 0;
FAIL: FAIL:
return -1; return -1;

View File

@ -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

View File

@ -207,7 +207,6 @@ enum
kAudioChannelLayoutTag_AudioUnit_5_0 = kAudioChannelLayoutTag_MPEG_5_0_B, // L R Ls Rs C kAudioChannelLayoutTag_AudioUnit_5_0 = kAudioChannelLayoutTag_MPEG_5_0_B, // L R Ls Rs C
kAudioChannelLayoutTag_AudioUnit_6_0 = (139L<<16) | 6, // L R Ls Rs C Cs kAudioChannelLayoutTag_AudioUnit_6_0 = (139L<<16) | 6, // L R Ls Rs C Cs
kAudioChannelLayoutTag_AudioUnit_7_0 = (140L<<16) | 7, // L R Ls Rs C Rls Rrs kAudioChannelLayoutTag_AudioUnit_7_0 = (140L<<16) | 7, // L R Ls Rs C Rls Rrs
kAudioChannelLayoutTag_AudioUnit_7_0_Front = (148L<<16) | 7, // L R Ls Rs C Lc Rc
kAudioChannelLayoutTag_AudioUnit_5_1 = kAudioChannelLayoutTag_MPEG_5_1_A, // L R C LFE Ls Rs kAudioChannelLayoutTag_AudioUnit_5_1 = kAudioChannelLayoutTag_MPEG_5_1_A, // L R C LFE Ls Rs
kAudioChannelLayoutTag_AudioUnit_6_1 = kAudioChannelLayoutTag_MPEG_6_1_A, // L R C LFE Ls Rs Cs kAudioChannelLayoutTag_AudioUnit_6_1 = kAudioChannelLayoutTag_MPEG_6_1_A, // L R C LFE Ls Rs Cs
kAudioChannelLayoutTag_AudioUnit_7_1 = kAudioChannelLayoutTag_MPEG_7_1_C, // L R C LFE Ls Rs Rls Rrs kAudioChannelLayoutTag_AudioUnit_7_1 = kAudioChannelLayoutTag_MPEG_7_1_C, // L R C LFE Ls Rs Rls Rrs
@ -227,6 +226,10 @@ enum
kAudioChannelLayoutTag_TMH_10_2_std = (145L<<16) | 16, // L R C Vhc Lsd Rsd Ls Rs Vhl Vhr Lw Rw Csd Cs LFE1 LFE2 kAudioChannelLayoutTag_TMH_10_2_std = (145L<<16) | 16, // L R C Vhc Lsd Rsd Ls Rs Vhl Vhr Lw Rw Csd Cs LFE1 LFE2
kAudioChannelLayoutTag_TMH_10_2_full = (146L<<16) | 21, // TMH_10_2_std plus: Lc Rc HI VI Haptic kAudioChannelLayoutTag_TMH_10_2_full = (146L<<16) | 21, // TMH_10_2_std plus: Lc Rc HI VI Haptic
kAudioChannelLayoutTag_DiscreteInOrder = (147L<<16) | 0, // needs to be ORed with the actual number of channels
kAudioChannelLayoutTag_AudioUnit_7_0_Front = (148L<<16) | 7, // L R Ls Rs C Lc Rc
kAudioChannelLayoutTag_AC3_1_0_1 = (149L<<16) | 2, // C LFE kAudioChannelLayoutTag_AC3_1_0_1 = (149L<<16) | 2, // C LFE
kAudioChannelLayoutTag_AC3_3_0 = (150L<<16) | 3, // L C R kAudioChannelLayoutTag_AC3_3_0 = (150L<<16) | 3, // L C R
kAudioChannelLayoutTag_AC3_3_1 = (151L<<16) | 4, // L C R Cs kAudioChannelLayoutTag_AC3_3_1 = (151L<<16) | 4, // L C R Cs
@ -234,7 +237,53 @@ enum
kAudioChannelLayoutTag_AC3_2_1_1 = (153L<<16) | 4, // L R Cs LFE kAudioChannelLayoutTag_AC3_2_1_1 = (153L<<16) | 4, // L R Cs LFE
kAudioChannelLayoutTag_AC3_3_1_1 = (154L<<16) | 5, // L C R Cs LFE kAudioChannelLayoutTag_AC3_3_1_1 = (154L<<16) | 5, // L C R Cs LFE
kAudioChannelLayoutTag_DiscreteInOrder = (147L<<16) | 0, // needs to be ORed with the actual number of channels kAudioChannelLayoutTag_EAC_6_0_A = (155<<16) | 6, // L C R Ls Rs Cs
kAudioChannelLayoutTag_EAC_7_0_A = (156<<16) | 7, // L C R Ls Rs Rls Rrs
kAudioChannelLayoutTag_EAC3_6_1_A = (157<<16) | 7, // L C R Ls Rs LFE Cs
kAudioChannelLayoutTag_EAC3_6_1_B = (158<<16) | 7, // L C R Ls Rs LFE Ts
kAudioChannelLayoutTag_EAC3_6_1_C = (159<<16) | 7, // L C R Ls Rs LFE Vhc
kAudioChannelLayoutTag_EAC3_7_1_A = (160<<16) | 8, // L C R Ls Rs LFE Rls Rrs
kAudioChannelLayoutTag_EAC3_7_1_B = (161<<16) | 8, // L C R Ls Rs LFE Lc Rc
kAudioChannelLayoutTag_EAC3_7_1_C = (162<<16) | 8, // L C R Ls Rs LFE Lsd Rsd
kAudioChannelLayoutTag_EAC3_7_1_D = (163<<16) | 8, // L C R Ls Rs LFE Lw Rw
kAudioChannelLayoutTag_EAC3_7_1_E = (164<<16) | 8, // L C R Ls Rs LFE Vhl Vhr
kAudioChannelLayoutTag_EAC3_7_1_F = (165<<16) | 8, // L C R Ls Rs LFE Cs Ts
kAudioChannelLayoutTag_EAC3_7_1_G = (166<<16) | 8, // L C R Ls Rs LFE Cs Vhc
kAudioChannelLayoutTag_EAC3_7_1_H = (167<<16) | 8, // L C R Ls Rs LFE Ts Vhc
kAudioChannelLayoutTag_DTS_3_1 = (168<<16) | 4, // C L R LFE
kAudioChannelLayoutTag_DTS_4_1 = (169<<16) | 5, // C L R Cs LFE
kAudioChannelLayoutTag_DTS_6_0_A = (170<<16) | 6, // Lc Rc L R Ls Rs
kAudioChannelLayoutTag_DTS_6_0_B = (171<<16) | 6, // C L R Rls Rrs Ts
kAudioChannelLayoutTag_DTS_6_0_C = (172<<16) | 6, // C Cs L R Rls Rrs
kAudioChannelLayoutTag_DTS_6_1_A = (173<<16) | 7, // Lc Rc L R Ls Rs LFE
kAudioChannelLayoutTag_DTS_6_1_B = (174<<16) | 7, // C L R Rls Rrs Ts LFE
kAudioChannelLayoutTag_DTS_6_1_C = (175<<16) | 7, // C Cs L R Rls Rrs LFE
kAudioChannelLayoutTag_DTS_7_0 = (176<<16) | 7, // Lc C Rc L R Ls Rs
kAudioChannelLayoutTag_DTS_7_1 = (177<<16) | 8, // Lc C Rc L R Ls Rs LFE
kAudioChannelLayoutTag_DTS_8_0_A = (178<<16) | 8, // Lc Rc L R Ls Rs Rls Rrs
kAudioChannelLayoutTag_DTS_8_0_B = (179<<16) | 8, // Lc C Rc L R Ls Cs Rs
kAudioChannelLayoutTag_DTS_8_1_A = (180<<16) | 9, // Lc Rc L R Ls Rs Rls Rrs LFE
kAudioChannelLayoutTag_DTS_8_1_B = (181<<16) | 9, // Lc C Rc L R Ls Cs Rs LFE
kAudioChannelLayoutTag_DTS_6_1_D = (182<<16) | 7, // C L R Ls Rs LFE Cs
kAudioChannelLayoutTag_AAC_7_1_B = (183<<16) | 8, // C L R Ls Rs Rls Rrs LFE
kAudioChannelLayoutTag_AAC_7_1_C = (184<<16) | 8, // C L R Ls Rs LFE Vhl Vhr
kAudioChannelLayoutTag_WAVE_4_0_B = (185<<16) | 4, // L R Rls Rrs
kAudioChannelLayoutTag_WAVE_5_0_B = (186<<16) | 5, // L R C Rls Rrs
kAudioChannelLayoutTag_WAVE_5_1_B = (187<<16) | 6, // L R C LFE Rls Rrs
kAudioChannelLayoutTag_WAVE_6_1 = (188<<16) | 7, // L R C LFE Cs Ls Rs
kAudioChannelLayoutTag_WAVE_7_1 = (189<<16) | 8, // L R C LFE Rls Rrs Ls Rs
kAudioChannelLayoutTag_Logic_4_0_C = (197U<<16) | 4, // L R Cs C
kAudioChannelLayoutTag_Logic_6_0_B = (198U<<16) | 6, // L R Ls Rs Cs C
kAudioChannelLayoutTag_Logic_6_1_B = (199U<<16) | 7, // L R Ls Rs Cs C LFE
kAudioChannelLayoutTag_Logic_6_1_D = (200U<<16) | 7, // L C R Ls Cs Rs LFE
kAudioChannelLayoutTag_Logic_7_1_B = (201U<<16) | 8, // L R Ls Rs Rls Rrs C LFE
kAudioChannelLayoutTag_Unknown = 0xFFFF0000 // needs to be ORed with the actual number of channels kAudioChannelLayoutTag_Unknown = 0xFFFF0000 // needs to be ORed with the actual number of channels
}; };

View File

@ -20,9 +20,18 @@
int64_t aacenc_timer(void); int64_t aacenc_timer(void);
FILE *aacenc_fopen(const char *name, const char *mode); FILE *aacenc_fopen(const char *name, const char *mode);
#ifdef _WIN32
void aacenc_getmainargs(int *argc, char ***argv); void aacenc_getmainargs(int *argc, char ***argv);
#else
#define aacenc_getmainargs(argc, argv) (void)0
#endif
char *aacenc_to_utf8(const char *s); char *aacenc_to_utf8(const char *s);
#ifdef _WIN32
int aacenc_fprintf(FILE *fp, const char *fmt, ...); int aacenc_fprintf(FILE *fp, const char *fmt, ...);
#else
#define aacenc_fprintf fprintf
#endif
const char *aacenc_basename(const char *path); const char *aacenc_basename(const char *path);
int aacenc_seekable(FILE *fp);
#endif #endif

View File

@ -32,20 +32,9 @@ FILE *aacenc_fopen(const char *name, const char *mode)
return fp; return fp;
} }
void aacenc_getmainargs(int *argc, char ***argv) int aacenc_seekable(FILE *fp)
{ {
return; return fseek(fp, 0, SEEK_CUR) == 0;
}
int aacenc_fprintf(FILE *fp, const char *fmt, ...)
{
va_list ap;
int cnt;
va_start(ap, fmt);
cnt = vfprintf(fp, fmt, ap);
va_end(ap);
return cnt;
} }
/* /*
@ -70,8 +59,8 @@ char *aacenc_to_utf8(const char *s)
#include <errno.h> #include <errno.h>
#include <iconv.h> #include <iconv.h>
#if HAVE_LOCALCHARSET_H #if HAVE_LIBCHARSET_H
#include <localcharset.h> #include <libcharset.h>
#elif HAVE_LANGINFO_H #elif HAVE_LANGINFO_H
#include <langinfo.h> #include <langinfo.h>
static const char *locale_charset(void) static const char *locale_charset(void)

View File

@ -20,14 +20,7 @@
#include "compat.h" #include "compat.h"
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <shellapi.h>
typedef struct
{
int newmode;
} _startupinfo;
extern
int __wgetmainargs(int *, wchar_t ***, wchar_t ***, int, _startupinfo *);
int64_t aacenc_timer(void) int64_t aacenc_timer(void)
{ {
@ -41,6 +34,11 @@ int64_t aacenc_timer(void)
return (int64_t)tv.time * 1000 + tv.millitm; return (int64_t)tv.time * 1000 + tv.millitm;
} }
int aacenc_seekable(FILE *fp)
{
return GetFileType((HANDLE)_get_osfhandle(_fileno(fp))) == FILE_TYPE_DISK;
}
static static
int codepage_decode_wchar(int codepage, const char *from, wchar_t **to) int codepage_decode_wchar(int codepage, const char *from, wchar_t **to)
{ {
@ -98,13 +96,13 @@ void aacenc_free_mainargs(void)
void aacenc_getmainargs(int *argc, char ***argv) void aacenc_getmainargs(int *argc, char ***argv)
{ {
int i; int i;
wchar_t **wargv, **envp; wchar_t **wargv;
_startupinfo si = { 0 };
__wgetmainargs(argc, &wargv, &envp, 1, &si); wargv = CommandLineToArgvW(GetCommandLineW(), argc);
*argv = malloc((*argc + 1) * sizeof(char*)); *argv = malloc((*argc + 1) * sizeof(char*));
for (i = 0; i < *argc; ++i) for (i = 0; i < *argc; ++i)
codepage_encode_wchar(CP_UTF8, wargv[i], &(*argv)[i]); codepage_encode_wchar(CP_UTF8, wargv[i], &(*argv)[i]);
LocalFree(wargv);
(*argv)[*argc] = 0; (*argv)[*argc] = 0;
__aacenc_argv__ = *argv; __aacenc_argv__ = *argv;
atexit(aacenc_free_mainargs); atexit(aacenc_free_mainargs);

View File

@ -86,11 +86,11 @@ static int fetch(extrapolater_t *self, unsigned nframes)
if (realloc_buffer(bp, nframes * sfmt->bytes_per_frame) == 0) { if (realloc_buffer(bp, nframes * sfmt->bytes_per_frame) == 0) {
rc = pcm_read_frames(self->src, bp->data, nframes); rc = pcm_read_frames(self->src, bp->data, nframes);
bp->count = rc > 0 ? rc : 0; if (rc > 0) bp->count = rc;
} }
if (rc > 0) if (rc > 0)
self->nbuffer ^= 1; self->nbuffer ^= 1;
return bp->count; return rc <= 0 ? 0 : bp->count;
} }
static int extrapolate(extrapolater_t *self, const buffer_t *bp, 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(buffer, nframes, nchannels);
reverse_buffer(bp->data, bp->count, 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; return nframes;
} }
@ -137,8 +143,32 @@ static int process1(extrapolater_t *self, void *buffer, unsigned nframes)
assert(bp->count <= nframes); assert(bp->count <= nframes);
memcpy(buffer, bp->data, bp->count * sfmt->bytes_per_frame); memcpy(buffer, bp->data, bp->count * sfmt->bytes_per_frame);
if (!fetch(self, nframes)) if (!fetch(self, nframes)) {
// got EOF
buffer_t *bbp = &self->buffer[self->nbuffer];
if (bp->count < 2 * LPC_ORDER) {
// final frame is too short, so we join with the pre-final frame
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 + bp->count * sfmt->channels_per_frame,
bbp->count * sfmt->bytes_per_frame);
bp->count = bbp->count;
}
}
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; self->process = process2;
}
return bp->count; return bp->count;
} }
@ -146,27 +176,15 @@ static int process2(extrapolater_t *self, void *buffer, unsigned nframes)
{ {
const pcm_sample_description_t *sfmt = pcm_get_format(self->src); const pcm_sample_description_t *sfmt = pcm_get_format(self->src);
buffer_t *bp = &self->buffer[self->nbuffer]; buffer_t *bp = &self->buffer[self->nbuffer];
buffer_t *bbp = &self->buffer[self->nbuffer ^ 1]; if (bp->count < nframes)
nframes = bp->count;
if (bp->count < 2 * LPC_ORDER) { memcpy(buffer, bp->data, nframes * sfmt->bytes_per_frame);
size_t total = bp->count + bbp->count; if (bp->count > nframes)
if (bbp->count && memmove(bp->data, bp->data + nframes * sfmt->channels_per_frame,
realloc_buffer(bbp, total * sfmt->bytes_per_frame) == 0) (bp->count - nframes) * sfmt->bytes_per_frame);
{ bp->count -= nframes;
memcpy(bbp->data + bbp->count * sfmt->channels_per_frame, if (bp->count == 0)
bp->data, bp->count * sfmt->bytes_per_frame); self->process = process3;
bbp->count = total;
bp->count = 0;
bp = bbp;
self->nbuffer ^= 1;
}
}
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; return nframes;
} }

186
src/limiter.c Normal file
View 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;
}

View File

@ -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;
}

View File

@ -61,7 +61,4 @@ inline double pcm_clip(double n, double min_value, double max_value)
return n; return n;
} }
int pcm_convert_to_native_sint16(const pcm_sample_description_t *format,
const void *input, uint32_t nframes,
int16_t *result);
#endif #endif

View File

@ -39,9 +39,18 @@ typedef struct m4af_chunk_entry_t {
uint32_t duration; uint32_t duration;
} m4af_chunk_entry_t; } m4af_chunk_entry_t;
typedef struct m4af_itmf_entry_t {
uint32_t fcc;
char *name;
uint32_t type_code;
char *data;
uint32_t data_size;
} m4af_itmf_entry_t;
typedef struct m4af_track_t { typedef struct m4af_track_t {
uint32_t codec; uint32_t codec;
uint32_t timescale; uint32_t timescale;
uint16_t num_channels;
int64_t creation_time; int64_t creation_time;
int64_t modification_time; int64_t modification_time;
int64_t duration; int64_t duration;
@ -102,12 +111,37 @@ typedef struct m4af_box_parser_t {
int (*handler)(m4af_ctx_t *ctx, uint32_t name, uint64_t size); int (*handler)(m4af_ctx_t *ctx, uint32_t name, uint64_t size);
} m4af_box_parser_t; } m4af_box_parser_t;
static
int m4af_write_null_cb(void *cookie, const void *data, uint32_t size)
{
int64_t *pos = cookie;
*pos += size;
return 0;
}
static
int m4af_seek_null_cb(void *cookie, int64_t off, int whence)
{
int64_t *pos = cookie;
*pos = off; /* XXX: we use only SEEK_SET */
return 0;
}
static
int64_t m4af_tell_null_cb(void *cookie)
{
return *((int64_t*)cookie);
}
static m4af_io_callbacks_t m4af_null_io_callbacks = {
0, m4af_write_null_cb, m4af_seek_null_cb, m4af_tell_null_cb
};
static static
int64_t m4af_timestamp(void) int64_t m4af_timestamp(void)
{ {
return (int64_t)(time(0)) + (((1970 - 1904) * 365) + 17) * 24 * 60 * 60; return (int64_t)(time(0)) + (((1970 - 1904) * 365) + 17) * 24 * 60 * 60;
} }
/* /*
* http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 * http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
*/ */
@ -189,7 +223,7 @@ void m4af_write32_at(m4af_ctx_t *ctx, int64_t pos, uint32_t value)
} }
m4af_ctx_t *m4af_create(uint32_t codec, uint32_t timescale, m4af_ctx_t *m4af_create(uint32_t codec, uint32_t timescale,
m4af_io_callbacks_t *io, void *io_cookie) m4af_io_callbacks_t *io, void *io_cookie, int no_timestamp)
{ {
m4af_ctx_t *ctx; m4af_ctx_t *ctx;
int64_t timestamp; int64_t timestamp;
@ -203,7 +237,7 @@ m4af_ctx_t *m4af_create(uint32_t codec, uint32_t timescale,
memcpy(&ctx->io, io, sizeof(m4af_io_callbacks_t)); memcpy(&ctx->io, io, sizeof(m4af_io_callbacks_t));
ctx->io_cookie = io_cookie; ctx->io_cookie = io_cookie;
ctx->timescale = timescale; ctx->timescale = timescale;
timestamp = m4af_timestamp(); timestamp = no_timestamp ? 0 : m4af_timestamp();
ctx->creation_time = timestamp; ctx->creation_time = timestamp;
ctx->modification_time = timestamp; ctx->modification_time = timestamp;
ctx->num_tracks = 1; ctx->num_tracks = 1;
@ -211,6 +245,7 @@ m4af_ctx_t *m4af_create(uint32_t codec, uint32_t timescale,
ctx->track[0].timescale = timescale; ctx->track[0].timescale = timescale;
ctx->track[0].creation_time = timestamp; ctx->track[0].creation_time = timestamp;
ctx->track[0].modification_time = timestamp; ctx->track[0].modification_time = timestamp;
ctx->track[0].num_channels = 2;
return ctx; return ctx;
} }
@ -254,6 +289,12 @@ void m4af_teardown(m4af_ctx_t **ctxp)
*ctxp = 0; *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, void m4af_set_fixed_frame_duration(m4af_ctx_t *ctx, uint32_t track_idx,
uint32_t length) uint32_t length)
{ {
@ -656,7 +697,7 @@ void m4af_write_stco_box(m4af_ctx_t *ctx, uint32_t track_idx)
m4af_track_t *track = &ctx->track[track_idx]; m4af_track_t *track = &ctx->track[track_idx];
uint32_t i; uint32_t i;
m4af_chunk_entry_t *index = track->chunk_table; m4af_chunk_entry_t *index = track->chunk_table;
int is_co64 = (ctx->mdat_pos + ctx->mdat_size > UINT32_MAX); int is_co64 = index[track->num_chunks - 1].offset > 0xffffffff;
int64_t pos = m4af_tell(ctx); int64_t pos = m4af_tell(ctx);
m4af_write32(ctx, 0); /* size */ m4af_write32(ctx, 0); /* size */
@ -816,11 +857,13 @@ void m4af_write_mp4a_box(m4af_ctx_t *ctx, uint32_t track_idx)
"\0\001" /* data_reference_index: 1 */ "\0\001" /* data_reference_index: 1 */
"\0\0\0\0" /* reserved[0] */ "\0\0\0\0" /* reserved[0] */
"\0\0\0\0" /* reserved[1] */ "\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\020" /* samplesize: 16 */
"\0\0" /* pre_defined */ "\0\0" /* pre_defined */
"\0\0" /* reserved */ "\0\0" /* reserved */
,24); ,6);
if (track->codec == M4AF_FOURCC('m','p','4','a')) { if (track->codec == M4AF_FOURCC('m','p','4','a')) {
m4af_write32(ctx, track->timescale << 16); m4af_write32(ctx, track->timescale << 16);
m4af_write_esds_box(ctx, track_idx); m4af_write_esds_box(ctx, track_idx);
@ -1002,7 +1045,7 @@ void m4af_write_hdlr_box(m4af_ctx_t *ctx, uint32_t track_idx, const char *type)
/* reserved[0] */ /* reserved[0] */
m4af_write(ctx, !strcmp(type, "mdir") ? "appl" : "\0\0\0\0", 4); m4af_write(ctx, !strcmp(type, "mdir") ? "appl" : "\0\0\0\0", 4);
/* reserved[1], reserved[2], name */ /* reserved[1], reserved[2], name */
m4af_write(ctx, reserved_and_name, (pos & 1) ? 9 : 10); m4af_write(ctx, reserved_and_name, 9);
m4af_update_box_size(ctx, pos); m4af_update_box_size(ctx, pos);
} }
@ -1060,8 +1103,10 @@ void m4af_write_tkhd_box(m4af_ctx_t *ctx, uint32_t track_idx)
{ {
m4af_track_t *track = &ctx->track[track_idx]; m4af_track_t *track = &ctx->track[track_idx];
int64_t pos = m4af_tell(ctx); int64_t pos = m4af_tell(ctx);
int64_t duration = int64_t duration = track->duration;
(double)track->duration / track->timescale * ctx->timescale + .5; if (ctx->priming_mode & M4AF_PRIMING_MODE_EDTS)
duration -= (track->encoder_delay + track->padding);
duration = (double)duration / track->timescale * ctx->timescale + .5;
uint8_t version = (track->creation_time > UINT32_MAX || uint8_t version = (track->creation_time > UINT32_MAX ||
track->modification_time > UINT32_MAX || track->modification_time > UINT32_MAX ||
duration > UINT32_MAX); duration > UINT32_MAX);
@ -1126,6 +1171,8 @@ int64_t m4af_movie_duration(m4af_ctx_t *ctx)
unsigned i; unsigned i;
for (i = 0; i < ctx->num_tracks; ++i) { for (i = 0; i < ctx->num_tracks; ++i) {
double x = ctx->track[i].duration; double x = ctx->track[i].duration;
if (ctx->priming_mode & M4AF_PRIMING_MODE_EDTS)
x -= (ctx->track[i].encoder_delay + ctx->track[i].padding);
int64_t duration = x / ctx->track[i].timescale * ctx->timescale + .5; int64_t duration = x / ctx->track[i].timescale * ctx->timescale + .5;
if (duration > movie_duration) if (duration > movie_duration)
movie_duration = duration; movie_duration = duration;
@ -1307,28 +1354,58 @@ void m4af_finalize_mdat(m4af_ctx_t *ctx)
m4af_set_pos(ctx, ctx->mdat_pos + ctx->mdat_size); m4af_set_pos(ctx, ctx->mdat_pos + ctx->mdat_size);
} }
static
uint64_t m4af_patch_moov(m4af_ctx_t *ctx, uint32_t moov_size, uint32_t offset)
{
int64_t pos = 0;
uint32_t moov_size2;
int i, j;
m4af_io_callbacks_t io_reserve = ctx->io;
void *io_cookie_reserve = ctx->io_cookie;
for (i = 0; i < ctx->num_tracks; ++i)
for (j = 0; j < ctx->track[i].num_chunks; ++j)
ctx->track[i].chunk_table[j].offset += offset;
ctx->io = m4af_null_io_callbacks;
ctx->io_cookie = &pos;
moov_size2 = m4af_write_moov_box(ctx);
if (moov_size2 != moov_size) {
/* stco -> co64 switching */
for (i = 0; i < ctx->num_tracks; ++i)
for (j = 0; j < ctx->track[i].num_chunks; ++j)
ctx->track[i].chunk_table[j].offset += moov_size2 - moov_size;
moov_size2 = m4af_write_moov_box(ctx);
}
ctx->io = io_reserve;
ctx->io_cookie = io_cookie_reserve;
return moov_size2;
}
static static
void m4af_shift_mdat_pos(m4af_ctx_t *ctx, uint32_t offset) void m4af_shift_mdat_pos(m4af_ctx_t *ctx, uint32_t offset)
{ {
unsigned i, j;
int64_t begin, end; int64_t begin, end;
char buf[8192]; char *buf;
buf = malloc(1024*1024*2);
end = ctx->mdat_pos + ctx->mdat_size; end = ctx->mdat_pos + ctx->mdat_size;
for (; (begin = m4af_max(ctx->mdat_pos, end - 8192)) < end; end = begin) { for (; (begin = m4af_max(ctx->mdat_pos, end - 1024*1024*2)) < end;
end = begin) {
m4af_set_pos(ctx, begin); m4af_set_pos(ctx, begin);
ctx->io.read(ctx->io_cookie, buf, end - begin); ctx->io.read(ctx->io_cookie, buf, end - begin);
m4af_set_pos(ctx, begin + offset); m4af_set_pos(ctx, begin + offset);
m4af_write(ctx, buf, end - begin); m4af_write(ctx, buf, end - begin);
} }
for (i = 0; i < ctx->num_tracks; ++i)
for (j = 0; j < ctx->track[i].num_chunks; ++j)
ctx->track[i].chunk_table[j].offset += offset;
ctx->mdat_pos += offset; ctx->mdat_pos += offset;
m4af_set_pos(ctx, ctx->mdat_pos - 16); m4af_set_pos(ctx, ctx->mdat_pos - 16);
m4af_write_free_box(ctx, 0); m4af_write_free_box(ctx, 0);
m4af_write(ctx, "\0\0\0\0mdat", 8); m4af_write(ctx, "\0\0\0\0mdat", 8);
m4af_finalize_mdat(ctx); m4af_finalize_mdat(ctx);
free(buf);
} }
int m4af_finalize(m4af_ctx_t *ctx, int optimize) int m4af_finalize(m4af_ctx_t *ctx, int optimize)
@ -1357,7 +1434,8 @@ int m4af_finalize(m4af_ctx_t *ctx, int optimize)
moov_size = m4af_write_moov_box(ctx); moov_size = m4af_write_moov_box(ctx);
if (optimize) { if (optimize) {
int64_t pos; int64_t pos;
m4af_shift_mdat_pos(ctx, moov_size + 1024); uint32_t moov_size2 = m4af_patch_moov(ctx, moov_size, moov_size + 1024);
m4af_shift_mdat_pos(ctx, moov_size2 + 1024);
m4af_set_pos(ctx, 32); m4af_set_pos(ctx, 32);
m4af_write_moov_box(ctx); m4af_write_moov_box(ctx);
pos = m4af_tell(ctx); pos = m4af_tell(ctx);

View File

@ -71,19 +71,11 @@ typedef struct m4af_io_callbacks_t {
m4af_tell_callback tell; m4af_tell_callback tell;
} m4af_io_callbacks_t; } m4af_io_callbacks_t;
typedef struct m4af_itmf_entry_t {
uint32_t fcc;
char *name;
uint32_t type_code;
char *data;
uint32_t data_size;
} m4af_itmf_entry_t;
typedef struct m4af_ctx_t m4af_ctx_t; typedef struct m4af_ctx_t m4af_ctx_t;
m4af_ctx_t *m4af_create(uint32_t codec, uint32_t timescale, m4af_ctx_t *m4af_create(uint32_t codec, uint32_t timescale,
m4af_io_callbacks_t *io, void *io_cookie); m4af_io_callbacks_t *io, void *io_cookie, int no_timestamp);
int m4af_begin_write(m4af_ctx_t *ctx); int m4af_begin_write(m4af_ctx_t *ctx);
@ -104,6 +96,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_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, void m4af_set_fixed_frame_duration(m4af_ctx_t *ctx, uint32_t track_idx,
uint32_t length); uint32_t length);

View File

@ -33,8 +33,7 @@
#include <windows.h> #include <windows.h>
#endif #endif
#include "compat.h" #include "compat.h"
#include "wav_reader.h" #include "pcm_reader.h"
#include "caf_reader.h"
#include "aacenc.h" #include "aacenc.h"
#include "m4af.h" #include "m4af.h"
#include "progress.h" #include "progress.h"
@ -118,17 +117,13 @@ PROGNAME " %s\n"
" 29: MPEG-4 HE-AAC v2 (SBR+PS)\n" " 29: MPEG-4 HE-AAC v2 (SBR+PS)\n"
" 23: MPEG-4 AAC LD\n" " 23: MPEG-4 AAC LD\n"
" 39: MPEG-4 AAC ELD\n" " 39: MPEG-4 AAC ELD\n"
" 129: MPEG-2 AAC LC\n"
" 132: MPEG-2 HE-AAC (SBR)\n"
" 156: MPEG-2 HE-AAC v2 (SBR+PS)\n"
" -b, --bitrate <n> Bitrate in bits per seconds (for CBR)\n" " -b, --bitrate <n> Bitrate in bits per seconds (for CBR)\n"
" -m, --bitrate-mode <n> Bitrate configuration\n" " -m, --bitrate-mode <n> Bitrate configuration\n"
" 0: CBR (default)\n" " 0: CBR (default)\n"
" 1-5: VBR\n" " 1-5: VBR\n"
" (VBR mode is not officially supported, and\n" " (VBR mode 1 is tuned for HE-AAC v2\n"
" works only on a certain combination of\n" " VBR mode 2 is tuned for HE-AAC\n"
" parameter settings, sample rate, and\n" " VBR mode 3 or greater is for AAC LC)\n"
" channel configuration)\n"
" -w, --bandwidth <n> Frequency bandwidth in Hz (AAC LC only)\n" " -w, --bandwidth <n> Frequency bandwidth in Hz (AAC LC only)\n"
" -a, --afterburner <n> Afterburner\n" " -a, --afterburner <n> Afterburner\n"
" 0: Off\n" " 0: Off\n"
@ -163,6 +158,7 @@ PROGNAME " %s\n"
" -I, --ignorelength Ignore length of WAV header\n" " -I, --ignorelength Ignore length of WAV header\n"
" -S, --silent Don't print progress messages\n" " -S, --silent Don't print progress messages\n"
" --moov-before-mdat Place moov box before mdat box on m4a output\n" " --moov-before-mdat Place moov box before mdat box on m4a output\n"
" --no-timestamp Don't inject timestamp in the file\n"
"\n" "\n"
"Options for raw (headerless) input:\n" "Options for raw (headerless) input:\n"
" -R, --raw Treat input as raw (by default WAV is\n" " -R, --raw Treat input as raw (by default WAV is\n"
@ -225,6 +221,8 @@ typedef struct aacenc_param_ex_t {
unsigned raw_rate; unsigned raw_rate;
const char *raw_format; const char *raw_format;
int no_timestamp;
aacenc_tag_store_t tags; aacenc_tag_store_t tags;
aacenc_tag_store_t source_tags; aacenc_tag_store_t source_tags;
aacenc_translate_generic_text_tag_ctx_t source_tag_ctx; aacenc_translate_generic_text_tag_ctx_t source_tag_ctx;
@ -248,7 +246,7 @@ int parse_options(int argc, char **argv, aacenc_param_ex_t *params)
#define OPT_LONG_TAG M4AF_FOURCC('l','t','a','g') #define OPT_LONG_TAG M4AF_FOURCC('l','t','a','g')
#define OPT_TAG_FROM_JSON M4AF_FOURCC('t','f','j','s') #define OPT_TAG_FROM_JSON M4AF_FOURCC('t','f','j','s')
static struct option long_options[] = { static const struct option long_options[] = {
{ "help", no_argument, 0, 'h' }, { "help", no_argument, 0, 'h' },
{ "profile", required_argument, 0, 'p' }, { "profile", required_argument, 0, 'p' },
{ "bitrate", required_argument, 0, 'b' }, { "bitrate", required_argument, 0, 'b' },
@ -288,12 +286,14 @@ int parse_options(int argc, char **argv, aacenc_param_ex_t *params)
{ "tag-from-file", required_argument, 0, OPT_SHORT_TAG_FILE }, { "tag-from-file", required_argument, 0, OPT_SHORT_TAG_FILE },
{ "long-tag", required_argument, 0, OPT_LONG_TAG }, { "long-tag", required_argument, 0, OPT_LONG_TAG },
{ "tag-from-json", required_argument, 0, OPT_TAG_FROM_JSON }, { "tag-from-json", required_argument, 0, OPT_TAG_FROM_JSON },
{ "no-timestamp", no_argument, 0, '#' },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 },
}; };
params->afterburner = 1; params->afterburner = 1;
aacenc_getmainargs(&argc, &argv); aacenc_getmainargs(&argc, &argv);
while ((ch = getopt_long(argc, argv, "hp:b:m:w:a:Ls:f:CP:G:Io:SR", while ((ch = getopt_long(argc, argv, "hp:b:m:w:a:L:s:f:CP:G:Io:SR",
long_options, 0)) != EOF) { long_options, 0)) != EOF) {
switch (ch) { switch (ch) {
case 'h': case 'h':
@ -460,6 +460,9 @@ int parse_options(int argc, char **argv, aacenc_param_ex_t *params)
case OPT_TAG_FROM_JSON: case OPT_TAG_FROM_JSON:
params->json_filename = optarg; params->json_filename = optarg;
break; break;
case '#':
params->no_timestamp = 1;
break;
default: default:
return usage(), -1; return usage(), -1;
} }
@ -507,12 +510,17 @@ int write_sample(FILE *ofp, m4af_ctx_t *m4af, aacenc_frame_t *frame)
return 0; return 0;
} }
static int do_smart_padding(int profile)
{
return profile == 2 || profile == 5 || profile == 29;
}
static static
int encode(aacenc_param_ex_t *params, pcm_reader_t *reader, int encode(aacenc_param_ex_t *params, pcm_reader_t *reader,
HANDLE_AACENCODER encoder, uint32_t frame_length, HANDLE_AACENCODER encoder, uint32_t frame_length,
m4af_ctx_t *m4af) m4af_ctx_t *m4af)
{ {
int16_t *ibuf = 0, *ip; INT_PCM *ibuf = 0, *ip;
aacenc_frame_t obuf[2] = {{ 0 }}, *obp; aacenc_frame_t obuf[2] = {{ 0 }}, *obp;
unsigned flip = 0; unsigned flip = 0;
int nread = 1; int nread = 1;
@ -521,15 +529,12 @@ int encode(aacenc_param_ex_t *params, pcm_reader_t *reader,
int frames_written = 0, encoded = 0; int frames_written = 0, encoded = 0;
aacenc_progress_t progress = { 0 }; aacenc_progress_t progress = { 0 };
const pcm_sample_description_t *fmt = pcm_get_format(reader); const pcm_sample_description_t *fmt = pcm_get_format(reader);
const int is_padding = do_smart_padding(params->profile);
ibuf = malloc(frame_length * fmt->bytes_per_frame); ibuf = malloc(frame_length * fmt->bytes_per_frame);
aacenc_progress_init(&progress, pcm_get_length(reader), fmt->sample_rate); aacenc_progress_init(&progress, pcm_get_length(reader), fmt->sample_rate);
for (;;) { for (;;) {
/*
* Since we delay the write, we cannot just exit loop when interrupted.
* Instead, we regard it as EOF.
*/
if (g_interrupted) if (g_interrupted)
nread = 0; nread = 0;
if (nread > 0) { if (nread > 0) {
@ -552,7 +557,7 @@ int encode(aacenc_param_ex_t *params, pcm_reader_t *reader,
remaining -= consumed; remaining -= consumed;
ip += consumed * fmt->channels_per_frame; ip += consumed * fmt->channels_per_frame;
flip ^= 1; if (is_padding) {
/* /*
* As we pad 1 frame at beginning and ending by our extrapolator, * As we pad 1 frame at beginning and ending by our extrapolator,
* we want to drop them. * we want to drop them.
@ -561,16 +566,26 @@ int encode(aacenc_param_ex_t *params, pcm_reader_t *reader,
* Since sbr_header is included in the first frame (in case of * Since sbr_header is included in the first frame (in case of
* SBR), we cannot discard first frame. So we pick second instead. * SBR), we cannot discard first frame. So we pick second instead.
*/ */
++encoded; flip ^= 1;
if (encoded == 1 || encoded == 3) ++encoded;
continue; if (encoded == 1 || encoded == 3)
obp = &obuf[flip]; continue;
if (write_sample(params->output_fp, m4af, obp) < 0) }
if (write_sample(params->output_fp, m4af, &obuf[flip]) < 0)
goto END; goto END;
++frames_written; ++frames_written;
} while (remaining > 0); } while (remaining > 0);
} }
DONE: DONE:
/*
* When interrupted, we haven't pulled out last extrapolated frames
* from the reader. Therefore, we have to write the final outcome.
*/
if (g_interrupted) {
if (write_sample(params->output_fp, m4af, &obp[flip^1]) < 0)
goto END;
++frames_written;
}
if (!params->silent) if (!params->silent)
aacenc_progress_finish(&progress, pcm_get_position(reader)); aacenc_progress_finish(&progress, pcm_get_position(reader));
rc = frames_written; rc = frames_written;
@ -694,16 +709,14 @@ pcm_reader_t *open_input(aacenc_param_ex_t *params)
{ {
pcm_io_context_t io = { 0 }; pcm_io_context_t io = { 0 };
pcm_reader_t *reader = 0; pcm_reader_t *reader = 0;
struct stat stb = { 0 };
if ((params->input_fp = aacenc_fopen(params->input_filename, "rb")) == 0) { if ((params->input_fp = aacenc_fopen(params->input_filename, "rb")) == 0) {
aacenc_fprintf(stderr, "ERROR: %s: %s\n", params->input_filename, aacenc_fprintf(stderr, "ERROR: %s: %s\n", params->input_filename,
strerror(errno)); strerror(errno));
goto END; goto FAIL;
} }
io.cookie = params->input_fp; io.cookie = params->input_fp;
if (fstat(fileno(params->input_fp), &stb) == 0 if (aacenc_seekable(params->input_fp))
&& (stb.st_mode & S_IFMT) == S_IFREG)
io.vtbl = &pcm_io_vtbl; io.vtbl = &pcm_io_vtbl;
else else
io.vtbl = &pcm_io_vtbl_noseek; io.vtbl = &pcm_io_vtbl_noseek;
@ -713,7 +726,7 @@ pcm_reader_t *open_input(aacenc_param_ex_t *params)
pcm_sample_description_t desc = { 0 }; pcm_sample_description_t desc = { 0 };
if (parse_raw_spec(params->raw_format, &desc) < 0) { if (parse_raw_spec(params->raw_format, &desc) < 0) {
fprintf(stderr, "ERROR: invalid raw-format spec\n"); fprintf(stderr, "ERROR: invalid raw-format spec\n");
goto END; goto FAIL;
} }
desc.sample_rate = params->raw_rate; desc.sample_rate = params->raw_rate;
desc.channels_per_frame = params->raw_channels; desc.channels_per_frame = params->raw_channels;
@ -721,7 +734,7 @@ pcm_reader_t *open_input(aacenc_param_ex_t *params)
desc.bytes_per_frame = params->raw_channels * bytes_per_channel; desc.bytes_per_frame = params->raw_channels * bytes_per_channel;
if ((reader = raw_open(&io, &desc)) == 0) { if ((reader = raw_open(&io, &desc)) == 0) {
fprintf(stderr, "ERROR: failed to open raw input\n"); fprintf(stderr, "ERROR: failed to open raw input\n");
goto END; goto FAIL;
} }
} else { } else {
int c; int c;
@ -731,7 +744,7 @@ pcm_reader_t *open_input(aacenc_param_ex_t *params)
case 'R': case 'R':
if ((reader = wav_open(&io, params->ignore_length)) == 0) { if ((reader = wav_open(&io, params->ignore_length)) == 0) {
fprintf(stderr, "ERROR: broken / unsupported input file\n"); fprintf(stderr, "ERROR: broken / unsupported input file\n");
goto END; goto FAIL;
} }
break; break;
case 'c': case 'c':
@ -741,18 +754,23 @@ pcm_reader_t *open_input(aacenc_param_ex_t *params)
aacenc_translate_generic_text_tag, aacenc_translate_generic_text_tag,
&params->source_tag_ctx)) == 0) { &params->source_tag_ctx)) == 0) {
fprintf(stderr, "ERROR: broken / unsupported input file\n"); fprintf(stderr, "ERROR: broken / unsupported input file\n");
goto END; goto FAIL;
} }
break; break;
default: default:
fprintf(stderr, "ERROR: unsupported input file\n"); 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);
reader = extrapolater_open(reader); if (reader && PCM_IS_FLOAT(pcm_get_format(reader)))
reader = limiter_open(reader);
if (reader && (reader = pcm_open_sint16_converter(reader)) != 0) {
if (do_smart_padding(params->profile))
reader = extrapolater_open(reader);
}
return reader; return reader;
END: FAIL:
return 0; return 0;
} }
@ -792,12 +810,14 @@ int main(int argc, char **argv)
params.sbr_ratio = 2; params.sbr_ratio = 2;
} }
scale_shift = aacenc_is_dual_rate_sbr((aacenc_param_t*)&params); scale_shift = aacenc_is_dual_rate_sbr((aacenc_param_t*)&params);
params.sbr_signaling = params.sbr_signaling = 0;
(params.transport_format == TT_MP4_LOAS) ? 2 : if (sbr_mode) {
(params.transport_format == TT_MP4_RAW) ? 1 : 0; if (params.transport_format == TT_MP4_LOAS || !scale_shift)
if (sbr_mode && !scale_shift) params.sbr_signaling = 2;
params.sbr_signaling = 2; if (params.transport_format == TT_MP4_RAW &&
aacenc_is_explicit_bw_compatible_sbr_signaling_available())
params.sbr_signaling = 1;
}
if (aacenc_init(&encoder, (aacenc_param_t*)&params, sample_format, if (aacenc_init(&encoder, (aacenc_param_t*)&params, sample_format,
&aacinfo) < 0) &aacinfo) < 0)
goto END; goto END;
@ -820,39 +840,40 @@ int main(int argc, char **argv)
unsigned framelen = aacinfo.frameLength; unsigned framelen = aacinfo.frameLength;
scale = sample_format->sample_rate >> scale_shift; scale = sample_format->sample_rate >> scale_shift;
if ((m4af = m4af_create(M4AF_CODEC_MP4A, scale, &m4af_io, if ((m4af = m4af_create(M4AF_CODEC_MP4A, scale, &m4af_io,
params.output_fp)) < 0) params.output_fp, params.no_timestamp)) < 0)
goto END; goto END;
m4af_set_decoder_specific_info(m4af, 0, m4af_set_num_channels(m4af, 0, sample_format->channels_per_frame);
aacinfo.confBuf, aacinfo.confSize); m4af_set_fixed_frame_duration(m4af, 0, framelen >> scale_shift);
m4af_set_fixed_frame_duration(m4af, 0, if (aacenc_is_explicit_bw_compatible_sbr_signaling_available())
framelen >> scale_shift); m4af_set_decoder_specific_info(m4af, 0,
aacinfo.confBuf, aacinfo.confSize);
else {
uint8_t mp4asc[32];
uint32_t ascsize = sizeof(mp4asc);
aacenc_mp4asc((aacenc_param_t*)&params, aacinfo.confBuf,
aacinfo.confSize, mp4asc, &ascsize);
m4af_set_decoder_specific_info(m4af, 0, mp4asc, ascsize);
}
m4af_set_vbr_mode(m4af, 0, params.bitrate_mode); m4af_set_vbr_mode(m4af, 0, params.bitrate_mode);
m4af_set_priming_mode(m4af, params.gapless_mode + 1); m4af_set_priming_mode(m4af, params.gapless_mode + 1);
m4af_begin_write(m4af); m4af_begin_write(m4af);
} }
if (scale_shift && (aacinfo.encoderDelay & 1)) {
/*
* Since odd delay cannot be exactly expressed in downsampled scale,
* we push one zero frame to the encoder here, to make delay even
*/
int16_t zero[8] = { 0 };
aacenc_frame_t frame = { 0 };
aac_encode_frame(encoder, sample_format, zero, 1, &frame);
free(frame.data);
}
frame_count = encode(&params, reader, encoder, aacinfo.frameLength, m4af); frame_count = encode(&params, reader, encoder, aacinfo.frameLength, m4af);
if (frame_count < 0) if (frame_count < 0)
goto END; goto END;
if (m4af) { if (m4af) {
uint32_t delay = aacinfo.encoderDelay;
uint32_t padding; uint32_t padding;
#if AACENCODER_LIB_VL0 < 4
uint32_t delay = aacinfo.encoderDelay;
if (sbr_mode && params.profile != AOT_ER_AAC_ELD
&& !params.include_sbr_delay)
delay -= 481 << scale_shift;
#else
uint32_t delay = params.include_sbr_delay ? aacinfo.nDelay
: aacinfo.nDelayCore;
#endif
int64_t frames_read = pcm_get_position(reader); int64_t frames_read = pcm_get_position(reader);
if (sbr_mode && params.profile != AOT_ER_AAC_ELD &&
!params.include_sbr_delay)
delay -= 481 << scale_shift;
if (scale_shift && (delay & 1))
++delay;
padding = frame_count * aacinfo.frameLength - frames_read - delay; padding = frame_count * aacinfo.frameLength - frames_read - delay;
m4af_set_priming(m4af, 0, delay >> scale_shift, padding >> scale_shift); m4af_set_priming(m4af, 0, delay >> scale_shift, padding >> scale_shift);
if (finalize_m4a(m4af, &params, encoder) < 0) if (finalize_m4a(m4af, &params, encoder) < 0)

84
src/pcm_float_converter.c Normal file
View File

@ -0,0 +1,84 @@
/*
* 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)
{
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
View 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;
}

View File

@ -6,6 +6,7 @@
#define PCM_READER_H #define PCM_READER_H
#include "lpcm.h" #include "lpcm.h"
#include "metadata.h"
typedef struct pcm_reader_t pcm_reader_t; 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); return r->vtbl->get_position(r);
} }
static inline int pcm_read_frames(pcm_reader_t *r, void *data, unsigned nframes);
int64_t pcm_read_frames(pcm_reader_t *r, void *data, unsigned nframes)
{
return r->vtbl->read_frames(r, data, nframes);
}
static inline static inline
void pcm_teardown(pcm_reader_t **r) 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, int apple_chan_chunk(pcm_io_context_t *io, uint32_t chunk_size,
pcm_sample_description_t *fmt, uint8_t *mapping); 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 *pcm_open_sint16_converter(pcm_reader_t *reader);
pcm_reader_t *extrapolater_open(pcm_reader_t *reader); pcm_reader_t *extrapolater_open(pcm_reader_t *reader);
pcm_reader_t *limiter_open(pcm_reader_t *reader);
#endif #endif

View File

@ -19,15 +19,35 @@
#include "m4af_endian.h" #include "m4af_endian.h"
#include "catypes.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 pcm_read(pcm_io_context_t *io, void *buffer, uint32_t size)
{ {
int rc; int rc;
uint32_t count = 0; uint32_t count = 0;
uint8_t *bp = buffer;
do { do {
rc = io->vtbl->read(io->cookie, buffer, size - count); rc = io->vtbl->read(io->cookie, bp, size - count);
if (rc > 0) if (rc > 0) {
count += rc; count += rc;
bp += rc;
}
} while (rc > 0 && count < size); } while (rc > 0 && count < size);
return count > 0 ? count : rc; return count > 0 ? count : rc;
} }
@ -40,6 +60,8 @@ int pcm_skip(pcm_io_context_t *io, int64_t count)
if (count == 0 || pcm_seek(io, count, SEEK_CUR) >= 0) if (count == 0 || pcm_seek(io, count, SEEK_CUR) >= 0)
return 0; return 0;
if (count < 0)
return -1;
do { do {
if ((rc = vp->read(io->cookie, buff, count > 8192 ? 8192 : count)) > 0) if ((rc = vp->read(io->cookie, buff, count > 8192 ? 8192 : count)) > 0)
count -= rc; count -= rc;
@ -273,6 +295,10 @@ int apple_chan_chunk(pcm_io_context_t *io, uint32_t chunk_size,
layout = "\x03\x01\x02\x09"; break; layout = "\x03\x01\x02\x09"; break;
case kAudioChannelLayoutTag_AC3_3_1: case kAudioChannelLayoutTag_AC3_3_1:
layout = "\x01\x03\x02\x09"; break; layout = "\x01\x03\x02\x09"; break;
case kAudioChannelLayoutTag_WAVE_4_0_B:
layout = "\x01\x02\x05\x06"; break;
case kAudioChannelLayoutTag_Logic_4_0_C:
layout = "\x01\x02\x09\x03"; break;
/* 4.1ch */ /* 4.1ch */
case kAudioChannelLayoutTag_DVD_6: case kAudioChannelLayoutTag_DVD_6:
layout = "\x01\x02\x04\x0A\x0B"; break; layout = "\x01\x02\x04\x0A\x0B"; break;
@ -282,6 +308,8 @@ int apple_chan_chunk(pcm_io_context_t *io, uint32_t chunk_size,
layout = "\x01\x02\x03\x04\x09"; break; layout = "\x01\x02\x03\x04\x09"; break;
case kAudioChannelLayoutTag_AC3_3_1_1: case kAudioChannelLayoutTag_AC3_3_1_1:
layout = "\x01\x03\x02\x09\x04"; break; layout = "\x01\x03\x02\x09\x04"; break;
case kAudioChannelLayoutTag_DTS_4_1:
layout = "\x03\x01\x02\x09\x04"; break;
/* 5ch */ /* 5ch */
case kAudioChannelLayoutTag_MPEG_5_0_A: case kAudioChannelLayoutTag_MPEG_5_0_A:
layout = "\x01\x02\x03\x0A\x0B"; break; layout = "\x01\x02\x03\x0A\x0B"; break;
@ -292,6 +320,8 @@ int apple_chan_chunk(pcm_io_context_t *io, uint32_t chunk_size,
layout = "\x01\x03\x02\x0A\x0B"; break; layout = "\x01\x03\x02\x0A\x0B"; break;
case kAudioChannelLayoutTag_MPEG_5_0_D: case kAudioChannelLayoutTag_MPEG_5_0_D:
layout = "\x03\x01\x02\x0A\x0B"; break; layout = "\x03\x01\x02\x0A\x0B"; break;
case kAudioChannelLayoutTag_WAVE_5_0_B:
layout = "\x01\x02\x03\x05\x06"; break;
/* 5.1ch */ /* 5.1ch */
case kAudioChannelLayoutTag_MPEG_5_1_A: case kAudioChannelLayoutTag_MPEG_5_1_A:
layout = "\x01\x02\x03\x04\x0A\x0B"; break; layout = "\x01\x02\x03\x04\x0A\x0B"; break;
@ -301,17 +331,49 @@ int apple_chan_chunk(pcm_io_context_t *io, uint32_t chunk_size,
layout = "\x01\x03\x02\x0A\x0B\x04"; break; layout = "\x01\x03\x02\x0A\x0B\x04"; break;
case kAudioChannelLayoutTag_MPEG_5_1_D: case kAudioChannelLayoutTag_MPEG_5_1_D:
layout = "\x03\x01\x02\x0A\x0B\x04"; break; layout = "\x03\x01\x02\x0A\x0B\x04"; break;
case kAudioChannelLayoutTag_WAVE_5_1_B:
layout = "\x01\x02\x03\x04\x05\x06"; break;
/* 6ch */ /* 6ch */
case kAudioChannelLayoutTag_Hexagonal: case kAudioChannelLayoutTag_Hexagonal:
case kAudioChannelLayoutTag_AudioUnit_6_0: case kAudioChannelLayoutTag_AudioUnit_6_0:
layout = "\x01\x02\x0A\x0B\x03\x09"; break; layout = "\x01\x02\x0A\x0B\x03\x09"; break;
case kAudioChannelLayoutTag_AAC_6_0: case kAudioChannelLayoutTag_AAC_6_0:
layout = "\x03\x01\x02\x0A\x0B\x09"; break; layout = "\x03\x01\x02\x0A\x0B\x09"; break;
case kAudioChannelLayoutTag_EAC_6_0_A:
layout = "\x01\x03\x02\x0A\x0B\x09"; break;
case kAudioChannelLayoutTag_DTS_6_0_A:
layout = "\x07\x08\x01\x02\x0A\x0B"; break;
case kAudioChannelLayoutTag_DTS_6_0_B:
layout = "\x03\x01\x02\x05\x06\x0C"; break;
case kAudioChannelLayoutTag_DTS_6_0_C:
layout = "\x03\x09\x01\x02\x05\x06"; break;
case kAudioChannelLayoutTag_Logic_6_0_B:
layout = "\x01\x02\x0A\x0B\x09\x03"; break;
/* 6.1ch */ /* 6.1ch */
case kAudioChannelLayoutTag_MPEG_6_1_A: case kAudioChannelLayoutTag_MPEG_6_1_A:
layout = "\x01\x02\x03\x04\x0A\x0B\x09"; break; layout = "\x01\x02\x03\x04\x0A\x0B\x09"; break;
case kAudioChannelLayoutTag_AAC_6_1: case kAudioChannelLayoutTag_AAC_6_1:
layout = "\x03\x01\x02\x0A\x0B\x09\x04"; break; layout = "\x03\x01\x02\x0A\x0B\x09\x04"; break;
case kAudioChannelLayoutTag_EAC3_6_1_A:
layout = "\x01\x03\x02\x0A\x0B\x04\x09"; break;
case kAudioChannelLayoutTag_EAC3_6_1_B:
layout = "\x01\x03\x02\x0A\x0B\x04\x0C"; break;
case kAudioChannelLayoutTag_EAC3_6_1_C:
layout = "\x01\x03\x02\x0A\x0B\x04\x0E"; break;
case kAudioChannelLayoutTag_DTS_6_1_A:
layout = "\x07\x08\x01\x02\x0A\x0B\x04"; break;
case kAudioChannelLayoutTag_DTS_6_1_B:
layout = "\x03\x01\x02\x05\x06\x0C\x04"; break;
case kAudioChannelLayoutTag_DTS_6_1_C:
layout = "\x03\x09\x01\x02\x05\x06\x04"; break;
case kAudioChannelLayoutTag_DTS_6_1_D:
layout = "\x03\x01\x02\x0A\x0B\x04\x09"; break;
case kAudioChannelLayoutTag_WAVE_6_1:
layout = "\x01\x02\x03\x04\x09\x0A\x0B"; break;
case kAudioChannelLayoutTag_Logic_6_1_B:
layout = "\x01\x02\x0A\x0B\x09\x03\x04"; break;
case kAudioChannelLayoutTag_Logic_6_1_D:
layout = "\x01\x03\x02\x0A\x09\x0B\x04"; break;
/* 7ch */ /* 7ch */
case kAudioChannelLayoutTag_AudioUnit_7_0: case kAudioChannelLayoutTag_AudioUnit_7_0:
layout = "\x01\x02\x0A\x0B\x03\x05\x06"; break; layout = "\x01\x02\x0A\x0B\x03\x05\x06"; break;
@ -319,6 +381,10 @@ int apple_chan_chunk(pcm_io_context_t *io, uint32_t chunk_size,
layout = "\x01\x02\x0A\x0B\x03\x07\x08"; break; layout = "\x01\x02\x0A\x0B\x03\x07\x08"; break;
case kAudioChannelLayoutTag_AAC_7_0: case kAudioChannelLayoutTag_AAC_7_0:
layout = "\x03\x01\x02\x0A\x0B\x05\x06"; break; layout = "\x03\x01\x02\x0A\x0B\x05\x06"; break;
case kAudioChannelLayoutTag_EAC_7_0_A:
layout = "\x01\x03\x02\x0A\x0B\x05\x06"; break;
case kAudioChannelLayoutTag_DTS_7_0:
layout = "\x07\x03\x08\x01\x02\x0A\x0B"; break;
/* 7.1ch */ /* 7.1ch */
case kAudioChannelLayoutTag_MPEG_7_1_A: case kAudioChannelLayoutTag_MPEG_7_1_A:
layout = "\x01\x02\x03\x04\x0A\x0B\x07\x08"; break; layout = "\x01\x02\x03\x04\x0A\x0B\x07\x08"; break;
@ -328,11 +394,37 @@ int apple_chan_chunk(pcm_io_context_t *io, uint32_t chunk_size,
layout = "\x01\x02\x03\x04\x0A\x0B\x05\x06"; break; layout = "\x01\x02\x03\x04\x0A\x0B\x05\x06"; break;
case kAudioChannelLayoutTag_Emagic_Default_7_1: case kAudioChannelLayoutTag_Emagic_Default_7_1:
layout = "\x01\x02\x0A\x0B\x03\x04\x07\x08"; break; layout = "\x01\x02\x0A\x0B\x03\x04\x07\x08"; break;
case kAudioChannelLayoutTag_AAC_7_1_B:
layout = "\x03\x01\x02\x0A\x0B\x05\x06\x04"; break;
case kAudioChannelLayoutTag_AAC_7_1_C:
layout = "\x03\x01\x02\x0A\x0B\x04\x0D\x0F"; break;
case kAudioChannelLayoutTag_EAC3_7_1_A:
layout = "\x01\x03\x02\x0A\x0B\x04\x05\x06"; break;
case kAudioChannelLayoutTag_EAC3_7_1_B:
layout = "\x01\x03\x02\x0A\x0B\x04\x07\x08"; break;
case kAudioChannelLayoutTag_EAC3_7_1_E:
layout = "\x01\x03\x02\x0A\x0B\x04\x0D\x0F"; break;
case kAudioChannelLayoutTag_EAC3_7_1_F:
layout = "\x01\x03\x02\x0A\x0B\x04\x09\x0C"; break;
case kAudioChannelLayoutTag_EAC3_7_1_G:
layout = "\x01\x03\x02\x0A\x0B\x04\x09\x0E"; break;
case kAudioChannelLayoutTag_EAC3_7_1_H:
layout = "\x01\x03\x02\x0A\x0B\x04\x0C\x0E"; break;
case kAudioChannelLayoutTag_DTS_7_1:
layout = "\x07\x03\x08\x01\x02\x0A\x0B\x04"; break;
case kAudioChannelLayoutTag_WAVE_7_1:
layout = "\x01\x02\x03\x04\x05\x06\x0A\x0B"; break;
case kAudioChannelLayoutTag_Logic_7_1_B:
layout = "\x01\x02\x0A\x0B\x05\x06\x03\x04"; break;
/* 8ch */ /* 8ch */
case kAudioChannelLayoutTag_Octagonal: case kAudioChannelLayoutTag_Octagonal:
layout = "\x01\x02\x05\x06\x03\x09\x0A\x0B"; break; layout = "\x01\x02\x05\x06\x03\x09\x0A\x0B"; break;
case kAudioChannelLayoutTag_AAC_Octagonal: case kAudioChannelLayoutTag_AAC_Octagonal:
layout = "\x03\x01\x02\x0A\x0B\x05\x06\x09"; break; layout = "\x03\x01\x02\x0A\x0B\x05\x06\x09"; break;
case kAudioChannelLayoutTag_DTS_8_0_A:
layout = "\x07\x08\x01\x02\x0A\x0B\x05\x06"; break;
case kAudioChannelLayoutTag_DTS_8_0_B:
layout = "\x07\x03\x08\x01\x02\x0A\x09\x0B"; break;
default: default:
goto FAIL; goto FAIL;
} }

View File

@ -10,6 +10,8 @@
#if HAVE_STDINT_H #if HAVE_STDINT_H
# include <stdint.h> # include <stdint.h>
#endif #endif
#include <assert.h>
#include <fdk-aac/aacenc_lib.h>
#include "pcm_reader.h" #include "pcm_reader.h"
typedef struct pcm_sint16_converter_t { typedef struct pcm_sint16_converter_t {
@ -43,10 +45,10 @@ static int64_t get_position(pcm_reader_t *reader)
static int read_frames(pcm_reader_t *reader, void *buffer, unsigned nframes) 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; pcm_sint16_converter_t *self = (pcm_sint16_converter_t *)reader;
const pcm_sample_description_t *sfmt = pcm_get_format(self->src); const pcm_sample_description_t *sfmt = pcm_get_format(self->src);
unsigned bytes = nframes * sfmt->bytes_per_frame; unsigned bytes = nframes * sfmt->bytes_per_frame;
if (self->capacity < bytes) { if (self->capacity < bytes) {
void *p = realloc(self->pivot, bytes); void *p = realloc(self->pivot, bytes);
if (!p) return -1; if (!p) return -1;
@ -54,8 +56,35 @@ static int read_frames(pcm_reader_t *reader, void *buffer, unsigned nframes)
self->capacity = bytes; self->capacity = bytes;
} }
nframes = pcm_read_frames(self->src, self->pivot, nframes); nframes = pcm_read_frames(self->src, self->pivot, nframes);
if (pcm_convert_to_native_sint16(sfmt, self->pivot, nframes, buffer) < 0) count = nframes * sfmt->channels_per_frame;
return -1; if (PCM_IS_FLOAT(sfmt)) {
float *ip = self->pivot;
INT_PCM *op = buffer;
#if SAMPLE_BITS == 16
for (i = 0; i < count; ++i)
op[i] = (int16_t)pcm_clip(ip[i] * 32768.0, -32768.0, 32767.0);
#else
for (i = 0; i < count; ++i)
op[i] = (int32_t)pcm_clip(ip[i] * 2147483648.0, -2147483648.0, 2147483647.0);
#endif
} else {
int32_t *ip = self->pivot;
INT_PCM *op = buffer;
#if SAMPLE_BITS == 16
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;
}
}
#else
for (i = 0; i < count; ++i)
op[i] = ip[i];
#endif
}
return nframes; return nframes;
} }
@ -77,18 +106,16 @@ pcm_reader_t *pcm_open_sint16_converter(pcm_reader_t *reader)
pcm_sint16_converter_t *self = 0; pcm_sint16_converter_t *self = 0;
pcm_sample_description_t *fmt; pcm_sample_description_t *fmt;
assert((SAMPLE_BITS>>3) == sizeof(INT_PCM));
if ((self = calloc(1, sizeof(pcm_sint16_converter_t))) == 0) if ((self = calloc(1, sizeof(pcm_sint16_converter_t))) == 0)
return 0; return 0;
self->src = reader; self->src = reader;
self->vtbl = &my_vtable; self->vtbl = &my_vtable;
memcpy(&self->format, pcm_get_format(reader), sizeof(self->format)); memcpy(&self->format, pcm_get_format(reader), sizeof(self->format));
fmt = &self->format; fmt = &self->format;
#if WORDS_BIGENDIAN fmt->bits_per_channel = SAMPLE_BITS;
fmt->sample_type = PCM_TYPE_SINT_BE;
#else
fmt->sample_type = PCM_TYPE_SINT; fmt->sample_type = PCM_TYPE_SINT;
#endif fmt->bytes_per_frame = sizeof(INT_PCM) * fmt->channels_per_frame;
fmt->bits_per_channel = 16;
fmt->bytes_per_frame = 2 * fmt->channels_per_frame;
return (pcm_reader_t *)self; return (pcm_reader_t *)self;
} }

View File

@ -14,7 +14,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.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)) #define RIFF_FOURCC(a,b,c,d) ((a)|((b)<<8)|((c)<<16)|((d)<<24))
@ -113,8 +113,10 @@ int wav_fmt(wav_reader_t *reader, uint32_t size)
wValidBitsPerSample = wBitsPerSample; wValidBitsPerSample = wBitsPerSample;
ENSURE(wFormatTag == 1 || wFormatTag == 3 || wFormatTag == 0xfffe); ENSURE(wFormatTag == 1 || wFormatTag == 3 || wFormatTag == 0xfffe);
ENSURE(nChannels && nSamplesPerSec && nAvgBytesPerSec && ENSURE(nChannels > 0 && nChannels <= 8 &&
nBlockAlign && wBitsPerSample && !(wBitsPerSample & 7) && nSamplesPerSec && nAvgBytesPerSec &&
nBlockAlign && nBlockAlign < 256 &&
wBitsPerSample && wBitsPerSample < 256 && !(wBitsPerSample & 7) &&
nBlockAlign == nChannels * wBitsPerSample / 8); nBlockAlign == nChannels * wBitsPerSample / 8);
if (wFormatTag == 3) if (wFormatTag == 3)
@ -155,6 +157,7 @@ static
int wav_parse(wav_reader_t *reader, int64_t *data_length) int wav_parse(wav_reader_t *reader, int64_t *data_length)
{ {
uint32_t container, fcc, chunk_size; uint32_t container, fcc, chunk_size;
int fmt_seen = 0;
*data_length = 0; *data_length = 0;
container = riff_next_chunk(reader, &chunk_size); container = riff_next_chunk(reader, &chunk_size);
@ -167,6 +170,7 @@ int wav_parse(wav_reader_t *reader, int64_t *data_length)
riff_ds64(reader, data_length); riff_ds64(reader, data_length);
while ((fcc = riff_next_chunk(reader, &chunk_size)) != 0) { while ((fcc = riff_next_chunk(reader, &chunk_size)) != 0) {
if (fcc == RIFF_FOURCC('f','m','t',' ')) { if (fcc == RIFF_FOURCC('f','m','t',' ')) {
fmt_seen = 1;
if (wav_fmt(reader, chunk_size) < 0) if (wav_fmt(reader, chunk_size) < 0)
goto FAIL; goto FAIL;
} else if (fcc == RIFF_FOURCC('d','a','t','a')) { } else if (fcc == RIFF_FOURCC('d','a','t','a')) {
@ -178,8 +182,8 @@ int wav_parse(wav_reader_t *reader, int64_t *data_length)
TRY_IO(pcm_skip(&reader->io, (chunk_size + 1) & ~1)); TRY_IO(pcm_skip(&reader->io, (chunk_size + 1) & ~1));
} }
} }
if (fcc == RIFF_FOURCC('d','a','t','a')) ENSURE(fmt_seen && fcc == RIFF_FOURCC('d', 'a', 't', 'a'));
return 0; return 0;
FAIL: FAIL:
return -1; return -1;
} }

View File

@ -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

View File

@ -1,4 +1,4 @@
#ifndef VERSION_H #ifndef VERSION_H
#define VERSION_H #define VERSION_H
const char *fdkaac_version = "0.5.4"; const char *fdkaac_version = "1.0.6";
#endif #endif