4 ms·
To answer the author's question: No, SIMD would not help with this. This is neat. I wonder if the author would be willing to write a Kaitai Struct definition f
by junon 5y ago
To answer the author's question: No, SIMD would not help with this.
This is neat. I wonder if the author would be willing to write a Kaitai Struct definition for it.
Something else interesting: QOI is 1,2,2 letters off from PNG. I'm quite certain this is an accident but it's interesting nonetheless.
- jiggawatts 5y agoI suspect SIMD would help with the encoding. The lookup table is small enough to fit into 8 AVX2 registers, so instead of hashing, you could use direct lookup, which would improve compression ratio further (a little bit).
- junon 5y agoYes encoding might benefit of course, I was more considering decoding speed I suppose.
- jiggawatts 5y agoThere are some clever tricks that can be pulled with the latest instructions sets like AVX-512. The registers are huge and the instructions available are so varied that there are clever ways to use them in "off label" ways to implement lookup tables and bit-level parsers.
- junon 5y agoAVX-512 is deprecated and will be removed from future chips, so that's probably not as useful as one might think.
- jiggawatts 5y agoI doubt that. What would be hilarious is if AMD's upcoming Zen 4 supported it consistently, but not all Intel CPU models did.
- Const-me 5y ago> The lookup table is small enough to fit into 8 AVX2 registers Indeed. > so instead of hashing, you could use direct lookup However, I don’t think that part gonna work. See the code using that table: https://github.com/phoboslab/qoi/blob/master/qoi.h#L324-L328 https://github.com/phoboslab/qoi/blob/master/qoi.h#L324-L328 SIMD registers aren’t indexable (at least not on AMD64), the register needs to be known to the compiler. Lanes within each register aren’t indexable either. The insert and extract instructions are encoding lane index in the code. There’re workarounds for this one, like abusing vpshufb or vpermd, but with that amount of overhead I doubt SIMD will deliver any profit at all.
- deleted 5y ago[deleted]