mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-31 15:48:33 +00:00
The quantiser in try_tx called libm floorf for every coefficient, estimate_bits and the motion-vector cost called f64::log2, and coefficients that quantise to zero still went through an f32 division. - (x / q + rnd).floor() as i32 becomes (x / q + rnd) as i32: the operand is never negative, so truncation equals floor. - log2 of small integers comes from a table built with the same f64::log2 call (estimate_bits and the MV cost in motion_search), so the values are bit-identical. - Coefficients below an exact per-(q, rounding offset) threshold are zero without dividing. The threshold is found once per Decider by a binary search over f32 bit patterns of the monotone quantiser expression. The encoded stream is unchanged. Unit tests compare the new quantiser with the old expression at the threshold boundary and on random values for every quantiser index, and the table with f64::log2. Fixes #2373 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>