问题标签 [accelerate-framework]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
751 浏览

objective-c - 并发访问 GCD 中的单个 FFTSetup 数据结构

是否可以创建单个 FFTSetup数据结构并使用它同时执行多个 FFT 计算?会像以下工作吗?

我想答案取决于以下考虑:

1) 是否仅以“只读”方式vDSP_fft_zrip()访问其中的数据(或它指向的数据)?fftSetup或者在执行其 FFT 计算时fftSetup可能会写入一些临时缓冲区(暂存空间)?vDSP_fft_zrip()

2)如果fftSetup 以“只读”方式访问这样的数据,多个进程/线程/任务/块可以同时访问它吗?(我在考虑这样一种情况,即有可能多个进程打开同一个文件进行读取,但不一定用于写入或追加。这个类比合适吗?)

FFTSetup在相关的说明中,数据结构占用了多少内存?有什么办法可以查到吗?(它是一种不透明的数据类型。)

0 投票
3 回答
1297 浏览

ios - 如何使用加速框架(vImage)缩放灰度图像

嗨,我需要快速缩放灰度图像,所以我尝试了 vImage 并且应用程序崩溃了,请帮忙。在下面的代码中 srcimg.data/dstimg.data 是指向无符号字符图像数据的点(仅单通道灰度数据)。

0 投票
2 回答
1631 浏览

ios - 在 iOS 上如何快速将 RGB24 转换为 BGR24?

我使用vImageConvert_RGB888toPlanar8and vImageConvert_Planar8toRGB888from Accelerate.framework将RGB24转换为BGR24,但是当需要转换的数据非常大时,比如3M或4M,这需要花费的时间大约是10ms。所以有人知道一些足够快的想法吗?我的代码是这样的:

0 投票
1 回答
635 浏览

ios - 为什么从加速框架计算的特征向量符号不同?

嗨,以下 9x9 输入矩阵

来自 dsyevd_ (lapack) 的特征向量是

来自opencv的特征向量

这些值的位置不同,符号也不同。我如何在 lapack 中解决这个问题。

0 投票
5 回答
801 浏览

arrays - Why does order of array declaration affect performance so much?

First, in tuning a frequency analysis function using the Accelerate framework, the absolute system time has consistently been 225ms per iteration. Then last night I changed the order of which two of the arrays were declared and suddenly it went down to 202ms. A 10% increase by just changing the declaration order seems insane. Can someone explain to me why the compiler (which is set to optimize) is not already finding this solution?

Additional info: Before the loop there is some setup of the arrays used in the loop consisting of converting them from integer to float arrays (for Accelerate) and then taking sin and cos of the time array (16 lines long). All of the float arrays (8 arrays x 1000 elements) are declared first in the function (after a sanity check of the parameters). They are always declared the same size (by a constant), because otherwise performance suffered for little shrinkage of the footprint. I tested making them globals, but I think the compiler already figured that out as there is no performance change. The loop is 25 lines long.

---Additions---

Yes, "-Os" is the flag. (default in Xcode anyways: Fastest, Smallest)

(below is from memory - don't try to compile it, cause I didn't put in things like stride (which is 1), etc. However, all of the Accelerate calls are there)

passed parameters: inttimearray, intamparray, length, scale1, scale2, amp

---Current Solution---

I've made some changes as follows:

The arrays are all declared aligned, and zero'd out (I'll explain next) and maxsize is now a multiple of 16

I've zero'd out all of the arrays because now, when the length is less than maxsize, I round the length up to the nearest multiple of 16 so that all of the looped functions operate on widths divisible by 16, without affecting the sums.

The benefits are:

  • Slight performance boost
  • The speed is nearly constant regardless of order of array declaration (which is now done right before they are needed, instead of all in a big block)
  • The speed is also nearly constant for any 16-wide length (i.e. 241 to 256, or 225 to 240...), whereas before, if the length went from 256 to 255, the function would take a 3+% performance hit.

In the future (possibly with this code, as analysis requirements are still in flux), I realize I'll need to take into consideration stack usage more, and alignment/chunks of vectors. Unfortunately, for this code, I can't make these arrays static or globals as this function can be called by more than one object at a time.

0 投票
4 回答
581 浏览

ios - iOS Cocoa Touch vImage 二次采样

我正在使用 Cocoa Touch 中的 vImages,在我的情况下,它基本上是 ARGB-float-Arrays,我需要进行二次采样。使用 vImage 函数进行低通滤波没有问题,但我如何选择一个 2x2 像素(假设我想按因子 2 进行二次采样)?当然我可以使用 vDSP stride 函数,但这仅适用于水平子采样,而不适用于垂直子采样。

我希望以下内容能阐明我打算做什么。我希望选择所有标有 X 的像素,如下图所示:

但由于内存是线性的,我的数组看起来像这样:

如何以合理的方式执行子采样?

编辑:我正在寻找一种有效的方法来对存储为一维浮点数组(包括负值)的给定位图进行二维下采样。

0 投票
2 回答
1717 浏览

matlab - 非对数基数的 Matlab FFT(快速傅里叶变换)函数

我有一个正在开发的应用程序,它利用了Apple 的 Accelerate Framework FFT 函数,我试图让它模仿Matlab 的 FFT 函数的功能。我将当前代码设置为输出方式与我在 matlab 中的输出方式完全相同。唯一不输出相同的情况是数据数组中的元素数量!= 以 2 为底的对数(FFT 技术上必需的)。我想知道是否有人知道 Matlab 函数是如何处理这种情况的。如果我使用苹果代码来做,它会产生不同的结果。

注意:我不是简单地调用 fft(x)。我也 FFT 移位并取绝对值并将其平方。我也在苹果代码中反映了这些,因为它们不受 FFT 的直接影响。他们在事后被调用。

示例 1 - 16 个元素(对数基数 2): 类似的输出

Matlab调用:

*由于篇幅原因省略了苹果代码

苹果输出:

示例 2 - 10 个元素(非对数基数 2):不同的输出

Matlab调用:

*由于篇幅原因省略了苹果代码

苹果输出:

如您所见,它们在第一个示例和第二个示例中显然产生了相同的输出。我已经用正负输入进行了测试,唯一不同的是它们不是对数基数 2。有谁知道 Matlab 如何处理这个问题?也许它用 0 填充数组,直到它的对数基数为 2,然后对某些点进行平均?我做了很多搜索,无法弄清楚在这种特殊情况下他们做了什么来获得他们的输出。

0 投票
1 回答
543 浏览

objective-c - 是否可以将结果存储在 vDSP 框架中的输入向量之一中

在 Accelerate Framework 的 vDSP 函数中,所有函数都需要您输入结果向量。如果我不再需要原始输入向量中的任何内容,将输入向量(或输入向量之一)作为结果向量传递是否正确?

我的意思的例子:

这将采用 input_vector 并将 scalar_addition 添加到所有元素。结果将存储在 input_vector 中。

0 投票
1 回答
284 浏览

ios - 苹果加速框架——约束幅度而不损失绝对值

我想使用苹果的加速来有效地剪辑音频信号。如果信号大于1或小于-1,我想让它等于1或-1。vDSP_vmaxmg看起来这几乎就是我要找的东西,但不完全是。文档说它这样做:

输出向量 C 的每个元素是来自输入向量 A 和 B 的对应值的幅值中较大的一个。

所以看起来输出vDSP_vmaxmg总是输入的绝对值,总是正的。如果我想保留信号输出的绝对值但限制幅度,加速框架可以帮助我吗?

0 投票
1 回答
1739 浏览

ios - 带有浮点缓冲区 AudioUnit 的 FFT 输出

我对 vDSP_zrip 和 AudioUnit 的使用和配置有疑问。事实上,我将 AudioUnit 配置为将打包数据保存为浮点数。我创建了一个循环缓冲区,当这个缓冲区已满时,我计算一个 fft。我有结果,但我不明白为什么 fft 输出不好(参见图)

音频单元配置:

循环缓冲区:

vDSP 调用:

在哪里_fftsize = _audioSample.capacity()/2

数字