Skip to content

Commit

Permalink
add vcxproj
Browse files Browse the repository at this point in the history
  • Loading branch information
KinoMyu committed May 14, 2019
1 parent 67ecf23 commit 34eb088
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 35 deletions.
11 changes: 2 additions & 9 deletions HCADecodeService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ HCADecodeService::HCADecodeService()
chunksize{ 24 },
workersem{ new Semaphore[this->numthreads]{} },
datasem{ 0 },
mainsem{ this->numthreads },
mainsem{ 0 },
numchannels{ 0 },
workingrequest{ nullptr },
shutdown{ false },
Expand All @@ -31,7 +31,7 @@ HCADecodeService::HCADecodeService(unsigned int numthreads, unsigned int chunksi
chunksize{ chunksize ? chunksize : 24 },
workersem{ new Semaphore[this->numthreads]{} },
datasem{ 0 },
mainsem{ this->numthreads },
mainsem{ 0 },
numchannels{ 0 },
workingrequest{ nullptr },
shutdown{ false },
Expand Down Expand Up @@ -172,7 +172,6 @@ void HCADecodeService::Main_Thread()
}

mainsem.wait(numthreads);
wait_on_all_threads(mainsem);

workingrequest = nullptr;

Expand Down Expand Up @@ -221,12 +220,6 @@ void HCADecodeService::populate_block_list()
}
}

void HCADecodeService::wait_on_all_threads(Semaphore &sem)
{
sem.wait(numthreads);
sem.notify(numthreads);
}

void HCADecodeService::join_workers()
{
for (unsigned int i = 0; i < numthreads; ++i)
Expand Down
1 change: 0 additions & 1 deletion HCADecodeService.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class HCADecodeService
void Decode_Thread(unsigned int id);
void load_next_request();
void populate_block_list();
void wait_on_all_threads(Semaphore &sem);
void join_workers();

clHCA workingfile;
Expand Down
37 changes: 12 additions & 25 deletions clHCA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,17 @@
// インライン関数
//--------------------------------------------------
#ifdef _MSC_VER
#include <stdlib.h>
// MSVC does not optimize these functions to bswap even on -O2
inline short bswap(short v) { return _byteswap_ushort(v); }
inline unsigned short bswap(unsigned short v) { return _byteswap_ushort(v); }
inline int bswap(int v) { return _byteswap_ulong(v); }
inline unsigned int bswap(unsigned int v) { return _byteswap_ulong(v); }
inline long long bswap(long long v) { return _byteswap_uint64(v); }
inline unsigned long long bswap(unsigned long long v) { return _byteswap_uint64(v); }
#else
// gcc and clang optimize these functions to bswap instructions
inline short bswap(short v) { short r = v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; return r; }
inline unsigned short bswap(unsigned short v) { unsigned short r = v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; return r; }
inline int bswap(int v) { int r = v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; return r; }
inline unsigned int bswap(unsigned int v) { unsigned int r = v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; return r; }
inline long long bswap(long long v) { long long r = v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; return r; }
inline unsigned long long bswap(unsigned long long v) { unsigned long long r = v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; r <<= 8; v >>= 8; r |= v & 0xFF; return r; }
#define __builtin_bswap16 _byteswap_ushort
#define __builtin_bswap32 _byteswap_ulong
#define __builtin_bswap64 _byteswap_uint64
#endif // _MSC_VER
inline short bswap(short v) { return __builtin_bswap16(v); }
inline unsigned short bswap(unsigned short v) { return __builtin_bswap16(v); }
inline int bswap(int v) { return __builtin_bswap32(v); }
inline unsigned int bswap(unsigned int v) { return __builtin_bswap32(v); }
inline long long bswap(long long v) { return __builtin_bswap64(v); }
inline unsigned long long bswap(unsigned long long v) { return __builtin_bswap64(v); }

inline float bswap(float v) { unsigned int i = bswap(*(unsigned int *)&v); return *(float *)&i; }
inline unsigned int ceil2(unsigned int a, unsigned int b) { return (b>0) ? (a / b + ((a%b) ? 1 : 0)) : 0; }
template <class T> inline T clamp(T val, T min, T max) { return (val > max) ? max : (val < min) ? min : val; }
Expand Down Expand Up @@ -687,13 +681,6 @@ void clHCA::AsyncDecode(stChannel *channels, float *wavebuffer, unsigned int blo
if (stop) return;
unsigned int samplesize = _mode >> 3;
char *outwavptr = (char *)outputwavptr + (samplesize * blocknum * _channelCount << 10) + _wavheadersize;
if (blocknum == 0)
{
for (unsigned int i = 0; i < _channelCount; ++i)
{
memset(channels[i].wav2, 0, 512); // Clear previous IMDCT result
}
}
unsigned int endblock = blocknum + chunksize;
for (unsigned int currblock = blocknum ? blocknum - 1 : blocknum; currblock < endblock && currblock < _blockCount; ++currblock)
{
Expand Down Expand Up @@ -1087,10 +1074,10 @@ int clHCA::clData::CheckBit(int bitSize) {
int v = 0;
if (bitSize <= _size - _bit)
{
static unsigned int mask[] = { 0xFFFFFF,0x7FFFFF,0x3FFFFF,0x1FFFFF,0x0FFFFF,0x07FFFF,0x03FFFF,0x01FFFF };
static unsigned int mask[] = { 0xFFFFFF00,0xFFFF7F00,0xFFFF3F00,0xFFFF1F00,0xFFFF0F00,0xFFFF0700,0xFFFF0300,0xFFFF0100 };
unsigned int *data = (unsigned int *)&_data[_bit >> 3];
unsigned int shift_bits = _bit & 7;
v = bswap(*data) & mask[shift_bits];
v = bswap(*data & mask[shift_bits]);
v >>= 24 - shift_bits - bitSize;
}
return v;
Expand Down
186 changes: 186 additions & 0 deletions clHCA.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{F91BD81C-9D95-42E5-BBA3-E0D2162F4144}</ProjectGuid>
<RootNamespace>clHCA</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</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" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<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|x64'">
<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)'=='Release|Win32'">
<IncludePath>$(IncludePath)</IncludePath>
<LibraryPath>$(LibraryPath)</LibraryPath>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level2</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>
</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FloatingPointModel>
</FloatingPointModel>
<EnableEnhancedInstructionSet>
</EnableEnhancedInstructionSet>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<CallingConvention>StdCall</CallingConvention>
<BufferSecurityCheck>false</BufferSecurityCheck>
<ExceptionHandling>false</ExceptionHandling>
<StringPooling>true</StringPooling>
<OptimizeForWindowsApplication>true</OptimizeForWindowsApplication>
<LoopUnrolling>
</LoopUnrolling>
<LanguageStandard>
</LanguageStandard>
<ControlFlowGuard>false</ControlFlowGuard>
<FloatingPointExceptions>false</FloatingPointExceptions>
<PreprocessorDefinitions>_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<GenerateDebugInformation>false</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level2</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>
</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<Cpp0xSupport>true</Cpp0xSupport>
<OptimizeForWindowsApplication>true</OptimizeForWindowsApplication>
<Parallelization>true</Parallelization>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<OmitFramePointers>true</OmitFramePointers>
<BufferSecurityCheck>false</BufferSecurityCheck>
<StringPooling>true</StringPooling>
<ExceptionHandling>false</ExceptionHandling>
<FloatingPointModel />
<FloatingPointExceptions>false</FloatingPointExceptions>
<EnableEnhancedInstructionSet />
<ControlFlowGuard>false</ControlFlowGuard>
<CallingConvention>FastCall</CallingConvention>
<PreprocessorDefinitions>_HAS_EXCEPTIONS=0;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WholeProgramOptimization>true</WholeProgramOptimization>
<OpenMPSupport>false</OpenMPSupport>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<GenerateDebugInformation>DebugFastLink</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include=".\clHCA.cpp" />
<ClCompile Include=".\HCADecodeService.cpp" />
<ClCompile Include=".\Source.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include=".\clHCA.h" />
<ClInclude Include=".\HCADecodeService.h" />
<ClInclude Include=".\Semaphore.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

0 comments on commit 34eb088

Please sign in to comment.