audioconvert: improve noise bits

Make a new noise method called PATTERN and use it to add a slow (every
1024 samples) repeating pattern of -1, 0.
Only use this method when we don't already use triangular dither.

See #2540
This commit is contained in:
Wim Taymans 2022-07-18 11:39:24 +02:00
parent 57f63feb92
commit ada39f3048
4 changed files with 43 additions and 20 deletions

View file

@ -581,7 +581,7 @@ static inline void update_noise_sse2(struct convert *conv, uint32_t n_samples)
{
uint32_t n;
const uint32_t *r = SPA_PTR_ALIGN(conv->random, 16, uint32_t);
const int32_t *p = SPA_PTR_ALIGN(conv->prev, 16, int32_t);
int32_t *p = SPA_PTR_ALIGN(conv->prev, 16, int32_t), op;
__m128 scale = _mm_set1_ps(conv->scale);
__m128 out[1];
float *noise = SPA_PTR_ALIGN(conv->noise, 16, float);
@ -616,6 +616,12 @@ static inline void update_noise_sse2(struct convert *conv, uint32_t n_samples)
}
_mm_store_si128((__m128i*)p, old[0]);
break;
case NOISE_METHOD_PATTERN:
op = *p;
for (n = 0; n < n_samples; n++)
noise[n] = conv->scale * (1-((op++>>10)&1));
*p = op;
break;
}
}