How to convert unsigned char to signed integer using Neon SIMD

北城余情 提交于 2019-12-04 13:00:31

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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!