projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8571540
)
AnalogSegment: Calculate min/max also for small sample sizes
author
Soeren Apel
<soeren@apelpie.net>
Mon, 13 Feb 2017 23:07:55 +0000
(
00:07
+0100)
committer
Uwe Hermann
<uwe@hermann-uwe.de>
Wed, 15 Feb 2017 11:12:52 +0000
(12:12 +0100)
pv/data/analogsegment.cpp
patch
|
blob
|
history
diff --git
a/pv/data/analogsegment.cpp
b/pv/data/analogsegment.cpp
index cfc0f2bb60a9498d9561f10c27b5e22ae84ee896..38db0f123d3be31e95b98ee849fde237bf46819c 100644
(file)
--- a/
pv/data/analogsegment.cpp
+++ b/
pv/data/analogsegment.cpp
@@
-167,6
+167,18
@@
void AnalogSegment::append_payload_to_envelope_levels()
prev_length = e0.length;
e0.length = sample_count_ / EnvelopeScaleFactor;
prev_length = e0.length;
e0.length = sample_count_ / EnvelopeScaleFactor;
+ // Calculate min/max values in case we have too few samples for an envelope
+ if (sample_count_ < EnvelopeScaleFactor) {
+ it = begin_raw_sample_iteration(0);
+ for (uint64_t i = 0; i < sample_count_; i++) {
+ const float sample = *((float*)it->value);
+ if (sample < min_value_) min_value_ = sample;
+ if (sample > max_value_) max_value_ = sample;
+ continue_raw_sample_iteration(it, 1);
+ }
+ end_raw_sample_iteration(it);
+ }
+
// Break off if there are no new samples to compute
if (e0.length == prev_length)
return;
// Break off if there are no new samples to compute
if (e0.length == prev_length)
return;