audioconvert: ensure alignment

Allocate a little bit more data to ensure alignment and overread of the
dither data.
Ensure sse2 can load aligned data in all cases.
This commit is contained in:
Wim Taymans 2022-06-27 17:18:23 +02:00
parent b41d52cfd1
commit 00998ffd7e
4 changed files with 19 additions and 18 deletions

View file

@ -85,14 +85,14 @@ int dither_init(struct dither *d)
d->scale = 1.0f / (1ULL << (31 + d->intensity));
d->dither_size = DITHER_SIZE;
d->dither = calloc(d->dither_size + 8, sizeof(float));
d->dither = calloc(d->dither_size + DITHER_OPS_MAX_OVERREAD +
DITHER_OPS_MAX_ALIGN / sizeof(float), sizeof(float));
if (d->dither == NULL)
return -errno;
for (i = 0; i < SPA_N_ELEMENTS(d->random); i++)
d->random[i] = random();
d->free = impl_dither_free;
d->process = info->process;
return 0;