summaryrefslogtreecommitdiff
path: root/premix.c
diff options
context:
space:
mode:
Diffstat (limited to 'premix.c')
-rw-r--r--premix.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/premix.c b/premix.c
index 8c6f7e81..43a7ed8f 100644
--- a/premix.c
+++ b/premix.c
@@ -211,7 +211,14 @@ pcm_write_samples_float_to_16 (const ddb_waveformat_t * restrict inputfmt, const
if (channelmap[c] != -1) {
int16_t *out = (int16_t*)(output + (outputfmt->bps >> 3) * channelmap[c]);
float sample = *((float*)input);
- *out = (int16_t)ftoi (sample*0x7ff0);
+ // FIXME: sse optimize
+ if (sample > 1) {
+ sample = 1;
+ }
+ if (sample < -1) {
+ sample = -1;
+ }
+ *out = (int16_t)ftoi (sample*0x7fff);
}
input += 4;
}
@@ -229,7 +236,14 @@ pcm_write_samples_float_to_8 (const ddb_waveformat_t * restrict inputfmt, const
if (channelmap[c] != -1) {
int8_t *out = (int8_t*)(output + (outputfmt->bps >> 3) * channelmap[c]);
float sample = *((float*)input);
- *out = (int8_t)ftoi (sample*0x7e);
+ // FIXME: sse optimize
+ if (sample > 1) {
+ sample = 1;
+ }
+ if (sample < -1) {
+ sample = -1;
+ }
+ *out = (int8_t)ftoi (sample*0x7f);
}
input += 4;
}