-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Maverick Tse
authored and
Maverick Tse
committed
Oct 29, 2016
1 parent
50c5e30
commit b89b49b
Showing
11 changed files
with
621 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "RSigmoidTable.h" | ||
#include <xmmintrin.h> | ||
//#define NOMINMAX | ||
//#include <Windows.h> | ||
|
||
|
||
|
||
RSigmoidTable::RSigmoidTable(float midtone, float strength, int bin, float multiplier) | ||
{ | ||
kstep = static_cast<int>(multiplier / static_cast<float>(bin)); | ||
kmin = kstep / 2; | ||
kmax = kmin + kstep*bin; | ||
|
||
for (int x = kmin; x <= kmax; x += kstep) | ||
{ | ||
float u = static_cast<float>(x) / multiplier; | ||
float a = midtone; | ||
float b = strength; | ||
//float e1, e2, e3, e4; | ||
float result[4]{ 0 }; | ||
result[0] = std::expf(b*(a - u)); | ||
result[1] = std::expf(a*b); | ||
result[2] = std::expf(b*(a - 1)); | ||
result[3] = result[1]; | ||
|
||
__m128 ei = _mm_loadu_ps(result); | ||
__m128 v1 = _mm_set1_ps(1.0f); | ||
__m128 dst = _mm_add_ps(ei, v1); | ||
ei = _mm_div_ps(v1, dst); | ||
|
||
_mm_storeu_ps(result, ei); | ||
float y = (result[0] - result[1]) / (result[2] - result[3]); | ||
y *= multiplier; | ||
table.insert({ static_cast<int>(y), x }); | ||
} | ||
kmin = table.begin()->first; | ||
kmax = table.rbegin()->first; | ||
kstep = (table.begin()++)->first - kmin; | ||
} | ||
|
||
RSigmoidTable::~RSigmoidTable() | ||
{ | ||
table.clear(); | ||
|
||
//MessageBox(NULL, "~RSigTable", "Dtor", MB_OK | MB_ICONINFORMATION); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#pragma once | ||
#include "LUT.h" | ||
class RSigmoidTable : | ||
public LUT | ||
{ | ||
public: | ||
RSigmoidTable(float midtone, float strength, int bin, float multiplier); | ||
~RSigmoidTable(); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.