mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-03 09:01:54 -05:00
audioconvert: add dither noise setting in dither struct
Move the noise setting in the dither struct so that it can be handled separately. Setup dither separately. Set used cpu_flags in structures after setup.
This commit is contained in:
parent
b7e26002be
commit
b5e0151cc0
5 changed files with 33 additions and 20 deletions
|
|
@ -45,7 +45,7 @@ static const struct dither_info {
|
|||
} dither_table[] =
|
||||
{
|
||||
#if defined (HAVE_SSE2)
|
||||
{ dither_f32_sse2, 0 },
|
||||
{ dither_f32_sse2, SPA_CPU_FLAG_SSE, },
|
||||
#endif
|
||||
{ dither_f32_c, 0 },
|
||||
};
|
||||
|
|
@ -74,12 +74,16 @@ int dither_init(struct dither *d)
|
|||
{
|
||||
const struct dither_info *info;
|
||||
size_t i;
|
||||
uint32_t scale;
|
||||
|
||||
info = find_dither_info(d->cpu_flags);
|
||||
if (info == NULL)
|
||||
return -ENOTSUP;
|
||||
|
||||
d->scale = 1.0f / powf(2.0f, 31 + d->quantize);
|
||||
scale = d->quantize;
|
||||
scale -= SPA_MIN(scale, d->noise);
|
||||
|
||||
d->scale = 1.0f / powf(2.0f, 31 + scale);
|
||||
|
||||
d->dither_size = DITHER_SIZE;
|
||||
d->dither = calloc(d->dither_size + DITHER_OPS_MAX_OVERREAD +
|
||||
|
|
@ -90,6 +94,8 @@ int dither_init(struct dither *d)
|
|||
for (i = 0; i < SPA_N_ELEMENTS(d->random); i++)
|
||||
d->random[i] = random();
|
||||
|
||||
d->cpu_flags = info->cpu_flags;
|
||||
|
||||
d->free = impl_dither_free;
|
||||
d->process = info->process;
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue