Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tp7 committed Mar 9, 2014
0 parents commit 2677ca2
Show file tree
Hide file tree
Showing 12 changed files with 1,336 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Build
test
*.*sdf
*.suo
*.user
28 changes: 28 additions & 0 deletions CLExpr.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30110.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CLExpr", "CLExpr\CLExpr.vcxproj", "{D5AA35BC-C854-4E44-B093-3BC38319E25C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D5AA35BC-C854-4E44-B093-3BC38319E25C}.Debug|Win32.ActiveCfg = Debug|Win32
{D5AA35BC-C854-4E44-B093-3BC38319E25C}.Debug|Win32.Build.0 = Debug|Win32
{D5AA35BC-C854-4E44-B093-3BC38319E25C}.Debug|x64.ActiveCfg = Debug|x64
{D5AA35BC-C854-4E44-B093-3BC38319E25C}.Debug|x64.Build.0 = Debug|x64
{D5AA35BC-C854-4E44-B093-3BC38319E25C}.Release|Win32.ActiveCfg = Release|Win32
{D5AA35BC-C854-4E44-B093-3BC38319E25C}.Release|Win32.Build.0 = Release|Win32
{D5AA35BC-C854-4E44-B093-3BC38319E25C}.Release|x64.ActiveCfg = Release|x64
{D5AA35BC-C854-4E44-B093-3BC38319E25C}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
158 changes: 158 additions & 0 deletions CLExpr/CLExpr.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.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="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>{D5AA35BC-C854-4E44-B093-3BC38319E25C}</ProjectGuid>
<RootNamespace>CLExpr</RootNamespace>
<ProjectName>CLExpr</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</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" />
</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" />
</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 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" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)Build\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)Build\Temp\$(Platform)\$(Configuration)\</IntDir>
<IncludePath>$(AVISYNTH_SDK_PATH)\include;$(CUDA_INC_PATH);$(IncludePath)</IncludePath>
<LibraryPath>$(CUDA_LIB_PATH)\..\Win32;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)Build\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)Build\Temp\$(Platform)\$(Configuration)\</IntDir>
<IncludePath>$(AVISYNTH_SDK_PATH)\include;$(CUDA_INC_PATH);$(IncludePath)</IncludePath>
<LibraryPath>$(CUDA_LIB_PATH)\..\x64;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)Build\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)Build\Temp\$(Platform)\$(Configuration)\</IntDir>
<IncludePath>$(AVISYNTH_SDK_PATH)\include;$(CUDA_INC_PATH);$(IncludePath)</IncludePath>
<LibraryPath>$(CUDA_LIB_PATH)\..\Win32;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)Build\$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)Build\Temp\$(Platform)\$(Configuration)\</IntDir>
<IncludePath>$(AVISYNTH_SDK_PATH)\include;$(CUDA_INC_PATH);$(IncludePath)</IncludePath>
<LibraryPath>$(CUDA_LIB_PATH)\..\x64;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>OpenCL.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>OpenCL.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>OpenCL.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>OpenCL.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="expr.cpp" />
<ClCompile Include="parser\parser.cpp" />
<ClCompile Include="parser\symbol.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="clcode.h" />
<ClInclude Include="parser\parser.h" />
<ClInclude Include="parser\symbol.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
39 changes: 39 additions & 0 deletions CLExpr/CLExpr.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="expr.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="parser\parser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="parser\symbol.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="parser\parser.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="parser\symbol.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="clcode.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
157 changes: 157 additions & 0 deletions CLExpr/clcode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#ifndef __EXPR_COMMON__
#define __EXPR_COMMON__


