如何使用霓虹灯SIMD无符号字符转换为符号整数 [英] How to convert unsigned char to signed integer using Neon SIMD
本文介绍了如何使用霓虹灯SIMD无符号字符转换为符号整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用霓虹灯数据类型 uint8_t有
的变量转换为 int32_t
?我找不到任何内在这样做的。
How to convert a variable of data type uint8_t
to int32_t
using Neon? I could not find any intrinsic for doing this.
推荐答案
假设你想要的16×8位整数向量转换为4×32位整数四个矢量,你可以先拆包到16位做到这一点然后再次以32位:
Assuming you want to convert a vector of 16 x 8 bit ints to four vectors of 4 x 32 bit ints, you can do this by first unpacking to 16 bits and then again to 32 bits:
// load 8 bit vector
uint8x16_t v = vld1q_u8(p); // load vector of 16 x 8 bits ints from p
// unpack to 16 bits
int16x8_t vl = vreinterpretq_s16_u16(vmovl_u8(vget_low_u8(v))); // 0..7
int16x8_t vh = vreinterpretq_s16_u16(vmovl_u8(vget_high_u8(v))); // 8..15
// unpack to 32 bits
int32x4_t vll = vmovl_s16(vget_low_s16(vl)); // 0..3
int32x4_t vlh = vmovl_s16(vget_high_s16(vl)); // 4..7
int32x4_t vhl = vmovl_s16(vget_low_s16(vh)); // 8..11
int32x4_t vhh = vmovl_s16(vget_high_s16(vh)); // 12..15
这篇关于如何使用霓虹灯SIMD无符号字符转换为符号整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文