Permalink
Browse files

AMD64 support (refalac only)

  • Loading branch information...
1 parent 3d87469 commit f6ef7104a801d1c9d46e5a21d745aca550c3fc8d @nu774 committed Nov 28, 2011
View
@@ -88,20 +88,13 @@ void set_ag_params(AGParamRecPtr params, uint32_t m, uint32_t p, uint32_t k, uin
// note: implementing this with some kind of "count leading zeros" assembly is a big performance win
-#if defined(_MSC_VER) && !defined(_WIN64)
+#if defined(_MSC_VER)
+#include <intrin.h>
+#pragma intrinsic (_BitScanReverse)
static inline int32_t lead(int32_t m)
{
- if (m == 0)
- return 32;
- else {
- int n;
- __asm {
- mov eax, m
- bsr ebx, eax
- mov n, ebx
- }
- return n ^ 31;
- }
+ unsigned long n;
+ return _BitScanReverse(&n, m) ? n ^ 31 : 32;
}
#else
View
@@ -62,22 +62,14 @@
*/
// note: implementing this with some kind of "count leading zeros" assembly is a big performance win
-#if defined(_MSC_VER) && !defined(_WIN64)
+#if defined(_MSC_VER)
+#include <intrin.h>
+#pragma intrinsic (_BitScanReverse)
static inline int32_t lead(int32_t m)
{
- if (m == 0)
- return 32;
- else {
- int n;
- __asm {
- mov eax, m
- bsr ebx, eax
- mov n, ebx
- }
- return n ^ 31;
- }
+ unsigned long n;
+ return _BitScanReverse(&n, m) ? n ^ 31 : 32;
}
-
#else
static inline int32_t lead( int32_t m )
{
View
@@ -71,7 +71,8 @@ size_t ALACSource::readSamples(void *buffer, size_t nsamples)
uint8_t *bufp = static_cast<uint8_t*>(buffer);
uint32_t nread = 0;
- uint32_t size = std::min(m_buffer.rest(), nsamples);
+ uint32_t size = std::min(m_buffer.rest(),
+ static_cast<uint32_t>(nsamples));
if (size) {
std::memcpy(bufp, &m_buffer.v[m_buffer.done * bpf], size * bpf);
m_buffer.advance(size);
@@ -99,7 +100,8 @@ size_t ALACSource::readSamples(void *buffer, size_t nsamples)
m_format.m_nchannels, &ncount));
m_buffer.nsamples = ncount;
- duration = std::min(ncount - m_buffer.done, nsamples - nread);
+ duration = std::min(ncount - m_buffer.done,
+ static_cast<uint32_t>(nsamples) - nread);
std::memcpy(bufp, &m_buffer.v[m_buffer.done * bpf], duration * bpf);
m_buffer.advance(duration);
nread += duration;
View
@@ -121,9 +121,10 @@ size_t FLACSource::readSamples(void *buffer, size_t nsamples)
}
FLAC__StreamDecoderReadStatus
-FLACSource::readCallback(FLAC__byte *buffer, unsigned *bytes)
+FLACSource::readCallback(FLAC__byte *buffer, size_t *bytes)
{
- *bytes = m_stream.read(buffer, *bytes);
+ uint32_t nb = *bytes;
+ *bytes = m_stream.read(buffer, nb);
return *bytes == 0 ? FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM
: FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
}
View
@@ -47,7 +47,7 @@ class FLACSource :
static FLAC__StreamDecoderReadStatus staticReadCallback(
const FLAC__StreamDecoder *decoder,
FLAC__byte *buffer,
- unsigned *bytes,
+ size_t *bytes,
void *client_data)
{
FLACSource *self = reinterpret_cast<FLACSource*>(client_data);
@@ -109,7 +109,7 @@ class FLACSource :
self->errorCallback(status);
}
FLAC__StreamDecoderReadStatus
- readCallback(FLAC__byte *buffer, unsigned *bytes);
+ readCallback(FLAC__byte *buffer, size_t *bytes);
FLAC__StreamDecoderSeekStatus seekCallback(uint64_t offset);
FLAC__StreamDecoderTellStatus tellCallback(uint64_t *offset);
FLAC__StreamDecoderLengthStatus lengthCallback(uint64_t *length);
View
@@ -1082,7 +1082,11 @@ void load_modules(Options &opts)
opts.libflac = FLACModule(L"libFLAC.dll");
opts.libwavpack = WavpackModule(L"wavpackdll.dll");
opts.libtak = TakModule(L"tak_deco_lib.dll");
+#ifdef _WIN64
+ opts.libsoxrate = SoxModule(L"libsoxrate64.dll");
+#else
opts.libsoxrate = SoxModule(L"libsoxrate.dll");
+#endif
}
struct FNConverter {
View
@@ -164,8 +164,8 @@ size_t MatrixMixer::phaseShift(void *buffer, size_t nsamples)
src[i * ichannels + *it] /= m_filter_gain;
}
}
- uint32_t ilen = m_input_frames;
- uint32_t olen = nsamples;
+ size_t ilen = m_input_frames;
+ size_t olen = nsamples;
size_t j = 0;
for (size_t i = 0; i < m_shift_channels.size(); ++i) {
ivec[i] = src + m_shift_channels[i];
View
@@ -68,8 +68,8 @@ size_t SoxDSPProcessor::readSamples(void *buffer, size_t nsamples)
m_end_of_input = true;
src = &m_fbuffer[0];
}
- uint32_t ilen = m_input_frames;
- uint32_t olen = nsamples;
+ size_t ilen = m_input_frames;
+ size_t olen = nsamples;
for (size_t i = 0; i < nchannels; ++i) {
ivec[i] = src + i;
ovec[i] = dst + i;
View
4 util.h
@@ -23,13 +23,13 @@ inline int _wtoi(const wchar_t *s) { return std::wcstol(s, 0, 10); }
template <typename T, size_t size>
inline size_t array_size(const T (&)[size]) { return size; }
-inline int strindex(const char *s, int ch)
+inline intptr_t strindex(const char *s, int ch)
{
const char *p = std::strchr(s, ch);
return p ? p - s : -1;
}
-inline int strindex(const wchar_t *s, int ch)
+inline intptr_t strindex(const wchar_t *s, int ch)
{
const wchar_t *p = std::wcschr(s, ch);
return p ? p - s : -1;
@@ -5,10 +5,18 @@
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{47ED1718-29C3-4659-B4DD-7C1F5D9043AC}</ProjectGuid>
@@ -21,23 +29,42 @@
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>false</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</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="..\qaac.props" />
</ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\qaac.props" />
+ </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="..\qaac.props" />
</ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\qaac.props" />
+ </ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@@ -54,6 +81,20 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>inline=_inline;TARGET_RT_LITTLE_ENDIAN;TARGET_OS_WIN32;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(QTSDKDir)/CIncludes</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
@@ -73,6 +114,25 @@
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>inline=_inline;TARGET_RT_LITTLE_ENDIAN;TARGET_OS_WIN32;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <AdditionalIncludeDirectories>$(QTSDKDir)/CIncludes</AdditionalIncludeDirectories>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
<ItemGroup>
<None Include="ReadMe.txt" />
</ItemGroup>
@@ -5,10 +5,18 @@
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{81A5ABC3-9C87-47D5-B8E5-39B43E9F17A7}</ProjectGuid>
@@ -19,21 +27,37 @@
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\qaac.props" />
</ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\qaac.props" />
+ </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\qaac.props" />
</ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="..\qaac.props" />
+ </ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -55,6 +79,25 @@
<OutputFile>$(OutDir)common.lib</OutputFile>
</Lib>
</ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>..\..\include;..\..\CoreAudio;..\..\alac;$(mp4v2Includes);$(taglibIncludes);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;TAGLIB_STATIC;_DEBUG;_LIB;MP4V2_USE_STATIC_LIB;MP4V2_NO_STDINT_DEFS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Lib>
+ <OutputFile>$(OutDir)common.lib</OutputFile>
+ </Lib>
+ </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>..\..\include;..\..\CoreAudio;..\..\alac;$(mp4v2Includes);$(taglibIncludes);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -72,6 +115,23 @@
<OutputFile>$(OutDir)common.lib</OutputFile>
</Lib>
</ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <AdditionalIncludeDirectories>..\..\include;..\..\CoreAudio;..\..\alac;$(mp4v2Includes);$(taglibIncludes);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;TAGLIB_STATIC;NDEBUG;_LIB;MP4V2_USE_STATIC_LIB;MP4V2_NO_STDINT_DEFS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <StringPooling>true</StringPooling>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ </ClCompile>
+ <Lib>
+ <OutputFile>$(OutDir)common.lib</OutputFile>
+ </Lib>
+ </ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\alacsink.cpp" />
<ClCompile Include="..\..\alacsrc.cpp" />
Oops, something went wrong.

0 comments on commit f6ef710

Please sign in to comment.