diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/daemon/main.c | 4 | ||||
| -rw-r--r-- | src/pulsecore/resampler.c | 69 | ||||
| -rw-r--r-- | src/pulsecore/sconv-s16le.c | 42 | ||||
| -rw-r--r-- | src/pulsecore/sconv.c | 28 | ||||
| -rw-r--r-- | src/tests/envelope-test.c | 3 | ||||
| -rw-r--r-- | src/tests/mix-test.c | 3 | ||||
| -rw-r--r-- | src/tests/remix-test.c | 3 | ||||
| -rw-r--r-- | src/tests/resampler-test.c | 3 | 
8 files changed, 65 insertions, 90 deletions
diff --git a/src/daemon/main.c b/src/daemon/main.c index 774b4e90..31e434d9 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -39,8 +39,6 @@  #include <sys/types.h>  #include <sys/stat.h> -#include <liboil/liboil.h> -  #ifdef HAVE_SYS_MMAN_H  #include <sys/mman.h>  #endif @@ -863,8 +861,6 @@ int main(int argc, char *argv[]) {      win32_timer = pa_mainloop_get_api(mainloop)->rtclock_time_new(pa_mainloop_get_api(mainloop), pa_gettimeofday(&win32_tv), message_cb, NULL);  #endif -    oil_init(); -      if (!conf->no_cpu_limit)          pa_assert_se(pa_cpu_limit_init(pa_mainloop_get_api(mainloop)) == 0); diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c index 59e0a0c1..a3c17f8c 100644 --- a/src/pulsecore/resampler.c +++ b/src/pulsecore/resampler.c @@ -31,9 +31,6 @@  #include <speex/speex_resampler.h> -#include <liboil/liboilfuncs.h> -#include <liboil/liboil.h> -  #include <pulse/xmalloc.h>  #include <pulsecore/sconv.h>  #include <pulsecore/log.h> @@ -1045,33 +1042,46 @@ static pa_memchunk* convert_to_work_format(pa_resampler *r, pa_memchunk *input)      return &r->buf1;  } -static void vectoradd_s16_with_fraction( -        int16_t *d, int dstr, -        const int16_t *s1, int sstr1, -        const int16_t *s2, int sstr2, -        int n, -        float s3, float s4) { +static void vectoradd_f32( +        float *d, int dstr, +        const float *s, int sstr, +        int n, float s4) { -    int32_t i3, i4; +    for (; n > 0; n--) { +        *d = (float) (*d + (s4 * *s)); -    i3 = (int32_t) (s3 * 0x10000); -    i4 = (int32_t) (s4 * 0x10000); +        s = (const float*) ((const uint8_t*) s + sstr); +        d = (float*) ((uint8_t*) d + dstr); +    } +} + +static void vectoradd_s16( +        int16_t *d, int dstr, +        const int16_t *s, int sstr, +        int n) {      for (; n > 0; n--) { -        int32_t a, b; +        *d = (int16_t) (*d + *s); -        a = *s1; -        b = *s2; +        s = (const int16_t*) ((const uint8_t*) s + sstr); +        d = (int16_t*) ((uint8_t*) d + dstr); +    } +} -        a = (a * i3) / 0x10000; -        b = (b * i4) / 0x10000; +static void vectoradd_s16_with_fraction( +        int16_t *d, int dstr, +        const int16_t *s, int sstr, +        int n, float s4) { -        *d = (int16_t) (a + b); +    int32_t i4; -        s1 = (const int16_t*) ((const uint8_t*) s1 + sstr1); -        s2 = (const int16_t*) ((const uint8_t*) s2 + sstr2); -        d = (int16_t*) ((uint8_t*) d + dstr); +    i4 = (int32_t) (s4 * 0x10000); + +    for (; n > 0; n--) { +        *d = (int16_t) (*d + (((int32_t)*s * i4) >> 16)); +        s = (const int16_t*) ((const uint8_t*) s + sstr); +        d = (int16_t*) ((uint8_t*) d + dstr);      }  } @@ -1125,12 +1135,11 @@ static pa_memchunk *remap_channels(pa_resampler *r, pa_memchunk *input) {                      if (r->map_table[oc][ic] <= 0.0)                          continue; -                    oil_vectoradd_f32( -                            (float*) dst + oc, o_skip, +                    vectoradd_f32(                              (float*) dst + oc, o_skip,                              (float*) src + ic, i_skip,                              (int) n_frames, -                            &one, &r->map_table[oc][ic]); +                            r->map_table[oc][ic]);                  }              } @@ -1147,23 +1156,19 @@ static pa_memchunk *remap_channels(pa_resampler *r, pa_memchunk *input) {                          continue;                      if (r->map_table[oc][ic] >= 1.0) { -                        static const int16_t one = 1; -                        oil_vectoradd_s16( -                                (int16_t*) dst + oc, o_skip, +                        vectoradd_s16(                                  (int16_t*) dst + oc, o_skip,                                  (int16_t*) src + ic, i_skip, -                                (int) n_frames, -                                &one, &one); +                                (int) n_frames);                      } else                          vectoradd_s16_with_fraction(                                  (int16_t*) dst + oc, o_skip, -                                (int16_t*) dst + oc, o_skip,                                  (int16_t*) src + ic, i_skip,                                  (int) n_frames, -                                1.0f, r->map_table[oc][ic]); +                                r->map_table[oc][ic]);                  }              } @@ -1469,7 +1474,7 @@ static void trivial_resample(pa_resampler *r, const pa_memchunk *input, unsigned          pa_assert(o_index * fz < pa_memblock_get_length(output->memblock)); -        oil_memcpy((uint8_t*) dst + fz * o_index, +        memcpy((uint8_t*) dst + fz * o_index,                     (uint8_t*) src + fz * j, (int) fz);      } diff --git a/src/pulsecore/sconv-s16le.c b/src/pulsecore/sconv-s16le.c index 43b8cb3e..0fefdf1c 100644 --- a/src/pulsecore/sconv-s16le.c +++ b/src/pulsecore/sconv-s16le.c @@ -28,8 +28,6 @@  #include <inttypes.h>  #include <stdio.h> -#include <liboil/liboilfuncs.h> -  #include <pulsecore/sconv.h>  #include <pulsecore/macro.h>  #include <pulsecore/log.h> @@ -86,17 +84,13 @@ void pa_sconv_s16le_to_float32ne(unsigned n, const int16_t *a, float *b) {      pa_assert(b);  #if SWAP_WORDS == 1 -      for (; n > 0; n--) {          int16_t s = *(a++);          *(b++) = ((float) INT16_FROM(s))/(float) 0x7FFF;      } -  #else -{ -    static const double add = 0, factor = 1.0/0x7FFF; -    oil_scaleconv_f32_s16(b, a, (int) n, &add, &factor); -} +    for (; n > 0; n--) +        *(b++) = ((float) (*(a++)))/(float) 0x7FFF;  #endif  } @@ -105,17 +99,13 @@ void pa_sconv_s32le_to_float32ne(unsigned n, const int32_t *a, float *b) {      pa_assert(b);  #if SWAP_WORDS == 1 -      for (; n > 0; n--) {          int32_t s = *(a++);          *(b++) = (float) (((double) INT32_FROM(s))/0x7FFFFFFF);      } -  #else -{ -    static const double add = 0, factor = 1.0/0x7FFFFFFF; -    oil_scaleconv_f32_s32(b, a, (int) n, &add, &factor); -} +    for (; n > 0; n--) +        *(b++) = (float) (((double) (*(a++)))/0x7FFFFFFF);  #endif  } @@ -124,7 +114,6 @@ void pa_sconv_s16le_from_float32ne(unsigned n, const float *a, int16_t *b) {      pa_assert(b);  #if SWAP_WORDS == 1 -      for (; n > 0; n--) {          int16_t s;          float v = *(a++); @@ -133,12 +122,13 @@ void pa_sconv_s16le_from_float32ne(unsigned n, const float *a, int16_t *b) {          s = (int16_t) lrintf(v * 0x7FFF);          *(b++) = INT16_TO(s);      } -  #else -{ -    static const double add = 0, factor = 0x7FFF; -    oil_scaleconv_s16_f32(b, a, (int) n, &add, &factor); -} +    for (; n > 0; n--) { +        float v = *(a++); + +        v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.f); +        *(b++) = (int16_t) lrintf(v * 0x7FFF); +    }  #endif  } @@ -147,7 +137,6 @@ void pa_sconv_s32le_from_float32ne(unsigned n, const float *a, int32_t *b) {      pa_assert(b);  #if SWAP_WORDS == 1 -      for (; n > 0; n--) {          int32_t s;          float v = *(a++); @@ -156,12 +145,13 @@ void pa_sconv_s32le_from_float32ne(unsigned n, const float *a, int32_t *b) {          s = (int32_t) lrint((double) v * (double) 0x7FFFFFFF);          *(b++) = INT32_TO(s);      } -  #else -{ -    static const double add = 0, factor = 0x7FFFFFFF; -    oil_scaleconv_s32_f32(b, a, (int) n, &add, &factor); -} +    for (; n > 0; n--) { +        float v = *(a++); + +        v = PA_CLAMP_UNLIKELY(v, -1.0f, 1.0f); +        *(b++) = (int32_t) lrint((double) v * (double) 0x7FFFFFFF); +    }  #endif  } diff --git a/src/pulsecore/sconv.c b/src/pulsecore/sconv.c index d89f4283..937bf5d1 100644 --- a/src/pulsecore/sconv.c +++ b/src/pulsecore/sconv.c @@ -27,9 +27,6 @@  #include <stdio.h>  #include <stdlib.h> -#include <liboil/liboilfuncs.h> -#include <liboil/liboil.h> -  #include <pulsecore/g711.h>  #include <pulsecore/macro.h> @@ -41,32 +38,31 @@  /* u8 */  static void u8_to_float32ne(unsigned n, const uint8_t *a, float *b) { -    static const double add = -1, factor = 1.0/128.0; -      pa_assert(a);      pa_assert(b); -    oil_scaleconv_f32_u8(b, a, (int) n, &add, &factor); +    for (; n > 0; n--, a++, b++) +        *b = (*a * 1.0/128.0) - 1.0;  }  static void u8_from_float32ne(unsigned n, const float *a, uint8_t *b) { -    static const double add = 128, factor = 127.0; -      pa_assert(a);      pa_assert(b); -    oil_scaleconv_u8_f32(b, a, (int) n, &add, &factor); +    for (; n > 0; n--, a++, b++) { +        float v; +        v = (*a * 127.0) + 128.0; +	v = PA_CLAMP_UNLIKELY (v, 0.0, 255.0); +	*b = rint (v); +    }  }  static void u8_to_s16ne(unsigned n, const uint8_t *a, int16_t *b) { -    static const int16_t add = -0x80, factor = 0x100; -      pa_assert(a);      pa_assert(b); -    oil_conv_s16_u8(b, 2, a, 1, (int) n); -    oil_scalaradd_s16(b, 2, b, 2, &add, (int) n); -    oil_scalarmult_s16(b, 2, b, 2, &factor, (int) n); +    for (; n > 0; n--, a++, b++) +        *b = (((int16_t)*a) - 128) << 8;  }  static void u8_from_s16ne(unsigned n, const int16_t *a, uint8_t *b) { @@ -84,7 +80,7 @@ static void float32ne_to_float32ne(unsigned n, const float *a, float *b) {      pa_assert(a);      pa_assert(b); -    oil_memcpy(b, a, (int) (sizeof(float) * n)); +    memcpy(b, a, (int) (sizeof(float) * n));  }  static void float32re_to_float32ne(unsigned n, const float *a, float *b) { @@ -101,7 +97,7 @@ static void s16ne_to_s16ne(unsigned n, const int16_t *a, int16_t *b) {      pa_assert(a);      pa_assert(b); -    oil_memcpy(b, a, (int) (sizeof(int16_t) * n)); +    memcpy(b, a, (int) (sizeof(int16_t) * n));  }  static void s16re_to_s16ne(unsigned n, const int16_t *a, int16_t *b) { diff --git a/src/tests/envelope-test.c b/src/tests/envelope-test.c index 3af3044e..9382040b 100644 --- a/src/tests/envelope-test.c +++ b/src/tests/envelope-test.c @@ -34,8 +34,6 @@  #include <pulsecore/memblock.h>  #include <pulsecore/sample-util.h> -#include <liboil/liboil.h> -  const pa_envelope_def ramp_down = {      .n_points = 2,      .points_x = { 100*PA_USEC_PER_MSEC, 300*PA_USEC_PER_MSEC }, @@ -202,7 +200,6 @@ int main(int argc, char *argv[]) {          .values = { PA_VOLUME_NORM, PA_VOLUME_NORM/2 }      }; -    oil_init();      pa_log_set_level(PA_LOG_DEBUG);      pa_assert_se(pool = pa_mempool_new(FALSE, 0)); diff --git a/src/tests/mix-test.c b/src/tests/mix-test.c index f9f76da3..457c4acd 100644 --- a/src/tests/mix-test.c +++ b/src/tests/mix-test.c @@ -32,8 +32,6 @@  #include <pulsecore/memblock.h>  #include <pulsecore/sample-util.h> -#include <liboil/liboil.h> -  static float swap_float(float a) {      uint32_t *b = (uint32_t*) &a;      *b = PA_UINT32_SWAP(*b); @@ -211,7 +209,6 @@ int main(int argc, char *argv[]) {      pa_sample_spec a;      pa_cvolume v; -    oil_init();      pa_log_set_level(PA_LOG_DEBUG);      pa_assert_se(pool = pa_mempool_new(FALSE, 0)); diff --git a/src/tests/remix-test.c b/src/tests/remix-test.c index 9d110d6b..4990bf93 100644 --- a/src/tests/remix-test.c +++ b/src/tests/remix-test.c @@ -32,8 +32,6 @@  #include <pulsecore/memblock.h>  #include <pulsecore/sample-util.h> -#include <liboil/liboil.h> -  int main(int argc, char *argv[]) {      static const pa_channel_map maps[] = { @@ -55,7 +53,6 @@ int main(int argc, char *argv[]) {      unsigned i, j;      pa_mempool *pool; -    oil_init();      pa_log_set_level(PA_LOG_DEBUG);      pa_assert_se(pool = pa_mempool_new(FALSE, 0)); diff --git a/src/tests/resampler-test.c b/src/tests/resampler-test.c index 7236265a..82198b5e 100644 --- a/src/tests/resampler-test.c +++ b/src/tests/resampler-test.c @@ -32,8 +32,6 @@  #include <pulsecore/memblock.h>  #include <pulsecore/sample-util.h> -#include <liboil/liboil.h> -  static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) {      void *d;      unsigned i; @@ -248,7 +246,6 @@ int main(int argc, char *argv[]) {      pa_sample_spec a, b;      pa_cvolume v; -    oil_init();      pa_log_set_level(PA_LOG_DEBUG);      pa_assert_se(pool = pa_mempool_new(FALSE, 0));  | 
