Files
oasis-linux-mirror/pkg/alsa-lib/patch/0004-Use-switch-statements-instead-of-labels-as-values.patch
Michael Forney a2c390b417 alsa-lib: Minor tweaks to switch patch
Use local variable for get/put index.

Remove unused variables.

Add assert(0) to unreachable default case in switch.
2024-03-17 00:27:08 -07:00

1714 lines
71 KiB
Diff

From 33cc8c8e77a2282c11601a8a1e14fb2e856af0dc Mon Sep 17 00:00:00 2001
From: Michael Forney <mforney@mforney.org>
Date: Fri, 31 May 2019 17:47:08 -0700
Subject: [PATCH] Use switch statements instead of labels as values
---
src/pcm/pcm_adpcm.c | 20 +-
src/pcm/pcm_alaw.c | 20 +-
src/pcm/pcm_iec958.c | 22 +-
src/pcm/pcm_lfloat.c | 42 +-
src/pcm/pcm_linear.c | 22 +-
src/pcm/pcm_mulaw.c | 20 +-
src/pcm/pcm_rate_linear.c | 42 +-
src/pcm/pcm_route.c | 163 +++----
src/pcm/plugin_ops.h | 937 ++++++++++++++------------------------
9 files changed, 412 insertions(+), 876 deletions(-)
diff --git a/src/pcm/pcm_adpcm.c b/src/pcm/pcm_adpcm.c
index fd9b9e8e..d4546cd0 100644
--- a/src/pcm/pcm_adpcm.c
+++ b/src/pcm/pcm_adpcm.c
@@ -220,10 +220,6 @@ void snd_pcm_adpcm_decode(const snd_pcm_channel_area_t *dst_areas,
unsigned int putidx,
snd_pcm_adpcm_state_t *states)
{
-#define PUT16_LABELS
-#include "plugin_ops.h"
-#undef PUT16_LABELS
- void *put = put16_labels[putidx];
unsigned int channel;
for (channel = 0; channel < channels; ++channel, ++states) {
const char *src;
@@ -249,11 +245,7 @@ void snd_pcm_adpcm_decode(const snd_pcm_channel_area_t *dst_areas,
else
v = (*src >> 4) & 0x0f;
sample = adpcm_decoder(v, states);
- goto *put;
-#define PUT16_END after
-#include "plugin_ops.h"
-#undef PUT16_END
- after:
+ put16(dst, sample, putidx);
src += src_step;
srcbit += srcbit_step;
if (srcbit == 8) {
@@ -273,10 +265,6 @@ void snd_pcm_adpcm_encode(const snd_pcm_channel_area_t *dst_areas,
unsigned int getidx,
snd_pcm_adpcm_state_t *states)
{
-#define GET16_LABELS
-#include "plugin_ops.h"
-#undef GET16_LABELS
- void *get = get16_labels[getidx];
unsigned int channel;
int16_t sample = 0;
for (channel = 0; channel < channels; ++channel, ++states) {
@@ -297,11 +285,7 @@ void snd_pcm_adpcm_encode(const snd_pcm_channel_area_t *dst_areas,
frames1 = frames;
while (frames1-- > 0) {
int v;
- goto *get;
-#define GET16_END after
-#include "plugin_ops.h"
-#undef GET16_END
- after:
+ sample = get16(src, getidx);
v = adpcm_encoder(sample, states);
if (dstbit)
*dst = (*dst & 0xf0) | v;
diff --git a/src/pcm/pcm_alaw.c b/src/pcm/pcm_alaw.c
index 0a889183..f24e6351 100644
--- a/src/pcm/pcm_alaw.c
+++ b/src/pcm/pcm_alaw.c
@@ -148,10 +148,6 @@ void snd_pcm_alaw_decode(const snd_pcm_channel_area_t *dst_areas,
unsigned int channels, snd_pcm_uframes_t frames,
unsigned int putidx)
{
-#define PUT16_LABELS
-#include "plugin_ops.h"
-#undef PUT16_LABELS
- void *put = put16_labels[putidx];
unsigned int channel;
for (channel = 0; channel < channels; ++channel) {
const unsigned char *src;
@@ -167,11 +163,7 @@ void snd_pcm_alaw_decode(const snd_pcm_channel_area_t *dst_areas,
frames1 = frames;
while (frames1-- > 0) {
int16_t sample = alaw_to_s16(*src);
- goto *put;
-#define PUT16_END after
-#include "plugin_ops.h"
-#undef PUT16_END
- after:
+ put16(dst, sample, putidx);
src += src_step;
dst += dst_step;
}
@@ -185,10 +177,6 @@ void snd_pcm_alaw_encode(const snd_pcm_channel_area_t *dst_areas,
unsigned int channels, snd_pcm_uframes_t frames,
unsigned int getidx)
{
-#define GET16_LABELS
-#include "plugin_ops.h"
-#undef GET16_LABELS
- void *get = get16_labels[getidx];
unsigned int channel;
int16_t sample = 0;
for (channel = 0; channel < channels; ++channel) {
@@ -204,11 +192,7 @@ void snd_pcm_alaw_encode(const snd_pcm_channel_area_t *dst_areas,
dst_step = snd_pcm_channel_area_step(dst_area);
frames1 = frames;
while (frames1-- > 0) {
- goto *get;
-#define GET16_END after
-#include "plugin_ops.h"
-#undef GET16_END
- after:
+ sample = get16(src, getidx);
*dst = s16_to_alaw(sample);
src += src_step;
dst += dst_step;
diff --git a/src/pcm/pcm_iec958.c b/src/pcm/pcm_iec958.c
index 1afe7393..8f1cd9e9 100644
--- a/src/pcm/pcm_iec958.c
+++ b/src/pcm/pcm_iec958.c
@@ -149,11 +149,8 @@ static void snd_pcm_iec958_decode(snd_pcm_iec958_t *iec,
snd_pcm_uframes_t src_offset,
unsigned int channels, snd_pcm_uframes_t frames)
{
-#define PUT32_LABELS
-#include "plugin_ops.h"
-#undef PUT32_LABELS
- void *put = put32_labels[iec->getput_idx];
unsigned int channel;
+ unsigned int idx = iec->getput_idx;
for (channel = 0; channel < channels; ++channel) {
const uint32_t *src;
char *dst;
@@ -168,11 +165,7 @@ static void snd_pcm_iec958_decode(snd_pcm_iec958_t *iec,
frames1 = frames;
while (frames1-- > 0) {
int32_t sample = iec958_to_s32(iec, *src);
- goto *put;
-#define PUT32_END after
-#include "plugin_ops.h"
-#undef PUT32_END
- after:
+ put32(dst, sample, idx);
src += src_step;
dst += dst_step;
}
@@ -186,10 +179,6 @@ static void snd_pcm_iec958_encode(snd_pcm_iec958_t *iec,
snd_pcm_uframes_t src_offset,
unsigned int channels, snd_pcm_uframes_t frames)
{
-#define GET32_LABELS
-#include "plugin_ops.h"
-#undef GET32_LABELS
- void *get = get32_labels[iec->getput_idx];
unsigned int channel;
int32_t sample = 0;
int counter = iec->counter;
@@ -197,6 +186,7 @@ static void snd_pcm_iec958_encode(snd_pcm_iec958_t *iec,
(iec->status[0] & IEC958_AES0_NONAUDIO) &&
(channels == 8);
int counter_step = single_stream ? ((channels + 1) >> 1) : 1;
+ unsigned int idx = iec->getput_idx;
for (channel = 0; channel < channels; ++channel) {
const char *src;
uint32_t *dst;
@@ -216,11 +206,7 @@ static void snd_pcm_iec958_encode(snd_pcm_iec958_t *iec,
iec->counter = counter;
while (frames1-- > 0) {
- goto *get;
-#define GET32_END after
-#include "plugin_ops.h"
-#undef GET32_END
- after:
+ sample = get32(src, idx);
sample = iec958_subframe(iec, sample, channel);
// fprintf(stderr, "%d:%08x\n", frames1, sample);
*dst = sample;
diff --git a/src/pcm/pcm_lfloat.c b/src/pcm/pcm_lfloat.c
index 7785e4b9..c2e07a57 100644
--- a/src/pcm/pcm_lfloat.c
+++ b/src/pcm/pcm_lfloat.c
@@ -97,13 +97,6 @@ void snd_pcm_lfloat_convert_integer_float(const snd_pcm_channel_area_t *dst_area
unsigned int channels, snd_pcm_uframes_t frames,
unsigned int get32idx, unsigned int put32floatidx)
{
-#define GET32_LABELS
-#define PUT32F_LABELS
-#include "plugin_ops.h"
-#undef PUT32F_LABELS
-#undef GET32_LABELS
- void *get32 = get32_labels[get32idx];
- void *put32float = put32float_labels[put32floatidx];
unsigned int channel;
for (channel = 0; channel < channels; ++channel) {
const char *src;
@@ -111,8 +104,6 @@ void snd_pcm_lfloat_convert_integer_float(const snd_pcm_channel_area_t *dst_area
int src_step, dst_step;
snd_pcm_uframes_t frames1;
int32_t sample = 0;
- snd_tmp_float_t tmp_float;
- snd_tmp_double_t tmp_double;
const snd_pcm_channel_area_t *src_area = &src_areas[channel];
const snd_pcm_channel_area_t *dst_area = &dst_areas[channel];
src = snd_pcm_channel_area_addr(src_area, src_offset);
@@ -121,16 +112,8 @@ void snd_pcm_lfloat_convert_integer_float(const snd_pcm_channel_area_t *dst_area
dst_step = snd_pcm_channel_area_step(dst_area);
frames1 = frames;
while (frames1-- > 0) {
- goto *get32;
-#define GET32_END sample_loaded
-#include "plugin_ops.h"
-#undef GET32_END
- sample_loaded:
- goto *put32float;
-#define PUT32F_END sample_put
-#include "plugin_ops.h"
-#undef PUT32F_END
- sample_put:
+ sample = get32(src, get32idx);
+ put32float(dst, sample, put32floatidx);
src += src_step;
dst += dst_step;
}
@@ -142,13 +125,6 @@ void snd_pcm_lfloat_convert_float_integer(const snd_pcm_channel_area_t *dst_area
unsigned int channels, snd_pcm_uframes_t frames,
unsigned int put32idx, unsigned int get32floatidx)
{
-#define PUT32_LABELS
-#define GET32F_LABELS
-#include "plugin_ops.h"
-#undef GET32F_LABELS
-#undef PUT32_LABELS
- void *put32 = put32_labels[put32idx];
- void *get32float = get32float_labels[get32floatidx];
unsigned int channel;
for (channel = 0; channel < channels; ++channel) {
const char *src;
@@ -156,8 +132,6 @@ void snd_pcm_lfloat_convert_float_integer(const snd_pcm_channel_area_t *dst_area
int src_step, dst_step;
snd_pcm_uframes_t frames1;
int32_t sample = 0;
- snd_tmp_float_t tmp_float;
- snd_tmp_double_t tmp_double;
const snd_pcm_channel_area_t *src_area = &src_areas[channel];
const snd_pcm_channel_area_t *dst_area = &dst_areas[channel];
src = snd_pcm_channel_area_addr(src_area, src_offset);
@@ -166,16 +140,8 @@ void snd_pcm_lfloat_convert_float_integer(const snd_pcm_channel_area_t *dst_area
dst_step = snd_pcm_channel_area_step(dst_area);
frames1 = frames;
while (frames1-- > 0) {
- goto *get32float;
-#define GET32F_END sample_loaded
-#include "plugin_ops.h"
-#undef GET32F_END
- sample_loaded:
- goto *put32;
-#define PUT32_END sample_put
-#include "plugin_ops.h"
-#undef PUT32_END
- sample_put:
+ sample = get32float(src, get32floatidx);
+ put32(dst, sample, put32idx);
src += src_step;
dst += dst_step;
}
diff --git a/src/pcm/pcm_linear.c b/src/pcm/pcm_linear.c
index c95d1b95..bc8c7aa8 100644
--- a/src/pcm/pcm_linear.c
+++ b/src/pcm/pcm_linear.c
@@ -148,10 +148,6 @@ void snd_pcm_linear_convert(const snd_pcm_channel_area_t *dst_areas, snd_pcm_ufr
unsigned int channels, snd_pcm_uframes_t frames,
unsigned int convidx)
{
-#define CONV_LABELS
-#include "plugin_ops.h"
-#undef CONV_LABELS
- void *conv = conv_labels[convidx];
unsigned int channel;
for (channel = 0; channel < channels; ++channel) {
const char *src;
@@ -166,11 +162,7 @@ void snd_pcm_linear_convert(const snd_pcm_channel_area_t *dst_areas, snd_pcm_ufr
dst_step = snd_pcm_channel_area_step(dst_area);
frames1 = frames;
while (frames1-- > 0) {
- goto *conv;
-#define CONV_END after
-#include "plugin_ops.h"
-#undef CONV_END
- after:
+ conv(dst, src, convidx);
src += src_step;
dst += dst_step;
}
@@ -182,11 +174,6 @@ void snd_pcm_linear_getput(const snd_pcm_channel_area_t *dst_areas, snd_pcm_ufra
unsigned int channels, snd_pcm_uframes_t frames,
unsigned int get_idx, unsigned int put_idx)
{
-#define CONV24_LABELS
-#include "plugin_ops.h"
-#undef CONV24_LABELS
- void *get = get32_labels[get_idx];
- void *put = put32_labels[put_idx];
unsigned int channel;
uint32_t sample = 0;
for (channel = 0; channel < channels; ++channel) {
@@ -202,11 +189,8 @@ void snd_pcm_linear_getput(const snd_pcm_channel_area_t *dst_areas, snd_pcm_ufra
dst_step = snd_pcm_channel_area_step(dst_area);
frames1 = frames;
while (frames1-- > 0) {
- goto *get;
-#define CONV24_END after
-#include "plugin_ops.h"
-#undef CONV24_END
- after:
+ sample = get32(src, get_idx);
+ put32(dst, sample, put_idx);
src += src_step;
dst += dst_step;
}
diff --git a/src/pcm/pcm_mulaw.c b/src/pcm/pcm_mulaw.c
index 587fa54e..97dae154 100644
--- a/src/pcm/pcm_mulaw.c
+++ b/src/pcm/pcm_mulaw.c
@@ -164,10 +164,6 @@ void snd_pcm_mulaw_decode(const snd_pcm_channel_area_t *dst_areas,
unsigned int channels, snd_pcm_uframes_t frames,
unsigned int putidx)
{
-#define PUT16_LABELS
-#include "plugin_ops.h"
-#undef PUT16_LABELS
- void *put = put16_labels[putidx];
unsigned int channel;
for (channel = 0; channel < channels; ++channel) {
const unsigned char *src;
@@ -183,11 +179,7 @@ void snd_pcm_mulaw_decode(const snd_pcm_channel_area_t *dst_areas,
frames1 = frames;
while (frames1-- > 0) {
int16_t sample = ulaw_to_s16(*src);
- goto *put;
-#define PUT16_END after
-#include "plugin_ops.h"
-#undef PUT16_END
- after:
+ put16(dst, sample, putidx);
src += src_step;
dst += dst_step;
}
@@ -201,10 +193,6 @@ void snd_pcm_mulaw_encode(const snd_pcm_channel_area_t *dst_areas,
unsigned int channels, snd_pcm_uframes_t frames,
unsigned int getidx)
{
-#define GET16_LABELS
-#include "plugin_ops.h"
-#undef GET16_LABELS
- void *get = get16_labels[getidx];
unsigned int channel;
int16_t sample = 0;
for (channel = 0; channel < channels; ++channel) {
@@ -220,11 +208,7 @@ void snd_pcm_mulaw_encode(const snd_pcm_channel_area_t *dst_areas,
dst_step = snd_pcm_channel_area_step(dst_area);
frames1 = frames;
while (frames1-- > 0) {
- goto *get;
-#define GET16_END after
-#include "plugin_ops.h"
-#undef GET16_END
- after:
+ sample = get16(src, getidx);
*dst = s16_to_ulaw(sample);
src += src_step;
dst += dst_step;
diff --git a/src/pcm/pcm_rate_linear.c b/src/pcm/pcm_rate_linear.c
index 35a4d8ea..366fdad7 100644
--- a/src/pcm/pcm_rate_linear.c
+++ b/src/pcm/pcm_rate_linear.c
@@ -70,19 +70,13 @@ static void linear_expand(struct rate_linear *rate,
const snd_pcm_channel_area_t *src_areas,
snd_pcm_uframes_t src_offset, unsigned int src_frames)
{
-#define GET16_LABELS
-#define PUT16_LABELS
-#include "plugin_ops.h"
-#undef GET16_LABELS
-#undef PUT16_LABELS
- void *get = get16_labels[rate->get_idx];
- void *put = put16_labels[rate->put_idx];
unsigned int get_threshold = rate->pitch;
unsigned int channel;
unsigned int src_frames1;
unsigned int dst_frames1;
int16_t sample = 0;
unsigned int pos;
+ unsigned int get_idx = rate->get_idx, put_idx = rate->get_idx;
for (channel = 0; channel < rate->channels; ++channel) {
const snd_pcm_channel_area_t *src_area = &src_areas[channel];
@@ -106,22 +100,14 @@ static void linear_expand(struct rate_linear *rate,
pos -= get_threshold;
old_sample = new_sample;
if (src_frames1 < src_frames) {
- goto *get;
-#define GET16_END after_get
-#include "plugin_ops.h"
-#undef GET16_END
- after_get:
+ sample = get16(src, get_idx);
new_sample = sample;
}
}
new_weight = (pos << (16 - rate->pitch_shift)) / (get_threshold >> rate->pitch_shift);
old_weight = 0x10000 - new_weight;
sample = (old_sample * old_weight + new_sample * new_weight) >> 16;
- goto *put;
-#define PUT16_END after_put
-#include "plugin_ops.h"
-#undef PUT16_END
- after_put:
+ put16(dst, sample, put_idx);
dst += dst_step;
dst_frames1++;
pos += LINEAR_DIV;
@@ -192,19 +178,13 @@ static void linear_shrink(struct rate_linear *rate,
const snd_pcm_channel_area_t *src_areas,
snd_pcm_uframes_t src_offset, unsigned int src_frames)
{
-#define GET16_LABELS
-#define PUT16_LABELS
-#include "plugin_ops.h"
-#undef GET16_LABELS
-#undef PUT16_LABELS
- void *get = get16_labels[rate->get_idx];
- void *put = put16_labels[rate->put_idx];
unsigned int get_increment = rate->pitch;
unsigned int channel;
unsigned int src_frames1;
unsigned int dst_frames1;
int16_t sample = 0;
unsigned int pos;
+ unsigned int get_idx = rate->get_idx, put_idx = rate->get_idx;
for (channel = 0; channel < rate->channels; ++channel) {
const snd_pcm_channel_area_t *src_area = &src_areas[channel];
@@ -223,13 +203,7 @@ static void linear_shrink(struct rate_linear *rate,
src_frames1 = 0;
dst_frames1 = 0;
while (src_frames1 < src_frames) {
-
- goto *get;
-#define GET16_END after_get
-#include "plugin_ops.h"
-#undef GET16_END
- after_get:
- new_sample = sample;
+ new_sample = get16(src, get_idx);
src += src_step;
src_frames1++;
pos += get_increment;
@@ -238,11 +212,7 @@ static void linear_shrink(struct rate_linear *rate,
old_weight = (pos << (32 - LINEAR_DIV_SHIFT)) / (get_increment >> (LINEAR_DIV_SHIFT - 16));
new_weight = 0x10000 - old_weight;
sample = (old_sample * old_weight + new_sample * new_weight) >> 16;
- goto *put;
-#define PUT16_END after_put
-#include "plugin_ops.h"
-#undef PUT16_END
- after_put:
+ put16(dst, sample, put_idx);
dst += dst_step;
dst_frames1++;
if (CHECK_SANITY(dst_frames1 > dst_frames)) {
diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c
index 737c8fa4..f9ba16a1 100644
--- a/src/pcm/pcm_route.c
+++ b/src/pcm/pcm_route.c
@@ -131,10 +131,6 @@ static void snd_pcm_route_convert1_one(const snd_pcm_channel_area_t *dst_area,
const snd_pcm_route_ttable_dst_t* ttable,
const snd_pcm_route_params_t *params)
{
-#define CONV_LABELS
-#include "plugin_ops.h"
-#undef CONV_LABELS
- void *conv;
const snd_pcm_channel_area_t *src_area = 0;
unsigned int srcidx;
const char *src;
@@ -156,17 +152,12 @@ static void snd_pcm_route_convert1_one(const snd_pcm_channel_area_t *dst_area,
return;
}
- conv = conv_labels[params->conv_idx];
src = snd_pcm_channel_area_addr(src_area, src_offset);
dst = snd_pcm_channel_area_addr(dst_area, dst_offset);
src_step = snd_pcm_channel_area_step(src_area);
dst_step = snd_pcm_channel_area_step(dst_area);
while (frames-- > 0) {
- goto *conv;
-#define CONV_END after
-#include "plugin_ops.h"
-#undef CONV_END
- after:
+ conv(dst, src, params->conv_idx);
src += src_step;
dst += dst_step;
}
@@ -181,16 +172,13 @@ static void snd_pcm_route_convert1_one_getput(const snd_pcm_channel_area_t *dst_
const snd_pcm_route_ttable_dst_t* ttable,
const snd_pcm_route_params_t *params)
{
-#define CONV24_LABELS
-#include "plugin_ops.h"
-#undef CONV24_LABELS
- void *get, *put;
const snd_pcm_channel_area_t *src_area = 0;
unsigned int srcidx;
const char *src;
char *dst;
int src_step, dst_step;
uint32_t sample = 0;
+ unsigned int get_idx = params->get_idx, put_idx = params->put_idx;
for (srcidx = 0; srcidx < ttable->nsrcs && srcidx < src_channels; ++srcidx) {
unsigned int channel = ttable->srcs[srcidx].channel;
if (channel >= src_channels)
@@ -207,18 +195,13 @@ static void snd_pcm_route_convert1_one_getput(const snd_pcm_channel_area_t *dst_
return;
}
- get = get32_labels[params->get_idx];
- put = put32_labels[params->put_idx];
src = snd_pcm_channel_area_addr(src_area, src_offset);
dst = snd_pcm_channel_area_addr(dst_area, dst_offset);
src_step = snd_pcm_channel_area_step(src_area);
dst_step = snd_pcm_channel_area_step(dst_area);
while (frames-- > 0) {
- goto *get;
-#define CONV24_END after
-#include "plugin_ops.h"
-#undef CONV24_END
- after:
+ sample = get32(src, get_idx);
+ put32(dst, sample, put_idx);
src += src_step;
dst += dst_step;
}
@@ -233,34 +216,6 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
const snd_pcm_route_ttable_dst_t* ttable,
const snd_pcm_route_params_t *params)
{
-#define GET32_LABELS
-#define PUT32_LABELS
-#include "plugin_ops.h"
-#undef GET32_LABELS
-#undef PUT32_LABELS
- static void *const zero_labels[2] = {
- &&zero_int64,
-#if SND_PCM_PLUGIN_ROUTE_FLOAT
- &&zero_float
-#endif
- };
- /* sum_type att */
- static void *const add_labels[2 * 2] = {
- &&add_int64_noatt, &&add_int64_att,
-#if SND_PCM_PLUGIN_ROUTE_FLOAT
- &&add_float_noatt, &&add_float_att
-#endif
- };
- /* sum_type att */
- static void *const norm_labels[2 * 2] = {
- &&norm_int64_noatt,
- &&norm_int64_att,
-#if SND_PCM_PLUGIN_ROUTE_FLOAT
- &&norm_float,
- &&norm_float,
-#endif
- };
- void *zero, *get32, *add, *norm, *put32;
int nsrcs = ttable->nsrcs;
char *dst;
int dst_step;
@@ -269,6 +224,7 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
snd_pcm_route_ttable_src_t src_tt[nsrcs];
int32_t sample = 0;
int srcidx, srcidx1 = 0;
+ unsigned get_idx = params->get_idx, put_idx = params->put_idx;
for (srcidx = 0; srcidx < nsrcs && (unsigned)srcidx < src_channels; ++srcidx) {
const snd_pcm_channel_area_t *src_area;
unsigned int channel = ttable->srcs[srcidx].channel;
@@ -301,11 +257,6 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
return;
}
- zero = zero_labels[params->sum_idx];
- get32 = get32_labels[params->get_idx];
- add = add_labels[params->sum_idx * 2 + ttable->att];
- norm = norm_labels[params->sum_idx * 2 + ttable->att];
- 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);
@@ -314,83 +265,71 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
sum_t sum;
/* Zero sum */
- goto *zero;
- zero_int64:
- sum.as_sint64 = 0;
- goto zero_end;
+ switch (params->sum_idx) {
+ case 0: sum.as_sint64 = 0; break;
#if SND_PCM_PLUGIN_ROUTE_FLOAT
- zero_float:
- sum.as_float = 0.0;
- goto zero_end;
+ case 1: sum.as_float = 0.0; break;
#endif
- zero_end:
+ }
for (srcidx = 0; srcidx < nsrcs; ++srcidx) {
const char *src = srcs[srcidx];
/* Get sample */
- goto *get32;
-#define GET32_END after_get
-#include "plugin_ops.h"
-#undef GET32_END
- after_get:
+ sample = get32(src, get_idx);
/* Sum */
- goto *add;
- add_int64_att:
- sum.as_sint64 += (int64_t) sample * ttp->as_int;
- goto after_sum;
- add_int64_noatt:
- if (ttp->as_int)
- sum.as_sint64 += sample;
- goto after_sum;
+ switch (params->sum_idx * 2 + ttable->att) {
+ case 0:
+ if (ttp->as_int)
+ sum.as_sint64 += sample;
+ break;
+ case 1:
+ sum.as_sint64 += (int64_t) sample * ttp->as_int;
+ break;
#if SND_PCM_PLUGIN_ROUTE_FLOAT
- add_float_att:
- sum.as_float += sample * ttp->as_float;
- goto after_sum;
- add_float_noatt:
- if (ttp->as_int)
- sum.as_float += sample;
- goto after_sum;
+ case 2:
+ if (ttp->as_int)
+ sum.as_float += sample;
+ break;
+ case 3:
+ sum.as_float += sample * ttp->as_float;
+ break;
#endif
- after_sum:
+ }
srcs[srcidx] += src_steps[srcidx];
ttp++;
}
/* Normalization */
- goto *norm;
- norm_int64_att:
- div(sum.as_sint64);
- /* fallthru */
- norm_int64_noatt:
- if (sum.as_sint64 > (int64_t)0x7fffffff)
- sample = 0x7fffffff; /* maximum positive value */
- else if (sum.as_sint64 < -(int64_t)0x80000000)
- sample = 0x80000000; /* maximum negative value */
- else
- sample = sum.as_sint64;
- goto after_norm;
-
+ switch (params->sum_idx * 2 + ttable->att) {
+ case 1:
+ div(sum.as_sint64);
+ /* fallthru */
+ case 0:
+ if (sum.as_sint64 > (int64_t)0x7fffffff)
+ sample = 0x7fffffff; /* maximum positive value */
+ else if (sum.as_sint64 < -(int64_t)0x80000000)
+ sample = 0x80000000; /* maximum negative value */
+ else
+ sample = sum.as_sint64;
+ break;
#if SND_PCM_PLUGIN_ROUTE_FLOAT
- norm_float:
- sum.as_float = rint(sum.as_float);
- if (sum.as_float > (int64_t)0x7fffffff)
- sample = 0x7fffffff; /* maximum positive value */
- else if (sum.as_float < -(int64_t)0x80000000)
- sample = 0x80000000; /* maximum negative value */
- else
- sample = sum.as_float;
- goto after_norm;
+ case 2:
+ case 3:
+ sum.as_float = rint(sum.as_float);
+ if (sum.as_float > (int64_t)0x7fffffff)
+ sample = 0x7fffffff; /* maximum positive value */
+ else if (sum.as_float < -(int64_t)0x80000000)
+ sample = 0x80000000; /* maximum negative value */
+ else
+ sample = sum.as_float;
+ break;
#endif
- after_norm:
+ }
/* Put sample */
- goto *put32;
-#define PUT32_END after_put32
-#include "plugin_ops.h"
-#undef PUT32_END
- after_put32:
-
+ put32(dst, sample, put_idx);
+
dst += dst_step;
}
}
diff --git a/src/pcm/plugin_ops.h b/src/pcm/plugin_ops.h
index 6392073c..5c89a24f 100644
--- a/src/pcm/plugin_ops.h
+++ b/src/pcm/plugin_ops.h
@@ -19,6 +19,11 @@
*
*/
+#include <assert.h>
+#include <math.h>
+#include <stdint.h>
+#include <byteswap.h>
+
#ifndef SX_INLINES
#define SX_INLINES
static inline uint32_t sx20(uint32_t x)
@@ -92,626 +97,360 @@ static inline uint32_t sx24s(uint32_t x)
#define _put_triple_s(ptr,val) _put_triple_le(ptr,val)
#endif
-#ifdef CONV_LABELS
-/* src_wid src_endswap sign_toggle dst_wid dst_endswap */
-static void *const conv_labels[4 * 2 * 2 * 4 * 2] = {
- &&conv_xxx1_xxx1, /* 8h -> 8h */
- &&conv_xxx1_xxx1, /* 8h -> 8s */
- &&conv_xxx1_xx10, /* 8h -> 16h */
- &&conv_xxx1_xx01, /* 8h -> 16s */
- &&conv_xxx1_x100, /* 8h -> 24h */
- &&conv_xxx1_001x, /* 8h -> 24s */
- &&conv_xxx1_1000, /* 8h -> 32h */
- &&conv_xxx1_0001, /* 8h -> 32s */
- &&conv_xxx1_xxx9, /* 8h ^> 8h */
- &&conv_xxx1_xxx9, /* 8h ^> 8s */
- &&conv_xxx1_xx90, /* 8h ^> 16h */
- &&conv_xxx1_xx09, /* 8h ^> 16s */
- &&conv_xxx1_x900, /* 8h ^> 24h */
- &&conv_xxx1_009x, /* 8h ^> 24s */
- &&conv_xxx1_9000, /* 8h ^> 32h */
- &&conv_xxx1_0009, /* 8h ^> 32s */
- &&conv_xxx1_xxx1, /* 8s -> 8h */
- &&conv_xxx1_xxx1, /* 8s -> 8s */
- &&conv_xxx1_xx10, /* 8s -> 16h */
- &&conv_xxx1_xx01, /* 8s -> 16s */
- &&conv_xxx1_x100, /* 8s -> 24h */
- &&conv_xxx1_001x, /* 8s -> 24s */
- &&conv_xxx1_1000, /* 8s -> 32h */
- &&conv_xxx1_0001, /* 8s -> 32s */
- &&conv_xxx1_xxx9, /* 8s ^> 8h */
- &&conv_xxx1_xxx9, /* 8s ^> 8s */
- &&conv_xxx1_xx90, /* 8s ^> 16h */
- &&conv_xxx1_xx09, /* 8s ^> 16s */
- &&conv_xxx1_x900, /* 8s ^> 24h */
- &&conv_xxx1_009x, /* 8s ^> 24s */
- &&conv_xxx1_9000, /* 8s ^> 32h */
- &&conv_xxx1_0009, /* 8s ^> 32s */
- &&conv_xx12_xxx1, /* 16h -> 8h */
- &&conv_xx12_xxx1, /* 16h -> 8s */
- &&conv_xx12_xx12, /* 16h -> 16h */
- &&conv_xx12_xx21, /* 16h -> 16s */
- &&conv_xx12_x120, /* 16h -> 24h */
- &&conv_xx12_021x, /* 16h -> 24s */
- &&conv_xx12_1200, /* 16h -> 32h */
- &&conv_xx12_0021, /* 16h -> 32s */
- &&conv_xx12_xxx9, /* 16h ^> 8h */
- &&conv_xx12_xxx9, /* 16h ^> 8s */
- &&conv_xx12_xx92, /* 16h ^> 16h */
- &&conv_xx12_xx29, /* 16h ^> 16s */
- &&conv_xx12_x920, /* 16h ^> 24h */
- &&conv_xx12_029x, /* 16h ^> 24s */
- &&conv_xx12_9200, /* 16h ^> 32h */
- &&conv_xx12_0029, /* 16h ^> 32s */
- &&conv_xx12_xxx2, /* 16s -> 8h */
- &&conv_xx12_xxx2, /* 16s -> 8s */
- &&conv_xx12_xx21, /* 16s -> 16h */
- &&conv_xx12_xx12, /* 16s -> 16s */
- &&conv_xx12_x210, /* 16s -> 24h */
- &&conv_xx12_012x, /* 16s -> 24s */
- &&conv_xx12_2100, /* 16s -> 32h */
- &&conv_xx12_0012, /* 16s -> 32s */
- &&conv_xx12_xxxA, /* 16s ^> 8h */
- &&conv_xx12_xxxA, /* 16s ^> 8s */
- &&conv_xx12_xxA1, /* 16s ^> 16h */
- &&conv_xx12_xx1A, /* 16s ^> 16s */
- &&conv_xx12_xA10, /* 16s ^> 24h */
- &&conv_xx12_01Ax, /* 16s ^> 24s */
- &&conv_xx12_A100, /* 16s ^> 32h */
- &&conv_xx12_001A, /* 16s ^> 32s */
- &&conv_x123_xxx1, /* 24h -> 8h */
- &&conv_x123_xxx1, /* 24h -> 8s */
- &&conv_x123_xx12, /* 24h -> 16h */
- &&conv_x123_xx21, /* 24h -> 16s */
- &&conv_x123_x123, /* 24h -> 24h */
- &&conv_x123_321x, /* 24h -> 24s */
- &&conv_x123_1230, /* 24h -> 32h */
- &&conv_x123_0321, /* 24h -> 32s */
- &&conv_x123_xxx9, /* 24h ^> 8h */
- &&conv_x123_xxx9, /* 24h ^> 8s */
- &&conv_x123_xx92, /* 24h ^> 16h */
- &&conv_x123_xx29, /* 24h ^> 16s */
- &&conv_x123_x923, /* 24h ^> 24h */
- &&conv_x123_329x, /* 24h ^> 24s */
- &&conv_x123_9230, /* 24h ^> 32h */
- &&conv_x123_0329, /* 24h ^> 32s */
- &&conv_123x_xxx3, /* 24s -> 8h */
- &&conv_123x_xxx3, /* 24s -> 8s */
- &&conv_123x_xx32, /* 24s -> 16h */
- &&conv_123x_xx23, /* 24s -> 16s */
- &&conv_123x_x321, /* 24s -> 24h */
- &&conv_123x_123x, /* 24s -> 24s */
- &&conv_123x_3210, /* 24s -> 32h */
- &&conv_123x_0123, /* 24s -> 32s */
- &&conv_123x_xxxB, /* 24s ^> 8h */
- &&conv_123x_xxxB, /* 24s ^> 8s */
- &&conv_123x_xxB2, /* 24s ^> 16h */
- &&conv_123x_xx2B, /* 24s ^> 16s */
- &&conv_123x_xB21, /* 24s ^> 24h */
- &&conv_123x_12Bx, /* 24s ^> 24s */
- &&conv_123x_B210, /* 24s ^> 32h */
- &&conv_123x_012B, /* 24s ^> 32s */
- &&conv_1234_xxx1, /* 32h -> 8h */
- &&conv_1234_xxx1, /* 32h -> 8s */
- &&conv_1234_xx12, /* 32h -> 16h */
- &&conv_1234_xx21, /* 32h -> 16s */
- &&conv_1234_x123, /* 32h -> 24h */
- &&conv_1234_321x, /* 32h -> 24s */
- &&conv_1234_1234, /* 32h -> 32h */
- &&conv_1234_4321, /* 32h -> 32s */
- &&conv_1234_xxx9, /* 32h ^> 8h */
- &&conv_1234_xxx9, /* 32h ^> 8s */
- &&conv_1234_xx92, /* 32h ^> 16h */
- &&conv_1234_xx29, /* 32h ^> 16s */
- &&conv_1234_x923, /* 32h ^> 24h */
- &&conv_1234_329x, /* 32h ^> 24s */
- &&conv_1234_9234, /* 32h ^> 32h */
- &&conv_1234_4329, /* 32h ^> 32s */
- &&conv_1234_xxx4, /* 32s -> 8h */
- &&conv_1234_xxx4, /* 32s -> 8s */
- &&conv_1234_xx43, /* 32s -> 16h */
- &&conv_1234_xx34, /* 32s -> 16s */
- &&conv_1234_x432, /* 32s -> 24h */
- &&conv_1234_234x, /* 32s -> 24s */
- &&conv_1234_4321, /* 32s -> 32h */
- &&conv_1234_1234, /* 32s -> 32s */
- &&conv_1234_xxxC, /* 32s ^> 8h */
- &&conv_1234_xxxC, /* 32s ^> 8s */
- &&conv_1234_xxC3, /* 32s ^> 16h */
- &&conv_1234_xx3C, /* 32s ^> 16s */
- &&conv_1234_xC32, /* 32s ^> 24h */
- &&conv_1234_23Cx, /* 32s ^> 24s */
- &&conv_1234_C321, /* 32s ^> 32h */
- &&conv_1234_123C, /* 32s ^> 32s */
-};
-#endif
-
-#ifdef CONV_END
-while(0) {
-conv_xxx1_xxx1: as_u8(dst) = as_u8c(src); goto CONV_END;
-conv_xxx1_xx10: as_u16(dst) = (uint16_t)as_u8c(src) << 8; goto CONV_END;
-conv_xxx1_xx01: as_u16(dst) = (uint16_t)as_u8c(src); goto CONV_END;
-conv_xxx1_x100: as_u32(dst) = sx24((uint32_t)as_u8c(src) << 16); goto CONV_END;
-conv_xxx1_001x: as_u32(dst) = sx24s((uint32_t)as_u8c(src) << 8); goto CONV_END;
-conv_xxx1_1000: as_u32(dst) = (uint32_t)as_u8c(src) << 24; goto CONV_END;
-conv_xxx1_0001: as_u32(dst) = (uint32_t)as_u8c(src); goto CONV_END;
-conv_xxx1_xxx9: as_u8(dst) = as_u8c(src) ^ 0x80; goto CONV_END;
-conv_xxx1_xx90: as_u16(dst) = (uint16_t)(as_u8c(src) ^ 0x80) << 8; goto CONV_END;
-conv_xxx1_xx09: as_u16(dst) = (uint16_t)(as_u8c(src) ^ 0x80); goto CONV_END;
-conv_xxx1_x900: as_u32(dst) = sx24((uint32_t)(as_u8c(src) ^ 0x80) << 16); goto CONV_END;
-conv_xxx1_009x: as_u32(dst) = sx24s((uint32_t)(as_u8c(src) ^ 0x80) << 8); goto CONV_END;
-conv_xxx1_9000: as_u32(dst) = (uint32_t)(as_u8c(src) ^ 0x80) << 24; goto CONV_END;
-conv_xxx1_0009: as_u32(dst) = (uint32_t)(as_u8c(src) ^ 0x80); goto CONV_END;
-conv_xx12_xxx1: as_u8(dst) = as_u16c(src) >> 8; goto CONV_END;
-conv_xx12_xx12: as_u16(dst) = as_u16c(src); goto CONV_END;
-conv_xx12_xx21: as_u16(dst) = bswap_16(as_u16c(src)); goto CONV_END;
-conv_xx12_x120: as_u32(dst) = sx24((uint32_t)as_u16c(src) << 8); goto CONV_END;
-conv_xx12_021x: as_u32(dst) = sx24s((uint32_t)bswap_16(as_u16c(src)) << 8); goto CONV_END;
-conv_xx12_1200: as_u32(dst) = (uint32_t)as_u16c(src) << 16; goto CONV_END;
-conv_xx12_0021: as_u32(dst) = (uint32_t)bswap_16(as_u16c(src)); goto CONV_END;
-conv_xx12_xxx9: as_u8(dst) = (as_u16c(src) >> 8) ^ 0x80; goto CONV_END;
-conv_xx12_xx92: as_u16(dst) = as_u16c(src) ^ 0x8000; goto CONV_END;
-conv_xx12_xx29: as_u16(dst) = bswap_16(as_u16c(src)) ^ 0x80; goto CONV_END;
-conv_xx12_x920: as_u32(dst) = sx24((uint32_t)(as_u16c(src) ^ 0x8000) << 8); goto CONV_END;
-conv_xx12_029x: as_u32(dst) = sx24s((uint32_t)(bswap_16(as_u16c(src)) ^ 0x80) << 8); goto CONV_END;
-conv_xx12_9200: as_u32(dst) = (uint32_t)(as_u16c(src) ^ 0x8000) << 16; goto CONV_END;
-conv_xx12_0029: as_u32(dst) = (uint32_t)(bswap_16(as_u16c(src)) ^ 0x80); goto CONV_END;
-conv_xx12_xxx2: as_u8(dst) = as_u16c(src) & 0xff; goto CONV_END;
-conv_xx12_x210: as_u32(dst) = sx24((uint32_t)bswap_16(as_u16c(src)) << 8); goto CONV_END;
-conv_xx12_012x: as_u32(dst) = sx24s((uint32_t)as_u16c(src) << 8); goto CONV_END;
-conv_xx12_2100: as_u32(dst) = (uint32_t)bswap_16(as_u16c(src)) << 16; goto CONV_END;
-conv_xx12_0012: as_u32(dst) = (uint32_t)as_u16c(src); goto CONV_END;
-conv_xx12_xxxA: as_u8(dst) = (as_u16c(src) ^ 0x80) & 0xff; goto CONV_END;
-conv_xx12_xxA1: as_u16(dst) = bswap_16(as_u16c(src) ^ 0x80); goto CONV_END;
-conv_xx12_xx1A: as_u16(dst) = as_u16c(src) ^ 0x80; goto CONV_END;
-conv_xx12_xA10: as_u32(dst) = sx24((uint32_t)bswap_16(as_u16c(src) ^ 0x80) << 8); goto CONV_END;
-conv_xx12_01Ax: as_u32(dst) = sx24s((uint32_t)(as_u16c(src) ^ 0x80) << 8); goto CONV_END;
-conv_xx12_A100: as_u32(dst) = (uint32_t)bswap_16(as_u16c(src) ^ 0x80) << 16; goto CONV_END;
-conv_xx12_001A: as_u32(dst) = (uint32_t)(as_u16c(src) ^ 0x80); goto CONV_END;
-conv_x123_xxx1: as_u8(dst) = as_u32c(src) >> 16; goto CONV_END;
-conv_x123_xx12: as_u16(dst) = as_u32c(src) >> 8; goto CONV_END;
-conv_x123_xx21: as_u16(dst) = bswap_16(as_u32c(src) >> 8); goto CONV_END;
-conv_x123_x123: as_u32(dst) = sx24(as_u32c(src)); goto CONV_END;
-conv_x123_321x: as_u32(dst) = sx24s(bswap_32(as_u32c(src))); goto CONV_END;
-conv_x123_1230: as_u32(dst) = as_u32c(src) << 8; goto CONV_END;
-conv_x123_0321: as_u32(dst) = bswap_32(as_u32c(src)) >> 8; goto CONV_END;
-conv_x123_xxx9: as_u8(dst) = (as_u32c(src) >> 16) ^ 0x80; goto CONV_END;
-conv_x123_xx92: as_u16(dst) = (as_u32c(src) >> 8) ^ 0x8000; goto CONV_END;
-conv_x123_xx29: as_u16(dst) = bswap_16(as_u32c(src) >> 8) ^ 0x80; goto CONV_END;
-conv_x123_x923: as_u32(dst) = sx24(as_u32c(src) ^ 0x800000); goto CONV_END;
-conv_x123_329x: as_u32(dst) = sx24s(bswap_32(as_u32c(src)) ^ 0x8000); goto CONV_END;
-conv_x123_9230: as_u32(dst) = (as_u32c(src) ^ 0x800000) << 8; goto CONV_END;
-conv_x123_0329: as_u32(dst) = (bswap_32(as_u32c(src)) >> 8) ^ 0x80; goto CONV_END;
-conv_123x_xxx3: as_u8(dst) = (as_u32c(src) >> 8) & 0xff; goto CONV_END;
-conv_123x_xx32: as_u16(dst) = bswap_16(as_u32c(src) >> 8); goto CONV_END;
-conv_123x_xx23: as_u16(dst) = (as_u32c(src) >> 8) & 0xffff; goto CONV_END;
-conv_123x_x321: as_u32(dst) = sx24(bswap_32(as_u32c(src))); goto CONV_END;
-conv_123x_123x: as_u32(dst) = sx24s(as_u32c(src)); goto CONV_END;
-conv_123x_3210: as_u32(dst) = bswap_32(as_u32c(src)) << 8; goto CONV_END;
-conv_123x_0123: as_u32(dst) = as_u32c(src) >> 8; goto CONV_END;
-conv_123x_xxxB: as_u8(dst) = ((as_u32c(src) >> 8) & 0xff) ^ 0x80; goto CONV_END;
-conv_123x_xxB2: as_u16(dst) = bswap_16((as_u32c(src) >> 8) ^ 0x80); goto CONV_END;
-conv_123x_xx2B: as_u16(dst) = ((as_u32c(src) >> 8) & 0xffff) ^ 0x80; goto CONV_END;
-conv_123x_xB21: as_u32(dst) = sx24(bswap_32(as_u32c(src)) ^ 0x800000); goto CONV_END;
-conv_123x_12Bx: as_u32(dst) = sx24s(as_u32c(src) ^ 0x8000); goto CONV_END;
-conv_123x_B210: as_u32(dst) = bswap_32(as_u32c(src) ^ 0x8000) << 8; goto CONV_END;
-conv_123x_012B: as_u32(dst) = (as_u32c(src) >> 8) ^ 0x80; goto CONV_END;
-conv_1234_xxx1: as_u8(dst) = as_u32c(src) >> 24; goto CONV_END;
-conv_1234_xx12: as_u16(dst) = as_u32c(src) >> 16; goto CONV_END;
-conv_1234_xx21: as_u16(dst) = bswap_16(as_u32c(src) >> 16); goto CONV_END;
-conv_1234_x123: as_u32(dst) = sx24(as_u32c(src) >> 8); goto CONV_END;
-conv_1234_321x: as_u32(dst) = sx24s(bswap_32(as_u32c(src)) << 8); goto CONV_END;
-conv_1234_1234: as_u32(dst) = as_u32c(src); goto CONV_END;
-conv_1234_4321: as_u32(dst) = bswap_32(as_u32c(src)); goto CONV_END;
-conv_1234_xxx9: as_u8(dst) = (as_u32c(src) >> 24) ^ 0x80; goto CONV_END;
-conv_1234_xx92: as_u16(dst) = (as_u32c(src) >> 16) ^ 0x8000; goto CONV_END;
-conv_1234_xx29: as_u16(dst) = bswap_16(as_u32c(src) >> 16) ^ 0x80; goto CONV_END;
-conv_1234_x923: as_u32(dst) = sx24((as_u32c(src) >> 8) ^ 0x800000); goto CONV_END;
-conv_1234_329x: as_u32(dst) = sx24s((bswap_32(as_u32c(src)) ^ 0x80) << 8); goto CONV_END;
-conv_1234_9234: as_u32(dst) = as_u32c(src) ^ 0x80000000; goto CONV_END;
-conv_1234_4329: as_u32(dst) = bswap_32(as_u32c(src)) ^ 0x80; goto CONV_END;
-conv_1234_xxx4: as_u8(dst) = as_u32c(src) & 0xff; goto CONV_END;
-conv_1234_xx43: as_u16(dst) = bswap_16(as_u32c(src)); goto CONV_END;
-conv_1234_xx34: as_u16(dst) = as_u32c(src) & 0xffff; goto CONV_END;
-conv_1234_x432: as_u32(dst) = sx24(bswap_32(as_u32c(src)) >> 8); goto CONV_END;
-conv_1234_234x: as_u32(dst) = sx24s(as_u32c(src) << 8); goto CONV_END;
-conv_1234_xxxC: as_u8(dst) = (as_u32c(src) & 0xff) ^ 0x80; goto CONV_END;
-conv_1234_xxC3: as_u16(dst) = bswap_16(as_u32c(src) ^ 0x80); goto CONV_END;
-conv_1234_xx3C: as_u16(dst) = (as_u32c(src) & 0xffff) ^ 0x80; goto CONV_END;
-conv_1234_xC32: as_u32(dst) = sx24((bswap_32(as_u32c(src)) >> 8) ^ 0x800000); goto CONV_END;
-conv_1234_23Cx: as_u32(dst) = sx24s((as_u32c(src) ^ 0x80) << 8); goto CONV_END;
-conv_1234_C321: as_u32(dst) = bswap_32(as_u32c(src) ^ 0x80); goto CONV_END;
-conv_1234_123C: as_u32(dst) = as_u32c(src) ^ 0x80; goto CONV_END;
+static inline void conv(char *dst, const char *src, unsigned int idx) {
+ switch (idx) {
+ case 0: /* 8h -> 8h */
+ case 1: /* 8h -> 8s */
+ case 16: /* 8s -> 8h */
+ case 17: /* 8s -> 8s */ as_u8(dst) = as_u8c(src); break;
+ case 2: /* 8h -> 16h */
+ case 18: /* 8s -> 16h */ as_u16(dst) = (uint16_t)as_u8c(src) << 8; break;
+ case 3: /* 8h -> 16s */
+ case 19: /* 8s -> 16s */ as_u16(dst) = (uint16_t)as_u8c(src); break;
+ case 4: /* 8h -> 24h */
+ case 20: /* 8s -> 24h */ as_u32(dst) = sx24((uint32_t)as_u8c(src) << 16); break;
+ case 5: /* 8h -> 24s */
+ case 21: /* 8s -> 24s */ as_u32(dst) = sx24s((uint32_t)as_u8c(src) << 8); break;
+ case 6: /* 8h -> 32h */
+ case 22: /* 8s -> 32h */ as_u32(dst) = (uint32_t)as_u8c(src) << 24; break;
+ case 7: /* 8h -> 32s */
+ case 23: /* 8s -> 32s */ as_u32(dst) = (uint32_t)as_u8c(src); break;
+ case 8: /* 8h ^> 8h */
+ case 9: /* 8h ^> 8s */
+ case 24: /* 8s ^> 8h */
+ case 25: /* 8s ^> 8s */ as_u8(dst) = as_u8c(src) ^ 0x80; break;
+ case 10: /* 8h ^> 16h */
+ case 26: /* 8s ^> 16h */ as_u16(dst) = (uint16_t)(as_u8c(src) ^ 0x80) << 8; break;
+ case 11: /* 8h ^> 16s */
+ case 27: /* 8s ^> 16s */ as_u16(dst) = (uint16_t)(as_u8c(src) ^ 0x80); break;
+ case 12: /* 8h ^> 24h */
+ case 28: /* 8s ^> 24h */ as_u32(dst) = sx24((uint32_t)(as_u8c(src) ^ 0x80) << 16); break;
+ case 13: /* 8h ^> 24s */
+ case 29: /* 8s ^> 24s */ as_u32(dst) = sx24s((uint32_t)(as_u8c(src) ^ 0x80) << 8); break;
+ case 14: /* 8h ^> 32h */
+ case 30: /* 8s ^> 32h */ as_u32(dst) = (uint32_t)(as_u8c(src) ^ 0x80) << 24; break;
+ case 15: /* 8h ^> 32s */
+ case 31: /* 8s ^> 32s */ as_u32(dst) = (uint32_t)(as_u8c(src) ^ 0x80); break;
+ case 32: /* 16h -> 8h */
+ case 33: /* 16h -> 8s */ as_u8(dst) = as_u16c(src) >> 8; break;
+ case 34: /* 16h -> 16h */ as_u16(dst) = as_u16c(src); break;
+ case 35: /* 16h -> 16s */ as_u16(dst) = bswap_16(as_u16c(src)); break;
+ case 36: /* 16h -> 24h */ as_u32(dst) = sx24((uint32_t)as_u16c(src) << 8); break;
+ case 37: /* 16h -> 24s */ as_u32(dst) = sx24s((uint32_t)bswap_16(as_u16c(src)) << 8); break;
+ case 38: /* 16h -> 32h */ as_u32(dst) = (uint32_t)as_u16c(src) << 16; break;
+ case 39: /* 16h -> 32s */ as_u32(dst) = (uint32_t)bswap_16(as_u16c(src)); break;
+ case 40: /* 16h ^> 8h */
+ case 41: /* 16h ^> 8s */ as_u8(dst) = (as_u16c(src) >> 8) ^ 0x80; break;
+ case 42: /* 16h ^> 16h */
+ case 51: /* 16s -> 16s */ as_u16(dst) = as_u16c(src) ^ 0x8000; break;
+ case 43: /* 16h ^> 16s */
+ case 50: /* 16s -> 16h */ as_u16(dst) = bswap_16(as_u16c(src)) ^ 0x80; break;
+ case 44: /* 16h ^> 24h */ as_u32(dst) = sx24((uint32_t)(as_u16c(src) ^ 0x8000) << 8); break;
+ case 45: /* 16h ^> 24s */ as_u32(dst) = sx24s((uint32_t)(bswap_16(as_u16c(src)) ^ 0x80) << 8); break;
+ case 46: /* 16h ^> 32h */ as_u32(dst) = (uint32_t)(as_u16c(src) ^ 0x8000) << 16; break;
+ case 47: /* 16h ^> 32s */ as_u32(dst) = (uint32_t)(bswap_16(as_u16c(src)) ^ 0x80); break;
+ case 48: /* 16s -> 8h */
+ case 49: /* 16s -> 8s */ as_u8(dst) = as_u16c(src) & 0xff; break;
+ case 52: /* 16s -> 24h */ as_u32(dst) = sx24((uint32_t)bswap_16(as_u16c(src)) << 8); break;
+ case 53: /* 16s -> 24s */ as_u32(dst) = sx24s((uint32_t)as_u16c(src) << 8); break;
+ case 54: /* 16s -> 32h */ as_u32(dst) = (uint32_t)bswap_16(as_u16c(src)) << 16; break;
+ case 55: /* 16s -> 32s */ as_u32(dst) = (uint32_t)as_u16c(src); break;
+ case 56: /* 16s ^> 8h */
+ case 57: /* 16s ^> 8s */ as_u8(dst) = (as_u16c(src) ^ 0x80) & 0xff; break;
+ case 58: /* 16s ^> 16h */ as_u16(dst) = bswap_16(as_u16c(src) ^ 0x80); break;
+ case 59: /* 16s ^> 16s */ as_u16(dst) = as_u16c(src) ^ 0x80; break;
+ case 60: /* 16s ^> 24h */ as_u32(dst) = sx24((uint32_t)bswap_16(as_u16c(src) ^ 0x80) << 8); break;
+ case 61: /* 16s ^> 24s */ as_u32(dst) = sx24s((uint32_t)(as_u16c(src) ^ 0x80) << 8); break;
+ case 62: /* 16s ^> 32h */ as_u32(dst) = (uint32_t)bswap_16(as_u16c(src) ^ 0x80) << 16; break;
+ case 63: /* 16s ^> 32s */ as_u32(dst) = (uint32_t)(as_u16c(src) ^ 0x80); break;
+ case 64: /* 24h -> 8h */
+ case 65: /* 24h -> 8s */ as_u8(dst) = as_u32c(src) >> 16; break;
+ case 66: /* 24h -> 16h */ as_u16(dst) = as_u32c(src) >> 8; break;
+ case 67: /* 24h -> 16s */ as_u16(dst) = bswap_16(as_u32c(src) >> 8); break;
+ case 68: /* 24h -> 24h */ as_u32(dst) = sx24(as_u32c(src)); break;
+ case 69: /* 24h -> 24s */ as_u32(dst) = sx24s(bswap_32(as_u32c(src))); break;
+ case 70: /* 24h -> 32h */ as_u32(dst) = as_u32c(src) << 8; break;
+ case 71: /* 24h -> 32s */ as_u32(dst) = bswap_32(as_u32c(src)) >> 8; break;
+ case 72: /* 24h ^> 8h */
+ case 73: /* 24h ^> 8s */ as_u8(dst) = (as_u32c(src) >> 16) ^ 0x80; break;
+ case 74: /* 24h ^> 16h */ as_u16(dst) = (as_u32c(src) >> 8) ^ 0x8000; break;
+ case 75: /* 24h ^> 16s */ as_u16(dst) = bswap_16(as_u32c(src) >> 8) ^ 0x80; break;
+ case 76: /* 24h ^> 24h */ as_u32(dst) = sx24(as_u32c(src) ^ 0x800000); break;
+ case 77: /* 24h ^> 24s */ as_u32(dst) = sx24s(bswap_32(as_u32c(src)) ^ 0x8000); break;
+ case 78: /* 24h ^> 32h */ as_u32(dst) = (as_u32c(src) ^ 0x800000) << 8; break;
+ case 79: /* 24h ^> 32s */ as_u32(dst) = (bswap_32(as_u32c(src)) >> 8) ^ 0x80; break;
+ case 80: /* 24s -> 8h */
+ case 81: /* 24s -> 8s */ as_u8(dst) = (as_u32c(src) >> 8) & 0xff; break;
+ case 82: /* 24s -> 16h */ as_u16(dst) = bswap_16(as_u32c(src) >> 8); break;
+ case 83: /* 24s -> 16s */ as_u16(dst) = (as_u32c(src) >> 8) & 0xffff; break;
+ case 84: /* 24s -> 24h */ as_u32(dst) = sx24(bswap_32(as_u32c(src))); break;
+ case 85: /* 24s -> 24s */ as_u32(dst) = sx24s(as_u32c(src)); break;
+ case 86: /* 24s -> 32h */ as_u32(dst) = bswap_32(as_u32c(src)) << 8; break;
+ case 87: /* 24s -> 32s */ as_u32(dst) = as_u32c(src) >> 8; break;
+ case 88: /* 24s ^> 8h */
+ case 89: /* 24s ^> 8s */ as_u8(dst) = ((as_u32c(src) >> 8) & 0xff) ^ 0x80; break;
+ case 90: /* 24s ^> 16h */ as_u16(dst) = bswap_16((as_u32c(src) >> 8) ^ 0x80); break;
+ case 91: /* 24s ^> 16s */ as_u16(dst) = ((as_u32c(src) >> 8) & 0xffff) ^ 0x80; break;
+ case 92: /* 24s ^> 24h */ as_u32(dst) = sx24(bswap_32(as_u32c(src)) ^ 0x800000); break;
+ case 93: /* 24s ^> 24s */ as_u32(dst) = sx24s(as_u32c(src) ^ 0x8000); break;
+ case 94: /* 24s ^> 32h */ as_u32(dst) = bswap_32(as_u32c(src) ^ 0x8000) << 8; break;
+ case 95: /* 24s ^> 32s */ as_u32(dst) = (as_u32c(src) >> 8) ^ 0x80; break;
+ case 96: /* 32h -> 8h */
+ case 97: /* 32h -> 8s */ as_u8(dst) = as_u32c(src) >> 24; break;
+ case 98: /* 32h -> 16h */ as_u16(dst) = as_u32c(src) >> 16; break;
+ case 99: /* 32h -> 16s */ as_u16(dst) = bswap_16(as_u32c(src) >> 16); break;
+ case 100: /* 32h -> 24h */ as_u32(dst) = sx24(as_u32c(src) >> 8); break;
+ case 101: /* 32h -> 24s */ as_u32(dst) = sx24s(bswap_32(as_u32c(src)) << 8); break;
+ case 102: /* 32h -> 32h */
+ case 119: /* 32s -> 32s */ as_u32(dst) = as_u32c(src); break;
+ case 103: /* 32h -> 32s */
+ case 118: /* 32s -> 32h */ as_u32(dst) = bswap_32(as_u32c(src)); break;
+ case 104: /* 32h ^> 8h */
+ case 105: /* 32h ^> 8s */ as_u8(dst) = (as_u32c(src) >> 24) ^ 0x80; break;
+ case 106: /* 32h ^> 16h */ as_u16(dst) = (as_u32c(src) >> 16) ^ 0x8000; break;
+ case 107: /* 32h ^> 16s */ as_u16(dst) = bswap_16(as_u32c(src) >> 16) ^ 0x80; break;
+ case 108: /* 32h ^> 24h */ as_u32(dst) = sx24((as_u32c(src) >> 8) ^ 0x800000); break;
+ case 109: /* 32h ^> 24s */ as_u32(dst) = sx24s((bswap_32(as_u32c(src)) ^ 0x80) << 8); break;
+ case 110: /* 32h ^> 32h */ as_u32(dst) = as_u32c(src) ^ 0x80000000; break;
+ case 111: /* 32h ^> 32s */ as_u32(dst) = bswap_32(as_u32c(src)) ^ 0x80; break;
+ case 112: /* 32s -> 8h */
+ case 113: /* 32s -> 8s */ as_u8(dst) = as_u32c(src) & 0xff; break;
+ case 114: /* 32s -> 16h */ as_u16(dst) = bswap_16(as_u32c(src)); break;
+ case 115: /* 32s -> 16s */ as_u16(dst) = as_u32c(src) & 0xffff; break;
+ case 116: /* 32s -> 24h */ as_u32(dst) = sx24(bswap_32(as_u32c(src)) >> 8); break;
+ case 117: /* 32s -> 24s */ as_u32(dst) = sx24s(as_u32c(src) << 8); break;
+ case 120: /* 32s ^> 8h */
+ case 121: /* 32s ^> 8s */ as_u8(dst) = (as_u32c(src) & 0xff) ^ 0x80; break;
+ case 122: /* 32s ^> 16h */ as_u16(dst) = bswap_16(as_u32c(src) ^ 0x80); break;
+ case 123: /* 32s ^> 16s */ as_u16(dst) = (as_u32c(src) & 0xffff) ^ 0x80; break;
+ case 124: /* 32s ^> 24h */ as_u32(dst) = sx24((bswap_32(as_u32c(src)) >> 8) ^ 0x800000); break;
+ case 125: /* 32s ^> 24s */ as_u32(dst) = sx24s((as_u32c(src) ^ 0x80) << 8); break;
+ case 126: /* 32s ^> 32h */ as_u32(dst) = bswap_32(as_u32c(src) ^ 0x80); break;
+ case 127: /* 32s ^> 32s */ as_u32(dst) = as_u32c(src) ^ 0x80; break;
+ default: assert(0);
+ }
}
-#endif
-#ifdef GET16_LABELS
-/* src_wid src_endswap sign_toggle */
-static void *const get16_labels[5 * 2 * 2 + 4 * 3] = {
- &&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 */
+static inline uint16_t get16(const char *src, unsigned int idx) {
+ switch(idx) {
+ case 0: /* 8h -> 16h */
+ case 2: /* 8s -> 16h */ return (uint16_t)as_u8c(src) << 8;
+ case 1: /* 8h ^> 16h */
+ case 3: /* 8s ^> 16h */ return (uint16_t)(as_u8c(src) ^ 0x80) << 8;
+ case 4: /* 16h -> 16h */ return as_u16c(src);
+ case 5: /* 16h ^> 16h */ return as_u16c(src) ^ 0x8000;
+ case 6: /* 16s -> 16h */ return bswap_16(as_u16c(src));
+ case 7: /* 16s ^> 16h */ return bswap_16(as_u16c(src) ^ 0x80);
/* 4 byte formats */
- &&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 */
- &&get16_0123_12_20, /* 20h -> 16h */
- &&get16_0123_92_20, /* 20h ^> 16h */
- &&get16_1230_32_20, /* 20s -> 16h */
- &&get16_1230_B2_20, /* 20s ^> 16h */
+ case 8: /* 24h -> 16h */ return as_u32c(src) >> 8;
+ case 9: /* 24h ^> 16h */ return (as_u32c(src) >> 8) ^ 0x8000;
+ case 10: /* 24s -> 16h */ return bswap_16(as_u32c(src) >> 8);
+ case 11: /* 24s ^> 16h */ return bswap_16((as_u32c(src) >> 8) ^ 0x80);
+ case 12: /* 32h -> 16h */ return as_u32c(src) >> 16;
+ case 13: /* 32h ^> 16h */ return (as_u32c(src) >> 16) ^ 0x8000;
+ case 14: /* 32s -> 16h */ return bswap_16(as_u32c(src));
+ case 15: /* 32s ^> 16h */ return bswap_16(as_u32c(src) ^ 0x80);
+ case 16: /* 20h -> 16h */ return as_u32c(src) >> 4;
+ case 17: /* 20h ^> 16h */ return (as_u32c(src) >> 4) ^ 0x8000;
+ case 18: /* 20s -> 16h */ return bswap_32(as_u32c(src)) >> 4;
+ case 19: /* 20s ^> 16h */ return (bswap_32(as_u32c(src)) >> 4) ^ 0x8000;
/* 3bytes format */
- &&get16_123_12, /* 24h -> 16h */
- &&get16_123_92, /* 24h ^> 16h */
- &&get16_123_32, /* 24s -> 16h */
- &&get16_123_B2, /* 24s ^> 16h */
- &&get16_123_12_20, /* 20h -> 16h */
- &&get16_123_92_20, /* 20h ^> 16h */
- &&get16_123_32_20, /* 20s -> 16h */
- &&get16_123_B2_20, /* 20s ^> 16h */
- &&get16_123_12_18, /* 18h -> 16h */
- &&get16_123_92_18, /* 18h ^> 16h */
- &&get16_123_32_18, /* 18s -> 16h */
- &&get16_123_B2_18, /* 18s ^> 16h */
-};
-#endif
-
-#ifdef GET16_END
-while(0) {
-get16_1_10: sample = (uint16_t)as_u8c(src) << 8; goto GET16_END;
-get16_1_90: sample = (uint16_t)(as_u8c(src) ^ 0x80) << 8; goto GET16_END;
-get16_12_12: sample = as_u16c(src); goto GET16_END;
-get16_12_92: sample = as_u16c(src) ^ 0x8000; goto GET16_END;
-get16_12_21: sample = bswap_16(as_u16c(src)); goto GET16_END;
-get16_12_A1: sample = bswap_16(as_u16c(src) ^ 0x80); goto GET16_END;
-get16_0123_12: sample = as_u32c(src) >> 8; goto GET16_END;
-get16_0123_92: sample = (as_u32c(src) >> 8) ^ 0x8000; goto GET16_END;
-get16_1230_32: sample = bswap_16(as_u32c(src) >> 8); goto GET16_END;
-get16_1230_B2: sample = bswap_16((as_u32c(src) >> 8) ^ 0x80); goto GET16_END;
-get16_1234_12: sample = as_u32c(src) >> 16; goto GET16_END;
-get16_1234_92: sample = (as_u32c(src) >> 16) ^ 0x8000; goto GET16_END;
-get16_1234_43: sample = bswap_16(as_u32c(src)); goto GET16_END;
-get16_1234_C3: sample = bswap_16(as_u32c(src) ^ 0x80); goto GET16_END;
-get16_0123_12_20: sample = as_u32c(src) >> 4; goto GET16_END;
-get16_0123_92_20: sample = (as_u32c(src) >> 4) ^ 0x8000; goto GET16_END;
-get16_1230_32_20: sample = bswap_32(as_u32c(src)) >> 4; goto GET16_END;
-get16_1230_B2_20: sample = (bswap_32(as_u32c(src)) >> 4) ^ 0x8000; goto GET16_END;
-get16_123_12: sample = _get_triple(src) >> 8; goto GET16_END;
-get16_123_92: sample = (_get_triple(src) >> 8) ^ 0x8000; goto GET16_END;
-get16_123_32: sample = _get_triple_s(src) >> 8; goto GET16_END;
-get16_123_B2: sample = (_get_triple_s(src) >> 8) ^ 0x8000; goto GET16_END;
-get16_123_12_20: sample = _get_triple(src) >> 4; goto GET16_END;
-get16_123_92_20: sample = (_get_triple(src) >> 4) ^ 0x8000; goto GET16_END;
-get16_123_32_20: sample = _get_triple_s(src) >> 4; goto GET16_END;
-get16_123_B2_20: sample = (_get_triple_s(src) >> 4) ^ 0x8000; goto GET16_END;
-get16_123_12_18: sample = _get_triple(src) >> 2; goto GET16_END;
-get16_123_92_18: sample = (_get_triple(src) >> 2) ^ 0x8000; goto GET16_END;
-get16_123_32_18: sample = _get_triple_s(src) >> 2; goto GET16_END;
-get16_123_B2_18: sample = (_get_triple_s(src) >> 2) ^ 0x8000; goto GET16_END;
+ case 20: /* 24h -> 16h */ return _get_triple(src) >> 8;
+ case 21: /* 24h ^> 16h */ return (_get_triple(src) >> 8) ^ 0x8000;
+ case 22: /* 24s -> 16h */ return _get_triple_s(src) >> 8;
+ case 23: /* 24s ^> 16h */ return (_get_triple_s(src) >> 8) ^ 0x8000;
+ case 24: /* 20h -> 16h */ return _get_triple(src) >> 4;
+ case 25: /* 20h ^> 16h */ return (_get_triple(src) >> 4) ^ 0x8000;
+ case 26: /* 20s -> 16h */ return _get_triple_s(src) >> 4;
+ case 27: /* 20s ^> 16h */ return (_get_triple_s(src) >> 4) ^ 0x8000;
+ case 28: /* 18h -> 16h */ return _get_triple(src) >> 2;
+ case 29: /* 18h ^> 16h */ return (_get_triple(src) >> 2) ^ 0x8000;
+ case 30: /* 18s -> 16h */ return _get_triple_s(src) >> 2;
+ case 31: /* 18s ^> 16h */ return (_get_triple_s(src) >> 2) ^ 0x8000;
+ default: assert(0);
+ }
}
-#endif
-#ifdef PUT16_LABELS
-/* dst_wid dst_endswap sign_toggle */
-static void *const put16_labels[5 * 2 * 2 + 4 * 3] = {
- &&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 */
+static inline void put16(char *dst, int16_t sample, unsigned int idx)
+{
+ switch (idx) {
+ case 0: /* 16h -> 8h */
+ case 2: /* 16h -> 8s */ as_u8(dst) = sample >> 8; break;
+ case 1: /* 16h ^> 8h */
+ case 3: /* 16h ^> 8s */ as_u8(dst) = (sample >> 8) ^ 0x80; break;
+ case 4: /* 16h -> 16h */ as_u16(dst) = sample; break;
+ case 5: /* 16h ^> 16h */ as_u16(dst) = sample ^ 0x8000; break;
+ case 6: /* 16h -> 16s */ as_u16(dst) = bswap_16(sample); break;
+ case 7: /* 16h ^> 16s */ as_u16(dst) = bswap_16(sample) ^ 0x80; break;
/* 4 byte formats */
- &&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 */
- &&put16_12_0120_20, /* 16h -> 20h */
- &&put16_12_0920_20, /* 16h ^> 20h */
- &&put16_12_0210_20, /* 16h -> 20s */
- &&put16_12_0290_20, /* 16h ^> 20s */
+ case 8: /* 16h -> 24h */ as_u32(dst) = sx24((uint32_t)sample << 8); break;
+ case 9: /* 16h ^> 24h */ as_u32(dst) = sx24((uint32_t)(sample ^ 0x8000) << 8); break;
+ case 10: /* 16h -> 24s */ as_u32(dst) = sx24s((uint32_t)bswap_16(sample) << 8); break;
+ case 11: /* 16h ^> 24s */ as_u32(dst) = sx24s((uint32_t)(bswap_16(sample) ^ 0x80) << 8); break;
+ case 12: /* 16h -> 32h */ as_u32(dst) = (uint32_t)sample << 16; break;
+ case 13: /* 16h ^> 32h */ as_u32(dst) = (uint32_t)(sample ^ 0x8000) << 16; break;
+ case 14: /* 16h -> 32s */ as_u32(dst) = (uint32_t)bswap_16(sample); break;
+ case 15: /* 16h ^> 32s */ as_u32(dst) = (uint32_t)bswap_16(sample) ^ 0x80; break;
+ case 16: /* 16h -> 20h */ as_u32(dst) = sx20((uint32_t)sample << 4); break;
+ case 17: /* 16h ^> 20h */ as_u32(dst) = sx20((uint32_t)(sample ^ 0x8000) << 4); break;
+ case 18: /* 16h -> 20s */ as_u32(dst) = bswap_32(sx20((uint32_t)sample << 4)); break;
+ case 19: /* 16h ^> 20s */ as_u32(dst) = bswap_32(sx20((uint32_t)(sample ^ 0x8000) << 4)); break;
/* 3bytes format */
- &&put16_12_120, /* 16h -> 24h */
- &&put16_12_920, /* 16h ^> 24h */
- &&put16_12_021, /* 16h -> 24s */
- &&put16_12_029, /* 16h ^> 24s */
- &&put16_12_120_20, /* 16h -> 20h */
- &&put16_12_920_20, /* 16h ^> 20h */
- &&put16_12_021_20, /* 16h -> 20s */
- &&put16_12_029_20, /* 16h ^> 20s */
- &&put16_12_120_18, /* 16h -> 18h */
- &&put16_12_920_18, /* 16h ^> 18h */
- &&put16_12_021_18, /* 16h -> 18s */
- &&put16_12_029_18, /* 16h ^> 18s */
-};
-#endif
-
-#ifdef PUT16_END
-while (0) {
-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) = sx24((uint32_t)sample << 8); goto PUT16_END;
-put16_12_0920: as_u32(dst) = sx24((uint32_t)(sample ^ 0x8000) << 8); goto PUT16_END;
-put16_12_0210: as_u32(dst) = sx24s((uint32_t)bswap_16(sample) << 8); goto PUT16_END;
-put16_12_0290: as_u32(dst) = sx24s((uint32_t)(bswap_16(sample) ^ 0x80) << 8); goto PUT16_END;
-put16_12_1200: as_u32(dst) = (uint32_t)sample << 16; goto PUT16_END;
-put16_12_9200: as_u32(dst) = (uint32_t)(sample ^ 0x8000) << 16; goto PUT16_END;
-put16_12_0021: as_u32(dst) = (uint32_t)bswap_16(sample); goto PUT16_END;
-put16_12_0029: as_u32(dst) = (uint32_t)bswap_16(sample) ^ 0x80; goto PUT16_END;
-put16_12_0120_20: as_u32(dst) = sx20((uint32_t)sample << 4); goto PUT16_END;
-put16_12_0920_20: as_u32(dst) = sx20((uint32_t)(sample ^ 0x8000) << 4); goto PUT16_END;
-put16_12_0210_20: as_u32(dst) = bswap_32(sx20((uint32_t)sample << 4)); goto PUT16_END;
-put16_12_0290_20: as_u32(dst) = bswap_32(sx20((uint32_t)(sample ^ 0x8000) << 4)); goto PUT16_END;
-put16_12_120: _put_triple(dst, (uint32_t)sample << 8); goto PUT16_END;
-put16_12_920: _put_triple(dst, (uint32_t)(sample ^ 0x8000) << 8); goto PUT16_END;
-put16_12_021: _put_triple_s(dst, (uint32_t)sample << 8); goto PUT16_END;
-put16_12_029: _put_triple_s(dst, (uint32_t)(sample ^ 0x8000) << 8); goto PUT16_END;
-put16_12_120_20: _put_triple(dst, (uint32_t)sample << 4); goto PUT16_END;
-put16_12_920_20: _put_triple(dst, (uint32_t)(sample ^ 0x8000) << 4); goto PUT16_END;
-put16_12_021_20: _put_triple_s(dst, (uint32_t)sample << 4); goto PUT16_END;
-put16_12_029_20: _put_triple_s(dst, (uint32_t)(sample ^ 0x8000) << 4); goto PUT16_END;
-put16_12_120_18: _put_triple(dst, (uint32_t)sample << 2); goto PUT16_END;
-put16_12_920_18: _put_triple(dst, (uint32_t)(sample ^ 0x8000) << 2); goto PUT16_END;
-put16_12_021_18: _put_triple_s(dst, (uint32_t)sample << 2); goto PUT16_END;
-put16_12_029_18: _put_triple_s(dst, (uint32_t)(sample ^ 0x8000) << 2); goto PUT16_END;
+ case 20: /* 16h -> 24h */ _put_triple(dst, (uint32_t)sample << 8); break;
+ case 21: /* 16h ^> 24h */ _put_triple(dst, (uint32_t)(sample ^ 0x8000) << 8); break;
+ case 22: /* 16h -> 24s */ _put_triple_s(dst, (uint32_t)sample << 8); break;
+ case 23: /* 16h ^> 24s */ _put_triple_s(dst, (uint32_t)(sample ^ 0x8000) << 8); break;
+ case 24: /* 16h -> 20h */ _put_triple(dst, (uint32_t)sample << 4); break;
+ case 25: /* 16h ^> 20h */ _put_triple(dst, (uint32_t)(sample ^ 0x8000) << 4); break;
+ case 26: /* 16h -> 20s */ _put_triple_s(dst, (uint32_t)sample << 4); break;
+ case 27: /* 16h ^> 20s */ _put_triple_s(dst, (uint32_t)(sample ^ 0x8000) << 4); break;
+ case 28: /* 16h -> 18h */ _put_triple(dst, (uint32_t)sample << 2); break;
+ case 29: /* 16h ^> 18h */ _put_triple(dst, (uint32_t)(sample ^ 0x8000) << 2); break;
+ case 30: /* 16h -> 18s */ _put_triple_s(dst, (uint32_t)sample << 2); break;
+ case 31: /* 16h ^> 18s */ _put_triple_s(dst, (uint32_t)(sample ^ 0x8000) << 2); break;
+ default: assert(0);
+ }
}
-#endif
-
-#ifdef CONV24_LABELS
-#define GET32_LABELS
-#define PUT32_LABELS
-#endif
-#ifdef GET32_LABELS
-/* src_wid src_endswap sign_toggle */
-static void *const get32_labels[5 * 2 * 2 + 4 * 3] = {
- &&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 */
+static inline int32_t get32(const char *src, unsigned int idx)
+{
+ switch (idx) {
+ case 0: /* 8h -> 32h */
+ case 2: /* 8s -> 32h */ return (uint32_t)as_u8c(src) << 24;
+ case 1: /* 8h ^> 32h */
+ case 3: /* 8s ^> 32h */ return (uint32_t)(as_u8c(src) ^ 0x80) << 24;
+ case 4: /* 16h -> 32h */ return (uint32_t)as_u16c(src) << 16;
+ case 5: /* 16h ^> 32h */ return (uint32_t)(as_u16c(src) ^ 0x8000) << 16;
+ case 6: /* 16s -> 32h */ return (uint32_t)bswap_16(as_u16c(src)) << 16;
+ case 7: /* 16s ^> 32h */ return (uint32_t)bswap_16(as_u16c(src) ^ 0x80) << 16;
/* 4 byte formats */
- &&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 */
- &&get32_1234_C321, /* 32s ^> 32h */
- &&get32_0123_1230_20, /* 20h -> 32h */
- &&get32_0123_9230_20, /* 20h ^> 32h */
- &&get32_1230_3210_20, /* 20s -> 32h */
- &&get32_1230_B210_20, /* 20s ^> 32h */
+ case 8: /* 24h -> 32h */ return as_u32c(src) << 8;
+ case 9: /* 24h ^> 32h */ return (as_u32c(src) << 8) ^ 0x80000000;
+ case 10: /* 24s -> 32h */ return bswap_32(as_u32c(src) >> 8);
+ case 11: /* 24s ^> 32h */ return bswap_32((as_u32c(src) >> 8) ^ 0x80);
+ case 12: /* 32h -> 32h */ return as_u32c(src);
+ case 13: /* 32h ^> 32h */ return as_u32c(src) ^ 0x80000000;
+ case 14: /* 32s -> 32h */ return bswap_32(as_u32c(src));
+ case 15: /* 32s ^> 32h */ return bswap_32(as_u32c(src) ^ 0x80);
+ case 16: /* 20h -> 32h */ return as_u32c(src) << 12;
+ case 17: /* 20h ^> 32h */ return (as_u32c(src) << 12) ^ 0x80000000;
+ case 18: /* 20s -> 32h */ return bswap_32(as_u32c(src)) << 12;
+ case 19: /* 20s ^> 32h */ return (bswap_32(as_u32c(src)) << 12) ^ 0x80000000;
/* 3bytes format */
- &&get32_123_1230, /* 24h -> 32h */
- &&get32_123_9230, /* 24h ^> 32h */
- &&get32_123_3210, /* 24s -> 32h */
- &&get32_123_B210, /* 24s ^> 32h */
- &&get32_123_1230_20, /* 20h -> 32h */
- &&get32_123_9230_20, /* 20h ^> 32h */
- &&get32_123_3210_20, /* 20s -> 32h */
- &&get32_123_B210_20, /* 20s ^> 32h */
- &&get32_123_1230_18, /* 18h -> 32h */
- &&get32_123_9230_18, /* 18h ^> 32h */
- &&get32_123_3210_18, /* 18s -> 32h */
- &&get32_123_B210_18, /* 18s ^> 32h */
-};
-#endif
-
-#ifdef CONV24_END
-#define GET32_END __conv24_get
-#endif
-
-#ifdef GET32_END
-while (0) {
-get32_1_1000: sample = (uint32_t)as_u8c(src) << 24; goto GET32_END;
-get32_1_9000: sample = (uint32_t)(as_u8c(src) ^ 0x80) << 24; goto GET32_END;
-get32_12_1200: sample = (uint32_t)as_u16c(src) << 16; goto GET32_END;
-get32_12_9200: sample = (uint32_t)(as_u16c(src) ^ 0x8000) << 16; goto GET32_END;
-get32_12_2100: sample = (uint32_t)bswap_16(as_u16c(src)) << 16; goto GET32_END;
-get32_12_A100: sample = (uint32_t)bswap_16(as_u16c(src) ^ 0x80) << 16; goto GET32_END;
-get32_0123_1230: sample = as_u32c(src) << 8; goto GET32_END;
-get32_0123_9230: sample = (as_u32c(src) << 8) ^ 0x80000000; goto GET32_END;
-get32_1230_3210: sample = bswap_32(as_u32c(src) >> 8); goto GET32_END;
-get32_1230_B210: sample = bswap_32((as_u32c(src) >> 8) ^ 0x80); goto GET32_END;
-get32_1234_1234: sample = as_u32c(src); goto GET32_END;
-get32_1234_9234: sample = as_u32c(src) ^ 0x80000000; goto GET32_END;
-get32_1234_4321: sample = bswap_32(as_u32c(src)); goto GET32_END;
-get32_1234_C321: sample = bswap_32(as_u32c(src) ^ 0x80); goto GET32_END;
-get32_0123_1230_20: sample = as_u32c(src) << 12; goto GET32_END;
-get32_0123_9230_20: sample = (as_u32c(src) << 12) ^ 0x80000000; goto GET32_END;
-get32_1230_3210_20: sample = bswap_32(as_u32c(src)) << 12; goto GET32_END;
-get32_1230_B210_20: sample = (bswap_32(as_u32c(src)) << 12) ^ 0x80000000; goto GET32_END;
-get32_123_1230: sample = _get_triple(src) << 8; goto GET32_END;
-get32_123_9230: sample = (_get_triple(src) << 8) ^ 0x80000000; goto GET32_END;
-get32_123_3210: sample = _get_triple_s(src) << 8; goto GET32_END;
-get32_123_B210: sample = (_get_triple_s(src) << 8) ^ 0x80000000; goto GET32_END;
-get32_123_1230_20: sample = _get_triple(src) << 12; goto GET32_END;
-get32_123_9230_20: sample = (_get_triple(src) << 12) ^ 0x80000000; goto GET32_END;
-get32_123_3210_20: sample = _get_triple_s(src) << 12; goto GET32_END;
-get32_123_B210_20: sample = (_get_triple_s(src) << 12) ^ 0x80000000; goto GET32_END;
-get32_123_1230_18: sample = _get_triple(src) << 14; goto GET32_END;
-get32_123_9230_18: sample = (_get_triple(src) << 14) ^ 0x80000000; goto GET32_END;
-get32_123_3210_18: sample = _get_triple_s(src) << 14; goto GET32_END;
-get32_123_B210_18: sample = (_get_triple_s(src) << 14) ^ 0x80000000; goto GET32_END;
+ case 20: /* 24h -> 32h */ return _get_triple(src) << 8;
+ case 21: /* 24h ^> 32h */ return (_get_triple(src) << 8) ^ 0x80000000;
+ case 22: /* 24s -> 32h */ return _get_triple_s(src) << 8;
+ case 23: /* 24s ^> 32h */ return (_get_triple_s(src) << 8) ^ 0x80000000;
+ case 24: /* 20h -> 32h */ return _get_triple(src) << 12;
+ case 25: /* 20h ^> 32h */ return (_get_triple(src) << 12) ^ 0x80000000;
+ case 26: /* 20s -> 32h */ return _get_triple_s(src) << 12;
+ case 27: /* 20s ^> 32h */ return (_get_triple_s(src) << 12) ^ 0x80000000;
+ case 28: /* 18h -> 32h */ return _get_triple(src) << 14;
+ case 29: /* 18h ^> 32h */ return (_get_triple(src) << 14) ^ 0x80000000;
+ case 30: /* 18s -> 32h */ return _get_triple_s(src) << 14;
+ case 31: /* 18s ^> 32h */ return (_get_triple_s(src) << 14) ^ 0x80000000;
+ default: assert(0);
+ }
}
-#endif
-#ifdef CONV24_END
-__conv24_get: goto *put;
-#define PUT32_END CONV24_END
-#endif
-
-#ifdef PUT32_LABELS
-/* dst_wid dst_endswap sign_toggle */
-static void *const put32_labels[5 * 2 * 2 + 4 * 3] = {
- &&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 */
+static inline void put32(char *dst, int32_t sample, unsigned int idx)
+{
+ switch (idx) {
+ case 0: /* 32h -> 8h */
+ case 2: /* 32h -> 8s */ as_u8(dst) = sample >> 24; break;
+ case 1: /* 32h ^> 8h */
+ case 3: /* 32h ^> 8s */ as_u8(dst) = (sample >> 24) ^ 0x80; break;
+ case 4: /* 32h -> 16h */ as_u16(dst) = sample >> 16; break;
+ case 5: /* 32h ^> 16h */ as_u16(dst) = (sample >> 16) ^ 0x8000; break;
+ case 6: /* 32h -> 16s */ as_u16(dst) = bswap_16(sample >> 16); break;
+ case 7: /* 32h ^> 16s */ as_u16(dst) = bswap_16(sample >> 16) ^ 0x80; break;
/* 4 byte formats */
- &&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 */
- &&put32_1234_0123_20, /* 32h -> 20h */
- &&put32_1234_0923_20, /* 32h ^> 20h */
- &&put32_1234_3210_20, /* 32h -> 20s */
- &&put32_1234_3290_20, /* 32h ^> 20s */
+ case 8: /* 32h -> 24h */ as_u32(dst) = sx24(sample >> 8); break;
+ case 9: /* 32h ^> 24h */ as_u32(dst) = sx24((sample >> 8) ^ 0x800000); break;
+ case 10: /* 32h -> 24s */ as_u32(dst) = sx24s(bswap_32(sample) << 8); break;
+ case 11: /* 32h ^> 24s */ as_u32(dst) = sx24s((bswap_32(sample) ^ 0x80) << 8); break;
+ case 12: /* 32h -> 32h */ as_u32(dst) = sample; break;
+ case 13: /* 32h ^> 32h */ as_u32(dst) = sample ^ 0x80000000; break;
+ case 14: /* 32h -> 32s */ as_u32(dst) = bswap_32(sample); break;
+ case 15: /* 32h ^> 32s */ as_u32(dst) = bswap_32(sample) ^ 0x80; break;
+ case 16: /* 32h -> 20h */ as_u32(dst) = sx20(sample >> 12); break;
+ case 17: /* 32h ^> 20h */ as_u32(dst) = sx20((sample ^ 0x80000000) >> 12); break;
+ case 18: /* 32h -> 20s */ as_u32(dst) = bswap_32(sx20(sample >> 12)); break;
+ case 19: /* 32h ^> 20s */ as_u32(dst) = bswap_32(sx20((sample ^ 0x80000000) >> 12)); break;
/* 3bytes format */
- &&put32_1234_123, /* 32h -> 24h */
- &&put32_1234_923, /* 32h ^> 24h */
- &&put32_1234_321, /* 32h -> 24s */
- &&put32_1234_329, /* 32h ^> 24s */
- &&put32_1234_123_20, /* 32h -> 20h */
- &&put32_1234_923_20, /* 32h ^> 20h */
- &&put32_1234_321_20, /* 32h -> 20s */
- &&put32_1234_329_20, /* 32h ^> 20s */
- &&put32_1234_123_18, /* 32h -> 18h */
- &&put32_1234_923_18, /* 32h ^> 18h */
- &&put32_1234_321_18, /* 32h -> 18s */
- &&put32_1234_329_18, /* 32h ^> 18s */
-};
-#endif
-
-#ifdef CONV24_LABELS
-#undef GET32_LABELS
-#undef PUT32_LABELS
-#endif
-
-#ifdef PUT32_END
-while (0) {
-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) = sx24(sample >> 8); goto PUT32_END;
-put32_1234_0923: as_u32(dst) = sx24((sample >> 8) ^ 0x800000); goto PUT32_END;
-put32_1234_3210: as_u32(dst) = sx24s(bswap_32(sample) << 8); goto PUT32_END;
-put32_1234_3290: as_u32(dst) = sx24s((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;
-put32_1234_0123_20: as_u32(dst) = sx20(sample >> 12); goto PUT32_END;
-put32_1234_0923_20: as_u32(dst) = sx20((sample ^ 0x80000000) >> 12); goto PUT32_END;
-put32_1234_3210_20: as_u32(dst) = bswap_32(sx20(sample >> 12)); goto PUT32_END;
-put32_1234_3290_20: as_u32(dst) = bswap_32(sx20((sample ^ 0x80000000) >> 12)); goto PUT32_END;
-put32_1234_123: _put_triple(dst, sample >> 8); goto PUT32_END;
-put32_1234_923: _put_triple(dst, (sample ^ 0x80000000) >> 8); goto PUT32_END;
-put32_1234_321: _put_triple_s(dst, sample >> 8); goto PUT32_END;
-put32_1234_329: _put_triple_s(dst, (sample ^ 0x80000000) >> 8); goto PUT32_END;
-put32_1234_123_20: _put_triple(dst, sample >> 12); goto PUT32_END;
-put32_1234_923_20: _put_triple(dst, (sample ^ 0x80000000) >> 12); goto PUT32_END;
-put32_1234_321_20: _put_triple_s(dst, sample >> 12); goto PUT32_END;
-put32_1234_329_20: _put_triple_s(dst, (sample ^ 0x80000000) >> 12); goto PUT32_END;
-put32_1234_123_18: _put_triple(dst, sample >> 14); goto PUT32_END;
-put32_1234_923_18: _put_triple(dst, (sample ^ 0x80000000) >> 14); goto PUT32_END;
-put32_1234_321_18: _put_triple_s(dst, sample >> 14); goto PUT32_END;
-put32_1234_329_18: _put_triple_s(dst, (sample ^ 0x80000000) >> 14); goto PUT32_END;
+ case 20: /* 32h -> 24h */ _put_triple(dst, sample >> 8); break;
+ case 21: /* 32h ^> 24h */ _put_triple(dst, (sample ^ 0x80000000) >> 8); break;
+ case 22: /* 32h -> 24s */ _put_triple_s(dst, sample >> 8); break;
+ case 23: /* 32h ^> 24s */ _put_triple_s(dst, (sample ^ 0x80000000) >> 8); break;
+ case 24: /* 32h -> 20h */ _put_triple(dst, sample >> 12); break;
+ case 25: /* 32h ^> 20h */ _put_triple(dst, (sample ^ 0x80000000) >> 12); break;
+ case 26: /* 32h -> 20s */ _put_triple_s(dst, sample >> 12); break;
+ case 27: /* 32h ^> 20s */ _put_triple_s(dst, (sample ^ 0x80000000) >> 12); break;
+ case 28: /* 32h -> 18h */ _put_triple(dst, sample >> 14); break;
+ case 29: /* 32h ^> 18h */ _put_triple(dst, (sample ^ 0x80000000) >> 14); break;
+ case 30: /* 32h -> 18s */ _put_triple_s(dst, sample >> 14); break;
+ case 31: /* 32h ^> 18s */ _put_triple_s(dst, (sample ^ 0x80000000) >> 14); break;
+ default: assert(0);
+ }
}
-#endif
-
-#ifdef CONV24_END
-#undef GET32_END
-#undef PUT32_END
-#endif
-#ifdef PUT32F_LABELS
-/* type (0 = float, 1 = float64), endswap */
-static void *const put32float_labels[2 * 2] = {
- &&put32f_1234_1234F, /* 32h -> (float)h */
- &&put32f_1234_4321F, /* 32h -> (float)s */
- &&put32f_1234_1234D, /* 32h -> (float64)h */
- &&put32f_1234_4321D, /* 32h -> (float64)s */
-};
-#endif
+static inline void put32float(char *dst, int32_t sample, unsigned int idx)
+{
+ snd_tmp_float_t tmp_float;
+ snd_tmp_double_t tmp_double;
-#ifdef PUT32F_END
-put32f_1234_1234F: as_float(dst) = (float_t)((int32_t)sample) / (float_t)0x80000000UL; goto PUT32F_END;
-put32f_1234_4321F: tmp_float.f = (float_t)((int32_t)sample) / (float_t)0x80000000UL;
- as_u32(dst) = bswap_32(tmp_float.i); goto PUT32F_END;
-put32f_1234_1234D: as_double(dst) = (double_t)((int32_t)sample) / (double_t)0x80000000UL; goto PUT32F_END;
-put32f_1234_4321D: tmp_double.d = (double_t)((int32_t)sample) / (double_t)0x80000000UL;
- as_u64(dst) = bswap_64(tmp_double.l); goto PUT32F_END;
-#endif
+ switch (idx) {
+ case 0: /* 32h -> (float)h */
+ as_float(dst) = (float_t)((int32_t)sample) / (float_t)0x80000000UL; break;
+ case 1: /* 32h -> (float)s */
+ tmp_float.f = (float_t)((int32_t)sample) / (float_t)0x80000000UL;
+ as_u32(dst) = bswap_32(tmp_float.i); break;
+ case 2: /* 32h -> (float64)h */
+ as_double(dst) = (double_t)((int32_t)sample) / (double_t)0x80000000UL; break;
+ case 3: /* 32h -> (float64)s */
+ tmp_double.d = (double_t)((int32_t)sample) / (double_t)0x80000000UL;
+ as_u64(dst) = bswap_64(tmp_double.l); break;
+ default: assert(0);
+ }
+}
-#ifdef GET32F_LABELS
-/* type (0 = float, 1 = float64), endswap */
-static void *const get32float_labels[2 * 2] = {
- &&get32f_1234F_1234, /* (float)h -> 32h */
- &&get32f_4321F_1234, /* (float)s -> 32h */
- &&get32f_1234D_1234, /* (float64)h -> 32h */
- &&get32f_4321D_1234, /* (float64)s -> 32h */
-};
-#endif
+static inline int32_t get32float(const char *src, unsigned int idx)
+{
+ snd_tmp_float_t tmp_float;
+ snd_tmp_double_t tmp_double;
-#ifdef GET32F_END
-get32f_1234F_1234: tmp_float.f = as_floatc(src);
- if (tmp_float.f >= 1.0)
- sample = 0x7fffffff;
- else if (tmp_float.f <= -1.0)
- sample = 0x80000000;
- else
- sample = (int32_t)(tmp_float.f * (float_t)0x80000000UL);
- goto GET32F_END;
-get32f_4321F_1234: tmp_float.i = bswap_32(as_u32c(src));
- if (tmp_float.f >= 1.0)
- sample = 0x7fffffff;
- else if (tmp_float.f <= -1.0)
- sample = 0x80000000;
- else
- sample = (int32_t)(tmp_float.f * (float_t)0x80000000UL);
- goto GET32F_END;
-get32f_1234D_1234: tmp_double.d = as_doublec(src);
- if (tmp_double.d >= 1.0)
- sample = 0x7fffffff;
- else if (tmp_double.d <= -1.0)
- sample = 0x80000000;
- else
- sample = (int32_t)(tmp_double.d * (double_t)0x80000000UL);
- goto GET32F_END;
-get32f_4321D_1234: tmp_double.l = bswap_64(as_u64c(src));
- if (tmp_double.d >= 1.0)
- sample = 0x7fffffff;
- else if (tmp_double.d <= -1.0)
- sample = 0x80000000;
- else
- sample = (int32_t)(tmp_double.d * (double_t)0x80000000UL);
- goto GET32F_END;
-#endif
+ switch (idx) {
+ case 0: /* (float)h -> 32h */
+ tmp_float.f = as_floatc(src);
+ if (tmp_float.f >= 1.0)
+ return 0x7fffffff;
+ if (tmp_float.f <= -1.0)
+ return 0x80000000;
+ return (int32_t)(tmp_float.f * (float_t)0x80000000UL);
+ case 1: /* (float)s -> 32h */
+ tmp_float.i = bswap_32(as_u32c(src));
+ if (tmp_float.f >= 1.0)
+ return 0x7fffffff;
+ if (tmp_float.f <= -1.0)
+ return 0x80000000;
+ return (int32_t)(tmp_float.f * (float_t)0x80000000UL);
+ case 2: /* (float64)h -> 32h */
+ tmp_double.d = as_doublec(src);
+ if (tmp_double.d >= 1.0)
+ return 0x7fffffff;
+ if (tmp_double.d <= -1.0)
+ return 0x80000000;
+ return (int32_t)(tmp_double.d * (double_t)0x80000000UL);
+ case 3: /* (float64)s -> 32h */
+ tmp_double.l = bswap_64(as_u64c(src));
+ if (tmp_double.d >= 1.0)
+ return 0x7fffffff;
+ if (tmp_double.d <= -1.0)
+ return 0x80000000;
+ return (int32_t)(tmp_double.d * (double_t)0x80000000UL);
+ default: assert(0);
+ }
+}
#undef as_u8
#undef as_u16
--
2.44.0