From 284516185f90412c22dfa9a28cb93fb344af591b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 May 2007 00:10:02 +0000 Subject: really prefix everything with "sa_" git-svn-id: file:///home/lennart/svn/public/libsydney/trunk@28 9ba3c220-e4d3-45a2-8aa3-73fcc9aff6ce --- format.c | 90 ++++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'format.c') diff --git a/format.c b/format.c index 9b1f805..f7a8755 100644 --- a/format.c +++ b/format.c @@ -9,7 +9,7 @@ /* u8 --> */ -static int format_u8_to_s16(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_u8_to_s16(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { int16_t d = -0x80, f = 0x100; oil_conv_s16_u8(dst, dstr, src, sstr, bytes); @@ -19,7 +19,7 @@ static int format_u8_to_s16(bbuffer_t *b, void *dst, size_t dstr, const void *sr return SA_SUCCESS; } -static int format_u8_to_s32(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_u8_to_s32(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { int32_t d = -0x80, f = 0x1000000; oil_conv_s16_u8(dst, dstr, src, sstr, bytes); @@ -29,7 +29,7 @@ static int format_u8_to_s32(bbuffer_t *b, void *dst, size_t dstr, const void *sr return SA_SUCCESS; } -static int format_u8_to_f32(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_u8_to_f32(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { float d = -0x80, f = 1.0/0x7F; oil_conv_f32_u8(dst, dstr, src, sstr, bytes); @@ -41,71 +41,71 @@ static int format_u8_to_f32(bbuffer_t *b, void *dst, size_t dstr, const void *sr /* ulaw --> */ -static int format_ulaw_to_s16(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_ulaw_to_s16(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { int16_t *d = dst; const uint8_t *s = src; for (; bytes > 0; bytes --, d += dstr/sizeof(int16_t), s += sstr) - *d = st_ulaw2linear16(*s); + *d = sa_ulaw2linear16(*s); return SA_SUCCESS; } -static int format_ulaw_to_s32(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_ulaw_to_s32(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { int32_t *d = dst; const uint8_t *s = src; for (; bytes > 0; bytes --, d += dstr/sizeof(int32_t), s += sstr) - *d = (int32_t) st_ulaw2linear16(*s) * 0x10000; + *d = (int32_t) sa_ulaw2linear16(*s) * 0x10000; return SA_SUCCESS; } -static int format_ulaw_to_f32(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_ulaw_to_f32(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { float *d = dst; const uint8_t *s = src; for (; bytes > 0; bytes --, d += dstr/sizeof(float), s += sstr) - *d = st_ulaw2linear16(*s * 1.0F / 0x7FFF); + *d = sa_ulaw2linear16(*s * 1.0F / 0x7FFF); return SA_SUCCESS; } /* alaw --> */ -static int format_alaw_to_s16(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_alaw_to_s16(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { int16_t *d = dst; const uint8_t *s = src; for (; bytes > 0; bytes --, d += dstr/sizeof(int16_t), s += sstr) - *d = st_alaw2linear16(*s); + *d = sa_alaw2linear16(*s); return SA_SUCCESS; } -static int format_alaw_to_s32(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_alaw_to_s32(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { int32_t *d = dst; const uint8_t *s = src; for (; bytes > 0; bytes --, d += dstr/sizeof(int32_t), s += sstr) - *d = (int32_t) st_alaw2linear16(*(s++)) * 0x10000; + *d = (int32_t) sa_alaw2linear16(*(s++)) * 0x10000; return SA_SUCCESS; } -static int format_alaw_to_f32(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_alaw_to_f32(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { float *d = dst; const uint8_t *s = src; for (; bytes > 0; bytes --, d += dstr/sizeof(float), s += sstr) - *d = st_alaw2linear16(*(s++) * 1.0F / 0x7FFF); + *d = sa_alaw2linear16(*(s++) * 1.0F / 0x7FFF); return SA_SUCCESS; } /* s16 --> */ -static int format_s16_to_u8(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_s16_to_u8(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { uint8_t *d = dst; const int16_t *s = src; unsigned n = bytes/sizeof(int16_t); @@ -116,29 +116,29 @@ static int format_s16_to_u8(bbuffer_t *b, void *dst, size_t dstr, const void *sr return SA_SUCCESS; } -static int format_s16_to_ulaw(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_s16_to_ulaw(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { uint8_t *d = dst; const int16_t *s = src; unsigned n = bytes/sizeof(int16_t); for (; n > 0; n --, d += dstr, s += sstr/sizeof(int16_t)) - *d = st_14linear2ulaw(*s); + *d = sa_14linear2ulaw(*s); return SA_SUCCESS; } -static int format_s16_to_alaw(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_s16_to_alaw(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { uint8_t *d = dst; const int16_t *s = src; unsigned n = bytes/sizeof(int16_t); for (; n > 0; n --, d += dstr, s += sstr/sizeof(int16_t)) - *d = st_13linear2alaw(*s); + *d = sa_13linear2alaw(*s); return SA_SUCCESS; } -static int format_s16_to_s32(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_s16_to_s32(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { int f = 0x10000; unsigned n = bytes/sizeof(int16_t); @@ -148,7 +148,7 @@ static int format_s16_to_s32(bbuffer_t *b, void *dst, size_t dstr, const void *s return SA_SUCCESS; } -static int format_s16_to_f32(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_s16_to_f32(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { float f = 1.0/0x7ffff; unsigned n = bytes/sizeof(int16_t); @@ -160,7 +160,7 @@ static int format_s16_to_f32(bbuffer_t *b, void *dst, size_t dstr, const void *s /* s24 --> */ -static int format_s24_to_s32(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_s24_to_s32(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { int32_t *d = dst; const uint8_t *s = src; unsigned n = bytes/3; @@ -177,7 +177,7 @@ static int format_s24_to_s32(bbuffer_t *b, void *dst, size_t dstr, const void *s return SA_SUCCESS; } -static int format_s24_to_f32(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_s24_to_f32(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { float *d = dst; const uint8_t *s = src; unsigned n = bytes/3; @@ -196,7 +196,7 @@ static int format_s24_to_f32(bbuffer_t *b, void *dst, size_t dstr, const void *s /* s32 --> */ -static int format_s32_to_u8(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_s32_to_u8(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { uint8_t *d = dst; const int32_t *s = src; unsigned n = bytes/sizeof(int32_t); @@ -207,29 +207,29 @@ static int format_s32_to_u8(bbuffer_t *b, void *dst, size_t dstr, const void *sr return SA_SUCCESS; } -static int format_s32_to_ulaw(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_s32_to_ulaw(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { uint8_t *d = dst; const int32_t *s = src; unsigned n = bytes/sizeof(int32_t); for (; n > 0; n--, d += dstr, s += sstr/sizeof(int32_t)) - *d = st_14linear2ulaw(*s / 0x10000); + *d = sa_14linear2ulaw(*s / 0x10000); return SA_SUCCESS; } -static int format_s32_to_alaw(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_s32_to_alaw(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { uint8_t *d = dst; const int32_t *s = src; unsigned n = bytes/sizeof(int32_t); for (; n > 0; n--, d += dstr, s += sstr/sizeof(int32_t)) - *d = st_13linear2alaw(*s / 0x10000); + *d = sa_13linear2alaw(*s / 0x10000); return SA_SUCCESS; } -static int format_s32_to_s16(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_s32_to_s16(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { int16_t *d = dst; const int32_t *s = src; unsigned n = bytes/sizeof(int32_t); @@ -240,7 +240,7 @@ static int format_s32_to_s16(bbuffer_t *b, void *dst, size_t dstr, const void *s return SA_SUCCESS; } -static int format_s32_to_s24(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_s32_to_s24(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { uint8_t *d = dst; const int32_t *s = src; unsigned n = bytes/sizeof(float); @@ -264,7 +264,7 @@ static int format_s32_to_s24(bbuffer_t *b, void *dst, size_t dstr, const void *s return SA_SUCCESS; } -static int format_s32_to_f32(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_s32_to_f32(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { float f = 1.0/0x7fffffff; unsigned n = bytes/sizeof(int32_t); @@ -276,14 +276,14 @@ static int format_s32_to_f32(bbuffer_t *b, void *dst, size_t dstr, const void *s /* f32 --> */ -static int format_f32_to_u8(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_f32_to_u8(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { uint8_t *d = dst; const float *s = src; float *buf; float f = 0x7F, p = 0x80; unsigned n = bytes/sizeof(float); - if (!(buf = bbuffer_get(b, 0, bytes, 1))) + if (!(buf = sa_bbuffer_get(b, 0, bytes, 1))) return SA_ERROR_OOM; oil_scalarmult_f32(buf, sizeof(float), s, sstr, &f, n); @@ -293,7 +293,7 @@ static int format_f32_to_u8(bbuffer_t *b, void *dst, size_t dstr, const void *sr return SA_SUCCESS; } -static int format_f32_to_ulaw(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_f32_to_ulaw(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { uint8_t *d = dst; const float *s = src; unsigned n = bytes/sizeof(float); @@ -302,13 +302,13 @@ static int format_f32_to_ulaw(bbuffer_t *b, void *dst, size_t dstr, const void * float v = *s * 0x7FFF; if (v < -0x8000) v = -0x8000; if (v > -0x7FFF) v = -0x7FFF; - *d = st_13linear2alaw((int16_t) v); + *d = sa_13linear2alaw((int16_t) v); } return SA_SUCCESS; } -static int format_f32_to_alaw(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_f32_to_alaw(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { uint8_t *d = dst; const float *s = src; unsigned n = bytes/sizeof(float); @@ -317,20 +317,20 @@ static int format_f32_to_alaw(bbuffer_t *b, void *dst, size_t dstr, const void * float v = *s * 0x7FFF; if (v < -0x8000) v = -0x8000; if (v > -0x7FFF) v = -0x7FFF; - *d = st_13linear2alaw((int16_t) v); + *d = sa_13linear2alaw((int16_t) v); } return SA_SUCCESS; } -static int format_f32_to_s16(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_f32_to_s16(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { int16_t *d = dst; const float *s = src; float *buf; float f = 0x7FFF; unsigned n = bytes/sizeof(float); - if (!(buf = bbuffer_get(b, 0, bytes, 1))) + if (!(buf = sa_bbuffer_get(b, 0, bytes, 1))) return SA_ERROR_OOM; oil_scalarmult_f32(buf, sizeof(float), s, sstr, &f, n); @@ -339,7 +339,7 @@ static int format_f32_to_s16(bbuffer_t *b, void *dst, size_t dstr, const void *s return SA_SUCCESS; } -static int format_f32_to_s24(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_f32_to_s24(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { uint8_t *d = dst; const float *s = src; unsigned n = bytes/sizeof(float); @@ -369,14 +369,14 @@ static int format_f32_to_s24(bbuffer_t *b, void *dst, size_t dstr, const void *s return SA_SUCCESS; } -static int format_f32_to_s32(bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { +static int format_f32_to_s32(sa_bbuffer_t *b, void *dst, size_t dstr, const void *src, size_t sstr, size_t bytes) { int32_t *d = dst; const float *s = src; float *buf; float f = 0x7FFFFFFF; unsigned n = bytes/sizeof(float); - if (!(buf = bbuffer_get(b, 0, bytes, 1))) + if (!(buf = sa_bbuffer_get(b, 0, bytes, 1))) return SA_ERROR_OOM; oil_scalarmult_f32(buf, sizeof(float), s, sstr, &f, n); @@ -385,7 +385,7 @@ static int format_f32_to_s32(bbuffer_t *b, void *dst, size_t dstr, const void *s return SA_SUCCESS; } -format_func_t get_format_func(sa_pcm_format_t from, sa_pcm_format_t to) { +sa_format_func_t sa_get_format_func(sa_pcm_format_t from, sa_pcm_format_t to) { /* Rules: we need conversion functions: * @@ -394,7 +394,7 @@ format_func_t get_format_func(sa_pcm_format_t from, sa_pcm_format_t to) { * 3. only for NE types */ - static const format_func_t funcs[_SA_PCM_FORMAT_MAX * _SA_PCM_FORMAT_MAX] = { + static const sa_format_func_t funcs[_SA_PCM_FORMAT_MAX * _SA_PCM_FORMAT_MAX] = { [_SA_PCM_FORMAT_MAX * SA_PCM_FORMAT_U8 + SA_PCM_FORMAT_S16_NE ] = format_u8_to_s16, /* done */ [_SA_PCM_FORMAT_MAX * SA_PCM_FORMAT_U8 + SA_PCM_FORMAT_S32_NE ] = format_u8_to_s32, /* done */ [_SA_PCM_FORMAT_MAX * SA_PCM_FORMAT_U8 + SA_PCM_FORMAT_FLOAT32_NE] = format_u8_to_f32, /* done */ -- cgit