From 181e9c6d5d11cb1e5d36a2777eeb233ad8ed00e5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 9 Oct 2008 18:15:23 +0200 Subject: big pile of updates to match more what happened with libcanberra --- src/volscale.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'src/volscale.c') diff --git a/src/volscale.c b/src/volscale.c index f29cb0e..86b187b 100644 --- a/src/volscale.c +++ b/src/volscale.c @@ -1,3 +1,23 @@ +/*** + This file is part of libsydney. + + Copyright 2007-2008 Lennart Poettering + + libsydney is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 2.1 of the + License, or (at your option) any later version. + + libsydney is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with libsydney. If not, see + . +***/ + #ifdef HAVE_CONFIG_H #include #endif @@ -13,8 +33,8 @@ static void volscale_u8(void *_dst, size_t dstr, const void *_src, size_t sstr, for (; bytes > 0; bytes --) { int32_t t = (((int32_t) *src - 0x80) * factor) / divisor; - t = CLAMP(t, -0x80, 0x7F); - *dst = (int8_t) (t+0x80); + t = SA_CLAMP(t, -0x80, 0x7F); + *dst = (uint8_t) (t+0x80); src += sstr; dst += dstr; @@ -24,11 +44,11 @@ static void volscale_u8(void *_dst, size_t dstr, const void *_src, size_t sstr, static void volscale_s16(void *_dst, size_t dstr, const void *_src, size_t sstr, int32_t factor, int32_t divisor, size_t bytes) { int16_t *dst = _dst; const int16_t *src = _src; - unsigned n = bytes / sizeof(int16_t); + size_t n = bytes / sizeof(int16_t); for (; n > 0; n--) { int32_t t = ((int32_t) *src * factor) / divisor; - t = CLAMP(t, -0x8000, 0x7FFF); + t = SA_CLAMP(t, -0x8000, 0x7FFF); *dst = (int16_t) t; src += sstr / sizeof(int16_t); @@ -39,11 +59,11 @@ static void volscale_s16(void *_dst, size_t dstr, const void *_src, size_t sstr, static void volscale_s32(void *_dst, size_t dstr, const void *_src, size_t sstr, int32_t factor, int32_t divisor, size_t bytes) { int32_t *dst = _dst; const int32_t *src = _src; - unsigned n = bytes / sizeof(int32_t); + size_t n = bytes / sizeof(int32_t); for (; n > 0; n--) { int64_t t = ((int64_t) *src * factor) / divisor; - t = CLAMP(t, -0x80000000L, 0x7FFFFFFFL); + t = SA_CLAMP(t, -0x80000000LL, 0x7FFFFFFFLL); *dst = (int32_t) t; src += sstr / sizeof(int32_t); @@ -56,7 +76,7 @@ static void volscale_f32(void *_dst, size_t dstr, const void *_src, size_t sstr, const float *src = _src; float f = (float) factor / (float) divisor; - oil_scalarmult_f32(dst, dstr, src, sstr, &f, size / sizeof(float)); + oil_scalarmult_f32(dst, (int) dstr, src, (int) sstr, &f, (int) (size / sizeof(float))); } sa_volscale_func_t sa_get_volscale_func(sa_pcm_format_t f) { -- cgit