Precompute right-shift and reciprocal multiplier for AA division. Converts 32-bit AA division: (diff * 255u) / band (~60 cycles on AVR) into a multiply-by-reciprocal: ((diff >> shift) * inv) >> 8 (~14 cycles on AVR) where inv = round(255 * 256 / scaled).
| 207 | /// into a multiply-by-reciprocal: ((diff >> shift) * inv) >> 8 (~14 cycles on AVR) |
| 208 | /// where inv = round(255 * 256 / scaled). |
| 209 | inline void computeBandShift(fl::i32 band, fl::u8 &shift_out, fl::u16 &inv_out) { |
| 210 | fl::u8 sh = 0; |
| 211 | fl::u32 tmp = static_cast<fl::u32>(band); |
| 212 | while (tmp > 255u) { tmp >>= 1; ++sh; } |
| 213 | shift_out = sh; |
| 214 | // Reciprocal: (255 * 256 + scaled/2) / scaled — rounds to nearest |
| 215 | fl::u8 scaled = static_cast<fl::u8>(tmp); |
| 216 | inv_out = static_cast<fl::u16>((65280u + (scaled >> 1)) / scaled); |
| 217 | } |
| 218 | |
| 219 | /// Convert any Coord type to Q16.16 raw i32 for integer inner loops. |
| 220 | /// s16x16: direct raw access (already Q16.16, zero overhead). |
no outgoing calls
no test coverage detected