summaryrefslogtreecommitdiffstats
path: root/volscale.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-10-01 20:16:28 +0000
committerLennart Poettering <lennart@poettering.net>2007-10-01 20:16:28 +0000
commit7d83e5c7816b5e343695a75ba58b32dbe1be969a (patch)
treebfd1dfc9b7c8f4a2aaf66c1b30e78355dee8c88a /volscale.c
parent762196328ab7e60f1d2908fd5a337d2ca99726dd (diff)
move all sources down to a seperate src/ tree
git-svn-id: file:///home/lennart/svn/public/libsydney/trunk@34 9ba3c220-e4d3-45a2-8aa3-73fcc9aff6ce
Diffstat (limited to 'volscale.c')
-rw-r--r--volscale.c67
1 files changed, 0 insertions, 67 deletions
diff --git a/volscale.c b/volscale.c
deleted file mode 100644
index 2075b90..0000000
--- a/volscale.c
+++ /dev/null
@@ -1,67 +0,0 @@
-#include <liboil/liboil.h>
-
-#include "macro.h"
-#include "volscale.h"
-
-static void volscale_u8(void *_dst, size_t dstr, const void *_src, size_t sstr, int32_t factor, int32_t divisor, size_t bytes) {
- uint8_t *dst = _dst;
- const uint8_t *src = _src;
-
- for (; bytes > 0; bytes --) {
- int32_t t = (((int32_t) *src - 0x80) * factor) / divisor;
- *dst = t < -0x80 ? 0 : (t > 0x7F ? 0xFF : (int8_t) (t+0x80));
-
- src += sstr;
- dst += dstr;
- }
-}
-
-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);
-
- for (; n > 0; n--) {
- int32_t t = ((int32_t) *src * factor) / divisor;
- *dst = t < -0x8000 ? 0x8000 : (t > 0x7FFF ? 0x7FFF : (int16_t) t);
-
- src += sstr / sizeof(int16_t);
- dst += dstr / sizeof(int16_t);
- }
-}
-
-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);
-
- for (; n > 0; n--) {
- int64_t t = ((int64_t) *src * factor) / divisor;
- *dst = t < -0x80000000L ? (int32_t) 0x80000000L : (t > 0x7fffffffL ? (int32_t) 0x7fffffffL : (int32_t) t);
-
- src += sstr / sizeof(int32_t);
- dst += dstr / sizeof(int32_t);
- }
-}
-
-static void volscale_f32(void *_dst, size_t dstr, const void *_src, size_t sstr, int32_t factor, int32_t divisor, size_t size) {
- float *dst = _dst;
- const float *src = _src;
- float f = (float) factor / (float) divisor;
-
- oil_scalarmult_f32(dst, dstr, src, sstr, &f, size / sizeof(float));
-}
-
-sa_volscale_func_t sa_get_volscale_func(sa_pcm_format_t f) {
-
- static const sa_volscale_func_t funcs[_SA_PCM_FORMAT_MAX] = {
- [SA_PCM_FORMAT_U8] = volscale_u8,
- [SA_PCM_FORMAT_S16_NE] = volscale_s16,
- [SA_PCM_FORMAT_S32_NE] = volscale_s32,
- [SA_PCM_FORMAT_FLOAT32_NE] = volscale_f32
- };
-
- sa_assert(f < _SA_PCM_FORMAT_MAX);
-
- return funcs[f];
-}