diff options
author | 2010-11-28 19:11:46 +0100 | |
---|---|---|
committer | 2010-11-28 19:11:46 +0100 | |
commit | a895553b9f2dfaad951b1293a7b0e1c6c4180cd0 (patch) | |
tree | 908aa33af6f1ffadc70da09b91b6bbf9957673c0 | |
parent | c858c1c7b408e60d566e92aa5dc567918be3c9a4 (diff) |
added 24->8 and 24->16 converters
-rw-r--r-- | premix.c | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -175,6 +175,20 @@ pcm_write_samples_16_to_float (const ddb_waveformat_t * restrict inputfmt, const } static inline void +pcm_write_samples_24_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++) { + if (channelmap[c] != -1) { + char *out = output + channelmap[c]; + *out = input[2]; + } + input += 3; + } + output += outputsamplesize; + } +} + +static inline void pcm_write_samples_24_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++) { @@ -191,6 +205,21 @@ pcm_write_samples_24_to_24 (const ddb_waveformat_t * restrict inputfmt, const ch } static inline void +pcm_write_samples_24_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++) { + if (channelmap[c] != -1) { + char *out = output + 2 * channelmap[c]; + out[0] = input[1]; + out[1] = input[2]; + } + input += 3; + } + output += outputsamplesize; + } +} + +static inline void pcm_write_samples_24_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++) { @@ -373,6 +402,12 @@ pcm_convert (const ddb_waveformat_t * restrict inputfmt, const char * restrict i else if (inputfmt->bps == 16 && outputfmt->bps == 32 && outputfmt->is_float) { pcm_write_samples_16_to_float (inputfmt, input, outputfmt, output, nsamples, channelmap, outputsamplesize); } + else if (inputfmt->bps == 24 && outputfmt->bps == 8) { + pcm_write_samples_24_to_8 (inputfmt, input, outputfmt, output, nsamples, channelmap, outputsamplesize); + } + else if (inputfmt->bps == 24 && outputfmt->bps == 16) { + pcm_write_samples_24_to_16 (inputfmt, input, outputfmt, output, nsamples, channelmap, outputsamplesize); + } else if (inputfmt->bps == 24 && outputfmt->bps == 24) { pcm_write_samples_24_to_24 (inputfmt, input, outputfmt, output, nsamples, channelmap, outputsamplesize); } |