mirror of
https://github.com/drewcassidy/quicktex.git
synced 2024-09-13 06:37:34 +00:00
Fix min/max in block metrics
This commit is contained in:
parent
265a41bc2e
commit
4d3a0c0b61
@ -102,7 +102,7 @@ template <size_t S> void PrepSingleColorTable(MatchList &match_table, MatchList
|
||||
BC1Encoder::BC1Encoder(InterpolatorPtr interpolator) : _interpolator(interpolator) {
|
||||
PrepSingleColorTable<5>(*_single_match5, *_single_match5_half, *_interpolator);
|
||||
PrepSingleColorTable<6>(*_single_match6, *_single_match6_half, *_interpolator);
|
||||
_flags = Flags::None;
|
||||
_flags = Flags::BoundingBoxInt;
|
||||
}
|
||||
|
||||
void BC1Encoder::EncodeBlock(Color4x4 pixels, BC1Block *dest) const {
|
||||
@ -230,11 +230,12 @@ void encode_bc1_pick_initial(const Color *pSrc_pixels, uint32_t flags, bool gray
|
||||
void BC1Encoder::FindEndpoints(Color4x4 pixels, BC1Encoder::Flags flags, const BC1Encoder::BlockMetrics metrics, Color &low, Color &high) const {
|
||||
int lr, lg, lb, hr, hg, hb;
|
||||
auto colors = pixels.Flatten();
|
||||
encode_bc1_pick_initial(&colors[0], 0, metrics.is_greyscale, metrics.min.r, metrics.min.g, metrics.min.b, metrics.max.r, metrics.max.g, metrics.max.b,
|
||||
metrics.avg.r, metrics.avg.g, metrics.avg.b, metrics.sums[0], metrics.sums[1], metrics.sums[2], lr, lg, lb, hr, hg, hb);
|
||||
encode_bc1_pick_initial(&colors[0], (uint32_t)_flags, metrics.is_greyscale, metrics.min.r, metrics.min.g, metrics.min.b, metrics.max.r, metrics.max.g,
|
||||
metrics.max.b, metrics.avg.r, metrics.avg.g, metrics.avg.b, metrics.sums[0], metrics.sums[1], metrics.sums[2], lr, lg, lb, hr, hg,
|
||||
hb);
|
||||
low = Color(lr, lg, lb);
|
||||
high = Color(hr, hg, hb);
|
||||
// return;
|
||||
return;
|
||||
|
||||
if (metrics.is_greyscale) {
|
||||
// specialized greyscale case
|
||||
|
@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
@ -140,11 +141,8 @@ template <size_t M, size_t N> class ColorBlockView : public BlockView<Color, M,
|
||||
for (unsigned i = 0; i < M * N; i++) {
|
||||
auto val = Base::Get(i);
|
||||
for (unsigned c = 0; c < 3; c++) {
|
||||
if (val[c] < metrics.min[c]) {
|
||||
metrics.min[c] = val[c];
|
||||
} else {
|
||||
metrics.max[c] = val[c];
|
||||
}
|
||||
metrics.min[c] = std::min(metrics.min[c], val[c]);
|
||||
metrics.max[c] = std::max(metrics.max[c], val[c]);
|
||||
metrics.sums[c] += val[c];
|
||||
}
|
||||
metrics.is_greyscale &= ((val.r == val.g) && (val.r == val.b));
|
||||
|
Loading…
Reference in New Issue
Block a user