7#include "xorshift128p.hpp"
10namespace hi::inline
v1 {
37 hi_axiom(num_bits > 0);
38 auto maximum_value =
static_cast<float>((1_uz << num_bits) - 1);
41 maximum_value *= 127.0f;
44 maximum_value *= 2.0f;
46 _multiplier = f32x4::broadcast(1.0f / maximum_value);
54 if (to_bool(++_counter & 1)) {
55 auto rand = _state.next<
u64x2>();
60 _tpdf = spdf1 + spdf2;
63 auto second_tpdf = bit_cast<i16x8>(bit_cast<u64x2>(_tpdf).yx());
64 return f32x4{
i32x4{second_tpdf}} * _multiplier;
75 return samples + next();
83 [[nodiscard]]
float next(
float sample)
noexcept
85 return get<0>(f32x4::broadcast(sample) + next());
89 f32x4 _multiplier = {};
91 xorshift128p _state = {};
92 unsigned char _counter = 0;
Utilities used by the HikoGUI library itself.
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
DOXYGEN BUG.
Definition algorithm.hpp:15
An object that create dither values to add to samples before rounding.
Definition dither.hpp:23
dither(int num_bits) noexcept
Create a dither object.
Definition dither.hpp:35
f32x4 next() noexcept
Get 8 floating point number to add to a samples.
Definition dither.hpp:52
f32x4 next(f32x4 samples) noexcept
Add dither to the given samples.
Definition dither.hpp:73
float next(float sample) noexcept
Add dither to the given samples.
Definition dither.hpp:83