Simplified code by using unsigned int instead of union

This commit is contained in:
Andrew Murray 2022-05-01 22:33:49 +10:00
parent 31800a0213
commit b299d7cfc2

View File

@ -1519,7 +1519,7 @@ error_0:
typedef struct { typedef struct {
Pixel new; Pixel new;
Pixel furthest; uint32_t furthestV;
uint32_t furthestDistance; uint32_t furthestDistance;
int secondPixel; int secondPixel;
} DistanceData; } DistanceData;
@ -1536,7 +1536,7 @@ compute_distances(const HashTable *h, const Pixel pixel, uint32_t *dist, void *u
} }
if (oldDist > data->furthestDistance) { if (oldDist > data->furthestDistance) {
data->furthestDistance = oldDist; data->furthestDistance = oldDist;
data->furthest.v = pixel.v; data->furthestV = pixel.v;
} }
} }
@ -1579,8 +1579,8 @@ quantize2(
data.furthestDistance = 0; data.furthestDistance = 0;
data.secondPixel = (i == 1) ? 1 : 0; data.secondPixel = (i == 1) ? 1 : 0;
hashtable_foreach_update(h, compute_distances, &data); hashtable_foreach_update(h, compute_distances, &data);
p[i].v = data.furthest.v; p[i].v = data.furthestV;
data.new.v = data.furthest.v; data.new.v = data.furthestV;
} }
hashtable_free(h); hashtable_free(h);