diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2009-09-27 16:06:10 +0200 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2009-09-27 16:07:17 +0200 |
commit | 5e7bd5cb0c22ff34de5111205712d689527ab2eb (patch) | |
tree | cf077dd9768847529c0e0db8d82a65087c399e47 /streamer.c | |
parent | 5bf2da4cc9e1e15bbccca82d686203dd1bb408ca (diff) |
fixed ftoi conversion bug in streamer
Diffstat (limited to 'streamer.c')
-rw-r--r-- | streamer.c | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -513,7 +513,14 @@ float32_to_int16 (float *in, int16_t *out, int nsamples) { fpu_control ctl; fpu_setround (&ctl); while (nsamples > 0) { - *out++ = (int16_t)ftoi ((*in++)*0x7fff); + float sample = *in++; + if (sample > 1) { + sample = 1; + } + else if (sample < -1) { + sample = -1; + } + *out++ = (int16_t)ftoi (sample*0x7fff); nsamples--; } fpu_restore (ctl); |