const char* common_ocl_functions = " \
ulong clip_ulong(float x) { \
return (ulong)round(clamp(x, 0.0f, (float)(ULONG_MAX))); \
} \
\
long clip_long(float x) { \
return (long)round(clamp(x, (float)(LONG_MIN), (float)(LONG_MAX))); \
} \
\
float interrogation(float x, float y, float z) { \
return x > 0 ? y : z; \
} \
\
float equal(float x, float y) { \
return fabs(x - y) < 0.000001f ? 1.0f : -1.0f; \
} \
\
float notEqual(float x, float y) { \
return fabs(x - y) >= 0.000001f ? 1.0f : -1.0f; \
} \
\
float inferior(float x, float y) { \
return x <= y ? 1.0f : -1.0f; \
} \
\
float inferiorStrict(float x, float y) { \
return x < y ? 1.0f : -1.0f; \
} \
\
float superior(float x, float y) { \
return x >= y ? 1.0f : -1.0f; \
} \
\
float superiorStrict(float x, float y) { \
return x > y ? 1.0f : -1.0f; \
} \
\
float mt_and(float x, float y) { \
return ((x > 0) && (y > 0)) ? 1.0f : -1.0f; \
} \
\
float mt_or(float x, float y) { \
return ((x > 0) || (y > 0)) ? 1.0f : -1.0f; \
} \
\
float mt_andNot(float x, float y) { \
return ((x > 0) && (y <= 0)) ? 1.0f : -1.0f; \
} \
\
float mt_xor(float x, float y) { \
return (((x > 0) && (y <= 0)) || ((x <= 0) && (y > 0))) ? 1.0f : -1.0f; \
} \
\
float andUB(float x, float y) { \
return (float)(clip_ulong(x) & clip_ulong(y)); \
} \
\
float orUB(float x, float y) { \
return (float)(clip_ulong(x) | clip_ulong(y)); \
} \
\
float xorUB(float x, float y) { \
return (float)(clip_ulong(x) ^ clip_ulong(y)); \
} \
\
float negateUB(float x) { \
return (float)(~clip_ulong(x)); \
} \
\
float posshiftUB(float x, float y) { \
return y >= 0 ? (float)(clip_ulong(x) << clip_long(y)) : (float)(clip_ulong(x) >> clip_long(-y)); \
} \
\
float negshiftUB(float x, float y) { \
return y >= 0 ? (float)(clip_ulong(x) >> clip_long(y)) : (float)(clip_ulong(x) << clip_long(-y)); \
} \
\
float andSB(float x, float y) { \
return (float)(clip_long(x) & clip_long(y)); \
} \
\
float orSB(float x, float y) { \
return (float)(clip_long(x) | clip_long(y)); \
} \
\
float xorSB(float x, float y) { \
return (float)(clip_long(x) ^ clip_long(y)); \
} \
\
float negateSB(float x) { \
return (float)(~clip_long(x)); \
} \
\
float posshiftSB(float x, float y) { \
return y >= 0 ? (float)(clip_long(x) << clip_long(y)) : (float)(clip_long(x) >> clip_long(-y)); \
} \
\
float negshiftSB(float x, float y) { \
return y >= 0 ? (float)(clip_long(x) >> clip_long(y)) : (float)(clip_long(x) << clip_long(-y)); \
} \
\
";


const char* expr_source = "__kernel void expr(__global uchar *dstp, __global uchar* srcp, int width) { \
int offset = get_global_id(0); \
float x = srcp[offset]; \
dstp[offset] = (uchar)clamp((int)round({{expression}}), 0, 255); \
}";

const char* exprxy_source = "__kernel void expr(__global uchar *dstp, __global uchar* srcp1, __global uchar* srcp2, int width) { \
int offset = get_global_id(0); \
float x = srcp1[offset]; \
float y = srcp2[offset]; \
dstp[offset] = (uchar)clamp((int)round({{expression}}), 0, 255); \
}";

const char* exprxyz_source = "__kernel void expr(__global uchar *dstp, __global uchar* srcp1, __global uchar* srcp2, __global uchar* srcp3, int width) { \
int offset = get_global_id(0); \
float x = srcp1[offset]; \
float y = srcp2[offset]; \
float z = srcp3[offset]; \
dstp[offset] = (uchar)clamp((int)round({{expression}}), 0, 255); \
}";

const char* expr_source_lsb = "__kernel void expr(__global uchar *dstp, __global uchar* srcp, int width, int height) { \
int offset = get_global_id(0); \
float x = ((ushort)srcp[offset] << 8) + ((ushort)srcp[offset+width*height]); \
ushort result = clamp((int)round({{expression}}), 0, 65535); \
dstp[offset] = (uchar)((result >> 8) & 0xFF); \
dstp[offset+width*height] = (uchar)(result & 0xFF); \
}";

const char* exprxy_source_lsb = "__kernel void expr(__global uchar *dstp, __global uchar* srcp1, __global uchar* srcp2, int width, int height) { \
int offset = get_global_id(0); \
float x = ((ushort)srcp1[offset] << 8); + ((ushort)srcp1[offset+width*height]); \
float y = ((ushort)srcp2[offset] << 8) + ((ushort)srcp2[offset+width*height]); \
ushort result = clamp((int)round({{expression}}), 0, 65535); \
dstp[offset] = (uchar)((result >> 8) & 0xFF); \
dstp[offset+width*height] = (uchar)(result & 0xFF); \
}";

const char* exprxyz_source_lsb = "__kernel void expr(__global uchar *dstp, __global uchar* srcp1, __global uchar* srcp2, __global uchar* srcp3, int width, int height) { \
int offset = get_global_id(0); \
float x = ((ushort)srcp1[offset] << 8) + ((ushort)srcp1[offset+width*height]); \
float y = ((ushort)srcp2[offset] << 8) + ((ushort)srcp2[offset+width*height]); \
float z = ((ushort)srcp3[offset] << 8) + ((ushort)srcp3[offset+width*height]); \
ushort result = clamp((int)round({{expression}}), 0, 65535); \
dstp[offset] = (uchar)((result >> 8) & 0xFF); \
dstp[offset+width*height] = (uchar)(result & 0xFF); \
}";

#endif
Loading

0 comments on commit 2677ca2

Please sign in to comment.