diff --git a/src/BC1/BC1Encoder.cpp b/src/BC1/BC1Encoder.cpp index 274b799..267e501 100644 --- a/src/BC1/BC1Encoder.cpp +++ b/src/BC1/BC1Encoder.cpp @@ -41,10 +41,6 @@ namespace rgbcx { using namespace BC1; -using InterpolatorPtr = std::shared_ptr; -using Hash = uint16_t; -using BlockMetrics = Color4x4::BlockMetrics; -using EncodeResults = BC1Encoder::EncodeResults; using ColorMode = BC1Encoder::ColorMode; // constructors @@ -53,8 +49,8 @@ BC1Encoder::BC1Encoder(InterpolatorPtr interpolator) : _interpolator(interpolato Flags::UseFullMSEEval | Flags::TwoLeastSquaresPasses | Flags::UseLikelyTotalOrderings | Flags::Use3ColorBlocks | Flags::Use3ColorBlocksForBlackPixels; _error_mode = ErrorMode::Full; _endpoint_mode = EndpointMode::PCA; - _orderings4 = 16; - _orderings3 = 8; + _orderings4 = 128; + _orderings3 = 32; _search_rounds = 256; OrderTable<3>::Generate(); @@ -143,8 +139,7 @@ void BC1Encoder::EncodeBlock(Color4x4 pixels, BC1Block *dest) const { } // refine endpoints by searching for nearby colors - if (result.error > 0 && _search_rounds > 0) { - EndpointSearch(pixels, result, metrics); + if (result.error > 0 && _search_rounds > 0) { EndpointSearch(pixels, result); } WriteBlock(result, dest); @@ -434,8 +429,8 @@ void BC1Encoder::FindEndpoints(Color4x4 pixels, EncodeResults &block, const Bloc auto val = pixels.Get(i); if (ignore_black && val.IsBlack()) continue; - auto colorVec = Vector4::FromColorRGB(val); - Vector4 diff = colorVec - avg; + auto color_vec = Vector4::FromColorRGB(val); + Vector4 diff = color_vec - avg; for (unsigned c1 = 0; c1 < 3; c1++) { for (unsigned c2 = c1; c2 < 3; c2++) { covariance[c1][c2] += (diff[c1] * diff[c2]); @@ -472,10 +467,10 @@ void BC1Encoder::FindEndpoints(Color4x4 pixels, EncodeResults &block, const Bloc auto val = pixels.Get(i); if (ignore_black && val.IsBlack()) continue; - auto colorVec = Vector4::FromColorRGB(val); + auto color_vec = Vector4::FromColorRGB(val); // since axis is constant here, I dont think its magnitude actually matters, // since we only care about the min or max dot product - float dot = colorVec.Dot(axis); + float dot = color_vec.Dot(axis); if (dot > max_dot) { max_dot = dot; max_index = i; @@ -659,7 +654,7 @@ template void BC1Encoder::RefineEndpointsLS(std::array(sums, trial_result, trial_matrix, trial_hash); - FindSelectors(pixels, trial_result, _error_mode); + FindSelectors(pixels, trial_result, error_mode); } if (trial_result.error < block.error) { block = trial_result; } @@ -748,10 +743,10 @@ void BC1Encoder::RefineBlockCF(Color4x4 &pixels, EncodeResults &block, BlockMetr } } -void BC1Encoder::EndpointSearch(Color4x4 &pixels, EncodeResults &block, BlockMetrics &metrics) const { +void BC1Encoder::EndpointSearch(Color4x4 &pixels, EncodeResults &block) const { if ((bool)(block.color_mode & ColorMode::Solid)) return; - static const std::array voxels = {{ + static const std::array Voxels = {{ {1, 0, 0, 3}, // 0 {0, 1, 0, 4}, // 1 {0, 0, 1, 5}, // 2 @@ -779,7 +774,7 @@ void BC1Encoder::EndpointSearch(Color4x4 &pixels, EncodeResults &block, BlockMet if ((int)(i & 31) == forbidden_direction) continue; - Vector4Int delta = voxels[voxel_index]; + Vector4Int delta = Voxels[voxel_index]; EncodeResults trial_result = block; if (i & 16) { @@ -808,7 +803,7 @@ void BC1Encoder::EndpointSearch(Color4x4 &pixels, EncodeResults &block, BlockMet if (trial_result.error < block.error) { block = trial_result; - forbidden_direction = delta[3] | (i & 16); + forbidden_direction = delta[3] | (int)(i & 16); prev_improvement_index = i; } diff --git a/src/BC1/BC1Encoder.h b/src/BC1/BC1Encoder.h index 17e48fd..332c406 100644 --- a/src/BC1/BC1Encoder.h +++ b/src/BC1/BC1Encoder.h @@ -163,6 +163,6 @@ class BC1Encoder final : public BlockEncoder { template void RefineBlockCF(Color4x4 &pixels, EncodeResults &block, BlockMetrics &metrics, ErrorMode error_mode, unsigned orderings) const; - void EndpointSearch(Color4x4 &pixels, EncodeResults &block, BlockMetrics &metrics) const; + void EndpointSearch(Color4x4 &pixels, EncodeResults &block) const; }; } // namespace rgbcx