All values, including the slices, are big endian.
In a world where LE basically won, that's an astonishingly stupid decision --- especially if you care about tiny differences in performance.
All values, including the slices, are big endian.
In a world where LE basically won, that's an astonishingly stupid decision --- especially if you care about tiny differences in performance.
For converting a "slice" from the 64-bit format (which is has a 4-bit value in the highest bits, and 20 3-bit values organized from high to low. Each 3-bit value is read from the high to low), I treated it as two separate 32-bit values. The bottom two bits of are combined to get the 4-bit value, and the rest contains two pairs of 10 3-bit values organized low to high.
So this:
sample = (slice >> 57) & 0x7; //Get sample
slice <<= 3; //Advance to next sample (64-bit shift)
Became this: sample = slice & 0x7; //Get sample
slice >>= 3; //Advance to next sample (32-bit shift)
I think the conversion to 32-bit little endian was something like an 8-10% speed up, with no other changes? (This was a few months ago, and I didn't write down what the exact difference was.) The overhead big endian conversion and 64-bit shifts would become even more noticeable after further optimizations. (Replacing qoa_lms_predict with inline asm to use an integer multiply-accumulate instruction that GCC can't generate got something like another 20-25% speedup. Properly written asm would be even faster.)I was really thankful that Doom WAD file was big endian (side effect of being developed on NeXT?) when I ported doom to an nRF microcontroller.
Considering that little endian is objectively better for more types of data structures than big endian is [1], one would expect things to eventually converge on little endian (barring the entrenched big endian network protocols that hold everything back). Building for the eventuality of little endian would make more sense in a modern format.
The majority of file formats I've worked with are LE.