News for hackers. Stuff that matters.
Re:Farbfeld – A suckless image format by rasz_pl on Friday January 15, 2016 @12:36AM (#10907428)
endianness ...
Re:Farbfeld – A suckless image format by krasin on Friday January 15, 2016 @01:42AM (#10907642)
yeah, that was a bit strange. By choosing Little Endian, the author would achieve the ability to mmap an uncompressed image file to memory and then use it directly like an array in all contemporary hardware architectures. Not that it's a big deal, but I fail to see why would anyone choose Big Endian in 2016.
Re:Farbfeld – A suckless image format by frign on Friday January 15, 2016 @06:43AM (#10908638)
Hey krasin,

how come people assume there are only Little Endian machines. This mmap-technique wouldn't work on Big Endian like this, this is inaccetable!

However, you can still mmap and properly call ntohs() on each color channel value (if you access it). These functions won't hurt performance too much anyway, if at all. If you show me a measurable difference between using LE and BE, I owe you a beer, okay? :)

Re:Farbfeld – A suckless image format by userbinator on Friday January 15, 2016 @07:08AM (#10908751)
People are making the (valid) assumption that LE is far more common than BE.

On x86 swapping endianness is one instruction (BSWAP), but AFAIK it can't be SIMD'd easily. Given that SIMD is one of the things that can greatly speed up image processing, I don't think it "won't hurt performance too much"...

Re:Farbfeld – A suckless image format by nightcracker on Friday January 15, 2016 @08:56AM (#10909278)
For SIMD you can use _mm<width>_shuffle_epi8 to swap endianness in a single cycle.
Re:Farbfeld – A suckless image format by mtklein on Friday January 15, 2016 @09:29AM (#10909471)
(Just FYI, this only works with SSSE3+, which to be fair is essentially all x86 machines. It's also >1 cycle on mobile x86 chips, which is very frustrating.)
Re:Farbfeld – A suckless image format by irascible on Friday January 15, 2016 @05:04AM (#10908276)
One of the few legit criticisms in this thread.
Re:Farbfeld – A suckless image format by frign on Friday January 15, 2016 @06:50AM (#10908673)
Keep in mind not all machines are Little Endian. This assumption is wrong.
Re:Farbfeld – A suckless image format by rasz_pl on Friday January 15, 2016 @07:18AM (#10908801)
You are right, only 99.999% of machines are little endian now (iOS, Android and x86).
Re:Farbfeld – A suckless image format by yaur on Friday January 15, 2016 @11:21AM (#10910217)
All machines are ALSO not 64 bit and you have a trivially exploitable buffer overflow on 32 bit machines.
Re:Farbfeld – A suckless image format by rasz_pl on Friday January 15, 2016 @06:20AM (#10908541)
Choosing big endian is bad enough, but they dont even mention that in the four line specification :o
Re:Farbfeld – A suckless image format by frign on Friday January 15, 2016 @06:44AM (#10908642)
It is specified (BE = Big Endian)