25 int width,
int height) :
35 m_storageType(storageType)
37 #ifdef DEBUG_FFT_MEMORY_CACHE 38 cerr <<
"FFTMemoryCache[" <<
this <<
"]::FFTMemoryCache (type " 47 #ifdef DEBUG_FFT_MEMORY_CACHE 48 cerr <<
"FFTMemoryCache[" <<
this <<
"]::~FFTMemoryCache" << endl;
51 for (
int i = 0; i <
m_width; ++i) {
72 Profiler profiler(
"FFTMemoryCache::initialise");
76 #ifdef DEBUG_FFT_MEMORY_CACHE 77 cerr <<
"FFTMemoryCache[" <<
this <<
"]::initialise(" << width <<
"x" << height <<
" = " << width*height <<
")" << endl;
98 #ifdef DEBUG_FFT_MEMORY_CACHE 99 cerr <<
"done, width = " <<
m_width <<
" height = " <<
m_height << endl;
106 array = (uint16_t **)malloc(
m_width *
sizeof(uint16_t *));
107 if (!array)
throw std::bad_alloc();
110 for (
int i = 0; i <
m_width; ++i) {
111 array[i] = (uint16_t *)malloc(
m_height *
sizeof(uint16_t));
112 if (!array[i])
throw std::bad_alloc();
120 array = (
float **)malloc(
m_width *
sizeof(
float *));
121 if (!array)
throw std::bad_alloc();
124 for (
int i = 0; i <
m_width; ++i) {
125 array[i] = (
float *)malloc(
m_height *
sizeof(
float));
126 if (!array[i])
throw std::bad_alloc();
134 Profiler profiler(
"FFTMemoryCache::setColumnAt: from polar");
139 Profiler subprof(
"FFTMemoryCache::setColumnAt: polar to cart");
140 for (
int y = 0; y <
m_height; ++y) {
141 m_freal[x][y] = mags[y] * cosf(phases[y]);
142 m_fimag[x][y] = mags[y] * sinf(phases[y]);
145 for (
int y = 0; y <
m_height; ++y) {
159 Profiler profiler(
"FFTMemoryCache::setColumnAt: from cart");
166 for (
int y = 0; y <
m_height; ++y) {
169 float mag = sqrtf(reals[y] * reals[y] + imags[y] * imags[y]);
170 if (mag > max) max = mag;
177 Profiler subprof(
"FFTMemoryCache::setColumnAt: cart to polar");
178 for (
int y = 0; y <
m_height; ++y) {
179 float mag = sqrtf(reals[y] * reals[y] + imags[y] * imags[y]);
180 float phase = atan2f(imags[y], reals[y]);
183 if (mag > max) max = mag;
207 sz = (height * 2 + 1) * width *
sizeof(uint16_t);
212 sz = (height * 2 + 1) * width *
sizeof(
float);
FFTMemoryCache(FFTCache::StorageType storageType, int width, int height)
static int getCacheSize(int width, int height, FFTCache::StorageType type)
void setMagnitudeAt(int x, int y, float mag)
void setColumnAt(int x, float *mags, float *phases, float factor)
void setPhaseAt(int x, int y, float phase)
QReadWriteLock m_colsetLock
ResizeableBitset m_colset
void setNormalizationFactor(int x, float factor)
FFTCache::StorageType m_storageType
Profile point instance class.