From 60cf4161d6c4dff8ad3cf74fd84643e7f30fccdf Mon Sep 17 00:00:00 2001 From: waker Date: Wed, 18 May 2011 09:16:29 +0200 Subject: added int32 to int16 conversion --- premix.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'premix.c') diff --git a/premix.c b/premix.c index c7a3324b..3a44c5b2 100644 --- a/premix.c +++ b/premix.c @@ -221,6 +221,19 @@ pcm_write_samples_24_to_float (const ddb_waveformat_t * restrict inputfmt, const } } +static inline void +pcm_write_samples_32_to_16 (const ddb_waveformat_t * restrict inputfmt, const char * restrict input, const ddb_waveformat_t * restrict outputfmt, char * restrict output, int nsamples, int * restrict channelmap, int outputsamplesize) { + for (int s = 0; s < nsamples; s++) { + for (int c = 0; c < inputfmt->channels; c++) { + int16_t *out = (int16_t*)(output + 2 * channelmap[c]); + int32_t sample = *((int32_t*)input); + *out = (int16_t)(sample>>16); + input += 4; + } + output += outputsamplesize; + } +} + static inline void pcm_write_samples_32_to_32 (const ddb_waveformat_t * restrict inputfmt, const char * restrict input, const ddb_waveformat_t * restrict outputfmt, char * restrict output, int nsamples, int * restrict channelmap, int outputsamplesize) { for (int s = 0; s < nsamples; s++) { @@ -353,7 +366,7 @@ remap_fn_t remappers[8][8] = { }, { NULL, // FIXME: add 32_to_8 - NULL, // FIXME: add 32_to_16 + pcm_write_samples_32_to_16, NULL, // FIXME: add 32_to_24 pcm_write_samples_32_to_32, NULL, -- cgit v1.2.3