Skip to content

Commit

Permalink
Incapsulate weights
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Evstyukhin committed Apr 3, 2022
1 parent 3b8fbf6 commit 87f9789
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Bc7Compress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,11 @@ int Bc7MainWithArgs(const IBc7Core& bc7Core, const std::vector<std::string>& arg

if (mse_alpha > 0)
{
const double weightAlpha = bc7Core.pGetWeightAlpha();

PRINTF(" SubTexture A qMSE = %.1f, qPSNR = %f, SSIM_4x4 = %.8f",
(1.0 / gWeightAlpha) * mse_alpha / pixels,
10.0 * log((255.0 * 255.0) * gWeightAlpha * pixels / mse_alpha) / log(10.0),
(1.0 / weightAlpha) * mse_alpha / pixels,
10.0 * log((255.0 * 255.0) * weightAlpha * pixels / mse_alpha) / log(10.0),
ssim.Alpha * 16.0 / pixels);
}
else
Expand All @@ -503,9 +505,11 @@ int Bc7MainWithArgs(const IBc7Core& bc7Core, const std::vector<std::string>& arg

if (mse_color > 0)
{
const double weightColor = bc7Core.pGetWeightColor();

PRINTF(" SubTexture RGB qMSE = %.1f, qPSNR = %f, wSSIM_4x4 = %.8f",
(1.0 / gWeightColor) * mse_color / pixels,
10.0 * log((255.0 * 255.0) * gWeightColor * pixels / mse_color) / log(10.0),
(1.0 / weightColor) * mse_color / pixels,
10.0 * log((255.0 * 255.0) * weightColor * pixels / mse_color) / log(10.0),
ssim.Color * 16.0 / pixels);
}
else
Expand Down
13 changes: 13 additions & 0 deletions src/Bc7Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1929,6 +1929,16 @@ static void CompressKernel(const WorkerItem* begin, const WorkerItem* end, int s
}
}

static int GetWeightAlpha() noexcept
{
return gWeightAlpha;
}

static int GetWeightColor() noexcept
{
return gWeightColor;
}

bool GetBc7Core(void* bc7Core)
{
IBc7Core* p = reinterpret_cast<IBc7Core*>(bc7Core);
Expand All @@ -1938,5 +1948,8 @@ bool GetBc7Core(void* bc7Core)
p->pDecompress = &DecompressKernel;
p->pCompress = &CompressKernel;

p->pGetWeightAlpha = &GetWeightAlpha;
p->pGetWeightColor = &GetWeightColor;

return true;
}
4 changes: 4 additions & 0 deletions src/Bc7Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,15 @@ using PInitTables = void(*)(bool doDraft, bool doNormal, bool doSlow, bool linea

using PBlockKernel = void(*)(const WorkerItem* begin, const WorkerItem* end, int stride, int64_t& pErrorAlpha, int64_t& pErrorColor, BlockSSIM& pssim) noexcept;

using PGetWeight = int(*)() noexcept;

struct IBc7Core
{
PInitTables pInitTables;

PBlockKernel pDecompress, pCompress;

PGetWeight pGetWeightAlpha, pGetWeightColor;
};

//bool GetBc7Core(void* bc7Core);

0 comments on commit 87f9789

Please sign in to comment.