diff options
author | waker <wakeroid@gmail.com> | 2011-05-18 09:22:10 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2011-05-18 09:22:24 +0200 |
commit | 0b6ee456d7cfcc0b0cd32359b1d0fad7727c4b5e (patch) | |
tree | a848dc21183df6112d7d134cf73af31b3cf108fc /premix.c | |
parent | 60cf4161d6c4dff8ad3cf74fd84643e7f30fccdf (diff) |
added remaining 32_to_8/24/float conversions
Diffstat (limited to 'premix.c')
-rw-r--r-- | premix.c | 46 |
1 files changed, 43 insertions, 3 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_8 (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++) { + int8_t *out = (int8_t*)(output + channelmap[c]); + int32_t sample = *((int32_t*)input); + *out = (int8_t)(sample>>24); + input += 4; + } + output += outputsamplesize; + } +} + +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++) { @@ -235,6 +248,20 @@ pcm_write_samples_32_to_16 (const ddb_waveformat_t * restrict inputfmt, const ch } static inline void +pcm_write_samples_32_to_24 (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++) { + char *out = output + 3 * channelmap[c]; + out[0] = input[1]; + out[1] = input[2]; + out[2] = input[3]; + 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++) { @@ -245,6 +272,19 @@ pcm_write_samples_32_to_32 (const ddb_waveformat_t * restrict inputfmt, const ch } } + +static inline void +pcm_write_samples_32_to_float (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++) { + float *out = (float *)(output + 4 * channelmap[c]); + int32_t sample = *((int32_t*)input); + *out = sample / (float)0x7fffffff; + input += 4; + } + output += outputsamplesize; + } +} static inline void pcm_write_samples_float_to_8 (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) { fpu_control ctl; @@ -365,14 +405,14 @@ remap_fn_t remappers[8][8] = { pcm_write_samples_24_to_float, }, { - NULL, // FIXME: add 32_to_8 + pcm_write_samples_32_to_8, pcm_write_samples_32_to_16, - NULL, // FIXME: add 32_to_24 + pcm_write_samples_32_to_24, pcm_write_samples_32_to_32, NULL, NULL, NULL, - NULL, // FIXME: add 32_to_float + pcm_write_samples_32_to_float, }, { }, |