From f44ba092651aa75055e109e04b4164ea92ae7fdc Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 19 Jun 2006 21:53:48 +0000 Subject: big s/polyp/pulse/g git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1033 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/sconv.c | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 src/pulsecore/sconv.c (limited to 'src/pulsecore/sconv.c') diff --git a/src/pulsecore/sconv.c b/src/pulsecore/sconv.c new file mode 100644 index 00000000..ff2a0110 --- /dev/null +++ b/src/pulsecore/sconv.c @@ -0,0 +1,169 @@ +/* $Id$ */ + +/*** + This file is part of PulseAudio. + + PulseAudio 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 of the License, + or (at your option) any later version. + + PulseAudio 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 + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include +#include + +#include + +#include "endianmacros.h" +#include "sconv-s16le.h" +#include "sconv-s16be.h" + +#include "sconv.h" + +static void u8_to_float32ne(unsigned n, const void *a, float *b) { + const uint8_t *ca = a; + static const double add = -128.0/127.0, factor = 1.0/127.0; + + assert(a); + assert(b); + + oil_scaleconv_f32_u8(b, ca, n, &add, &factor); +} + +static void u8_from_float32ne(unsigned n, const float *a, void *b) { + uint8_t *cb = b; + static const double add = 128.0, factor = 127.0; + + assert(a); + assert(b); + + oil_scaleconv_u8_f32(cb, a, n, &add, &factor); +} + +static void float32ne_to_float32ne(unsigned n, const void *a, float *b) { + assert(a); + assert(b); + + oil_memcpy(b, a, sizeof(float) * n); +} + +static void float32ne_from_float32ne(unsigned n, const float *a, void *b) { + assert(a); + assert(b); + + oil_memcpy(b, a, sizeof(float) * n); +} + +static void ulaw_to_float32ne(unsigned n, const void *a, float *b) { + const uint8_t *ca = a; + + assert(a); + assert(b); + + for (; n > 0; n--) + *(b++) = st_ulaw2linear16(*(ca++)) * 1.0F / 0x7FFF; +} + +static void ulaw_from_float32ne(unsigned n, const float *a, void *b) { + uint8_t *cb = b; + + assert(a); + assert(b); + + for (; n > 0; n--) { + float v = *(a++); + + if (v > 1) + v = 1; + + if (v < -1) + v = -1; + + *(cb++) = st_14linear2ulaw((int16_t) (v * 0x1FFF)); + } +} + +static void alaw_to_float32ne(unsigned n, const void *a, float *b) { + const uint8_t *ca = a; + + assert(a); + assert(b); + + for (; n > 0; n--) + *(b++) = st_alaw2linear16(*(ca++)) * 1.0F / 0x7FFF; +} + +static void alaw_from_float32ne(unsigned n, const float *a, void *b) { + uint8_t *cb = b; + + assert(a); + assert(b); + + for (; n > 0; n--) { + float v = *(a++); + + if (v > 1) + v = 1; + + if (v < -1) + v = -1; + + *(cb++) = st_13linear2alaw((int16_t) (v * 0xFFF)); + } +} + +pa_convert_to_float32ne_func_t pa_get_convert_to_float32ne_function(pa_sample_format_t f) { + switch(f) { + case PA_SAMPLE_U8: + return u8_to_float32ne; + case PA_SAMPLE_S16LE: + return pa_sconv_s16le_to_float32ne; + case PA_SAMPLE_S16BE: + return pa_sconv_s16be_to_float32ne; + case PA_SAMPLE_FLOAT32NE: + return float32ne_to_float32ne; + case PA_SAMPLE_ALAW: + return alaw_to_float32ne; + case PA_SAMPLE_ULAW: + return ulaw_to_float32ne; + default: + return NULL; + } +} + +pa_convert_from_float32ne_func_t pa_get_convert_from_float32ne_function(pa_sample_format_t f) { + switch(f) { + case PA_SAMPLE_U8: + return u8_from_float32ne; + case PA_SAMPLE_S16LE: + return pa_sconv_s16le_from_float32ne; + case PA_SAMPLE_S16BE: + return pa_sconv_s16be_from_float32ne; + case PA_SAMPLE_FLOAT32NE: + return float32ne_from_float32ne; + case PA_SAMPLE_ALAW: + return alaw_from_float32ne; + case PA_SAMPLE_ULAW: + return ulaw_from_float32ne; + default: + return NULL; + } +} -- cgit From 0ef2d7eb778e25d252c78594fa6490a6cb654cb9 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Wed, 8 Nov 2006 13:03:35 +0000 Subject: Support reversed endian floats. (closes #28) (closes #35) git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1412 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/sconv.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/pulsecore/sconv.c') diff --git a/src/pulsecore/sconv.c b/src/pulsecore/sconv.c index ff2a0110..2e5e2dbe 100644 --- a/src/pulsecore/sconv.c +++ b/src/pulsecore/sconv.c @@ -72,6 +72,22 @@ static void float32ne_from_float32ne(unsigned n, const float *a, void *b) { oil_memcpy(b, a, sizeof(float) * n); } +static void float32re_to_float32ne(unsigned n, const void *a, float *b) { + assert(a); + assert(b); + + while (n-- > 0) + ((uint32_t *)b)[n] = UINT32_SWAP (((uint32_t *)a)[n]); +} + +static void float32re_from_float32ne(unsigned n, const float *a, void *b) { + assert(a); + assert(b); + + while (n-- > 0) + ((uint32_t *)b)[n] = UINT32_SWAP (((uint32_t *)a)[n]); +} + static void ulaw_to_float32ne(unsigned n, const void *a, float *b) { const uint8_t *ca = a; @@ -140,6 +156,8 @@ pa_convert_to_float32ne_func_t pa_get_convert_to_float32ne_function(pa_sample_fo return pa_sconv_s16be_to_float32ne; case PA_SAMPLE_FLOAT32NE: return float32ne_to_float32ne; + case PA_SAMPLE_FLOAT32RE: + return float32re_to_float32ne; case PA_SAMPLE_ALAW: return alaw_to_float32ne; case PA_SAMPLE_ULAW: @@ -159,6 +177,8 @@ pa_convert_from_float32ne_func_t pa_get_convert_from_float32ne_function(pa_sampl return pa_sconv_s16be_from_float32ne; case PA_SAMPLE_FLOAT32NE: return float32ne_from_float32ne; + case PA_SAMPLE_FLOAT32RE: + return float32re_from_float32ne; case PA_SAMPLE_ALAW: return alaw_from_float32ne; case PA_SAMPLE_ULAW: -- cgit From 521daf6f0ac4fa6a2fbfb5d523c0c743342dca2b Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 4 Jan 2007 13:43:45 +0000 Subject: Huge trailing whitespace cleanup. Let's keep the tree pure from here on, mmmkay? git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1418 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/sconv.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/pulsecore/sconv.c') diff --git a/src/pulsecore/sconv.c b/src/pulsecore/sconv.c index 2e5e2dbe..6bea0608 100644 --- a/src/pulsecore/sconv.c +++ b/src/pulsecore/sconv.c @@ -2,17 +2,17 @@ /*** This file is part of PulseAudio. - + PulseAudio 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 of the License, or (at your option) any later version. - + PulseAudio 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 General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with PulseAudio; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -41,12 +41,12 @@ static void u8_to_float32ne(unsigned n, const void *a, float *b) { const uint8_t *ca = a; static const double add = -128.0/127.0, factor = 1.0/127.0; - + assert(a); assert(b); oil_scaleconv_f32_u8(b, ca, n, &add, &factor); -} +} static void u8_from_float32ne(unsigned n, const float *a, void *b) { uint8_t *cb = b; @@ -93,7 +93,7 @@ static void ulaw_to_float32ne(unsigned n, const void *a, float *b) { assert(a); assert(b); - + for (; n > 0; n--) *(b++) = st_ulaw2linear16(*(ca++)) * 1.0F / 0x7FFF; } @@ -103,7 +103,7 @@ static void ulaw_from_float32ne(unsigned n, const float *a, void *b) { assert(a); assert(b); - + for (; n > 0; n--) { float v = *(a++); @@ -132,7 +132,7 @@ static void alaw_from_float32ne(unsigned n, const float *a, void *b) { assert(a); assert(b); - + for (; n > 0; n--) { float v = *(a++); -- cgit From 06211b7c8fd329137ae9003818543912a87d9898 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Tue, 13 Feb 2007 15:35:19 +0000 Subject: Add copyright notices to all relevant files. (based on svn log) git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1426 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/sconv.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/pulsecore/sconv.c') diff --git a/src/pulsecore/sconv.c b/src/pulsecore/sconv.c index 6bea0608..d15cec84 100644 --- a/src/pulsecore/sconv.c +++ b/src/pulsecore/sconv.c @@ -3,6 +3,9 @@ /*** This file is part of PulseAudio. + Copyright 2004-2006 Lennart Poettering + Copyright 2006 Pierre Ossman for Cendio AB + PulseAudio 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 of the License, -- cgit From a67c21f093202f142438689d3f7cfbdf4ea82eea Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 28 Oct 2007 19:13:50 +0000 Subject: merge 'lennart' branch back into trunk. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1971 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/sconv.c | 273 +++++++++++++++++++++++++++++++------------------- 1 file changed, 172 insertions(+), 101 deletions(-) (limited to 'src/pulsecore/sconv.c') diff --git a/src/pulsecore/sconv.c b/src/pulsecore/sconv.c index d15cec84..7f5da63f 100644 --- a/src/pulsecore/sconv.c +++ b/src/pulsecore/sconv.c @@ -28,12 +28,12 @@ #include #include -#include #include #include #include +#include #include "endianmacros.h" #include "sconv-s16le.h" @@ -41,152 +41,223 @@ #include "sconv.h" -static void u8_to_float32ne(unsigned n, const void *a, float *b) { - const uint8_t *ca = a; - static const double add = -128.0/127.0, factor = 1.0/127.0; +/* u8 */ +static void u8_to_float32ne(unsigned n, const uint8_t *a, float *b) { + static const double add = -1, factor = 1.0/128.0; - assert(a); - assert(b); + pa_assert(a); + pa_assert(b); - oil_scaleconv_f32_u8(b, ca, n, &add, &factor); + oil_scaleconv_f32_u8(b, a, n, &add, &factor); } -static void u8_from_float32ne(unsigned n, const float *a, void *b) { - uint8_t *cb = b; - static const double add = 128.0, factor = 127.0; +static void u8_from_float32ne(unsigned n, const float *a, uint8_t *b) { + static const double add = 128, factor = 127.0; - assert(a); - assert(b); + pa_assert(a); + pa_assert(b); - oil_scaleconv_u8_f32(cb, a, n, &add, &factor); + oil_scaleconv_u8_f32(b, a, n, &add, &factor); } -static void float32ne_to_float32ne(unsigned n, const void *a, float *b) { - assert(a); - assert(b); +static void u8_to_s16ne(unsigned n, const uint8_t *a, int16_t *b) { + static const int16_t add = -0x80, factor = 0x100; - oil_memcpy(b, a, sizeof(float) * n); + pa_assert(a); + pa_assert(b); + + oil_conv_s16_u8(b, 2, a, 1, n); + oil_scalaradd_s16(b, 2, b, 2, &add, n); + oil_scalarmult_s16(b, 2, b, 2, &factor, n); +} + +static void u8_from_s16ne(unsigned n, const int16_t *a, uint8_t *b) { + + pa_assert(a); + pa_assert(b); + + for (; n > 0; n--, a++, b++) + *b = (uint8_t) (*a / 0x100 + 0x80); } -static void float32ne_from_float32ne(unsigned n, const float *a, void *b) { - assert(a); - assert(b); +/* float32 */ + +static void float32ne_to_float32ne(unsigned n, const float *a, float *b) { + pa_assert(a); + pa_assert(b); oil_memcpy(b, a, sizeof(float) * n); } -static void float32re_to_float32ne(unsigned n, const void *a, float *b) { - assert(a); - assert(b); +static void float32re_to_float32ne(unsigned n, const float *a, float *b) { + pa_assert(a); + pa_assert(b); + + for (; n > 0; n--, a++, b++) + *((uint32_t *) b) = PA_UINT32_SWAP(*((uint32_t *) a)); +} + +/* s16 */ - while (n-- > 0) - ((uint32_t *)b)[n] = UINT32_SWAP (((uint32_t *)a)[n]); +static void s16ne_to_s16ne(unsigned n, const int16_t *a, int16_t *b) { + pa_assert(a); + pa_assert(b); + + oil_memcpy(b, a, sizeof(int16_t) * n); } -static void float32re_from_float32ne(unsigned n, const float *a, void *b) { - assert(a); - assert(b); +static void s16re_to_s16ne(unsigned n, const int16_t *a, int16_t *b) { + pa_assert(a); + pa_assert(b); - while (n-- > 0) - ((uint32_t *)b)[n] = UINT32_SWAP (((uint32_t *)a)[n]); + for (; n > 0; n--, a++, b++) + *b = PA_UINT16_SWAP(*a); } -static void ulaw_to_float32ne(unsigned n, const void *a, float *b) { - const uint8_t *ca = a; +/* ulaw */ - assert(a); - assert(b); +static void ulaw_to_float32ne(unsigned n, const uint8_t *a, float *b) { + pa_assert(a); + pa_assert(b); for (; n > 0; n--) - *(b++) = st_ulaw2linear16(*(ca++)) * 1.0F / 0x7FFF; + *(b++) = (float) st_ulaw2linear16(*(a++)) / 0x8000; } -static void ulaw_from_float32ne(unsigned n, const float *a, void *b) { - uint8_t *cb = b; - - assert(a); - assert(b); +static void ulaw_from_float32ne(unsigned n, const float *a, uint8_t *b) { + pa_assert(a); + pa_assert(b); for (; n > 0; n--) { float v = *(a++); + v = CLAMP(v, -1, 1); + v *= 0x1FFF; + *(b++) = st_14linear2ulaw((int16_t) v); + } +} + +static void ulaw_to_s16ne(unsigned n, const uint8_t *a, int16_t *b) { + pa_assert(a); + pa_assert(b); + + for (; n > 0; n--, a++, b++) + *b = st_ulaw2linear16(*a); +} + +static void ulaw_from_s16ne(unsigned n, const int16_t *a, uint8_t *b) { + pa_assert(a); + pa_assert(b); + + for (; n > 0; n--, a++, b++) + *b = st_14linear2ulaw(*a >> 2); +} - if (v > 1) - v = 1; +/* alaw */ - if (v < -1) - v = -1; +static void alaw_to_float32ne(unsigned n, const uint8_t *a, float *b) { + pa_assert(a); + pa_assert(b); - *(cb++) = st_14linear2ulaw((int16_t) (v * 0x1FFF)); + for (; n > 0; n--, a++, b++) + *b = (float) st_alaw2linear16(*a) / 0x8000; +} + +static void alaw_from_float32ne(unsigned n, const float *a, uint8_t *b) { + pa_assert(a); + pa_assert(b); + + for (; n > 0; n--, a++, b++) { + float v = *a; + v = CLAMP(v, -1, 1); + v *= 0xFFF; + *b = st_13linear2alaw((int16_t) v); } } -static void alaw_to_float32ne(unsigned n, const void *a, float *b) { - const uint8_t *ca = a; +static void alaw_to_s16ne(unsigned n, const int8_t *a, int16_t *b) { + pa_assert(a); + pa_assert(b); - assert(a); - assert(b); + for (; n > 0; n--, a++, b++) + *b = st_alaw2linear16(*a); +} - for (; n > 0; n--) - *(b++) = st_alaw2linear16(*(ca++)) * 1.0F / 0x7FFF; +static void alaw_from_s16ne(unsigned n, const int16_t *a, uint8_t *b) { + pa_assert(a); + pa_assert(b); + + for (; n > 0; n--, a++, b++) + *b = st_13linear2alaw(*a >> 3); } -static void alaw_from_float32ne(unsigned n, const float *a, void *b) { - uint8_t *cb = b; +pa_convert_func_t pa_get_convert_to_float32ne_function(pa_sample_format_t f) { - assert(a); - assert(b); + static const pa_convert_func_t table[] = { + [PA_SAMPLE_U8] = (pa_convert_func_t) u8_to_float32ne, + [PA_SAMPLE_ALAW] = (pa_convert_func_t) alaw_to_float32ne, + [PA_SAMPLE_ULAW] = (pa_convert_func_t) ulaw_to_float32ne, + [PA_SAMPLE_S16LE] = (pa_convert_func_t) pa_sconv_s16le_to_float32ne, + [PA_SAMPLE_S16BE] = (pa_convert_func_t) pa_sconv_s16be_to_float32ne, + [PA_SAMPLE_FLOAT32NE] = (pa_convert_func_t) float32ne_to_float32ne, + [PA_SAMPLE_FLOAT32RE] = (pa_convert_func_t) float32re_to_float32ne, + }; - for (; n > 0; n--) { - float v = *(a++); + pa_assert(f >= 0); + pa_assert(f < PA_SAMPLE_MAX); - if (v > 1) - v = 1; + return table[f]; +} - if (v < -1) - v = -1; +pa_convert_func_t pa_get_convert_from_float32ne_function(pa_sample_format_t f) { - *(cb++) = st_13linear2alaw((int16_t) (v * 0xFFF)); - } + static const pa_convert_func_t table[] = { + [PA_SAMPLE_U8] = (pa_convert_func_t) u8_from_float32ne, + [PA_SAMPLE_S16LE] = (pa_convert_func_t) pa_sconv_s16le_from_float32ne, + [PA_SAMPLE_S16BE] = (pa_convert_func_t) pa_sconv_s16be_from_float32ne, + [PA_SAMPLE_FLOAT32NE] = (pa_convert_func_t) float32ne_to_float32ne, + [PA_SAMPLE_FLOAT32RE] = (pa_convert_func_t) float32re_to_float32ne, + [PA_SAMPLE_ALAW] = (pa_convert_func_t) alaw_from_float32ne, + [PA_SAMPLE_ULAW] = (pa_convert_func_t) ulaw_from_float32ne + }; + + pa_assert(f >= 0); + pa_assert(f < PA_SAMPLE_MAX); + + return table[f]; } -pa_convert_to_float32ne_func_t pa_get_convert_to_float32ne_function(pa_sample_format_t f) { - switch(f) { - case PA_SAMPLE_U8: - return u8_to_float32ne; - case PA_SAMPLE_S16LE: - return pa_sconv_s16le_to_float32ne; - case PA_SAMPLE_S16BE: - return pa_sconv_s16be_to_float32ne; - case PA_SAMPLE_FLOAT32NE: - return float32ne_to_float32ne; - case PA_SAMPLE_FLOAT32RE: - return float32re_to_float32ne; - case PA_SAMPLE_ALAW: - return alaw_to_float32ne; - case PA_SAMPLE_ULAW: - return ulaw_to_float32ne; - default: - return NULL; - } +pa_convert_func_t pa_get_convert_to_s16ne_function(pa_sample_format_t f) { + + static const pa_convert_func_t table[] = { + [PA_SAMPLE_U8] = (pa_convert_func_t) u8_to_s16ne, + [PA_SAMPLE_S16NE] = (pa_convert_func_t) s16ne_to_s16ne, + [PA_SAMPLE_S16RE] = (pa_convert_func_t) s16re_to_s16ne, + [PA_SAMPLE_FLOAT32BE] = (pa_convert_func_t) pa_sconv_float32be_to_s16ne, + [PA_SAMPLE_FLOAT32LE] = (pa_convert_func_t) pa_sconv_float32le_to_s16ne, + [PA_SAMPLE_ALAW] = (pa_convert_func_t) alaw_to_s16ne, + [PA_SAMPLE_ULAW] = (pa_convert_func_t) ulaw_to_s16ne + }; + + pa_assert(f >= 0); + pa_assert(f < PA_SAMPLE_MAX); + + return table[f]; } -pa_convert_from_float32ne_func_t pa_get_convert_from_float32ne_function(pa_sample_format_t f) { - switch(f) { - case PA_SAMPLE_U8: - return u8_from_float32ne; - case PA_SAMPLE_S16LE: - return pa_sconv_s16le_from_float32ne; - case PA_SAMPLE_S16BE: - return pa_sconv_s16be_from_float32ne; - case PA_SAMPLE_FLOAT32NE: - return float32ne_from_float32ne; - case PA_SAMPLE_FLOAT32RE: - return float32re_from_float32ne; - case PA_SAMPLE_ALAW: - return alaw_from_float32ne; - case PA_SAMPLE_ULAW: - return ulaw_from_float32ne; - default: - return NULL; - } +pa_convert_func_t pa_get_convert_from_s16ne_function(pa_sample_format_t f) { + + static const pa_convert_func_t table[] = { + [PA_SAMPLE_U8] = (pa_convert_func_t) u8_from_s16ne, + [PA_SAMPLE_S16NE] = (pa_convert_func_t) s16ne_to_s16ne, + [PA_SAMPLE_S16RE] = (pa_convert_func_t) s16re_to_s16ne, + [PA_SAMPLE_FLOAT32BE] = (pa_convert_func_t) pa_sconv_float32be_from_s16ne, + [PA_SAMPLE_FLOAT32LE] = (pa_convert_func_t) pa_sconv_float32le_from_s16ne, + [PA_SAMPLE_ALAW] = (pa_convert_func_t) alaw_from_s16ne, + [PA_SAMPLE_ULAW] = (pa_convert_func_t) ulaw_from_s16ne, + }; + + pa_assert(f >= 0); + pa_assert(f < PA_SAMPLE_MAX); + + return table[f]; } -- cgit From 7e0f547f2fd8ddfae1d807334dbc3428a3dfe374 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 9 Nov 2007 02:45:07 +0000 Subject: add support for 32bit integer samples git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2037 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/sconv.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/pulsecore/sconv.c') diff --git a/src/pulsecore/sconv.c b/src/pulsecore/sconv.c index 7f5da63f..8a3e830a 100644 --- a/src/pulsecore/sconv.c +++ b/src/pulsecore/sconv.c @@ -198,6 +198,8 @@ pa_convert_func_t pa_get_convert_to_float32ne_function(pa_sample_format_t f) { [PA_SAMPLE_ULAW] = (pa_convert_func_t) ulaw_to_float32ne, [PA_SAMPLE_S16LE] = (pa_convert_func_t) pa_sconv_s16le_to_float32ne, [PA_SAMPLE_S16BE] = (pa_convert_func_t) pa_sconv_s16be_to_float32ne, + [PA_SAMPLE_S32LE] = (pa_convert_func_t) pa_sconv_s32le_to_float32ne, + [PA_SAMPLE_S32BE] = (pa_convert_func_t) pa_sconv_s32be_to_float32ne, [PA_SAMPLE_FLOAT32NE] = (pa_convert_func_t) float32ne_to_float32ne, [PA_SAMPLE_FLOAT32RE] = (pa_convert_func_t) float32re_to_float32ne, }; @@ -214,6 +216,8 @@ pa_convert_func_t pa_get_convert_from_float32ne_function(pa_sample_format_t f) { [PA_SAMPLE_U8] = (pa_convert_func_t) u8_from_float32ne, [PA_SAMPLE_S16LE] = (pa_convert_func_t) pa_sconv_s16le_from_float32ne, [PA_SAMPLE_S16BE] = (pa_convert_func_t) pa_sconv_s16be_from_float32ne, + [PA_SAMPLE_S32LE] = (pa_convert_func_t) pa_sconv_s32le_from_float32ne, + [PA_SAMPLE_S32BE] = (pa_convert_func_t) pa_sconv_s32be_from_float32ne, [PA_SAMPLE_FLOAT32NE] = (pa_convert_func_t) float32ne_to_float32ne, [PA_SAMPLE_FLOAT32RE] = (pa_convert_func_t) float32re_to_float32ne, [PA_SAMPLE_ALAW] = (pa_convert_func_t) alaw_from_float32ne, @@ -234,6 +238,8 @@ pa_convert_func_t pa_get_convert_to_s16ne_function(pa_sample_format_t f) { [PA_SAMPLE_S16RE] = (pa_convert_func_t) s16re_to_s16ne, [PA_SAMPLE_FLOAT32BE] = (pa_convert_func_t) pa_sconv_float32be_to_s16ne, [PA_SAMPLE_FLOAT32LE] = (pa_convert_func_t) pa_sconv_float32le_to_s16ne, + [PA_SAMPLE_S32BE] = (pa_convert_func_t) pa_sconv_s32be_to_s16ne, + [PA_SAMPLE_S32LE] = (pa_convert_func_t) pa_sconv_s32le_to_s16ne, [PA_SAMPLE_ALAW] = (pa_convert_func_t) alaw_to_s16ne, [PA_SAMPLE_ULAW] = (pa_convert_func_t) ulaw_to_s16ne }; @@ -252,6 +258,8 @@ pa_convert_func_t pa_get_convert_from_s16ne_function(pa_sample_format_t f) { [PA_SAMPLE_S16RE] = (pa_convert_func_t) s16re_to_s16ne, [PA_SAMPLE_FLOAT32BE] = (pa_convert_func_t) pa_sconv_float32be_from_s16ne, [PA_SAMPLE_FLOAT32LE] = (pa_convert_func_t) pa_sconv_float32le_from_s16ne, + [PA_SAMPLE_S32BE] = (pa_convert_func_t) pa_sconv_s32be_from_s16ne, + [PA_SAMPLE_S32LE] = (pa_convert_func_t) pa_sconv_s32le_from_s16ne, [PA_SAMPLE_ALAW] = (pa_convert_func_t) alaw_from_s16ne, [PA_SAMPLE_ULAW] = (pa_convert_func_t) ulaw_from_s16ne, }; -- cgit From c1985c2acc43f5d2c23e1e736588c5ef3a398a17 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 9 Nov 2007 14:20:12 +0000 Subject: replace a few CLAMPs by PA_CLAMP_UNLIKELY git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2040 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/pulsecore/sconv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pulsecore/sconv.c') diff --git a/src/pulsecore/sconv.c b/src/pulsecore/sconv.c index 8a3e830a..ebd74586 100644 --- a/src/pulsecore/sconv.c +++ b/src/pulsecore/sconv.c @@ -130,7 +130,7 @@ static void ulaw_from_float32ne(unsigned n, const float *a, uint8_t *b) { for (; n > 0; n--) { float v = *(a++); - v = CLAMP(v, -1, 1); + v = PA_CLAMP_UNLIKELY(v, -1, 1); v *= 0x1FFF; *(b++) = st_14linear2ulaw((int16_t) v); } @@ -168,7 +168,7 @@ static void alaw_from_float32ne(unsigned n, const float *a, uint8_t *b) { for (; n > 0; n--, a++, b++) { float v = *a; - v = CLAMP(v, -1, 1); + v = PA_CLAMP_UNLIKELY(v, -1, 1); v *= 0xFFF; *b = st_13linear2alaw((int16_t) v); } -- cgit