* @brief Compute bit-mismatch for partitioning in 4-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. */
| 312 | * @return The number of bit mismatches. |
| 313 | */ |
| 314 | static inline uint8_t partition_mismatch4( |
| 315 | const uint64_t a[4], |
| 316 | const uint64_t b[4] |
| 317 | ) { |
| 318 | int p00 = popcount(a[0] ^ b[0]); |
| 319 | int p01 = popcount(a[0] ^ b[1]); |
| 320 | int p02 = popcount(a[0] ^ b[2]); |
| 321 | int p03 = popcount(a[0] ^ b[3]); |
| 322 | |
| 323 | int p10 = popcount(a[1] ^ b[0]); |
| 324 | int p11 = popcount(a[1] ^ b[1]); |
| 325 | int p12 = popcount(a[1] ^ b[2]); |
| 326 | int p13 = popcount(a[1] ^ b[3]); |
| 327 | |
| 328 | int p20 = popcount(a[2] ^ b[0]); |
| 329 | int p21 = popcount(a[2] ^ b[1]); |
| 330 | int p22 = popcount(a[2] ^ b[2]); |
| 331 | int p23 = popcount(a[2] ^ b[3]); |
| 332 | |
| 333 | int p30 = popcount(a[3] ^ b[0]); |
| 334 | int p31 = popcount(a[3] ^ b[1]); |
| 335 | int p32 = popcount(a[3] ^ b[2]); |
| 336 | int p33 = popcount(a[3] ^ b[3]); |
| 337 | |
| 338 | int mx23 = astc::min(p22 + p33, p23 + p32); |
| 339 | int mx13 = astc::min(p21 + p33, p23 + p31); |
| 340 | int mx12 = astc::min(p21 + p32, p22 + p31); |
| 341 | int mx03 = astc::min(p20 + p33, p23 + p30); |
| 342 | int mx02 = astc::min(p20 + p32, p22 + p30); |
| 343 | int mx01 = astc::min(p21 + p30, p20 + p31); |
| 344 | |
| 345 | int v0 = p00 + astc::min(p11 + mx23, p12 + mx13, p13 + mx12); |
| 346 | int v1 = p01 + astc::min(p10 + mx23, p12 + mx03, p13 + mx02); |
| 347 | int v2 = p02 + astc::min(p11 + mx03, p10 + mx13, p13 + mx01); |
| 348 | int v3 = p03 + astc::min(p11 + mx02, p12 + mx01, p10 + mx12); |
| 349 | |
| 350 | // Divide by 2 because XOR always counts errors twice, once when missing |
| 351 | // in the expected position, and again when present in the wrong partition |
| 352 | return static_cast<uint8_t>(astc::min(v0, v1, v2, v3) / 2); |
| 353 | } |
| 354 | |
| 355 | using mismatch_dispatch = unsigned int (*)(const uint64_t*, const uint64_t*); |
| 356 |
no test coverage detected