1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514 | diff -urN uhd-3.7.3/host/lib/convert/CMakeLists.txt uhd-3.8.5/host/lib/convert/CMakeLists.txt
--- uhd-3.7.3/host/lib/convert/CMakeLists.txt 2014-10-06 01:21:14.000000000 -0600
+++ uhd-3.8.5/host/lib/convert/CMakeLists.txt 2015-07-21 11:38:58.000000000 -0600
@@ -70,6 +70,7 @@
IF(HAVE_EMMINTRIN_H)
SET(convert_with_sse2_sources
+ ${CMAKE_CURRENT_SOURCE_DIR}/sse2_sc16_to_sc16.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sse2_sc16_to_fc64.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sse2_sc16_to_fc32.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sse2_sc8_to_fc64.cpp
@@ -94,8 +95,11 @@
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
IF(HAVE_ARM_NEON_H)
+ ENABLE_LANGUAGE(ASM)
+
LIBUHD_APPEND_SOURCES(
${CMAKE_CURRENT_SOURCE_DIR}/convert_with_neon.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/convert_neon.S
)
ENDIF()
diff -urN uhd-3.7.3/host/lib/convert/convert_common.hpp uhd-3.8.5/host/lib/convert/convert_common.hpp
--- uhd-3.7.3/host/lib/convert/convert_common.hpp 2014-10-06 01:21:14.000000000 -0600
+++ uhd-3.8.5/host/lib/convert/convert_common.hpp 2015-07-21 11:38:58.000000000 -0600
@@ -42,6 +42,19 @@
const input_type &inputs, const output_type &outputs, const size_t nsamps \
)
+/*! Convenience macro to declare a single-function converter
+ *
+ * Most converters consist of a single for loop, and can make use of
+ * this macro for declaration and registering.
+ *
+ * Following this macro should be a function block in curly braces
+ * which runs the conversion. Available parameters in this function block
+ * are:
+ * - `inputs`: Vector of pointers to the input data. Size of the vector == `num_in`
+ * - `outputs`: Vector of pointers to where the output data goes. Size of the vector == `num_out`
+ * - `nsamps`: Number of items per input buffer to convert
+ * - `scale_factor`: Scaling factor for float conversions
+ */
#define DECLARE_CONVERTER(in_form, num_in, out_form, num_out, prio) \
_DECLARE_CONVERTER(__convert_##in_form##_##num_in##_##out_form##_##num_out##_##prio, in_form, num_in, out_form, num_out, prio)
diff -urN uhd-3.7.3/host/lib/convert/convert_impl.cpp uhd-3.8.5/host/lib/convert/convert_impl.cpp
--- uhd-3.7.3/host/lib/convert/convert_impl.cpp 2014-10-06 01:21:14.000000000 -0600
+++ uhd-3.8.5/host/lib/convert/convert_impl.cpp 2015-07-21 11:38:58.000000000 -0600
@@ -27,6 +27,10 @@
using namespace uhd;
+convert::converter::~converter(void){
+ /* NOP */
+}
+
bool convert::operator==(const convert::id_type &lhs, const convert::id_type &rhs){
return true
and (lhs.input_format == rhs.input_format)
diff -urN uhd-3.7.3/host/lib/convert/convert_neon.S uhd-3.8.5/host/lib/convert/convert_neon.S
--- uhd-3.7.3/host/lib/convert/convert_neon.S 1969-12-31 17:00:00.000000000 -0700
+++ uhd-3.8.5/host/lib/convert/convert_neon.S 2015-07-21 11:38:58.000000000 -0600
@@ -0,0 +1,37 @@
+//
+// Copyright 2014 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+ .arch armv7-a
+ .fpu neon
+ .syntax unified
+ .text
+ .align 2
+ .global neon_item32_sc16_swap_16n
+ .type neon_item32_sc16_swap_16n, %function
+neon_item32_sc16_swap_16n:
+.loop_swap:
+ vld2.16 {q0, q1}, [r0]!
+ vld2.16 {q2, q3}, [r0]!
+ vswp q0, q1
+ vswp q2, q3
+ vst2.16 {q0, q1}, [r1]!
+ vst2.16 {q2, q3}, [r1]!
+ subs r2, #1
+ bne .loop_swap
+ bx lr
+ .size neon_item32_sc16_swap_16n, .-neon_item32_sc16_swap_16n
+ .section .note.GNU-stack,"",%progbits
diff -urN uhd-3.7.3/host/lib/convert/convert_pack_sc12.cpp uhd-3.8.5/host/lib/convert/convert_pack_sc12.cpp
--- uhd-3.7.3/host/lib/convert/convert_pack_sc12.cpp 2014-10-06 01:21:14.000000000 -0600
+++ uhd-3.8.5/host/lib/convert/convert_pack_sc12.cpp 2015-07-21 11:38:58.000000000 -0600
@@ -32,6 +32,28 @@
item32_t line2;
};
+enum item32_sc12_3x_enable {
+ CONVERT12_LINE0 = 0x01,
+ CONVERT12_LINE1 = 0x02,
+ CONVERT12_LINE2 = 0x04,
+ CONVERT12_LINE_ALL = 0x07,
+};
+
+/*
+ * Packed 12-bit converter with selective line enable
+ *
+ * The converter operates on 4 complex inputs and selectively writes to one to
+ * three 32-bit lines. Line selection allows for partial writes of less than
+ * 4 complex samples, or a full 3 x 32-bit struct. Writes are always full 32-bit
+ * lines, so in the case of partial writes, the number of bytes written will
+ * exceed the the number of bytes filled by actual samples.
+ *
+ * _ _ _ _ _ _ _ _
+ * |_ _ _1_ _ _|_ _| 0
+ * |_2_ _ _|_ _ _3_|
+ * |_ _|_ _ _4_ _ _| 2
+ * 31 0
+ */
template <typename type, towire32_type towire>
void convert_star_4_to_sc12_item32_3
(
@@ -39,6 +61,7 @@
const std::complex<type> &in1,
const std::complex<type> &in2,
const std::complex<type> &in3,
+ const int enable,
item32_sc12_3x &output,
const double scalar
)
@@ -59,9 +82,12 @@
const item32_t line1 = (i1 << 28) | (q1 << 16) | (i2 << 4) | (q2 >> 8);
const item32_t line2 = (q2 << 24) | (i3 << 12) | (q3);
- output.line0 = towire(line0);
- output.line1 = towire(line1);
- output.line2 = towire(line2);
+ if (enable & CONVERT12_LINE0)
+ output.line0 = towire(line0);
+ if (enable & CONVERT12_LINE1)
+ output.line1 = towire(line1);
+ if (enable & CONVERT12_LINE2)
+ output.line2 = towire(line2);
}
template <typename type, towire32_type towire>
@@ -85,7 +111,8 @@
* Effectively outputs will point to a managed_buffer instance. These buffers are 32 bit aligned.
* For a detailed description see comments in 'convert_unpack_sc12.cpp'.
*/
- const size_t head_samps = size_t(inputs[0]) & 0x3;
+ const size_t head_samps = size_t(outputs[0]) & 0x3;
+ int enable;
size_t rewind = 0;
switch(head_samps)
{
@@ -102,17 +129,27 @@
//handle the head case
switch (head_samps)
{
- case 0: break; //no head
- case 1: convert_star_4_to_sc12_item32_3<type, towire>(0, 0, 0, input[0], output[o++], _scalar); break;
- case 2: convert_star_4_to_sc12_item32_3<type, towire>(0, 0, input[0], input[1], output[o++], _scalar); break;
- case 3: convert_star_4_to_sc12_item32_3<type, towire>(0, input[0], input[1], input[2], output[o++], _scalar); break;
+ case 0:
+ break; //no head
+ case 1:
+ enable = CONVERT12_LINE2;
+ convert_star_4_to_sc12_item32_3<type, towire>(0, 0, 0, input[0], enable, output[o++], _scalar);
+ break;
+ case 2:
+ enable = CONVERT12_LINE2 | CONVERT12_LINE1;
+ convert_star_4_to_sc12_item32_3<type, towire>(0, 0, input[0], input[1], enable, output[o++], _scalar);
+ break;
+ case 3:
+ enable = CONVERT12_LINE2 | CONVERT12_LINE1 | CONVERT12_LINE0;
+ convert_star_4_to_sc12_item32_3<type, towire>(0, input[0], input[1], input[2], enable, output[o++], _scalar);
+ break;
}
i += head_samps;
//convert the body
while (i+3 < nsamps)
{
- convert_star_4_to_sc12_item32_3<type, towire>(input[i+0], input[i+1], input[i+2], input[i+3], output[o], _scalar);
+ convert_star_4_to_sc12_item32_3<type, towire>(input[i+0], input[i+1], input[i+2], input[i+3], CONVERT12_LINE_ALL, output[o], _scalar);
o++; i += 4;
}
@@ -120,10 +157,20 @@
const size_t tail_samps = nsamps - i;
switch (tail_samps)
{
- case 0: break; //no tail
- case 1: convert_star_4_to_sc12_item32_3<type, towire>(input[i+0], 0, 0, 0, output[o], _scalar); break;
- case 2: convert_star_4_to_sc12_item32_3<type, towire>(input[i+0], input[i+1], 0, 0, output[o], _scalar); break;
- case 3: convert_star_4_to_sc12_item32_3<type, towire>(input[i+0], input[i+1], input[i+2], 0, output[o], _scalar); break;
+ case 0:
+ break; //no tail
+ case 1:
+ enable = CONVERT12_LINE0;
+ convert_star_4_to_sc12_item32_3<type, towire>(input[i+0], 0, 0, 0, enable, output[o], _scalar);
+ break;
+ case 2:
+ enable = CONVERT12_LINE0 | CONVERT12_LINE1;
+ convert_star_4_to_sc12_item32_3<type, towire>(input[i+0], input[i+1], 0, 0, enable, output[o], _scalar);
+ break;
+ case 3:
+ enable = CONVERT12_LINE0 | CONVERT12_LINE1 | CONVERT12_LINE2;
+ convert_star_4_to_sc12_item32_3<type, towire>(input[i+0], input[i+1], input[i+2], 0, enable, output[o], _scalar);
+ break;
}
}
diff -urN uhd-3.7.3/host/lib/convert/convert_unpack_sc12.cpp uhd-3.8.5/host/lib/convert/convert_unpack_sc12.cpp
--- uhd-3.7.3/host/lib/convert/convert_unpack_sc12.cpp 2014-10-06 01:21:14.000000000 -0600
+++ uhd-3.8.5/host/lib/convert/convert_unpack_sc12.cpp 2015-07-21 11:38:58.000000000 -0600
@@ -62,17 +62,17 @@
const boost::uint64_t line12 = (boost::uint64_t(line1) << 32) | line2;
//step 1: shift out and mask off the individual numbers
- const type i0 = type(boost::int16_t(line0 >> 16)*scalar);
- const type q0 = type(boost::int16_t(line0 >> 4)*scalar);
+ const type i0 = type(boost::int16_t((line0 >> 16) & 0xfff0)*scalar);
+ const type q0 = type(boost::int16_t((line0 >> 4) & 0xfff0)*scalar);
- const type i1 = type(boost::int16_t(line01 >> 24)*scalar);
- const type q1 = type(boost::int16_t(line1 >> 12)*scalar);
+ const type i1 = type(boost::int16_t((line01 >> 24) & 0xfff0)*scalar);
+ const type q1 = type(boost::int16_t((line1 >> 12) & 0xfff0)*scalar);
- const type i2 = type(boost::int16_t(line1 >> 0)*scalar);
- const type q2 = type(boost::int16_t(line12 >> 20)*scalar);
+ const type i2 = type(boost::int16_t((line1 >> 0) & 0xfff0)*scalar);
+ const type q2 = type(boost::int16_t((line12 >> 20) & 0xfff0)*scalar);
- const type i3 = type(boost::int16_t(line2 >> 8)*scalar);
- const type q3 = type(boost::int16_t(line2 << 4)*scalar);
+ const type i3 = type(boost::int16_t((line2 >> 8) & 0xfff0)*scalar);
+ const type q3 = type(boost::int16_t((line2 << 4) & 0xfff0)*scalar);
//step 2: load the outputs
out0 = std::complex<type>(i0, q0);
diff -urN uhd-3.7.3/host/lib/convert/convert_with_neon.cpp uhd-3.8.5/host/lib/convert/convert_with_neon.cpp
--- uhd-3.7.3/host/lib/convert/convert_with_neon.cpp 2014-10-06 01:21:14.000000000 -0600
+++ uhd-3.8.5/host/lib/convert/convert_with_neon.cpp 2015-07-21 11:38:58.000000000 -0600
@@ -1,5 +1,5 @@
//
-// Copyright 2011-2012 Ettus Research LLC
+// Copyright 2011-2014 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -19,6 +19,12 @@
#include <uhd/utils/byteswap.hpp>
#include <arm_neon.h>
+extern "C" {
+void neon_item32_sc16_swap_16n(void *, void *, int iter);
+}
+
+static const int SIMD_WIDTH = 16;
+
using namespace uhd::convert;
DECLARE_CONVERTER(fc32, 1, sc16_item32_le, 1, PRIORITY_SIMD){
@@ -58,3 +64,31 @@
item32_sc16_to_xx<uhd::htowx>(input+i, output+i, nsamps-i, scale_factor);
}
+
+DECLARE_CONVERTER(sc16, 1, sc16_item32_le, 1, PRIORITY_SIMD){
+ const sc16_t *input = reinterpret_cast<const sc16_t *>(inputs[0]);
+ item32_t *output = reinterpret_cast<item32_t *>(outputs[0]);
+
+ size_t i = nsamps / SIMD_WIDTH;
+
+ if (i)
+ neon_item32_sc16_swap_16n((void *) input, (void *) output, i);
+
+ i *= SIMD_WIDTH;
+
+ xx_to_item32_sc16<uhd::htowx>(input+i, output+i, nsamps-i, scale_factor);
+}
+
+DECLARE_CONVERTER(sc16_item32_le, 1, sc16, 1, PRIORITY_SIMD){
+ const item32_t *input = reinterpret_cast<const item32_t *>(inputs[0]);
+ sc16_t *output = reinterpret_cast<sc16_t *>(outputs[0]);
+
+ size_t i = nsamps / SIMD_WIDTH;
+
+ if (i)
+ neon_item32_sc16_swap_16n((void *) input, (void *) output, i);
+
+ i *= SIMD_WIDTH;
+
+ item32_sc16_to_xx<uhd::wtohx>(input+i, output+i, nsamps-i, scale_factor);
+}
diff -urN uhd-3.7.3/host/lib/convert/sse2_sc16_to_sc16.cpp uhd-3.8.5/host/lib/convert/sse2_sc16_to_sc16.cpp
--- uhd-3.7.3/host/lib/convert/sse2_sc16_to_sc16.cpp 1969-12-31 17:00:00.000000000 -0700
+++ uhd-3.8.5/host/lib/convert/sse2_sc16_to_sc16.cpp 2015-07-21 11:38:58.000000000 -0600
@@ -0,0 +1,201 @@
+//
+// Copyright 2015 Ettus Research LLC
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+//
+
+#include "convert_common.hpp"
+#include <uhd/utils/byteswap.hpp>
+#include <emmintrin.h>
+
+using namespace uhd::convert;
+
+//
+// SSE 16-bit pair swap
+//
+// Valid alignment macro arguments are 'u_' and '_' for unaligned and aligned
+// access respectively. Macro operates on 4 complex 16-bit integers at a time.
+//
+// -----------------
+// | A | B | C | D | Input
+// -----------------
+// 0 1 2 3 Address
+// -----------------
+// | C | D | A | B | Output
+// -----------------
+//
+#define CONVERT_SC16_1_TO_SC16_1_NSWAP_GUTS(_ialign_,_oalign_) \
+ for (; i+3 < nsamps; i+=4) { \
+ __m128i m0; \
+ \
+ /* load from input */ \
+ m0 = _mm_load ## _ialign_ ## si128((const __m128i *) (input+i));\
+ \
+ /* swap 16-bit pairs */ \
+ m0 = _mm_shufflelo_epi16(m0, _MM_SHUFFLE(2, 3, 0, 1)); \
+ m0 = _mm_shufflehi_epi16(m0, _MM_SHUFFLE(2, 3, 0, 1)); \
+ \
+ /* store to output */ \
+ _mm_store ## _oalign_ ## si128((__m128i *) (output+i), m0); \
+ } \
+
+//
+// SSE byte swap
+//
+// Valid alignment macro arguments are 'u_' and '_' for unaligned and aligned
+// access respectively. Macro operates on 4 complex 16-bit integers at a time.
+//
+// -----------------
+// | A | B | C | D | Input
+// -----------------
+// 0 1 2 3 Address
+// -----------------
+// | B | A | D | C | Output
+// -----------------
+//
+#define CONVERT_SC16_1_TO_SC16_1_BSWAP_GUTS(_ialign_,_oalign_) \
+ for (; i+3 < nsamps; i+=4) { \
+ __m128i m0, m1, m2; \
+ \
+ /* load from input */ \
+ m0 = _mm_load ## _ialign_ ## si128((const __m128i *) (input+i));\
+ \
+ /* byteswap 16 bit words */ \
+ m1 = _mm_srli_epi16(m0, 8); \
+ m2 = _mm_slli_epi16(m0, 8); \
+ m0 = _mm_or_si128(m1, m2); \
+ \
+ /* store to output */ \
+ _mm_store ## _oalign_ ## si128((__m128i *) (output+i), m0); \
+ } \
+
+DECLARE_CONVERTER(sc16, 1, sc16_item32_le, 1, PRIORITY_SIMD){
+ const sc16_t *input = reinterpret_cast<const sc16_t *>(inputs[0]);
+ item32_t *output = reinterpret_cast<item32_t *>(outputs[0]);
+
+ size_t i = 0;
+
+ // need to dispatch according to alignment for fastest conversion
+ switch (size_t(input) & 0xf){
+ case 0x0:
+ // the data is 16-byte aligned, so do the fast processing of the bulk of the samples
+ CONVERT_SC16_1_TO_SC16_1_NSWAP_GUTS(_,u_)
+ break;
+ case 0x8:
+ if (nsamps < 2)
+ break;
+ // the first sample is 8-byte aligned - process it to align the remainder of the samples to 16-bytes
+ xx_to_item32_sc16<uhd::htowx>(input, output, 2, 1.0);
+ i += 2;
+ CONVERT_SC16_1_TO_SC16_1_NSWAP_GUTS(_,u_)
+ // do faster processing of the bulk of the samples now that we are 16-byte aligned
+ break;
+ default:
+ // we are not 8 or 16-byte aligned, so do fast processing with the unaligned load
+ CONVERT_SC16_1_TO_SC16_1_NSWAP_GUTS(u_,u_)
+ }
+
+ // convert any remaining samples
+ xx_to_item32_sc16<uhd::htowx>(input+i, output+i, nsamps-i, 1.0);
+}
+
+DECLARE_CONVERTER(sc16, 1, sc16_item32_be, 1, PRIORITY_SIMD){
+ const sc16_t *input = reinterpret_cast<const sc16_t *>(inputs[0]);
+ item32_t *output = reinterpret_cast<item32_t *>(outputs[0]);
+
+ size_t i = 0;
+
+ // need to dispatch according to alignment for fastest conversion
+ switch (size_t(input) & 0xf){
+ case 0x0:
+ // the data is 16-byte aligned, so do the fast processing of the bulk of the samples
+ CONVERT_SC16_1_TO_SC16_1_BSWAP_GUTS(_,u_)
+ break;
+ case 0x8:
+ if (nsamps < 2)
+ break;
+ // the first value is 8-byte aligned - process it and prepare the bulk of the data for fast conversion
+ xx_to_item32_sc16<uhd::htonx>(input, output, 2, 1.0);
+ i += 2;
+ // do faster processing of the remaining samples now that we are 16-byte aligned
+ CONVERT_SC16_1_TO_SC16_1_BSWAP_GUTS(_,u_)
+ break;
+ default:
+ // we are not 8 or 16-byte aligned, so do fast processing with the unaligned load
+ CONVERT_SC16_1_TO_SC16_1_BSWAP_GUTS(u_,u_)
+ }
+
+ // convert any remaining samples
+ xx_to_item32_sc16<uhd::htonx>(input+i, output+i, nsamps-i, 1.0);
+}
+
+DECLARE_CONVERTER(sc16_item32_le, 1, sc16, 1, PRIORITY_SIMD){
+ const item32_t *input = reinterpret_cast<const item32_t *>(inputs[0]);
+ sc16_t *output = reinterpret_cast<sc16_t *>(outputs[0]);
+
+ size_t i = 0;
+
+ // need to dispatch according to alignment for fastest conversion
+ switch (size_t(output) & 0xf){
+ case 0x0:
+ // the data is 16-byte aligned, so do the fast processing of the bulk of the samples
+ CONVERT_SC16_1_TO_SC16_1_NSWAP_GUTS(u_,_)
+ break;
+ case 0x8:
+ if (nsamps < 2)
+ break;
+ // the first sample is 8-byte aligned - process it to align the remainder of the samples to 16-bytes
+ item32_sc16_to_xx<uhd::htowx>(input, output, 2, 1.0);
+ i += 2;
+ // do faster processing of the bulk of the samples now that we are 16-byte aligned
+ CONVERT_SC16_1_TO_SC16_1_NSWAP_GUTS(u_,_)
+ break;
+ default:
+ // we are not 8 or 16-byte aligned, so do fast processing with the unaligned load and store
+ CONVERT_SC16_1_TO_SC16_1_NSWAP_GUTS(u_,u_)
+ }
+
+ // convert any remaining samples
+ item32_sc16_to_xx<uhd::htowx>(input+i, output+i, nsamps-i, 1.0);
+}
+
+DECLARE_CONVERTER(sc16_item32_be, 1, sc16, 1, PRIORITY_SIMD){
+ const item32_t *input = reinterpret_cast<const item32_t *>(inputs[0]);
+ sc16_t *output = reinterpret_cast<sc16_t *>(outputs[0]);
+
+ size_t i = 0;
+
+ // need to dispatch according to alignment for fastest conversion
+ switch (size_t(output) & 0xf){
+ case 0x0:
+ // the data is 16-byte aligned, so do the fast processing of the bulk of the samples
+ CONVERT_SC16_1_TO_SC16_1_BSWAP_GUTS(u_,_)
+ break;
+ case 0x8:
+ if (nsamps < 2)
+ break;
+ // the first sample is 8-byte aligned - process it to align the remainder of the samples to 16-bytes
+ item32_sc16_to_xx<uhd::htonx>(input, output, 2, 1.0);
+ i += 2;
+ // do faster processing of the bulk of the samples now that we are 16-byte aligned
+ CONVERT_SC16_1_TO_SC16_1_BSWAP_GUTS(u_,_)
+ break;
+ default:
+ // we are not 8 or 16-byte aligned, so do fast processing with the unaligned load and store
+ CONVERT_SC16_1_TO_SC16_1_BSWAP_GUTS(u_,u_)
+ }
+
+ // convert any remaining samples
+ item32_sc16_to_xx<uhd::htonx>(input+i, output+i, nsamps-i, 1.0);
+}
|