comparison data/model/EditableDenseThreeDimensionalModel.h @ 1777:d484490cdf69

Split EditableDenseThreeDimensionalModel into explicitly compressed and uncompressed variants. Simplifies the uncompressed version, and we may want to consider whether we need the compressed one at all.
author Chris Cannam
date Tue, 10 Sep 2019 16:34:47 +0100
parents 78fe29adfd16
children c546429d4c2f
comparison
equal deleted inserted replaced
1776:5750b9e60818 1777:d484490cdf69
16 #ifndef SV_EDITABLE_DENSE_THREE_DIMENSIONAL_MODEL_H 16 #ifndef SV_EDITABLE_DENSE_THREE_DIMENSIONAL_MODEL_H
17 #define SV_EDITABLE_DENSE_THREE_DIMENSIONAL_MODEL_H 17 #define SV_EDITABLE_DENSE_THREE_DIMENSIONAL_MODEL_H
18 18
19 #include "DenseThreeDimensionalModel.h" 19 #include "DenseThreeDimensionalModel.h"
20 20
21 #include <QReadWriteLock> 21 #include <QMutex>
22 22
23 #include <vector> 23 #include <vector>
24 24
25 class EditableDenseThreeDimensionalModel : public DenseThreeDimensionalModel 25 class EditableDenseThreeDimensionalModel : public DenseThreeDimensionalModel
26 { 26 {
27 Q_OBJECT 27 Q_OBJECT
28 28
29 public: 29 public:
30
31 // EditableDenseThreeDimensionalModel supports a basic compression
32 // method that reduces the size of multirate data (e.g. wavelet
33 // transform outputs) that are stored as plain 3d grids by about
34 // 60% or thereabouts. However, it can only be used for models
35 // whose columns are set in order from 0 and never subsequently
36 // changed. If the model is going to be actually edited, it must
37 // have NoCompression.
38
39 enum CompressionType
40 {
41 NoCompression,
42 BasicMultirateCompression
43 };
44
45 EditableDenseThreeDimensionalModel(sv_samplerate_t sampleRate, 30 EditableDenseThreeDimensionalModel(sv_samplerate_t sampleRate,
46 int resolution, 31 int resolution,
47 int height, 32 int height,
48 CompressionType compression,
49 bool notifyOnAdd = true); 33 bool notifyOnAdd = true);
50 34
51 bool isOK() const override; 35 bool isOK() const override;
52 bool isReady(int *completion = 0) const override; 36 bool isReady(int *completion = 0) const override;
53 void setCompletion(int completion, bool update = true); 37 void setCompletion(int completion, bool update = true);
199 183
200 protected: 184 protected:
201 typedef std::vector<Column> ValueMatrix; 185 typedef std::vector<Column> ValueMatrix;
202 ValueMatrix m_data; 186 ValueMatrix m_data;
203 187
204 // m_trunc is used for simple compression. If at least the top N
205 // elements of column x (for N = some proportion of the column
206 // height) are equal to those of an earlier column x', then
207 // m_trunc[x] will contain x-x' and column x will be truncated so
208 // as to remove the duplicate elements. If the equal elements are
209 // at the bottom, then m_trunc[x] will contain x'-x (a negative
210 // value). If m_trunc[x] is 0 then the whole of column x is
211 // stored.
212 std::vector<signed char> m_trunc;
213 void truncateAndStore(int index, const Column & values);
214 Column expandAndRetrieve(int index) const;
215 Column rightHeight(const Column &c) const;
216
217 std::vector<QString> m_binNames; 188 std::vector<QString> m_binNames;
218 std::vector<float> m_binValues; 189 std::vector<float> m_binValues;
219 QString m_binValueUnit; 190 QString m_binValueUnit;
220 191
221 sv_frame_t m_startFrame; 192 sv_frame_t m_startFrame;
222 sv_samplerate_t m_sampleRate; 193 sv_samplerate_t m_sampleRate;
223 int m_resolution; 194 int m_resolution;
224 int m_yBinCount; 195 int m_yBinCount;
225 CompressionType m_compression;
226 float m_minimum; 196 float m_minimum;
227 float m_maximum; 197 float m_maximum;
228 bool m_haveExtents; 198 bool m_haveExtents;
229 bool m_notifyOnAdd; 199 bool m_notifyOnAdd;
230 sv_frame_t m_sinceLastNotifyMin; 200 sv_frame_t m_sinceLastNotifyMin;
231 sv_frame_t m_sinceLastNotifyMax; 201 sv_frame_t m_sinceLastNotifyMax;
232 int m_completion; 202 int m_completion;
233 203
234 mutable QReadWriteLock m_lock; 204 mutable QMutex m_mutex;
235 }; 205 };
236 206
237 #endif 207 #endif