Mercurial > hg > svcore
comparison data/fft/FFTMemoryCache.cpp @ 374:7cc6b7b0d819 sv1-v1.2pre3
* line up overview widget nicely with main pane (at least on first startup)
* fix #1878396 renaming layer seems to have no visible effect
* comment out some debug output
| author | Chris Cannam |
|---|---|
| date | Wed, 06 Feb 2008 17:40:53 +0000 |
| parents | 824ee993ca8d |
| children | 115f60df1e4d |
comparison
equal
deleted
inserted
replaced
| 373:0a44caddd9fe | 374:7cc6b7b0d819 |
|---|---|
| 16 #include "FFTMemoryCache.h" | 16 #include "FFTMemoryCache.h" |
| 17 #include "system/System.h" | 17 #include "system/System.h" |
| 18 | 18 |
| 19 #include <iostream> | 19 #include <iostream> |
| 20 | 20 |
| 21 //#define DEBUG_FFT_MEMORY_CACHE 1 | |
| 22 | |
| 21 FFTMemoryCache::FFTMemoryCache(StorageType storageType) : | 23 FFTMemoryCache::FFTMemoryCache(StorageType storageType) : |
| 22 m_width(0), | 24 m_width(0), |
| 23 m_height(0), | 25 m_height(0), |
| 24 m_magnitude(0), | 26 m_magnitude(0), |
| 25 m_phase(0), | 27 m_phase(0), |
| 28 m_freal(0), | 30 m_freal(0), |
| 29 m_fimag(0), | 31 m_fimag(0), |
| 30 m_factor(0), | 32 m_factor(0), |
| 31 m_storageType(storageType) | 33 m_storageType(storageType) |
| 32 { | 34 { |
| 35 #ifdef DEBUG_FFT_MEMORY_CACHE | |
| 33 std::cerr << "FFTMemoryCache[" << this << "]::FFTMemoryCache (type " | 36 std::cerr << "FFTMemoryCache[" << this << "]::FFTMemoryCache (type " |
| 34 << m_storageType << ")" << std::endl; | 37 << m_storageType << ")" << std::endl; |
| 38 #endif | |
| 35 } | 39 } |
| 36 | 40 |
| 37 FFTMemoryCache::~FFTMemoryCache() | 41 FFTMemoryCache::~FFTMemoryCache() |
| 38 { | 42 { |
| 39 // std::cerr << "FFTMemoryCache[" << this << "]::~FFTMemoryCache" << std::endl; | 43 #ifdef DEBUG_FFT_MEMORY_CACHE |
| 44 std::cerr << "FFTMemoryCache[" << this << "]::~FFTMemoryCache" << std::endl; | |
| 45 #endif | |
| 40 | 46 |
| 41 for (size_t i = 0; i < m_width; ++i) { | 47 for (size_t i = 0; i < m_width; ++i) { |
| 42 if (m_magnitude && m_magnitude[i]) free(m_magnitude[i]); | 48 if (m_magnitude && m_magnitude[i]) free(m_magnitude[i]); |
| 43 if (m_phase && m_phase[i]) free(m_phase[i]); | 49 if (m_phase && m_phase[i]) free(m_phase[i]); |
| 44 if (m_fmagnitude && m_fmagnitude[i]) free(m_fmagnitude[i]); | 50 if (m_fmagnitude && m_fmagnitude[i]) free(m_fmagnitude[i]); |
| 57 } | 63 } |
| 58 | 64 |
| 59 void | 65 void |
| 60 FFTMemoryCache::resize(size_t width, size_t height) | 66 FFTMemoryCache::resize(size_t width, size_t height) |
| 61 { | 67 { |
| 68 #ifdef DEBUG_FFT_MEMORY_CACHE | |
| 62 std::cerr << "FFTMemoryCache[" << this << "]::resize(" << width << "x" << height << " = " << width*height << ")" << std::endl; | 69 std::cerr << "FFTMemoryCache[" << this << "]::resize(" << width << "x" << height << " = " << width*height << ")" << std::endl; |
| 70 #endif | |
| 63 | 71 |
| 64 if (m_width == width && m_height == height) return; | 72 if (m_width == width && m_height == height) return; |
| 65 | 73 |
| 66 if (m_storageType == Compact) { | 74 if (m_storageType == Compact) { |
| 67 resize(m_magnitude, width, height); | 75 resize(m_magnitude, width, height); |
| 79 m_factor = (float *)realloc(m_factor, width * sizeof(float)); | 87 m_factor = (float *)realloc(m_factor, width * sizeof(float)); |
| 80 | 88 |
| 81 m_width = width; | 89 m_width = width; |
| 82 m_height = height; | 90 m_height = height; |
| 83 | 91 |
| 84 // std::cerr << "done, width = " << m_width << " height = " << m_height << std::endl; | 92 #ifdef DEBUG_FFT_MEMORY_CACHE |
| 93 std::cerr << "done, width = " << m_width << " height = " << m_height << std::endl; | |
| 94 #endif | |
| 85 } | 95 } |
| 86 | 96 |
| 87 void | 97 void |
| 88 FFTMemoryCache::resize(uint16_t **&array, size_t width, size_t height) | 98 FFTMemoryCache::resize(uint16_t **&array, size_t width, size_t height) |
| 89 { | 99 { |
