MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / partition_mismatch3

Function partition_mismatch3

Source/astcenc_find_best_partitioning.cpp:273–304  ·  view source on GitHub ↗

* @brief Compute bit-mismatch for partitioning in 3-partition mode. * * @param a The texel assignment bitvector for the block. * @param b The texel assignment bitvector for the partition table. * * @return The number of bit mismatches. */

Source from the content-addressed store, hash-verified

271 * @return The number of bit mismatches.
272 */
273static inline uint8_t partition_mismatch3(
274 const uint64_t a[3],
275 const uint64_t b[3]
276) {
277 int p00 = popcount(a[0] ^ b[0]);
278 int p01 = popcount(a[0] ^ b[1]);
279 int p02 = popcount(a[0] ^ b[2]);
280
281 int p10 = popcount(a[1] ^ b[0]);
282 int p11 = popcount(a[1] ^ b[1]);
283 int p12 = popcount(a[1] ^ b[2]);
284
285 int p20 = popcount(a[2] ^ b[0]);
286 int p21 = popcount(a[2] ^ b[1]);
287 int p22 = popcount(a[2] ^ b[2]);
288
289 int s0 = p11 + p22;
290 int s1 = p12 + p21;
291 int v0 = astc::min(s0, s1) + p00;
292
293 int s2 = p10 + p22;
294 int s3 = p12 + p20;
295 int v1 = astc::min(s2, s3) + p01;
296
297 int s4 = p10 + p21;
298 int s5 = p11 + p20;
299 int v2 = astc::min(s4, s5) + p02;
300
301 // Divide by 2 because XOR always counts errors twice, once when missing
302 // in the expected position, and again when present in the wrong partition
303 return static_cast<uint8_t>(astc::min(v0, v1, v2) / 2);
304}
305
306/**
307 * @brief Compute bit-mismatch for partitioning in 4-partition mode.

Callers 1

Calls 2

popcountFunction · 0.70
minFunction · 0.70

Tested by

no test coverage detected