Changed route plugin arithmetic to unsigned. Choosen better names for plugin ops

This commit is contained in:
Abramo Bagnara 2000-05-20 13:18:55 +00:00
parent 76363aa060
commit 0b2b3c8a81
8 changed files with 301 additions and 314 deletions

View file

@ -303,6 +303,18 @@ int snd_pcm_plugin_build_mmap(snd_pcm_plugin_handle_t *handle,
snd_pcm_t *slave, snd_pcm_t *slave,
snd_pcm_format_t *format, snd_pcm_format_t *format,
snd_pcm_plugin_t **r_plugin); snd_pcm_plugin_t **r_plugin);
#define ROUTE_PLUGIN_USE_FLOAT 1
#if ROUTE_PLUGIN_USE_FLOAT
#define FULL 1.0
#define HALF 0.5
typedef float route_ttable_entry_t;
#else
#define FULL ROUTE_PLUGIN_RESOLUTION
#define HALF ROUTE_PLUGIN_RESOLUTION / 2
typedef int route_ttable_entry_t;
#endif
/* conversion plugins */ /* conversion plugins */
int snd_pcm_plugin_build_interleave(snd_pcm_plugin_handle_t *handle, int snd_pcm_plugin_build_interleave(snd_pcm_plugin_handle_t *handle,
int channel, int channel,
@ -338,7 +350,7 @@ int snd_pcm_plugin_build_route(snd_pcm_plugin_handle_t *handle,
int channel, int channel,
snd_pcm_format_t *src_format, snd_pcm_format_t *src_format,
snd_pcm_format_t *dst_format, snd_pcm_format_t *dst_format,
float *ttable, route_ttable_entry_t *ttable,
snd_pcm_plugin_t **r_plugin); snd_pcm_plugin_t **r_plugin);
int snd_pcm_plugin_build_copy(snd_pcm_plugin_handle_t *handle, int snd_pcm_plugin_build_copy(snd_pcm_plugin_handle_t *handle,
int channel, int channel,

View file

@ -526,16 +526,6 @@ int snd_pcm_plug_slave_params(snd_pcm_channel_params_t *params,
return 0; return 0;
} }
#ifdef __KERNEL__
#define FULL ROUTE_PLUGIN_RESOLUTION
#define HALF ROUTE_PLUGIN_RESOLUTION / 2
typedef int ttable_entry_t;
#else
#define FULL 1.0
#define HALF 0.5
typedef float ttable_entry_t;
#endif
int snd_pcm_plug_format(snd_pcm_plugin_handle_t *handle, int snd_pcm_plug_format(snd_pcm_plugin_handle_t *handle,
snd_pcm_channel_params_t *params, snd_pcm_channel_params_t *params,
snd_pcm_channel_params_t *slave_params) snd_pcm_channel_params_t *slave_params)
@ -628,7 +618,7 @@ int snd_pcm_plug_format(snd_pcm_plugin_handle_t *handle,
if (srcparams->format.voices > dstparams.format.voices) { if (srcparams->format.voices > dstparams.format.voices) {
int sv = srcparams->format.voices; int sv = srcparams->format.voices;
int dv = dstparams.format.voices; int dv = dstparams.format.voices;
ttable_entry_t *ttable = calloc(1, dv*sv*sizeof(*ttable)); route_ttable_entry_t *ttable = calloc(1, dv*sv*sizeof(*ttable));
#if 1 #if 1
if (sv == 2 && dv == 1) { if (sv == 2 && dv == 1) {
ttable[0] = HALF; ttable[0] = HALF;
@ -694,7 +684,7 @@ int snd_pcm_plug_format(snd_pcm_plugin_handle_t *handle,
if (srcparams->format.voices < dstparams.format.voices) { if (srcparams->format.voices < dstparams.format.voices) {
int sv = srcparams->format.voices; int sv = srcparams->format.voices;
int dv = dstparams.format.voices; int dv = dstparams.format.voices;
ttable_entry_t *ttable = calloc(1, dv * sv * sizeof(*ttable)); route_ttable_entry_t *ttable = calloc(1, dv * sv * sizeof(*ttable));
#if 0 #if 0
{ {
int v; int v;

View file

@ -215,11 +215,11 @@ static void adpcm_decode(snd_pcm_plugin_t *plugin,
snd_pcm_plugin_voice_t *dst_voices, snd_pcm_plugin_voice_t *dst_voices,
size_t samples) size_t samples)
{ {
#define PUT16_LABELS #define PUT_S16_LABELS
#include "plugin_ops.h" #include "plugin_ops.h"
#undef PUT16_LABELS #undef PUT_S16_LABELS
adpcm_t *data = (adpcm_t *)plugin->extra_data; adpcm_t *data = (adpcm_t *)plugin->extra_data;
void *put = put16_labels[data->conv]; void *put = put_s16_labels[data->conv];
int voice; int voice;
int nvoices = plugin->src_format.voices; int nvoices = plugin->src_format.voices;
for (voice = 0; voice < nvoices; ++voice) { for (voice = 0; voice < nvoices; ++voice) {
@ -253,9 +253,9 @@ static void adpcm_decode(snd_pcm_plugin_t *plugin,
v = (*src >> 4) & 0x0f; v = (*src >> 4) & 0x0f;
sample = adpcm_decoder(v, state); sample = adpcm_decoder(v, state);
goto *put; goto *put;
#define PUT16_END after #define PUT_S16_END after
#include "plugin_ops.h" #include "plugin_ops.h"
#undef PUT16_END #undef PUT_S16_END
after: after:
src += src_step; src += src_step;
srcbit += srcbit_step; srcbit += srcbit_step;
@ -273,11 +273,11 @@ static void adpcm_encode(snd_pcm_plugin_t *plugin,
snd_pcm_plugin_voice_t *dst_voices, snd_pcm_plugin_voice_t *dst_voices,
size_t samples) size_t samples)
{ {
#define GET16_LABELS #define GET_S16_LABELS
#include "plugin_ops.h" #include "plugin_ops.h"
#undef GET16_LABELS #undef GET_S16_LABELS
adpcm_t *data = (adpcm_t *)plugin->extra_data; adpcm_t *data = (adpcm_t *)plugin->extra_data;
void *get = get16_labels[data->conv]; void *get = get_s16_labels[data->conv];
int voice; int voice;
int nvoices = plugin->src_format.voices; int nvoices = plugin->src_format.voices;
signed short sample = 0; signed short sample = 0;
@ -306,9 +306,9 @@ static void adpcm_encode(snd_pcm_plugin_t *plugin,
while (samples1-- > 0) { while (samples1-- > 0) {
int v; int v;
goto *get; goto *get;
#define GET16_END after #define GET_S16_END after
#include "plugin_ops.h" #include "plugin_ops.h"
#undef GET16_END #undef GET_S16_END
after: after:
v = adpcm_encoder(sample, state); v = adpcm_encoder(sample, state);
if (dstbit) if (dstbit)

View file

@ -147,11 +147,11 @@ static void alaw_decode(snd_pcm_plugin_t *plugin,
snd_pcm_plugin_voice_t *dst_voices, snd_pcm_plugin_voice_t *dst_voices,
size_t samples) size_t samples)
{ {
#define PUT16_LABELS #define PUT_S16_LABELS
#include "plugin_ops.h" #include "plugin_ops.h"
#undef PUT16_LABELS #undef PUT_S16_LABELS
alaw_t *data = (alaw_t *)plugin->extra_data; alaw_t *data = (alaw_t *)plugin->extra_data;
void *put = put16_labels[data->conv]; void *put = put_s16_labels[data->conv];
int voice; int voice;
int nvoices = plugin->src_format.voices; int nvoices = plugin->src_format.voices;
for (voice = 0; voice < nvoices; ++voice) { for (voice = 0; voice < nvoices; ++voice) {
@ -174,9 +174,9 @@ static void alaw_decode(snd_pcm_plugin_t *plugin,
while (samples1-- > 0) { while (samples1-- > 0) {
signed short sample = alaw2linear(*src); signed short sample = alaw2linear(*src);
goto *put; goto *put;
#define PUT16_END after #define PUT_S16_END after
#include "plugin_ops.h" #include "plugin_ops.h"
#undef PUT16_END #undef PUT_S16_END
after: after:
src += src_step; src += src_step;
dst += dst_step; dst += dst_step;
@ -189,11 +189,11 @@ static void alaw_encode(snd_pcm_plugin_t *plugin,
snd_pcm_plugin_voice_t *dst_voices, snd_pcm_plugin_voice_t *dst_voices,
size_t samples) size_t samples)
{ {
#define GET16_LABELS #define GET_S16_LABELS
#include "plugin_ops.h" #include "plugin_ops.h"
#undef GET16_LABELS #undef GET_S16_LABELS
alaw_t *data = (alaw_t *)plugin->extra_data; alaw_t *data = (alaw_t *)plugin->extra_data;
void *get = get16_labels[data->conv]; void *get = get_s16_labels[data->conv];
int voice; int voice;
int nvoices = plugin->src_format.voices; int nvoices = plugin->src_format.voices;
signed short sample = 0; signed short sample = 0;
@ -216,9 +216,9 @@ static void alaw_encode(snd_pcm_plugin_t *plugin,
samples1 = samples; samples1 = samples;
while (samples1-- > 0) { while (samples1-- > 0) {
goto *get; goto *get;
#define GET16_END after #define GET_S16_END after
#include "plugin_ops.h" #include "plugin_ops.h"
#undef GET16_END #undef GET_S16_END
after: after:
*dst = linear2alaw(sample); *dst = linear2alaw(sample);
src += src_step; src += src_step;

View file

@ -163,11 +163,11 @@ static void mulaw_decode(snd_pcm_plugin_t *plugin,
snd_pcm_plugin_voice_t *dst_voices, snd_pcm_plugin_voice_t *dst_voices,
size_t samples) size_t samples)
{ {
#define PUT16_LABELS #define PUT_S16_LABELS
#include "plugin_ops.h" #include "plugin_ops.h"
#undef PUT16_LABELS #undef PUT_S16_LABELS
mulaw_t *data = (mulaw_t *)plugin->extra_data; mulaw_t *data = (mulaw_t *)plugin->extra_data;
void *put = put16_labels[data->conv]; void *put = put_s16_labels[data->conv];
int voice; int voice;
int nvoices = plugin->src_format.voices; int nvoices = plugin->src_format.voices;
for (voice = 0; voice < nvoices; ++voice) { for (voice = 0; voice < nvoices; ++voice) {
@ -190,9 +190,9 @@ static void mulaw_decode(snd_pcm_plugin_t *plugin,
while (samples1-- > 0) { while (samples1-- > 0) {
signed short sample = ulaw2linear(*src); signed short sample = ulaw2linear(*src);
goto *put; goto *put;
#define PUT16_END after #define PUT_S16_END after
#include "plugin_ops.h" #include "plugin_ops.h"
#undef PUT16_END #undef PUT_S16_END
after: after:
src += src_step; src += src_step;
dst += dst_step; dst += dst_step;
@ -205,11 +205,11 @@ static void mulaw_encode(snd_pcm_plugin_t *plugin,
snd_pcm_plugin_voice_t *dst_voices, snd_pcm_plugin_voice_t *dst_voices,
size_t samples) size_t samples)
{ {
#define GET16_LABELS #define GET_S16_LABELS
#include "plugin_ops.h" #include "plugin_ops.h"
#undef GET16_LABELS #undef GET_S16_LABELS
mulaw_t *data = (mulaw_t *)plugin->extra_data; mulaw_t *data = (mulaw_t *)plugin->extra_data;
void *get = get16_labels[data->conv]; void *get = get_s16_labels[data->conv];
int voice; int voice;
int nvoices = plugin->src_format.voices; int nvoices = plugin->src_format.voices;
signed short sample = 0; signed short sample = 0;
@ -232,9 +232,9 @@ static void mulaw_encode(snd_pcm_plugin_t *plugin,
samples1 = samples; samples1 = samples;
while (samples1-- > 0) { while (samples1-- > 0) {
goto *get; goto *get;
#define GET16_END after #define GET_S16_END after
#include "plugin_ops.h" #include "plugin_ops.h"
#undef GET16_END #undef GET_S16_END
after: after:
*dst = linear2ulaw(sample); *dst = linear2ulaw(sample);
src += src_step; src += src_step;

View file

@ -280,90 +280,91 @@ conv_1234_123C: as_u32(dst) = as_u32(src) ^ 0x80; goto CONV_END;
} }
#endif #endif
#ifdef GET16_LABELS #ifdef GET_S16_LABELS
/* src_wid src_endswap sign_toggle */ /* src_wid src_endswap unsigned */
static void *get16_labels[4 * 2 * 2] = { static void *get_s16_labels[4 * 2 * 2] = {
&&get16_xxx1_xx10, /* 8h -> 16h */ &&get_s16_xxx1_xx10, /* 8h -> 16h */
&&get16_xxx1_xx90, /* 8h ^> 16h */ &&get_s16_xxx1_xx90, /* 8h ^> 16h */
&&get16_xxx1_xx10, /* 8s -> 16h */ &&get_s16_xxx1_xx10, /* 8s -> 16h */
&&get16_xxx1_xx90, /* 8s ^> 16h */ &&get_s16_xxx1_xx90, /* 8s ^> 16h */
&&get16_xx12_xx12, /* 16h -> 16h */ &&get_s16_xx12_xx12, /* 16h -> 16h */
&&get16_xx12_xx92, /* 16h ^> 16h */ &&get_s16_xx12_xx92, /* 16h ^> 16h */
&&get16_xx12_xx21, /* 16s -> 16h */ &&get_s16_xx12_xx21, /* 16s -> 16h */
&&get16_xx12_xxA1, /* 16s ^> 16h */ &&get_s16_xx12_xxA1, /* 16s ^> 16h */
&&get16_x123_xx12, /* 24h -> 16h */ &&get_s16_x123_xx12, /* 24h -> 16h */
&&get16_x123_xx92, /* 24h ^> 16h */ &&get_s16_x123_xx92, /* 24h ^> 16h */
&&get16_123x_xx32, /* 24s -> 16h */ &&get_s16_123x_xx32, /* 24s -> 16h */
&&get16_123x_xxB2, /* 24s ^> 16h */ &&get_s16_123x_xxB2, /* 24s ^> 16h */
&&get16_1234_xx12, /* 32h -> 16h */ &&get_s16_1234_xx12, /* 32h -> 16h */
&&get16_1234_xx92, /* 32h ^> 16h */ &&get_s16_1234_xx92, /* 32h ^> 16h */
&&get16_1234_xx43, /* 32s -> 16h */ &&get_s16_1234_xx43, /* 32s -> 16h */
&&get16_1234_xxC3, /* 32s ^> 16h */ &&get_s16_1234_xxC3, /* 32s ^> 16h */
}; };
#endif #endif
#ifdef GET16_END #ifdef GET_S16_END
while(0) { while(0) {
get16_xxx1_xx10: sample = (u_int32_t)as_u8(src) << 8; goto GET16_END; get_s16_xxx1_xx10: sample = (u_int32_t)as_u8(src) << 8; goto GET_S16_END;
get16_xxx1_xx90: sample = (u_int32_t)(as_u8(src) ^ 0x80) << 8; goto GET16_END; get_s16_xxx1_xx90: sample = (u_int32_t)(as_u8(src) ^ 0x80) << 8; goto GET_S16_END;
get16_xx12_xx12: sample = as_u16(src); goto GET16_END; get_s16_xx12_xx12: sample = as_u16(src); goto GET_S16_END;
get16_xx12_xx92: sample = as_u16(src) ^ 0x8000; goto GET16_END; get_s16_xx12_xx92: sample = as_u16(src) ^ 0x8000; goto GET_S16_END;
get16_xx12_xx21: sample = bswap_16(as_u16(src)); goto GET16_END; get_s16_xx12_xx21: sample = bswap_16(as_u16(src)); goto GET_S16_END;
get16_xx12_xxA1: sample = bswap_16(as_u16(src) ^ 0x80); goto GET16_END; get_s16_xx12_xxA1: sample = bswap_16(as_u16(src) ^ 0x80); goto GET_S16_END;
get16_x123_xx12: sample = as_u32(src) >> 8; goto GET16_END; get_s16_x123_xx12: sample = as_u32(src) >> 8; goto GET_S16_END;
get16_x123_xx92: sample = (as_u32(src) >> 8) ^ 0x8000; goto GET16_END; get_s16_x123_xx92: sample = (as_u32(src) >> 8) ^ 0x8000; goto GET_S16_END;
get16_123x_xx32: sample = bswap_16(as_u32(src) >> 8); goto GET16_END; get_s16_123x_xx32: sample = bswap_16(as_u32(src) >> 8); goto GET_S16_END;
get16_123x_xxB2: sample = bswap_16((as_u32(src) >> 8) ^ 0x8000); goto GET16_END; get_s16_123x_xxB2: sample = bswap_16((as_u32(src) >> 8) ^ 0x8000); goto GET_S16_END;
get16_1234_xx12: sample = as_u32(src) >> 16; goto GET16_END; get_s16_1234_xx12: sample = as_u32(src) >> 16; goto GET_S16_END;
get16_1234_xx92: sample = (as_u32(src) >> 16) ^ 0x8000; goto GET16_END; get_s16_1234_xx92: sample = (as_u32(src) >> 16) ^ 0x8000; goto GET_S16_END;
get16_1234_xx43: sample = bswap_16(as_u32(src)); goto GET16_END; get_s16_1234_xx43: sample = bswap_16(as_u32(src)); goto GET_S16_END;
get16_1234_xxC3: sample = bswap_16(as_u32(src) ^ 0x80); goto GET16_END; get_s16_1234_xxC3: sample = bswap_16(as_u32(src) ^ 0x80); goto GET_S16_END;
} }
#endif #endif
#ifdef PUT16_LABELS #ifdef PUT_S16_LABELS
/* dst_wid dst_endswap sign_toggle*/ /* dst_wid dst_endswap unsigned */
static void *put16_labels[4 * 2 * 2 * 4 * 2] = { static void *put_s16_labels[4 * 2 * 2 * 4 * 2] = {
&&put16_xx12_xxx1, /* 16h -> 8h */ &&put_s16_xx12_xxx1, /* 16h -> 8h */
&&put16_xx12_xxx9, /* 16h ^> 8h */ &&put_s16_xx12_xxx9, /* 16h ^> 8h */
&&put16_xx12_xxx1, /* 16h -> 8s */ &&put_s16_xx12_xxx1, /* 16h -> 8s */
&&put16_xx12_xxx9, /* 16h ^> 8s */ &&put_s16_xx12_xxx9, /* 16h ^> 8s */
&&put16_xx12_xx12, /* 16h -> 16h */ &&put_s16_xx12_xx12, /* 16h -> 16h */
&&put16_xx12_xx92, /* 16h ^> 16h */ &&put_s16_xx12_xx92, /* 16h ^> 16h */
&&put16_xx12_xx21, /* 16h -> 16s */ &&put_s16_xx12_xx21, /* 16h -> 16s */
&&put16_xx12_xx29, /* 16h ^> 16s */ &&put_s16_xx12_xx29, /* 16h ^> 16s */
&&put16_xx12_x120, /* 16h -> 24h */ &&put_s16_xx12_x120, /* 16h -> 24h */
&&put16_xx12_x920, /* 16h ^> 24h */ &&put_s16_xx12_x920, /* 16h ^> 24h */
&&put16_xx12_021x, /* 16h -> 24s */ &&put_s16_xx12_021x, /* 16h -> 24s */
&&put16_xx12_029x, /* 16h ^> 24s */ &&put_s16_xx12_029x, /* 16h ^> 24s */
&&put16_xx12_1200, /* 16h -> 32h */ &&put_s16_xx12_1200, /* 16h -> 32h */
&&put16_xx12_9200, /* 16h ^> 32h */ &&put_s16_xx12_9200, /* 16h ^> 32h */
&&put16_xx12_0021, /* 16h -> 32s */ &&put_s16_xx12_0021, /* 16h -> 32s */
&&put16_xx12_0029, /* 16h ^> 32s */ &&put_s16_xx12_0029, /* 16h ^> 32s */
}; };
#endif #endif
#ifdef PUT16_END #ifdef PUT_S16_END
while (0) { while (0) {
put16_xx12_xxx1: as_u8(dst) = sample >> 8; goto PUT16_END; put_s16_xx12_xxx1: as_u8(dst) = sample >> 8; goto PUT_S16_END;
put16_xx12_xxx9: as_u8(dst) = (sample >> 8) ^ 0x80; goto PUT16_END; put_s16_xx12_xxx9: as_u8(dst) = (sample >> 8) ^ 0x80; goto PUT_S16_END;
put16_xx12_xx12: as_u16(dst) = sample; goto PUT16_END; put_s16_xx12_xx12: as_u16(dst) = sample; goto PUT_S16_END;
put16_xx12_xx92: as_u16(dst) = sample ^ 0x8000; goto PUT16_END; put_s16_xx12_xx92: as_u16(dst) = sample ^ 0x8000; goto PUT_S16_END;
put16_xx12_xx21: as_u16(dst) = bswap_16(sample); goto PUT16_END; put_s16_xx12_xx21: as_u16(dst) = bswap_16(sample); goto PUT_S16_END;
put16_xx12_xx29: as_u16(dst) = bswap_16(sample) ^ 0x80; goto PUT16_END; put_s16_xx12_xx29: as_u16(dst) = bswap_16(sample) ^ 0x80; goto PUT_S16_END;
put16_xx12_x120: as_u32(dst) = (u_int32_t)sample << 8; goto PUT16_END; put_s16_xx12_x120: as_u32(dst) = (u_int32_t)sample << 8; goto PUT_S16_END;
put16_xx12_x920: as_u32(dst) = (u_int32_t)(sample ^ 0x8000) << 8; goto PUT16_END; put_s16_xx12_x920: as_u32(dst) = (u_int32_t)(sample ^ 0x8000) << 8; goto PUT_S16_END;
put16_xx12_021x: as_u32(dst) = (u_int32_t)bswap_16(sample) << 8; goto PUT16_END; put_s16_xx12_021x: as_u32(dst) = (u_int32_t)bswap_16(sample) << 8; goto PUT_S16_END;
put16_xx12_029x: as_u32(dst) = (u_int32_t)(bswap_16(sample) ^ 0x80) << 8; goto PUT16_END; put_s16_xx12_029x: as_u32(dst) = (u_int32_t)(bswap_16(sample) ^ 0x80) << 8; goto PUT_S16_END;
put16_xx12_1200: as_u32(dst) = (u_int32_t)sample << 16; goto PUT16_END; put_s16_xx12_1200: as_u32(dst) = (u_int32_t)sample << 16; goto PUT_S16_END;
put16_xx12_9200: as_u32(dst) = (u_int32_t)(sample ^ 0x8000) << 16; goto PUT16_END; put_s16_xx12_9200: as_u32(dst) = (u_int32_t)(sample ^ 0x8000) << 16; goto PUT_S16_END;
put16_xx12_0021: as_u32(dst) = (u_int32_t)bswap_16(sample); goto PUT16_END; put_s16_xx12_0021: as_u32(dst) = (u_int32_t)bswap_16(sample); goto PUT_S16_END;
put16_xx12_0029: as_u32(dst) = (u_int32_t)bswap_16(sample) ^ 0x80; goto PUT16_END; put_s16_xx12_0029: as_u32(dst) = (u_int32_t)bswap_16(sample) ^ 0x80; goto PUT_S16_END;
} }
#endif #endif
#if 0
#ifdef GET32_LABELS #ifdef GET32_LABELS
/* src_wid src_endswap sign_toggle */ /* src_wid src_endswap unsigned */
static void *get32_labels[4 * 2 * 2] = { static void *get32_labels[4 * 2 * 2] = {
&&get32_xxx1_1000, /* 8h -> 32h */ &&get32_xxx1_1000, /* 8h -> 32h */
&&get32_xxx1_9000, /* 8h ^> 32h */ &&get32_xxx1_9000, /* 8h ^> 32h */
@ -402,91 +403,93 @@ get32_1234_4321: sample = bswap_32(as_u32(src)); goto GET32_END;
get32_1234_C321: sample = bswap_32(as_u32(src) ^ 0x80); goto GET32_END; get32_1234_C321: sample = bswap_32(as_u32(src) ^ 0x80); goto GET32_END;
} }
#endif #endif
#endif
#ifdef PUT32_LABELS #ifdef PUT_U32_LABELS
/* dst_wid dst_endswap sign_toggle*/ /* dst_wid dst_endswap unsigned */
static void *put32_labels[4 * 2 * 2] = { static void *put_u32_labels[4 * 2 * 2] = {
&&put32_1234_xxx1, /* 32h -> 8h */ &&put_u32_1234_xxx9, /* u32h -> s8h */
&&put32_1234_xxx9, /* 32h ^> 8h */ &&put_u32_1234_xxx1, /* u32h -> u8h */
&&put32_1234_xxx1, /* 32h -> 8s */ &&put_u32_1234_xxx9, /* u32h -> s8s */
&&put32_1234_xxx9, /* 32h ^> 8s */ &&put_u32_1234_xxx1, /* u32h -> u8s */
&&put32_1234_xx12, /* 32h -> 16h */ &&put_u32_1234_xx92, /* u32h -> s16h */
&&put32_1234_xx92, /* 32h ^> 16h */ &&put_u32_1234_xx12, /* u32h -> u16h */
&&put32_1234_xx21, /* 32h -> 16s */ &&put_u32_1234_xx29, /* u32h -> s16s */
&&put32_1234_xx29, /* 32h ^> 16s */ &&put_u32_1234_xx21, /* u32h -> u16s */
&&put32_1234_x123, /* 32h -> 24h */ &&put_u32_1234_x923, /* u32h -> s24h */
&&put32_1234_x923, /* 32h ^> 24h */ &&put_u32_1234_x123, /* u32h -> u24h */
&&put32_1234_321x, /* 32h -> 24s */ &&put_u32_1234_329x, /* u32h -> s24s */
&&put32_1234_329x, /* 32h ^> 24s */ &&put_u32_1234_321x, /* u32h -> u24s */
&&put32_1234_1234, /* 32h -> 32h */ &&put_u32_1234_9234, /* u32h -> s32h */
&&put32_1234_9234, /* 32h ^> 32h */ &&put_u32_1234_1234, /* u32h -> u32h */
&&put32_1234_4321, /* 32h -> 32s */ &&put_u32_1234_4329, /* u32h -> s32s */
&&put32_1234_4329, /* 32h ^> 32s */ &&put_u32_1234_4321, /* u32h -> u32s */
}; };
#endif #endif
#ifdef PUT32_END #ifdef PUT_U32_END
while (0) { while (0) {
put32_1234_xxx1: as_u8(dst) = sample >> 24; goto PUT32_END; put_u32_1234_xxx1: as_u8(dst) = sample >> 24; goto PUT_U32_END;
put32_1234_xxx9: as_u8(dst) = (sample >> 24) ^ 0x80; goto PUT32_END; put_u32_1234_xxx9: as_u8(dst) = (sample >> 24) ^ 0x80; goto PUT_U32_END;
put32_1234_xx12: as_u16(dst) = sample >> 16; goto PUT32_END; put_u32_1234_xx12: as_u16(dst) = sample >> 16; goto PUT_U32_END;
put32_1234_xx92: as_u16(dst) = (sample >> 16) ^ 0x8000; goto PUT32_END; put_u32_1234_xx92: as_u16(dst) = (sample >> 16) ^ 0x8000; goto PUT_U32_END;
put32_1234_xx21: as_u16(dst) = bswap_16(sample >> 16); goto PUT32_END; put_u32_1234_xx21: as_u16(dst) = bswap_16(sample >> 16); goto PUT_U32_END;
put32_1234_xx29: as_u16(dst) = bswap_16(sample >> 16) ^ 0x80; goto PUT32_END; put_u32_1234_xx29: as_u16(dst) = bswap_16(sample >> 16) ^ 0x80; goto PUT_U32_END;
put32_1234_x123: as_u32(dst) = sample >> 8; goto PUT32_END; put_u32_1234_x123: as_u32(dst) = sample >> 8; goto PUT_U32_END;
put32_1234_x923: as_u32(dst) = (sample >> 8) ^ 0x800000; goto PUT32_END; put_u32_1234_x923: as_u32(dst) = (sample >> 8) ^ 0x800000; goto PUT_U32_END;
put32_1234_321x: as_u32(dst) = bswap_32(sample) << 8; goto PUT32_END; put_u32_1234_321x: as_u32(dst) = bswap_32(sample) << 8; goto PUT_U32_END;
put32_1234_329x: as_u32(dst) = (bswap_32(sample) ^ 0x80) << 8; goto PUT32_END; put_u32_1234_329x: as_u32(dst) = (bswap_32(sample) ^ 0x80) << 8; goto PUT_U32_END;
put32_1234_1234: as_u32(dst) = sample; goto PUT32_END; put_u32_1234_1234: as_u32(dst) = sample; goto PUT_U32_END;
put32_1234_9234: as_u32(dst) = sample ^ 0x80000000; goto PUT32_END; put_u32_1234_9234: as_u32(dst) = sample ^ 0x80000000; goto PUT_U32_END;
put32_1234_4321: as_u32(dst) = bswap_32(sample); goto PUT32_END; put_u32_1234_4321: as_u32(dst) = bswap_32(sample); goto PUT_U32_END;
put32_1234_4329: as_u32(dst) = bswap_32(sample) ^ 0x80; goto PUT32_END; put_u32_1234_4329: as_u32(dst) = bswap_32(sample) ^ 0x80; goto PUT_U32_END;
} }
#endif #endif
#ifdef GET_LABELS #ifdef GET_U_LABELS
/* width endswap sign_toggle*/ /* width endswap unsigned*/
static void *get_labels[4 * 2 * 2] = { static void *get_u_labels[4 * 2 * 2] = {
&&get_s8, /* s8 -> s8 */ &&get_u_s8, /* s8 -> u8 */
&&get_u8, /* u8 -> s8 */ &&get_u_u8, /* u8 -> u8 */
&&get_s8, /* s8 -> s8 */ &&get_u_s8, /* s8 -> u8 */
&&get_u8, /* u8 -> s8 */ &&get_u_u8, /* u8 -> u8 */
&&get_s16h, /* s16h -> s16h */ &&get_u_s16h, /* s16h -> u16h */
&&get_u16h, /* u16h -> s16h */ &&get_u_u16h, /* u16h -> u16h */
&&get_s16s, /* s16s -> s16h */ &&get_u_s16s, /* s16s -> u16h */
&&get_u16s, /* u16s -> s16h */ &&get_u_u16s, /* u16s -> u16h */
&&get_s24h, /* s24h -> s32h */ &&get_u_s24h, /* s24h -> u32h */
&&get_u24h, /* u24h -> s32h */ &&get_u_u24h, /* u24h -> u32h */
&&get_s24s, /* s24s -> s32h */ &&get_u_s24s, /* s24s -> u32h */
&&get_u24s, /* u24s -> s32h */ &&get_u_u24s, /* u24s -> u32h */
&&get_s32h, /* s32h -> s32h */ &&get_u_s32h, /* s32h -> u32h */
&&get_u32h, /* u32h -> s32h */ &&get_u_u32h, /* u32h -> u32h */
&&get_s32s, /* s32s -> s32h */ &&get_u_s32s, /* s32s -> u32h */
&&get_u32s, /* u32s -> s32h */ &&get_u_u32s, /* u32s -> u32h */
}; };
#endif #endif
#ifdef GET_END #ifdef GET_U_END
while (0) { while (0) {
get_s8: sample = as_s8(src); goto GET_END; get_u_s8: sample = as_u8(src) ^ 0x80; goto GET_U_END;
get_u8: sample = (int8_t)(as_u8(src) ^ 0x80); goto GET_END; get_u_u8: sample = as_u8(src); goto GET_U_END;
get_s16h: sample = as_s16(src); goto GET_END; get_u_s16h: sample = as_u16(src) ^ 0x8000; goto GET_U_END;
get_u16h: sample = (int16_t)(as_u16(src) ^ 0x8000); goto GET_END; get_u_u16h: sample = as_u16(src); goto GET_U_END;
get_s16s: sample = (int16_t)bswap_16(as_u16(src)); goto GET_END; get_u_s16s: sample = bswap_16(as_u16(src) ^ 0x80); goto GET_U_END;
get_u16s: sample = (int16_t)(bswap_16(as_u16(src) ^ 0x80)); goto GET_END; get_u_u16s: sample = bswap_16(as_u16(src)); goto GET_U_END;
get_s24h: sample = (int32_t)(as_u32(src) << 8) / 256; goto GET_END; get_u_s24h: sample = (as_u32(src) ^ 0x800000); goto GET_U_END;
get_u24h: sample = (as_u32(src) ^ 0x80000000); goto GET_END; get_u_u24h: sample = as_u32(src); goto GET_U_END;
get_s24s: sample = (int32_t)(bswap_32(as_u32(src)) << 8) / 256; goto GET_END; get_u_s24s: sample = bswap_32(as_u32(src) ^ 0x800000); goto GET_U_END;
get_u24s: sample = bswap_32(as_u32(src) ^ 0x80); goto GET_END; get_u_u24s: sample = bswap_32(as_u32(src)); goto GET_U_END;
get_s32h: sample = as_s32(src); goto GET_END; get_u_s32h: sample = as_u32(src) ^ 0x80000000; goto GET_U_END;
get_u32h: sample = as_u32(src) ^ 0x80000000; goto GET_END; get_u_u32h: sample = as_u32(src); goto GET_U_END;
get_s32s: sample = bswap_32(as_u32(src)); goto GET_END; get_u_s32s: sample = bswap_32(as_u32(src) ^ 0x80); goto GET_U_END;
get_u32s: sample = bswap_32(as_u32(src) ^ 0x80); goto GET_END; get_u_u32s: sample = bswap_32(as_u32(src)); goto GET_U_END;
} }
#endif #endif
#if 0
#ifdef PUT_LABELS #ifdef PUT_LABELS
/* width endswap sign_toggle*/ /* width endswap unsigned */
static void *put_labels[4 * 2 * 2] = { static void *put_labels[4 * 2 * 2] = {
&&put_s8, /* s8 -> s8 */ &&put_s8, /* s8 -> s8 */
&&put_u8, /* u8 -> s8 */ &&put_u8, /* u8 -> s8 */
@ -523,6 +526,7 @@ put_u32h: as_u32(dst) = sample ^ 0x80000000; goto PUT_END;
put_s32s: as_s32(dst) = bswap_32(sample); goto PUT_END; put_s32s: as_s32(dst) = bswap_32(sample); goto PUT_END;
put_u32s: as_u32(dst) = bswap_32(sample ^ 0x80); goto PUT_END; put_u32s: as_u32(dst) = bswap_32(sample ^ 0x80); goto PUT_END;
#endif #endif
#endif
#undef as_u8 #undef as_u8
#undef as_u16 #undef as_u16

View file

@ -87,18 +87,18 @@ static void resample_expand(snd_pcm_plugin_t *plugin,
rate_t *data = (rate_t *)plugin->extra_data; rate_t *data = (rate_t *)plugin->extra_data;
rate_voice_t *rvoices = data->voices; rate_voice_t *rvoices = data->voices;
#define GET16_LABELS #define GET_S16_LABELS
#define PUT16_LABELS #define PUT_S16_LABELS
#include "plugin_ops.h" #include "plugin_ops.h"
#undef GET16_LABELS #undef GET_S16_LABELS
#undef PUT16_LABELS #undef PUT_S16_LABELS
void *get = get16_labels[data->get]; void *get = get_s16_labels[data->get];
void *put = put16_labels[data->put]; void *put = put_s16_labels[data->put];
void *get16_end = 0; void *get_s16_end = 0;
signed short sample = 0; signed short sample = 0;
#define GET16_END *get16_end #define GET_S16_END *get_s16_end
#include "plugin_ops.h" #include "plugin_ops.h"
#undef GET16_END #undef GET_S16_END
for (voice = 0; voice < plugin->src_format.voices; voice++, rvoices++) { for (voice = 0; voice < plugin->src_format.voices; voice++, rvoices++) {
pos = data->pos; pos = data->pos;
@ -118,7 +118,7 @@ static void resample_expand(snd_pcm_plugin_t *plugin,
src_samples1 = src_samples; src_samples1 = src_samples;
dst_samples1 = dst_samples; dst_samples1 = dst_samples;
if (pos & ~MASK) { if (pos & ~MASK) {
get16_end = &&after_get1; get_s16_end = &&after_get1;
goto *get; goto *get;
after_get1: after_get1:
pos &= MASK; pos &= MASK;
@ -132,7 +132,7 @@ static void resample_expand(snd_pcm_plugin_t *plugin,
pos &= MASK; pos &= MASK;
S1 = S2; S1 = S2;
if (src_samples1-- > 0) { if (src_samples1-- > 0) {
get16_end = &&after_get2; get_s16_end = &&after_get2;
goto *get; goto *get;
after_get2: after_get2:
S2 = sample; S2 = sample;
@ -146,9 +146,9 @@ static void resample_expand(snd_pcm_plugin_t *plugin,
val = 32767; val = 32767;
sample = val; sample = val;
goto *put; goto *put;
#define PUT16_END after_put #define PUT_S16_END after_put
#include "plugin_ops.h" #include "plugin_ops.h"
#undef PUT16_END #undef PUT_S16_END
after_put: after_put:
dst += dst_step; dst += dst_step;
pos += data->pitch; pos += data->pitch;
@ -175,13 +175,13 @@ static void resample_shrink(snd_pcm_plugin_t *plugin,
rate_t *data = (rate_t *)plugin->extra_data; rate_t *data = (rate_t *)plugin->extra_data;
rate_voice_t *rvoices = data->voices; rate_voice_t *rvoices = data->voices;
#define GET16_LABELS #define GET_S16_LABELS
#define PUT16_LABELS #define PUT_S16_LABELS
#include "plugin_ops.h" #include "plugin_ops.h"
#undef GET16_LABELS #undef GET_S16_LABELS
#undef PUT16_LABELS #undef PUT_S16_LABELS
void *get = get16_labels[data->get]; void *get = get_s16_labels[data->get];
void *put = put16_labels[data->put]; void *put = put_s16_labels[data->put];
signed short sample = 0; signed short sample = 0;
for (voice = 0; voice < plugin->src_format.voices; ++voice) { for (voice = 0; voice < plugin->src_format.voices; ++voice) {
@ -205,9 +205,9 @@ static void resample_shrink(snd_pcm_plugin_t *plugin,
S1 = S2; S1 = S2;
if (src_samples1-- > 0) { if (src_samples1-- > 0) {
goto *get; goto *get;
#define GET16_END after_get #define GET_S16_END after_get
#include "plugin_ops.h" #include "plugin_ops.h"
#undef GET16_END #undef GET_S16_END
after_get: after_get:
S2 = sample; S2 = sample;
src += src_step; src += src_step;
@ -221,9 +221,9 @@ static void resample_shrink(snd_pcm_plugin_t *plugin,
val = 32767; val = 32767;
sample = val; sample = val;
goto *put; goto *put;
#define PUT16_END after_put #define PUT_S16_END after_put
#include "plugin_ops.h" #include "plugin_ops.h"
#undef PUT16_END #undef PUT_S16_END
after_put: after_put:
dst += dst_step; dst += dst_step;
dst_samples1--; dst_samples1--;

View file

@ -46,7 +46,7 @@ typedef void (*route_voice_f)(snd_pcm_plugin_t *plugin,
typedef struct { typedef struct {
int voice; int voice;
int as_int; int as_int;
#ifndef __KERNEL #if ROUTE_PLUGIN_USE_FLOAT
float as_float; float as_float;
#endif #endif
} ttable_src_t; } ttable_src_t;
@ -59,7 +59,7 @@ struct ttable_dst {
}; };
struct route_private_data { struct route_private_data {
enum {INT32=0, INT64=1, FLOAT=2} sum_type; enum {UINT32=0, UINT64=1, FLOAT=2} sum_type;
int get, put; int get, put;
int conv; int conv;
int src_sample_size; int src_sample_size;
@ -67,28 +67,28 @@ struct route_private_data {
}; };
typedef union { typedef union {
int32_t as_int32; u_int32_t as_uint32;
int64_t as_int64; u_int64_t as_uint64;
#ifndef __KERNEL__ #if ROUTE_PLUGIN_USE_FLOAT
float as_float; float as_float;
#endif #endif
} sum_t; } sum_t;
static void route_to_voice_zero(snd_pcm_plugin_t *plugin, static void route_to_voice_from_zero(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices UNUSED, const snd_pcm_plugin_voice_t *src_voices UNUSED,
snd_pcm_plugin_voice_t *dst_voice, snd_pcm_plugin_voice_t *dst_voice,
ttable_dst_t* ttable UNUSED, size_t samples) ttable_dst_t* ttable UNUSED, size_t samples)
{ {
if (dst_voice->wanted) if (dst_voice->wanted)
snd_pcm_area_silence(&dst_voice->area, 0, samples, plugin->dst_format.format); snd_pcm_area_silence(&dst_voice->area, 0, samples, plugin->dst_format.format);
dst_voice->enabled = 0; dst_voice->enabled = 0;
} }
static void route_to_voice_one(snd_pcm_plugin_t *plugin, static void route_to_voice_from_one(snd_pcm_plugin_t *plugin,
const snd_pcm_plugin_voice_t *src_voices, const snd_pcm_plugin_voice_t *src_voices,
snd_pcm_plugin_voice_t *dst_voice, snd_pcm_plugin_voice_t *dst_voice,
ttable_dst_t* ttable, size_t samples) ttable_dst_t* ttable, size_t samples)
{ {
#define CONV_LABELS #define CONV_LABELS
#include "plugin_ops.h" #include "plugin_ops.h"
@ -105,7 +105,7 @@ static void route_to_voice_one(snd_pcm_plugin_t *plugin,
break; break;
} }
if (srcidx == ttable->nsrcs) { if (srcidx == ttable->nsrcs) {
route_to_voice_zero(plugin, src_voices, dst_voice, ttable, samples); route_to_voice_from_zero(plugin, src_voices, dst_voice, ttable, samples);
return; return;
} }
@ -131,20 +131,20 @@ static void route_to_voice(snd_pcm_plugin_t *plugin,
snd_pcm_plugin_voice_t *dst_voice, snd_pcm_plugin_voice_t *dst_voice,
ttable_dst_t* ttable, size_t samples) ttable_dst_t* ttable, size_t samples)
{ {
#define GET_LABELS #define GET_U_LABELS
#define PUT32_LABELS #define PUT_U32_LABELS
#include "plugin_ops.h" #include "plugin_ops.h"
#undef GET_LABELS #undef GET_U_LABELS
#undef PUT32_LABELS #undef PUT_U32_LABELS
static void *zero_labels[3] = { &&zero_int32, &&zero_int64, static void *zero_labels[3] = { &&zero_int32, &&zero_int64,
#ifndef __KERNEL__ #if ROUTE_PLUGIN_USE_FLOAT
&&zero_float &&zero_float
#endif #endif
}; };
/* sum_type att */ /* sum_type att */
static void *add_labels[3 * 2] = { &&add_int32_noatt, &&add_int32_att, static void *add_labels[3 * 2] = { &&add_int32_noatt, &&add_int32_att,
&&add_int64_noatt, &&add_int64_att, &&add_int64_noatt, &&add_int64_att,
#ifndef __KERNEL__ #if ROUTE_PLUGIN_USE_FLOAT
&&add_float_noatt, &&add_float_att &&add_float_noatt, &&add_float_att
#endif #endif
}; };
@ -165,7 +165,7 @@ static void route_to_voice(snd_pcm_plugin_t *plugin,
&&norm_int64_8_att, &&norm_int64_8_att,
&&norm_int64_16_att, &&norm_int64_16_att,
&&norm_int64_24_att, &&norm_int64_24_att,
#ifndef __KERNEL__ #if ROUTE_PLUGIN_USE_FLOAT
&&norm_float_0, &&norm_float_0,
&&norm_float_8, &&norm_float_8,
&&norm_float_16, &&norm_float_16,
@ -177,14 +177,14 @@ static void route_to_voice(snd_pcm_plugin_t *plugin,
#endif #endif
}; };
route_t *data = (route_t *)plugin->extra_data; route_t *data = (route_t *)plugin->extra_data;
void *zero, *get, *add, *norm, *put32; void *zero, *get, *add, *norm, *put_u32;
int nsrcs = ttable->nsrcs; int nsrcs = ttable->nsrcs;
char *dst; char *dst;
int dst_step; int dst_step;
char *srcs[nsrcs]; char *srcs[nsrcs];
int src_steps[nsrcs]; int src_steps[nsrcs];
ttable_src_t src_tt[nsrcs]; ttable_src_t src_tt[nsrcs];
int32_t sample = 0; u_int32_t sample = 0;
int srcidx, srcidx1 = 0; int srcidx, srcidx1 = 0;
for (srcidx = 0; srcidx < nsrcs; ++srcidx) { for (srcidx = 0; srcidx < nsrcs; ++srcidx) {
const snd_pcm_plugin_voice_t *src_voice = &src_voices[ttable->srcs[srcidx].voice]; const snd_pcm_plugin_voice_t *src_voice = &src_voices[ttable->srcs[srcidx].voice];
@ -197,19 +197,19 @@ static void route_to_voice(snd_pcm_plugin_t *plugin,
} }
nsrcs = srcidx1; nsrcs = srcidx1;
if (nsrcs == 0) { if (nsrcs == 0) {
route_to_voice_zero(plugin, src_voices, dst_voice, ttable, samples); route_to_voice_from_zero(plugin, src_voices, dst_voice, ttable, samples);
return; return;
} else if (nsrcs == 1 && src_tt[0].as_int == ROUTE_PLUGIN_RESOLUTION) { } else if (nsrcs == 1 && src_tt[0].as_int == ROUTE_PLUGIN_RESOLUTION) {
route_to_voice_one(plugin, src_voices, dst_voice, ttable, samples); route_to_voice_from_one(plugin, src_voices, dst_voice, ttable, samples);
return; return;
} }
dst_voice->enabled = 1; dst_voice->enabled = 1;
zero = zero_labels[data->sum_type]; zero = zero_labels[data->sum_type];
get = get_labels[data->get]; get = get_u_labels[data->get];
add = add_labels[data->sum_type * 2 + ttable->att]; add = add_labels[data->sum_type * 2 + ttable->att];
norm = norm_labels[data->sum_type * 8 + ttable->att * 4 + 4 - data->src_sample_size]; norm = norm_labels[data->sum_type * 8 + ttable->att * 4 + 4 - data->src_sample_size];
put32 = put32_labels[data->put]; put_u32 = put_u32_labels[data->put];
dst = dst_voice->area.addr + dst_voice->area.first / 8; dst = dst_voice->area.addr + dst_voice->area.first / 8;
dst_step = dst_voice->area.step / 8; dst_step = dst_voice->area.step / 8;
@ -220,12 +220,12 @@ static void route_to_voice(snd_pcm_plugin_t *plugin,
/* Zero sum */ /* Zero sum */
goto *zero; goto *zero;
zero_int32: zero_int32:
sum.as_int32 = 0; sum.as_uint32 = 0;
goto zero_end; goto zero_end;
zero_int64: zero_int64:
sum.as_int64 = 0; sum.as_uint64 = 0;
goto zero_end; goto zero_end;
#ifndef __KERNEL__ #if ROUTE_PLUGIN_USE_FLOAT
zero_float: zero_float:
sum.as_float = 0.0; sum.as_float = 0.0;
goto zero_end; goto zero_end;
@ -236,28 +236,28 @@ static void route_to_voice(snd_pcm_plugin_t *plugin,
/* Get sample */ /* Get sample */
goto *get; goto *get;
#define GET_END after_get #define GET_U_END after_get
#include "plugin_ops.h" #include "plugin_ops.h"
#undef GET_END #undef GET_U_END
after_get: after_get:
/* Sum */ /* Sum */
goto *add; goto *add;
add_int32_att: add_int32_att:
sum.as_int32 += sample * ttp->as_int; sum.as_uint32 += sample * ttp->as_int;
goto after_sum; goto after_sum;
add_int32_noatt: add_int32_noatt:
if (ttp->as_int) if (ttp->as_int)
sum.as_int32 += sample; sum.as_uint32 += sample;
goto after_sum; goto after_sum;
add_int64_att: add_int64_att:
sum.as_int64 += (int64_t) sample * ttp->as_int; sum.as_uint64 += (u_int64_t) sample * ttp->as_int;
goto after_sum; goto after_sum;
add_int64_noatt: add_int64_noatt:
if (ttp->as_int) if (ttp->as_int)
sum.as_int64 += sample; sum.as_uint64 += sample;
goto after_sum; goto after_sum;
#ifndef __KERNEL__ #if ROUTE_PLUGIN_USE_FLOAT
add_float_att: add_float_att:
sum.as_float += sample * ttp->as_float; sum.as_float += sample * ttp->as_float;
goto after_sum; goto after_sum;
@ -272,64 +272,55 @@ static void route_to_voice(snd_pcm_plugin_t *plugin,
} }
/* Normalization */ /* Normalization */
goto *norm;
norm_int32_8_att: norm_int32_8_att:
sum.as_int64 = sum.as_int32; sum.as_uint64 = sum.as_uint32;
sum.as_int64 *= (1 << 8) / ROUTE_PLUGIN_RESOLUTION;
goto after_norm;
norm_int32_16_att:
sum.as_int64 = sum.as_int32;
sum.as_int64 *= (1 << 16) / ROUTE_PLUGIN_RESOLUTION;
goto after_norm;
norm_int32_24_att:
sum.as_int64 = sum.as_int32;
sum.as_int64 *= (1 << 24) / ROUTE_PLUGIN_RESOLUTION;
goto norm_int;
norm_int64_0_att:
sum.as_int64 /= ROUTE_PLUGIN_RESOLUTION;
goto norm_int;
norm_int64_8_att: norm_int64_8_att:
sum.as_int64 *= (1 << 8) / ROUTE_PLUGIN_RESOLUTION; sum.as_uint64 <<= 8;
norm_int64_0_att:
sum.as_uint64 /= ROUTE_PLUGIN_RESOLUTION;
goto norm_int; goto norm_int;
norm_int32_16_att:
sum.as_uint64 = sum.as_uint32;
norm_int64_16_att: norm_int64_16_att:
sum.as_int64 *= (1 << 16) / ROUTE_PLUGIN_RESOLUTION; sum.as_uint64 <<= 16;
sum.as_uint64 /= ROUTE_PLUGIN_RESOLUTION;
goto norm_int; goto norm_int;
norm_int32_24_att:
sum.as_uint64 = sum.as_uint32;
norm_int64_24_att: norm_int64_24_att:
sum.as_int64 *= (1 << 24) / ROUTE_PLUGIN_RESOLUTION; sum.as_uint64 <<= 24;
sum.as_uint64 /= ROUTE_PLUGIN_RESOLUTION;
goto norm_int; goto norm_int;
norm_int32_8_noatt: norm_int32_8_noatt:
sum.as_int64 = sum.as_int32; sum.as_uint64 = sum.as_uint32;
sum.as_int64 *= (1 << 8);
goto after_norm;
norm_int32_16_noatt:
sum.as_int64 = sum.as_int32;
sum.as_int64 *= (1 << 16);
goto after_norm;
norm_int32_24_noatt:
sum.as_int64 = sum.as_int32;
sum.as_int64 *= (1 << 24);
goto norm_int;
norm_int64_0_noatt:
goto norm_int;
norm_int64_8_noatt: norm_int64_8_noatt:
sum.as_int64 *= (1 << 8); sum.as_uint64 <<= 8;
goto norm_int; goto norm_int;
norm_int32_16_noatt:
sum.as_uint64 = sum.as_uint32;
norm_int64_16_noatt: norm_int64_16_noatt:
sum.as_int64 *= (1 << 16); sum.as_uint64 <<= 16;
goto norm_int; goto norm_int;
norm_int32_24_noatt:
sum.as_uint64 = sum.as_uint32;
norm_int64_24_noatt: norm_int64_24_noatt:
sum.as_int64 *= (1 << 24); sum.as_uint64 <<= 24;
goto norm_int; goto norm_int;
norm_int64_0_noatt:
norm_int: norm_int:
if (sum.as_int64 < (int32_t)0x80000000) if (sum.as_uint64 > (u_int32_t)0xffffffff)
sample = (int32_t)0x80000000; sample = (u_int32_t)0xffffffff;
else if (sum.as_int64 > 0x7fffffffLL) {
sample = 0x7fffffff;
}
else else
sample = sum.as_int64; sample = sum.as_uint64;
goto after_norm; goto after_norm;
#ifndef __KERNEL__
#if ROUTE_PLUGIN_USE_FLOAT
norm_float_8: norm_float_8:
sum.as_float *= 1 << 8; sum.as_float *= 1 << 8;
goto norm_float; goto norm_float;
@ -342,10 +333,8 @@ static void route_to_voice(snd_pcm_plugin_t *plugin,
norm_float_0: norm_float_0:
norm_float: norm_float:
sum.as_float = floor(sum.as_float + 0.5); sum.as_float = floor(sum.as_float + 0.5);
if (sum.as_float < (int32_t)0x80000000) if (sum.as_float > (u_int32_t)0xffffffff)
sample = (int32_t)0x80000000; sample = (u_int32_t)0xffffffff;
else if (sum.as_float > 0x7fffffff)
sample = 0x7fffffff;
else else
sample = sum.as_float; sample = sum.as_float;
goto after_norm; goto after_norm;
@ -353,11 +342,11 @@ static void route_to_voice(snd_pcm_plugin_t *plugin,
after_norm: after_norm:
/* Put sample */ /* Put sample */
goto *put32; goto *put_u32;
#define PUT32_END after_put32 #define PUT_U32_END after_put_u32
#include "plugin_ops.h" #include "plugin_ops.h"
#undef PUT32_END #undef PUT_U32_END
after_put32: after_put_u32:
dst += dst_step; dst += dst_step;
} }
@ -412,14 +401,6 @@ int route_dst_voices_mask(snd_pcm_plugin_t *plugin,
return 0; return 0;
} }
#ifdef __KERNEL__
#define FULL ROUTE_PLUGIN_RESOLUTION
typedef int src_ttable_entry_t;
#else
#define FULL 1.0
typedef float src_ttable_entry_t;
#endif
static void route_free(snd_pcm_plugin_t *plugin, void* private_data UNUSED) static void route_free(snd_pcm_plugin_t *plugin, void* private_data UNUSED)
{ {
route_t *data = (route_t *)plugin->extra_data; route_t *data = (route_t *)plugin->extra_data;
@ -431,11 +412,11 @@ static void route_free(snd_pcm_plugin_t *plugin, void* private_data UNUSED)
} }
static int route_load_ttable(snd_pcm_plugin_t *plugin, static int route_load_ttable(snd_pcm_plugin_t *plugin,
const src_ttable_entry_t* src_ttable) const route_ttable_entry_t* src_ttable)
{ {
route_t *data; route_t *data;
unsigned int src_voice, dst_voice; unsigned int src_voice, dst_voice;
const src_ttable_entry_t *sptr; const route_ttable_entry_t *sptr;
ttable_dst_t *dptr; ttable_dst_t *dptr;
if (src_ttable == NULL) if (src_ttable == NULL)
return 0; return 0;
@ -444,7 +425,7 @@ static int route_load_ttable(snd_pcm_plugin_t *plugin,
sptr = src_ttable; sptr = src_ttable;
plugin->private_free = route_free; plugin->private_free = route_free;
for (dst_voice = 0; dst_voice < plugin->dst_format.voices; ++dst_voice) { for (dst_voice = 0; dst_voice < plugin->dst_format.voices; ++dst_voice) {
src_ttable_entry_t t = 0; route_ttable_entry_t t = 0;
int att = 0; int att = 0;
int nsrcs = 0; int nsrcs = 0;
ttable_src_t srcs[plugin->src_format.voices]; ttable_src_t srcs[plugin->src_format.voices];
@ -453,12 +434,12 @@ static int route_load_ttable(snd_pcm_plugin_t *plugin,
return -EINVAL; return -EINVAL;
if (*sptr != 0) { if (*sptr != 0) {
srcs[nsrcs].voice = src_voice; srcs[nsrcs].voice = src_voice;
#ifdef __KERNEL__ #if ROUTE_PLUGIN_USE_FLOAT
srcs[nsrcs].as_int = *sptr;
#else
/* Also in user space for non attenuated */ /* Also in user space for non attenuated */
srcs[nsrcs].as_int = (*sptr == FULL ? ROUTE_PLUGIN_RESOLUTION : 0); srcs[nsrcs].as_int = (*sptr == FULL ? ROUTE_PLUGIN_RESOLUTION : 0);
srcs[nsrcs].as_float = *sptr; srcs[nsrcs].as_float = *sptr;
#else
srcs[nsrcs].as_int = *sptr;
#endif #endif
if (*sptr != FULL) if (*sptr != FULL)
att = 1; att = 1;
@ -475,10 +456,10 @@ static int route_load_ttable(snd_pcm_plugin_t *plugin,
dptr->nsrcs = nsrcs; dptr->nsrcs = nsrcs;
switch (nsrcs) { switch (nsrcs) {
case 0: case 0:
dptr->func = route_to_voice_zero; dptr->func = route_to_voice_from_zero;
break; break;
case 1: case 1:
dptr->func = route_to_voice_one; dptr->func = route_to_voice_from_one;
break; break;
default: default:
dptr->func = route_to_voice; dptr->func = route_to_voice;
@ -556,7 +537,7 @@ int snd_pcm_plugin_build_route(snd_pcm_plugin_handle_t *handle,
int channel, int channel,
snd_pcm_format_t *src_format, snd_pcm_format_t *src_format,
snd_pcm_format_t *dst_format, snd_pcm_format_t *dst_format,
src_ttable_entry_t *ttable, route_ttable_entry_t *ttable,
snd_pcm_plugin_t **r_plugin) snd_pcm_plugin_t **r_plugin)
{ {
route_t *data; route_t *data;
@ -587,13 +568,13 @@ int snd_pcm_plugin_build_route(snd_pcm_plugin_handle_t *handle,
data->put = getput_index(dst_format->format); data->put = getput_index(dst_format->format);
data->conv = conv_index(src_format->format, dst_format->format); data->conv = conv_index(src_format->format, dst_format->format);
#ifdef __KERNEL__ #if ROUTE_PLUGIN_USE_FLOAT
if (snd_pcm_format_width(src_format->format) == 32)
data->sum_type = INT64;
else
data->sum_type = INT32;
#else
data->sum_type = FLOAT; data->sum_type = FLOAT;
#else
if (snd_pcm_format_width(src_format->format) == 32)
data->sum_type = UINT64;
else
data->sum_type = UINT32;
#endif #endif
data->src_sample_size = snd_pcm_format_width(src_format->format) / 8; data->src_sample_size = snd_pcm_format_width(src_format->format) / 8;