From 8586ba20c9388c1055339d0143d48b71066b2b9f Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 10 Jul 2002 12:13:45 +0000 Subject: [PATCH] Fixed normalization of int64 and float values --- src/pcm/pcm_route.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c index eed050b7..b6c44a89 100644 --- a/src/pcm/pcm_route.c +++ b/src/pcm/pcm_route.c @@ -408,8 +408,10 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area, norm_int64_0_noatt: norm_int: - if (sum.as_sint64 > (u_int32_t)0xffffffff) - sample = (u_int32_t)0xffffffff; + if (sum.as_sint64 > (int64_t)0x7fffffff) + sample = 0x7fffffff; /* maximum positive value */ + else if (sum.as_sint64 < (int64_t)-0x80000000) + sample = 0x80000000; /* maximum negative value */ else sample = sum.as_sint64; goto after_norm; @@ -427,8 +429,10 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area, norm_float_0: norm_float: sum.as_float = floor(sum.as_float + 0.5); - if (sum.as_float > (u_int32_t)0xffffffff) - sample = (u_int32_t)0xffffffff; + if (sum.as_float > (int64_t)0x7fffffff) + sample = 0x7fffffff; /* maximum positive value */ + else if (sum.as_float < (int64_t)-0x80000000) + sample = 0x80000000; /* maximum negative value */ else sample = sum.as_float; goto after_norm; -- 2.47.1