Mercurial > hg > svcore
comparison data/fft/FFTFileCacheReader.h @ 935:f960d67ce842 tonioni
Merge from branch warnfix_no_size_t
| author | Chris Cannam |
|---|---|
| date | Wed, 18 Jun 2014 13:42:01 +0100 |
| parents | 59e7fe1b1003 |
| children | cc27f35aa75c |
comparison
equal
deleted
inserted
replaced
| 925:3efc20c59a94 | 935:f960d67ce842 |
|---|---|
| 26 { | 26 { |
| 27 public: | 27 public: |
| 28 FFTFileCacheReader(FFTFileCacheWriter *); | 28 FFTFileCacheReader(FFTFileCacheWriter *); |
| 29 ~FFTFileCacheReader(); | 29 ~FFTFileCacheReader(); |
| 30 | 30 |
| 31 size_t getWidth() const; | 31 int getWidth() const; |
| 32 size_t getHeight() const; | 32 int getHeight() const; |
| 33 | 33 |
| 34 float getMagnitudeAt(size_t x, size_t y) const; | 34 float getMagnitudeAt(int x, int y) const; |
| 35 float getNormalizedMagnitudeAt(size_t x, size_t y) const; | 35 float getNormalizedMagnitudeAt(int x, int y) const; |
| 36 float getMaximumMagnitudeAt(size_t x) const; | 36 float getMaximumMagnitudeAt(int x) const; |
| 37 float getPhaseAt(size_t x, size_t y) const; | 37 float getPhaseAt(int x, int y) const; |
| 38 | 38 |
| 39 void getValuesAt(size_t x, size_t y, float &real, float &imag) const; | 39 void getValuesAt(int x, int y, float &real, float &imag) const; |
| 40 void getMagnitudesAt(size_t x, float *values, size_t minbin, size_t count, size_t step) const; | 40 void getMagnitudesAt(int x, float *values, int minbin, int count, int step) const; |
| 41 | 41 |
| 42 bool haveSetColumnAt(size_t x) const; | 42 bool haveSetColumnAt(int x) const; |
| 43 | 43 |
| 44 static size_t getCacheSize(size_t width, size_t height, | 44 static int getCacheSize(int width, int height, |
| 45 FFTCache::StorageType type); | 45 FFTCache::StorageType type); |
| 46 | 46 |
| 47 FFTCache::StorageType getStorageType() const { return m_storageType; } | 47 FFTCache::StorageType getStorageType() const { return m_storageType; } |
| 48 | 48 |
| 49 protected: | 49 protected: |
| 50 mutable char *m_readbuf; | 50 mutable char *m_readbuf; |
| 51 mutable size_t m_readbufCol; | 51 mutable int m_readbufCol; |
| 52 mutable size_t m_readbufWidth; | 52 mutable int m_readbufWidth; |
| 53 mutable bool m_readbufGood; | 53 mutable bool m_readbufGood; |
| 54 | 54 |
| 55 float getFromReadBufStandard(size_t x, size_t y) const { | 55 float getFromReadBufStandard(int x, int y) const { |
| 56 float v; | 56 float v; |
| 57 if (m_readbuf && | 57 if (m_readbuf && |
| 58 (m_readbufCol == x || (m_readbufWidth > 1 && m_readbufCol+1 == x))) { | 58 (m_readbufCol == x || (m_readbufWidth > 1 && m_readbufCol+1 == x))) { |
| 59 v = ((float *)m_readbuf)[(x - m_readbufCol) * m_mfc->getHeight() + y]; | 59 v = ((float *)m_readbuf)[(x - m_readbufCol) * m_mfc->getHeight() + y]; |
| 60 return v; | 60 return v; |
| 63 v = getFromReadBufStandard(x, y); | 63 v = getFromReadBufStandard(x, y); |
| 64 return v; | 64 return v; |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 float getFromReadBufCompactUnsigned(size_t x, size_t y) const { | 68 float getFromReadBufCompactUnsigned(int x, int y) const { |
| 69 float v; | 69 float v; |
| 70 if (m_readbuf && | 70 if (m_readbuf && |
| 71 (m_readbufCol == x || (m_readbufWidth > 1 && m_readbufCol+1 == x))) { | 71 (m_readbufCol == x || (m_readbufWidth > 1 && m_readbufCol+1 == x))) { |
| 72 v = ((uint16_t *)m_readbuf)[(x - m_readbufCol) * m_mfc->getHeight() + y]; | 72 v = ((uint16_t *)m_readbuf)[(x - m_readbufCol) * m_mfc->getHeight() + y]; |
| 73 return v; | 73 return v; |
| 76 v = getFromReadBufCompactUnsigned(x, y); | 76 v = getFromReadBufCompactUnsigned(x, y); |
| 77 return v; | 77 return v; |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 float getFromReadBufCompactSigned(size_t x, size_t y) const { | 81 float getFromReadBufCompactSigned(int x, int y) const { |
| 82 float v; | 82 float v; |
| 83 if (m_readbuf && | 83 if (m_readbuf && |
| 84 (m_readbufCol == x || (m_readbufWidth > 1 && m_readbufCol+1 == x))) { | 84 (m_readbufCol == x || (m_readbufWidth > 1 && m_readbufCol+1 == x))) { |
| 85 v = ((int16_t *)m_readbuf)[(x - m_readbufCol) * m_mfc->getHeight() + y]; | 85 v = ((int16_t *)m_readbuf)[(x - m_readbufCol) * m_mfc->getHeight() + y]; |
| 86 return v; | 86 return v; |
| 89 v = getFromReadBufCompactSigned(x, y); | 89 v = getFromReadBufCompactSigned(x, y); |
| 90 return v; | 90 return v; |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 void populateReadBuf(size_t x) const; | 94 void populateReadBuf(int x) const; |
| 95 | 95 |
| 96 float getNormalizationFactor(size_t col) const { | 96 float getNormalizationFactor(int col) const { |
| 97 size_t h = m_mfc->getHeight(); | 97 int h = m_mfc->getHeight(); |
| 98 if (h < m_factorSize) return 0; | 98 if (h < m_factorSize) return 0; |
| 99 if (m_storageType != FFTCache::Compact) { | 99 if (m_storageType != FFTCache::Compact) { |
| 100 return getFromReadBufStandard(col, h - 1); | 100 return getFromReadBufStandard(col, h - 1); |
| 101 } else { | 101 } else { |
| 102 union { | 102 union { |
| 106 if (!m_readbuf || | 106 if (!m_readbuf || |
| 107 !(m_readbufCol == col || | 107 !(m_readbufCol == col || |
| 108 (m_readbufWidth > 1 && m_readbufCol+1 == col))) { | 108 (m_readbufWidth > 1 && m_readbufCol+1 == col))) { |
| 109 populateReadBuf(col); | 109 populateReadBuf(col); |
| 110 } | 110 } |
| 111 size_t ix = (col - m_readbufCol) * m_mfc->getHeight() + h; | 111 int ix = (col - m_readbufCol) * m_mfc->getHeight() + h; |
| 112 factor.u[0] = ((uint16_t *)m_readbuf)[ix - 2]; | 112 factor.u[0] = ((uint16_t *)m_readbuf)[ix - 2]; |
| 113 factor.u[1] = ((uint16_t *)m_readbuf)[ix - 1]; | 113 factor.u[1] = ((uint16_t *)m_readbuf)[ix - 1]; |
| 114 return factor.f; | 114 return factor.f; |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 FFTCache::StorageType m_storageType; | 118 FFTCache::StorageType m_storageType; |
| 119 size_t m_factorSize; | 119 int m_factorSize; |
| 120 MatrixFile *m_mfc; | 120 MatrixFile *m_mfc; |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 #endif | 123 #endif |
