将 8bit uint8_t 加载为 uint32_t? [英] Load 8bit uint8_t as uint32_t?

查看:45
本文介绍了将 8bit uint8_t 加载为 uint32_t?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的图像处理项目使用灰度图像.我有 ARM Cortex-A8 处理器平台.我想使用NEON.

my image processing project works with grayscale images. I have ARM Cortex-A8 processor platform. I want to make use of the NEON.

我有一个灰度图像(考虑下面的示例),在我的算法中,我只需要添加列.

I have a grayscale image( consider the example below) and in my alogorithm, I have to add only the columns.

如何并行加载 四个 8 位像素值,它们是 uint8_t,作为 四个 uint32_t 到 128- 之一位 NEON 寄存器?我必须使用什么内在函数来做到这一点?

How can I load four 8-bit pixel values in parallel, which are uint8_t, as four uint32_t into one of the 128-bit NEON registers? What intrinsic do I have to use to do this?

我的意思是:

我必须将它们加载为 32 位,因为如果你仔细观察,我执行 255 + 255 的那一刻是 512,它不能保存在 8 位寄存器中.

I must load them as 32 bits because if you look carefully, the moment I do 255 + 255 is 512, which can't be held in a 8-bit register.

例如

255 255 255 255 ......... (640 pixels)
255 255 255 255
255 255 255 255
255 255 255 255
.
.
.
.
.
(480 pixels) 

推荐答案

我建议你花一点时间了解 SIMD 在 ARM 上的工作原理.看:

I will recommend that you spend a bit of time understanding how SIMD works on ARM. Look at:

看看:

  1. http://blogs.arm.com/software-enablement/161-coding-for-neon-part-1-load-and-stores/
  2. http://blogs.arm.com/software-enablement/196-coding-for-neon-part-2-dealing-with-leftovers/
  3. http://blogs.arm.com/software-enablement/241-coding-for-neon-part-3-matrix-multiplication/
  4. http://blogs.arm.com/software-enablement/277-coding-for-neon-part-4-shifting-left-and-right/

让你开始.然后,您可以使用内联汇编程序或 domen 推荐的相应 ARM 内部函数来实现您的 SIMD 代码.

to get you started. You can then implement your SIMD code using inline assembler or corresponding ARM intrinsics recommended by domen.

这篇关于将 8bit uint8_t 加载为 uint32_t?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