From 8a625fd63ba5c175bd920c7301dfba1d53b87f7f Mon Sep 17 00:00:00 2001 From: Abramo Bagnara Date: Sun, 22 Oct 2000 09:50:20 +0000 Subject: [PATCH] Cleaned and fixed plugin ops --- src/pcm/pcm_adpcm.c | 28 ++-- src/pcm/pcm_alaw.c | 28 ++-- src/pcm/pcm_mulaw.c | 28 ++-- src/pcm/pcm_plugin.c | 27 ++- src/pcm/pcm_plugin.h | 3 +- src/pcm/pcm_rate.c | 44 ++--- src/pcm/pcm_route.c | 30 ++-- src/pcm/plugin_ops.h | 384 +++++++++++++++++++++---------------------- 8 files changed, 293 insertions(+), 279 deletions(-) diff --git a/src/pcm/pcm_adpcm.c b/src/pcm/pcm_adpcm.c index e1c70f1d..2c58b1da 100644 --- a/src/pcm/pcm_adpcm.c +++ b/src/pcm/pcm_adpcm.c @@ -204,10 +204,10 @@ static void adpcm_decode(snd_pcm_channel_area_t *src_areas, size_t frames, size_t channels, int putidx, adpcm_state_t *states) { -#define PUT_S16_LABELS +#define PUT16_LABELS #include "plugin_ops.h" -#undef PUT_S16_LABELS - void *put = put_s16_labels[putidx]; +#undef PUT16_LABELS + void *put = put16_labels[putidx]; size_t channel; for (channel = 0; channel < channels; ++channel, ++states) { char *src; @@ -243,9 +243,9 @@ static void adpcm_decode(snd_pcm_channel_area_t *src_areas, v = (*src >> 4) & 0x0f; sample = adpcm_decoder(v, states); goto *put; -#define PUT_S16_END after +#define PUT16_END after #include "plugin_ops.h" -#undef PUT_S16_END +#undef PUT16_END after: src += src_step; srcbit += srcbit_step; @@ -265,10 +265,10 @@ static void adpcm_encode(snd_pcm_channel_area_t *src_areas, size_t frames, size_t channels, int getidx, adpcm_state_t *states) { -#define GET_S16_LABELS +#define GET16_LABELS #include "plugin_ops.h" -#undef GET_S16_LABELS - void *get = get_s16_labels[getidx]; +#undef GET16_LABELS + void *get = get16_labels[getidx]; size_t channel; int16_t sample = 0; for (channel = 0; channel < channels; ++channel, ++states) { @@ -299,9 +299,9 @@ static void adpcm_encode(snd_pcm_channel_area_t *src_areas, while (frames1-- > 0) { int v; goto *get; -#define GET_S16_END after +#define GET16_END after #include "plugin_ops.h" -#undef GET_S16_END +#undef GET16_END after: v = adpcm_encoder(sample, states); if (dstbit) @@ -409,18 +409,18 @@ static int snd_pcm_adpcm_setup(snd_pcm_t *pcm, snd_pcm_setup_t * setup) setup->mmap_bytes = 0; if (pcm->stream == SND_PCM_STREAM_PLAYBACK) { if (adpcm->sformat == SND_PCM_SFMT_IMA_ADPCM) { - adpcm->getput_idx = getput_index(adpcm->cformat); + adpcm->getput_idx = get_index(adpcm->cformat, SND_PCM_SFMT_S16); adpcm->func = adpcm_encode; } else { - adpcm->getput_idx = getput_index(adpcm->sformat); + adpcm->getput_idx = put_index(SND_PCM_SFMT_S16, adpcm->sformat); adpcm->func = adpcm_decode; } } else { if (adpcm->sformat == SND_PCM_SFMT_IMA_ADPCM) { - adpcm->getput_idx = getput_index(adpcm->cformat); + adpcm->getput_idx = put_index(SND_PCM_SFMT_S16, adpcm->cformat); adpcm->func = adpcm_decode; } else { - adpcm->getput_idx = getput_index(adpcm->sformat); + adpcm->getput_idx = get_index(adpcm->sformat, SND_PCM_SFMT_S16); adpcm->func = adpcm_encode; } } diff --git a/src/pcm/pcm_alaw.c b/src/pcm/pcm_alaw.c index c105d78f..de8f944e 100644 --- a/src/pcm/pcm_alaw.c +++ b/src/pcm/pcm_alaw.c @@ -128,10 +128,10 @@ static void alaw_decode(snd_pcm_channel_area_t *src_areas, size_t dst_offset, size_t frames, size_t channels, int putidx) { -#define PUT_S16_LABELS +#define PUT16_LABELS #include "plugin_ops.h" -#undef PUT_S16_LABELS - void *put = put_s16_labels[putidx]; +#undef PUT16_LABELS + void *put = put16_labels[putidx]; size_t channel; for (channel = 0; channel < channels; ++channel) { char *src; @@ -157,9 +157,9 @@ static void alaw_decode(snd_pcm_channel_area_t *src_areas, while (frames1-- > 0) { int16_t sample = alaw_to_s16(*src); goto *put; -#define PUT_S16_END after +#define PUT16_END after #include "plugin_ops.h" -#undef PUT_S16_END +#undef PUT16_END after: src += src_step; dst += dst_step; @@ -173,10 +173,10 @@ static void alaw_encode(snd_pcm_channel_area_t *src_areas, size_t dst_offset, size_t frames, size_t channels, int getidx) { -#define GET_S16_LABELS +#define GET16_LABELS #include "plugin_ops.h" -#undef GET_S16_LABELS - void *get = get_s16_labels[getidx]; +#undef GET16_LABELS + void *get = get16_labels[getidx]; size_t channel; int16_t sample = 0; for (channel = 0; channel < channels; ++channel) { @@ -202,9 +202,9 @@ static void alaw_encode(snd_pcm_channel_area_t *src_areas, frames1 = frames; while (frames1-- > 0) { goto *get; -#define GET_S16_END after +#define GET16_END after #include "plugin_ops.h" -#undef GET_S16_END +#undef GET16_END after: *dst = s16_to_alaw(sample); src += src_step; @@ -291,18 +291,18 @@ static int snd_pcm_alaw_setup(snd_pcm_t *pcm, snd_pcm_setup_t * setup) setup->mmap_bytes = 0; if (pcm->stream == SND_PCM_STREAM_PLAYBACK) { if (alaw->sformat == SND_PCM_SFMT_A_LAW) { - alaw->getput_idx = getput_index(alaw->cformat); + alaw->getput_idx = get_index(alaw->cformat, SND_PCM_SFMT_S16); alaw->func = alaw_encode; } else { - alaw->getput_idx = getput_index(alaw->sformat); + alaw->getput_idx = put_index(SND_PCM_SFMT_S16, alaw->sformat); alaw->func = alaw_decode; } } else { if (alaw->sformat == SND_PCM_SFMT_A_LAW) { - alaw->getput_idx = getput_index(alaw->cformat); + alaw->getput_idx = put_index(SND_PCM_SFMT_S16, alaw->cformat); alaw->func = alaw_decode; } else { - alaw->getput_idx = getput_index(alaw->sformat); + alaw->getput_idx = get_index(alaw->sformat, SND_PCM_SFMT_S16); alaw->func = alaw_encode; } } diff --git a/src/pcm/pcm_mulaw.c b/src/pcm/pcm_mulaw.c index 95c3f82f..e7ed4802 100644 --- a/src/pcm/pcm_mulaw.c +++ b/src/pcm/pcm_mulaw.c @@ -145,10 +145,10 @@ static void mulaw_decode(snd_pcm_channel_area_t *src_areas, size_t dst_offset, size_t frames, size_t channels, int putidx) { -#define PUT_S16_LABELS +#define PUT16_LABELS #include "plugin_ops.h" -#undef PUT_S16_LABELS - void *put = put_s16_labels[putidx]; +#undef PUT16_LABELS + void *put = put16_labels[putidx]; size_t channel; for (channel = 0; channel < channels; ++channel) { char *src; @@ -174,9 +174,9 @@ static void mulaw_decode(snd_pcm_channel_area_t *src_areas, while (frames1-- > 0) { int16_t sample = ulaw_to_s16(*src); goto *put; -#define PUT_S16_END after +#define PUT16_END after #include "plugin_ops.h" -#undef PUT_S16_END +#undef PUT16_END after: src += src_step; dst += dst_step; @@ -190,10 +190,10 @@ static void mulaw_encode(snd_pcm_channel_area_t *src_areas, size_t dst_offset, size_t frames, size_t channels, int getidx) { -#define GET_S16_LABELS +#define GET16_LABELS #include "plugin_ops.h" -#undef GET_S16_LABELS - void *get = get_s16_labels[getidx]; +#undef GET16_LABELS + void *get = get16_labels[getidx]; size_t channel; int16_t sample = 0; for (channel = 0; channel < channels; ++channel) { @@ -219,9 +219,9 @@ static void mulaw_encode(snd_pcm_channel_area_t *src_areas, frames1 = frames; while (frames1-- > 0) { goto *get; -#define GET_S16_END after +#define GET16_END after #include "plugin_ops.h" -#undef GET_S16_END +#undef GET16_END after: *dst = s16_to_ulaw(sample); src += src_step; @@ -308,18 +308,18 @@ static int snd_pcm_mulaw_setup(snd_pcm_t *pcm, snd_pcm_setup_t * setup) setup->mmap_bytes = 0; if (pcm->stream == SND_PCM_STREAM_PLAYBACK) { if (mulaw->sformat == SND_PCM_SFMT_MU_LAW) { - mulaw->getput_idx = getput_index(mulaw->cformat); + mulaw->getput_idx = get_index(mulaw->cformat, SND_PCM_SFMT_S16); mulaw->func = mulaw_encode; } else { - mulaw->getput_idx = getput_index(mulaw->sformat); + mulaw->getput_idx = put_index(SND_PCM_SFMT_S16, mulaw->sformat); mulaw->func = mulaw_decode; } } else { if (mulaw->sformat == SND_PCM_SFMT_MU_LAW) { - mulaw->getput_idx = getput_index(mulaw->cformat); + mulaw->getput_idx = put_index(SND_PCM_SFMT_S16, mulaw->cformat); mulaw->func = mulaw_decode; } else { - mulaw->getput_idx = getput_index(mulaw->sformat); + mulaw->getput_idx = get_index(mulaw->sformat, SND_PCM_SFMT_S16); mulaw->func = mulaw_encode; } } diff --git a/src/pcm/pcm_plugin.c b/src/pcm/pcm_plugin.c index 303f4819..9929558f 100644 --- a/src/pcm/pcm_plugin.c +++ b/src/pcm/pcm_plugin.c @@ -379,15 +379,32 @@ int conv_index(int src_format, int dst_format) return src_width * 32 + src_endian * 16 + sign * 8 + dst_width * 2 + dst_endian; } -int getput_index(int format) +int get_index(int src_format, int dst_format) { int sign, width, endian; - sign = !snd_pcm_format_signed(format); - width = snd_pcm_format_width(format) / 8 - 1; + sign = (snd_pcm_format_signed(src_format) != + snd_pcm_format_signed(dst_format)); + width = snd_pcm_format_width(src_format) / 8 - 1; +#ifdef SND_LITTLE_ENDIAN + endian = snd_pcm_format_big_endian(src_format); +#else + endian = snd_pcm_format_little_endian(src_format); +#endif + if (endian < 0) + endian = 0; + return width * 4 + endian * 2 + sign; +} + +int put_index(int src_format, int dst_format) +{ + int sign, width, endian; + sign = (snd_pcm_format_signed(src_format) != + snd_pcm_format_signed(dst_format)); + width = snd_pcm_format_width(dst_format) / 8 - 1; #ifdef SND_LITTLE_ENDIAN - endian = snd_pcm_format_big_endian(format); + endian = snd_pcm_format_big_endian(dst_format); #else - endian = snd_pcm_format_little_endian(format); + endian = snd_pcm_format_little_endian(dst_format); #endif if (endian < 0) endian = 0; diff --git a/src/pcm/pcm_plugin.h b/src/pcm/pcm_plugin.h index 13ec00af..b0275fd8 100644 --- a/src/pcm/pcm_plugin.h +++ b/src/pcm/pcm_plugin.h @@ -59,7 +59,8 @@ int snd_pcm_plugin_munmap_control(snd_pcm_t *pcm); int snd_pcm_plugin_munmap(snd_pcm_t *pcm); int snd_pcm_plugin_poll_descriptor(snd_pcm_t *pcm); int snd_pcm_plugin_channels_mask(snd_pcm_t *pcm, bitset_t *cmask); -int getput_index(int format); +int get_index(int src_format, int dst_format); +int put_index(int src_format, int dst_format); int conv_index(int src_format, int dst_format); #define SND_PCM_LINEAR_FORMATS (SND_PCM_FMT_S8 | SND_PCM_FMT_U8 | \ diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c index ffe379bb..8893f268 100644 --- a/src/pcm/pcm_rate.c +++ b/src/pcm/pcm_rate.c @@ -67,13 +67,13 @@ static size_t resample_expand(snd_pcm_channel_area_t *src_areas, unsigned int get_threshold, rate_state_t *states) { -#define GET_S16_LABELS -#define PUT_S16_LABELS +#define GET16_LABELS +#define PUT16_LABELS #include "plugin_ops.h" -#undef GET_S16_LABELS -#undef PUT_S16_LABELS - void *get = get_s16_labels[getidx]; - void *put = put_s16_labels[putidx]; +#undef GET16_LABELS +#undef PUT16_LABELS + void *get = get16_labels[getidx]; + void *put = put16_labels[putidx]; unsigned int channel; size_t src_frames1 = 0; size_t dst_frames1 = 0; @@ -112,9 +112,9 @@ static size_t resample_expand(snd_pcm_channel_area_t *src_areas, break; pos -= get_threshold; goto *get; -#define GET_S16_END after_get +#define GET16_END after_get #include "plugin_ops.h" -#undef GET_S16_END +#undef GET16_END after_get: src += src_step; src_frames1++; @@ -124,9 +124,9 @@ static size_t resample_expand(snd_pcm_channel_area_t *src_areas, } else sample = old_sample; goto *put; -#define PUT_S16_END after_put +#define PUT16_END after_put #include "plugin_ops.h" -#undef PUT_S16_END +#undef PUT16_END after_put: dst += dst_step; dst_frames1++; @@ -149,13 +149,13 @@ static size_t resample_shrink(snd_pcm_channel_area_t *src_areas, unsigned int get_increment, rate_state_t *states) { -#define GET_S16_LABELS -#define PUT_S16_LABELS +#define GET16_LABELS +#define PUT16_LABELS #include "plugin_ops.h" -#undef GET_S16_LABELS -#undef PUT_S16_LABELS - void *get = get_s16_labels[getidx]; - void *put = put_s16_labels[putidx]; +#undef GET16_LABELS +#undef PUT16_LABELS + void *get = get16_labels[getidx]; + void *put = put16_labels[putidx]; unsigned int channel; size_t src_frames1 = 0; size_t dst_frames1 = 0; @@ -192,9 +192,9 @@ static size_t resample_shrink(snd_pcm_channel_area_t *src_areas, while (src_frames1 < src_frames) { goto *get; -#define GET_S16_END after_get +#define GET16_END after_get #include "plugin_ops.h" -#undef GET_S16_END +#undef GET16_END after_get: src += src_step; src_frames1++; @@ -206,9 +206,9 @@ static size_t resample_shrink(snd_pcm_channel_area_t *src_areas, sum /= DIV; sample = sum; goto *put; -#define PUT_S16_END after_put +#define PUT16_END after_put #include "plugin_ops.h" -#undef PUT_S16_END +#undef PUT16_END after_put: dst += dst_step; sum = s * pos; @@ -372,8 +372,8 @@ static int snd_pcm_rate_setup(snd_pcm_t *pcm, snd_pcm_setup_t * setup) src_rate = rate->srate; dst_rate = rate->crate; } - rate->get_idx = getput_index(src_format); - rate->put_idx = getput_index(dst_format); + rate->get_idx = get_index(src_format, SND_PCM_SFMT_S16); + rate->put_idx = put_index(SND_PCM_SFMT_S16, dst_format); if (src_rate < dst_rate) { rate->func = resample_expand; /* pitch is get_threshold */ diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c index d704464a..4e841553 100644 --- a/src/pcm/pcm_route.c +++ b/src/pcm/pcm_route.c @@ -161,11 +161,11 @@ static void route1_many(snd_pcm_channel_area_t *src_areas, ttable_dst_t* ttable, route_params_t *params) { -#define GET_U_LABELS -#define PUT_U32_LABELS +#define GET_LABELS +#define PUT32_LABELS #include "plugin_ops.h" -#undef GET_U_LABELS -#undef PUT_U32_LABELS +#undef GET_LABELS +#undef PUT32_LABELS static void *zero_labels[3] = { &&zero_int32, &&zero_int64, #if ROUTE_PLUGIN_FLOAT &&zero_float @@ -206,7 +206,7 @@ static void route1_many(snd_pcm_channel_area_t *src_areas, &&norm_float_24, #endif }; - void *zero, *get, *add, *norm, *put_u32; + void *zero, *get, *add, *norm, *put32; int nsrcs = ttable->nsrcs; char *dst; int dst_step; @@ -239,10 +239,10 @@ static void route1_many(snd_pcm_channel_area_t *src_areas, dst_area->enabled = 1; #endif zero = zero_labels[params->sum_idx]; - get = get_u_labels[params->get_idx]; + get = get_labels[params->get_idx]; add = add_labels[params->sum_idx * 2 + ttable->att]; norm = norm_labels[params->sum_idx * 8 + ttable->att * 4 + 4 - params->src_size]; - put_u32 = put_u32_labels[params->put_idx]; + put32 = put32_labels[params->put_idx]; dst = snd_pcm_channel_area_addr(dst_area, dst_offset); dst_step = snd_pcm_channel_area_step(dst_area); @@ -269,9 +269,9 @@ static void route1_many(snd_pcm_channel_area_t *src_areas, /* Get sample */ goto *get; -#define GET_U_END after_get +#define GET_END after_get #include "plugin_ops.h" -#undef GET_U_END +#undef GET_END after_get: /* Sum */ @@ -376,11 +376,11 @@ static void route1_many(snd_pcm_channel_area_t *src_areas, after_norm: /* Put sample */ - goto *put_u32; -#define PUT_U32_END after_put_u32 + goto *put32; +#define PUT32_END after_put32 #include "plugin_ops.h" -#undef PUT_U32_END - after_put_u32: +#undef PUT32_END + after_put32: dst += dst_step; } @@ -531,8 +531,8 @@ static int snd_pcm_route_setup(snd_pcm_t *pcm, snd_pcm_setup_t * setup) src_format = route->sformat; dst_format = route->cformat; } - route->params.get_idx = getput_index(src_format); - route->params.put_idx = getput_index(dst_format); + route->params.get_idx = get_index(src_format, SND_PCM_SFMT_U16); + route->params.put_idx = put_index(SND_PCM_SFMT_U32, dst_format); route->params.conv_idx = conv_index(src_format, dst_format); route->params.src_size = snd_pcm_format_width(src_format) / 8; route->params.dst_sfmt = dst_format; diff --git a/src/pcm/plugin_ops.h b/src/pcm/plugin_ops.h index ed91a2c1..c9ac07c9 100644 --- a/src/pcm/plugin_ops.h +++ b/src/pcm/plugin_ops.h @@ -280,104 +280,103 @@ conv_1234_123C: as_u32(dst) = as_u32(src) ^ 0x80; goto CONV_END; } #endif -#ifdef GET_S16_LABELS -/* src_wid src_endswap unsigned */ -static void *get_s16_labels[4 * 2 * 2] = { - &&get_s16_xxx1_xx10, /* 8h -> 16h */ - &&get_s16_xxx1_xx90, /* 8h ^> 16h */ - &&get_s16_xxx1_xx10, /* 8s -> 16h */ - &&get_s16_xxx1_xx90, /* 8s ^> 16h */ - &&get_s16_xx12_xx12, /* 16h -> 16h */ - &&get_s16_xx12_xx92, /* 16h ^> 16h */ - &&get_s16_xx12_xx21, /* 16s -> 16h */ - &&get_s16_xx12_xxA1, /* 16s ^> 16h */ - &&get_s16_x123_xx12, /* 24h -> 16h */ - &&get_s16_x123_xx92, /* 24h ^> 16h */ - &&get_s16_123x_xx32, /* 24s -> 16h */ - &&get_s16_123x_xxB2, /* 24s ^> 16h */ - &&get_s16_1234_xx12, /* 32h -> 16h */ - &&get_s16_1234_xx92, /* 32h ^> 16h */ - &&get_s16_1234_xx43, /* 32s -> 16h */ - &&get_s16_1234_xxC3, /* 32s ^> 16h */ +#ifdef GET16_LABELS +/* src_wid src_endswap sign_toggle */ +static void *get16_labels[4 * 2 * 2] = { + &&get16_1_10, /* 8h -> 16h */ + &&get16_1_90, /* 8h ^> 16h */ + &&get16_1_10, /* 8s -> 16h */ + &&get16_1_90, /* 8s ^> 16h */ + &&get16_12_12, /* 16h -> 16h */ + &&get16_12_92, /* 16h ^> 16h */ + &&get16_12_21, /* 16s -> 16h */ + &&get16_12_A1, /* 16s ^> 16h */ + &&get16_0123_12, /* 24h -> 16h */ + &&get16_0123_92, /* 24h ^> 16h */ + &&get16_1230_32, /* 24s -> 16h */ + &&get16_1230_B2, /* 24s ^> 16h */ + &&get16_1234_12, /* 32h -> 16h */ + &&get16_1234_92, /* 32h ^> 16h */ + &&get16_1234_43, /* 32s -> 16h */ + &&get16_1234_C3, /* 32s ^> 16h */ }; #endif -#ifdef GET_S16_END +#ifdef GET16_END while(0) { -get_s16_xxx1_xx10: sample = (u_int16_t)as_u8(src) << 8; goto GET_S16_END; -get_s16_xxx1_xx90: sample = (u_int16_t)(as_u8(src) ^ 0x80) << 8; goto GET_S16_END; -get_s16_xx12_xx12: sample = as_u16(src); goto GET_S16_END; -get_s16_xx12_xx92: sample = as_u16(src) ^ 0x8000; goto GET_S16_END; -get_s16_xx12_xx21: sample = bswap_16(as_u16(src)); goto GET_S16_END; -get_s16_xx12_xxA1: sample = bswap_16(as_u16(src) ^ 0x80); goto GET_S16_END; -get_s16_x123_xx12: sample = as_u32(src) >> 8; goto GET_S16_END; -get_s16_x123_xx92: sample = (as_u32(src) >> 8) ^ 0x8000; goto GET_S16_END; -get_s16_123x_xx32: sample = bswap_16(as_u32(src) >> 8); goto GET_S16_END; -get_s16_123x_xxB2: sample = bswap_16((as_u32(src) >> 8) ^ 0x8000); goto GET_S16_END; -get_s16_1234_xx12: sample = as_u32(src) >> 16; goto GET_S16_END; -get_s16_1234_xx92: sample = (as_u32(src) >> 16) ^ 0x8000; goto GET_S16_END; -get_s16_1234_xx43: sample = bswap_16(as_u32(src)); goto GET_S16_END; -get_s16_1234_xxC3: sample = bswap_16(as_u32(src) ^ 0x80); goto GET_S16_END; +get16_1_10: sample = (u_int16_t)as_u8(src) << 8; goto GET16_END; +get16_1_90: sample = (u_int16_t)(as_u8(src) ^ 0x80) << 8; goto GET16_END; +get16_12_12: sample = as_u16(src); goto GET16_END; +get16_12_92: sample = as_u16(src) ^ 0x8000; goto GET16_END; +get16_12_21: sample = bswap_16(as_u16(src)); goto GET16_END; +get16_12_A1: sample = bswap_16(as_u16(src) ^ 0x80); goto GET16_END; +get16_0123_12: sample = as_u32(src) >> 8; goto GET16_END; +get16_0123_92: sample = (as_u32(src) >> 8) ^ 0x8000; goto GET16_END; +get16_1230_32: sample = bswap_16(as_u32(src) >> 8); goto GET16_END; +get16_1230_B2: sample = bswap_16((as_u32(src) >> 8) ^ 0x8000); goto GET16_END; +get16_1234_12: sample = as_u32(src) >> 16; goto GET16_END; +get16_1234_92: sample = (as_u32(src) >> 16) ^ 0x8000; goto GET16_END; +get16_1234_43: sample = bswap_16(as_u32(src)); goto GET16_END; +get16_1234_C3: sample = bswap_16(as_u32(src) ^ 0x80); goto GET16_END; } #endif -#ifdef PUT_S16_LABELS -/* dst_wid dst_endswap unsigned */ -static void *put_s16_labels[4 * 2 * 2 * 4 * 2] = { - &&put_s16_xx12_xxx1, /* 16h -> 8h */ - &&put_s16_xx12_xxx9, /* 16h ^> 8h */ - &&put_s16_xx12_xxx1, /* 16h -> 8s */ - &&put_s16_xx12_xxx9, /* 16h ^> 8s */ - &&put_s16_xx12_xx12, /* 16h -> 16h */ - &&put_s16_xx12_xx92, /* 16h ^> 16h */ - &&put_s16_xx12_xx21, /* 16h -> 16s */ - &&put_s16_xx12_xx29, /* 16h ^> 16s */ - &&put_s16_xx12_x120, /* 16h -> 24h */ - &&put_s16_xx12_x920, /* 16h ^> 24h */ - &&put_s16_xx12_021x, /* 16h -> 24s */ - &&put_s16_xx12_029x, /* 16h ^> 24s */ - &&put_s16_xx12_1200, /* 16h -> 32h */ - &&put_s16_xx12_9200, /* 16h ^> 32h */ - &&put_s16_xx12_0021, /* 16h -> 32s */ - &&put_s16_xx12_0029, /* 16h ^> 32s */ +#ifdef PUT16_LABELS +/* dst_wid dst_endswap sign_toggle */ +static void *put16_labels[4 * 2 * 2 * 4 * 2] = { + &&put16_12_1, /* 16h -> 8h */ + &&put16_12_9, /* 16h ^> 8h */ + &&put16_12_1, /* 16h -> 8s */ + &&put16_12_9, /* 16h ^> 8s */ + &&put16_12_12, /* 16h -> 16h */ + &&put16_12_92, /* 16h ^> 16h */ + &&put16_12_21, /* 16h -> 16s */ + &&put16_12_29, /* 16h ^> 16s */ + &&put16_12_0120, /* 16h -> 24h */ + &&put16_12_0920, /* 16h ^> 24h */ + &&put16_12_0210, /* 16h -> 24s */ + &&put16_12_0290, /* 16h ^> 24s */ + &&put16_12_1200, /* 16h -> 32h */ + &&put16_12_9200, /* 16h ^> 32h */ + &&put16_12_0021, /* 16h -> 32s */ + &&put16_12_0029, /* 16h ^> 32s */ }; #endif -#ifdef PUT_S16_END +#ifdef PUT16_END while (0) { -put_s16_xx12_xxx1: as_u8(dst) = sample >> 8; goto PUT_S16_END; -put_s16_xx12_xxx9: as_u8(dst) = (sample >> 8) ^ 0x80; goto PUT_S16_END; -put_s16_xx12_xx12: as_u16(dst) = sample; goto PUT_S16_END; -put_s16_xx12_xx92: as_u16(dst) = sample ^ 0x8000; goto PUT_S16_END; -put_s16_xx12_xx21: as_u16(dst) = bswap_16(sample); goto PUT_S16_END; -put_s16_xx12_xx29: as_u16(dst) = bswap_16(sample) ^ 0x80; goto PUT_S16_END; -put_s16_xx12_x120: as_u32(dst) = (u_int32_t)sample << 8; goto PUT_S16_END; -put_s16_xx12_x920: as_u32(dst) = (u_int32_t)(sample ^ 0x8000) << 8; goto PUT_S16_END; -put_s16_xx12_021x: as_u32(dst) = (u_int32_t)bswap_16(sample) << 8; goto PUT_S16_END; -put_s16_xx12_029x: as_u32(dst) = (u_int32_t)(bswap_16(sample) ^ 0x80) << 8; goto PUT_S16_END; -put_s16_xx12_1200: as_u32(dst) = (u_int32_t)sample << 16; goto PUT_S16_END; -put_s16_xx12_9200: as_u32(dst) = (u_int32_t)(sample ^ 0x8000) << 16; goto PUT_S16_END; -put_s16_xx12_0021: as_u32(dst) = (u_int32_t)bswap_16(sample); goto PUT_S16_END; -put_s16_xx12_0029: as_u32(dst) = (u_int32_t)bswap_16(sample) ^ 0x80; goto PUT_S16_END; +put16_12_1: as_u8(dst) = sample >> 8; goto PUT16_END; +put16_12_9: as_u8(dst) = (sample >> 8) ^ 0x80; goto PUT16_END; +put16_12_12: as_u16(dst) = sample; goto PUT16_END; +put16_12_92: as_u16(dst) = sample ^ 0x8000; goto PUT16_END; +put16_12_21: as_u16(dst) = bswap_16(sample); goto PUT16_END; +put16_12_29: as_u16(dst) = bswap_16(sample) ^ 0x80; goto PUT16_END; +put16_12_0120: as_u32(dst) = (u_int32_t)sample << 8; goto PUT16_END; +put16_12_0920: as_u32(dst) = (u_int32_t)(sample ^ 0x8000) << 8; goto PUT16_END; +put16_12_0210: as_u32(dst) = (u_int32_t)bswap_16(sample) << 8; goto PUT16_END; +put16_12_0290: as_u32(dst) = (u_int32_t)(bswap_16(sample) ^ 0x80) << 8; goto PUT16_END; +put16_12_1200: as_u32(dst) = (u_int32_t)sample << 16; goto PUT16_END; +put16_12_9200: as_u32(dst) = (u_int32_t)(sample ^ 0x8000) << 16; goto PUT16_END; +put16_12_0021: as_u32(dst) = (u_int32_t)bswap_16(sample); goto PUT16_END; +put16_12_0029: as_u32(dst) = (u_int32_t)bswap_16(sample) ^ 0x80; goto PUT16_END; } #endif -#if 0 #ifdef GET32_LABELS -/* src_wid src_endswap unsigned */ +/* src_wid src_endswap sign_toggle */ static void *get32_labels[4 * 2 * 2] = { - &&get32_xxx1_1000, /* 8h -> 32h */ - &&get32_xxx1_9000, /* 8h ^> 32h */ - &&get32_xxx1_1000, /* 8s -> 32h */ - &&get32_xxx1_9000, /* 8s ^> 32h */ - &&get32_xx12_1200, /* 16h -> 32h */ - &&get32_xx12_9200, /* 16h ^> 32h */ - &&get32_xx12_2100, /* 16s -> 32h */ - &&get32_xx12_A100, /* 16s ^> 32h */ - &&get32_x123_1230, /* 24h -> 32h */ - &&get32_x123_9230, /* 24h ^> 32h */ - &&get32_123x_3210, /* 24s -> 32h */ - &&get32_123x_B210, /* 24s ^> 32h */ + &&get32_1_1000, /* 8h -> 32h */ + &&get32_1_9000, /* 8h ^> 32h */ + &&get32_1_1000, /* 8s -> 32h */ + &&get32_1_9000, /* 8s ^> 32h */ + &&get32_12_1200, /* 16h -> 32h */ + &&get32_12_9200, /* 16h ^> 32h */ + &&get32_12_2100, /* 16s -> 32h */ + &&get32_12_A100, /* 16s ^> 32h */ + &&get32_0123_1230, /* 24h -> 32h */ + &&get32_0123_9230, /* 24h ^> 32h */ + &&get32_1230_3210, /* 24s -> 32h */ + &&get32_1230_B210, /* 24s ^> 32h */ &&get32_1234_1234, /* 32h -> 32h */ &&get32_1234_9234, /* 32h ^> 32h */ &&get32_1234_4321, /* 32s -> 32h */ @@ -387,145 +386,142 @@ static void *get32_labels[4 * 2 * 2] = { #ifdef GET32_END while (0) { -get32_xxx1_1000: sample = (u_int32_t)as_u8(src) << 24; goto GET32_END; -get32_xxx1_9000: sample = (u_int32_t)(as_u8(src) ^ 0x80) << 24; goto GET32_END; -get32_xx12_1200: sample = (u_int32_t)as_u16(src) << 16; goto GET32_END; -get32_xx12_9200: sample = (u_int32_t)(as_u16(src) ^ 0x8000) << 16; goto GET32_END; -get32_xx12_2100: sample = (u_int32_t)bswap_16(as_u16(src)) << 16; goto GET32_END; -get32_xx12_A100: sample = (u_int32_t)bswap_16(as_u16(src) ^ 0x80) << 16; goto GET32_END; -get32_x123_1230: sample = as_u32(src) << 8; goto GET32_END; -get32_x123_9230: sample = (as_u32(src) << 8) ^ 0x80000000; goto GET32_END; -get32_123x_3210: sample = bswap_32(as_u32(src) >> 8); goto GET32_END; -get32_123x_B210: sample = bswap_32((as_u32(src) >> 8) ^ 0x80); goto GET32_END; +get32_1_1000: sample = (u_int32_t)as_u8(src) << 24; goto GET32_END; +get32_1_9000: sample = (u_int32_t)(as_u8(src) ^ 0x80) << 24; goto GET32_END; +get32_12_1200: sample = (u_int32_t)as_u16(src) << 16; goto GET32_END; +get32_12_9200: sample = (u_int32_t)(as_u16(src) ^ 0x8000) << 16; goto GET32_END; +get32_12_2100: sample = (u_int32_t)bswap_16(as_u16(src)) << 16; goto GET32_END; +get32_12_A100: sample = (u_int32_t)bswap_16(as_u16(src) ^ 0x80) << 16; goto GET32_END; +get32_0123_1230: sample = as_u32(src) << 8; goto GET32_END; +get32_0123_9230: sample = (as_u32(src) << 8) ^ 0x80000000; goto GET32_END; +get32_1230_3210: sample = bswap_32(as_u32(src) >> 8); goto GET32_END; +get32_1230_B210: sample = bswap_32((as_u32(src) >> 8) ^ 0x80); goto GET32_END; get32_1234_1234: sample = as_u32(src); goto GET32_END; get32_1234_9234: sample = as_u32(src) ^ 0x80000000; goto GET32_END; 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; } #endif -#endif -#ifdef PUT_U32_LABELS -/* dst_wid dst_endswap unsigned */ -static void *put_u32_labels[4 * 2 * 2] = { - &&put_u32_1234_xxx9, /* u32h -> s8h */ - &&put_u32_1234_xxx1, /* u32h -> u8h */ - &&put_u32_1234_xxx9, /* u32h -> s8s */ - &&put_u32_1234_xxx1, /* u32h -> u8s */ - &&put_u32_1234_xx92, /* u32h -> s16h */ - &&put_u32_1234_xx12, /* u32h -> u16h */ - &&put_u32_1234_xx29, /* u32h -> s16s */ - &&put_u32_1234_xx21, /* u32h -> u16s */ - &&put_u32_1234_x923, /* u32h -> s24h */ - &&put_u32_1234_x123, /* u32h -> u24h */ - &&put_u32_1234_329x, /* u32h -> s24s */ - &&put_u32_1234_321x, /* u32h -> u24s */ - &&put_u32_1234_9234, /* u32h -> s32h */ - &&put_u32_1234_1234, /* u32h -> u32h */ - &&put_u32_1234_4329, /* u32h -> s32s */ - &&put_u32_1234_4321, /* u32h -> u32s */ +#ifdef PUT32_LABELS +/* dst_wid dst_endswap sign_toggle */ +static void *put32_labels[4 * 2 * 2] = { + &&put32_1234_1, /* 32h -> 8h */ + &&put32_1234_9, /* 32h ^> 8h */ + &&put32_1234_1, /* 32h -> 8s */ + &&put32_1234_9, /* 32h ^> 8s */ + &&put32_1234_12, /* 32h -> 16h */ + &&put32_1234_92, /* 32h ^> 16h */ + &&put32_1234_21, /* 32h -> 16s */ + &&put32_1234_29, /* 32h ^> 16s */ + &&put32_1234_0123, /* 32h -> 24h */ + &&put32_1234_0923, /* 32h ^> 24h */ + &&put32_1234_3210, /* 32h -> 24s */ + &&put32_1234_3290, /* 32h ^> 24s */ + &&put32_1234_1234, /* 32h -> 32h */ + &&put32_1234_9234, /* 32h ^> 32h */ + &&put32_1234_4321, /* 32h -> 32s */ + &&put32_1234_4329, /* 32h ^> 32s */ }; #endif -#ifdef PUT_U32_END +#ifdef PUT32_END while (0) { -put_u32_1234_xxx1: as_u8(dst) = sample >> 24; goto PUT_U32_END; -put_u32_1234_xxx9: as_u8(dst) = (sample >> 24) ^ 0x80; goto PUT_U32_END; -put_u32_1234_xx12: as_u16(dst) = sample >> 16; goto PUT_U32_END; -put_u32_1234_xx92: as_u16(dst) = (sample >> 16) ^ 0x8000; goto PUT_U32_END; -put_u32_1234_xx21: as_u16(dst) = bswap_16(sample >> 16); goto PUT_U32_END; -put_u32_1234_xx29: as_u16(dst) = bswap_16(sample >> 16) ^ 0x80; goto PUT_U32_END; -put_u32_1234_x123: as_u32(dst) = sample >> 8; goto PUT_U32_END; -put_u32_1234_x923: as_u32(dst) = (sample >> 8) ^ 0x800000; goto PUT_U32_END; -put_u32_1234_321x: as_u32(dst) = bswap_32(sample) << 8; goto PUT_U32_END; -put_u32_1234_329x: as_u32(dst) = (bswap_32(sample) ^ 0x80) << 8; goto PUT_U32_END; -put_u32_1234_1234: as_u32(dst) = sample; goto PUT_U32_END; -put_u32_1234_9234: as_u32(dst) = sample ^ 0x80000000; goto PUT_U32_END; -put_u32_1234_4321: as_u32(dst) = bswap_32(sample); goto PUT_U32_END; -put_u32_1234_4329: as_u32(dst) = bswap_32(sample) ^ 0x80; goto PUT_U32_END; +put32_1234_1: as_u8(dst) = sample >> 24; goto PUT32_END; +put32_1234_9: as_u8(dst) = (sample >> 24) ^ 0x80; goto PUT32_END; +put32_1234_12: as_u16(dst) = sample >> 16; goto PUT32_END; +put32_1234_92: as_u16(dst) = (sample >> 16) ^ 0x8000; goto PUT32_END; +put32_1234_21: as_u16(dst) = bswap_16(sample >> 16); goto PUT32_END; +put32_1234_29: as_u16(dst) = bswap_16(sample >> 16) ^ 0x80; goto PUT32_END; +put32_1234_0123: as_u32(dst) = sample >> 8; goto PUT32_END; +put32_1234_0923: as_u32(dst) = (sample >> 8) ^ 0x800000; goto PUT32_END; +put32_1234_3210: as_u32(dst) = bswap_32(sample) << 8; goto PUT32_END; +put32_1234_3290: as_u32(dst) = (bswap_32(sample) ^ 0x80) << 8; goto PUT32_END; +put32_1234_1234: as_u32(dst) = sample; goto PUT32_END; +put32_1234_9234: as_u32(dst) = sample ^ 0x80000000; goto PUT32_END; +put32_1234_4321: as_u32(dst) = bswap_32(sample); goto PUT32_END; +put32_1234_4329: as_u32(dst) = bswap_32(sample) ^ 0x80; goto PUT32_END; } #endif -#ifdef GET_U_LABELS -/* width endswap unsigned*/ -static void *get_u_labels[4 * 2 * 2] = { - &&get_u_s8, /* s8 -> u8 */ - &&get_u_u8, /* u8 -> u8 */ - &&get_u_s8, /* s8 -> u8 */ - &&get_u_u8, /* u8 -> u8 */ - &&get_u_s16h, /* s16h -> u16h */ - &&get_u_u16h, /* u16h -> u16h */ - &&get_u_s16s, /* s16s -> u16h */ - &&get_u_u16s, /* u16s -> u16h */ - &&get_u_s24h, /* s24h -> u32h */ - &&get_u_u24h, /* u24h -> u32h */ - &&get_u_s24s, /* s24s -> u32h */ - &&get_u_u24s, /* u24s -> u32h */ - &&get_u_s32h, /* s32h -> u32h */ - &&get_u_u32h, /* u32h -> u32h */ - &&get_u_s32s, /* s32s -> u32h */ - &&get_u_u32s, /* u32s -> u32h */ +#ifdef GET_LABELS +/* width endswap sign_toggle */ +static void *get_labels[4 * 2 * 2] = { + &&get_1_1, /* 8h -> 8h */ + &&get_1_9, /* 8h ^> 8h */ + &&get_1_1, /* 8s -> 8h */ + &&get_1_9, /* 8s ^> 8h */ + &&get_12_12, /* 16h -> 16h */ + &&get_12_92, /* 16h ^> 16h */ + &&get_12_21, /* 16s -> 16h */ + &&get_12_A1, /* 16s ^> 16h */ + &&get_0123_0123, /* 24h -> 24h */ + &&get_0123_0923, /* 24h ^> 24h */ + &&get_1230_0321, /* 24s -> 24h */ + &&get_1230_0B21, /* 24s ^> 24h */ + &&get_1234_1234, /* 32h -> 32h */ + &&get_1234_9234, /* 32h ^> 32h */ + &&get_1234_4321, /* 32s -> 32h */ + &&get_1234_C321, /* 32s ^> 32h */ }; #endif -#ifdef GET_U_END +#ifdef GET_END while (0) { -get_u_s8: sample = as_u8(src) ^ 0x80; goto GET_U_END; -get_u_u8: sample = as_u8(src); goto GET_U_END; -get_u_s16h: sample = as_u16(src) ^ 0x8000; goto GET_U_END; -get_u_u16h: sample = as_u16(src); goto GET_U_END; -get_u_s16s: sample = bswap_16(as_u16(src) ^ 0x80); goto GET_U_END; -get_u_u16s: sample = bswap_16(as_u16(src)); goto GET_U_END; -get_u_s24h: sample = (as_u32(src) ^ 0x800000); goto GET_U_END; -get_u_u24h: sample = as_u32(src); goto GET_U_END; -get_u_s24s: sample = bswap_32(as_u32(src) ^ 0x800000); goto GET_U_END; -get_u_u24s: sample = bswap_32(as_u32(src)); goto GET_U_END; -get_u_s32h: sample = as_u32(src) ^ 0x80000000; goto GET_U_END; -get_u_u32h: sample = as_u32(src); goto GET_U_END; -get_u_s32s: sample = bswap_32(as_u32(src) ^ 0x80); goto GET_U_END; -get_u_u32s: sample = bswap_32(as_u32(src)); goto GET_U_END; +get_1_1: sample = as_u8(src); goto GET_END; +get_1_9: sample = as_u8(src) ^ 0x80; goto GET_END; +get_12_12: sample = as_u16(src); goto GET_END; +get_12_92: sample = as_u16(src) ^ 0x8000; goto GET_END; +get_12_21: sample = bswap_16(as_u16(src)); goto GET_END; +get_12_A1: sample = bswap_16(as_u16(src) ^ 0x80); goto GET_END; +get_0123_0123: sample = as_u32(src); goto GET_END; +get_0123_0923: sample = (as_u32(src) ^ 0x800000); goto GET_END; +get_1230_0321: sample = bswap_32(as_u32(src)); goto GET_END; +get_1230_0B21: sample = bswap_32(as_u32(src) ^ 0x8000); goto GET_END; +get_1234_1234: sample = as_u32(src); goto GET_END; +get_1234_9234: sample = as_u32(src) ^ 0x80000000; goto GET_END; +get_1234_4321: sample = bswap_32(as_u32(src)); goto GET_END; +get_1234_C321: sample = bswap_32(as_u32(src) ^ 0x80); goto GET_END; } #endif -#if 0 #ifdef PUT_LABELS -/* width endswap unsigned */ +/* width endswap sign_toggle */ static void *put_labels[4 * 2 * 2] = { - &&put_s8, /* s8 -> s8 */ - &&put_u8, /* u8 -> s8 */ - &&put_s8, /* s8 -> s8 */ - &&put_u8, /* u8 -> s8 */ - &&put_s16h, /* s16h -> s16h */ - &&put_u16h, /* u16h -> s16h */ - &&put_s16s, /* s16s -> s16h */ - &&put_u16s, /* u16s -> s16h */ - &&put_s24h, /* s24h -> s32h */ - &&put_u24h, /* u24h -> s32h */ - &&put_s24s, /* s24s -> s32h */ - &&put_u24s, /* u24s -> s32h */ - &&put_s32h, /* s32h -> s32h */ - &&put_u32h, /* u32h -> s32h */ - &&put_s32s, /* s32s -> s32h */ - &&put_u32s, /* u32s -> s32h */ + &&put_1_1, /* 8h -> 8h */ + &&put_1_9, /* 8h ^> 8h */ + &&put_1_1, /* 8h -> 8s */ + &&put_1_9, /* 8h ^> 8s */ + &&put_12_12, /* 16h -> 16h */ + &&put_12_92, /* 16h ^> 16h */ + &&put_12_21, /* 16h -> 16s */ + &&put_12_A1, /* 16h ^> 16s */ + &&put_0123_0123, /* 24h -> 24h */ + &&put_0123_0923, /* 24h ^> 24h */ + &&put_0123_3210, /* 24h -> 24s */ + &&put_0123_3290, /* 24h ^> 24s */ + &&put_1234_1234, /* 32h -> 32h */ + &&put_1234_9234, /* 32h ^> 32h */ + &&put_1234_4321, /* 32h -> 32s */ + &&put_1234_4329, /* 32h ^> 32s */ }; #endif #ifdef PUT_END -put_s8: as_s8(dst) = sample; goto PUT_END; -put_u8: as_u8(dst) = sample ^ 0x80; goto PUT_END; -put_s16h: as_s16(dst) = sample; goto PUT_END; -put_u16h: as_u16(dst) = sample ^ 0x8000; goto PUT_END; -put_s16s: as_s16(dst) = bswap_16(sample); goto PUT_END; -put_u16s: as_u16(dst) = bswap_16(sample ^ 0x80); goto PUT_END; -put_s24h: as_s24(dst) = sample & 0xffffff; goto PUT_END; -put_u24h: as_u24(dst) = sample ^ 0x80000000; goto PUT_END; -put_s24s: as_s24(dst) = bswap_32(sample & 0xffffff); goto PUT_END; -put_u24s: as_u24(dst) = bswap_32(sample ^ 0x80); goto PUT_END; -put_s32h: as_s32(dst) = sample; goto PUT_END; -put_u32h: as_u32(dst) = sample ^ 0x80000000; 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; -#endif +put_1_1: as_s8(dst) = sample; goto PUT_END; +put_1_9: as_u8(dst) = sample ^ 0x80; goto PUT_END; +put_12_12: as_s16(dst) = sample; goto PUT_END; +put_12_92: as_u16(dst) = sample ^ 0x8000; goto PUT_END; +put_12_21: as_s16(dst) = bswap_16(sample); goto PUT_END; +put_12_A1: as_u16(dst) = bswap_16(sample ^ 0x80); goto PUT_END; +put_0123_0123: as_s24(dst) = sample; goto PUT_END; +put_0123_0923: as_u24(dst) = sample ^ 0x800000; goto PUT_END; +put_0123_3210: as_s24(dst) = bswap_32(sample); goto PUT_END; +put_0123_3290: as_u24(dst) = bswap_32(sample) ^ 0x8000; goto PUT_END; +put_1234_1234: as_s32(dst) = sample; goto PUT_END; +put_1234_9234: as_u32(dst) = sample ^ 0x80000000; goto PUT_END; +put_1234_4321: as_s32(dst) = bswap_32(sample); goto PUT_END; +put_1234_4329: as_u32(dst) = bswap_32(sample) ^ 0x80; goto PUT_END; #endif #undef as_u8 -- 2.47.1