1 Commits
Author SHA1 Message Date
LibretroAdmin f3c9d525ea IPU: read the bitstream window through defined loads
The five window readers move to ipu_bitstream.h as C, taking the window
and the bit position as arguments so they depend on neither the FIFO nor
the bit pointer's state. Every window access is a fixed-width memcpy and
every left shift happens in the unsigned domain, which is what the
positions these are called at require: the bit pointer is byte-granular at
best, so the loads are unaligned by construction, and the value being
shifted can have its top bit set. They stay in the header so they keep
inlining into the decoder.

The width limit is now written down. Serving a request out of one 32-bit
word means bits + (bp & 7) must be 32 or less -- 25 bits at the worst
alignment. The decoder's widest read is 24, so it sits inside that
everywhere; past the limit the low bits come back as zeroes.

tests/ipu/bitstream_hash.cpp checks them against a model that walks the
window a bit at a time, sweeping every position in 0..127 at every width
the limit allows, and bitstream_build.sh runs it on both compilers at
SSE2, SSE4.1 and AVX2 and on aarch64, where the byteswap has to reach the
same bits. Exhaustive alignment coverage is what these want; a stream only
visits the positions its own symbol lengths produce.
2026-09-21 21:02:24 +02:00