diff options
author | waker <wakeroid@gmail.com> | 2011-05-18 09:16:29 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2011-05-18 09:16:29 +0200 |
commit | 60cf4161d6c4dff8ad3cf74fd84643e7f30fccdf (patch) | |
tree | 66bc9a351a82559d120d19f9f607bb2d4da62b57 /premix.c | |
parent | 31519fd0e5b473a4ad7e994dc0914f811ee3d8d0 (diff) |
added int32 to int16 conversion
Diffstat (limited to 'premix.c')
-rw-r--r-- | premix.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -222,6 +222,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++) { for (int c = 0; c < inputfmt->channels; c++) { @@ -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, |