Mercurial > hg > svcore
comparison data/model/RangeSummarisableTimeValueModel.h @ 836:f3c98e89cf75
I don't think this optimisation is worth the loss of data fidelity any more
author | Chris Cannam |
---|---|
date | Wed, 09 Oct 2013 14:44:05 +0100 |
parents | 8c5b0eec6fe9 |
children | 59e7fe1b1003 |
comparison
equal
deleted
inserted
replaced
835:1d439494604c | 836:f3c98e89cf75 |
---|---|
35 Q_OBJECT | 35 Q_OBJECT |
36 | 36 |
37 public: | 37 public: |
38 RangeSummarisableTimeValueModel() { } | 38 RangeSummarisableTimeValueModel() { } |
39 | 39 |
40 #define RANGE_USE_SHORT 1 | |
41 #ifdef RANGE_USE_SHORT | |
42 class Range | |
43 { | |
44 public: | |
45 Range() : | |
46 m_min(0), m_max(0), m_absmean(0) { } | |
47 Range(const Range &r) : | |
48 m_min(r.m_min), m_max(r.m_max), m_absmean(r.m_absmean) { } | |
49 Range(float min, float max, float absmean) | |
50 { setMin(min); setMax(max); setAbsmean(absmean); } | |
51 | |
52 float min() const { return i2f(m_min); } | |
53 float max() const { return i2f(m_max); } | |
54 float absmean() const { return i2f(m_absmean); } | |
55 | |
56 void setMin(float min) { m_min = f2i(min); } | |
57 void setMax(float max) { m_max = f2i(max); } | |
58 void setAbsmean(float absmean) { m_absmean = f2i(absmean); } | |
59 | |
60 private: | |
61 static inline int16_t f2i(float f) { | |
62 if (f > 1.f) f = 1.f; | |
63 if (f < -1.f) f = -1.f; | |
64 return int16_t(f * 32767.f); | |
65 } | |
66 static inline float i2f(int16_t i) { | |
67 return float(i) / 32767.f; | |
68 } | |
69 | |
70 int16_t m_min; | |
71 int16_t m_max; | |
72 int16_t m_absmean; | |
73 }; | |
74 #else | |
75 class Range | 40 class Range |
76 { | 41 { |
77 public: | 42 public: |
78 Range() : | 43 Range() : |
79 m_min(0.f), m_max(0.f), m_absmean(0.f) { } | 44 m_min(0.f), m_max(0.f), m_absmean(0.f) { } |
93 private: | 58 private: |
94 float m_min; | 59 float m_min; |
95 float m_max; | 60 float m_max; |
96 float m_absmean; | 61 float m_absmean; |
97 }; | 62 }; |
98 #endif | |
99 | 63 |
100 typedef std::vector<Range> RangeBlock; | 64 typedef std::vector<Range> RangeBlock; |
101 | 65 |
102 /** | 66 /** |
103 * Return ranges from the given start frame, corresponding to the | 67 * Return ranges from the given start frame, corresponding to the |