mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
audioconvert: use faster noise generator
This commit is contained in:
parent
938f2b123e
commit
0b62cea4f9
1 changed files with 4 additions and 8 deletions
|
|
@ -736,15 +736,11 @@ conv_f64d_to_f32_c(struct convert *conv, void * SPA_RESTRICT dst[], const void *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 32 bit xorshift PRNG, see https://en.wikipedia.org/wiki/Xorshift */
|
|
||||||
static inline int32_t
|
static inline int32_t
|
||||||
xorshift(uint32_t *state)
|
lcnoise(uint32_t *state)
|
||||||
{
|
{
|
||||||
uint32_t x = *state;
|
*state = (*state * 96314165) + 907633515;
|
||||||
x ^= x << 13;
|
return (int32_t)(*state);
|
||||||
x ^= x >> 17;
|
|
||||||
x ^= x << 5;
|
|
||||||
return (int32_t)(*state = x);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void update_dither_c(struct convert *conv, uint32_t n_samples)
|
static inline void update_dither_c(struct convert *conv, uint32_t n_samples)
|
||||||
|
|
@ -754,7 +750,7 @@ static inline void update_dither_c(struct convert *conv, uint32_t n_samples)
|
||||||
uint32_t *state = &conv->random[0];
|
uint32_t *state = &conv->random[0];
|
||||||
|
|
||||||
for (n = 0; n < n_samples; n++)
|
for (n = 0; n < n_samples; n++)
|
||||||
dither[n] = xorshift(state) * scale;
|
dither[n] = lcnoise(state) * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue