1From 33cc8c8e77a2282c11601a8a1e14fb2e856af0dc Mon Sep 17 00:00:00 2001
2From: Michael Forney <mforney@mforney.org>
3Date: Fri, 31 May 2019 17:47:08 -0700
4Subject: [PATCH] Use switch statements instead of labels as values
5
6---
7 src/pcm/pcm_adpcm.c | 20 +-
8 src/pcm/pcm_alaw.c | 20 +-
9 src/pcm/pcm_iec958.c | 22 +-
10 src/pcm/pcm_lfloat.c | 42 +-
11 src/pcm/pcm_linear.c | 22 +-
12 src/pcm/pcm_mulaw.c | 20 +-
13 src/pcm/pcm_rate_linear.c | 42 +-
14 src/pcm/pcm_route.c | 163 +++----
15 src/pcm/plugin_ops.h | 937 ++++++++++++++------------------------
16 9 files changed, 412 insertions(+), 876 deletions(-)
17
18diff --git a/src/pcm/pcm_adpcm.c b/src/pcm/pcm_adpcm.c
19index fd9b9e8e..d4546cd0 100644
20--- a/src/pcm/pcm_adpcm.c
21+++ b/src/pcm/pcm_adpcm.c
22@@ -220,10 +220,6 @@ void snd_pcm_adpcm_decode(const snd_pcm_channel_area_t *dst_areas,
23 unsigned int putidx,
24 snd_pcm_adpcm_state_t *states)
25 {
26-#define PUT16_LABELS
27-#include "plugin_ops.h"
28-#undef PUT16_LABELS
29- void *put = put16_labels[putidx];
30 unsigned int channel;
31 for (channel = 0; channel < channels; ++channel, ++states) {
32 const char *src;
33@@ -249,11 +245,7 @@ void snd_pcm_adpcm_decode(const snd_pcm_channel_area_t *dst_areas,
34 else
35 v = (*src >> 4) & 0x0f;
36 sample = adpcm_decoder(v, states);
37- goto *put;
38-#define PUT16_END after
39-#include "plugin_ops.h"
40-#undef PUT16_END
41- after:
42+ put16(dst, sample, putidx);
43 src += src_step;
44 srcbit += srcbit_step;
45 if (srcbit == 8) {
46@@ -273,10 +265,6 @@ void snd_pcm_adpcm_encode(const snd_pcm_channel_area_t *dst_areas,
47 unsigned int getidx,
48 snd_pcm_adpcm_state_t *states)
49 {
50-#define GET16_LABELS
51-#include "plugin_ops.h"
52-#undef GET16_LABELS
53- void *get = get16_labels[getidx];
54 unsigned int channel;
55 int16_t sample = 0;
56 for (channel = 0; channel < channels; ++channel, ++states) {
57@@ -297,11 +285,7 @@ void snd_pcm_adpcm_encode(const snd_pcm_channel_area_t *dst_areas,
58 frames1 = frames;
59 while (frames1-- > 0) {
60 int v;
61- goto *get;
62-#define GET16_END after
63-#include "plugin_ops.h"
64-#undef GET16_END
65- after:
66+ sample = get16(src, getidx);
67 v = adpcm_encoder(sample, states);
68 if (dstbit)
69 *dst = (*dst & 0xf0) | v;
70diff --git a/src/pcm/pcm_alaw.c b/src/pcm/pcm_alaw.c
71index 0a889183..f24e6351 100644
72--- a/src/pcm/pcm_alaw.c
73+++ b/src/pcm/pcm_alaw.c
74@@ -148,10 +148,6 @@ void snd_pcm_alaw_decode(const snd_pcm_channel_area_t *dst_areas,
75 unsigned int channels, snd_pcm_uframes_t frames,
76 unsigned int putidx)
77 {
78-#define PUT16_LABELS
79-#include "plugin_ops.h"
80-#undef PUT16_LABELS
81- void *put = put16_labels[putidx];
82 unsigned int channel;
83 for (channel = 0; channel < channels; ++channel) {
84 const unsigned char *src;
85@@ -167,11 +163,7 @@ void snd_pcm_alaw_decode(const snd_pcm_channel_area_t *dst_areas,
86 frames1 = frames;
87 while (frames1-- > 0) {
88 int16_t sample = alaw_to_s16(*src);
89- goto *put;
90-#define PUT16_END after
91-#include "plugin_ops.h"
92-#undef PUT16_END
93- after:
94+ put16(dst, sample, putidx);
95 src += src_step;
96 dst += dst_step;
97 }
98@@ -185,10 +177,6 @@ void snd_pcm_alaw_encode(const snd_pcm_channel_area_t *dst_areas,
99 unsigned int channels, snd_pcm_uframes_t frames,
100 unsigned int getidx)
101 {
102-#define GET16_LABELS
103-#include "plugin_ops.h"
104-#undef GET16_LABELS
105- void *get = get16_labels[getidx];
106 unsigned int channel;
107 int16_t sample = 0;
108 for (channel = 0; channel < channels; ++channel) {
109@@ -204,11 +192,7 @@ void snd_pcm_alaw_encode(const snd_pcm_channel_area_t *dst_areas,
110 dst_step = snd_pcm_channel_area_step(dst_area);
111 frames1 = frames;
112 while (frames1-- > 0) {
113- goto *get;
114-#define GET16_END after
115-#include "plugin_ops.h"
116-#undef GET16_END
117- after:
118+ sample = get16(src, getidx);
119 *dst = s16_to_alaw(sample);
120 src += src_step;
121 dst += dst_step;
122diff --git a/src/pcm/pcm_iec958.c b/src/pcm/pcm_iec958.c
123index 1afe7393..8f1cd9e9 100644
124--- a/src/pcm/pcm_iec958.c
125+++ b/src/pcm/pcm_iec958.c
126@@ -149,11 +149,8 @@ static void snd_pcm_iec958_decode(snd_pcm_iec958_t *iec,
127 snd_pcm_uframes_t src_offset,
128 unsigned int channels, snd_pcm_uframes_t frames)
129 {
130-#define PUT32_LABELS
131-#include "plugin_ops.h"
132-#undef PUT32_LABELS
133- void *put = put32_labels[iec->getput_idx];
134 unsigned int channel;
135+ unsigned int idx = iec->getput_idx;
136 for (channel = 0; channel < channels; ++channel) {
137 const uint32_t *src;
138 char *dst;
139@@ -168,11 +165,7 @@ static void snd_pcm_iec958_decode(snd_pcm_iec958_t *iec,
140 frames1 = frames;
141 while (frames1-- > 0) {
142 int32_t sample = iec958_to_s32(iec, *src);
143- goto *put;
144-#define PUT32_END after
145-#include "plugin_ops.h"
146-#undef PUT32_END
147- after:
148+ put32(dst, sample, idx);
149 src += src_step;
150 dst += dst_step;
151 }
152@@ -186,10 +179,6 @@ static void snd_pcm_iec958_encode(snd_pcm_iec958_t *iec,
153 snd_pcm_uframes_t src_offset,
154 unsigned int channels, snd_pcm_uframes_t frames)
155 {
156-#define GET32_LABELS
157-#include "plugin_ops.h"
158-#undef GET32_LABELS
159- void *get = get32_labels[iec->getput_idx];
160 unsigned int channel;
161 int32_t sample = 0;
162 int counter = iec->counter;
163@@ -197,6 +186,7 @@ static void snd_pcm_iec958_encode(snd_pcm_iec958_t *iec,
164 (iec->status[0] & IEC958_AES0_NONAUDIO) &&
165 (channels == 8);
166 int counter_step = single_stream ? ((channels + 1) >> 1) : 1;
167+ unsigned int idx = iec->getput_idx;
168 for (channel = 0; channel < channels; ++channel) {
169 const char *src;
170 uint32_t *dst;
171@@ -216,11 +206,7 @@ static void snd_pcm_iec958_encode(snd_pcm_iec958_t *iec,
172 iec->counter = counter;
173
174 while (frames1-- > 0) {
175- goto *get;
176-#define GET32_END after
177-#include "plugin_ops.h"
178-#undef GET32_END
179- after:
180+ sample = get32(src, idx);
181 sample = iec958_subframe(iec, sample, channel);
182 // fprintf(stderr, "%d:%08x\n", frames1, sample);
183 *dst = sample;
184diff --git a/src/pcm/pcm_lfloat.c b/src/pcm/pcm_lfloat.c
185index 7785e4b9..c2e07a57 100644
186--- a/src/pcm/pcm_lfloat.c
187+++ b/src/pcm/pcm_lfloat.c
188@@ -97,13 +97,6 @@ void snd_pcm_lfloat_convert_integer_float(const snd_pcm_channel_area_t *dst_area
189 unsigned int channels, snd_pcm_uframes_t frames,
190 unsigned int get32idx, unsigned int put32floatidx)
191 {
192-#define GET32_LABELS
193-#define PUT32F_LABELS
194-#include "plugin_ops.h"
195-#undef PUT32F_LABELS
196-#undef GET32_LABELS
197- void *get32 = get32_labels[get32idx];
198- void *put32float = put32float_labels[put32floatidx];
199 unsigned int channel;
200 for (channel = 0; channel < channels; ++channel) {
201 const char *src;
202@@ -111,8 +104,6 @@ void snd_pcm_lfloat_convert_integer_float(const snd_pcm_channel_area_t *dst_area
203 int src_step, dst_step;
204 snd_pcm_uframes_t frames1;
205 int32_t sample = 0;
206- snd_tmp_float_t tmp_float;
207- snd_tmp_double_t tmp_double;
208 const snd_pcm_channel_area_t *src_area = &src_areas[channel];
209 const snd_pcm_channel_area_t *dst_area = &dst_areas[channel];
210 src = snd_pcm_channel_area_addr(src_area, src_offset);
211@@ -121,16 +112,8 @@ void snd_pcm_lfloat_convert_integer_float(const snd_pcm_channel_area_t *dst_area
212 dst_step = snd_pcm_channel_area_step(dst_area);
213 frames1 = frames;
214 while (frames1-- > 0) {
215- goto *get32;
216-#define GET32_END sample_loaded
217-#include "plugin_ops.h"
218-#undef GET32_END
219- sample_loaded:
220- goto *put32float;
221-#define PUT32F_END sample_put
222-#include "plugin_ops.h"
223-#undef PUT32F_END
224- sample_put:
225+ sample = get32(src, get32idx);
226+ put32float(dst, sample, put32floatidx);
227 src += src_step;
228 dst += dst_step;
229 }
230@@ -142,13 +125,6 @@ void snd_pcm_lfloat_convert_float_integer(const snd_pcm_channel_area_t *dst_area
231 unsigned int channels, snd_pcm_uframes_t frames,
232 unsigned int put32idx, unsigned int get32floatidx)
233 {
234-#define PUT32_LABELS
235-#define GET32F_LABELS
236-#include "plugin_ops.h"
237-#undef GET32F_LABELS
238-#undef PUT32_LABELS
239- void *put32 = put32_labels[put32idx];
240- void *get32float = get32float_labels[get32floatidx];
241 unsigned int channel;
242 for (channel = 0; channel < channels; ++channel) {
243 const char *src;
244@@ -156,8 +132,6 @@ void snd_pcm_lfloat_convert_float_integer(const snd_pcm_channel_area_t *dst_area
245 int src_step, dst_step;
246 snd_pcm_uframes_t frames1;
247 int32_t sample = 0;
248- snd_tmp_float_t tmp_float;
249- snd_tmp_double_t tmp_double;
250 const snd_pcm_channel_area_t *src_area = &src_areas[channel];
251 const snd_pcm_channel_area_t *dst_area = &dst_areas[channel];
252 src = snd_pcm_channel_area_addr(src_area, src_offset);
253@@ -166,16 +140,8 @@ void snd_pcm_lfloat_convert_float_integer(const snd_pcm_channel_area_t *dst_area
254 dst_step = snd_pcm_channel_area_step(dst_area);
255 frames1 = frames;
256 while (frames1-- > 0) {
257- goto *get32float;
258-#define GET32F_END sample_loaded
259-#include "plugin_ops.h"
260-#undef GET32F_END
261- sample_loaded:
262- goto *put32;
263-#define PUT32_END sample_put
264-#include "plugin_ops.h"
265-#undef PUT32_END
266- sample_put:
267+ sample = get32float(src, get32floatidx);
268+ put32(dst, sample, put32idx);
269 src += src_step;
270 dst += dst_step;
271 }
272diff --git a/src/pcm/pcm_linear.c b/src/pcm/pcm_linear.c
273index c95d1b95..bc8c7aa8 100644
274--- a/src/pcm/pcm_linear.c
275+++ b/src/pcm/pcm_linear.c
276@@ -148,10 +148,6 @@ void snd_pcm_linear_convert(const snd_pcm_channel_area_t *dst_areas, snd_pcm_ufr
277 unsigned int channels, snd_pcm_uframes_t frames,
278 unsigned int convidx)
279 {
280-#define CONV_LABELS
281-#include "plugin_ops.h"
282-#undef CONV_LABELS
283- void *conv = conv_labels[convidx];
284 unsigned int channel;
285 for (channel = 0; channel < channels; ++channel) {
286 const char *src;
287@@ -166,11 +162,7 @@ void snd_pcm_linear_convert(const snd_pcm_channel_area_t *dst_areas, snd_pcm_ufr
288 dst_step = snd_pcm_channel_area_step(dst_area);
289 frames1 = frames;
290 while (frames1-- > 0) {
291- goto *conv;
292-#define CONV_END after
293-#include "plugin_ops.h"
294-#undef CONV_END
295- after:
296+ conv(dst, src, convidx);
297 src += src_step;
298 dst += dst_step;
299 }
300@@ -182,11 +174,6 @@ void snd_pcm_linear_getput(const snd_pcm_channel_area_t *dst_areas, snd_pcm_ufra
301 unsigned int channels, snd_pcm_uframes_t frames,
302 unsigned int get_idx, unsigned int put_idx)
303 {
304-#define CONV24_LABELS
305-#include "plugin_ops.h"
306-#undef CONV24_LABELS
307- void *get = get32_labels[get_idx];
308- void *put = put32_labels[put_idx];
309 unsigned int channel;
310 uint32_t sample = 0;
311 for (channel = 0; channel < channels; ++channel) {
312@@ -202,11 +189,8 @@ void snd_pcm_linear_getput(const snd_pcm_channel_area_t *dst_areas, snd_pcm_ufra
313 dst_step = snd_pcm_channel_area_step(dst_area);
314 frames1 = frames;
315 while (frames1-- > 0) {
316- goto *get;
317-#define CONV24_END after
318-#include "plugin_ops.h"
319-#undef CONV24_END
320- after:
321+ sample = get32(src, get_idx);
322+ put32(dst, sample, put_idx);
323 src += src_step;
324 dst += dst_step;
325 }
326diff --git a/src/pcm/pcm_mulaw.c b/src/pcm/pcm_mulaw.c
327index 587fa54e..97dae154 100644
328--- a/src/pcm/pcm_mulaw.c
329+++ b/src/pcm/pcm_mulaw.c
330@@ -164,10 +164,6 @@ void snd_pcm_mulaw_decode(const snd_pcm_channel_area_t *dst_areas,
331 unsigned int channels, snd_pcm_uframes_t frames,
332 unsigned int putidx)
333 {
334-#define PUT16_LABELS
335-#include "plugin_ops.h"
336-#undef PUT16_LABELS
337- void *put = put16_labels[putidx];
338 unsigned int channel;
339 for (channel = 0; channel < channels; ++channel) {
340 const unsigned char *src;
341@@ -183,11 +179,7 @@ void snd_pcm_mulaw_decode(const snd_pcm_channel_area_t *dst_areas,
342 frames1 = frames;
343 while (frames1-- > 0) {
344 int16_t sample = ulaw_to_s16(*src);
345- goto *put;
346-#define PUT16_END after
347-#include "plugin_ops.h"
348-#undef PUT16_END
349- after:
350+ put16(dst, sample, putidx);
351 src += src_step;
352 dst += dst_step;
353 }
354@@ -201,10 +193,6 @@ void snd_pcm_mulaw_encode(const snd_pcm_channel_area_t *dst_areas,
355 unsigned int channels, snd_pcm_uframes_t frames,
356 unsigned int getidx)
357 {
358-#define GET16_LABELS
359-#include "plugin_ops.h"
360-#undef GET16_LABELS
361- void *get = get16_labels[getidx];
362 unsigned int channel;
363 int16_t sample = 0;
364 for (channel = 0; channel < channels; ++channel) {
365@@ -220,11 +208,7 @@ void snd_pcm_mulaw_encode(const snd_pcm_channel_area_t *dst_areas,
366 dst_step = snd_pcm_channel_area_step(dst_area);
367 frames1 = frames;
368 while (frames1-- > 0) {
369- goto *get;
370-#define GET16_END after
371-#include "plugin_ops.h"
372-#undef GET16_END
373- after:
374+ sample = get16(src, getidx);
375 *dst = s16_to_ulaw(sample);
376 src += src_step;
377 dst += dst_step;
378diff --git a/src/pcm/pcm_rate_linear.c b/src/pcm/pcm_rate_linear.c
379index 35a4d8ea..366fdad7 100644
380--- a/src/pcm/pcm_rate_linear.c
381+++ b/src/pcm/pcm_rate_linear.c
382@@ -70,19 +70,13 @@ static void linear_expand(struct rate_linear *rate,
383 const snd_pcm_channel_area_t *src_areas,
384 snd_pcm_uframes_t src_offset, unsigned int src_frames)
385 {
386-#define GET16_LABELS
387-#define PUT16_LABELS
388-#include "plugin_ops.h"
389-#undef GET16_LABELS
390-#undef PUT16_LABELS
391- void *get = get16_labels[rate->get_idx];
392- void *put = put16_labels[rate->put_idx];
393 unsigned int get_threshold = rate->pitch;
394 unsigned int channel;
395 unsigned int src_frames1;
396 unsigned int dst_frames1;
397 int16_t sample = 0;
398 unsigned int pos;
399+ unsigned int get_idx = rate->get_idx, put_idx = rate->get_idx;
400
401 for (channel = 0; channel < rate->channels; ++channel) {
402 const snd_pcm_channel_area_t *src_area = &src_areas[channel];
403@@ -106,22 +100,14 @@ static void linear_expand(struct rate_linear *rate,
404 pos -= get_threshold;
405 old_sample = new_sample;
406 if (src_frames1 < src_frames) {
407- goto *get;
408-#define GET16_END after_get
409-#include "plugin_ops.h"
410-#undef GET16_END
411- after_get:
412+ sample = get16(src, get_idx);
413 new_sample = sample;
414 }
415 }
416 new_weight = (pos << (16 - rate->pitch_shift)) / (get_threshold >> rate->pitch_shift);
417 old_weight = 0x10000 - new_weight;
418 sample = (old_sample * old_weight + new_sample * new_weight) >> 16;
419- goto *put;
420-#define PUT16_END after_put
421-#include "plugin_ops.h"
422-#undef PUT16_END
423- after_put:
424+ put16(dst, sample, put_idx);
425 dst += dst_step;
426 dst_frames1++;
427 pos += LINEAR_DIV;
428@@ -192,19 +178,13 @@ static void linear_shrink(struct rate_linear *rate,
429 const snd_pcm_channel_area_t *src_areas,
430 snd_pcm_uframes_t src_offset, unsigned int src_frames)
431 {
432-#define GET16_LABELS
433-#define PUT16_LABELS
434-#include "plugin_ops.h"
435-#undef GET16_LABELS
436-#undef PUT16_LABELS
437- void *get = get16_labels[rate->get_idx];
438- void *put = put16_labels[rate->put_idx];
439 unsigned int get_increment = rate->pitch;
440 unsigned int channel;
441 unsigned int src_frames1;
442 unsigned int dst_frames1;
443 int16_t sample = 0;
444 unsigned int pos;
445+ unsigned int get_idx = rate->get_idx, put_idx = rate->get_idx;
446
447 for (channel = 0; channel < rate->channels; ++channel) {
448 const snd_pcm_channel_area_t *src_area = &src_areas[channel];
449@@ -223,13 +203,7 @@ static void linear_shrink(struct rate_linear *rate,
450 src_frames1 = 0;
451 dst_frames1 = 0;
452 while (src_frames1 < src_frames) {
453-
454- goto *get;
455-#define GET16_END after_get
456-#include "plugin_ops.h"
457-#undef GET16_END
458- after_get:
459- new_sample = sample;
460+ new_sample = get16(src, get_idx);
461 src += src_step;
462 src_frames1++;
463 pos += get_increment;
464@@ -238,11 +212,7 @@ static void linear_shrink(struct rate_linear *rate,
465 old_weight = (pos << (32 - LINEAR_DIV_SHIFT)) / (get_increment >> (LINEAR_DIV_SHIFT - 16));
466 new_weight = 0x10000 - old_weight;
467 sample = (old_sample * old_weight + new_sample * new_weight) >> 16;
468- goto *put;
469-#define PUT16_END after_put
470-#include "plugin_ops.h"
471-#undef PUT16_END
472- after_put:
473+ put16(dst, sample, put_idx);
474 dst += dst_step;
475 dst_frames1++;
476 if (CHECK_SANITY(dst_frames1 > dst_frames)) {
477diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c
478index 737c8fa4..f9ba16a1 100644
479--- a/src/pcm/pcm_route.c
480+++ b/src/pcm/pcm_route.c
481@@ -131,10 +131,6 @@ static void snd_pcm_route_convert1_one(const snd_pcm_channel_area_t *dst_area,
482 const snd_pcm_route_ttable_dst_t* ttable,
483 const snd_pcm_route_params_t *params)
484 {
485-#define CONV_LABELS
486-#include "plugin_ops.h"
487-#undef CONV_LABELS
488- void *conv;
489 const snd_pcm_channel_area_t *src_area = 0;
490 unsigned int srcidx;
491 const char *src;
492@@ -156,17 +152,12 @@ static void snd_pcm_route_convert1_one(const snd_pcm_channel_area_t *dst_area,
493 return;
494 }
495
496- conv = conv_labels[params->conv_idx];
497 src = snd_pcm_channel_area_addr(src_area, src_offset);
498 dst = snd_pcm_channel_area_addr(dst_area, dst_offset);
499 src_step = snd_pcm_channel_area_step(src_area);
500 dst_step = snd_pcm_channel_area_step(dst_area);
501 while (frames-- > 0) {
502- goto *conv;
503-#define CONV_END after
504-#include "plugin_ops.h"
505-#undef CONV_END
506- after:
507+ conv(dst, src, params->conv_idx);
508 src += src_step;
509 dst += dst_step;
510 }
511@@ -181,16 +172,13 @@ static void snd_pcm_route_convert1_one_getput(const snd_pcm_channel_area_t *dst_
512 const snd_pcm_route_ttable_dst_t* ttable,
513 const snd_pcm_route_params_t *params)
514 {
515-#define CONV24_LABELS
516-#include "plugin_ops.h"
517-#undef CONV24_LABELS
518- void *get, *put;
519 const snd_pcm_channel_area_t *src_area = 0;
520 unsigned int srcidx;
521 const char *src;
522 char *dst;
523 int src_step, dst_step;
524 uint32_t sample = 0;
525+ unsigned int get_idx = params->get_idx, put_idx = params->put_idx;
526 for (srcidx = 0; srcidx < ttable->nsrcs && srcidx < src_channels; ++srcidx) {
527 unsigned int channel = ttable->srcs[srcidx].channel;
528 if (channel >= src_channels)
529@@ -207,18 +195,13 @@ static void snd_pcm_route_convert1_one_getput(const snd_pcm_channel_area_t *dst_
530 return;
531 }
532
533- get = get32_labels[params->get_idx];
534- put = put32_labels[params->put_idx];
535 src = snd_pcm_channel_area_addr(src_area, src_offset);
536 dst = snd_pcm_channel_area_addr(dst_area, dst_offset);
537 src_step = snd_pcm_channel_area_step(src_area);
538 dst_step = snd_pcm_channel_area_step(dst_area);
539 while (frames-- > 0) {
540- goto *get;
541-#define CONV24_END after
542-#include "plugin_ops.h"
543-#undef CONV24_END
544- after:
545+ sample = get32(src, get_idx);
546+ put32(dst, sample, put_idx);
547 src += src_step;
548 dst += dst_step;
549 }
550@@ -233,34 +216,6 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
551 const snd_pcm_route_ttable_dst_t* ttable,
552 const snd_pcm_route_params_t *params)
553 {
554-#define GET32_LABELS
555-#define PUT32_LABELS
556-#include "plugin_ops.h"
557-#undef GET32_LABELS
558-#undef PUT32_LABELS
559- static void *const zero_labels[2] = {
560- &&zero_int64,
561-#if SND_PCM_PLUGIN_ROUTE_FLOAT
562- &&zero_float
563-#endif
564- };
565- /* sum_type att */
566- static void *const add_labels[2 * 2] = {
567- &&add_int64_noatt, &&add_int64_att,
568-#if SND_PCM_PLUGIN_ROUTE_FLOAT
569- &&add_float_noatt, &&add_float_att
570-#endif
571- };
572- /* sum_type att */
573- static void *const norm_labels[2 * 2] = {
574- &&norm_int64_noatt,
575- &&norm_int64_att,
576-#if SND_PCM_PLUGIN_ROUTE_FLOAT
577- &&norm_float,
578- &&norm_float,
579-#endif
580- };
581- void *zero, *get32, *add, *norm, *put32;
582 int nsrcs = ttable->nsrcs;
583 char *dst;
584 int dst_step;
585@@ -269,6 +224,7 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
586 snd_pcm_route_ttable_src_t src_tt[nsrcs];
587 int32_t sample = 0;
588 int srcidx, srcidx1 = 0;
589+ unsigned get_idx = params->get_idx, put_idx = params->put_idx;
590 for (srcidx = 0; srcidx < nsrcs && (unsigned)srcidx < src_channels; ++srcidx) {
591 const snd_pcm_channel_area_t *src_area;
592 unsigned int channel = ttable->srcs[srcidx].channel;
593@@ -301,11 +257,6 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
594 return;
595 }
596
597- zero = zero_labels[params->sum_idx];
598- get32 = get32_labels[params->get_idx];
599- add = add_labels[params->sum_idx * 2 + ttable->att];
600- norm = norm_labels[params->sum_idx * 2 + ttable->att];
601- put32 = put32_labels[params->put_idx];
602 dst = snd_pcm_channel_area_addr(dst_area, dst_offset);
603 dst_step = snd_pcm_channel_area_step(dst_area);
604
605@@ -314,83 +265,71 @@ static void snd_pcm_route_convert1_many(const snd_pcm_channel_area_t *dst_area,
606 sum_t sum;
607
608 /* Zero sum */
609- goto *zero;
610- zero_int64:
611- sum.as_sint64 = 0;
612- goto zero_end;
613+ switch (params->sum_idx) {
614+ case 0: sum.as_sint64 = 0; break;
615 #if SND_PCM_PLUGIN_ROUTE_FLOAT
616- zero_float:
617- sum.as_float = 0.0;
618- goto zero_end;
619+ case 1: sum.as_float = 0.0; break;
620 #endif
621- zero_end:
622+ }
623 for (srcidx = 0; srcidx < nsrcs; ++srcidx) {
624 const char *src = srcs[srcidx];
625
626 /* Get sample */
627- goto *get32;
628-#define GET32_END after_get
629-#include "plugin_ops.h"
630-#undef GET32_END
631- after_get:
632+ sample = get32(src, get_idx);
633
634 /* Sum */
635- goto *add;
636- add_int64_att:
637- sum.as_sint64 += (int64_t) sample * ttp->as_int;
638- goto after_sum;
639- add_int64_noatt:
640- if (ttp->as_int)
641- sum.as_sint64 += sample;
642- goto after_sum;
643+ switch (params->sum_idx * 2 + ttable->att) {
644+ case 0:
645+ if (ttp->as_int)
646+ sum.as_sint64 += sample;
647+ break;
648+ case 1:
649+ sum.as_sint64 += (int64_t) sample * ttp->as_int;
650+ break;
651 #if SND_PCM_PLUGIN_ROUTE_FLOAT
652- add_float_att:
653- sum.as_float += sample * ttp->as_float;
654- goto after_sum;
655- add_float_noatt:
656- if (ttp->as_int)
657- sum.as_float += sample;
658- goto after_sum;
659+ case 2:
660+ if (ttp->as_int)
661+ sum.as_float += sample;
662+ break;
663+ case 3:
664+ sum.as_float += sample * ttp->as_float;
665+ break;
666 #endif
667- after_sum:
668+ }
669 srcs[srcidx] += src_steps[srcidx];
670 ttp++;
671 }
672
673 /* Normalization */
674- goto *norm;
675- norm_int64_att:
676- div(sum.as_sint64);
677- /* fallthru */
678- norm_int64_noatt:
679- if (sum.as_sint64 > (int64_t)0x7fffffff)
680- sample = 0x7fffffff; /* maximum positive value */
681- else if (sum.as_sint64 < -(int64_t)0x80000000)
682- sample = 0x80000000; /* maximum negative value */
683- else
684- sample = sum.as_sint64;
685- goto after_norm;
686-
687+ switch (params->sum_idx * 2 + ttable->att) {
688+ case 1:
689+ div(sum.as_sint64);
690+ /* fallthru */
691+ case 0:
692+ if (sum.as_sint64 > (int64_t)0x7fffffff)
693+ sample = 0x7fffffff; /* maximum positive value */
694+ else if (sum.as_sint64 < -(int64_t)0x80000000)
695+ sample = 0x80000000; /* maximum negative value */
696+ else
697+ sample = sum.as_sint64;
698+ break;
699 #if SND_PCM_PLUGIN_ROUTE_FLOAT
700- norm_float:
701- sum.as_float = rint(sum.as_float);
702- if (sum.as_float > (int64_t)0x7fffffff)
703- sample = 0x7fffffff; /* maximum positive value */
704- else if (sum.as_float < -(int64_t)0x80000000)
705- sample = 0x80000000; /* maximum negative value */
706- else
707- sample = sum.as_float;
708- goto after_norm;
709+ case 2:
710+ case 3:
711+ sum.as_float = rint(sum.as_float);
712+ if (sum.as_float > (int64_t)0x7fffffff)
713+ sample = 0x7fffffff; /* maximum positive value */
714+ else if (sum.as_float < -(int64_t)0x80000000)
715+ sample = 0x80000000; /* maximum negative value */
716+ else
717+ sample = sum.as_float;
718+ break;
719 #endif
720- after_norm:
721+ }
722
723 /* Put sample */
724- goto *put32;
725-#define PUT32_END after_put32
726-#include "plugin_ops.h"
727-#undef PUT32_END
728- after_put32:
729-
730+ put32(dst, sample, put_idx);
731+
732 dst += dst_step;
733 }
734 }
735diff --git a/src/pcm/plugin_ops.h b/src/pcm/plugin_ops.h
736index 6392073c..5c89a24f 100644
737--- a/src/pcm/plugin_ops.h
738+++ b/src/pcm/plugin_ops.h
739@@ -19,6 +19,11 @@
740 *
741 */
742
743+#include <assert.h>
744+#include <math.h>
745+#include <stdint.h>
746+#include <byteswap.h>
747+
748 #ifndef SX_INLINES
749 #define SX_INLINES
750 static inline uint32_t sx20(uint32_t x)
751@@ -92,626 +97,360 @@ static inline uint32_t sx24s(uint32_t x)
752 #define _put_triple_s(ptr,val) _put_triple_le(ptr,val)
753 #endif
754
755-#ifdef CONV_LABELS
756-/* src_wid src_endswap sign_toggle dst_wid dst_endswap */
757-static void *const conv_labels[4 * 2 * 2 * 4 * 2] = {
758- &&conv_xxx1_xxx1, /* 8h -> 8h */
759- &&conv_xxx1_xxx1, /* 8h -> 8s */
760- &&conv_xxx1_xx10, /* 8h -> 16h */
761- &&conv_xxx1_xx01, /* 8h -> 16s */
762- &&conv_xxx1_x100, /* 8h -> 24h */
763- &&conv_xxx1_001x, /* 8h -> 24s */
764- &&conv_xxx1_1000, /* 8h -> 32h */
765- &&conv_xxx1_0001, /* 8h -> 32s */
766- &&conv_xxx1_xxx9, /* 8h ^> 8h */
767- &&conv_xxx1_xxx9, /* 8h ^> 8s */
768- &&conv_xxx1_xx90, /* 8h ^> 16h */
769- &&conv_xxx1_xx09, /* 8h ^> 16s */
770- &&conv_xxx1_x900, /* 8h ^> 24h */
771- &&conv_xxx1_009x, /* 8h ^> 24s */
772- &&conv_xxx1_9000, /* 8h ^> 32h */
773- &&conv_xxx1_0009, /* 8h ^> 32s */
774- &&conv_xxx1_xxx1, /* 8s -> 8h */
775- &&conv_xxx1_xxx1, /* 8s -> 8s */
776- &&conv_xxx1_xx10, /* 8s -> 16h */
777- &&conv_xxx1_xx01, /* 8s -> 16s */
778- &&conv_xxx1_x100, /* 8s -> 24h */
779- &&conv_xxx1_001x, /* 8s -> 24s */
780- &&conv_xxx1_1000, /* 8s -> 32h */
781- &&conv_xxx1_0001, /* 8s -> 32s */
782- &&conv_xxx1_xxx9, /* 8s ^> 8h */
783- &&conv_xxx1_xxx9, /* 8s ^> 8s */
784- &&conv_xxx1_xx90, /* 8s ^> 16h */
785- &&conv_xxx1_xx09, /* 8s ^> 16s */
786- &&conv_xxx1_x900, /* 8s ^> 24h */
787- &&conv_xxx1_009x, /* 8s ^> 24s */
788- &&conv_xxx1_9000, /* 8s ^> 32h */
789- &&conv_xxx1_0009, /* 8s ^> 32s */
790- &&conv_xx12_xxx1, /* 16h -> 8h */
791- &&conv_xx12_xxx1, /* 16h -> 8s */
792- &&conv_xx12_xx12, /* 16h -> 16h */
793- &&conv_xx12_xx21, /* 16h -> 16s */
794- &&conv_xx12_x120, /* 16h -> 24h */
795- &&conv_xx12_021x, /* 16h -> 24s */
796- &&conv_xx12_1200, /* 16h -> 32h */
797- &&conv_xx12_0021, /* 16h -> 32s */
798- &&conv_xx12_xxx9, /* 16h ^> 8h */
799- &&conv_xx12_xxx9, /* 16h ^> 8s */
800- &&conv_xx12_xx92, /* 16h ^> 16h */
801- &&conv_xx12_xx29, /* 16h ^> 16s */
802- &&conv_xx12_x920, /* 16h ^> 24h */
803- &&conv_xx12_029x, /* 16h ^> 24s */
804- &&conv_xx12_9200, /* 16h ^> 32h */
805- &&conv_xx12_0029, /* 16h ^> 32s */
806- &&conv_xx12_xxx2, /* 16s -> 8h */
807- &&conv_xx12_xxx2, /* 16s -> 8s */
808- &&conv_xx12_xx21, /* 16s -> 16h */
809- &&conv_xx12_xx12, /* 16s -> 16s */
810- &&conv_xx12_x210, /* 16s -> 24h */
811- &&conv_xx12_012x, /* 16s -> 24s */
812- &&conv_xx12_2100, /* 16s -> 32h */
813- &&conv_xx12_0012, /* 16s -> 32s */
814- &&conv_xx12_xxxA, /* 16s ^> 8h */
815- &&conv_xx12_xxxA, /* 16s ^> 8s */
816- &&conv_xx12_xxA1, /* 16s ^> 16h */
817- &&conv_xx12_xx1A, /* 16s ^> 16s */
818- &&conv_xx12_xA10, /* 16s ^> 24h */
819- &&conv_xx12_01Ax, /* 16s ^> 24s */
820- &&conv_xx12_A100, /* 16s ^> 32h */
821- &&conv_xx12_001A, /* 16s ^> 32s */
822- &&conv_x123_xxx1, /* 24h -> 8h */
823- &&conv_x123_xxx1, /* 24h -> 8s */
824- &&conv_x123_xx12, /* 24h -> 16h */
825- &&conv_x123_xx21, /* 24h -> 16s */
826- &&conv_x123_x123, /* 24h -> 24h */
827- &&conv_x123_321x, /* 24h -> 24s */
828- &&conv_x123_1230, /* 24h -> 32h */
829- &&conv_x123_0321, /* 24h -> 32s */
830- &&conv_x123_xxx9, /* 24h ^> 8h */
831- &&conv_x123_xxx9, /* 24h ^> 8s */
832- &&conv_x123_xx92, /* 24h ^> 16h */
833- &&conv_x123_xx29, /* 24h ^> 16s */
834- &&conv_x123_x923, /* 24h ^> 24h */
835- &&conv_x123_329x, /* 24h ^> 24s */
836- &&conv_x123_9230, /* 24h ^> 32h */
837- &&conv_x123_0329, /* 24h ^> 32s */
838- &&conv_123x_xxx3, /* 24s -> 8h */
839- &&conv_123x_xxx3, /* 24s -> 8s */
840- &&conv_123x_xx32, /* 24s -> 16h */
841- &&conv_123x_xx23, /* 24s -> 16s */
842- &&conv_123x_x321, /* 24s -> 24h */
843- &&conv_123x_123x, /* 24s -> 24s */
844- &&conv_123x_3210, /* 24s -> 32h */
845- &&conv_123x_0123, /* 24s -> 32s */
846- &&conv_123x_xxxB, /* 24s ^> 8h */
847- &&conv_123x_xxxB, /* 24s ^> 8s */
848- &&conv_123x_xxB2, /* 24s ^> 16h */
849- &&conv_123x_xx2B, /* 24s ^> 16s */
850- &&conv_123x_xB21, /* 24s ^> 24h */
851- &&conv_123x_12Bx, /* 24s ^> 24s */
852- &&conv_123x_B210, /* 24s ^> 32h */
853- &&conv_123x_012B, /* 24s ^> 32s */
854- &&conv_1234_xxx1, /* 32h -> 8h */
855- &&conv_1234_xxx1, /* 32h -> 8s */
856- &&conv_1234_xx12, /* 32h -> 16h */
857- &&conv_1234_xx21, /* 32h -> 16s */
858- &&conv_1234_x123, /* 32h -> 24h */
859- &&conv_1234_321x, /* 32h -> 24s */
860- &&conv_1234_1234, /* 32h -> 32h */
861- &&conv_1234_4321, /* 32h -> 32s */
862- &&conv_1234_xxx9, /* 32h ^> 8h */
863- &&conv_1234_xxx9, /* 32h ^> 8s */
864- &&conv_1234_xx92, /* 32h ^> 16h */
865- &&conv_1234_xx29, /* 32h ^> 16s */
866- &&conv_1234_x923, /* 32h ^> 24h */
867- &&conv_1234_329x, /* 32h ^> 24s */
868- &&conv_1234_9234, /* 32h ^> 32h */
869- &&conv_1234_4329, /* 32h ^> 32s */
870- &&conv_1234_xxx4, /* 32s -> 8h */
871- &&conv_1234_xxx4, /* 32s -> 8s */
872- &&conv_1234_xx43, /* 32s -> 16h */
873- &&conv_1234_xx34, /* 32s -> 16s */
874- &&conv_1234_x432, /* 32s -> 24h */
875- &&conv_1234_234x, /* 32s -> 24s */
876- &&conv_1234_4321, /* 32s -> 32h */
877- &&conv_1234_1234, /* 32s -> 32s */
878- &&conv_1234_xxxC, /* 32s ^> 8h */
879- &&conv_1234_xxxC, /* 32s ^> 8s */
880- &&conv_1234_xxC3, /* 32s ^> 16h */
881- &&conv_1234_xx3C, /* 32s ^> 16s */
882- &&conv_1234_xC32, /* 32s ^> 24h */
883- &&conv_1234_23Cx, /* 32s ^> 24s */
884- &&conv_1234_C321, /* 32s ^> 32h */
885- &&conv_1234_123C, /* 32s ^> 32s */
886-};
887-#endif
888-
889-#ifdef CONV_END
890-while(0) {
891-conv_xxx1_xxx1: as_u8(dst) = as_u8c(src); goto CONV_END;
892-conv_xxx1_xx10: as_u16(dst) = (uint16_t)as_u8c(src) << 8; goto CONV_END;
893-conv_xxx1_xx01: as_u16(dst) = (uint16_t)as_u8c(src); goto CONV_END;
894-conv_xxx1_x100: as_u32(dst) = sx24((uint32_t)as_u8c(src) << 16); goto CONV_END;
895-conv_xxx1_001x: as_u32(dst) = sx24s((uint32_t)as_u8c(src) << 8); goto CONV_END;
896-conv_xxx1_1000: as_u32(dst) = (uint32_t)as_u8c(src) << 24; goto CONV_END;
897-conv_xxx1_0001: as_u32(dst) = (uint32_t)as_u8c(src); goto CONV_END;
898-conv_xxx1_xxx9: as_u8(dst) = as_u8c(src) ^ 0x80; goto CONV_END;
899-conv_xxx1_xx90: as_u16(dst) = (uint16_t)(as_u8c(src) ^ 0x80) << 8; goto CONV_END;
900-conv_xxx1_xx09: as_u16(dst) = (uint16_t)(as_u8c(src) ^ 0x80); goto CONV_END;
901-conv_xxx1_x900: as_u32(dst) = sx24((uint32_t)(as_u8c(src) ^ 0x80) << 16); goto CONV_END;
902-conv_xxx1_009x: as_u32(dst) = sx24s((uint32_t)(as_u8c(src) ^ 0x80) << 8); goto CONV_END;
903-conv_xxx1_9000: as_u32(dst) = (uint32_t)(as_u8c(src) ^ 0x80) << 24; goto CONV_END;
904-conv_xxx1_0009: as_u32(dst) = (uint32_t)(as_u8c(src) ^ 0x80); goto CONV_END;
905-conv_xx12_xxx1: as_u8(dst) = as_u16c(src) >> 8; goto CONV_END;
906-conv_xx12_xx12: as_u16(dst) = as_u16c(src); goto CONV_END;
907-conv_xx12_xx21: as_u16(dst) = bswap_16(as_u16c(src)); goto CONV_END;
908-conv_xx12_x120: as_u32(dst) = sx24((uint32_t)as_u16c(src) << 8); goto CONV_END;
909-conv_xx12_021x: as_u32(dst) = sx24s((uint32_t)bswap_16(as_u16c(src)) << 8); goto CONV_END;
910-conv_xx12_1200: as_u32(dst) = (uint32_t)as_u16c(src) << 16; goto CONV_END;
911-conv_xx12_0021: as_u32(dst) = (uint32_t)bswap_16(as_u16c(src)); goto CONV_END;
912-conv_xx12_xxx9: as_u8(dst) = (as_u16c(src) >> 8) ^ 0x80; goto CONV_END;
913-conv_xx12_xx92: as_u16(dst) = as_u16c(src) ^ 0x8000; goto CONV_END;
914-conv_xx12_xx29: as_u16(dst) = bswap_16(as_u16c(src)) ^ 0x80; goto CONV_END;
915-conv_xx12_x920: as_u32(dst) = sx24((uint32_t)(as_u16c(src) ^ 0x8000) << 8); goto CONV_END;
916-conv_xx12_029x: as_u32(dst) = sx24s((uint32_t)(bswap_16(as_u16c(src)) ^ 0x80) << 8); goto CONV_END;
917-conv_xx12_9200: as_u32(dst) = (uint32_t)(as_u16c(src) ^ 0x8000) << 16; goto CONV_END;
918-conv_xx12_0029: as_u32(dst) = (uint32_t)(bswap_16(as_u16c(src)) ^ 0x80); goto CONV_END;
919-conv_xx12_xxx2: as_u8(dst) = as_u16c(src) & 0xff; goto CONV_END;
920-conv_xx12_x210: as_u32(dst) = sx24((uint32_t)bswap_16(as_u16c(src)) << 8); goto CONV_END;
921-conv_xx12_012x: as_u32(dst) = sx24s((uint32_t)as_u16c(src) << 8); goto CONV_END;
922-conv_xx12_2100: as_u32(dst) = (uint32_t)bswap_16(as_u16c(src)) << 16; goto CONV_END;
923-conv_xx12_0012: as_u32(dst) = (uint32_t)as_u16c(src); goto CONV_END;
924-conv_xx12_xxxA: as_u8(dst) = (as_u16c(src) ^ 0x80) & 0xff; goto CONV_END;
925-conv_xx12_xxA1: as_u16(dst) = bswap_16(as_u16c(src) ^ 0x80); goto CONV_END;
926-conv_xx12_xx1A: as_u16(dst) = as_u16c(src) ^ 0x80; goto CONV_END;
927-conv_xx12_xA10: as_u32(dst) = sx24((uint32_t)bswap_16(as_u16c(src) ^ 0x80) << 8); goto CONV_END;
928-conv_xx12_01Ax: as_u32(dst) = sx24s((uint32_t)(as_u16c(src) ^ 0x80) << 8); goto CONV_END;
929-conv_xx12_A100: as_u32(dst) = (uint32_t)bswap_16(as_u16c(src) ^ 0x80) << 16; goto CONV_END;
930-conv_xx12_001A: as_u32(dst) = (uint32_t)(as_u16c(src) ^ 0x80); goto CONV_END;
931-conv_x123_xxx1: as_u8(dst) = as_u32c(src) >> 16; goto CONV_END;
932-conv_x123_xx12: as_u16(dst) = as_u32c(src) >> 8; goto CONV_END;
933-conv_x123_xx21: as_u16(dst) = bswap_16(as_u32c(src) >> 8); goto CONV_END;
934-conv_x123_x123: as_u32(dst) = sx24(as_u32c(src)); goto CONV_END;
935-conv_x123_321x: as_u32(dst) = sx24s(bswap_32(as_u32c(src))); goto CONV_END;
936-conv_x123_1230: as_u32(dst) = as_u32c(src) << 8; goto CONV_END;
937-conv_x123_0321: as_u32(dst) = bswap_32(as_u32c(src)) >> 8; goto CONV_END;
938-conv_x123_xxx9: as_u8(dst) = (as_u32c(src) >> 16) ^ 0x80; goto CONV_END;
939-conv_x123_xx92: as_u16(dst) = (as_u32c(src) >> 8) ^ 0x8000; goto CONV_END;
940-conv_x123_xx29: as_u16(dst) = bswap_16(as_u32c(src) >> 8) ^ 0x80; goto CONV_END;
941-conv_x123_x923: as_u32(dst) = sx24(as_u32c(src) ^ 0x800000); goto CONV_END;
942-conv_x123_329x: as_u32(dst) = sx24s(bswap_32(as_u32c(src)) ^ 0x8000); goto CONV_END;
943-conv_x123_9230: as_u32(dst) = (as_u32c(src) ^ 0x800000) << 8; goto CONV_END;
944-conv_x123_0329: as_u32(dst) = (bswap_32(as_u32c(src)) >> 8) ^ 0x80; goto CONV_END;
945-conv_123x_xxx3: as_u8(dst) = (as_u32c(src) >> 8) & 0xff; goto CONV_END;
946-conv_123x_xx32: as_u16(dst) = bswap_16(as_u32c(src) >> 8); goto CONV_END;
947-conv_123x_xx23: as_u16(dst) = (as_u32c(src) >> 8) & 0xffff; goto CONV_END;
948-conv_123x_x321: as_u32(dst) = sx24(bswap_32(as_u32c(src))); goto CONV_END;
949-conv_123x_123x: as_u32(dst) = sx24s(as_u32c(src)); goto CONV_END;
950-conv_123x_3210: as_u32(dst) = bswap_32(as_u32c(src)) << 8; goto CONV_END;
951-conv_123x_0123: as_u32(dst) = as_u32c(src) >> 8; goto CONV_END;
952-conv_123x_xxxB: as_u8(dst) = ((as_u32c(src) >> 8) & 0xff) ^ 0x80; goto CONV_END;
953-conv_123x_xxB2: as_u16(dst) = bswap_16((as_u32c(src) >> 8) ^ 0x80); goto CONV_END;
954-conv_123x_xx2B: as_u16(dst) = ((as_u32c(src) >> 8) & 0xffff) ^ 0x80; goto CONV_END;
955-conv_123x_xB21: as_u32(dst) = sx24(bswap_32(as_u32c(src)) ^ 0x800000); goto CONV_END;
956-conv_123x_12Bx: as_u32(dst) = sx24s(as_u32c(src) ^ 0x8000); goto CONV_END;
957-conv_123x_B210: as_u32(dst) = bswap_32(as_u32c(src) ^ 0x8000) << 8; goto CONV_END;
958-conv_123x_012B: as_u32(dst) = (as_u32c(src) >> 8) ^ 0x80; goto CONV_END;
959-conv_1234_xxx1: as_u8(dst) = as_u32c(src) >> 24; goto CONV_END;
960-conv_1234_xx12: as_u16(dst) = as_u32c(src) >> 16; goto CONV_END;
961-conv_1234_xx21: as_u16(dst) = bswap_16(as_u32c(src) >> 16); goto CONV_END;
962-conv_1234_x123: as_u32(dst) = sx24(as_u32c(src) >> 8); goto CONV_END;
963-conv_1234_321x: as_u32(dst) = sx24s(bswap_32(as_u32c(src)) << 8); goto CONV_END;
964-conv_1234_1234: as_u32(dst) = as_u32c(src); goto CONV_END;
965-conv_1234_4321: as_u32(dst) = bswap_32(as_u32c(src)); goto CONV_END;
966-conv_1234_xxx9: as_u8(dst) = (as_u32c(src) >> 24) ^ 0x80; goto CONV_END;
967-conv_1234_xx92: as_u16(dst) = (as_u32c(src) >> 16) ^ 0x8000; goto CONV_END;
968-conv_1234_xx29: as_u16(dst) = bswap_16(as_u32c(src) >> 16) ^ 0x80; goto CONV_END;
969-conv_1234_x923: as_u32(dst) = sx24((as_u32c(src) >> 8) ^ 0x800000); goto CONV_END;
970-conv_1234_329x: as_u32(dst) = sx24s((bswap_32(as_u32c(src)) ^ 0x80) << 8); goto CONV_END;
971-conv_1234_9234: as_u32(dst) = as_u32c(src) ^ 0x80000000; goto CONV_END;
972-conv_1234_4329: as_u32(dst) = bswap_32(as_u32c(src)) ^ 0x80; goto CONV_END;
973-conv_1234_xxx4: as_u8(dst) = as_u32c(src) & 0xff; goto CONV_END;
974-conv_1234_xx43: as_u16(dst) = bswap_16(as_u32c(src)); goto CONV_END;
975-conv_1234_xx34: as_u16(dst) = as_u32c(src) & 0xffff; goto CONV_END;
976-conv_1234_x432: as_u32(dst) = sx24(bswap_32(as_u32c(src)) >> 8); goto CONV_END;
977-conv_1234_234x: as_u32(dst) = sx24s(as_u32c(src) << 8); goto CONV_END;
978-conv_1234_xxxC: as_u8(dst) = (as_u32c(src) & 0xff) ^ 0x80; goto CONV_END;
979-conv_1234_xxC3: as_u16(dst) = bswap_16(as_u32c(src) ^ 0x80); goto CONV_END;
980-conv_1234_xx3C: as_u16(dst) = (as_u32c(src) & 0xffff) ^ 0x80; goto CONV_END;
981-conv_1234_xC32: as_u32(dst) = sx24((bswap_32(as_u32c(src)) >> 8) ^ 0x800000); goto CONV_END;
982-conv_1234_23Cx: as_u32(dst) = sx24s((as_u32c(src) ^ 0x80) << 8); goto CONV_END;
983-conv_1234_C321: as_u32(dst) = bswap_32(as_u32c(src) ^ 0x80); goto CONV_END;
984-conv_1234_123C: as_u32(dst) = as_u32c(src) ^ 0x80; goto CONV_END;
985+static inline void conv(char *dst, const char *src, unsigned int idx) {
986+ switch (idx) {
987+ case 0: /* 8h -> 8h */
988+ case 1: /* 8h -> 8s */
989+ case 16: /* 8s -> 8h */
990+ case 17: /* 8s -> 8s */ as_u8(dst) = as_u8c(src); break;
991+ case 2: /* 8h -> 16h */
992+ case 18: /* 8s -> 16h */ as_u16(dst) = (uint16_t)as_u8c(src) << 8; break;
993+ case 3: /* 8h -> 16s */
994+ case 19: /* 8s -> 16s */ as_u16(dst) = (uint16_t)as_u8c(src); break;
995+ case 4: /* 8h -> 24h */
996+ case 20: /* 8s -> 24h */ as_u32(dst) = sx24((uint32_t)as_u8c(src) << 16); break;
997+ case 5: /* 8h -> 24s */
998+ case 21: /* 8s -> 24s */ as_u32(dst) = sx24s((uint32_t)as_u8c(src) << 8); break;
999+ case 6: /* 8h -> 32h */
1000+ case 22: /* 8s -> 32h */ as_u32(dst) = (uint32_t)as_u8c(src) << 24; break;
1001+ case 7: /* 8h -> 32s */
1002+ case 23: /* 8s -> 32s */ as_u32(dst) = (uint32_t)as_u8c(src); break;
1003+ case 8: /* 8h ^> 8h */
1004+ case 9: /* 8h ^> 8s */
1005+ case 24: /* 8s ^> 8h */
1006+ case 25: /* 8s ^> 8s */ as_u8(dst) = as_u8c(src) ^ 0x80; break;
1007+ case 10: /* 8h ^> 16h */
1008+ case 26: /* 8s ^> 16h */ as_u16(dst) = (uint16_t)(as_u8c(src) ^ 0x80) << 8; break;
1009+ case 11: /* 8h ^> 16s */
1010+ case 27: /* 8s ^> 16s */ as_u16(dst) = (uint16_t)(as_u8c(src) ^ 0x80); break;
1011+ case 12: /* 8h ^> 24h */
1012+ case 28: /* 8s ^> 24h */ as_u32(dst) = sx24((uint32_t)(as_u8c(src) ^ 0x80) << 16); break;
1013+ case 13: /* 8h ^> 24s */
1014+ case 29: /* 8s ^> 24s */ as_u32(dst) = sx24s((uint32_t)(as_u8c(src) ^ 0x80) << 8); break;
1015+ case 14: /* 8h ^> 32h */
1016+ case 30: /* 8s ^> 32h */ as_u32(dst) = (uint32_t)(as_u8c(src) ^ 0x80) << 24; break;
1017+ case 15: /* 8h ^> 32s */
1018+ case 31: /* 8s ^> 32s */ as_u32(dst) = (uint32_t)(as_u8c(src) ^ 0x80); break;
1019+ case 32: /* 16h -> 8h */
1020+ case 33: /* 16h -> 8s */ as_u8(dst) = as_u16c(src) >> 8; break;
1021+ case 34: /* 16h -> 16h */ as_u16(dst) = as_u16c(src); break;
1022+ case 35: /* 16h -> 16s */ as_u16(dst) = bswap_16(as_u16c(src)); break;
1023+ case 36: /* 16h -> 24h */ as_u32(dst) = sx24((uint32_t)as_u16c(src) << 8); break;
1024+ case 37: /* 16h -> 24s */ as_u32(dst) = sx24s((uint32_t)bswap_16(as_u16c(src)) << 8); break;
1025+ case 38: /* 16h -> 32h */ as_u32(dst) = (uint32_t)as_u16c(src) << 16; break;
1026+ case 39: /* 16h -> 32s */ as_u32(dst) = (uint32_t)bswap_16(as_u16c(src)); break;
1027+ case 40: /* 16h ^> 8h */
1028+ case 41: /* 16h ^> 8s */ as_u8(dst) = (as_u16c(src) >> 8) ^ 0x80; break;
1029+ case 42: /* 16h ^> 16h */
1030+ case 51: /* 16s -> 16s */ as_u16(dst) = as_u16c(src) ^ 0x8000; break;
1031+ case 43: /* 16h ^> 16s */
1032+ case 50: /* 16s -> 16h */ as_u16(dst) = bswap_16(as_u16c(src)) ^ 0x80; break;
1033+ case 44: /* 16h ^> 24h */ as_u32(dst) = sx24((uint32_t)(as_u16c(src) ^ 0x8000) << 8); break;
1034+ case 45: /* 16h ^> 24s */ as_u32(dst) = sx24s((uint32_t)(bswap_16(as_u16c(src)) ^ 0x80) << 8); break;
1035+ case 46: /* 16h ^> 32h */ as_u32(dst) = (uint32_t)(as_u16c(src) ^ 0x8000) << 16; break;
1036+ case 47: /* 16h ^> 32s */ as_u32(dst) = (uint32_t)(bswap_16(as_u16c(src)) ^ 0x80); break;
1037+ case 48: /* 16s -> 8h */
1038+ case 49: /* 16s -> 8s */ as_u8(dst) = as_u16c(src) & 0xff; break;
1039+ case 52: /* 16s -> 24h */ as_u32(dst) = sx24((uint32_t)bswap_16(as_u16c(src)) << 8); break;
1040+ case 53: /* 16s -> 24s */ as_u32(dst) = sx24s((uint32_t)as_u16c(src) << 8); break;
1041+ case 54: /* 16s -> 32h */ as_u32(dst) = (uint32_t)bswap_16(as_u16c(src)) << 16; break;
1042+ case 55: /* 16s -> 32s */ as_u32(dst) = (uint32_t)as_u16c(src); break;
1043+ case 56: /* 16s ^> 8h */
1044+ case 57: /* 16s ^> 8s */ as_u8(dst) = (as_u16c(src) ^ 0x80) & 0xff; break;
1045+ case 58: /* 16s ^> 16h */ as_u16(dst) = bswap_16(as_u16c(src) ^ 0x80); break;
1046+ case 59: /* 16s ^> 16s */ as_u16(dst) = as_u16c(src) ^ 0x80; break;
1047+ case 60: /* 16s ^> 24h */ as_u32(dst) = sx24((uint32_t)bswap_16(as_u16c(src) ^ 0x80) << 8); break;
1048+ case 61: /* 16s ^> 24s */ as_u32(dst) = sx24s((uint32_t)(as_u16c(src) ^ 0x80) << 8); break;
1049+ case 62: /* 16s ^> 32h */ as_u32(dst) = (uint32_t)bswap_16(as_u16c(src) ^ 0x80) << 16; break;
1050+ case 63: /* 16s ^> 32s */ as_u32(dst) = (uint32_t)(as_u16c(src) ^ 0x80); break;
1051+ case 64: /* 24h -> 8h */
1052+ case 65: /* 24h -> 8s */ as_u8(dst) = as_u32c(src) >> 16; break;
1053+ case 66: /* 24h -> 16h */ as_u16(dst) = as_u32c(src) >> 8; break;
1054+ case 67: /* 24h -> 16s */ as_u16(dst) = bswap_16(as_u32c(src) >> 8); break;
1055+ case 68: /* 24h -> 24h */ as_u32(dst) = sx24(as_u32c(src)); break;
1056+ case 69: /* 24h -> 24s */ as_u32(dst) = sx24s(bswap_32(as_u32c(src))); break;
1057+ case 70: /* 24h -> 32h */ as_u32(dst) = as_u32c(src) << 8; break;
1058+ case 71: /* 24h -> 32s */ as_u32(dst) = bswap_32(as_u32c(src)) >> 8; break;
1059+ case 72: /* 24h ^> 8h */
1060+ case 73: /* 24h ^> 8s */ as_u8(dst) = (as_u32c(src) >> 16) ^ 0x80; break;
1061+ case 74: /* 24h ^> 16h */ as_u16(dst) = (as_u32c(src) >> 8) ^ 0x8000; break;
1062+ case 75: /* 24h ^> 16s */ as_u16(dst) = bswap_16(as_u32c(src) >> 8) ^ 0x80; break;
1063+ case 76: /* 24h ^> 24h */ as_u32(dst) = sx24(as_u32c(src) ^ 0x800000); break;
1064+ case 77: /* 24h ^> 24s */ as_u32(dst) = sx24s(bswap_32(as_u32c(src)) ^ 0x8000); break;
1065+ case 78: /* 24h ^> 32h */ as_u32(dst) = (as_u32c(src) ^ 0x800000) << 8; break;
1066+ case 79: /* 24h ^> 32s */ as_u32(dst) = (bswap_32(as_u32c(src)) >> 8) ^ 0x80; break;
1067+ case 80: /* 24s -> 8h */
1068+ case 81: /* 24s -> 8s */ as_u8(dst) = (as_u32c(src) >> 8) & 0xff; break;
1069+ case 82: /* 24s -> 16h */ as_u16(dst) = bswap_16(as_u32c(src) >> 8); break;
1070+ case 83: /* 24s -> 16s */ as_u16(dst) = (as_u32c(src) >> 8) & 0xffff; break;
1071+ case 84: /* 24s -> 24h */ as_u32(dst) = sx24(bswap_32(as_u32c(src))); break;
1072+ case 85: /* 24s -> 24s */ as_u32(dst) = sx24s(as_u32c(src)); break;
1073+ case 86: /* 24s -> 32h */ as_u32(dst) = bswap_32(as_u32c(src)) << 8; break;
1074+ case 87: /* 24s -> 32s */ as_u32(dst) = as_u32c(src) >> 8; break;
1075+ case 88: /* 24s ^> 8h */
1076+ case 89: /* 24s ^> 8s */ as_u8(dst) = ((as_u32c(src) >> 8) & 0xff) ^ 0x80; break;
1077+ case 90: /* 24s ^> 16h */ as_u16(dst) = bswap_16((as_u32c(src) >> 8) ^ 0x80); break;
1078+ case 91: /* 24s ^> 16s */ as_u16(dst) = ((as_u32c(src) >> 8) & 0xffff) ^ 0x80; break;
1079+ case 92: /* 24s ^> 24h */ as_u32(dst) = sx24(bswap_32(as_u32c(src)) ^ 0x800000); break;
1080+ case 93: /* 24s ^> 24s */ as_u32(dst) = sx24s(as_u32c(src) ^ 0x8000); break;
1081+ case 94: /* 24s ^> 32h */ as_u32(dst) = bswap_32(as_u32c(src) ^ 0x8000) << 8; break;
1082+ case 95: /* 24s ^> 32s */ as_u32(dst) = (as_u32c(src) >> 8) ^ 0x80; break;
1083+ case 96: /* 32h -> 8h */
1084+ case 97: /* 32h -> 8s */ as_u8(dst) = as_u32c(src) >> 24; break;
1085+ case 98: /* 32h -> 16h */ as_u16(dst) = as_u32c(src) >> 16; break;
1086+ case 99: /* 32h -> 16s */ as_u16(dst) = bswap_16(as_u32c(src) >> 16); break;
1087+ case 100: /* 32h -> 24h */ as_u32(dst) = sx24(as_u32c(src) >> 8); break;
1088+ case 101: /* 32h -> 24s */ as_u32(dst) = sx24s(bswap_32(as_u32c(src)) << 8); break;
1089+ case 102: /* 32h -> 32h */
1090+ case 119: /* 32s -> 32s */ as_u32(dst) = as_u32c(src); break;
1091+ case 103: /* 32h -> 32s */
1092+ case 118: /* 32s -> 32h */ as_u32(dst) = bswap_32(as_u32c(src)); break;
1093+ case 104: /* 32h ^> 8h */
1094+ case 105: /* 32h ^> 8s */ as_u8(dst) = (as_u32c(src) >> 24) ^ 0x80; break;
1095+ case 106: /* 32h ^> 16h */ as_u16(dst) = (as_u32c(src) >> 16) ^ 0x8000; break;
1096+ case 107: /* 32h ^> 16s */ as_u16(dst) = bswap_16(as_u32c(src) >> 16) ^ 0x80; break;
1097+ case 108: /* 32h ^> 24h */ as_u32(dst) = sx24((as_u32c(src) >> 8) ^ 0x800000); break;
1098+ case 109: /* 32h ^> 24s */ as_u32(dst) = sx24s((bswap_32(as_u32c(src)) ^ 0x80) << 8); break;
1099+ case 110: /* 32h ^> 32h */ as_u32(dst) = as_u32c(src) ^ 0x80000000; break;
1100+ case 111: /* 32h ^> 32s */ as_u32(dst) = bswap_32(as_u32c(src)) ^ 0x80; break;
1101+ case 112: /* 32s -> 8h */
1102+ case 113: /* 32s -> 8s */ as_u8(dst) = as_u32c(src) & 0xff; break;
1103+ case 114: /* 32s -> 16h */ as_u16(dst) = bswap_16(as_u32c(src)); break;
1104+ case 115: /* 32s -> 16s */ as_u16(dst) = as_u32c(src) & 0xffff; break;
1105+ case 116: /* 32s -> 24h */ as_u32(dst) = sx24(bswap_32(as_u32c(src)) >> 8); break;
1106+ case 117: /* 32s -> 24s */ as_u32(dst) = sx24s(as_u32c(src) << 8); break;
1107+ case 120: /* 32s ^> 8h */
1108+ case 121: /* 32s ^> 8s */ as_u8(dst) = (as_u32c(src) & 0xff) ^ 0x80; break;
1109+ case 122: /* 32s ^> 16h */ as_u16(dst) = bswap_16(as_u32c(src) ^ 0x80); break;
1110+ case 123: /* 32s ^> 16s */ as_u16(dst) = (as_u32c(src) & 0xffff) ^ 0x80; break;
1111+ case 124: /* 32s ^> 24h */ as_u32(dst) = sx24((bswap_32(as_u32c(src)) >> 8) ^ 0x800000); break;
1112+ case 125: /* 32s ^> 24s */ as_u32(dst) = sx24s((as_u32c(src) ^ 0x80) << 8); break;
1113+ case 126: /* 32s ^> 32h */ as_u32(dst) = bswap_32(as_u32c(src) ^ 0x80); break;
1114+ case 127: /* 32s ^> 32s */ as_u32(dst) = as_u32c(src) ^ 0x80; break;
1115+ default: assert(0);
1116+ }
1117 }
1118-#endif
1119
1120-#ifdef GET16_LABELS
1121-/* src_wid src_endswap sign_toggle */
1122-static void *const get16_labels[5 * 2 * 2 + 4 * 3] = {
1123- &&get16_1_10, /* 8h -> 16h */
1124- &&get16_1_90, /* 8h ^> 16h */
1125- &&get16_1_10, /* 8s -> 16h */
1126- &&get16_1_90, /* 8s ^> 16h */
1127- &&get16_12_12, /* 16h -> 16h */
1128- &&get16_12_92, /* 16h ^> 16h */
1129- &&get16_12_21, /* 16s -> 16h */
1130- &&get16_12_A1, /* 16s ^> 16h */
1131+static inline uint16_t get16(const char *src, unsigned int idx) {
1132+ switch(idx) {
1133+ case 0: /* 8h -> 16h */
1134+ case 2: /* 8s -> 16h */ return (uint16_t)as_u8c(src) << 8;
1135+ case 1: /* 8h ^> 16h */
1136+ case 3: /* 8s ^> 16h */ return (uint16_t)(as_u8c(src) ^ 0x80) << 8;
1137+ case 4: /* 16h -> 16h */ return as_u16c(src);
1138+ case 5: /* 16h ^> 16h */ return as_u16c(src) ^ 0x8000;
1139+ case 6: /* 16s -> 16h */ return bswap_16(as_u16c(src));
1140+ case 7: /* 16s ^> 16h */ return bswap_16(as_u16c(src) ^ 0x80);
1141 /* 4 byte formats */
1142- &&get16_0123_12, /* 24h -> 16h */
1143- &&get16_0123_92, /* 24h ^> 16h */
1144- &&get16_1230_32, /* 24s -> 16h */
1145- &&get16_1230_B2, /* 24s ^> 16h */
1146- &&get16_1234_12, /* 32h -> 16h */
1147- &&get16_1234_92, /* 32h ^> 16h */
1148- &&get16_1234_43, /* 32s -> 16h */
1149- &&get16_1234_C3, /* 32s ^> 16h */
1150- &&get16_0123_12_20, /* 20h -> 16h */
1151- &&get16_0123_92_20, /* 20h ^> 16h */
1152- &&get16_1230_32_20, /* 20s -> 16h */
1153- &&get16_1230_B2_20, /* 20s ^> 16h */
1154+ case 8: /* 24h -> 16h */ return as_u32c(src) >> 8;
1155+ case 9: /* 24h ^> 16h */ return (as_u32c(src) >> 8) ^ 0x8000;
1156+ case 10: /* 24s -> 16h */ return bswap_16(as_u32c(src) >> 8);
1157+ case 11: /* 24s ^> 16h */ return bswap_16((as_u32c(src) >> 8) ^ 0x80);
1158+ case 12: /* 32h -> 16h */ return as_u32c(src) >> 16;
1159+ case 13: /* 32h ^> 16h */ return (as_u32c(src) >> 16) ^ 0x8000;
1160+ case 14: /* 32s -> 16h */ return bswap_16(as_u32c(src));
1161+ case 15: /* 32s ^> 16h */ return bswap_16(as_u32c(src) ^ 0x80);
1162+ case 16: /* 20h -> 16h */ return as_u32c(src) >> 4;
1163+ case 17: /* 20h ^> 16h */ return (as_u32c(src) >> 4) ^ 0x8000;
1164+ case 18: /* 20s -> 16h */ return bswap_32(as_u32c(src)) >> 4;
1165+ case 19: /* 20s ^> 16h */ return (bswap_32(as_u32c(src)) >> 4) ^ 0x8000;
1166 /* 3bytes format */
1167- &&get16_123_12, /* 24h -> 16h */
1168- &&get16_123_92, /* 24h ^> 16h */
1169- &&get16_123_32, /* 24s -> 16h */
1170- &&get16_123_B2, /* 24s ^> 16h */
1171- &&get16_123_12_20, /* 20h -> 16h */
1172- &&get16_123_92_20, /* 20h ^> 16h */
1173- &&get16_123_32_20, /* 20s -> 16h */
1174- &&get16_123_B2_20, /* 20s ^> 16h */
1175- &&get16_123_12_18, /* 18h -> 16h */
1176- &&get16_123_92_18, /* 18h ^> 16h */
1177- &&get16_123_32_18, /* 18s -> 16h */
1178- &&get16_123_B2_18, /* 18s ^> 16h */
1179-};
1180-#endif
1181-
1182-#ifdef GET16_END
1183-while(0) {
1184-get16_1_10: sample = (uint16_t)as_u8c(src) << 8; goto GET16_END;
1185-get16_1_90: sample = (uint16_t)(as_u8c(src) ^ 0x80) << 8; goto GET16_END;
1186-get16_12_12: sample = as_u16c(src); goto GET16_END;
1187-get16_12_92: sample = as_u16c(src) ^ 0x8000; goto GET16_END;
1188-get16_12_21: sample = bswap_16(as_u16c(src)); goto GET16_END;
1189-get16_12_A1: sample = bswap_16(as_u16c(src) ^ 0x80); goto GET16_END;
1190-get16_0123_12: sample = as_u32c(src) >> 8; goto GET16_END;
1191-get16_0123_92: sample = (as_u32c(src) >> 8) ^ 0x8000; goto GET16_END;
1192-get16_1230_32: sample = bswap_16(as_u32c(src) >> 8); goto GET16_END;
1193-get16_1230_B2: sample = bswap_16((as_u32c(src) >> 8) ^ 0x80); goto GET16_END;
1194-get16_1234_12: sample = as_u32c(src) >> 16; goto GET16_END;
1195-get16_1234_92: sample = (as_u32c(src) >> 16) ^ 0x8000; goto GET16_END;
1196-get16_1234_43: sample = bswap_16(as_u32c(src)); goto GET16_END;
1197-get16_1234_C3: sample = bswap_16(as_u32c(src) ^ 0x80); goto GET16_END;
1198-get16_0123_12_20: sample = as_u32c(src) >> 4; goto GET16_END;
1199-get16_0123_92_20: sample = (as_u32c(src) >> 4) ^ 0x8000; goto GET16_END;
1200-get16_1230_32_20: sample = bswap_32(as_u32c(src)) >> 4; goto GET16_END;
1201-get16_1230_B2_20: sample = (bswap_32(as_u32c(src)) >> 4) ^ 0x8000; goto GET16_END;
1202-get16_123_12: sample = _get_triple(src) >> 8; goto GET16_END;
1203-get16_123_92: sample = (_get_triple(src) >> 8) ^ 0x8000; goto GET16_END;
1204-get16_123_32: sample = _get_triple_s(src) >> 8; goto GET16_END;
1205-get16_123_B2: sample = (_get_triple_s(src) >> 8) ^ 0x8000; goto GET16_END;
1206-get16_123_12_20: sample = _get_triple(src) >> 4; goto GET16_END;
1207-get16_123_92_20: sample = (_get_triple(src) >> 4) ^ 0x8000; goto GET16_END;
1208-get16_123_32_20: sample = _get_triple_s(src) >> 4; goto GET16_END;
1209-get16_123_B2_20: sample = (_get_triple_s(src) >> 4) ^ 0x8000; goto GET16_END;
1210-get16_123_12_18: sample = _get_triple(src) >> 2; goto GET16_END;
1211-get16_123_92_18: sample = (_get_triple(src) >> 2) ^ 0x8000; goto GET16_END;
1212-get16_123_32_18: sample = _get_triple_s(src) >> 2; goto GET16_END;
1213-get16_123_B2_18: sample = (_get_triple_s(src) >> 2) ^ 0x8000; goto GET16_END;
1214+ case 20: /* 24h -> 16h */ return _get_triple(src) >> 8;
1215+ case 21: /* 24h ^> 16h */ return (_get_triple(src) >> 8) ^ 0x8000;
1216+ case 22: /* 24s -> 16h */ return _get_triple_s(src) >> 8;
1217+ case 23: /* 24s ^> 16h */ return (_get_triple_s(src) >> 8) ^ 0x8000;
1218+ case 24: /* 20h -> 16h */ return _get_triple(src) >> 4;
1219+ case 25: /* 20h ^> 16h */ return (_get_triple(src) >> 4) ^ 0x8000;
1220+ case 26: /* 20s -> 16h */ return _get_triple_s(src) >> 4;
1221+ case 27: /* 20s ^> 16h */ return (_get_triple_s(src) >> 4) ^ 0x8000;
1222+ case 28: /* 18h -> 16h */ return _get_triple(src) >> 2;
1223+ case 29: /* 18h ^> 16h */ return (_get_triple(src) >> 2) ^ 0x8000;
1224+ case 30: /* 18s -> 16h */ return _get_triple_s(src) >> 2;
1225+ case 31: /* 18s ^> 16h */ return (_get_triple_s(src) >> 2) ^ 0x8000;
1226+ default: assert(0);
1227+ }
1228 }
1229-#endif
1230
1231-#ifdef PUT16_LABELS
1232-/* dst_wid dst_endswap sign_toggle */
1233-static void *const put16_labels[5 * 2 * 2 + 4 * 3] = {
1234- &&put16_12_1, /* 16h -> 8h */
1235- &&put16_12_9, /* 16h ^> 8h */
1236- &&put16_12_1, /* 16h -> 8s */
1237- &&put16_12_9, /* 16h ^> 8s */
1238- &&put16_12_12, /* 16h -> 16h */
1239- &&put16_12_92, /* 16h ^> 16h */
1240- &&put16_12_21, /* 16h -> 16s */
1241- &&put16_12_29, /* 16h ^> 16s */
1242+static inline void put16(char *dst, int16_t sample, unsigned int idx)
1243+{
1244+ switch (idx) {
1245+ case 0: /* 16h -> 8h */
1246+ case 2: /* 16h -> 8s */ as_u8(dst) = sample >> 8; break;
1247+ case 1: /* 16h ^> 8h */
1248+ case 3: /* 16h ^> 8s */ as_u8(dst) = (sample >> 8) ^ 0x80; break;
1249+ case 4: /* 16h -> 16h */ as_u16(dst) = sample; break;
1250+ case 5: /* 16h ^> 16h */ as_u16(dst) = sample ^ 0x8000; break;
1251+ case 6: /* 16h -> 16s */ as_u16(dst) = bswap_16(sample); break;
1252+ case 7: /* 16h ^> 16s */ as_u16(dst) = bswap_16(sample) ^ 0x80; break;
1253 /* 4 byte formats */
1254- &&put16_12_0120, /* 16h -> 24h */
1255- &&put16_12_0920, /* 16h ^> 24h */
1256- &&put16_12_0210, /* 16h -> 24s */
1257- &&put16_12_0290, /* 16h ^> 24s */
1258- &&put16_12_1200, /* 16h -> 32h */
1259- &&put16_12_9200, /* 16h ^> 32h */
1260- &&put16_12_0021, /* 16h -> 32s */
1261- &&put16_12_0029, /* 16h ^> 32s */
1262- &&put16_12_0120_20, /* 16h -> 20h */
1263- &&put16_12_0920_20, /* 16h ^> 20h */
1264- &&put16_12_0210_20, /* 16h -> 20s */
1265- &&put16_12_0290_20, /* 16h ^> 20s */
1266+ case 8: /* 16h -> 24h */ as_u32(dst) = sx24((uint32_t)sample << 8); break;
1267+ case 9: /* 16h ^> 24h */ as_u32(dst) = sx24((uint32_t)(sample ^ 0x8000) << 8); break;
1268+ case 10: /* 16h -> 24s */ as_u32(dst) = sx24s((uint32_t)bswap_16(sample) << 8); break;
1269+ case 11: /* 16h ^> 24s */ as_u32(dst) = sx24s((uint32_t)(bswap_16(sample) ^ 0x80) << 8); break;
1270+ case 12: /* 16h -> 32h */ as_u32(dst) = (uint32_t)sample << 16; break;
1271+ case 13: /* 16h ^> 32h */ as_u32(dst) = (uint32_t)(sample ^ 0x8000) << 16; break;
1272+ case 14: /* 16h -> 32s */ as_u32(dst) = (uint32_t)bswap_16(sample); break;
1273+ case 15: /* 16h ^> 32s */ as_u32(dst) = (uint32_t)bswap_16(sample) ^ 0x80; break;
1274+ case 16: /* 16h -> 20h */ as_u32(dst) = sx20((uint32_t)sample << 4); break;
1275+ case 17: /* 16h ^> 20h */ as_u32(dst) = sx20((uint32_t)(sample ^ 0x8000) << 4); break;
1276+ case 18: /* 16h -> 20s */ as_u32(dst) = bswap_32(sx20((uint32_t)sample << 4)); break;
1277+ case 19: /* 16h ^> 20s */ as_u32(dst) = bswap_32(sx20((uint32_t)(sample ^ 0x8000) << 4)); break;
1278 /* 3bytes format */
1279- &&put16_12_120, /* 16h -> 24h */
1280- &&put16_12_920, /* 16h ^> 24h */
1281- &&put16_12_021, /* 16h -> 24s */
1282- &&put16_12_029, /* 16h ^> 24s */
1283- &&put16_12_120_20, /* 16h -> 20h */
1284- &&put16_12_920_20, /* 16h ^> 20h */
1285- &&put16_12_021_20, /* 16h -> 20s */
1286- &&put16_12_029_20, /* 16h ^> 20s */
1287- &&put16_12_120_18, /* 16h -> 18h */
1288- &&put16_12_920_18, /* 16h ^> 18h */
1289- &&put16_12_021_18, /* 16h -> 18s */
1290- &&put16_12_029_18, /* 16h ^> 18s */
1291-};
1292-#endif
1293-
1294-#ifdef PUT16_END
1295-while (0) {
1296-put16_12_1: as_u8(dst) = sample >> 8; goto PUT16_END;
1297-put16_12_9: as_u8(dst) = (sample >> 8) ^ 0x80; goto PUT16_END;
1298-put16_12_12: as_u16(dst) = sample; goto PUT16_END;
1299-put16_12_92: as_u16(dst) = sample ^ 0x8000; goto PUT16_END;
1300-put16_12_21: as_u16(dst) = bswap_16(sample); goto PUT16_END;
1301-put16_12_29: as_u16(dst) = bswap_16(sample) ^ 0x80; goto PUT16_END;
1302-put16_12_0120: as_u32(dst) = sx24((uint32_t)sample << 8); goto PUT16_END;
1303-put16_12_0920: as_u32(dst) = sx24((uint32_t)(sample ^ 0x8000) << 8); goto PUT16_END;
1304-put16_12_0210: as_u32(dst) = sx24s((uint32_t)bswap_16(sample) << 8); goto PUT16_END;
1305-put16_12_0290: as_u32(dst) = sx24s((uint32_t)(bswap_16(sample) ^ 0x80) << 8); goto PUT16_END;
1306-put16_12_1200: as_u32(dst) = (uint32_t)sample << 16; goto PUT16_END;
1307-put16_12_9200: as_u32(dst) = (uint32_t)(sample ^ 0x8000) << 16; goto PUT16_END;
1308-put16_12_0021: as_u32(dst) = (uint32_t)bswap_16(sample); goto PUT16_END;
1309-put16_12_0029: as_u32(dst) = (uint32_t)bswap_16(sample) ^ 0x80; goto PUT16_END;
1310-put16_12_0120_20: as_u32(dst) = sx20((uint32_t)sample << 4); goto PUT16_END;
1311-put16_12_0920_20: as_u32(dst) = sx20((uint32_t)(sample ^ 0x8000) << 4); goto PUT16_END;
1312-put16_12_0210_20: as_u32(dst) = bswap_32(sx20((uint32_t)sample << 4)); goto PUT16_END;
1313-put16_12_0290_20: as_u32(dst) = bswap_32(sx20((uint32_t)(sample ^ 0x8000) << 4)); goto PUT16_END;
1314-put16_12_120: _put_triple(dst, (uint32_t)sample << 8); goto PUT16_END;
1315-put16_12_920: _put_triple(dst, (uint32_t)(sample ^ 0x8000) << 8); goto PUT16_END;
1316-put16_12_021: _put_triple_s(dst, (uint32_t)sample << 8); goto PUT16_END;
1317-put16_12_029: _put_triple_s(dst, (uint32_t)(sample ^ 0x8000) << 8); goto PUT16_END;
1318-put16_12_120_20: _put_triple(dst, (uint32_t)sample << 4); goto PUT16_END;
1319-put16_12_920_20: _put_triple(dst, (uint32_t)(sample ^ 0x8000) << 4); goto PUT16_END;
1320-put16_12_021_20: _put_triple_s(dst, (uint32_t)sample << 4); goto PUT16_END;
1321-put16_12_029_20: _put_triple_s(dst, (uint32_t)(sample ^ 0x8000) << 4); goto PUT16_END;
1322-put16_12_120_18: _put_triple(dst, (uint32_t)sample << 2); goto PUT16_END;
1323-put16_12_920_18: _put_triple(dst, (uint32_t)(sample ^ 0x8000) << 2); goto PUT16_END;
1324-put16_12_021_18: _put_triple_s(dst, (uint32_t)sample << 2); goto PUT16_END;
1325-put16_12_029_18: _put_triple_s(dst, (uint32_t)(sample ^ 0x8000) << 2); goto PUT16_END;
1326+ case 20: /* 16h -> 24h */ _put_triple(dst, (uint32_t)sample << 8); break;
1327+ case 21: /* 16h ^> 24h */ _put_triple(dst, (uint32_t)(sample ^ 0x8000) << 8); break;
1328+ case 22: /* 16h -> 24s */ _put_triple_s(dst, (uint32_t)sample << 8); break;
1329+ case 23: /* 16h ^> 24s */ _put_triple_s(dst, (uint32_t)(sample ^ 0x8000) << 8); break;
1330+ case 24: /* 16h -> 20h */ _put_triple(dst, (uint32_t)sample << 4); break;
1331+ case 25: /* 16h ^> 20h */ _put_triple(dst, (uint32_t)(sample ^ 0x8000) << 4); break;
1332+ case 26: /* 16h -> 20s */ _put_triple_s(dst, (uint32_t)sample << 4); break;
1333+ case 27: /* 16h ^> 20s */ _put_triple_s(dst, (uint32_t)(sample ^ 0x8000) << 4); break;
1334+ case 28: /* 16h -> 18h */ _put_triple(dst, (uint32_t)sample << 2); break;
1335+ case 29: /* 16h ^> 18h */ _put_triple(dst, (uint32_t)(sample ^ 0x8000) << 2); break;
1336+ case 30: /* 16h -> 18s */ _put_triple_s(dst, (uint32_t)sample << 2); break;
1337+ case 31: /* 16h ^> 18s */ _put_triple_s(dst, (uint32_t)(sample ^ 0x8000) << 2); break;
1338+ default: assert(0);
1339+ }
1340 }
1341-#endif
1342-
1343-#ifdef CONV24_LABELS
1344-#define GET32_LABELS
1345-#define PUT32_LABELS
1346-#endif
1347
1348-#ifdef GET32_LABELS
1349-/* src_wid src_endswap sign_toggle */
1350-static void *const get32_labels[5 * 2 * 2 + 4 * 3] = {
1351- &&get32_1_1000, /* 8h -> 32h */
1352- &&get32_1_9000, /* 8h ^> 32h */
1353- &&get32_1_1000, /* 8s -> 32h */
1354- &&get32_1_9000, /* 8s ^> 32h */
1355- &&get32_12_1200, /* 16h -> 32h */
1356- &&get32_12_9200, /* 16h ^> 32h */
1357- &&get32_12_2100, /* 16s -> 32h */
1358- &&get32_12_A100, /* 16s ^> 32h */
1359+static inline int32_t get32(const char *src, unsigned int idx)
1360+{
1361+ switch (idx) {
1362+ case 0: /* 8h -> 32h */
1363+ case 2: /* 8s -> 32h */ return (uint32_t)as_u8c(src) << 24;
1364+ case 1: /* 8h ^> 32h */
1365+ case 3: /* 8s ^> 32h */ return (uint32_t)(as_u8c(src) ^ 0x80) << 24;
1366+ case 4: /* 16h -> 32h */ return (uint32_t)as_u16c(src) << 16;
1367+ case 5: /* 16h ^> 32h */ return (uint32_t)(as_u16c(src) ^ 0x8000) << 16;
1368+ case 6: /* 16s -> 32h */ return (uint32_t)bswap_16(as_u16c(src)) << 16;
1369+ case 7: /* 16s ^> 32h */ return (uint32_t)bswap_16(as_u16c(src) ^ 0x80) << 16;
1370 /* 4 byte formats */
1371- &&get32_0123_1230, /* 24h -> 32h */
1372- &&get32_0123_9230, /* 24h ^> 32h */
1373- &&get32_1230_3210, /* 24s -> 32h */
1374- &&get32_1230_B210, /* 24s ^> 32h */
1375- &&get32_1234_1234, /* 32h -> 32h */
1376- &&get32_1234_9234, /* 32h ^> 32h */
1377- &&get32_1234_4321, /* 32s -> 32h */
1378- &&get32_1234_C321, /* 32s ^> 32h */
1379- &&get32_0123_1230_20, /* 20h -> 32h */
1380- &&get32_0123_9230_20, /* 20h ^> 32h */
1381- &&get32_1230_3210_20, /* 20s -> 32h */
1382- &&get32_1230_B210_20, /* 20s ^> 32h */
1383+ case 8: /* 24h -> 32h */ return as_u32c(src) << 8;
1384+ case 9: /* 24h ^> 32h */ return (as_u32c(src) << 8) ^ 0x80000000;
1385+ case 10: /* 24s -> 32h */ return bswap_32(as_u32c(src) >> 8);
1386+ case 11: /* 24s ^> 32h */ return bswap_32((as_u32c(src) >> 8) ^ 0x80);
1387+ case 12: /* 32h -> 32h */ return as_u32c(src);
1388+ case 13: /* 32h ^> 32h */ return as_u32c(src) ^ 0x80000000;
1389+ case 14: /* 32s -> 32h */ return bswap_32(as_u32c(src));
1390+ case 15: /* 32s ^> 32h */ return bswap_32(as_u32c(src) ^ 0x80);
1391+ case 16: /* 20h -> 32h */ return as_u32c(src) << 12;
1392+ case 17: /* 20h ^> 32h */ return (as_u32c(src) << 12) ^ 0x80000000;
1393+ case 18: /* 20s -> 32h */ return bswap_32(as_u32c(src)) << 12;
1394+ case 19: /* 20s ^> 32h */ return (bswap_32(as_u32c(src)) << 12) ^ 0x80000000;
1395 /* 3bytes format */
1396- &&get32_123_1230, /* 24h -> 32h */
1397- &&get32_123_9230, /* 24h ^> 32h */
1398- &&get32_123_3210, /* 24s -> 32h */
1399- &&get32_123_B210, /* 24s ^> 32h */
1400- &&get32_123_1230_20, /* 20h -> 32h */
1401- &&get32_123_9230_20, /* 20h ^> 32h */
1402- &&get32_123_3210_20, /* 20s -> 32h */
1403- &&get32_123_B210_20, /* 20s ^> 32h */
1404- &&get32_123_1230_18, /* 18h -> 32h */
1405- &&get32_123_9230_18, /* 18h ^> 32h */
1406- &&get32_123_3210_18, /* 18s -> 32h */
1407- &&get32_123_B210_18, /* 18s ^> 32h */
1408-};
1409-#endif
1410-
1411-#ifdef CONV24_END
1412-#define GET32_END __conv24_get
1413-#endif
1414-
1415-#ifdef GET32_END
1416-while (0) {
1417-get32_1_1000: sample = (uint32_t)as_u8c(src) << 24; goto GET32_END;
1418-get32_1_9000: sample = (uint32_t)(as_u8c(src) ^ 0x80) << 24; goto GET32_END;
1419-get32_12_1200: sample = (uint32_t)as_u16c(src) << 16; goto GET32_END;
1420-get32_12_9200: sample = (uint32_t)(as_u16c(src) ^ 0x8000) << 16; goto GET32_END;
1421-get32_12_2100: sample = (uint32_t)bswap_16(as_u16c(src)) << 16; goto GET32_END;
1422-get32_12_A100: sample = (uint32_t)bswap_16(as_u16c(src) ^ 0x80) << 16; goto GET32_END;
1423-get32_0123_1230: sample = as_u32c(src) << 8; goto GET32_END;
1424-get32_0123_9230: sample = (as_u32c(src) << 8) ^ 0x80000000; goto GET32_END;
1425-get32_1230_3210: sample = bswap_32(as_u32c(src) >> 8); goto GET32_END;
1426-get32_1230_B210: sample = bswap_32((as_u32c(src) >> 8) ^ 0x80); goto GET32_END;
1427-get32_1234_1234: sample = as_u32c(src); goto GET32_END;
1428-get32_1234_9234: sample = as_u32c(src) ^ 0x80000000; goto GET32_END;
1429-get32_1234_4321: sample = bswap_32(as_u32c(src)); goto GET32_END;
1430-get32_1234_C321: sample = bswap_32(as_u32c(src) ^ 0x80); goto GET32_END;
1431-get32_0123_1230_20: sample = as_u32c(src) << 12; goto GET32_END;
1432-get32_0123_9230_20: sample = (as_u32c(src) << 12) ^ 0x80000000; goto GET32_END;
1433-get32_1230_3210_20: sample = bswap_32(as_u32c(src)) << 12; goto GET32_END;
1434-get32_1230_B210_20: sample = (bswap_32(as_u32c(src)) << 12) ^ 0x80000000; goto GET32_END;
1435-get32_123_1230: sample = _get_triple(src) << 8; goto GET32_END;
1436-get32_123_9230: sample = (_get_triple(src) << 8) ^ 0x80000000; goto GET32_END;
1437-get32_123_3210: sample = _get_triple_s(src) << 8; goto GET32_END;
1438-get32_123_B210: sample = (_get_triple_s(src) << 8) ^ 0x80000000; goto GET32_END;
1439-get32_123_1230_20: sample = _get_triple(src) << 12; goto GET32_END;
1440-get32_123_9230_20: sample = (_get_triple(src) << 12) ^ 0x80000000; goto GET32_END;
1441-get32_123_3210_20: sample = _get_triple_s(src) << 12; goto GET32_END;
1442-get32_123_B210_20: sample = (_get_triple_s(src) << 12) ^ 0x80000000; goto GET32_END;
1443-get32_123_1230_18: sample = _get_triple(src) << 14; goto GET32_END;
1444-get32_123_9230_18: sample = (_get_triple(src) << 14) ^ 0x80000000; goto GET32_END;
1445-get32_123_3210_18: sample = _get_triple_s(src) << 14; goto GET32_END;
1446-get32_123_B210_18: sample = (_get_triple_s(src) << 14) ^ 0x80000000; goto GET32_END;
1447+ case 20: /* 24h -> 32h */ return _get_triple(src) << 8;
1448+ case 21: /* 24h ^> 32h */ return (_get_triple(src) << 8) ^ 0x80000000;
1449+ case 22: /* 24s -> 32h */ return _get_triple_s(src) << 8;
1450+ case 23: /* 24s ^> 32h */ return (_get_triple_s(src) << 8) ^ 0x80000000;
1451+ case 24: /* 20h -> 32h */ return _get_triple(src) << 12;
1452+ case 25: /* 20h ^> 32h */ return (_get_triple(src) << 12) ^ 0x80000000;
1453+ case 26: /* 20s -> 32h */ return _get_triple_s(src) << 12;
1454+ case 27: /* 20s ^> 32h */ return (_get_triple_s(src) << 12) ^ 0x80000000;
1455+ case 28: /* 18h -> 32h */ return _get_triple(src) << 14;
1456+ case 29: /* 18h ^> 32h */ return (_get_triple(src) << 14) ^ 0x80000000;
1457+ case 30: /* 18s -> 32h */ return _get_triple_s(src) << 14;
1458+ case 31: /* 18s ^> 32h */ return (_get_triple_s(src) << 14) ^ 0x80000000;
1459+ default: assert(0);
1460+ }
1461 }
1462-#endif
1463
1464-#ifdef CONV24_END
1465-__conv24_get: goto *put;
1466-#define PUT32_END CONV24_END
1467-#endif
1468-
1469-#ifdef PUT32_LABELS
1470-/* dst_wid dst_endswap sign_toggle */
1471-static void *const put32_labels[5 * 2 * 2 + 4 * 3] = {
1472- &&put32_1234_1, /* 32h -> 8h */
1473- &&put32_1234_9, /* 32h ^> 8h */
1474- &&put32_1234_1, /* 32h -> 8s */
1475- &&put32_1234_9, /* 32h ^> 8s */
1476- &&put32_1234_12, /* 32h -> 16h */
1477- &&put32_1234_92, /* 32h ^> 16h */
1478- &&put32_1234_21, /* 32h -> 16s */
1479- &&put32_1234_29, /* 32h ^> 16s */
1480+static inline void put32(char *dst, int32_t sample, unsigned int idx)
1481+{
1482+ switch (idx) {
1483+ case 0: /* 32h -> 8h */
1484+ case 2: /* 32h -> 8s */ as_u8(dst) = sample >> 24; break;
1485+ case 1: /* 32h ^> 8h */
1486+ case 3: /* 32h ^> 8s */ as_u8(dst) = (sample >> 24) ^ 0x80; break;
1487+ case 4: /* 32h -> 16h */ as_u16(dst) = sample >> 16; break;
1488+ case 5: /* 32h ^> 16h */ as_u16(dst) = (sample >> 16) ^ 0x8000; break;
1489+ case 6: /* 32h -> 16s */ as_u16(dst) = bswap_16(sample >> 16); break;
1490+ case 7: /* 32h ^> 16s */ as_u16(dst) = bswap_16(sample >> 16) ^ 0x80; break;
1491 /* 4 byte formats */
1492- &&put32_1234_0123, /* 32h -> 24h */
1493- &&put32_1234_0923, /* 32h ^> 24h */
1494- &&put32_1234_3210, /* 32h -> 24s */
1495- &&put32_1234_3290, /* 32h ^> 24s */
1496- &&put32_1234_1234, /* 32h -> 32h */
1497- &&put32_1234_9234, /* 32h ^> 32h */
1498- &&put32_1234_4321, /* 32h -> 32s */
1499- &&put32_1234_4329, /* 32h ^> 32s */
1500- &&put32_1234_0123_20, /* 32h -> 20h */
1501- &&put32_1234_0923_20, /* 32h ^> 20h */
1502- &&put32_1234_3210_20, /* 32h -> 20s */
1503- &&put32_1234_3290_20, /* 32h ^> 20s */
1504+ case 8: /* 32h -> 24h */ as_u32(dst) = sx24(sample >> 8); break;
1505+ case 9: /* 32h ^> 24h */ as_u32(dst) = sx24((sample >> 8) ^ 0x800000); break;
1506+ case 10: /* 32h -> 24s */ as_u32(dst) = sx24s(bswap_32(sample) << 8); break;
1507+ case 11: /* 32h ^> 24s */ as_u32(dst) = sx24s((bswap_32(sample) ^ 0x80) << 8); break;
1508+ case 12: /* 32h -> 32h */ as_u32(dst) = sample; break;
1509+ case 13: /* 32h ^> 32h */ as_u32(dst) = sample ^ 0x80000000; break;
1510+ case 14: /* 32h -> 32s */ as_u32(dst) = bswap_32(sample); break;
1511+ case 15: /* 32h ^> 32s */ as_u32(dst) = bswap_32(sample) ^ 0x80; break;
1512+ case 16: /* 32h -> 20h */ as_u32(dst) = sx20(sample >> 12); break;
1513+ case 17: /* 32h ^> 20h */ as_u32(dst) = sx20((sample ^ 0x80000000) >> 12); break;
1514+ case 18: /* 32h -> 20s */ as_u32(dst) = bswap_32(sx20(sample >> 12)); break;
1515+ case 19: /* 32h ^> 20s */ as_u32(dst) = bswap_32(sx20((sample ^ 0x80000000) >> 12)); break;
1516 /* 3bytes format */
1517- &&put32_1234_123, /* 32h -> 24h */
1518- &&put32_1234_923, /* 32h ^> 24h */
1519- &&put32_1234_321, /* 32h -> 24s */
1520- &&put32_1234_329, /* 32h ^> 24s */
1521- &&put32_1234_123_20, /* 32h -> 20h */
1522- &&put32_1234_923_20, /* 32h ^> 20h */
1523- &&put32_1234_321_20, /* 32h -> 20s */
1524- &&put32_1234_329_20, /* 32h ^> 20s */
1525- &&put32_1234_123_18, /* 32h -> 18h */
1526- &&put32_1234_923_18, /* 32h ^> 18h */
1527- &&put32_1234_321_18, /* 32h -> 18s */
1528- &&put32_1234_329_18, /* 32h ^> 18s */
1529-};
1530-#endif
1531-
1532-#ifdef CONV24_LABELS
1533-#undef GET32_LABELS
1534-#undef PUT32_LABELS
1535-#endif
1536-
1537-#ifdef PUT32_END
1538-while (0) {
1539-put32_1234_1: as_u8(dst) = sample >> 24; goto PUT32_END;
1540-put32_1234_9: as_u8(dst) = (sample >> 24) ^ 0x80; goto PUT32_END;
1541-put32_1234_12: as_u16(dst) = sample >> 16; goto PUT32_END;
1542-put32_1234_92: as_u16(dst) = (sample >> 16) ^ 0x8000; goto PUT32_END;
1543-put32_1234_21: as_u16(dst) = bswap_16(sample >> 16); goto PUT32_END;
1544-put32_1234_29: as_u16(dst) = bswap_16(sample >> 16) ^ 0x80; goto PUT32_END;
1545-put32_1234_0123: as_u32(dst) = sx24(sample >> 8); goto PUT32_END;
1546-put32_1234_0923: as_u32(dst) = sx24((sample >> 8) ^ 0x800000); goto PUT32_END;
1547-put32_1234_3210: as_u32(dst) = sx24s(bswap_32(sample) << 8); goto PUT32_END;
1548-put32_1234_3290: as_u32(dst) = sx24s((bswap_32(sample) ^ 0x80) << 8); goto PUT32_END;
1549-put32_1234_1234: as_u32(dst) = sample; goto PUT32_END;
1550-put32_1234_9234: as_u32(dst) = sample ^ 0x80000000; goto PUT32_END;
1551-put32_1234_4321: as_u32(dst) = bswap_32(sample); goto PUT32_END;
1552-put32_1234_4329: as_u32(dst) = bswap_32(sample) ^ 0x80; goto PUT32_END;
1553-put32_1234_0123_20: as_u32(dst) = sx20(sample >> 12); goto PUT32_END;
1554-put32_1234_0923_20: as_u32(dst) = sx20((sample ^ 0x80000000) >> 12); goto PUT32_END;
1555-put32_1234_3210_20: as_u32(dst) = bswap_32(sx20(sample >> 12)); goto PUT32_END;
1556-put32_1234_3290_20: as_u32(dst) = bswap_32(sx20((sample ^ 0x80000000) >> 12)); goto PUT32_END;
1557-put32_1234_123: _put_triple(dst, sample >> 8); goto PUT32_END;
1558-put32_1234_923: _put_triple(dst, (sample ^ 0x80000000) >> 8); goto PUT32_END;
1559-put32_1234_321: _put_triple_s(dst, sample >> 8); goto PUT32_END;
1560-put32_1234_329: _put_triple_s(dst, (sample ^ 0x80000000) >> 8); goto PUT32_END;
1561-put32_1234_123_20: _put_triple(dst, sample >> 12); goto PUT32_END;
1562-put32_1234_923_20: _put_triple(dst, (sample ^ 0x80000000) >> 12); goto PUT32_END;
1563-put32_1234_321_20: _put_triple_s(dst, sample >> 12); goto PUT32_END;
1564-put32_1234_329_20: _put_triple_s(dst, (sample ^ 0x80000000) >> 12); goto PUT32_END;
1565-put32_1234_123_18: _put_triple(dst, sample >> 14); goto PUT32_END;
1566-put32_1234_923_18: _put_triple(dst, (sample ^ 0x80000000) >> 14); goto PUT32_END;
1567-put32_1234_321_18: _put_triple_s(dst, sample >> 14); goto PUT32_END;
1568-put32_1234_329_18: _put_triple_s(dst, (sample ^ 0x80000000) >> 14); goto PUT32_END;
1569+ case 20: /* 32h -> 24h */ _put_triple(dst, sample >> 8); break;
1570+ case 21: /* 32h ^> 24h */ _put_triple(dst, (sample ^ 0x80000000) >> 8); break;
1571+ case 22: /* 32h -> 24s */ _put_triple_s(dst, sample >> 8); break;
1572+ case 23: /* 32h ^> 24s */ _put_triple_s(dst, (sample ^ 0x80000000) >> 8); break;
1573+ case 24: /* 32h -> 20h */ _put_triple(dst, sample >> 12); break;
1574+ case 25: /* 32h ^> 20h */ _put_triple(dst, (sample ^ 0x80000000) >> 12); break;
1575+ case 26: /* 32h -> 20s */ _put_triple_s(dst, sample >> 12); break;
1576+ case 27: /* 32h ^> 20s */ _put_triple_s(dst, (sample ^ 0x80000000) >> 12); break;
1577+ case 28: /* 32h -> 18h */ _put_triple(dst, sample >> 14); break;
1578+ case 29: /* 32h ^> 18h */ _put_triple(dst, (sample ^ 0x80000000) >> 14); break;
1579+ case 30: /* 32h -> 18s */ _put_triple_s(dst, sample >> 14); break;
1580+ case 31: /* 32h ^> 18s */ _put_triple_s(dst, (sample ^ 0x80000000) >> 14); break;
1581+ default: assert(0);
1582+ }
1583 }
1584-#endif
1585-
1586-#ifdef CONV24_END
1587-#undef GET32_END
1588-#undef PUT32_END
1589-#endif
1590
1591-#ifdef PUT32F_LABELS
1592-/* type (0 = float, 1 = float64), endswap */
1593-static void *const put32float_labels[2 * 2] = {
1594- &&put32f_1234_1234F, /* 32h -> (float)h */
1595- &&put32f_1234_4321F, /* 32h -> (float)s */
1596- &&put32f_1234_1234D, /* 32h -> (float64)h */
1597- &&put32f_1234_4321D, /* 32h -> (float64)s */
1598-};
1599-#endif
1600+static inline void put32float(char *dst, int32_t sample, unsigned int idx)
1601+{
1602+ snd_tmp_float_t tmp_float;
1603+ snd_tmp_double_t tmp_double;
1604
1605-#ifdef PUT32F_END
1606-put32f_1234_1234F: as_float(dst) = (float_t)((int32_t)sample) / (float_t)0x80000000UL; goto PUT32F_END;
1607-put32f_1234_4321F: tmp_float.f = (float_t)((int32_t)sample) / (float_t)0x80000000UL;
1608- as_u32(dst) = bswap_32(tmp_float.i); goto PUT32F_END;
1609-put32f_1234_1234D: as_double(dst) = (double_t)((int32_t)sample) / (double_t)0x80000000UL; goto PUT32F_END;
1610-put32f_1234_4321D: tmp_double.d = (double_t)((int32_t)sample) / (double_t)0x80000000UL;
1611- as_u64(dst) = bswap_64(tmp_double.l); goto PUT32F_END;
1612-#endif
1613+ switch (idx) {
1614+ case 0: /* 32h -> (float)h */
1615+ as_float(dst) = (float_t)((int32_t)sample) / (float_t)0x80000000UL; break;
1616+ case 1: /* 32h -> (float)s */
1617+ tmp_float.f = (float_t)((int32_t)sample) / (float_t)0x80000000UL;
1618+ as_u32(dst) = bswap_32(tmp_float.i); break;
1619+ case 2: /* 32h -> (float64)h */
1620+ as_double(dst) = (double_t)((int32_t)sample) / (double_t)0x80000000UL; break;
1621+ case 3: /* 32h -> (float64)s */
1622+ tmp_double.d = (double_t)((int32_t)sample) / (double_t)0x80000000UL;
1623+ as_u64(dst) = bswap_64(tmp_double.l); break;
1624+ default: assert(0);
1625+ }
1626+}
1627
1628-#ifdef GET32F_LABELS
1629-/* type (0 = float, 1 = float64), endswap */
1630-static void *const get32float_labels[2 * 2] = {
1631- &&get32f_1234F_1234, /* (float)h -> 32h */
1632- &&get32f_4321F_1234, /* (float)s -> 32h */
1633- &&get32f_1234D_1234, /* (float64)h -> 32h */
1634- &&get32f_4321D_1234, /* (float64)s -> 32h */
1635-};
1636-#endif
1637+static inline int32_t get32float(const char *src, unsigned int idx)
1638+{
1639+ snd_tmp_float_t tmp_float;
1640+ snd_tmp_double_t tmp_double;
1641
1642-#ifdef GET32F_END
1643-get32f_1234F_1234: tmp_float.f = as_floatc(src);
1644- if (tmp_float.f >= 1.0)
1645- sample = 0x7fffffff;
1646- else if (tmp_float.f <= -1.0)
1647- sample = 0x80000000;
1648- else
1649- sample = (int32_t)(tmp_float.f * (float_t)0x80000000UL);
1650- goto GET32F_END;
1651-get32f_4321F_1234: tmp_float.i = bswap_32(as_u32c(src));
1652- if (tmp_float.f >= 1.0)
1653- sample = 0x7fffffff;
1654- else if (tmp_float.f <= -1.0)
1655- sample = 0x80000000;
1656- else
1657- sample = (int32_t)(tmp_float.f * (float_t)0x80000000UL);
1658- goto GET32F_END;
1659-get32f_1234D_1234: tmp_double.d = as_doublec(src);
1660- if (tmp_double.d >= 1.0)
1661- sample = 0x7fffffff;
1662- else if (tmp_double.d <= -1.0)
1663- sample = 0x80000000;
1664- else
1665- sample = (int32_t)(tmp_double.d * (double_t)0x80000000UL);
1666- goto GET32F_END;
1667-get32f_4321D_1234: tmp_double.l = bswap_64(as_u64c(src));
1668- if (tmp_double.d >= 1.0)
1669- sample = 0x7fffffff;
1670- else if (tmp_double.d <= -1.0)
1671- sample = 0x80000000;
1672- else
1673- sample = (int32_t)(tmp_double.d * (double_t)0x80000000UL);
1674- goto GET32F_END;
1675-#endif
1676+ switch (idx) {
1677+ case 0: /* (float)h -> 32h */
1678+ tmp_float.f = as_floatc(src);
1679+ if (tmp_float.f >= 1.0)
1680+ return 0x7fffffff;
1681+ if (tmp_float.f <= -1.0)
1682+ return 0x80000000;
1683+ return (int32_t)(tmp_float.f * (float_t)0x80000000UL);
1684+ case 1: /* (float)s -> 32h */
1685+ tmp_float.i = bswap_32(as_u32c(src));
1686+ if (tmp_float.f >= 1.0)
1687+ return 0x7fffffff;
1688+ if (tmp_float.f <= -1.0)
1689+ return 0x80000000;
1690+ return (int32_t)(tmp_float.f * (float_t)0x80000000UL);
1691+ case 2: /* (float64)h -> 32h */
1692+ tmp_double.d = as_doublec(src);
1693+ if (tmp_double.d >= 1.0)
1694+ return 0x7fffffff;
1695+ if (tmp_double.d <= -1.0)
1696+ return 0x80000000;
1697+ return (int32_t)(tmp_double.d * (double_t)0x80000000UL);
1698+ case 3: /* (float64)s -> 32h */
1699+ tmp_double.l = bswap_64(as_u64c(src));
1700+ if (tmp_double.d >= 1.0)
1701+ return 0x7fffffff;
1702+ if (tmp_double.d <= -1.0)
1703+ return 0x80000000;
1704+ return (int32_t)(tmp_double.d * (double_t)0x80000000UL);
1705+ default: assert(0);
1706+ }
1707+}
1708
1709 #undef as_u8
1710 #undef as_u16
1711--
17122.44.0
1713