mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-13 13:29:58 -05:00
big resampler rework: support integer-only resampling, support speex resampler
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1712 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
4eb9bb0746
commit
ed4dc16b95
8 changed files with 723 additions and 442 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -41,6 +41,11 @@ typedef enum pa_resample_method {
|
||||||
PA_RESAMPLER_SRC_ZERO_ORDER_HOLD = SRC_ZERO_ORDER_HOLD,
|
PA_RESAMPLER_SRC_ZERO_ORDER_HOLD = SRC_ZERO_ORDER_HOLD,
|
||||||
PA_RESAMPLER_SRC_LINEAR = SRC_LINEAR,
|
PA_RESAMPLER_SRC_LINEAR = SRC_LINEAR,
|
||||||
PA_RESAMPLER_TRIVIAL,
|
PA_RESAMPLER_TRIVIAL,
|
||||||
|
PA_RESAMPLER_SPEEX_FLOAT_BASE,
|
||||||
|
PA_RESAMPLER_SPEEX_FLOAT_MAX = PA_RESAMPLER_SPEEX_FLOAT_BASE + 10,
|
||||||
|
PA_RESAMPLER_SPEEX_FIXED_BASE,
|
||||||
|
PA_RESAMPLER_SPEEX_FIXED_MAX = PA_RESAMPLER_SPEEX_FIXED_BASE + 10,
|
||||||
|
PA_RESAMPLER_AUTO, /* automatic select based on sample format */
|
||||||
PA_RESAMPLER_MAX
|
PA_RESAMPLER_MAX
|
||||||
} pa_resample_method_t;
|
} pa_resample_method_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,9 @@
|
||||||
#define pa_sconv_s16le_to_float32ne pa_sconv_s16be_to_float32ne
|
#define pa_sconv_s16le_to_float32ne pa_sconv_s16be_to_float32ne
|
||||||
#define pa_sconv_s16le_from_float32ne pa_sconv_s16be_from_float32ne
|
#define pa_sconv_s16le_from_float32ne pa_sconv_s16be_from_float32ne
|
||||||
|
|
||||||
|
#define pa_sconv_s16le_to_float32re pa_sconv_s16be_to_float32re
|
||||||
|
#define pa_sconv_s16le_from_float32re pa_sconv_s16be_from_float32re
|
||||||
|
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
#define SWAP_WORDS 0
|
#define SWAP_WORDS 0
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,18 @@
|
||||||
USA.
|
USA.
|
||||||
***/
|
***/
|
||||||
|
|
||||||
void pa_sconv_s16be_to_float32ne(unsigned n, const void *a, float *b);
|
#include <inttypes.h>
|
||||||
void pa_sconv_s16be_from_float32ne(unsigned n, const float *a, void *b);
|
|
||||||
|
void pa_sconv_s16be_to_float32ne(unsigned n, const int16_t *a, float *b);
|
||||||
|
void pa_sconv_s16be_from_float32ne(unsigned n, const float *a, int16_t *b);
|
||||||
|
void pa_sconv_s16be_to_float32re(unsigned n, const int16_t *a, float *b);
|
||||||
|
void pa_sconv_s16be_from_float32re(unsigned n, const float *a, int16_t *b);
|
||||||
|
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
#define pa_sconv_float32be_to_s16ne pa_sconv_s16be_from_float32ne
|
||||||
|
#define pa_sconv_float32be_from_s16ne pa_sconv_s16be_to_float32ne
|
||||||
|
#define pa_sconv_float32le_to_s16ne pa_sconv_s16be_from_float32re
|
||||||
|
#define pa_sconv_float32le_from_s16ne pa_sconv_s16be_to_float32re
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -25,12 +25,12 @@
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include <liboil/liboilfuncs.h>
|
#include <liboil/liboilfuncs.h>
|
||||||
|
|
||||||
#include <pulsecore/sconv.h>
|
#include <pulsecore/sconv.h>
|
||||||
|
#include <pulsecore/macro.h>
|
||||||
#include <pulsecore/log.h>
|
#include <pulsecore/log.h>
|
||||||
|
|
||||||
#include "endianmacros.h"
|
#include "endianmacros.h"
|
||||||
|
|
@ -53,32 +53,28 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void pa_sconv_s16le_to_float32ne(unsigned n, const void *a, float *b) {
|
void pa_sconv_s16le_to_float32ne(unsigned n, const int16_t *a, float *b) {
|
||||||
const int16_t *ca = a;
|
pa_assert(a);
|
||||||
|
pa_assert(b);
|
||||||
assert(a);
|
|
||||||
assert(b);
|
|
||||||
|
|
||||||
#if SWAP_WORDS == 1
|
#if SWAP_WORDS == 1
|
||||||
|
|
||||||
for (; n > 0; n--) {
|
for (; n > 0; n--) {
|
||||||
int16_t s = *(ca++);
|
int16_t s = *(a++);
|
||||||
*(b++) = ((float) INT16_FROM(s))/0x7FFF;
|
*(b++) = ((float) INT16_FROM(s))/0x7FFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
static const double add = 0, factor = 1.0/0x7FFF;
|
static const double add = 0, factor = 1.0/0x7FFF;
|
||||||
oil_scaleconv_f32_s16(b, ca, n, &add, &factor);
|
oil_scaleconv_f32_s16(b, a, n, &add, &factor);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void pa_sconv_s16le_from_float32ne(unsigned n, const float *a, void *b) {
|
void pa_sconv_s16le_from_float32ne(unsigned n, const float *a, int16_t *b) {
|
||||||
int16_t *cb = b;
|
pa_assert(a);
|
||||||
|
pa_assert(b);
|
||||||
assert(a);
|
|
||||||
assert(b);
|
|
||||||
|
|
||||||
#if SWAP_WORDS == 1
|
#if SWAP_WORDS == 1
|
||||||
|
|
||||||
|
|
@ -93,13 +89,55 @@ void pa_sconv_s16le_from_float32ne(unsigned n, const float *a, void *b) {
|
||||||
v = -1;
|
v = -1;
|
||||||
|
|
||||||
s = (int16_t) (v * 0x7FFF);
|
s = (int16_t) (v * 0x7FFF);
|
||||||
*(cb++) = INT16_TO(s);
|
*(b++) = INT16_TO(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
static const double add = 0, factor = 0x7FFF;
|
static const double add = 0, factor = 0x7FFF;
|
||||||
oil_scaleconv_s16_f32(cb, a, n, &add, &factor);
|
oil_scaleconv_s16_f32(b, a, n, &add, &factor);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pa_sconv_s16le_to_float32re(unsigned n, const int16_t *a, float *b) {
|
||||||
|
pa_assert(a);
|
||||||
|
pa_assert(b);
|
||||||
|
|
||||||
|
#if SWAP_WORDS == 1
|
||||||
|
|
||||||
|
for (; n > 0; n--) {
|
||||||
|
int16_t s = *(a++);
|
||||||
|
float k = ((float) INT16_FROM(s))/0x7FFF;
|
||||||
|
uint32_t *j = (uint32_t*) &k;
|
||||||
|
*j = UINT32_SWAP(*j);
|
||||||
|
*(b++) = k;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void pa_sconv_s16le_from_float32re(unsigned n, const float *a, int16_t *b) {
|
||||||
|
pa_assert(a);
|
||||||
|
pa_assert(b);
|
||||||
|
|
||||||
|
#if SWAP_WORDS == 1
|
||||||
|
|
||||||
|
for (; n > 0; n--) {
|
||||||
|
int16_t s;
|
||||||
|
float v = *(a++);
|
||||||
|
uint32_t *j = (uint32_t*) &v;
|
||||||
|
*j = UINT32_SWAP(*j);
|
||||||
|
|
||||||
|
if (v > 1)
|
||||||
|
v = 1;
|
||||||
|
|
||||||
|
if (v < -1)
|
||||||
|
v = -1;
|
||||||
|
|
||||||
|
s = (int16_t) (v * 0x7FFF);
|
||||||
|
*(b++) = INT16_TO(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,18 @@
|
||||||
USA.
|
USA.
|
||||||
***/
|
***/
|
||||||
|
|
||||||
void pa_sconv_s16le_to_float32ne(unsigned n, const void *a, float *b);
|
#include <inttypes.h>
|
||||||
void pa_sconv_s16le_from_float32ne(unsigned n, const float *a, void *b);
|
|
||||||
|
void pa_sconv_s16le_to_float32ne(unsigned n, const int16_t *a, float *b);
|
||||||
|
void pa_sconv_s16le_from_float32ne(unsigned n, const float *a, int16_t *b);
|
||||||
|
void pa_sconv_s16le_to_float32re(unsigned n, const int16_t *a, float *b);
|
||||||
|
void pa_sconv_s16le_from_float32re(unsigned n, const float *a, int16_t *b);
|
||||||
|
|
||||||
|
#ifndef WORDS_BIGENDIAN
|
||||||
|
#define pa_sconv_float32be_to_s16ne pa_sconv_s16le_from_float32re
|
||||||
|
#define pa_sconv_float32be_from_s16ne pa_sconv_s16le_to_float32re
|
||||||
|
#define pa_sconv_float32le_to_s16ne pa_sconv_s16le_from_float32ne
|
||||||
|
#define pa_sconv_float32le_from_s16ne pa_sconv_s16le_to_float32ne
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -28,12 +28,12 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include <liboil/liboilfuncs.h>
|
#include <liboil/liboilfuncs.h>
|
||||||
#include <liboil/liboil.h>
|
#include <liboil/liboil.h>
|
||||||
|
|
||||||
#include <pulsecore/g711.h>
|
#include <pulsecore/g711.h>
|
||||||
|
#include <pulsecore/macro.h>
|
||||||
|
|
||||||
#include "endianmacros.h"
|
#include "endianmacros.h"
|
||||||
#include "sconv-s16le.h"
|
#include "sconv-s16le.h"
|
||||||
|
|
@ -41,71 +41,92 @@
|
||||||
|
|
||||||
#include "sconv.h"
|
#include "sconv.h"
|
||||||
|
|
||||||
static void u8_to_float32ne(unsigned n, const void *a, float *b) {
|
/* u8 */
|
||||||
const uint8_t *ca = a;
|
static void u8_to_float32ne(unsigned n, const uint8_t *a, float *b) {
|
||||||
static const double add = -128.0/127.0, factor = 1.0/127.0;
|
static const double add = -128.0/127.0, factor = 1.0/127.0;
|
||||||
|
|
||||||
assert(a);
|
pa_assert(a);
|
||||||
assert(b);
|
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) {
|
static void u8_from_float32ne(unsigned n, const float *a, uint8_t *b) {
|
||||||
uint8_t *cb = b;
|
|
||||||
static const double add = 128.0, factor = 127.0;
|
static const double add = 128.0, factor = 127.0;
|
||||||
|
|
||||||
assert(a);
|
pa_assert(a);
|
||||||
assert(b);
|
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) {
|
static void u8_to_s16ne(unsigned n, const uint8_t *a, int16_t *b) {
|
||||||
assert(a);
|
static const int16_t add = -128, factor = 0x100;
|
||||||
assert(b);
|
|
||||||
|
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 ++, a++)
|
||||||
|
*b = (uint8_t) (*a / 0x100 + 0x80);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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);
|
oil_memcpy(b, a, sizeof(float) * n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void float32ne_from_float32ne(unsigned n, const float *a, void *b) {
|
static void float32re_to_float32ne(unsigned n, const float *a, float *b) {
|
||||||
assert(a);
|
pa_assert(a);
|
||||||
assert(b);
|
pa_assert(b);
|
||||||
|
|
||||||
oil_memcpy(b, a, sizeof(float) * n);
|
for (; n > 0; n--, a++, b++)
|
||||||
|
*((uint32_t *) b) = UINT32_SWAP(*((uint32_t *) a));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void float32re_to_float32ne(unsigned n, const void *a, float *b) {
|
/* s16 */
|
||||||
assert(a);
|
|
||||||
assert(b);
|
|
||||||
|
|
||||||
while (n-- > 0)
|
static void s16ne_to_s16ne(unsigned n, const int16_t *a, int16_t *b) {
|
||||||
((uint32_t *)b)[n] = UINT32_SWAP (((uint32_t *)a)[n]);
|
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) {
|
static void s16re_to_s16ne(unsigned n, const int16_t *a, int16_t *b) {
|
||||||
assert(a);
|
pa_assert(a);
|
||||||
assert(b);
|
pa_assert(b);
|
||||||
|
|
||||||
while (n-- > 0)
|
for (; n > 0; n--, a++, b++)
|
||||||
((uint32_t *)b)[n] = UINT32_SWAP (((uint32_t *)a)[n]);
|
*b = UINT16_SWAP(*a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ulaw_to_float32ne(unsigned n, const void *a, float *b) {
|
/* ulaw */
|
||||||
const uint8_t *ca = a;
|
|
||||||
|
|
||||||
assert(a);
|
static void ulaw_to_float32ne(unsigned n, const uint8_t *a, float *b) {
|
||||||
assert(b);
|
pa_assert(a);
|
||||||
|
pa_assert(b);
|
||||||
|
|
||||||
for (; n > 0; n--)
|
for (; n > 0; n--)
|
||||||
*(b++) = st_ulaw2linear16(*(ca++)) * 1.0F / 0x7FFF;
|
*(b++) = st_ulaw2linear16(*(a++)) * 1.0F / 0x7FFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ulaw_from_float32ne(unsigned n, const float *a, void *b) {
|
static void ulaw_from_float32ne(unsigned n, const float *a, uint8_t *b) {
|
||||||
uint8_t *cb = b;
|
pa_assert(a);
|
||||||
|
pa_assert(b);
|
||||||
assert(a);
|
|
||||||
assert(b);
|
|
||||||
|
|
||||||
for (; n > 0; n--) {
|
for (; n > 0; n--) {
|
||||||
float v = *(a++);
|
float v = *(a++);
|
||||||
|
|
@ -116,28 +137,42 @@ static void ulaw_from_float32ne(unsigned n, const float *a, void *b) {
|
||||||
if (v < -1)
|
if (v < -1)
|
||||||
v = -1;
|
v = -1;
|
||||||
|
|
||||||
*(cb++) = st_14linear2ulaw((int16_t) (v * 0x1FFF));
|
*(b++) = st_14linear2ulaw((int16_t) (v * 0x1FFF));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void alaw_to_float32ne(unsigned n, const void *a, float *b) {
|
static void ulaw_to_s16ne(unsigned n, const uint8_t *a, int16_t *b) {
|
||||||
const uint8_t *ca = a;
|
pa_assert(a);
|
||||||
|
pa_assert(b);
|
||||||
|
|
||||||
assert(a);
|
for (; n > 0; n--, a++, b++)
|
||||||
assert(b);
|
*b = st_ulaw2linear16(*a);
|
||||||
|
|
||||||
for (; n > 0; n--)
|
|
||||||
*(b++) = st_alaw2linear16(*(ca++)) * 1.0F / 0x7FFF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void alaw_from_float32ne(unsigned n, const float *a, void *b) {
|
static void ulaw_from_s16ne(unsigned n, const int16_t *a, uint8_t *b) {
|
||||||
uint8_t *cb = b;
|
pa_assert(a);
|
||||||
|
pa_assert(b);
|
||||||
|
|
||||||
assert(a);
|
for (; n > 0; n--, a++, b++)
|
||||||
assert(b);
|
*b = st_14linear2ulaw(*a >> 2);
|
||||||
|
}
|
||||||
|
|
||||||
for (; n > 0; n--) {
|
/* alaw */
|
||||||
float v = *(a++);
|
|
||||||
|
static void alaw_to_float32ne(unsigned n, const uint8_t *a, float *b) {
|
||||||
|
pa_assert(a);
|
||||||
|
pa_assert(b);
|
||||||
|
|
||||||
|
for (; n > 0; n--, a++, b++)
|
||||||
|
*b = st_alaw2linear16(*a) * 1.0F / 0x7FFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
if (v > 1)
|
if (v > 1)
|
||||||
v = 1;
|
v = 1;
|
||||||
|
|
@ -145,48 +180,94 @@ static void alaw_from_float32ne(unsigned n, const float *a, void *b) {
|
||||||
if (v < -1)
|
if (v < -1)
|
||||||
v = -1;
|
v = -1;
|
||||||
|
|
||||||
*(cb++) = st_13linear2alaw((int16_t) (v * 0xFFF));
|
*b = st_13linear2alaw((int16_t) (v * 0xFFF));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_convert_to_float32ne_func_t pa_get_convert_to_float32ne_function(pa_sample_format_t f) {
|
static void alaw_to_s16ne(unsigned n, const int8_t *a, int16_t *b) {
|
||||||
switch(f) {
|
pa_assert(a);
|
||||||
case PA_SAMPLE_U8:
|
pa_assert(b);
|
||||||
return u8_to_float32ne;
|
|
||||||
case PA_SAMPLE_S16LE:
|
for (; n > 0; n--, a++, b++)
|
||||||
return pa_sconv_s16le_to_float32ne;
|
*b = st_alaw2linear16(*a);
|
||||||
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_from_float32ne_func_t pa_get_convert_from_float32ne_function(pa_sample_format_t f) {
|
static void alaw_from_s16ne(unsigned n, const int16_t *a, uint8_t *b) {
|
||||||
switch(f) {
|
pa_assert(a);
|
||||||
case PA_SAMPLE_U8:
|
pa_assert(b);
|
||||||
return u8_from_float32ne;
|
|
||||||
case PA_SAMPLE_S16LE:
|
for (; n > 0; n--)
|
||||||
return pa_sconv_s16le_from_float32ne;
|
*b = st_13linear2alaw(*a >> 3);
|
||||||
case PA_SAMPLE_S16BE:
|
}
|
||||||
return pa_sconv_s16be_from_float32ne;
|
|
||||||
case PA_SAMPLE_FLOAT32NE:
|
pa_convert_func_t pa_get_convert_to_float32ne_function(pa_sample_format_t f) {
|
||||||
return float32ne_from_float32ne;
|
|
||||||
case PA_SAMPLE_FLOAT32RE:
|
static const pa_convert_func_t table[] = {
|
||||||
return float32re_from_float32ne;
|
[PA_SAMPLE_U8] = (pa_convert_func_t) u8_to_float32ne,
|
||||||
case PA_SAMPLE_ALAW:
|
[PA_SAMPLE_ALAW] = (pa_convert_func_t) alaw_to_float32ne,
|
||||||
return alaw_from_float32ne;
|
[PA_SAMPLE_ULAW] = (pa_convert_func_t) ulaw_to_float32ne,
|
||||||
case PA_SAMPLE_ULAW:
|
[PA_SAMPLE_S16LE] = (pa_convert_func_t) pa_sconv_s16le_to_float32ne,
|
||||||
return ulaw_from_float32ne;
|
[PA_SAMPLE_S16BE] = (pa_convert_func_t) pa_sconv_s16be_to_float32ne,
|
||||||
default:
|
[PA_SAMPLE_FLOAT32NE] = (pa_convert_func_t) float32ne_to_float32ne,
|
||||||
return NULL;
|
[PA_SAMPLE_FLOAT32RE] = (pa_convert_func_t) float32re_to_float32ne,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
pa_assert(f >= 0);
|
||||||
|
pa_assert(f < PA_SAMPLE_MAX);
|
||||||
|
|
||||||
|
return table[f];
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_convert_func_t pa_get_convert_from_float32ne_function(pa_sample_format_t f) {
|
||||||
|
|
||||||
|
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_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_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];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,12 @@
|
||||||
|
|
||||||
#include <pulse/sample.h>
|
#include <pulse/sample.h>
|
||||||
|
|
||||||
typedef void (*pa_convert_to_float32ne_func_t)(unsigned n, const void *a, float *b);
|
typedef void (*pa_convert_func_t)(unsigned n, const void *a, void *b);
|
||||||
typedef void (*pa_convert_from_float32ne_func_t)(unsigned n, const float *a, void *b);
|
|
||||||
|
|
||||||
pa_convert_to_float32ne_func_t pa_get_convert_to_float32ne_function(pa_sample_format_t f);
|
pa_convert_func_t pa_get_convert_to_float32ne_function(pa_sample_format_t f);
|
||||||
pa_convert_from_float32ne_func_t pa_get_convert_from_float32ne_function(pa_sample_format_t f);
|
pa_convert_func_t pa_get_convert_from_float32ne_function(pa_sample_format_t f);
|
||||||
|
|
||||||
|
pa_convert_func_t pa_get_convert_to_s16ne_function(pa_sample_format_t f);
|
||||||
|
pa_convert_func_t pa_get_convert_from_s16ne_function(pa_sample_format_t f);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue