fast-srgb8

Build Status Docs Latest Version Minimum Rust Version

Small crate implementing fast conversion between linear float and 8-bit sRGB. Includes API for performing 4 simultaneous conversions, which are SIMD accelerated using SSE2 if available. Supports no_std (doesn't need libm either).

Features

Benefits

Benchmarks

```

Measures fast_srgb8::f32_to_srgb8 vs ref impl

test tests::bench::fastscalar ... bench: 144 ns/iter (+/- 11) test tests::bench::naivescalar ... bench: 971 ns/iter (+/- 48)

Measures fast_srgb8::f32x4_to_srgb8 vs calling reference impl 4 times

test tests::bench::fastf32x4 ... bench: 440 ns/iter (+/- 29) test tests::bench::naivef32x4 ... bench: 3,625 ns/iter (+/- 282) test tests::bench::fastf32x4nosimd ... bench: 482 ns/iter (+/- 27)

Measures fast_srgb8::srgb8_to_f32 vs ref impl

test tests::bench::fastfromsrgb8 ... bench: 81 ns/iter (+/- 6) test tests::bench::naivefromsrgb8 ... bench: 4,026 ns/iter (+/- 282) `` (Note that thens/iter` time is not for a single invocation of these function, it's for several)

License

Public domain, as explained here. If that's unacceptable, it's also available under either the Apache-2.0 or MIT licenses, at your option.

The float->srgb code is originally¹ based on public domain routines by Fabien "ryg" Giesen, although I'm no longer sure where these are available.

¹ (Well, specifically: The Rust code in this crate is ported from code in a C++ game engine of mine, which in turn, was based on the code from ryg. This doesn't make a difference, but increases the likelihood that any errors are solely my responsibility).