如何在 Neon 中将 uint32x4_t 转换为 uint8x16_t?
How to convert uint32x4_t to uint8x16_t in Neon?
那我的意思是我要把每个32位的unsigned int拆分成4个8位的。对应位不变。
如果 uint32x4_t
是:
01000101001111100000001000010000 | 01000101001111100000001000010000 | 01000101001111100000001000010000 | 01000101001111100000001000010000
我想得到:
01000101 | 00111110 | 00000010 | 00010000 | 01000101 | 00111110 | 00000010 | 00010000 | 01000101 | 00111110 | 00000010 | 00010000 | 01000101 | 00111110 | 00000010 | 00010000 |
我该怎么做?
与vreinterpretq_u8_u32
。原型为:
uint8x16_t vreinterpretq_u8_u32 (uint32x4_t a);
编辑:正如@EOF 在下面的评论中指出的那样,您可能也需要字节序交换 (vrev32q_u8
)。 GCC 和 clang 定义 __BYTE_ORDER__
(小端为 __ORDER_LITTLE_ENDIAN__
,大端为 __ORDER_BIG_ENDIAN__
),或者如果您需要更便携的东西,请参见 https://github.com/nemequ/portable-snippets/tree/master/endian
那我的意思是我要把每个32位的unsigned int拆分成4个8位的。对应位不变。
如果 uint32x4_t
是:
01000101001111100000001000010000 | 01000101001111100000001000010000 | 01000101001111100000001000010000 | 01000101001111100000001000010000
我想得到:
01000101 | 00111110 | 00000010 | 00010000 | 01000101 | 00111110 | 00000010 | 00010000 | 01000101 | 00111110 | 00000010 | 00010000 | 01000101 | 00111110 | 00000010 | 00010000 |
我该怎么做?
与vreinterpretq_u8_u32
。原型为:
uint8x16_t vreinterpretq_u8_u32 (uint32x4_t a);
编辑:正如@EOF 在下面的评论中指出的那样,您可能也需要字节序交换 (vrev32q_u8
)。 GCC 和 clang 定义 __BYTE_ORDER__
(小端为 __ORDER_LITTLE_ENDIAN__
,大端为 __ORDER_BIG_ENDIAN__
),或者如果您需要更便携的东西,请参见 https://github.com/nemequ/portable-snippets/tree/master/endian