Slight performance improvement on detailed fft

This commit is contained in:
Ryzerth 2021-04-13 03:52:30 +02:00
parent cb8bbd7ccc
commit 58864b79e4

View File

@ -4,6 +4,7 @@
#include <GL/glew.h> #include <GL/glew.h>
#include <imutils.h> #include <imutils.h>
#include <algorithm> #include <algorithm>
#include <volk/volk.h>
#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>
@ -23,7 +24,7 @@ float DEFAULT_COLOR_MAP[][3] = {
{0x4A, 0x00, 0x00} {0x4A, 0x00, 0x00}
}; };
void doZoom(int offset, int width, int outWidth, float* data, float* out, bool fast) { inline void doZoom(int offset, int width, int outWidth, float* data, float* out, bool fast) {
// NOTE: REMOVE THAT SHIT, IT'S JUST A HACKY FIX // NOTE: REMOVE THAT SHIT, IT'S JUST A HACKY FIX
if (offset < 0) { if (offset < 0) {
offset = 0; offset = 0;
@ -38,19 +39,20 @@ void doZoom(int offset, int width, int outWidth, float* data, float* out, bool f
for (int i = 0; i < outWidth; i++) { for (int i = 0; i < outWidth; i++) {
out[i] = data[(int)(offset + ((float)i * factor))]; out[i] = data[(int)(offset + ((float)i * factor))];
} }
return;
} }
else {
float id = offset; float sFactor = ceilf(factor);
float val, maxVal; float id = offset;
float next; float val, maxVal;
for (int i = 0; i < outWidth; i++) { uint32_t maxId;
maxVal = -INFINITY; for (int i = 0; i < outWidth; i++) {
for (int j = 0; j < factor; j++) { maxVal = -INFINITY;
if (data[(int)id + j] > maxVal) { maxVal = data[(int)id + j]; } for (int j = 0; j < sFactor; j++) {
if (data[(int)id + j] > maxVal) { maxVal = data[(int)id + j]; }
}
out[i] = maxVal;
id += factor;
} }
out[i] = maxVal;
id += factor;
} }
} }