Commit fb17e32b authored by sletz's avatar sletz
Browse files

Gabriel Beddingfield patch (r4541) reverted.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4553 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 24b75dbc
......@@ -36,6 +36,10 @@ John Emmas
Jackdmp changes log
---------------------------
2011-10-27 Stephane Letz <letz@grame.fr>
* Gabriel Beddingfield patch (r4541) reverted.
2011-10-10 Stephane Letz <letz@grame.fr>
* John Emmas patch for DSP CPU computation.
......
......@@ -206,42 +206,19 @@ inline unsigned int fast_rand() {
/* functions for native float sample data */
void sample_move_floatLE_sSs (jack_default_audio_sample_t *dst, char *src, unsigned long nsamples, unsigned long src_skip) {
#if __BYTE_ORDER == __LITTLE_ENDIAN
char *d = (char*)dst;
while (nsamples--) {
*d++ = src[3];
*d++ = src[2];
*d++ = src[1];
*d++ = src[0];
*dst = *((float *) src);
dst++;
src += src_skip;
}
#else
// Matching byte order
while (nsamples--) {
*dst = *((float *) src);
dst++;
src += src_skip;
}
#endif
}
void sample_move_dS_floatLE (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state) {
#if __BYTE_ORDER == __LITTLE_ENDIAN
while (nsamples--) {
*((float *) dst) = *src;
dst += dst_skip;
src++;
}
#else
char *d = (char*)dst;
while (nsamples--) {
*d++ = src[3];
*d++ = src[2];
*d++ = src[1];
*d++ = src[0];
src += src_skip;
}
#endif
}
/* NOTES on function naming:
......@@ -272,19 +249,22 @@ void sample_move_dS_floatLE (char *dst, jack_default_audio_sample_t *src, unsign
void sample_move_d32u24_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
{
int32_t z;
union {
jack_default_audio_sample_t f;
char c[4];
} t;
while (nsamples--) {
t.c[0] = *((char*)src + 3);
t.c[1] = *((char*)src + 2);
t.c[2] = *((char*)src + 1);
t.c[3] = *((char*)src + 0);
float_24u32 (t.f, z);
*((int32_t *) dst) = z;
while (nsamples--) {
float_24u32 (*src, z);
#if __BYTE_ORDER == __LITTLE_ENDIAN
dst[0]=(char)(z>>24);
dst[1]=(char)(z>>16);
dst[2]=(char)(z>>8);
dst[3]=(char)(z);
#elif __BYTE_ORDER == __BIG_ENDIAN
dst[0]=(char)(z);
dst[1]=(char)(z>>8);
dst[2]=(char)(z>>16);
dst[3]=(char)(z>>24);
#endif
dst += dst_skip;
src++;
}
......@@ -424,26 +404,17 @@ void sample_move_dS_s32u24 (jack_default_audio_sample_t *dst, char *src, unsigne
void sample_move_d24_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
{
int32_t z;
union {
jack_default_audio_sample_t f;
char c[4];
} t;
while (nsamples--) {
t.c[0] = *((char*)src + 3);
t.c[1] = *((char*)src + 2);
t.c[2] = *((char*)src + 1);
t.c[3] = *((char*)src + 0);
float_24 (t.f, z);
float_24 (*src, z);
#if __BYTE_ORDER == __LITTLE_ENDIAN
dst[0]=(char)(z);
dst[1]=(char)(z>>8);
dst[2]=(char)(z>>16);
#elif __BYTE_ORDER == __BIG_ENDIAN
dst[0]=(char)(z>>16);
dst[1]=(char)(z>>8);
dst[2]=(char)(z);
#elif __BYTE_ORDER == __BIG_ENDIAN
dst[0]=(char)(z);
dst[1]=(char)(z>>8);
dst[2]=(char)(z>>16);
#endif
dst += dst_skip;
src++;
......@@ -577,28 +548,25 @@ void sample_move_dS_s24 (jack_default_audio_sample_t *dst, char *src, unsigned l
void sample_move_d16_sSs (char *dst, jack_default_audio_sample_t *src, unsigned long nsamples, unsigned long dst_skip, dither_state_t *state)
{
int16_t tmp;
union {
jack_default_audio_sample_t f;
char c[4];
} t;
while (nsamples--) {
t.c[0] = *((char*)src + 3);
t.c[1] = *((char*)src + 2);
t.c[2] = *((char*)src + 1);
t.c[3] = *((char*)src + 0);
// float_16 (*src, tmp);
if (t.f <= NORMALIZED_FLOAT_MIN) {
if (*src <= NORMALIZED_FLOAT_MIN) {
tmp = SAMPLE_16BIT_MIN;
} else if (t.f >= NORMALIZED_FLOAT_MAX) {
} else if (*src >= NORMALIZED_FLOAT_MAX) {
tmp = SAMPLE_16BIT_MAX;
} else {
tmp = (int16_t) f_round (t.f * SAMPLE_16BIT_SCALING);
tmp = (int16_t) f_round (*src * SAMPLE_16BIT_SCALING);
}
*((int16_t *) dst) = tmp;
#if __BYTE_ORDER == __LITTLE_ENDIAN
dst[0]=(char)(tmp>>8);
dst[1]=(char)(tmp);
#elif __BYTE_ORDER == __BIG_ENDIAN
dst[0]=(char)(tmp);
dst[1]=(char)(tmp>>8);
#endif
dst += dst_skip;
src++;
}
......@@ -617,19 +585,17 @@ void sample_move_dither_rect_d16_sSs (char *dst, jack_default_audio_sample_t *s
{
jack_default_audio_sample_t val;
int16_t tmp;
union {
jack_default_audio_sample_t f;
char c[4];
} t;
while (nsamples--) {
t.c[0] = *((char*)src + 3);
t.c[1] = *((char*)src + 2);
t.c[2] = *((char*)src + 1);
t.c[3] = *((char*)src + 0);
val = (t.f * SAMPLE_16BIT_SCALING) + fast_rand() / (float) UINT_MAX - 0.5f;
val = (*src * SAMPLE_16BIT_SCALING) + fast_rand() / (float) UINT_MAX - 0.5f;
float_16_scaled (val, tmp);
*((int16_t *) dst) = tmp;
#if __BYTE_ORDER == __LITTLE_ENDIAN
dst[0]=(char)(tmp>>8);
dst[1]=(char)(tmp);
#elif __BYTE_ORDER == __BIG_ENDIAN
dst[0]=(char)(tmp);
dst[1]=(char)(tmp>>8);
#endif
dst += dst_skip;
src++;
}
......@@ -651,19 +617,18 @@ void sample_move_dither_tri_d16_sSs (char *dst, jack_default_audio_sample_t *sr
{
jack_default_audio_sample_t val;
int16_t tmp;
union {
jack_default_audio_sample_t f;
char c[4];
} t;
while (nsamples--) {
t.c[0] = *((char*)src + 3);
t.c[1] = *((char*)src + 2);
t.c[2] = *((char*)src + 1);
t.c[3] = *((char*)src + 0);
val = (t.f * SAMPLE_16BIT_SCALING) + ((float)fast_rand() + (float)fast_rand()) / (float)UINT_MAX - 1.0f;
val = (*src * SAMPLE_16BIT_SCALING) + ((float)fast_rand() + (float)fast_rand()) / (float)UINT_MAX - 1.0f;
float_16_scaled (val, tmp);
*((int16_t *) dst) = tmp;
#if __BYTE_ORDER == __LITTLE_ENDIAN
dst[0]=(char)(tmp>>8);
dst[1]=(char)(tmp);
#elif __BYTE_ORDER == __BIG_ENDIAN
dst[0]=(char)(tmp);
dst[1]=(char)(tmp>>8);
#endif
dst += dst_skip;
src++;
}
......@@ -690,18 +655,9 @@ void sample_move_dither_shaped_d16_sSs (char *dst, jack_default_audio_sample_t
float rm1 = state->rm1;
unsigned int idx = state->idx;
int16_t tmp;
union {
jack_default_audio_sample_t f;
char c[4];
} t;
while (nsamples--) {
t.c[0] = *((char*)src + 3);
t.c[1] = *((char*)src + 2);
t.c[2] = *((char*)src + 1);
t.c[3] = *((char*)src + 0);
x = t.f * SAMPLE_16BIT_SCALING;
x = *src * SAMPLE_16BIT_SCALING;
r = ((float)fast_rand() + (float)fast_rand()) / (float)UINT_MAX - 1.0f;
/* Filter the error with Lipshitz's minimally audible FIR:
[2.033 -2.165 1.959 -1.590 0.6149] */
......@@ -719,7 +675,14 @@ void sample_move_dither_shaped_d16_sSs (char *dst, jack_default_audio_sample_t
/* Intrinsic z^-1 delay */
idx = (idx + 1) & DITHER_BUF_MASK;
state->e[idx] = xp - xe;
*((int16_t *) dst) = tmp;
#if __BYTE_ORDER == __LITTLE_ENDIAN
dst[0]=(char)(tmp>>8);
dst[1]=(char)(tmp);
#elif __BYTE_ORDER == __BIG_ENDIAN
dst[0]=(char)(tmp);
dst[1]=(char)(tmp>>8);
#endif
dst += dst_skip;
src++;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment