2 * Plugin sample operators with fast switch
3 * Copyright (c) 2000 by Jaroslav Kysela <perex@suse.cz>
6 * This library is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Library General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
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 Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #define as_u8(ptr) (*(u_int8_t*)(ptr))
24 #define as_u16(ptr) (*(u_int16_t*)(ptr))
25 #define as_u32(ptr) (*(u_int32_t*)(ptr))
26 #define as_u64(ptr) (*(u_int64_t*)(ptr))
27 #define as_s8(ptr) (*(int8_t*)(ptr))
28 #define as_s16(ptr) (*(int16_t*)(ptr))
29 #define as_s32(ptr) (*(int32_t*)(ptr))
30 #define as_s64(ptr) (*(int64_t*)(ptr))
32 #define as_u8c(ptr) (*(const u_int8_t*)(ptr))
33 #define as_u16c(ptr) (*(const u_int16_t*)(ptr))
34 #define as_u32c(ptr) (*(const u_int32_t*)(ptr))
35 #define as_u64c(ptr) (*(const u_int64_t*)(ptr))
36 #define as_s8c(ptr) (*(const int8_t*)(ptr))
37 #define as_s16c(ptr) (*(const int16_t*)(ptr))
38 #define as_s32c(ptr) (*(const int32_t*)(ptr))
39 #define as_s64c(ptr) (*(const int64_t*)(ptr))
42 static void *copy_labels[4] = {
52 copy_8: as_s8(dst) = as_s8c(src); goto COPY_END;
53 copy_16: as_s16(dst) = as_s16c(src); goto COPY_END;
54 copy_32: as_s32(dst) = as_s32c(src); goto COPY_END;
55 copy_64: as_s64(dst) = as_s64c(src); goto COPY_END;
60 /* src_wid src_endswap sign_toggle dst_wid dst_endswap */
61 static void *conv_labels[4 * 2 * 2 * 4 * 2] = {
62 &&conv_xxx1_xxx1, /* 8h -> 8h */
63 &&conv_xxx1_xxx1, /* 8h -> 8s */
64 &&conv_xxx1_xx10, /* 8h -> 16h */
65 &&conv_xxx1_xx01, /* 8h -> 16s */
66 &&conv_xxx1_x100, /* 8h -> 24h */
67 &&conv_xxx1_001x, /* 8h -> 24s */
68 &&conv_xxx1_1000, /* 8h -> 32h */
69 &&conv_xxx1_0001, /* 8h -> 32s */
70 &&conv_xxx1_xxx9, /* 8h ^> 8h */
71 &&conv_xxx1_xxx9, /* 8h ^> 8s */
72 &&conv_xxx1_xx90, /* 8h ^> 16h */
73 &&conv_xxx1_xx09, /* 8h ^> 16s */
74 &&conv_xxx1_x900, /* 8h ^> 24h */
75 &&conv_xxx1_009x, /* 8h ^> 24s */
76 &&conv_xxx1_9000, /* 8h ^> 32h */
77 &&conv_xxx1_0009, /* 8h ^> 32s */
78 &&conv_xxx1_xxx1, /* 8s -> 8h */
79 &&conv_xxx1_xxx1, /* 8s -> 8s */
80 &&conv_xxx1_xx10, /* 8s -> 16h */
81 &&conv_xxx1_xx01, /* 8s -> 16s */
82 &&conv_xxx1_x100, /* 8s -> 24h */
83 &&conv_xxx1_001x, /* 8s -> 24s */
84 &&conv_xxx1_1000, /* 8s -> 32h */
85 &&conv_xxx1_0001, /* 8s -> 32s */
86 &&conv_xxx1_xxx9, /* 8s ^> 8h */
87 &&conv_xxx1_xxx9, /* 8s ^> 8s */
88 &&conv_xxx1_xx90, /* 8s ^> 16h */
89 &&conv_xxx1_xx09, /* 8s ^> 16s */
90 &&conv_xxx1_x900, /* 8s ^> 24h */
91 &&conv_xxx1_009x, /* 8s ^> 24s */
92 &&conv_xxx1_9000, /* 8s ^> 32h */
93 &&conv_xxx1_0009, /* 8s ^> 32s */
94 &&conv_xx12_xxx1, /* 16h -> 8h */
95 &&conv_xx12_xxx1, /* 16h -> 8s */
96 &&conv_xx12_xx12, /* 16h -> 16h */
97 &&conv_xx12_xx21, /* 16h -> 16s */
98 &&conv_xx12_x120, /* 16h -> 24h */
99 &&conv_xx12_021x, /* 16h -> 24s */
100 &&conv_xx12_1200, /* 16h -> 32h */
101 &&conv_xx12_0021, /* 16h -> 32s */
102 &&conv_xx12_xxx9, /* 16h ^> 8h */
103 &&conv_xx12_xxx9, /* 16h ^> 8s */
104 &&conv_xx12_xx92, /* 16h ^> 16h */
105 &&conv_xx12_xx29, /* 16h ^> 16s */
106 &&conv_xx12_x920, /* 16h ^> 24h */
107 &&conv_xx12_029x, /* 16h ^> 24s */
108 &&conv_xx12_9200, /* 16h ^> 32h */
109 &&conv_xx12_0029, /* 16h ^> 32s */
110 &&conv_xx12_xxx2, /* 16s -> 8h */
111 &&conv_xx12_xxx2, /* 16s -> 8s */
112 &&conv_xx12_xx21, /* 16s -> 16h */
113 &&conv_xx12_xx12, /* 16s -> 16s */
114 &&conv_xx12_x210, /* 16s -> 24h */
115 &&conv_xx12_012x, /* 16s -> 24s */
116 &&conv_xx12_2100, /* 16s -> 32h */
117 &&conv_xx12_0012, /* 16s -> 32s */
118 &&conv_xx12_xxxA, /* 16s ^> 8h */
119 &&conv_xx12_xxxA, /* 16s ^> 8s */
120 &&conv_xx12_xxA1, /* 16s ^> 16h */
121 &&conv_xx12_xx1A, /* 16s ^> 16s */
122 &&conv_xx12_xA10, /* 16s ^> 24h */
123 &&conv_xx12_01Ax, /* 16s ^> 24s */
124 &&conv_xx12_A100, /* 16s ^> 32h */
125 &&conv_xx12_001A, /* 16s ^> 32s */
126 &&conv_x123_xxx1, /* 24h -> 8h */
127 &&conv_x123_xxx1, /* 24h -> 8s */
128 &&conv_x123_xx12, /* 24h -> 16h */
129 &&conv_x123_xx21, /* 24h -> 16s */
130 &&conv_x123_x123, /* 24h -> 24h */
131 &&conv_x123_321x, /* 24h -> 24s */
132 &&conv_x123_1230, /* 24h -> 32h */
133 &&conv_x123_0321, /* 24h -> 32s */
134 &&conv_x123_xxx9, /* 24h ^> 8h */
135 &&conv_x123_xxx9, /* 24h ^> 8s */
136 &&conv_x123_xx92, /* 24h ^> 16h */
137 &&conv_x123_xx29, /* 24h ^> 16s */
138 &&conv_x123_x923, /* 24h ^> 24h */
139 &&conv_x123_329x, /* 24h ^> 24s */
140 &&conv_x123_9230, /* 24h ^> 32h */
141 &&conv_x123_0329, /* 24h ^> 32s */
142 &&conv_123x_xxx3, /* 24s -> 8h */
143 &&conv_123x_xxx3, /* 24s -> 8s */
144 &&conv_123x_xx32, /* 24s -> 16h */
145 &&conv_123x_xx23, /* 24s -> 16s */
146 &&conv_123x_x321, /* 24s -> 24h */
147 &&conv_123x_123x, /* 24s -> 24s */
148 &&conv_123x_3210, /* 24s -> 32h */
149 &&conv_123x_0123, /* 24s -> 32s */
150 &&conv_123x_xxxB, /* 24s ^> 8h */
151 &&conv_123x_xxxB, /* 24s ^> 8s */
152 &&conv_123x_xxB2, /* 24s ^> 16h */
153 &&conv_123x_xx2B, /* 24s ^> 16s */
154 &&conv_123x_xB21, /* 24s ^> 24h */
155 &&conv_123x_12Bx, /* 24s ^> 24s */
156 &&conv_123x_B210, /* 24s ^> 32h */
157 &&conv_123x_012B, /* 24s ^> 32s */
158 &&conv_1234_xxx1, /* 32h -> 8h */
159 &&conv_1234_xxx1, /* 32h -> 8s */
160 &&conv_1234_xx12, /* 32h -> 16h */
161 &&conv_1234_xx21, /* 32h -> 16s */
162 &&conv_1234_x123, /* 32h -> 24h */
163 &&conv_1234_321x, /* 32h -> 24s */
164 &&conv_1234_1234, /* 32h -> 32h */
165 &&conv_1234_4321, /* 32h -> 32s */
166 &&conv_1234_xxx9, /* 32h ^> 8h */
167 &&conv_1234_xxx9, /* 32h ^> 8s */
168 &&conv_1234_xx92, /* 32h ^> 16h */
169 &&conv_1234_xx29, /* 32h ^> 16s */
170 &&conv_1234_x923, /* 32h ^> 24h */
171 &&conv_1234_329x, /* 32h ^> 24s */
172 &&conv_1234_9234, /* 32h ^> 32h */
173 &&conv_1234_4329, /* 32h ^> 32s */
174 &&conv_1234_xxx4, /* 32s -> 8h */
175 &&conv_1234_xxx4, /* 32s -> 8s */
176 &&conv_1234_xx43, /* 32s -> 16h */
177 &&conv_1234_xx34, /* 32s -> 16s */
178 &&conv_1234_x432, /* 32s -> 24h */
179 &&conv_1234_234x, /* 32s -> 24s */
180 &&conv_1234_4321, /* 32s -> 32h */
181 &&conv_1234_1234, /* 32s -> 32s */
182 &&conv_1234_xxxC, /* 32s ^> 8h */
183 &&conv_1234_xxxC, /* 32s ^> 8s */
184 &&conv_1234_xxC3, /* 32s ^> 16h */
185 &&conv_1234_xx3C, /* 32s ^> 16s */
186 &&conv_1234_xC32, /* 32s ^> 24h */
187 &&conv_1234_23Cx, /* 32s ^> 24s */
188 &&conv_1234_C321, /* 32s ^> 32h */
189 &&conv_1234_123C, /* 32s ^> 32s */
195 conv_xxx1_xxx1: as_u8(dst) = as_u8c(src); goto CONV_END;
196 conv_xxx1_xx10: as_u16(dst) = (u_int16_t)as_u8c(src) << 8; goto CONV_END;
197 conv_xxx1_xx01: as_u16(dst) = (u_int16_t)as_u8c(src); goto CONV_END;
198 conv_xxx1_x100: as_u32(dst) = (u_int32_t)as_u8c(src) << 16; goto CONV_END;
199 conv_xxx1_001x: as_u32(dst) = (u_int32_t)as_u8c(src) << 8; goto CONV_END;
200 conv_xxx1_1000: as_u32(dst) = (u_int32_t)as_u8c(src) << 24; goto CONV_END;
201 conv_xxx1_0001: as_u32(dst) = (u_int32_t)as_u8c(src); goto CONV_END;
202 conv_xxx1_xxx9: as_u8(dst) = as_u8c(src) ^ 0x80; goto CONV_END;
203 conv_xxx1_xx90: as_u16(dst) = (u_int16_t)(as_u8c(src) ^ 0x80) << 8; goto CONV_END;
204 conv_xxx1_xx09: as_u16(dst) = (u_int16_t)(as_u8c(src) ^ 0x80); goto CONV_END;
205 conv_xxx1_x900: as_u32(dst) = (u_int32_t)(as_u8c(src) ^ 0x80) << 16; goto CONV_END;
206 conv_xxx1_009x: as_u32(dst) = (u_int32_t)(as_u8c(src) ^ 0x80) << 8; goto CONV_END;
207 conv_xxx1_9000: as_u32(dst) = (u_int32_t)(as_u8c(src) ^ 0x80) << 24; goto CONV_END;
208 conv_xxx1_0009: as_u32(dst) = (u_int32_t)(as_u8c(src) ^ 0x80); goto CONV_END;
209 conv_xx12_xxx1: as_u8(dst) = as_u16c(src) >> 8; goto CONV_END;
210 conv_xx12_xx12: as_u16(dst) = as_u16c(src); goto CONV_END;
211 conv_xx12_xx21: as_u16(dst) = bswap_16(as_u16c(src)); goto CONV_END;
212 conv_xx12_x120: as_u32(dst) = (u_int32_t)as_u16c(src) << 8; goto CONV_END;
213 conv_xx12_021x: as_u32(dst) = (u_int32_t)bswap_16(as_u16c(src)) << 8; goto CONV_END;
214 conv_xx12_1200: as_u32(dst) = (u_int32_t)as_u16c(src) << 16; goto CONV_END;
215 conv_xx12_0021: as_u32(dst) = (u_int32_t)bswap_16(as_u16c(src)); goto CONV_END;
216 conv_xx12_xxx9: as_u8(dst) = (as_u16c(src) >> 8) ^ 0x80; goto CONV_END;
217 conv_xx12_xx92: as_u16(dst) = as_u16c(src) ^ 0x8000; goto CONV_END;
218 conv_xx12_xx29: as_u16(dst) = bswap_16(as_u16c(src)) ^ 0x80; goto CONV_END;
219 conv_xx12_x920: as_u32(dst) = (u_int32_t)(as_u16c(src) ^ 0x8000) << 8; goto CONV_END;
220 conv_xx12_029x: as_u32(dst) = (u_int32_t)(bswap_16(as_u16c(src)) ^ 0x80) << 8; goto CONV_END;
221 conv_xx12_9200: as_u32(dst) = (u_int32_t)(as_u16c(src) ^ 0x8000) << 16; goto CONV_END;
222 conv_xx12_0029: as_u32(dst) = (u_int32_t)(bswap_16(as_u16c(src)) ^ 0x80); goto CONV_END;
223 conv_xx12_xxx2: as_u8(dst) = as_u16c(src) & 0xff; goto CONV_END;
224 conv_xx12_x210: as_u32(dst) = (u_int32_t)bswap_16(as_u16c(src)) << 8; goto CONV_END;
225 conv_xx12_012x: as_u32(dst) = (u_int32_t)as_u16c(src) << 8; goto CONV_END;
226 conv_xx12_2100: as_u32(dst) = (u_int32_t)bswap_16(as_u16c(src)) << 16; goto CONV_END;
227 conv_xx12_0012: as_u32(dst) = (u_int32_t)as_u16c(src); goto CONV_END;
228 conv_xx12_xxxA: as_u8(dst) = (as_u16c(src) ^ 0x80) & 0xff; goto CONV_END;
229 conv_xx12_xxA1: as_u16(dst) = bswap_16(as_u16c(src) ^ 0x80); goto CONV_END;
230 conv_xx12_xx1A: as_u16(dst) = as_u16c(src) ^ 0x80; goto CONV_END;
231 conv_xx12_xA10: as_u32(dst) = (u_int32_t)bswap_16(as_u16c(src) ^ 0x80) << 8; goto CONV_END;
232 conv_xx12_01Ax: as_u32(dst) = (u_int32_t)(as_u16c(src) ^ 0x80) << 8; goto CONV_END;
233 conv_xx12_A100: as_u32(dst) = (u_int32_t)bswap_16(as_u16c(src) ^ 0x80) << 16; goto CONV_END;
234 conv_xx12_001A: as_u32(dst) = (u_int32_t)(as_u16c(src) ^ 0x80); goto CONV_END;
235 conv_x123_xxx1: as_u8(dst) = as_u32c(src) >> 16; goto CONV_END;
236 conv_x123_xx12: as_u16(dst) = as_u32c(src) >> 8; goto CONV_END;
237 conv_x123_xx21: as_u16(dst) = bswap_16(as_u32c(src) >> 8); goto CONV_END;
238 conv_x123_x123: as_u32(dst) = as_u32c(src); goto CONV_END;
239 conv_x123_321x: as_u32(dst) = bswap_32(as_u32c(src)); goto CONV_END;
240 conv_x123_1230: as_u32(dst) = as_u32c(src) << 8; goto CONV_END;
241 conv_x123_0321: as_u32(dst) = bswap_32(as_u32c(src)) >> 8; goto CONV_END;
242 conv_x123_xxx9: as_u8(dst) = (as_u32c(src) >> 16) ^ 0x80; goto CONV_END;
243 conv_x123_xx92: as_u16(dst) = (as_u32c(src) >> 8) ^ 0x8000; goto CONV_END;
244 conv_x123_xx29: as_u16(dst) = bswap_16(as_u32c(src) >> 8) ^ 0x80; goto CONV_END;
245 conv_x123_x923: as_u32(dst) = as_u32c(src) ^ 0x800000; goto CONV_END;
246 conv_x123_329x: as_u32(dst) = bswap_32(as_u32c(src)) ^ 0x8000; goto CONV_END;
247 conv_x123_9230: as_u32(dst) = (as_u32c(src) ^ 0x800000) << 8; goto CONV_END;
248 conv_x123_0329: as_u32(dst) = (bswap_32(as_u32c(src)) >> 8) ^ 0x80; goto CONV_END;
249 conv_123x_xxx3: as_u8(dst) = (as_u32c(src) >> 8) & 0xff; goto CONV_END;
250 conv_123x_xx32: as_u16(dst) = bswap_16(as_u32c(src) >> 8); goto CONV_END;
251 conv_123x_xx23: as_u16(dst) = (as_u32c(src) >> 8) & 0xffff; goto CONV_END;
252 conv_123x_x321: as_u32(dst) = bswap_32(as_u32c(src)); goto CONV_END;
253 conv_123x_123x: as_u32(dst) = as_u32c(src); goto CONV_END;
254 conv_123x_3210: as_u32(dst) = bswap_32(as_u32c(src)) << 8; goto CONV_END;
255 conv_123x_0123: as_u32(dst) = as_u32c(src) >> 8; goto CONV_END;
256 conv_123x_xxxB: as_u8(dst) = ((as_u32c(src) >> 8) & 0xff) ^ 0x80; goto CONV_END;
257 conv_123x_xxB2: as_u16(dst) = bswap_16((as_u32c(src) >> 8) ^ 0x80); goto CONV_END;
258 conv_123x_xx2B: as_u16(dst) = ((as_u32c(src) >> 8) & 0xffff) ^ 0x80; goto CONV_END;
259 conv_123x_xB21: as_u32(dst) = bswap_32(as_u32c(src)) ^ 0x800000; goto CONV_END;
260 conv_123x_12Bx: as_u32(dst) = as_u32c(src) ^ 0x8000; goto CONV_END;
261 conv_123x_B210: as_u32(dst) = bswap_32(as_u32c(src) ^ 0x8000) << 8; goto CONV_END;
262 conv_123x_012B: as_u32(dst) = (as_u32c(src) >> 8) ^ 0x80; goto CONV_END;
263 conv_1234_xxx1: as_u8(dst) = as_u32c(src) >> 24; goto CONV_END;
264 conv_1234_xx12: as_u16(dst) = as_u32c(src) >> 16; goto CONV_END;
265 conv_1234_xx21: as_u16(dst) = bswap_16(as_u32c(src) >> 16); goto CONV_END;
266 conv_1234_x123: as_u32(dst) = as_u32c(src) >> 8; goto CONV_END;
267 conv_1234_321x: as_u32(dst) = bswap_32(as_u32c(src)) << 8; goto CONV_END;
268 conv_1234_1234: as_u32(dst) = as_u32c(src); goto CONV_END;
269 conv_1234_4321: as_u32(dst) = bswap_32(as_u32c(src)); goto CONV_END;
270 conv_1234_xxx9: as_u8(dst) = (as_u32c(src) >> 24) ^ 0x80; goto CONV_END;
271 conv_1234_xx92: as_u16(dst) = (as_u32c(src) >> 16) ^ 0x8000; goto CONV_END;
272 conv_1234_xx29: as_u16(dst) = bswap_16(as_u32c(src) >> 16) ^ 0x80; goto CONV_END;
273 conv_1234_x923: as_u32(dst) = (as_u32c(src) >> 8) ^ 0x800000; goto CONV_END;
274 conv_1234_329x: as_u32(dst) = (bswap_32(as_u32c(src)) ^ 0x80) << 8; goto CONV_END;
275 conv_1234_9234: as_u32(dst) = as_u32c(src) ^ 0x80000000; goto CONV_END;
276 conv_1234_4329: as_u32(dst) = bswap_32(as_u32c(src)) ^ 0x80; goto CONV_END;
277 conv_1234_xxx4: as_u8(dst) = as_u32c(src) & 0xff; goto CONV_END;
278 conv_1234_xx43: as_u16(dst) = bswap_16(as_u32c(src)); goto CONV_END;
279 conv_1234_xx34: as_u16(dst) = as_u32c(src) & 0xffff; goto CONV_END;
280 conv_1234_x432: as_u32(dst) = bswap_32(as_u32c(src)) >> 8; goto CONV_END;
281 conv_1234_234x: as_u32(dst) = as_u32c(src) << 8; goto CONV_END;
282 conv_1234_xxxC: as_u8(dst) = (as_u32c(src) & 0xff) ^ 0x80; goto CONV_END;
283 conv_1234_xxC3: as_u16(dst) = bswap_16(as_u32c(src) ^ 0x80); goto CONV_END;
284 conv_1234_xx3C: as_u16(dst) = (as_u32c(src) & 0xffff) ^ 0x80; goto CONV_END;
285 conv_1234_xC32: as_u32(dst) = (bswap_32(as_u32c(src)) >> 8) ^ 0x800000; goto CONV_END;
286 conv_1234_23Cx: as_u32(dst) = (as_u32c(src) ^ 0x80) << 8; goto CONV_END;
287 conv_1234_C321: as_u32(dst) = bswap_32(as_u32c(src) ^ 0x80); goto CONV_END;
288 conv_1234_123C: as_u32(dst) = as_u32c(src) ^ 0x80; goto CONV_END;
293 /* src_wid src_endswap sign_toggle */
294 static void *get16_labels[4 * 2 * 2] = {
295 &&get16_1_10, /* 8h -> 16h */
296 &&get16_1_90, /* 8h ^> 16h */
297 &&get16_1_10, /* 8s -> 16h */
298 &&get16_1_90, /* 8s ^> 16h */
299 &&get16_12_12, /* 16h -> 16h */
300 &&get16_12_92, /* 16h ^> 16h */
301 &&get16_12_21, /* 16s -> 16h */
302 &&get16_12_A1, /* 16s ^> 16h */
303 &&get16_0123_12, /* 24h -> 16h */
304 &&get16_0123_92, /* 24h ^> 16h */
305 &&get16_1230_32, /* 24s -> 16h */
306 &&get16_1230_B2, /* 24s ^> 16h */
307 &&get16_1234_12, /* 32h -> 16h */
308 &&get16_1234_92, /* 32h ^> 16h */
309 &&get16_1234_43, /* 32s -> 16h */
310 &&get16_1234_C3, /* 32s ^> 16h */
316 get16_1_10: sample = (u_int16_t)as_u8c(src) << 8; goto GET16_END;
317 get16_1_90: sample = (u_int16_t)(as_u8c(src) ^ 0x80) << 8; goto GET16_END;
318 get16_12_12: sample = as_u16c(src); goto GET16_END;
319 get16_12_92: sample = as_u16c(src) ^ 0x8000; goto GET16_END;
320 get16_12_21: sample = bswap_16(as_u16c(src)); goto GET16_END;
321 get16_12_A1: sample = bswap_16(as_u16c(src) ^ 0x80); goto GET16_END;
322 get16_0123_12: sample = as_u32c(src) >> 8; goto GET16_END;
323 get16_0123_92: sample = (as_u32c(src) >> 8) ^ 0x8000; goto GET16_END;
324 get16_1230_32: sample = bswap_16(as_u32c(src) >> 8); goto GET16_END;
325 get16_1230_B2: sample = bswap_16((as_u32c(src) >> 8) ^ 0x8000); goto GET16_END;
326 get16_1234_12: sample = as_u32c(src) >> 16; goto GET16_END;
327 get16_1234_92: sample = (as_u32c(src) >> 16) ^ 0x8000; goto GET16_END;
328 get16_1234_43: sample = bswap_16(as_u32c(src)); goto GET16_END;
329 get16_1234_C3: sample = bswap_16(as_u32c(src) ^ 0x80); goto GET16_END;
334 /* dst_wid dst_endswap sign_toggle */
335 static void *put16_labels[4 * 2 * 2 * 4 * 2] = {
336 &&put16_12_1, /* 16h -> 8h */
337 &&put16_12_9, /* 16h ^> 8h */
338 &&put16_12_1, /* 16h -> 8s */
339 &&put16_12_9, /* 16h ^> 8s */
340 &&put16_12_12, /* 16h -> 16h */
341 &&put16_12_92, /* 16h ^> 16h */
342 &&put16_12_21, /* 16h -> 16s */
343 &&put16_12_29, /* 16h ^> 16s */
344 &&put16_12_0120, /* 16h -> 24h */
345 &&put16_12_0920, /* 16h ^> 24h */
346 &&put16_12_0210, /* 16h -> 24s */
347 &&put16_12_0290, /* 16h ^> 24s */
348 &&put16_12_1200, /* 16h -> 32h */
349 &&put16_12_9200, /* 16h ^> 32h */
350 &&put16_12_0021, /* 16h -> 32s */
351 &&put16_12_0029, /* 16h ^> 32s */
357 put16_12_1: as_u8(dst) = sample >> 8; goto PUT16_END;
358 put16_12_9: as_u8(dst) = (sample >> 8) ^ 0x80; goto PUT16_END;
359 put16_12_12: as_u16(dst) = sample; goto PUT16_END;
360 put16_12_92: as_u16(dst) = sample ^ 0x8000; goto PUT16_END;
361 put16_12_21: as_u16(dst) = bswap_16(sample); goto PUT16_END;
362 put16_12_29: as_u16(dst) = bswap_16(sample) ^ 0x80; goto PUT16_END;
363 put16_12_0120: as_u32(dst) = (u_int32_t)sample << 8; goto PUT16_END;
364 put16_12_0920: as_u32(dst) = (u_int32_t)(sample ^ 0x8000) << 8; goto PUT16_END;
365 put16_12_0210: as_u32(dst) = (u_int32_t)bswap_16(sample) << 8; goto PUT16_END;
366 put16_12_0290: as_u32(dst) = (u_int32_t)(bswap_16(sample) ^ 0x80) << 8; goto PUT16_END;
367 put16_12_1200: as_u32(dst) = (u_int32_t)sample << 16; goto PUT16_END;
368 put16_12_9200: as_u32(dst) = (u_int32_t)(sample ^ 0x8000) << 16; goto PUT16_END;
369 put16_12_0021: as_u32(dst) = (u_int32_t)bswap_16(sample); goto PUT16_END;
370 put16_12_0029: as_u32(dst) = (u_int32_t)bswap_16(sample) ^ 0x80; goto PUT16_END;
375 /* src_wid src_endswap sign_toggle */
376 static void *get32_labels[4 * 2 * 2] = {
377 &&get32_1_1000, /* 8h -> 32h */
378 &&get32_1_9000, /* 8h ^> 32h */
379 &&get32_1_1000, /* 8s -> 32h */
380 &&get32_1_9000, /* 8s ^> 32h */
381 &&get32_12_1200, /* 16h -> 32h */
382 &&get32_12_9200, /* 16h ^> 32h */
383 &&get32_12_2100, /* 16s -> 32h */
384 &&get32_12_A100, /* 16s ^> 32h */
385 &&get32_0123_1230, /* 24h -> 32h */
386 &&get32_0123_9230, /* 24h ^> 32h */
387 &&get32_1230_3210, /* 24s -> 32h */
388 &&get32_1230_B210, /* 24s ^> 32h */
389 &&get32_1234_1234, /* 32h -> 32h */
390 &&get32_1234_9234, /* 32h ^> 32h */
391 &&get32_1234_4321, /* 32s -> 32h */
392 &&get32_1234_C321, /* 32s ^> 32h */
398 get32_1_1000: sample = (u_int32_t)as_u8c(src) << 24; goto GET32_END;
399 get32_1_9000: sample = (u_int32_t)(as_u8c(src) ^ 0x80) << 24; goto GET32_END;
400 get32_12_1200: sample = (u_int32_t)as_u16c(src) << 16; goto GET32_END;
401 get32_12_9200: sample = (u_int32_t)(as_u16c(src) ^ 0x8000) << 16; goto GET32_END;
402 get32_12_2100: sample = (u_int32_t)bswap_16(as_u16c(src)) << 16; goto GET32_END;
403 get32_12_A100: sample = (u_int32_t)bswap_16(as_u16c(src) ^ 0x80) << 16; goto GET32_END;
404 get32_0123_1230: sample = as_u32c(src) << 8; goto GET32_END;
405 get32_0123_9230: sample = (as_u32c(src) << 8) ^ 0x80000000; goto GET32_END;
406 get32_1230_3210: sample = bswap_32(as_u32c(src) >> 8); goto GET32_END;
407 get32_1230_B210: sample = bswap_32((as_u32c(src) >> 8) ^ 0x80); goto GET32_END;
408 get32_1234_1234: sample = as_u32c(src); goto GET32_END;
409 get32_1234_9234: sample = as_u32c(src) ^ 0x80000000; goto GET32_END;
410 get32_1234_4321: sample = bswap_32(as_u32c(src)); goto GET32_END;
411 get32_1234_C321: sample = bswap_32(as_u32c(src) ^ 0x80); goto GET32_END;
416 /* dst_wid dst_endswap sign_toggle */
417 static void *put32_labels[4 * 2 * 2] = {
418 &&put32_1234_1, /* 32h -> 8h */
419 &&put32_1234_9, /* 32h ^> 8h */
420 &&put32_1234_1, /* 32h -> 8s */
421 &&put32_1234_9, /* 32h ^> 8s */
422 &&put32_1234_12, /* 32h -> 16h */
423 &&put32_1234_92, /* 32h ^> 16h */
424 &&put32_1234_21, /* 32h -> 16s */
425 &&put32_1234_29, /* 32h ^> 16s */
426 &&put32_1234_0123, /* 32h -> 24h */
427 &&put32_1234_0923, /* 32h ^> 24h */
428 &&put32_1234_3210, /* 32h -> 24s */
429 &&put32_1234_3290, /* 32h ^> 24s */
430 &&put32_1234_1234, /* 32h -> 32h */
431 &&put32_1234_9234, /* 32h ^> 32h */
432 &&put32_1234_4321, /* 32h -> 32s */
433 &&put32_1234_4329, /* 32h ^> 32s */
439 put32_1234_1: as_u8(dst) = sample >> 24; goto PUT32_END;
440 put32_1234_9: as_u8(dst) = (sample >> 24) ^ 0x80; goto PUT32_END;
441 put32_1234_12: as_u16(dst) = sample >> 16; goto PUT32_END;
442 put32_1234_92: as_u16(dst) = (sample >> 16) ^ 0x8000; goto PUT32_END;
443 put32_1234_21: as_u16(dst) = bswap_16(sample >> 16); goto PUT32_END;
444 put32_1234_29: as_u16(dst) = bswap_16(sample >> 16) ^ 0x80; goto PUT32_END;
445 put32_1234_0123: as_u32(dst) = sample >> 8; goto PUT32_END;
446 put32_1234_0923: as_u32(dst) = (sample >> 8) ^ 0x800000; goto PUT32_END;
447 put32_1234_3210: as_u32(dst) = bswap_32(sample) << 8; goto PUT32_END;
448 put32_1234_3290: as_u32(dst) = (bswap_32(sample) ^ 0x80) << 8; goto PUT32_END;
449 put32_1234_1234: as_u32(dst) = sample; goto PUT32_END;
450 put32_1234_9234: as_u32(dst) = sample ^ 0x80000000; goto PUT32_END;
451 put32_1234_4321: as_u32(dst) = bswap_32(sample); goto PUT32_END;
452 put32_1234_4329: as_u32(dst) = bswap_32(sample) ^ 0x80; goto PUT32_END;
457 /* width endswap sign_toggle */
458 static void *getu_labels[4 * 2 * 2] = {
459 &&getu_1_1, /* 8h -> 8h */
460 &&getu_1_9, /* 8h ^> 8h */
461 &&getu_1_1, /* 8s -> 8h */
462 &&getu_1_9, /* 8s ^> 8h */
463 &&getu_12_12, /* 16h -> 16h */
464 &&getu_12_92, /* 16h ^> 16h */
465 &&getu_12_21, /* 16s -> 16h */
466 &&getu_12_A1, /* 16s ^> 16h */
467 &&getu_0123_0123, /* 24h -> 24h */
468 &&getu_0123_0923, /* 24h ^> 24h */
469 &&getu_1230_0321, /* 24s -> 24h */
470 &&getu_1230_0B21, /* 24s ^> 24h */
471 &&getu_1234_1234, /* 32h -> 32h */
472 &&getu_1234_9234, /* 32h ^> 32h */
473 &&getu_1234_4321, /* 32s -> 32h */
474 &&getu_1234_C321, /* 32s ^> 32h */
480 getu_1_1: sample = as_u8c(src); goto GETU_END;
481 getu_1_9: sample = as_u8c(src) ^ 0x80; goto GETU_END;
482 getu_12_12: sample = as_u16c(src); goto GETU_END;
483 getu_12_92: sample = as_u16c(src) ^ 0x8000; goto GETU_END;
484 getu_12_21: sample = bswap_16(as_u16c(src)); goto GETU_END;
485 getu_12_A1: sample = bswap_16(as_u16c(src) ^ 0x80); goto GETU_END;
486 getu_0123_0123: sample = as_u32c(src); goto GETU_END;
487 getu_0123_0923: sample = (as_u32c(src) ^ 0x800000); goto GETU_END;
488 getu_1230_0321: sample = bswap_32(as_u32c(src)); goto GETU_END;
489 getu_1230_0B21: sample = bswap_32(as_u32c(src) ^ 0x8000); goto GETU_END;
490 getu_1234_1234: sample = as_u32c(src); goto GETU_END;
491 getu_1234_9234: sample = as_u32c(src) ^ 0x80000000; goto GETU_END;
492 getu_1234_4321: sample = bswap_32(as_u32c(src)); goto GETU_END;
493 getu_1234_C321: sample = bswap_32(as_u32c(src) ^ 0x80); goto GETU_END;
498 /* width endswap sign_toggle */
499 static void *put_labels[4 * 2 * 2] = {
500 &&put_1_1, /* 8h -> 8h */
501 &&put_1_9, /* 8h ^> 8h */
502 &&put_1_1, /* 8h -> 8s */
503 &&put_1_9, /* 8h ^> 8s */
504 &&put_12_12, /* 16h -> 16h */
505 &&put_12_92, /* 16h ^> 16h */
506 &&put_12_21, /* 16h -> 16s */
507 &&put_12_A1, /* 16h ^> 16s */
508 &&put_0123_0123, /* 24h -> 24h */
509 &&put_0123_0923, /* 24h ^> 24h */
510 &&put_0123_3210, /* 24h -> 24s */
511 &&put_0123_3290, /* 24h ^> 24s */
512 &&put_1234_1234, /* 32h -> 32h */
513 &&put_1234_9234, /* 32h ^> 32h */
514 &&put_1234_4321, /* 32h -> 32s */
515 &&put_1234_4329, /* 32h ^> 32s */
520 put_1_1: as_s8(dst) = sample; goto PUT_END;
521 put_1_9: as_u8(dst) = sample ^ 0x80; goto PUT_END;
522 put_12_12: as_s16(dst) = sample; goto PUT_END;
523 put_12_92: as_u16(dst) = sample ^ 0x8000; goto PUT_END;
524 put_12_21: as_s16(dst) = bswap_16(sample); goto PUT_END;
525 put_12_A1: as_u16(dst) = bswap_16(sample ^ 0x80); goto PUT_END;
526 put_0123_0123: as_s24(dst) = sample; goto PUT_END;
527 put_0123_0923: as_u24(dst) = sample ^ 0x800000; goto PUT_END;
528 put_0123_3210: as_s24(dst) = bswap_32(sample); goto PUT_END;
529 put_0123_3290: as_u24(dst) = bswap_32(sample) ^ 0x8000; goto PUT_END;
530 put_1234_1234: as_s32(dst) = sample; goto PUT_END;
531 put_1234_9234: as_u32(dst) = sample ^ 0x80000000; goto PUT_END;
532 put_1234_4321: as_s32(dst) = bswap_32(sample); goto PUT_END;
533 put_1234_4329: as_u32(dst) = bswap_32(sample) ^ 0x80; goto PUT_END;
537 static inline int32_t getS(const void *src, int src_sign, int src_wid, int src_end,
546 s = *(u_int16_t*)src;
552 s = *(u_int32_t*)src;
561 s -= 1U << (src_wid - 1);
562 if (src_wid < dst_wid)
563 return s * (1 << (dst_wid - src_wid));
565 return s / (1 << (src_wid - dst_wid));
568 /* src_sign src_wid src_end dst_wid */
569 static void *gets_labels[2 * 4 * 2 * 4] = {
570 &&gets_u8_8, /* u8h -> s8 */
571 &&gets_u8_16, /* u8h -> s16 */
572 &&gets_u8_24, /* u8h -> s24 */
573 &&gets_u8_32, /* u8h -> s32 */
574 &&gets_u8_8, /* u8s -> s8 */
575 &&gets_u8_16, /* u8s -> s16 */
576 &&gets_u8_24, /* u8s -> s24 */
577 &&gets_u8_32, /* u8s -> s32 */
578 &&gets_u16h_8, /* u16h -> s8 */
579 &&gets_u16h_16, /* u16h -> s16 */
580 &&gets_u16h_24, /* u16h -> s24 */
581 &&gets_u16h_32, /* u16h -> s32 */
582 &&gets_u16s_8, /* u16s -> s8 */
583 &&gets_u16s_16, /* u16s -> s16 */
584 &&gets_u16s_24, /* u16s -> s24 */
585 &&gets_u16s_32, /* u16s -> s32 */
586 &&gets_u24h_8, /* u24h -> s8 */
587 &&gets_u24h_16, /* u24h -> s16 */
588 &&gets_u24h_24, /* u24h -> s24 */
589 &&gets_u24h_32, /* u24h -> s32 */
590 &&gets_u24s_8, /* u24s -> s8 */
591 &&gets_u24s_16, /* u24s -> s16 */
592 &&gets_u24s_24, /* u24s -> s24 */
593 &&gets_u24s_32, /* u24s -> s32 */
594 &&gets_u32h_8, /* u32h -> s8 */
595 &&gets_u32h_16, /* u32h -> s16 */
596 &&gets_u32h_24, /* u32h -> s24 */
597 &&gets_u32h_32, /* u32h -> s32 */
598 &&gets_u32s_8, /* u32s -> s8 */
599 &&gets_u32s_16, /* u32s -> s16 */
600 &&gets_u32s_24, /* u32s -> s24 */
601 &&gets_u32s_32, /* u32s -> s32 */
602 &&gets_s8_8, /* s8h -> s8 */
603 &&gets_s8_16, /* s8h -> s16 */
604 &&gets_s8_24, /* s8h -> s24 */
605 &&gets_s8_32, /* s8h -> s32 */
606 &&gets_s8_8, /* s8s -> s8 */
607 &&gets_s8_16, /* s8s -> s16 */
608 &&gets_s8_24, /* s8s -> s24 */
609 &&gets_s8_32, /* s8s -> s32 */
610 &&gets_s16h_8, /* s16h -> s8 */
611 &&gets_s16h_16, /* s16h -> s16 */
612 &&gets_s16h_24, /* s16h -> s24 */
613 &&gets_s16h_32, /* s16h -> s32 */
614 &&gets_s16s_8, /* s16s -> s8 */
615 &&gets_s16s_16, /* s16s -> s16 */
616 &&gets_s16s_24, /* s16s -> s24 */
617 &&gets_s16s_32, /* s16s -> s32 */
618 &&gets_s24h_8, /* s24h -> s8 */
619 &&gets_s24h_16, /* s24h -> s16 */
620 &&gets_s24h_24, /* s24h -> s24 */
621 &&gets_s24h_32, /* s24h -> s32 */
622 &&gets_s24s_8, /* s24s -> s8 */
623 &&gets_s24s_16, /* s24s -> s16 */
624 &&gets_s24s_24, /* s24s -> s24 */
625 &&gets_s24s_32, /* s24s -> s32 */
626 &&gets_s32h_8, /* s32h -> s8 */
627 &&gets_s32h_16, /* s32h -> s16 */
628 &&gets_s32h_24, /* s32h -> s24 */
629 &&gets_s32h_32, /* s32h -> s32 */
630 &&gets_s32s_8, /* s32s -> s8 */
631 &&gets_s32s_16, /* s32s -> s16 */
632 &&gets_s32s_24, /* s32s -> s24 */
633 &&gets_s32s_32, /* s32s -> s32 */
638 gets_u8_8: sample = getS(src, 0, 8, 0, 8); goto GETS_END;
639 gets_u8_16: sample = getS(src, 0, 8, 0, 16); goto GETS_END;
640 gets_u8_24: sample = getS(src, 0, 8, 0, 24); goto GETS_END;
641 gets_u8_32: sample = getS(src, 0, 8, 0, 32); goto GETS_END;
642 gets_u16h_8: sample = getS(src, 0, 16, 0, 8); goto GETS_END;
643 gets_u16h_16: sample = getS(src, 0, 16, 0, 16); goto GETS_END;
644 gets_u16h_24: sample = getS(src, 0, 16, 0, 24); goto GETS_END;
645 gets_u16h_32: sample = getS(src, 0, 16, 0, 32); goto GETS_END;
646 gets_u16s_8: sample = getS(src, 0, 16, 1, 8); goto GETS_END;
647 gets_u16s_16: sample = getS(src, 0, 16, 1, 16); goto GETS_END;
648 gets_u16s_24: sample = getS(src, 0, 16, 1, 24); goto GETS_END;
649 gets_u16s_32: sample = getS(src, 0, 16, 1, 32); goto GETS_END;
650 gets_u24h_8: sample = getS(src, 0, 24, 0, 8); goto GETS_END;
651 gets_u24h_16: sample = getS(src, 0, 24, 0, 16); goto GETS_END;
652 gets_u24h_24: sample = getS(src, 0, 24, 0, 24); goto GETS_END;
653 gets_u24h_32: sample = getS(src, 0, 24, 0, 32); goto GETS_END;
654 gets_u24s_8: sample = getS(src, 0, 24, 1, 8); goto GETS_END;
655 gets_u24s_16: sample = getS(src, 0, 24, 1, 16); goto GETS_END;
656 gets_u24s_24: sample = getS(src, 0, 24, 1, 24); goto GETS_END;
657 gets_u24s_32: sample = getS(src, 0, 24, 1, 32); goto GETS_END;
658 gets_u32h_8: sample = getS(src, 0, 32, 0, 8); goto GETS_END;
659 gets_u32h_16: sample = getS(src, 0, 32, 0, 16); goto GETS_END;
660 gets_u32h_24: sample = getS(src, 0, 32, 0, 24); goto GETS_END;
661 gets_u32h_32: sample = getS(src, 0, 32, 0, 32); goto GETS_END;
662 gets_u32s_8: sample = getS(src, 0, 32, 1, 8); goto GETS_END;
663 gets_u32s_16: sample = getS(src, 0, 32, 1, 16); goto GETS_END;
664 gets_u32s_24: sample = getS(src, 0, 32, 1, 24); goto GETS_END;
665 gets_u32s_32: sample = getS(src, 0, 32, 1, 32); goto GETS_END;
666 gets_s8_8: sample = getS(src, 1, 8, 0, 8); goto GETS_END;
667 gets_s8_16: sample = getS(src, 1, 8, 0, 16); goto GETS_END;
668 gets_s8_24: sample = getS(src, 1, 8, 0, 24); goto GETS_END;
669 gets_s8_32: sample = getS(src, 1, 8, 0, 32); goto GETS_END;
670 gets_s16h_8: sample = getS(src, 1, 16, 0, 8); goto GETS_END;
671 gets_s16h_16: sample = getS(src, 1, 16, 0, 16); goto GETS_END;
672 gets_s16h_24: sample = getS(src, 1, 16, 0, 24); goto GETS_END;
673 gets_s16h_32: sample = getS(src, 1, 16, 0, 32); goto GETS_END;
674 gets_s16s_8: sample = getS(src, 1, 16, 1, 8); goto GETS_END;
675 gets_s16s_16: sample = getS(src, 1, 16, 1, 16); goto GETS_END;
676 gets_s16s_24: sample = getS(src, 1, 16, 1, 24); goto GETS_END;
677 gets_s16s_32: sample = getS(src, 1, 16, 1, 32); goto GETS_END;
678 gets_s24h_8: sample = getS(src, 1, 24, 0, 8); goto GETS_END;
679 gets_s24h_16: sample = getS(src, 1, 24, 0, 16); goto GETS_END;
680 gets_s24h_24: sample = getS(src, 1, 24, 0, 24); goto GETS_END;
681 gets_s24h_32: sample = getS(src, 1, 24, 0, 32); goto GETS_END;
682 gets_s24s_8: sample = getS(src, 1, 24, 1, 8); goto GETS_END;
683 gets_s24s_16: sample = getS(src, 1, 24, 1, 16); goto GETS_END;
684 gets_s24s_24: sample = getS(src, 1, 24, 1, 24); goto GETS_END;
685 gets_s24s_32: sample = getS(src, 1, 24, 1, 32); goto GETS_END;
686 gets_s32h_8: sample = getS(src, 1, 32, 0, 8); goto GETS_END;
687 gets_s32h_16: sample = getS(src, 1, 32, 0, 16); goto GETS_END;
688 gets_s32h_24: sample = getS(src, 1, 32, 0, 24); goto GETS_END;
689 gets_s32h_32: sample = getS(src, 1, 32, 0, 32); goto GETS_END;
690 gets_s32s_8: sample = getS(src, 1, 32, 1, 8); goto GETS_END;
691 gets_s32s_16: sample = getS(src, 1, 32, 1, 16); goto GETS_END;
692 gets_s32s_24: sample = getS(src, 1, 32, 1, 24); goto GETS_END;
693 gets_s32s_32: sample = getS(src, 1, 32, 1, 32); goto GETS_END;