We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6b1912d commit 881848dCopy full SHA for 881848d
sampleconv.h
@@ -34,8 +34,8 @@
34
35
#if BIT_PERFECT
36
/* these clip, but are bit perfect */
37
- #define SAMPLE_TO_U8(x) ((uint8_t) (((x) * 128.0 + 127.0 < 0.0) ? 0 : lrint((x) * 128.0 + 127.0)))
38
- #define U8_TO_SAMPLE(x) (((sample_t) (x) - 127.0) / 128.0)
+ #define SAMPLE_TO_U8(x) ((uint8_t) (((x) * 128.0 + 128.0 > 255.0) ? 255.0 : lrint((x) * 128.0 + 128.0)))
+ #define U8_TO_SAMPLE(x) (((sample_t) (x) - 128.0) / 128.0)
39
#define SAMPLE_TO_S8(x) ((int8_t) (((x) * 128.0 > 127.0) ? 127 : lrint((x) * 128.0)))
40
#define S8_TO_SAMPLE(x) ((sample_t) (x) / 128.0)
41
#define SAMPLE_TO_S16(x) ((int16_t) (((x) * 32768.0 > 32767.0) ? 32767 : lrint((x) * 32768.0)))
0 commit comments