Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CodeTests/CodeTests/Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,36 @@

//// User Defined
#include "../../Sequencer.h"
void createConstellation()
{

}

void ConstructCString()
{
unsigned char glork[16] = {100, 12, 29, 255,
27, 128, 32, 109,
87, 91, 194, 5};

char *glork2 = "abcdeiulahblivuahrlivghauier7yvao87foa87vff";

std::string tmpstring(reinterpret_cast<char*> (glork));
std::cout << tmpstring << "\n";
std::cout << "Size of glork: " << sizeof(glork) << ". Size of &glork: " << sizeof(&glork) << "\n";
std::cout << "Size of glork2: " << sizeof(glork2) << ". Size of &glork2: " << sizeof(&glork2) << "\n";
}


int main(int argc, char **argv)
{
ConstructCString();

std::string image_filename = "prefix.00000.ext";
std::string out_filename = "prefix_signature.00000.ppm";
Sequencer sequencer(image_filename);



bool tmp = true;
do
{
Expand Down
49 changes: 6 additions & 43 deletions hash_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,14 @@ typedef unsigned long long THash;

namespace hash_generator
{
void make_hash_from_key(const std::string &key_in, THash *hash)
//void make_hash_from_key(const std::string &key_in, THash *hash)
void make_hash_from_key(const unsigned char key_in[], THash *hash)
{
/*std::string buffered_key = key_in;
size_t size = key_in.size();*/

// Add padding that will be removed
// Only for use with texture based HASH lookup
//for (size_t ii = 3; ii < buffered_key.size(); ii += 4)
//{
// buffered_key.insert(ii, ".");
//}


////std::string output = "";
//{
// //uint64_t hash[12];


//uint8_t hash_count = 0;
uint8_t shift_offset = 7;
//uint8_t shift_offset = 7;
uint8_t hash_iter = 0;
for (unsigned int ii = 0; ii < key_in.size(); ii += 8)
unsigned int key_size = sizeof(&key_in) / sizeof(unsigned char);
for (unsigned int ii = 0; ii < key_size; ii += 8)
{
THash tmp = (
(THash)key_in[ii] << 56 |
Expand All @@ -47,32 +33,9 @@ namespace hash_generator
std::cout << std::hex << hash[hash_iter] << std::endl;

hash_iter++;
shift_offset = 7;
//shift_offset = 7;

}


// for (size_t jj = 0; jj < 12; jj++)
// {
// uint64_t tmpmask = 0x0000000000000001;
// uint64_t current_hash = hash[jj];
// for (size_t ll = 0; ll < 64; ll++)
// {
// unsigned char tmp = 255;
// uint64_t masked_hash = tmpmask & current_hash;
// bool flip = masked_hash;

// tmp = (flip) ? 255 : 0;
// output.push_back(tmp);
// tmpmask = tmpmask << 1;
// }

// }
// //memset(hash, 0, 12 * sizeof(*hash));
//}

//
//sdkSavePPM4ub(std::string("NewHash.ppm").c_str(), (unsigned char*)output.c_str(), 16, 16);
//output.clear();
};
}
116 changes: 116 additions & 0 deletions imageDenoising.cu
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,122 @@ __device__ TColor tcolor_plus_tcolor(const TColor &a, const TColor &b)
return make_color_int(ar + br, ag + bg, ab + bb, aa + ba);
}

__device__ void THashAffineLookup(int4 input, THash *lookup, unsigned short orientation, float &r, float &g, float &b)
{
if (orientation == 0 || orientation > 3)
{
THash mask = THash(0x0000000000000001);
int channel_size = 4;
int channel_mult = 0;
int iter = input.x & 3;
THash sub_iter = input.x - (iter * 64);
THash mask_r = mask << sub_iter;
r = (mask_r & lookup[iter + (channel_mult*channel_size)]) * 255.0f;

mask = THash(0x0000000000000001);
channel_mult = 1;
iter = input.y & 3;
sub_iter = input.y - (iter * 64);
mask_r = mask << sub_iter;
g = (mask_r & lookup[iter + (channel_mult*channel_size)]) * 255.0f;

mask = THash(0x0000000000000001);
channel_mult = 2;
iter = input.z & 3;
sub_iter = input.z - (iter * 64);
mask_r = mask << sub_iter;
b = (mask_r & lookup[iter + (channel_mult*channel_size)]) * 255.0f;
}
else if (orientation == 1)
{
THash mask = THash(0x0000000000000001);

//remap inputs
int3 _in;
_in.x = (16 * (input.x & 15)) + (input.x & 15);
_in.y = (16 * (input.y & 15)) + (input.y & 15);
_in.z = (16 * (input.z & 15)) + (input.z & 15);

int channel_size = 4;
int channel_mult = 0;
int iter = _in.x & 3;
THash sub_iter = _in.x - (iter * 64);
THash mask_r = mask << sub_iter;
r = (mask_r & lookup[iter + (channel_mult*channel_size)]) * 255.0f;

mask = THash(0x0000000000000001);
channel_mult = 1;
iter = _in.y & 3;
sub_iter = _in.y - (iter * 64);
mask_r = mask << sub_iter;
g = (mask_r & lookup[iter + (channel_mult*channel_size)]) * 255.0f;

mask = THash(0x0000000000000001);
channel_mult = 2;
iter = _in.z & 3;
sub_iter = _in.z - (iter * 64);
mask_r = mask << sub_iter;
b = (mask_r & lookup[iter + (channel_mult*channel_size)]) * 255.0f;


}
else if (orientation == 2)
{
THash mask = THash(0x8000000000000000);
int channel_size = 4;
int channel_mult = 0;
int iter = 3 - (input.x & 3);
THash sub_iter = 64 - (input.x - (iter * 64));
THash mask_r = mask >> sub_iter;
r = (mask_r & lookup[iter + (channel_mult*channel_size)]) * 255.0f;

mask = THash(0x8000000000000000);
channel_mult = 1;
iter = 3 - (input.y & 3);
sub_iter = 64 - (input.y - (iter * 64));
mask_r = mask >> sub_iter;
g = (mask_r & lookup[iter + (channel_mult*channel_size)]) * 255.0f;

mask = THash(0x8000000000000000);
channel_mult = 2;
iter = 3 - (input.z & 3);
sub_iter = 64 - (input.z - (iter * 64));
mask_r = mask >> sub_iter;
b = (mask_r & lookup[iter + (channel_mult*channel_size)]) * 255.0f;
}
else
{
THash mask = THash(0x8000000000000000);

//remap inputs
int3 _in;
_in.x = (16 * (input.x & 15)) + (input.x & 15);
_in.y = (16 * (input.y & 15)) + (input.y & 15);
_in.z = (16 * (input.z & 15)) + (input.z & 15);

int channel_size = 4;
int channel_mult = 0;
int iter = _in.x & 3;
THash sub_iter = _in.x - (iter * 64);
THash mask_r = mask >> sub_iter;
r = (mask_r & lookup[iter + (channel_mult*channel_size)]) * 255.0f;

mask = THash(0x8000000000000000);
channel_mult = 1;
iter = _in.y & 3;
sub_iter = _in.y - (iter * 64);
mask_r = mask >> sub_iter;
g = (mask_r & lookup[iter + (channel_mult*channel_size)]) * 255.0f;

mask = THash(0x8000000000000000);
channel_mult = 2;
iter = _in.z & 3;
sub_iter = _in.z - (iter * 64);
mask_r = mask >> sub_iter;
b = (mask_r & lookup[iter + (channel_mult*channel_size)]) * 255.0f;
}
}




Expand Down
6 changes: 4 additions & 2 deletions imageDenoisingGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,10 @@ int main(int argc, char **argv)

// Create Memory for Running Signature
// CUDA Malloc Array
/*std::string unique_key = "Saturday 2019-08 August-31__08:46:32.38948-pm Pacific Daylight time-phoneid:xxxxxxxxxxx-xxxxxxxx";*/
std::string unique_key = "Saturday 2117-12 Decemb-25__21:13:56.48204-am Eastern Standard Time -phone:id:309uIUHkj??iusdHbx";
//std::string unique_key = "Saturday 2019-08 August-31__08:46:32.38948-pm Pacific Daylight time-phoneid:xxxxxxxxxxx-xxxxxxxx";
unsigned char unique_key[96] = "Saturday 2019-08 August-31__08:46:32.38948-pm Pacific Daylight time-phoneid:xxxxxxxxxx-xxxxxxxx";
//std::string unique_key = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
//std::string unique_key = "Saturday \n\t\v\b\r\f\a\\\'\"~emb-25__21:13:56.482!@#$%^&*(){}:\"<>?ndard Time -phone:id:309uIUHkj??iusdHbx";
THash *hash = (THash*)malloc(sizeof(THash) * 12);
hash_generator::make_hash_from_key(unique_key, hash);

Expand Down
34 changes: 15 additions & 19 deletions imageDenoising_hasher_kernel.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -201,25 +201,21 @@ __global__ void TimeHASH_UINT(
fIntResult.y = __float2int_rz(fresult.y * 255.0f);
fIntResult.z = __float2int_rz(fresult.z * 255.0f);

THash mask = THash(0x0000000000000001);
int channel_size = 4;
int channel_mult = 0;
int iter = fIntResult.x & 3;
int sub_iter = fIntResult.x - (iter * 64);
THash mask_r = mask << sub_iter;
float hr = (mask_r & hash[iter + (channel_mult*channel_size)]) * 255.0f;

channel_mult = 1;
iter = fIntResult.y & 3;
sub_iter = fIntResult.y - (iter * 64);
mask_r = mask << sub_iter;
float hg = (mask_r & hash[iter + (channel_mult*channel_size)]) * 255.0f;

channel_mult = 2;
iter = fIntResult.z & 3;
sub_iter = fIntResult.z - (iter * 64);
mask_r = mask << sub_iter;
float hb = (mask_r & hash[iter + (channel_mult*channel_size)]) * 255.0f;
float hr, hg, hb;
//unsigned short orientation = (ix&1 && iy&1)? 0 : (!ix&1 && iy&1)? 1 : (!ix&1 && !iy&1)? 2 : 3 ;
unsigned short orientation = 0;
int _ixi, _iyi;
_ixi = __float2int_rz(ix);
_iyi = __float2int_rz(iy);
if ((_ixi & 1) == 1 && (_iyi & 1) == 1)
orientation = 0;
else if ((_ixi & 1) == 1 && (_iyi & 1) == 0)
orientation = 1;
else if ((_ixi & 1) == 0 && (_iyi & 1) == 0)
orientation = 2;
else
orientation = 3;
THashAffineLookup(fIntResult, hash, orientation, hr, hg, hb);



Expand Down
6 changes: 6 additions & 0 deletions imageDenoising_vs2015.vcxproj.andrew britton.nvuser
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ProjectSettingsModel DefinitionId="a218e900-1199-4ab1-a767-7976786f04d4" DisplayName="Nexus Project User Settings" xmlns="clr-namespace:Ark.PropertyModel;assembly=Ark">
<SettingsPointModel DefinitionId="3eb7ba04-016d-475e-b0ff-daa5f0e59a08" DisplayName="Launch">
<Property Name="ConnectionName" Value="DESKTOP-0DT9AHF" />
<Property Name="LaunchSettingsModifiedByUser" Value="True" />
</SettingsPointModel>
</ProjectSettingsModel>