Commit d24f2ba5 authored by Max Kellermann's avatar Max Kellermann

pcm_dither: added pcm_dither_32_to_16()

For 32 bit dithering, reuse the 24 bit dithering code, but apply a 8 bit right shift first.
parent 78e08f65
......@@ -76,3 +76,18 @@ pcm_dither_24_to_16(struct pcm_dither *dither,
while (num_samples-- > 0)
*dest++ = pcm_dither_sample_24_to_16(*src++, dither);
}
static int16_t
pcm_dither_sample_32_to_16(int32_t sample, struct pcm_dither *dither)
{
return pcm_dither_sample_24_to_16(sample >> 8, dither);
}
void
pcm_dither_32_to_16(struct pcm_dither *dither,
int16_t *dest, const int32_t *src,
unsigned num_samples)
{
while (num_samples-- > 0)
*dest++ = pcm_dither_sample_32_to_16(*src++, dither);
}
......@@ -38,4 +38,9 @@ pcm_dither_24_to_16(struct pcm_dither *dither,
int16_t *dest, const int32_t *src,
unsigned num_samples);
void
pcm_dither_32_to_16(struct pcm_dither *dither,
int16_t *dest, const int32_t *src,
unsigned num_samples);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment