mirror of
https://github.com/drewcassidy/quicktex.git
synced 2024-09-13 06:37:34 +00:00
IWYU pass
This commit is contained in:
parent
d0e66b31f7
commit
05af708e84
@ -19,23 +19,22 @@
|
||||
|
||||
#include "BC1Encoder.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
#include "../BlockView.h"
|
||||
#include "../Color.h"
|
||||
#include "../Interpolator.h"
|
||||
#include "../Matrix4x4.h"
|
||||
#include "../Vector4.h"
|
||||
#include "../Vector4Int.h"
|
||||
#include "../bitwiseEnums.h"
|
||||
#include "../util.h"
|
||||
#include "Histogram.h"
|
||||
#include "OrderTable.h"
|
||||
#include "SingleColorTable.h"
|
||||
|
||||
@ -288,6 +287,7 @@ void BC1Encoder::FindEndpoints(Color4x4 pixels, EncodeResults &block, const Bloc
|
||||
uint8_t hr6 = scale8To6(metrics.max.r);
|
||||
|
||||
block.low = Color(lr5, lr6, lr5);
|
||||
block.high = Color(hr5, hr6, hr5);
|
||||
}
|
||||
} else if (endpoint_mode == EndpointMode::LeastSquares) {
|
||||
// 2D Least Squares approach from Humus's example, with added inset and optimal rounding.
|
||||
@ -297,7 +297,6 @@ void BC1Encoder::FindEndpoints(Color4x4 pixels, EncodeResults &block, const Bloc
|
||||
|
||||
auto &sums = metrics.sums;
|
||||
auto &min = metrics.min;
|
||||
auto &max = metrics.max;
|
||||
|
||||
unsigned chan0 = (unsigned)diff.MaxChannelRGB(); // primary axis of the bounding box
|
||||
l[chan0] = (float)min[chan0];
|
||||
@ -312,8 +311,8 @@ void BC1Encoder::FindEndpoints(Color4x4 pixels, EncodeResults &block, const Bloc
|
||||
for (unsigned c = 0; c < 3; c++) { sums_xy[c] += val[chan0] * val[c]; }
|
||||
}
|
||||
|
||||
const auto &sum_x = sums[chan0];
|
||||
const auto &sum_xx = sums_xy[chan0];
|
||||
const unsigned sum_x = (unsigned)sums[chan0];
|
||||
const unsigned sum_xx = sums_xy[chan0];
|
||||
|
||||
float denominator = (float)(16 * sum_xx) - (float)(sum_x * sum_x);
|
||||
|
||||
@ -326,9 +325,9 @@ void BC1Encoder::FindEndpoints(Color4x4 pixels, EncodeResults &block, const Bloc
|
||||
* a = (m∑xy - ∑x∑y) / m∑x² - (∑x)²
|
||||
* b = (∑x²∑y - ∑xy∑x) / m∑x² - (∑x)²
|
||||
* see Giordano/Weir pg.103 */
|
||||
const auto chan = (chan0 + i) % 3;
|
||||
const auto &sum_y = sums[chan];
|
||||
const auto &sum_xy = sums_xy[chan];
|
||||
const unsigned chan = (chan0 + i) % 3;
|
||||
const unsigned sum_y = (unsigned)sums[chan];
|
||||
const unsigned sum_xy = sums_xy[chan];
|
||||
|
||||
float a = (float)((16 * sum_xy) - (sum_x * sum_y)) / denominator;
|
||||
float b = (float)((sum_xx * sum_y) - (sum_xy * sum_x)) / denominator;
|
||||
@ -709,9 +708,8 @@ void BC1Encoder::RefineBlockCF(Color4x4 &pixels, EncodeResults &block, BlockMetr
|
||||
sums[i + 1] = sums[i] + color_vectors[p];
|
||||
}
|
||||
|
||||
const Hash q_total = ((_flags & Flags::Exhaustive) != Flags::None) ? OrderTable::OrderCount : orderings;
|
||||
const unsigned q_total = ((_flags & Flags::Exhaustive) != Flags::None) ? OrderTable::OrderCount : orderings;
|
||||
for (Hash q = 0; q < q_total; q++) {
|
||||
|
||||
Hash trial_hash = ((_flags & Flags::Exhaustive) != Flags::None) ? q : OrderTable::BestOrders[start_hash][q];
|
||||
Vector4 trial_matrix = OrderTable::GetFactors(trial_hash);
|
||||
|
||||
|
@ -20,21 +20,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <climits>
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
|
||||
#include "../BlockEncoder.h"
|
||||
#include "../BlockView.h"
|
||||
#include "../Interpolator.h"
|
||||
#include "../bitwiseEnums.h"
|
||||
#include "../ndebug.h"
|
||||
#include "../Color.h"
|
||||
#include "BC1Block.h"
|
||||
#include "OrderTable.h"
|
||||
#include "SingleColorTable.h"
|
||||
#include "Tables.h"
|
||||
|
||||
namespace rgbcx {
|
||||
class Interpolator;
|
||||
class Vector4;
|
||||
|
||||
class BC1Encoder final : public BlockEncoder<BC1Block, 4, 4> {
|
||||
public:
|
||||
@ -163,6 +161,6 @@ class BC1Encoder final : public BlockEncoder<BC1Block, 4, 4> {
|
||||
|
||||
template <ColorMode M> void RefineBlockLS(Color4x4 &pixels, EncodeResults &block, BlockMetrics &metrics, ErrorMode error_mode, unsigned passes) const;
|
||||
|
||||
template<ColorMode M> void RefineBlockCF(Color4x4 &pixels, EncodeResults &block, BlockMetrics &metrics, ErrorMode error_mode, unsigned orderings) const;
|
||||
template <ColorMode M> void RefineBlockCF(Color4x4 &pixels, EncodeResults &block, BlockMetrics &metrics, ErrorMode error_mode, unsigned orderings) const;
|
||||
};
|
||||
} // namespace rgbcx
|
||||
|
@ -72,7 +72,7 @@ template <size_t N> class Histogram {
|
||||
|
||||
unsigned GetPacked() const {
|
||||
unsigned packed = 0;
|
||||
for (unsigned i = 0; i < (N - 1); i++) { packed |= (_bins[i] << (4 * i)); }
|
||||
for (unsigned i = 0; i < (N - 1); i++) { packed |= (_bins[i] << (4U * i)); }
|
||||
|
||||
// assert(packed < HashCount);
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <array>
|
||||
|
||||
#include "../Vector4.h"
|
||||
#include "Histogram.h"
|
||||
|
||||
namespace rgbcx {
|
||||
using Hash = uint16_t;
|
||||
|
@ -21,14 +21,12 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
#include <numeric>
|
||||
|
||||
#include "../Vector4.h"
|
||||
#include "../util.h"
|
||||
#include "Histogram.h"
|
||||
#include "Tables.h"
|
||||
|
||||
namespace rgbcx {
|
||||
template <size_t N> class Histogram;
|
||||
@ -106,7 +104,7 @@ template <size_t N> class OrderTable {
|
||||
}
|
||||
|
||||
static Vector4 GetFactors(Hash hash) {
|
||||
assert(generated);
|
||||
assert(generated.load());
|
||||
assert(factors != nullptr);
|
||||
|
||||
return factors->at(hash);
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <climits>
|
||||
#include <cstdint>
|
||||
|
||||
#include "BlockView.h"
|
||||
|
||||
@ -59,11 +59,7 @@ template <class B, size_t M, size_t N> class BlockEncoder {
|
||||
assert(pixel_x + N <= image_width);
|
||||
|
||||
unsigned top_left = pixel_x + (pixel_y * image_width);
|
||||
auto src = DecodedBlock(&decoded[top_left], image_width);
|
||||
|
||||
if (pixel_x == 272 && pixel_y == 748) {
|
||||
int foo = 3;
|
||||
}
|
||||
auto src = DecodedBlock(&decoded[top_left], (int)image_width);
|
||||
|
||||
EncodeBlock(src, &blocks[x + block_width * y]);
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ template <size_t M, size_t N> class ColorBlockView : public BlockView<Color, M,
|
||||
metrics.has_black |= (val.r | val.g | val.b < black_threshold);
|
||||
}
|
||||
|
||||
for (unsigned c = 0; c < 3; c++) { metrics.avg[c] = (uint8_t)(metrics.sums[c] / (M * N)); }
|
||||
for (unsigned c = 0; c < 3; c++) { metrics.avg[c] = (uint8_t)((unsigned)metrics.sums[c] / (M * N)); }
|
||||
|
||||
return metrics;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class Vector4Int {
|
||||
return _c[index];
|
||||
}
|
||||
|
||||
operator Vector4() const { return Vector4(_c[0], _c[1], _c[2], _c[3]); }
|
||||
operator Vector4() const { return Vector4((float)_c[0], (float)_c[1], (float)_c[2], (float)_c[3]); }
|
||||
|
||||
friend Vector4Int operator+(const Vector4Int &lhs, const Vector4Int &rhs) { return DoOp(lhs, rhs, std::plus()); }
|
||||
friend Vector4Int operator-(const Vector4Int &lhs, const Vector4Int &rhs) { return DoOp(lhs, rhs, std::minus()); }
|
||||
|
Loading…
Reference in New Issue
Block a user