Skip to content

Commit

Permalink
Cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
HolyWu committed Aug 4, 2019
1 parent feb2319 commit 6de8502
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 130 deletions.
113 changes: 55 additions & 58 deletions DFTTest/DFTTest.cpp

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions DFTTest/DFTTest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ struct DFTTestData {
std::unordered_map<std::thread::id, VSFrameRef *> ebuff;
std::unordered_map<std::thread::id, float *> dftr;
std::unordered_map<std::thread::id, fftwf_complex *> dftc, dftc2;
void (*copyPad)(const VSFrameRef *, VSFrameRef *[3], const DFTTestData *, const VSAPI *) noexcept;
void (*copyPad)(const VSFrameRef *, VSFrameRef * [3], const DFTTestData *, const VSAPI *) noexcept;
void (*filterCoeffs)(float *, const float *, const int, const float *, const float *, const float *) noexcept;
void (*func_0)(VSFrameRef *[3], VSFrameRef *, const DFTTestData *, const VSAPI *) noexcept;
void (*func_1)(VSFrameRef *[15][3], VSFrameRef *, const int, const DFTTestData *, const VSAPI *) noexcept;
void (*func_0)(VSFrameRef * [3], VSFrameRef *, const DFTTestData *, const VSAPI *) noexcept;
void (*func_1)(VSFrameRef * [15][3], VSFrameRef *, const int, const DFTTestData *, const VSAPI *) noexcept;
};
58 changes: 10 additions & 48 deletions DFTTest/DFTTest.vcxproj
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<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">
<UseNativeEnvironment>true</UseNativeEnvironment>
<VCProjectVersion>15.0</VCProjectVersion>
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{23B9F54B-763D-491C-A201-657918CD1377}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>DFTTest</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>Intel C++ Compiler 18.0</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>Intel C++ Compiler 18.0</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand All @@ -38,47 +27,21 @@
</ImportGroup>
<ImportGroup Label="Shared">
</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)'=='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>C:\Program Files %28x86%29\VapourSynth\sdk\include\vapoursynth;C:\fftw-3.3.5-dll32;$(IncludePath)</IncludePath>
<LibraryPath>C:\fftw-3.3.5-dll32;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>C:\Program Files %28x86%29\VapourSynth\sdk\include\vapoursynth;C:\fftw-3.3.5-dll64;$(IncludePath)</IncludePath>
<LibraryPath>C:\fftw-3.3.5-dll64;$(LibraryPath)</LibraryPath>
<IncludePath>C:\Program Files\VapourSynth\sdk\include\vapoursynth;C:\fftw-3.3.8-dll64;$(IncludePath)</IncludePath>
<LibraryPath>C:\fftw-3.3.8-dll64;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>VS_TARGET_CPU_X86;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeedHighLevel</Optimization>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FloatingPointModel>Fast</FloatingPointModel>
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
<EnableAnsiAliasing>true</EnableAnsiAliasing>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libfftw3f-3.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PreprocessorDefinitions>VS_TARGET_CPU_X86;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>VS_TARGET_CPU_X86;_CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeedHighLevel</Optimization>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FloatingPointModel>Fast</FloatingPointModel>
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
<EnableAnsiAliasing>true</EnableAnsiAliasing>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<BufferSecurityCheck>false</BufferSecurityCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -90,7 +53,6 @@
<ItemGroup>
<ClCompile Include="DFTTest.cpp" />
<ClCompile Include="DFTTest_AVX2.cpp">
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
</ClCompile>
<ClCompile Include="DFTTest_SSE2.cpp" />
Expand Down
2 changes: 1 addition & 1 deletion DFTTest/DFTTest.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
Expand Down
4 changes: 2 additions & 2 deletions DFTTest/DFTTest_AVX2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ inline void proc0(const float * _s0, const float * _s1, float * d, const int p0,
for (int v = 0; v < p1; v += 8) {
const Vec8f s0 = Vec8f().load(_s0 + v);
const Vec8f s1 = Vec8f().load(_s1 + v);
(s0 * 255.f * s1).store(d + v);
(s0 * 255.0f * s1).store(d + v);
}

_s0 += p0;
Expand Down Expand Up @@ -241,7 +241,7 @@ void cast(const float * ebp, float * dstp, const int dstWidth, const int dstHeig
for (int y = 0; y < dstHeight; y++) {
for (int x = 0; x < dstWidth; x += 8) {
const Vec8f srcp = Vec8f().load(ebp + x);
(srcp * (1.f / 255.f)).stream(dstp + x);
(srcp * (1.0f / 255.0f)).stream(dstp + x);
}

ebp += ebpStride;
Expand Down
4 changes: 2 additions & 2 deletions DFTTest/DFTTest_SSE2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ inline void proc0(const float * _s0, const float * _s1, float * d, const int p0,
for (int v = 0; v < p1; v += 4) {
const Vec4f s0 = Vec4f().load(_s0 + v);
const Vec4f s1 = Vec4f().load(_s1 + v);
(s0 * 255.f * s1).store(d + v);
(s0 * 255.0f * s1).store(d + v);
}

_s0 += p0;
Expand Down Expand Up @@ -330,7 +330,7 @@ void cast(const float * ebp, float * dstp, const int dstWidth, const int dstHeig
for (int y = 0; y < dstHeight; y++) {
for (int x = 0; x < dstWidth; x += 4) {
const Vec4f srcp = Vec4f().load(ebp + x);
(srcp * (1.f / 255.f)).stream(dstp + x);
(srcp * (1.0f / 255.0f)).stream(dstp + x);
}

ebp += ebpStride;
Expand Down
19 changes: 15 additions & 4 deletions DFTTest/vectorclass/vectori128.h
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,11 @@ static inline Vec16uc min(Vec16uc const & a, Vec16uc const & b) {
return _mm_min_epu8(a,b);
}

// function avg: (a + b + 1) >> 1
static inline Vec16uc avg(Vec16uc const & a, Vec16uc const & b) {
return _mm_avg_epu8(a,b);
}



/*****************************************************************************
Expand Down Expand Up @@ -1977,6 +1982,11 @@ static inline Vec8us min(Vec8us const & a, Vec8us const & b) {
#endif
}

// function avg: (a + b + 1) >> 1
static inline Vec8us avg(Vec8us const & a, Vec8us const & b) {
return _mm_avg_epu16(a,b);
}



/*****************************************************************************
Expand Down Expand Up @@ -5355,10 +5365,11 @@ static inline Vec8us compress_saturated_s2u (Vec4i const & low, Vec4i const & hi
#if INSTRSET >= 5 // SSE4.1 supported
return _mm_packus_epi32(low,high); // this instruction saturates from signed 32 bit to unsigned 16 bit
#else
__m128i signbit = _mm_set1_epi32(0x8000);
__m128i low1 = _mm_sub_epi32(low,signbit);
__m128i high1 = _mm_sub_epi32(high,signbit);
return _mm_xor_si128(_mm_packs_epi32(low1,high1),_mm_set1_epi16(-0x8000));
__m128i val_32 = _mm_set1_epi32(0x8000);
__m128i val_16 = _mm_set1_epi16(0x8000);
__m128i low1 = _mm_sub_epi32(low,val_32);
__m128i high1 = _mm_sub_epi32(high,val_32);
return _mm_add_epi16(_mm_packs_epi32(low1,high1),val_16);
#endif
}

Expand Down
10 changes: 10 additions & 0 deletions DFTTest/vectorclass/vectori256.h
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,11 @@ static inline Vec32uc min(Vec32uc const & a, Vec32uc const & b) {
return _mm256_min_epu8(a,b);
}

// function avg: (a + b + 1) >> 1
static inline Vec32uc avg(Vec32uc const & a, Vec32uc const & b) {
return _mm256_avg_epu8(a,b);
}



/*****************************************************************************
Expand Down Expand Up @@ -1793,6 +1798,11 @@ static inline Vec16us min(Vec16us const & a, Vec16us const & b) {
return _mm256_min_epu16(a,b);
}

// function avg: (a + b + 1) >> 1
static inline Vec16us avg(Vec16us const & a, Vec16us const & b) {
return _mm256_avg_epu16(a,b);
}


/*****************************************************************************
*
Expand Down
11 changes: 5 additions & 6 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Expand Down Expand Up @@ -290,8 +290,8 @@ to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

{description}
Copyright (C) {year} {fullname}
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -329,12 +329,11 @@ necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.

{signature of Ty Coon}, 1 April 1989
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Ported from AviSynth plugin http://bengal.missouri.edu/~kes25c/
Usage
=====

dfttest.DFTTest(clip clip[, int ftype=0, float sigma=8.0, float sigma2=8.0, float pmin=0.0, float pmax=500.0, int sbsize=16, int smode=1, int sosize=12, int tbsize=3, int tmode=0, int tosize=0, int swin=0, int twin=7, float sbeta=2.5, float tbeta=2.5, bint zmean=True, float f0beta=1.0, string nstring='', string sstring='', string ssx='', string ssy='', string sst='', int[] planes, int opt=0])
dfttest.DFTTest(clip clip[, int ftype=0, float sigma=8.0, float sigma2=8.0, float pmin=0.0, float pmax=500.0, int sbsize=16, int smode=1, int sosize=12, int tbsize=3, int tmode=0, int tosize=0, int swin=0, int twin=7, float sbeta=2.5, float tbeta=2.5, bint zmean=True, float f0beta=1.0, string nstring='', string sstring='', string ssx='', string ssy='', string sst='', int[] planes=[0, 1, 2], int opt=0])

```
clip -
Expand Down Expand Up @@ -238,8 +238,8 @@ sstring/ssx/ssy/sst -
sstring = "0.0:0.0 0.15:10.0 0.85:10.0 1.0:0.0"
There are two methods for computing sigma values for a given frequency bin based on
sstring. The first computes the normalized frequency location of each dimension
(horizontal,vertical,temporal), interpolates sigma for each of those dimensions,
sstring. The first computes the normalized frequency location of each dimension
(horizontal,vertical,temporal), interpolates sigma for each of those dimensions,
and then multiples the individual sigmas to obtain the final sigma value. So that
everything scales correctly, all sigma values entered in sstring are first raised to
the 1/#_dimensions power before performing linear interpolation and multiplying.
Expand All @@ -257,13 +257,13 @@ sstring/ssx/ssy/sst -
---------------- ssx/ssy/sst explanation -------------------------------
sstring breaks the 1D (sbsize=1), 2D (for tbsize=1), or 3D (for sbsize>1 and tbsize>1)
sstring breaks the 1D (sbsize=1), 2D (for tbsize=1), or 3D (for sbsize>1 and tbsize>1)
frequency spectrum into chunks by normalizing each dimension to [0.0,1.0]... i.e. the
frequency range [0.0,0.25] is a cube covering the first 1/4 of each dimension. This works
fine if you want to treat all dimensions the same in terms of how sigma should vary.
However, if you wanted to ramp sigma based only on temporal frequency or horizontal
frequency, this is too limited. This is where ssx/ssy/sst come in!
ssx/ssy/sst allow you to specify sigma as a function of horizontal (ssx), vertical (ssy),
and temporal (sst) frequency only. The syntax is exactly the same as that of sstring. To
get the final sigma value for a frequency location, the three separate values (one for
Expand Down Expand Up @@ -294,7 +294,7 @@ sstring/ssx/ssy/sst -
planes -
A list of the planes to process. By default all planes are processed.
Sets which planes will be processed. Any unprocessed planes will be simply copied.
opt -
Expand Down

0 comments on commit 6de8502

Please sign in to comment.