OSDN Git Service

- removed bad get_triple_* for i386. this can access over pages.
[android-x86/external-alsa-lib.git] / src / pcm / plugin_ops.h
1 /*
2  *  Plugin sample operators with fast switch
3  *  Copyright (c) 2000 by Jaroslav Kysela <perex@suse.cz>
4  *
5  *
6  *   This library is free software; you can redistribute it and/or modify
7  *   it under the terms of the GNU Lesser General Public License as
8  *   published by the Free Software Foundation; either version 2.1 of
9  *   the License, or (at your option) any later version.
10  *
11  *   This program is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *   GNU Lesser General Public License for more details.
15  *
16  *   You should have received a copy of the GNU Lesser General Public
17  *   License along with this library; if not, write to the Free Software
18  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19  *
20  */
21
22 #define as_u8(ptr) (*(u_int8_t*)(ptr))
23 #define as_u16(ptr) (*(u_int16_t*)(ptr))
24 #define as_u32(ptr) (*(u_int32_t*)(ptr))
25 #define as_u64(ptr) (*(u_int64_t*)(ptr))
26 #define as_s8(ptr) (*(int8_t*)(ptr))
27 #define as_s16(ptr) (*(int16_t*)(ptr))
28 #define as_s32(ptr) (*(int32_t*)(ptr))
29 #define as_s64(ptr) (*(int64_t*)(ptr))
30 #define as_float(ptr) (*(float_t*)(ptr))
31 #define as_double(ptr) (*(double_t*)(ptr))
32
33 #define as_u8c(ptr) (*(const u_int8_t*)(ptr))
34 #define as_u16c(ptr) (*(const u_int16_t*)(ptr))
35 #ifdef SND_LITTLE_ENDIAN
36 #define as_u24c(ptr) (u_int32_t)(as_u8(ptr) | as_u8(((char *)ptr) + 1) << 8 | as_u8(((char *)ptr + 2) << 16)
37 #elif defined(SND_BIG_ENDIAN)
38 #define as_u24c(ptr) (u_int32_t)(as_u8(ptr) << 16 | as_u8(((char *)ptr) + 1) << 8 | as_u8(((char *)ptr + 2))
39 #else
40 #error "Wrong endian..."
41 #endif
42 #define as_u32c(ptr) (*(const u_int32_t*)(ptr))
43 #define as_u64c(ptr) (*(const u_int64_t*)(ptr))
44 #define as_s8c(ptr) (*(const int8_t*)(ptr))
45 #define as_s16c(ptr) (*(const int16_t*)(ptr))
46 #define as_s32c(ptr) (*(const int32_t*)(ptr))
47 #define as_s64c(ptr) (*(const int64_t*)(ptr))
48 #define as_floatc(ptr) (*(const float_t*)(ptr))
49 #define as_doublec(ptr) (*(const double_t*)(ptr))
50
51 #define _get_triple_le(ptr) (*(u_int8_t*)(ptr) | (u_int32_t)*((u_int8_t*)(ptr) + 1) << 8 | (u_int32_t)*((u_int8_t*)(ptr) + 2) << 16)
52 #define _get_triple_be(ptr) ((u_int32_t)*(u_int8_t*)(ptr) << 16 | (u_int32_t)*((u_int8_t*)(ptr) + 1) << 8 | *((u_int8_t*)(ptr) + 2))
53 #define _put_triple_le(ptr,val) do { \
54         u_int8_t *_tmp = (u_int8_t *)(ptr); \
55         u_int32_t _val = (val); \
56         _tmp[0] = _val; \
57         _tmp[1] = _val >> 8; \
58         _tmp[2] = _val >> 16; \
59 } while(0)
60 #define _put_triple_be(ptr,val) do { \
61         u_int8_t *_tmp = (u_int8_t *)(ptr); \
62         u_int32_t _val = (val); \
63         _tmp[0] = _val >> 16; \
64         _tmp[1] = _val >> 8; \
65         _tmp[2] = _val; \
66 } while(0)
67
68 #ifdef SNDRV_LITTLE_ENDIAN
69 #define _get_triple(ptr) _get_triple_le(ptr)
70 #define _get_triple_s(ptr) _get_triple_be(ptr)
71 #define _put_triple(ptr,val) _put_triple_le(ptr,val)
72 #define _put_triple_s(ptr,val) _put_triple_be(ptr,val)
73 #else
74 #define _get_triple(ptr) _get_triple_be(ptr)
75 #define _get_triple_s(ptr) _get_triple_le(ptr)
76 #define _put_triple(ptr,val) _put_triple_be(ptr,val)
77 #define _put_triple_s(ptr,val) _put_triple_le(ptr,val)
78 #endif
79
80 #ifdef COPY_LABELS
81 static void *copy_labels[5] = {
82         &&copy_8,
83         &&copy_16,
84         &&copy_24
85         &&copy_32,
86         &&copy_64
87 };
88 #endif
89
90 #ifdef COPY_END
91 while(0) {
92 copy_8: as_s8(dst) = as_s8c(src); goto COPY_END;
93 copy_16: as_s16(dst) = as_s16c(src); goto COPY_END;
94 copy_24: memcpy(dst,src,3); goto COPY_END;
95 copy_32: as_s32(dst) = as_s32c(src); goto COPY_END;
96 copy_64: as_s64(dst) = as_s64c(src); goto COPY_END;
97 }
98 #endif
99
100 #ifdef CONV_LABELS
101 /* src_wid src_endswap sign_toggle dst_wid dst_endswap */
102 static void *conv_labels[4 * 2 * 2 * 4 * 2] = {
103         &&conv_xxx1_xxx1,        /*  8h ->  8h */
104         &&conv_xxx1_xxx1,        /*  8h ->  8s */
105         &&conv_xxx1_xx10,        /*  8h -> 16h */
106         &&conv_xxx1_xx01,        /*  8h -> 16s */
107         &&conv_xxx1_x100,        /*  8h -> 24h */
108         &&conv_xxx1_001x,        /*  8h -> 24s */
109         &&conv_xxx1_1000,        /*  8h -> 32h */
110         &&conv_xxx1_0001,        /*  8h -> 32s */
111         &&conv_xxx1_xxx9,        /*  8h ^>  8h */
112         &&conv_xxx1_xxx9,        /*  8h ^>  8s */
113         &&conv_xxx1_xx90,        /*  8h ^> 16h */
114         &&conv_xxx1_xx09,        /*  8h ^> 16s */
115         &&conv_xxx1_x900,        /*  8h ^> 24h */
116         &&conv_xxx1_009x,        /*  8h ^> 24s */
117         &&conv_xxx1_9000,        /*  8h ^> 32h */
118         &&conv_xxx1_0009,        /*  8h ^> 32s */
119         &&conv_xxx1_xxx1,        /*  8s ->  8h */
120         &&conv_xxx1_xxx1,        /*  8s ->  8s */
121         &&conv_xxx1_xx10,        /*  8s -> 16h */
122         &&conv_xxx1_xx01,        /*  8s -> 16s */
123         &&conv_xxx1_x100,        /*  8s -> 24h */
124         &&conv_xxx1_001x,        /*  8s -> 24s */
125         &&conv_xxx1_1000,        /*  8s -> 32h */
126         &&conv_xxx1_0001,        /*  8s -> 32s */
127         &&conv_xxx1_xxx9,        /*  8s ^>  8h */
128         &&conv_xxx1_xxx9,        /*  8s ^>  8s */
129         &&conv_xxx1_xx90,        /*  8s ^> 16h */
130         &&conv_xxx1_xx09,        /*  8s ^> 16s */
131         &&conv_xxx1_x900,        /*  8s ^> 24h */
132         &&conv_xxx1_009x,        /*  8s ^> 24s */
133         &&conv_xxx1_9000,        /*  8s ^> 32h */
134         &&conv_xxx1_0009,        /*  8s ^> 32s */
135         &&conv_xx12_xxx1,        /* 16h ->  8h */
136         &&conv_xx12_xxx1,        /* 16h ->  8s */
137         &&conv_xx12_xx12,        /* 16h -> 16h */
138         &&conv_xx12_xx21,        /* 16h -> 16s */
139         &&conv_xx12_x120,        /* 16h -> 24h */
140         &&conv_xx12_021x,        /* 16h -> 24s */
141         &&conv_xx12_1200,        /* 16h -> 32h */
142         &&conv_xx12_0021,        /* 16h -> 32s */
143         &&conv_xx12_xxx9,        /* 16h ^>  8h */
144         &&conv_xx12_xxx9,        /* 16h ^>  8s */
145         &&conv_xx12_xx92,        /* 16h ^> 16h */
146         &&conv_xx12_xx29,        /* 16h ^> 16s */
147         &&conv_xx12_x920,        /* 16h ^> 24h */
148         &&conv_xx12_029x,        /* 16h ^> 24s */
149         &&conv_xx12_9200,        /* 16h ^> 32h */
150         &&conv_xx12_0029,        /* 16h ^> 32s */
151         &&conv_xx12_xxx2,        /* 16s ->  8h */
152         &&conv_xx12_xxx2,        /* 16s ->  8s */
153         &&conv_xx12_xx21,        /* 16s -> 16h */
154         &&conv_xx12_xx12,        /* 16s -> 16s */
155         &&conv_xx12_x210,        /* 16s -> 24h */
156         &&conv_xx12_012x,        /* 16s -> 24s */
157         &&conv_xx12_2100,        /* 16s -> 32h */
158         &&conv_xx12_0012,        /* 16s -> 32s */
159         &&conv_xx12_xxxA,        /* 16s ^>  8h */
160         &&conv_xx12_xxxA,        /* 16s ^>  8s */
161         &&conv_xx12_xxA1,        /* 16s ^> 16h */
162         &&conv_xx12_xx1A,        /* 16s ^> 16s */
163         &&conv_xx12_xA10,        /* 16s ^> 24h */
164         &&conv_xx12_01Ax,        /* 16s ^> 24s */
165         &&conv_xx12_A100,        /* 16s ^> 32h */
166         &&conv_xx12_001A,        /* 16s ^> 32s */
167         &&conv_x123_xxx1,        /* 24h ->  8h */
168         &&conv_x123_xxx1,        /* 24h ->  8s */
169         &&conv_x123_xx12,        /* 24h -> 16h */
170         &&conv_x123_xx21,        /* 24h -> 16s */
171         &&conv_x123_x123,        /* 24h -> 24h */
172         &&conv_x123_321x,        /* 24h -> 24s */
173         &&conv_x123_1230,        /* 24h -> 32h */
174         &&conv_x123_0321,        /* 24h -> 32s */
175         &&conv_x123_xxx9,        /* 24h ^>  8h */
176         &&conv_x123_xxx9,        /* 24h ^>  8s */
177         &&conv_x123_xx92,        /* 24h ^> 16h */
178         &&conv_x123_xx29,        /* 24h ^> 16s */
179         &&conv_x123_x923,        /* 24h ^> 24h */
180         &&conv_x123_329x,        /* 24h ^> 24s */
181         &&conv_x123_9230,        /* 24h ^> 32h */
182         &&conv_x123_0329,        /* 24h ^> 32s */
183         &&conv_123x_xxx3,        /* 24s ->  8h */
184         &&conv_123x_xxx3,        /* 24s ->  8s */
185         &&conv_123x_xx32,        /* 24s -> 16h */
186         &&conv_123x_xx23,        /* 24s -> 16s */
187         &&conv_123x_x321,        /* 24s -> 24h */
188         &&conv_123x_123x,        /* 24s -> 24s */
189         &&conv_123x_3210,        /* 24s -> 32h */
190         &&conv_123x_0123,        /* 24s -> 32s */
191         &&conv_123x_xxxB,        /* 24s ^>  8h */
192         &&conv_123x_xxxB,        /* 24s ^>  8s */
193         &&conv_123x_xxB2,        /* 24s ^> 16h */
194         &&conv_123x_xx2B,        /* 24s ^> 16s */
195         &&conv_123x_xB21,        /* 24s ^> 24h */
196         &&conv_123x_12Bx,        /* 24s ^> 24s */
197         &&conv_123x_B210,        /* 24s ^> 32h */
198         &&conv_123x_012B,        /* 24s ^> 32s */
199         &&conv_1234_xxx1,        /* 32h ->  8h */
200         &&conv_1234_xxx1,        /* 32h ->  8s */
201         &&conv_1234_xx12,        /* 32h -> 16h */
202         &&conv_1234_xx21,        /* 32h -> 16s */
203         &&conv_1234_x123,        /* 32h -> 24h */
204         &&conv_1234_321x,        /* 32h -> 24s */
205         &&conv_1234_1234,        /* 32h -> 32h */
206         &&conv_1234_4321,        /* 32h -> 32s */
207         &&conv_1234_xxx9,        /* 32h ^>  8h */
208         &&conv_1234_xxx9,        /* 32h ^>  8s */
209         &&conv_1234_xx92,        /* 32h ^> 16h */
210         &&conv_1234_xx29,        /* 32h ^> 16s */
211         &&conv_1234_x923,        /* 32h ^> 24h */
212         &&conv_1234_329x,        /* 32h ^> 24s */
213         &&conv_1234_9234,        /* 32h ^> 32h */
214         &&conv_1234_4329,        /* 32h ^> 32s */
215         &&conv_1234_xxx4,        /* 32s ->  8h */
216         &&conv_1234_xxx4,        /* 32s ->  8s */
217         &&conv_1234_xx43,        /* 32s -> 16h */
218         &&conv_1234_xx34,        /* 32s -> 16s */
219         &&conv_1234_x432,        /* 32s -> 24h */
220         &&conv_1234_234x,        /* 32s -> 24s */
221         &&conv_1234_4321,        /* 32s -> 32h */
222         &&conv_1234_1234,        /* 32s -> 32s */
223         &&conv_1234_xxxC,        /* 32s ^>  8h */
224         &&conv_1234_xxxC,        /* 32s ^>  8s */
225         &&conv_1234_xxC3,        /* 32s ^> 16h */
226         &&conv_1234_xx3C,        /* 32s ^> 16s */
227         &&conv_1234_xC32,        /* 32s ^> 24h */
228         &&conv_1234_23Cx,        /* 32s ^> 24s */
229         &&conv_1234_C321,        /* 32s ^> 32h */
230         &&conv_1234_123C,        /* 32s ^> 32s */
231 };
232 #endif
233
234 #ifdef CONV_END
235 while(0) {
236 conv_xxx1_xxx1: as_u8(dst) = as_u8c(src); goto CONV_END;
237 conv_xxx1_xx10: as_u16(dst) = (u_int16_t)as_u8c(src) << 8; goto CONV_END;
238 conv_xxx1_xx01: as_u16(dst) = (u_int16_t)as_u8c(src); goto CONV_END;
239 conv_xxx1_x100: as_u32(dst) = (u_int32_t)as_u8c(src) << 16; goto CONV_END;
240 conv_xxx1_001x: as_u32(dst) = (u_int32_t)as_u8c(src) << 8; goto CONV_END;
241 conv_xxx1_1000: as_u32(dst) = (u_int32_t)as_u8c(src) << 24; goto CONV_END;
242 conv_xxx1_0001: as_u32(dst) = (u_int32_t)as_u8c(src); goto CONV_END;
243 conv_xxx1_xxx9: as_u8(dst) = as_u8c(src) ^ 0x80; goto CONV_END;
244 conv_xxx1_xx90: as_u16(dst) = (u_int16_t)(as_u8c(src) ^ 0x80) << 8; goto CONV_END;
245 conv_xxx1_xx09: as_u16(dst) = (u_int16_t)(as_u8c(src) ^ 0x80); goto CONV_END;
246 conv_xxx1_x900: as_u32(dst) = (u_int32_t)(as_u8c(src) ^ 0x80) << 16; goto CONV_END;
247 conv_xxx1_009x: as_u32(dst) = (u_int32_t)(as_u8c(src) ^ 0x80) << 8; goto CONV_END;
248 conv_xxx1_9000: as_u32(dst) = (u_int32_t)(as_u8c(src) ^ 0x80) << 24; goto CONV_END;
249 conv_xxx1_0009: as_u32(dst) = (u_int32_t)(as_u8c(src) ^ 0x80); goto CONV_END;
250 conv_xx12_xxx1: as_u8(dst) = as_u16c(src) >> 8; goto CONV_END;
251 conv_xx12_xx12: as_u16(dst) = as_u16c(src); goto CONV_END;
252 conv_xx12_xx21: as_u16(dst) = bswap_16(as_u16c(src)); goto CONV_END;
253 conv_xx12_x120: as_u32(dst) = (u_int32_t)as_u16c(src) << 8; goto CONV_END;
254 conv_xx12_021x: as_u32(dst) = (u_int32_t)bswap_16(as_u16c(src)) << 8; goto CONV_END;
255 conv_xx12_1200: as_u32(dst) = (u_int32_t)as_u16c(src) << 16; goto CONV_END;
256 conv_xx12_0021: as_u32(dst) = (u_int32_t)bswap_16(as_u16c(src)); goto CONV_END;
257 conv_xx12_xxx9: as_u8(dst) = (as_u16c(src) >> 8) ^ 0x80; goto CONV_END;
258 conv_xx12_xx92: as_u16(dst) = as_u16c(src) ^ 0x8000; goto CONV_END;
259 conv_xx12_xx29: as_u16(dst) = bswap_16(as_u16c(src)) ^ 0x80; goto CONV_END;
260 conv_xx12_x920: as_u32(dst) = (u_int32_t)(as_u16c(src) ^ 0x8000) << 8; goto CONV_END;
261 conv_xx12_029x: as_u32(dst) = (u_int32_t)(bswap_16(as_u16c(src)) ^ 0x80) << 8; goto CONV_END;
262 conv_xx12_9200: as_u32(dst) = (u_int32_t)(as_u16c(src) ^ 0x8000) << 16; goto CONV_END;
263 conv_xx12_0029: as_u32(dst) = (u_int32_t)(bswap_16(as_u16c(src)) ^ 0x80); goto CONV_END;
264 conv_xx12_xxx2: as_u8(dst) = as_u16c(src) & 0xff; goto CONV_END;
265 conv_xx12_x210: as_u32(dst) = (u_int32_t)bswap_16(as_u16c(src)) << 8; goto CONV_END;
266 conv_xx12_012x: as_u32(dst) = (u_int32_t)as_u16c(src) << 8; goto CONV_END;
267 conv_xx12_2100: as_u32(dst) = (u_int32_t)bswap_16(as_u16c(src)) << 16; goto CONV_END;
268 conv_xx12_0012: as_u32(dst) = (u_int32_t)as_u16c(src); goto CONV_END; 
269 conv_xx12_xxxA: as_u8(dst) = (as_u16c(src) ^ 0x80) & 0xff; goto CONV_END;
270 conv_xx12_xxA1: as_u16(dst) = bswap_16(as_u16c(src) ^ 0x80); goto CONV_END;
271 conv_xx12_xx1A: as_u16(dst) = as_u16c(src) ^ 0x80; goto CONV_END;
272 conv_xx12_xA10: as_u32(dst) = (u_int32_t)bswap_16(as_u16c(src) ^ 0x80) << 8; goto CONV_END;
273 conv_xx12_01Ax: as_u32(dst) = (u_int32_t)(as_u16c(src) ^ 0x80) << 8; goto CONV_END;
274 conv_xx12_A100: as_u32(dst) = (u_int32_t)bswap_16(as_u16c(src) ^ 0x80) << 16; goto CONV_END;
275 conv_xx12_001A: as_u32(dst) = (u_int32_t)(as_u16c(src) ^ 0x80); goto CONV_END;
276 conv_x123_xxx1: as_u8(dst) = as_u32c(src) >> 16; goto CONV_END;
277 conv_x123_xx12: as_u16(dst) = as_u32c(src) >> 8; goto CONV_END;
278 conv_x123_xx21: as_u16(dst) = bswap_16(as_u32c(src) >> 8); goto CONV_END;
279 conv_x123_x123: as_u32(dst) = as_u32c(src); goto CONV_END;
280 conv_x123_321x: as_u32(dst) = bswap_32(as_u32c(src)); goto CONV_END;
281 conv_x123_1230: as_u32(dst) = as_u32c(src) << 8; goto CONV_END;
282 conv_x123_0321: as_u32(dst) = bswap_32(as_u32c(src)) >> 8; goto CONV_END;
283 conv_x123_xxx9: as_u8(dst) = (as_u32c(src) >> 16) ^ 0x80; goto CONV_END;
284 conv_x123_xx92: as_u16(dst) = (as_u32c(src) >> 8) ^ 0x8000; goto CONV_END;
285 conv_x123_xx29: as_u16(dst) = bswap_16(as_u32c(src) >> 8) ^ 0x80; goto CONV_END;
286 conv_x123_x923: as_u32(dst) = as_u32c(src) ^ 0x800000; goto CONV_END;
287 conv_x123_329x: as_u32(dst) = bswap_32(as_u32c(src)) ^ 0x8000; goto CONV_END;
288 conv_x123_9230: as_u32(dst) = (as_u32c(src) ^ 0x800000) << 8; goto CONV_END;
289 conv_x123_0329: as_u32(dst) = (bswap_32(as_u32c(src)) >> 8) ^ 0x80; goto CONV_END;
290 conv_123x_xxx3: as_u8(dst) = (as_u32c(src) >> 8) & 0xff; goto CONV_END;
291 conv_123x_xx32: as_u16(dst) = bswap_16(as_u32c(src) >> 8); goto CONV_END;
292 conv_123x_xx23: as_u16(dst) = (as_u32c(src) >> 8) & 0xffff; goto CONV_END;
293 conv_123x_x321: as_u32(dst) = bswap_32(as_u32c(src)); goto CONV_END;
294 conv_123x_123x: as_u32(dst) = as_u32c(src); goto CONV_END;
295 conv_123x_3210: as_u32(dst) = bswap_32(as_u32c(src)) << 8; goto CONV_END;
296 conv_123x_0123: as_u32(dst) = as_u32c(src) >> 8; goto CONV_END;
297 conv_123x_xxxB: as_u8(dst) = ((as_u32c(src) >> 8) & 0xff) ^ 0x80; goto CONV_END;
298 conv_123x_xxB2: as_u16(dst) = bswap_16((as_u32c(src) >> 8) ^ 0x80); goto CONV_END;
299 conv_123x_xx2B: as_u16(dst) = ((as_u32c(src) >> 8) & 0xffff) ^ 0x80; goto CONV_END;
300 conv_123x_xB21: as_u32(dst) = bswap_32(as_u32c(src)) ^ 0x800000; goto CONV_END;
301 conv_123x_12Bx: as_u32(dst) = as_u32c(src) ^ 0x8000; goto CONV_END;
302 conv_123x_B210: as_u32(dst) = bswap_32(as_u32c(src) ^ 0x8000) << 8; goto CONV_END;
303 conv_123x_012B: as_u32(dst) = (as_u32c(src) >> 8) ^ 0x80; goto CONV_END;
304 conv_1234_xxx1: as_u8(dst) = as_u32c(src) >> 24; goto CONV_END;
305 conv_1234_xx12: as_u16(dst) = as_u32c(src) >> 16; goto CONV_END;
306 conv_1234_xx21: as_u16(dst) = bswap_16(as_u32c(src) >> 16); goto CONV_END;
307 conv_1234_x123: as_u32(dst) = as_u32c(src) >> 8; goto CONV_END;
308 conv_1234_321x: as_u32(dst) = bswap_32(as_u32c(src)) << 8; goto CONV_END;
309 conv_1234_1234: as_u32(dst) = as_u32c(src); goto CONV_END;
310 conv_1234_4321: as_u32(dst) = bswap_32(as_u32c(src)); goto CONV_END;
311 conv_1234_xxx9: as_u8(dst) = (as_u32c(src) >> 24) ^ 0x80; goto CONV_END;
312 conv_1234_xx92: as_u16(dst) = (as_u32c(src) >> 16) ^ 0x8000; goto CONV_END;
313 conv_1234_xx29: as_u16(dst) = bswap_16(as_u32c(src) >> 16) ^ 0x80; goto CONV_END;
314 conv_1234_x923: as_u32(dst) = (as_u32c(src) >> 8) ^ 0x800000; goto CONV_END;
315 conv_1234_329x: as_u32(dst) = (bswap_32(as_u32c(src)) ^ 0x80) << 8; goto CONV_END;
316 conv_1234_9234: as_u32(dst) = as_u32c(src) ^ 0x80000000; goto CONV_END;
317 conv_1234_4329: as_u32(dst) = bswap_32(as_u32c(src)) ^ 0x80; goto CONV_END;
318 conv_1234_xxx4: as_u8(dst) = as_u32c(src) & 0xff; goto CONV_END;
319 conv_1234_xx43: as_u16(dst) = bswap_16(as_u32c(src)); goto CONV_END;
320 conv_1234_xx34: as_u16(dst) = as_u32c(src) & 0xffff; goto CONV_END;
321 conv_1234_x432: as_u32(dst) = bswap_32(as_u32c(src)) >> 8; goto CONV_END;
322 conv_1234_234x: as_u32(dst) = as_u32c(src) << 8; goto CONV_END;
323 conv_1234_xxxC: as_u8(dst) = (as_u32c(src) & 0xff) ^ 0x80; goto CONV_END;
324 conv_1234_xxC3: as_u16(dst) = bswap_16(as_u32c(src) ^ 0x80); goto CONV_END;
325 conv_1234_xx3C: as_u16(dst) = (as_u32c(src) & 0xffff) ^ 0x80; goto CONV_END;
326 conv_1234_xC32: as_u32(dst) = (bswap_32(as_u32c(src)) >> 8) ^ 0x800000; goto CONV_END;
327 conv_1234_23Cx: as_u32(dst) = (as_u32c(src) ^ 0x80) << 8; goto CONV_END;
328 conv_1234_C321: as_u32(dst) = bswap_32(as_u32c(src) ^ 0x80); goto CONV_END;
329 conv_1234_123C: as_u32(dst) = as_u32c(src) ^ 0x80; goto CONV_END;
330 }
331 #endif
332
333 #ifdef GET16_LABELS
334 /* src_wid src_endswap sign_toggle */
335 static void *get16_labels[4 * 2 * 2 + 4 * 3] = {
336         &&get16_1_10,    /*  8h -> 16h */
337         &&get16_1_90,    /*  8h ^> 16h */
338         &&get16_1_10,    /*  8s -> 16h */
339         &&get16_1_90,    /*  8s ^> 16h */
340         &&get16_12_12,   /* 16h -> 16h */
341         &&get16_12_92,   /* 16h ^> 16h */
342         &&get16_12_21,   /* 16s -> 16h */
343         &&get16_12_A1,   /* 16s ^> 16h */
344         &&get16_0123_12, /* 24h -> 16h */
345         &&get16_0123_92, /* 24h ^> 16h */
346         &&get16_1230_32, /* 24s -> 16h */
347         &&get16_1230_B2, /* 24s ^> 16h */
348         &&get16_1234_12, /* 32h -> 16h */
349         &&get16_1234_92, /* 32h ^> 16h */
350         &&get16_1234_43, /* 32s -> 16h */
351         &&get16_1234_C3, /* 32s ^> 16h */
352         /* 3bytes format */
353         &&get16_123_12,  /* 24h -> 16h */
354         &&get16_123_92,  /* 24h ^> 16h */
355         &&get16_123_32,  /* 24s -> 16h */
356         &&get16_123_B2,  /* 24s ^> 16h */
357         &&get16_123_12_20,       /* 20h -> 16h */
358         &&get16_123_92_20,       /* 20h ^> 16h */
359         &&get16_123_32_20,       /* 20s -> 16h */
360         &&get16_123_B2_20,       /* 20s ^> 16h */
361         &&get16_123_12_18,       /* 18h -> 16h */
362         &&get16_123_92_18,       /* 18h ^> 16h */
363         &&get16_123_32_18,       /* 18s -> 16h */
364         &&get16_123_B2_18,       /* 18s ^> 16h */
365 };
366 #endif
367
368 #ifdef GET16_END
369 while(0) {
370 get16_1_10: sample = (u_int16_t)as_u8c(src) << 8; goto GET16_END;
371 get16_1_90: sample = (u_int16_t)(as_u8c(src) ^ 0x80) << 8; goto GET16_END;
372 get16_12_12: sample = as_u16c(src); goto GET16_END;
373 get16_12_92: sample = as_u16c(src) ^ 0x8000; goto GET16_END;
374 get16_12_21: sample = bswap_16(as_u16c(src)); goto GET16_END;
375 get16_12_A1: sample = bswap_16(as_u16c(src) ^ 0x80); goto GET16_END;
376 get16_0123_12: sample = as_u32c(src) >> 8; goto GET16_END;
377 get16_0123_92: sample = (as_u32c(src) >> 8) ^ 0x8000; goto GET16_END;
378 get16_1230_32: sample = bswap_16(as_u32c(src) >> 8); goto GET16_END;
379 get16_1230_B2: sample = bswap_16((as_u32c(src) >> 8) ^ 0x80); goto GET16_END;
380 get16_1234_12: sample = as_u32c(src) >> 16; goto GET16_END;
381 get16_1234_92: sample = (as_u32c(src) >> 16) ^ 0x8000; goto GET16_END;
382 get16_1234_43: sample = bswap_16(as_u32c(src)); goto GET16_END;
383 get16_1234_C3: sample = bswap_16(as_u32c(src) ^ 0x80); goto GET16_END;
384 get16_123_12: sample = _get_triple(src) >> 8; goto GET16_END;
385 get16_123_92: sample = (_get_triple(src) >> 8) ^ 0x8000; goto GET16_END;
386 get16_123_32: sample = _get_triple_s(src) >> 8; goto GET16_END;
387 get16_123_B2: sample = (_get_triple_s(src) >> 8) ^ 0x8000; goto GET16_END;
388 get16_123_12_20: sample = _get_triple(src) >> 4; goto GET16_END;
389 get16_123_92_20: sample = (_get_triple(src) >> 4) ^ 0x8000; goto GET16_END;
390 get16_123_32_20: sample = _get_triple_s(src) >> 4; goto GET16_END;
391 get16_123_B2_20: sample = (_get_triple_s(src) >> 4) ^ 0x8000; goto GET16_END;
392 get16_123_12_18: sample = _get_triple(src) >> 2; goto GET16_END;
393 get16_123_92_18: sample = (_get_triple(src) >> 2) ^ 0x8000; goto GET16_END;
394 get16_123_32_18: sample = _get_triple_s(src) >> 2; goto GET16_END;
395 get16_123_B2_18: sample = (_get_triple_s(src) >> 2) ^ 0x8000; goto GET16_END;
396 }
397 #endif
398
399 #ifdef PUT16_LABELS
400 /* dst_wid dst_endswap sign_toggle */
401 static void *put16_labels[4 * 2 * 2] = {
402         &&put16_12_1,            /* 16h ->  8h */
403         &&put16_12_9,            /* 16h ^>  8h */
404         &&put16_12_1,            /* 16h ->  8s */
405         &&put16_12_9,            /* 16h ^>  8s */
406         &&put16_12_12,           /* 16h -> 16h */
407         &&put16_12_92,           /* 16h ^> 16h */
408         &&put16_12_21,           /* 16h -> 16s */
409         &&put16_12_29,           /* 16h ^> 16s */
410         &&put16_12_0120,         /* 16h -> 24h */
411         &&put16_12_0920,         /* 16h ^> 24h */
412         &&put16_12_0210,         /* 16h -> 24s */
413         &&put16_12_0290,         /* 16h ^> 24s */
414         &&put16_12_1200,         /* 16h -> 32h */
415         &&put16_12_9200,         /* 16h ^> 32h */
416         &&put16_12_0021,         /* 16h -> 32s */
417         &&put16_12_0029,         /* 16h ^> 32s */
418 };
419 #endif
420
421 #ifdef PUT16_END
422 while (0) {
423 put16_12_1: as_u8(dst) = sample >> 8; goto PUT16_END;
424 put16_12_9: as_u8(dst) = (sample >> 8) ^ 0x80; goto PUT16_END;
425 put16_12_12: as_u16(dst) = sample; goto PUT16_END;
426 put16_12_92: as_u16(dst) = sample ^ 0x8000; goto PUT16_END;
427 put16_12_21: as_u16(dst) = bswap_16(sample); goto PUT16_END;
428 put16_12_29: as_u16(dst) = bswap_16(sample) ^ 0x80; goto PUT16_END;
429 put16_12_0120: as_u32(dst) = (u_int32_t)sample << 8; goto PUT16_END;
430 put16_12_0920: as_u32(dst) = (u_int32_t)(sample ^ 0x8000) << 8; goto PUT16_END;
431 put16_12_0210: as_u32(dst) = (u_int32_t)bswap_16(sample) << 8; goto PUT16_END;
432 put16_12_0290: as_u32(dst) = (u_int32_t)(bswap_16(sample) ^ 0x80) << 8; goto PUT16_END;
433 put16_12_1200: as_u32(dst) = (u_int32_t)sample << 16; goto PUT16_END;
434 put16_12_9200: as_u32(dst) = (u_int32_t)(sample ^ 0x8000) << 16; goto PUT16_END;
435 put16_12_0021: as_u32(dst) = (u_int32_t)bswap_16(sample); goto PUT16_END;
436 put16_12_0029: as_u32(dst) = (u_int32_t)bswap_16(sample) ^ 0x80; goto PUT16_END;
437 }
438 #endif
439
440 #ifdef CONV24_LABELS
441 #define GET32_LABELS
442 #define PUT32_LABELS
443 #endif
444
445 #ifdef GET32_LABELS
446 /* src_wid src_endswap sign_toggle */
447 static void *get32_labels[4 * 2 * 2 + 4 * 3] = {
448         &&get32_1_1000,          /*  8h -> 32h */
449         &&get32_1_9000,          /*  8h ^> 32h */
450         &&get32_1_1000,          /*  8s -> 32h */
451         &&get32_1_9000,          /*  8s ^> 32h */
452         &&get32_12_1200,         /* 16h -> 32h */
453         &&get32_12_9200,         /* 16h ^> 32h */
454         &&get32_12_2100,         /* 16s -> 32h */
455         &&get32_12_A100,         /* 16s ^> 32h */
456         &&get32_0123_1230,       /* 24h -> 32h */
457         &&get32_0123_9230,       /* 24h ^> 32h */
458         &&get32_1230_3210,       /* 24s -> 32h */
459         &&get32_1230_B210,       /* 24s ^> 32h */
460         &&get32_1234_1234,       /* 32h -> 32h */
461         &&get32_1234_9234,       /* 32h ^> 32h */
462         &&get32_1234_4321,       /* 32s -> 32h */
463         &&get32_1234_C321,       /* 32s ^> 32h */
464         /* 3bytes format */
465         &&get32_123_1230,        /* 24h -> 32h */
466         &&get32_123_9230,        /* 24h ^> 32h */
467         &&get32_123_3210,        /* 24s -> 32h */
468         &&get32_123_B210,        /* 24s ^> 32h */
469         &&get32_123_1230_20,     /* 20h -> 32h */
470         &&get32_123_9230_20,     /* 20h ^> 32h */
471         &&get32_123_3210_20,     /* 20s -> 32h */
472         &&get32_123_B210_20,     /* 20s ^> 32h */
473         &&get32_123_1230_18,     /* 18h -> 32h */
474         &&get32_123_9230_18,     /* 18h ^> 32h */
475         &&get32_123_3210_18,     /* 18s -> 32h */
476         &&get32_123_B210_18,     /* 18s ^> 32h */
477 };
478 #endif
479
480 #ifdef CONV24_END
481 #define GET32_END __conv24_get
482 #endif
483
484 #ifdef GET32_END
485 while (0) {
486 get32_1_1000: sample = (u_int32_t)as_u8c(src) << 24; goto GET32_END;
487 get32_1_9000: sample = (u_int32_t)(as_u8c(src) ^ 0x80) << 24; goto GET32_END;
488 get32_12_1200: sample = (u_int32_t)as_u16c(src) << 16; goto GET32_END;
489 get32_12_9200: sample = (u_int32_t)(as_u16c(src) ^ 0x8000) << 16; goto GET32_END;
490 get32_12_2100: sample = (u_int32_t)bswap_16(as_u16c(src)) << 16; goto GET32_END;
491 get32_12_A100: sample = (u_int32_t)bswap_16(as_u16c(src) ^ 0x80) << 16; goto GET32_END;
492 get32_0123_1230: sample = as_u32c(src) << 8; goto GET32_END;
493 get32_0123_9230: sample = (as_u32c(src) << 8) ^ 0x80000000; goto GET32_END;
494 get32_1230_3210: sample = bswap_32(as_u32c(src) >> 8); goto GET32_END;
495 get32_1230_B210: sample = bswap_32((as_u32c(src) >> 8) ^ 0x80); goto GET32_END;
496 get32_1234_1234: sample = as_u32c(src); goto GET32_END;
497 get32_1234_9234: sample = as_u32c(src) ^ 0x80000000; goto GET32_END;
498 get32_1234_4321: sample = bswap_32(as_u32c(src)); goto GET32_END;
499 get32_1234_C321: sample = bswap_32(as_u32c(src) ^ 0x80); goto GET32_END;
500 get32_123_1230: sample = _get_triple(src) << 8; goto GET32_END;
501 get32_123_9230: sample = (_get_triple(src) << 8) ^ 0x80000000; goto GET32_END;
502 get32_123_3210: sample = _get_triple_s(src) << 8; goto GET32_END;
503 get32_123_B210: sample = (_get_triple_s(src) << 8) ^ 0x80000000; goto GET32_END;
504 get32_123_1230_20: sample = _get_triple(src) << 12; goto GET32_END;
505 get32_123_9230_20: sample = (_get_triple(src) << 12) ^ 0x80000000; goto GET32_END;
506 get32_123_3210_20: sample = _get_triple_s(src) << 12; goto GET32_END;
507 get32_123_B210_20: sample = (_get_triple_s(src) << 12) ^ 0x80000000; goto GET32_END;
508 get32_123_1230_18: sample = _get_triple(src) << 14; goto GET32_END;
509 get32_123_9230_18: sample = (_get_triple(src) << 14) ^ 0x80000000; goto GET32_END;
510 get32_123_3210_18: sample = _get_triple_s(src) << 14; goto GET32_END;
511 get32_123_B210_18: sample = (_get_triple_s(src) << 14) ^ 0x80000000; goto GET32_END;
512 }
513 #endif
514
515 #ifdef CONV24_END
516 __conv24_get: goto *put;
517 #define PUT32_END CONV24_END
518 #endif
519
520 #ifdef PUT32_LABELS
521 /* dst_wid dst_endswap sign_toggle */
522 static void *put32_labels[4 * 2 * 2 + 4 * 3] = {
523         &&put32_1234_1,          /* 32h ->  8h */
524         &&put32_1234_9,          /* 32h ^>  8h */
525         &&put32_1234_1,          /* 32h ->  8s */
526         &&put32_1234_9,          /* 32h ^>  8s */
527         &&put32_1234_12,         /* 32h -> 16h */
528         &&put32_1234_92,         /* 32h ^> 16h */
529         &&put32_1234_21,         /* 32h -> 16s */
530         &&put32_1234_29,         /* 32h ^> 16s */
531         &&put32_1234_0123,       /* 32h -> 24h */
532         &&put32_1234_0923,       /* 32h ^> 24h */
533         &&put32_1234_3210,       /* 32h -> 24s */
534         &&put32_1234_3290,       /* 32h ^> 24s */
535         &&put32_1234_1234,       /* 32h -> 32h */
536         &&put32_1234_9234,       /* 32h ^> 32h */
537         &&put32_1234_4321,       /* 32h -> 32s */
538         &&put32_1234_4329,       /* 32h ^> 32s */
539         /* 3bytes format */
540         &&put32_1234_123,        /* 32h -> 24h */
541         &&put32_1234_923,        /* 32h ^> 24h */
542         &&put32_1234_321,        /* 32h -> 24s */
543         &&put32_1234_329,        /* 32h ^> 24s */
544         &&put32_1234_123_20,     /* 32h -> 24h */
545         &&put32_1234_923_20,     /* 32h ^> 24h */
546         &&put32_1234_321_20,     /* 32h -> 24s */
547         &&put32_1234_329_20,     /* 32h ^> 24s */
548         &&put32_1234_123_18,     /* 32h -> 24h */
549         &&put32_1234_923_18,     /* 32h ^> 24h */
550         &&put32_1234_321_18,     /* 32h -> 24s */
551         &&put32_1234_329_18,     /* 32h ^> 24s */
552 };
553 #endif
554
555 #ifdef CONV24_LABELS
556 #undef GET32_LABELS
557 #undef PUT32_LABELS
558 #endif
559
560 #ifdef PUT32_END
561 while (0) {
562 put32_1234_1: as_u8(dst) = sample >> 24; goto PUT32_END;
563 put32_1234_9: as_u8(dst) = (sample >> 24) ^ 0x80; goto PUT32_END;
564 put32_1234_12: as_u16(dst) = sample >> 16; goto PUT32_END;
565 put32_1234_92: as_u16(dst) = (sample >> 16) ^ 0x8000; goto PUT32_END;
566 put32_1234_21: as_u16(dst) = bswap_16(sample >> 16); goto PUT32_END;
567 put32_1234_29: as_u16(dst) = bswap_16(sample >> 16) ^ 0x80; goto PUT32_END;
568 put32_1234_0123: as_u32(dst) = sample >> 8; goto PUT32_END;
569 put32_1234_0923: as_u32(dst) = (sample >> 8) ^ 0x800000; goto PUT32_END;
570 put32_1234_3210: as_u32(dst) = bswap_32(sample) << 8; goto PUT32_END;
571 put32_1234_3290: as_u32(dst) = (bswap_32(sample) ^ 0x80) << 8; goto PUT32_END;
572 put32_1234_1234: as_u32(dst) = sample; goto PUT32_END;
573 put32_1234_9234: as_u32(dst) = sample ^ 0x80000000; goto PUT32_END;
574 put32_1234_4321: as_u32(dst) = bswap_32(sample); goto PUT32_END;
575 put32_1234_4329: as_u32(dst) = bswap_32(sample) ^ 0x80; goto PUT32_END;
576 put32_1234_123: _put_triple(dst, sample >> 8); goto PUT32_END;
577 put32_1234_923: _put_triple(dst, (sample ^ 0x80000000) >> 8); goto PUT32_END;
578 put32_1234_321: _put_triple_s(dst, sample >> 8); goto PUT32_END;
579 put32_1234_329: _put_triple_s(dst, (sample ^ 0x80000000) >> 8); goto PUT32_END;
580 put32_1234_123_20: _put_triple(dst, sample >> 12); goto PUT32_END;
581 put32_1234_923_20: _put_triple(dst, (sample ^ 0x80000000) >> 12); goto PUT32_END;
582 put32_1234_321_20: _put_triple_s(dst, sample >> 12); goto PUT32_END;
583 put32_1234_329_20: _put_triple_s(dst, (sample ^ 0x80000000) >> 12); goto PUT32_END;
584 put32_1234_123_18: _put_triple(dst, sample >> 14); goto PUT32_END;
585 put32_1234_923_18: _put_triple(dst, (sample ^ 0x80000000) >> 14); goto PUT32_END;
586 put32_1234_321_18: _put_triple_s(dst, sample >> 14); goto PUT32_END;
587 put32_1234_329_18: _put_triple_s(dst, (sample ^ 0x80000000) >> 14); goto PUT32_END;
588 }
589 #endif
590
591 #ifdef CONV24_END
592 #undef GET32_END
593 #undef PUT32_END
594 #endif
595
596 #ifdef GETU_LABELS
597 /* width endswap sign_toggle */
598 static void *getu_labels[4 * 2 * 2] = {
599         &&getu_1_1,             /*  8h ->  8h */
600         &&getu_1_9,             /*  8h ^>  8h */
601         &&getu_1_1,             /*  8s ->  8h */
602         &&getu_1_9,             /*  8s ^>  8h */
603         &&getu_12_12,           /* 16h -> 16h */
604         &&getu_12_92,           /* 16h ^> 16h */
605         &&getu_12_21,           /* 16s -> 16h */
606         &&getu_12_A1,           /* 16s ^> 16h */
607         &&getu_0123_0123,       /* 24h -> 24h */
608         &&getu_0123_0923,       /* 24h ^> 24h */
609         &&getu_1230_0321,       /* 24s -> 24h */
610         &&getu_1230_0B21,       /* 24s ^> 24h */
611         &&getu_1234_1234,       /* 32h -> 32h */
612         &&getu_1234_9234,       /* 32h ^> 32h */
613         &&getu_1234_4321,       /* 32s -> 32h */
614         &&getu_1234_C321,       /* 32s ^> 32h */
615 };
616 #endif
617
618 #ifdef GETU_END
619 while (0) {
620 getu_1_1: sample = as_u8c(src); goto GETU_END;
621 getu_1_9: sample = as_u8c(src) ^ 0x80; goto GETU_END;
622 getu_12_12: sample = as_u16c(src); goto GETU_END;
623 getu_12_92: sample = as_u16c(src) ^ 0x8000; goto GETU_END;
624 getu_12_21: sample = bswap_16(as_u16c(src)); goto GETU_END;
625 getu_12_A1: sample = bswap_16(as_u16c(src) ^ 0x80); goto GETU_END;
626 getu_0123_0123: sample = as_u32c(src); goto GETU_END;
627 getu_0123_0923: sample = (as_u32c(src) ^ 0x800000); goto GETU_END;
628 getu_1230_0321: sample = bswap_32(as_u32c(src)); goto GETU_END;
629 getu_1230_0B21: sample = bswap_32(as_u32c(src) ^ 0x8000); goto GETU_END;
630 getu_1234_1234: sample = as_u32c(src); goto GETU_END;
631 getu_1234_9234: sample = as_u32c(src) ^ 0x80000000; goto GETU_END;
632 getu_1234_4321: sample = bswap_32(as_u32c(src)); goto GETU_END;
633 getu_1234_C321: sample = bswap_32(as_u32c(src) ^ 0x80); goto GETU_END;
634 }
635 #endif
636
637 #ifdef GETS_LABELS
638 /* width endswap sign_toggle */
639 static void *gets_labels[4 * 2 * 2] = {
640         &&gets_1_1,             /*  8h ->  8h */
641         &&gets_1_9,             /*  8h ^>  8h */
642         &&gets_1_1,             /*  8s ->  8h */
643         &&gets_1_9,             /*  8s ^>  8h */
644         &&gets_12_12,           /* 16h -> 16h */
645         &&gets_12_92,           /* 16h ^> 16h */
646         &&gets_12_21,           /* 16s -> 16h */
647         &&gets_12_A1,           /* 16s ^> 16h */
648         &&gets_0123_0123,       /* 24h -> 24h */
649         &&gets_0123_0923,       /* 24h ^> 24h */
650         &&gets_1230_0321,       /* 24s -> 24h */
651         &&gets_1230_0B21,       /* 24s ^> 24h */
652         &&gets_1234_1234,       /* 32h -> 32h */
653         &&gets_1234_9234,       /* 32h ^> 32h */
654         &&gets_1234_4321,       /* 32s -> 32h */
655         &&gets_1234_C321,       /* 32s ^> 32h */
656 };
657 #endif
658
659 #ifdef GETS_END
660 while (0) {
661 gets_1_1: sample = as_s8c(src); goto GETS_END;
662 gets_1_9: sample = (int8_t)(as_s8c(src) ^ 0x80); goto GETS_END;
663 gets_12_12: sample = as_s16c(src); goto GETS_END;
664 gets_12_92: sample = (int16_t)(as_s16c(src) ^ 0x8000); goto GETS_END;
665 gets_12_21: sample = (int16_t)bswap_16(as_s16c(src)); goto GETS_END;
666 gets_12_A1: sample = (int16_t)bswap_16(as_s16c(src) ^ 0x80); goto GETS_END;
667 gets_0123_0123: sample = (int32_t)(as_s32c(src) << 8) >> 8; goto GETS_END;
668 gets_0123_0923: sample = (int32_t)((as_s32c(src) ^ 0x800000) << 8) >> 8; goto GETS_END;
669 gets_1230_0321: sample = (int32_t)(bswap_32(as_s32c(src)) << 8) >> 8; goto GETS_END;
670 gets_1230_0B21: sample = (int32_t)(bswap_32(as_s32c(src) ^ 0x8000) << 8) >> 8; goto GETS_END;
671 gets_1234_1234: sample = as_s32c(src); goto GETS_END;
672 gets_1234_9234: sample = (int32_t)(as_s32c(src) ^ 0x80000000); goto GETS_END;
673 gets_1234_4321: sample = (int32_t)bswap_32(as_s32c(src)); goto GETS_END;
674 gets_1234_C321: sample = (int32_t)bswap_32(as_s32c(src) ^ 0x80); goto GETS_END;
675 }
676 #endif
677
678 #ifdef PUT_LABELS
679 /* width endswap sign_toggle */
680 static void *put_labels[4 * 2 * 2] = {
681         &&put_1_1,              /*  8h ->  8h */
682         &&put_1_9,              /*  8h ^>  8h */
683         &&put_1_1,              /*  8h ->  8s */
684         &&put_1_9,              /*  8h ^>  8s */
685         &&put_12_12,            /* 16h -> 16h */
686         &&put_12_92,            /* 16h ^> 16h */
687         &&put_12_21,            /* 16h -> 16s */
688         &&put_12_29,            /* 16h ^> 16s */
689         &&put_0123_0123,        /* 24h -> 24h */
690         &&put_0123_0923,        /* 24h ^> 24h */
691         &&put_0123_3210,        /* 24h -> 24s */
692         &&put_0123_3290,        /* 24h ^> 24s */
693         &&put_1234_1234,        /* 32h -> 32h */
694         &&put_1234_9234,        /* 32h ^> 32h */
695         &&put_1234_4321,        /* 32h -> 32s */
696         &&put_1234_4329,        /* 32h ^> 32s */
697 };
698 #endif
699
700 #ifdef PUT_END
701 put_1_1: as_s8(dst) = sample; goto PUT_END;
702 put_1_9: as_u8(dst) = sample ^ 0x80; goto PUT_END;
703 put_12_12: as_s16(dst) = sample; goto PUT_END;
704 put_12_92: as_u16(dst) = sample ^ 0x8000; goto PUT_END;
705 put_12_21: as_s16(dst) = bswap_16(sample); goto PUT_END;
706 put_12_29: as_u16(dst) = bswap_16(sample) ^ 0x80; goto PUT_END;
707 /* this always writes the unused byte in 24-bit formats as 0x00 */
708 put_0123_0123: as_s32(dst) = sample & 0x00ffffff; goto PUT_END;
709 put_0123_0923: as_u32(dst) = (sample & 0x00ffffff) ^ 0x800000; goto PUT_END;
710 put_0123_3210: as_s32(dst) = bswap_32(sample) & 0xffffff00; goto PUT_END;
711 put_0123_3290: as_u32(dst) = (bswap_32(sample) & 0xffffff00) ^ 0x8000; goto PUT_END;
712 put_1234_1234: as_s32(dst) = sample; goto PUT_END;
713 put_1234_9234: as_u32(dst) = sample ^ 0x80000000; goto PUT_END;
714 put_1234_4321: as_s32(dst) = bswap_32(sample); goto PUT_END;
715 put_1234_4329: as_u32(dst) = bswap_32(sample) ^ 0x80; goto PUT_END;
716 #endif
717
718 #ifdef PUT32F_LABELS
719 /* type (0 = float, 1 = float64), endswap */
720 static void *put32float_labels[2 * 2] = {
721         &&put32f_1234_1234F,    /* 32h -> (float)h */
722         &&put32f_1234_4321F,    /* 32h -> (float)s */
723         &&put32f_1234_1234D,    /* 32h -> (float64)h */
724         &&put32f_1234_4321D,    /* 32h -> (float64)s */
725 };
726 #endif
727
728 #ifdef PUT32F_END
729 put32f_1234_1234F: as_float(dst) = (float_t)((int32_t)sample) / (float_t)0x80000000UL; goto PUT32F_END;
730 put32f_1234_4321F: tmp_float = (float_t)((int32_t)sample) / (float_t)0x80000000UL;
731                    as_u32(dst) = bswap_32(as_u32c(&tmp_float)); goto PUT32F_END;
732 put32f_1234_1234D: as_double(dst) = (double_t)((int32_t)sample) / (double_t)0x80000000UL; goto PUT32F_END;
733 put32f_1234_4321D: tmp_double = (double_t)((int32_t)sample) / (double_t)0x80000000UL;
734                    as_u64(dst) = bswap_64(as_u64c(&tmp_double)); goto PUT32F_END;
735 #endif
736
737 #ifdef GET32F_LABELS
738 /* type (0 = float, 1 = float64), endswap */
739 static void *get32float_labels[2 * 2] = {
740         &&get32f_1234F_1234,    /* (float)h -> 32h */
741         &&get32f_4321F_1234,    /* (float)s -> 32h */
742         &&get32f_1234D_1234,    /* (float64)h -> 32h */
743         &&get32f_4321D_1234,    /* (float64)s -> 32h */
744 };
745 #endif
746
747 #ifdef GET32F_END
748 get32f_1234F_1234: tmp_float = as_floatc(src);
749                    if (tmp_float >= 1.0)
750                         sample = 0x7fffffff;
751                    else if (tmp_float <= -1.0)
752                         sample = 0x80000000;
753                    else
754                         sample = (int32_t)(tmp_float * (float_t)0x80000000UL);
755                    goto GET32F_END;
756 get32f_4321F_1234: sample = bswap_32(as_u32c(src));
757                    tmp_float = as_floatc(&sample);
758                    if (tmp_float >= 1.0)
759                         sample = 0x7fffffff;
760                    else if (tmp_float <= -1.0)
761                         sample = 0x80000000;
762                    else
763                         sample = (int32_t)(tmp_float * (float_t)0x80000000UL);
764                    goto GET32F_END;
765 get32f_1234D_1234: tmp_double = as_doublec(src);
766                    if (tmp_double >= 1.0)
767                         sample = 0x7fffffff;
768                    else if (tmp_double <= -1.0)
769                         sample = 0x80000000;
770                    else
771                         sample = (int32_t)(tmp_double * (double_t)0x80000000UL);
772                    goto GET32F_END;
773 get32f_4321D_1234: sample64 = bswap_64(as_u64c(src));
774                    tmp_double = as_doublec(&sample);
775                    if (tmp_double >= 1.0)
776                         sample = 0x7fffffff;
777                    else if (tmp_double <= -1.0)
778                         sample = 0x80000000;
779                    else
780                         sample = (int32_t)(tmp_double * (double_t)0x80000000UL);
781                    goto GET32F_END;
782 #endif
783
784 #ifdef NORMS_LABELS
785 static inline void _norms(const void *src, void *dst,
786                           int src_wid,
787                           int dst_sign, int dst_wid, int dst_end)
788 {
789         int32_t s;
790         switch (src_wid) {
791         case 8:
792                 s = *(int8_t*)src;
793                 if (s >= 0x7f)
794                         goto _max;
795                 else if (s <= -0x80)
796                         goto _min;
797                 break;
798         case 16:
799                 s = *(int16_t*)src;
800                 if (s >= 0x7fff)
801                         goto _max;
802                 else if (s <= -0x8000)
803                         goto _min;
804                 break;
805         case 24:
806                 s = *(int32_t*)src;
807                 if (s >= 0x7fffff)
808                         goto _max;
809                 else if (s <= -0x800000)
810                         goto _min;
811                 break;
812         case 32:
813         {
814                 int64_t s64;
815                 s64 = *(int64_t*)src;
816                 if (s64 >= 0x7fffffff)
817                         goto _max;
818                 else if (s64 <= -0x80000000)
819                         goto _min;
820                 s = s64;
821                 break;
822         }
823         default:
824                 assert(0);
825                 return;
826         }
827         if (src_wid < dst_wid) {
828                 unsigned int bits = dst_wid - src_wid;
829                 s *= 1 << bits;
830         } else if (src_wid > dst_wid) {
831                 unsigned int bits = src_wid - dst_wid;
832                 s = (s + (1 << (bits - 1)))/ (1 << bits);
833         }
834         if (!dst_sign)
835                 s += (1U << (dst_wid - 1));
836         switch (dst_wid) {
837         case 8:
838                 *(u_int8_t*)dst = s;
839                 break;
840         case 16:
841                 if (dst_end)
842                         s = bswap_16(s);
843                 *(u_int16_t*)dst = s;
844                 break;
845         case 24:
846         case 32:
847                 if (dst_end)
848                         s = bswap_32(s);
849                 *(u_int32_t*)dst = s;
850                 break;
851         }
852         return;
853
854  _min:
855         switch (dst_wid) {
856         case 8:
857                 if (dst_sign)
858                         *(u_int8_t*)dst = 0x80;
859                 else
860                         *(u_int8_t*)dst = 0;
861                 break;
862         case 16:
863                 if (dst_sign)
864                         *(u_int16_t*)dst = dst_end ? 0x0080 : 0x8000;
865                 else
866                         *(u_int16_t*)dst = 0;
867                 break;
868         case 24:
869                 if (dst_sign)
870                         *(u_int32_t*)dst = dst_end ? 0x00008000 : 0x00800000;
871                 else
872                         *(u_int32_t*)dst = 0;
873                 break;
874         case 32:
875                 if (dst_sign)
876                         *(u_int32_t*)dst = dst_end ? 0x00000080 : 0x80000000;
877                 else
878                         *(u_int32_t*)dst = 0;
879                 break;
880         default:
881                 assert(0);
882                 break;
883         }
884         return;
885
886  _max:
887         switch (dst_wid) {
888         case 8:
889                 if (dst_sign)
890                         *(u_int8_t*)dst = 0x7f;
891                 else
892                         *(u_int8_t*)dst = 0xff;
893                 break;
894         case 16:
895                 if (dst_sign)
896                         *(u_int16_t*)dst = dst_end ? 0xff7f : 0x7fff;
897                 else
898                         *(u_int16_t*)dst = 0;
899                 break;
900         case 24:
901                 if (dst_sign)
902                         *(u_int32_t*)dst = dst_end ? 0xffff7f00 : 0x007fffff;
903                 else
904                         *(u_int32_t*)dst = 0;
905                 break;
906         case 32:
907                 if (dst_sign)
908                         *(u_int32_t*)dst = dst_end ? 0xffffff7f : 0x7fffffff;
909                 else
910                         *(u_int32_t*)dst = 0;
911                 break;
912         default:
913                 assert(0);
914                 break;
915         }
916         return;
917 }
918
919 /* src_wid dst_sign dst_wid dst_end */
920 static void *norms_labels[4 * 2 * 4 * 2] = {
921         &&norms_8_u8,           /*  s8 -> u8 */
922         &&norms_8_u8,           /*  s8 -> u8 */
923         &&norms_8_u16h,         /*  s8 -> u16h */
924         &&norms_8_u16s,         /*  s8 -> u16s */
925         &&norms_8_u24h,         /*  s8 -> u24h */
926         &&norms_8_u24s,         /*  s8 -> u24s */
927         &&norms_8_u32h,         /*  s8 -> u32h */
928         &&norms_8_u32s,         /*  s8 -> u32s */
929         &&norms_8_s8,           /*  s8 -> s8 */
930         &&norms_8_s8,           /*  s8 -> s8 */
931         &&norms_8_s16h,         /*  s8 -> s16h */
932         &&norms_8_s16s,         /*  s8 -> s16s */
933         &&norms_8_s24h,         /*  s8 -> s24h */
934         &&norms_8_s24s,         /*  s8 -> s24s */
935         &&norms_8_s32h,         /*  s8 -> s32h */
936         &&norms_8_s32s,         /*  s8 -> s32s */
937         &&norms_16_u8,          /* s16 -> u8 */
938         &&norms_16_u8,          /* s16 -> u8 */
939         &&norms_16_u16h,        /* s16 -> u16h */
940         &&norms_16_u16s,        /* s16 -> u16s */
941         &&norms_16_u24h,        /* s16 -> u24h */
942         &&norms_16_u24s,        /* s16 -> u24s */
943         &&norms_16_u32h,        /* s16 -> u32h */
944         &&norms_16_u32s,        /* s16 -> u32s */
945         &&norms_16_s8,          /* s16 -> s8 h*/
946         &&norms_16_s8,          /* s16 -> s8 */
947         &&norms_16_s16h,        /* s16 -> s16h */
948         &&norms_16_s16s,        /* s16 -> s16s */
949         &&norms_16_s24h,        /* s16 -> s24h */
950         &&norms_16_s24s,        /* s16 -> s24s */
951         &&norms_16_s32h,        /* s16 -> s32h */
952         &&norms_16_s32s,        /* s16 -> s32s */
953         &&norms_24_u8,          /* s24 -> u8 */
954         &&norms_24_u8,          /* s24 -> u8 */
955         &&norms_24_u16h,        /* s24 -> u16h */
956         &&norms_24_u16s,        /* s24 -> u16s */
957         &&norms_24_u24h,        /* s24 -> u24h */
958         &&norms_24_u24s,        /* s24 -> u24s */
959         &&norms_24_u32h,        /* s24 -> u32h */
960         &&norms_24_u32s,        /* s24 -> u32s */
961         &&norms_24_s8,          /* s24 -> s8 */
962         &&norms_24_s8,          /* s24 -> s8 */
963         &&norms_24_s16h,        /* s24 -> s16h */
964         &&norms_24_s16s,        /* s24 -> s16s */
965         &&norms_24_s24h,        /* s24 -> s24h */
966         &&norms_24_s24s,        /* s24 -> s24s */
967         &&norms_24_s32h,        /* s24 -> s32h */
968         &&norms_24_s32s,        /* s24 -> s32s */
969         &&norms_32_u8,          /* s32 -> u8 */
970         &&norms_32_u8,          /* s32 -> u8 */
971         &&norms_32_u16h,        /* s32 -> u16h */
972         &&norms_32_u16s,        /* s32 -> u16s */
973         &&norms_32_u24h,        /* s32 -> u24h */
974         &&norms_32_u24s,        /* s32 -> u24s */
975         &&norms_32_u32h,        /* s32 -> u32h */
976         &&norms_32_u32s,        /* s32 -> u32s */
977         &&norms_32_s8,          /* s32 -> s8 */
978         &&norms_32_s8,          /* s32 -> s8 */
979         &&norms_32_s16h,        /* s32 -> s16h */
980         &&norms_32_s16s,        /* s32 -> s16s */
981         &&norms_32_s24h,        /* s32 -> s24h */
982         &&norms_32_s24s,        /* s32 -> s24s */
983         &&norms_32_s32h,        /* s32 -> s32h */
984         &&norms_32_s32s,        /* s32 -> s32s */
985 };
986 #endif
987
988 #ifdef NORMS_END
989 norms_8_u8:     _norms(src, dst,  8, 0,  8, 0); goto NORMS_END;
990 norms_8_u16h:   _norms(src, dst,  8, 0,  16, 0); goto NORMS_END;
991 norms_8_u16s:   _norms(src, dst,  8, 0,  16, 1); goto NORMS_END;
992 norms_8_u24h:   _norms(src, dst,  8, 0,  24, 0); goto NORMS_END;
993 norms_8_u24s:   _norms(src, dst,  8, 0,  24, 1); goto NORMS_END;
994 norms_8_u32h:   _norms(src, dst,  8, 0,  32, 0); goto NORMS_END;
995 norms_8_u32s:   _norms(src, dst,  8, 0,  32, 1); goto NORMS_END;
996 norms_8_s8:     _norms(src, dst,  8, 1,  8, 0); goto NORMS_END;
997 norms_8_s16h:   _norms(src, dst,  8, 1,  16, 0); goto NORMS_END;
998 norms_8_s16s:   _norms(src, dst,  8, 1,  16, 1); goto NORMS_END;
999 norms_8_s24h:   _norms(src, dst,  8, 1,  24, 0); goto NORMS_END;
1000 norms_8_s24s:   _norms(src, dst,  8, 1,  24, 1); goto NORMS_END;
1001 norms_8_s32h:   _norms(src, dst,  8, 1,  32, 0); goto NORMS_END;
1002 norms_8_s32s:   _norms(src, dst,  8, 1,  32, 1); goto NORMS_END;
1003 norms_16_u8:    _norms(src, dst, 16, 0,  8, 0); goto NORMS_END;
1004 norms_16_u16h:  _norms(src, dst, 16, 0,  16, 0); goto NORMS_END;
1005 norms_16_u16s:  _norms(src, dst, 16, 0,  16, 1); goto NORMS_END;
1006 norms_16_u24h:  _norms(src, dst, 16, 0,  24, 0); goto NORMS_END;
1007 norms_16_u24s:  _norms(src, dst, 16, 0,  24, 1); goto NORMS_END;
1008 norms_16_u32h:  _norms(src, dst, 16, 0,  32, 0); goto NORMS_END;
1009 norms_16_u32s:  _norms(src, dst, 16, 0,  32, 1); goto NORMS_END;
1010 norms_16_s8:    _norms(src, dst, 16, 1,  8, 0); goto NORMS_END;
1011 norms_16_s16h:  _norms(src, dst, 16, 1,  16, 0); goto NORMS_END;
1012 norms_16_s16s:  _norms(src, dst, 16, 1,  16, 1); goto NORMS_END;
1013 norms_16_s24h:  _norms(src, dst, 16, 1,  24, 0); goto NORMS_END;
1014 norms_16_s24s:  _norms(src, dst, 16, 1,  24, 1); goto NORMS_END;
1015 norms_16_s32h:  _norms(src, dst, 16, 1,  32, 0); goto NORMS_END;
1016 norms_16_s32s:  _norms(src, dst, 16, 1,  32, 1); goto NORMS_END;
1017 norms_24_u8:    _norms(src, dst, 24, 0,  8, 0); goto NORMS_END;
1018 norms_24_u16h:  _norms(src, dst, 24, 0,  16, 0); goto NORMS_END;
1019 norms_24_u16s:  _norms(src, dst, 24, 0,  16, 1); goto NORMS_END;
1020 norms_24_u24h:  _norms(src, dst, 24, 0,  24, 0); goto NORMS_END;
1021 norms_24_u24s:  _norms(src, dst, 24, 0,  24, 1); goto NORMS_END;
1022 norms_24_u32h:  _norms(src, dst, 24, 0,  32, 0); goto NORMS_END;
1023 norms_24_u32s:  _norms(src, dst, 24, 0,  32, 1); goto NORMS_END;
1024 norms_24_s8:    _norms(src, dst, 24, 1,  8, 0); goto NORMS_END;
1025 norms_24_s16h:  _norms(src, dst, 24, 1,  16, 0); goto NORMS_END;
1026 norms_24_s16s:  _norms(src, dst, 24, 1,  16, 1); goto NORMS_END;
1027 norms_24_s24h:  _norms(src, dst, 24, 1,  24, 0); goto NORMS_END;
1028 norms_24_s24s:  _norms(src, dst, 24, 1,  24, 1); goto NORMS_END;
1029 norms_24_s32h:  _norms(src, dst, 24, 1,  32, 0); goto NORMS_END;
1030 norms_24_s32s:  _norms(src, dst, 24, 1,  32, 1); goto NORMS_END;
1031 norms_32_u8:    _norms(src, dst, 32, 0,  8, 0); goto NORMS_END;
1032 norms_32_u16h:  _norms(src, dst, 32, 0,  16, 0); goto NORMS_END;
1033 norms_32_u16s:  _norms(src, dst, 32, 0,  16, 1); goto NORMS_END;
1034 norms_32_u24h:  _norms(src, dst, 32, 0,  24, 0); goto NORMS_END;
1035 norms_32_u24s:  _norms(src, dst, 32, 0,  24, 1); goto NORMS_END;
1036 norms_32_u32h:  _norms(src, dst, 32, 0,  32, 0); goto NORMS_END;
1037 norms_32_u32s:  _norms(src, dst, 32, 0,  32, 1); goto NORMS_END;
1038 norms_32_s8:    _norms(src, dst, 32, 1,  8, 0); goto NORMS_END;
1039 norms_32_s16h:  _norms(src, dst, 32, 1,  16, 0); goto NORMS_END;
1040 norms_32_s16s:  _norms(src, dst, 32, 1,  16, 1); goto NORMS_END;
1041 norms_32_s24h:  _norms(src, dst, 32, 1,  24, 0); goto NORMS_END;
1042 norms_32_s24s:  _norms(src, dst, 32, 1,  24, 1); goto NORMS_END;
1043 norms_32_s32h:  _norms(src, dst, 32, 1,  32, 0); goto NORMS_END;
1044 norms_32_s32s:  _norms(src, dst, 32, 1,  32, 1); goto NORMS_END;
1045 #endif
1046
1047
1048 #undef as_u8
1049 #undef as_u16
1050 #undef as_u32
1051 #undef as_s8
1052 #undef as_s16
1053 #undef as_s32
1054 #undef as_float
1055 #undef as_double
1056
1057 #undef as_u8c
1058 #undef as_u16c
1059 #undef as_u32c
1060 #undef as_s8c
1061 #undef as_s16c
1062 #undef as_s32c
1063 #undef as_floatc
1064 #undef as_doublec
1065
1066 #undef _get_triple
1067 #undef _get_triple_s
1068 #undef _get_triple_le
1069 #undef _get_triple_be
1070 #undef _put_triple
1071 #undef _put_triple_s
1072 #undef _put_triple_le
1073 #undef _put_triple_be
1074