mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
audioconvert: move scaling to setup
This commit is contained in:
parent
68f883ff77
commit
c35006f040
3 changed files with 4 additions and 3 deletions
|
|
@ -237,7 +237,6 @@ 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];
|
||||||
|
|
||||||
if (conv->method < DITHER_METHOD_TRIANGULAR) {
|
if (conv->method < DITHER_METHOD_TRIANGULAR) {
|
||||||
scale *= 0.5f;
|
|
||||||
for (n = 0; n < n_samples; n++)
|
for (n = 0; n < n_samples; n++)
|
||||||
dither[n] = lcnoise(state) * scale;
|
dither[n] = lcnoise(state) * scale;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -585,12 +585,12 @@ static inline void update_dither_sse2(struct convert *conv, uint32_t n_samples)
|
||||||
{
|
{
|
||||||
uint32_t n;
|
uint32_t n;
|
||||||
const uint32_t *r = SPA_PTR_ALIGN(conv->random, 16, uint32_t);
|
const uint32_t *r = SPA_PTR_ALIGN(conv->random, 16, uint32_t);
|
||||||
|
__m128 scale = _mm_set1_ps(conv->scale);
|
||||||
__m128 out[1];
|
__m128 out[1];
|
||||||
float *dither = SPA_PTR_ALIGN(conv->dither, 16, float);
|
float *dither = SPA_PTR_ALIGN(conv->dither, 16, float);
|
||||||
__m128i in[2];
|
__m128i in[2];
|
||||||
|
|
||||||
if (conv->method < DITHER_METHOD_TRIANGULAR) {
|
if (conv->method < DITHER_METHOD_TRIANGULAR) {
|
||||||
__m128 scale = _mm_set1_ps(conv->scale * 0.5f);
|
|
||||||
for (n = 0; n < n_samples; n += 4) {
|
for (n = 0; n < n_samples; n += 4) {
|
||||||
in[0] = _MM_XORSHIFT_EPI32(r);
|
in[0] = _MM_XORSHIFT_EPI32(r);
|
||||||
out[0] = _mm_cvtepi32_ps(_MM_XORSHIFT_EPI32(r));
|
out[0] = _mm_cvtepi32_ps(_MM_XORSHIFT_EPI32(r));
|
||||||
|
|
@ -598,7 +598,6 @@ static inline void update_dither_sse2(struct convert *conv, uint32_t n_samples)
|
||||||
_mm_store_ps(&dither[n], out[0]);
|
_mm_store_ps(&dither[n], out[0]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__m128 scale = _mm_set1_ps(conv->scale);
|
|
||||||
for (n = 0; n < n_samples; n += 4) {
|
for (n = 0; n < n_samples; n += 4) {
|
||||||
in[0] = _mm_add_epi32( _MM_XORSHIFT_EPI32(r), _MM_XORSHIFT_EPI32(r));
|
in[0] = _mm_add_epi32( _MM_XORSHIFT_EPI32(r), _MM_XORSHIFT_EPI32(r));
|
||||||
out[0] = _mm_cvtepi32_ps(in[0]);
|
out[0] = _mm_cvtepi32_ps(in[0]);
|
||||||
|
|
|
||||||
|
|
@ -408,6 +408,9 @@ int convert_init(struct convert *conv)
|
||||||
if (conv->method == DITHER_METHOD_SHAPED_5 && conv->rate < 32000)
|
if (conv->method == DITHER_METHOD_SHAPED_5 && conv->rate < 32000)
|
||||||
conv->method = DITHER_METHOD_TRIANGULAR;
|
conv->method = DITHER_METHOD_TRIANGULAR;
|
||||||
|
|
||||||
|
if (conv->method < DITHER_METHOD_TRIANGULAR)
|
||||||
|
conv->scale *= 0.5f;
|
||||||
|
|
||||||
dither_flags = 0;
|
dither_flags = 0;
|
||||||
if (conv->method != DITHER_METHOD_NONE || conv->noise)
|
if (conv->method != DITHER_METHOD_NONE || conv->noise)
|
||||||
dither_flags |= CONV_DITHER;
|
dither_flags |= CONV_DITHER;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue