aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/pcm_dither.c15
-rw-r--r--src/pcm_dither.h5
2 files changed, 20 insertions, 0 deletions
diff --git a/src/pcm_dither.c b/src/pcm_dither.c
index c6f10dd30..dfd6d287d 100644
--- a/src/pcm_dither.c
+++ b/src/pcm_dither.c
@@ -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);
+}
diff --git a/src/pcm_dither.h b/src/pcm_dither.h
index b0c0304ee..962122fd8 100644
--- a/src/pcm_dither.h
+++ b/src/pcm_dither.h
@@ -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