mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
add pa_ prefix to all identifiers.
fix downsampling/resampling add support for U8 samples git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@49 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
a8a5ab1c79
commit
e61c2dddb7
91 changed files with 1795 additions and 1643 deletions
53
src/sconv.c
53
src/sconv.c
|
|
@ -1,48 +1,53 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include "endianmacros.h"
|
||||
#include "sconv.h"
|
||||
|
||||
static void s16le_to_float32(unsigned n, const void *a, unsigned an, float *b) {
|
||||
const int16_t *ca = a;
|
||||
#include "sconv-s16le.h"
|
||||
#include "sconv-s16be.h"
|
||||
|
||||
static void u8_to_float32(unsigned n, const void *a, unsigned an, float *b) {
|
||||
unsigned i;
|
||||
const uint8_t *ca = a;
|
||||
assert(n && a && an && b);
|
||||
|
||||
for (; n > 0; n--) {
|
||||
unsigned i;
|
||||
float sum = 0;
|
||||
|
||||
|
||||
for (i = 0; i < an; i++) {
|
||||
int16_t s = *(ca++);
|
||||
sum += ((float) INT16_FROM_LE(s))/0x7FFF;
|
||||
uint8_t v = *(ca++);
|
||||
sum += (((float) v)-127)/127;
|
||||
}
|
||||
|
||||
if (sum > 1)
|
||||
sum = 1;
|
||||
if (sum < -1)
|
||||
sum = -1;
|
||||
|
||||
|
||||
*(b++) = sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void u8_from_float32(unsigned n, const float *a, void *b, unsigned bn) {
|
||||
unsigned i;
|
||||
uint8_t *cb = b;
|
||||
|
||||
static void s16le_from_float32(unsigned n, const float *a, void *b, unsigned bn) {
|
||||
int16_t *cb = b;
|
||||
assert(n && a && b && bn);
|
||||
|
||||
for (; n > 0; n--) {
|
||||
unsigned i;
|
||||
int16_t s;
|
||||
float v = *(a++);
|
||||
uint8_t u;
|
||||
|
||||
if (v > 1)
|
||||
v = 1;
|
||||
|
||||
if (v < -1)
|
||||
v = -1;
|
||||
|
||||
s = (int16_t) (v * 0x7FFF);
|
||||
|
||||
u = (uint8_t) (v*127+127);
|
||||
|
||||
for (i = 0; i < bn; i++)
|
||||
*(cb++) = INT16_TO_LE(v);
|
||||
*(cb++) = u;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -76,10 +81,14 @@ static void float32_from_float32(unsigned n, const float *a, void *b, unsigned b
|
|||
}
|
||||
}
|
||||
|
||||
convert_to_float32_func_t get_convert_to_float32_function(enum pa_sample_format f) {
|
||||
pa_convert_to_float32_func_t pa_get_convert_to_float32_function(enum pa_sample_format f) {
|
||||
switch(f) {
|
||||
case PA_SAMPLE_U8:
|
||||
return u8_to_float32;
|
||||
case PA_SAMPLE_S16LE:
|
||||
return s16le_to_float32;
|
||||
return pa_sconv_s16le_to_float32;
|
||||
case PA_SAMPLE_S16BE:
|
||||
return pa_sconv_s16be_to_float32;
|
||||
case PA_SAMPLE_FLOAT32:
|
||||
return float32_to_float32;
|
||||
default:
|
||||
|
|
@ -87,10 +96,14 @@ convert_to_float32_func_t get_convert_to_float32_function(enum pa_sample_format
|
|||
}
|
||||
}
|
||||
|
||||
convert_from_float32_func_t get_convert_from_float32_function(enum pa_sample_format f) {
|
||||
pa_convert_from_float32_func_t pa_get_convert_from_float32_function(enum pa_sample_format f) {
|
||||
switch(f) {
|
||||
case PA_SAMPLE_U8:
|
||||
return u8_from_float32;
|
||||
case PA_SAMPLE_S16LE:
|
||||
return s16le_from_float32;
|
||||
return pa_sconv_s16le_from_float32;
|
||||
case PA_SAMPLE_S16BE:
|
||||
return pa_sconv_s16be_from_float32;
|
||||
case PA_SAMPLE_FLOAT32:
|
||||
return float32_from_float32;
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue