X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fdata%2Fanalogsegment.cpp;h=1bd33876cc21ac99b455f356cf8993a2aedda42e;hb=aca9aa834c742ba70f49d1ac3eb2d1e02e759416;hp=7458a074fff8c229650a16279fa785945faef067;hpb=eb8269e3b5eebdd77e6a82d42bcfdfbc3f7613a9;p=pulseview.git diff --git a/pv/data/analogsegment.cpp b/pv/data/analogsegment.cpp index 7458a07..1bd3387 100644 --- a/pv/data/analogsegment.cpp +++ b/pv/data/analogsegment.cpp @@ -20,9 +20,9 @@ #include #include -#include -#include #include +#include +#include #include @@ -31,19 +31,20 @@ using std::lock_guard; using std::recursive_mutex; +using std::make_pair; using std::max; using std::max_element; using std::min; using std::min_element; +using std::pair; namespace pv { namespace data { const int AnalogSegment::EnvelopeScalePower = 4; const int AnalogSegment::EnvelopeScaleFactor = 1 << EnvelopeScalePower; -const float AnalogSegment::LogEnvelopeScaleFactor = - logf(EnvelopeScaleFactor); -const uint64_t AnalogSegment::EnvelopeDataUnit = 64*1024; // bytes +const float AnalogSegment::LogEnvelopeScaleFactor = logf(EnvelopeScaleFactor); +const uint64_t AnalogSegment::EnvelopeDataUnit = 64 * 1024; // bytes AnalogSegment::AnalogSegment(Analog& owner, uint64_t samplerate) : Segment(samplerate, sizeof(float)), @@ -71,7 +72,7 @@ void AnalogSegment::append_interleaved_samples(const float *data, uint64_t prev_sample_count = sample_count_; - for (uint32_t i=0; i < sample_count; i++) { + for (uint32_t i = 0; i < sample_count; i++) { append_single_sample((void*)data); data += stride; } @@ -101,9 +102,9 @@ const float* AnalogSegment::get_samples( return (float*)get_raw_samples(start_sample, (end_sample - start_sample)); } -const std::pair AnalogSegment::get_min_max() const +const pair AnalogSegment::get_min_max() const { - return std::make_pair(min_value_, max_value_); + return make_pair(min_value_, max_value_); } SegmentAnalogDataIterator* AnalogSegment::begin_sample_iteration(uint64_t start) @@ -172,8 +173,10 @@ void AnalogSegment::append_payload_to_envelope_levels() 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; + 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); @@ -189,7 +192,7 @@ void AnalogSegment::append_payload_to_envelope_levels() // Iterate through the samples to populate the first level mipmap uint64_t start_sample = prev_length * EnvelopeScaleFactor; - uint64_t end_sample = e0.length * EnvelopeScaleFactor; + uint64_t end_sample = e0.length * EnvelopeScaleFactor; it = begin_raw_sample_iteration(start_sample); for (uint64_t i = start_sample; i < end_sample; i += EnvelopeScaleFactor) { @@ -200,8 +203,10 @@ void AnalogSegment::append_payload_to_envelope_levels() *max_element(samples, samples + EnvelopeScaleFactor), }; - if (sub_sample.min < min_value_) min_value_ = sub_sample.min; - if (sub_sample.max > max_value_) max_value_ = sub_sample.max; + if (sub_sample.min < min_value_) + min_value_ = sub_sample.min; + if (sub_sample.max > max_value_) + max_value_ = sub_sample.max; continue_raw_sample_iteration(it, EnvelopeScaleFactor); *dest_ptr++ = sub_sample; @@ -211,7 +216,7 @@ void AnalogSegment::append_payload_to_envelope_levels() // Compute higher level mipmaps for (unsigned int level = 1; level < ScaleStepCount; level++) { Envelope &e = envelope_levels_[level]; - const Envelope &el = envelope_levels_[level-1]; + const Envelope &el = envelope_levels_[level - 1]; // Expand the data buffer to fit the new samples prev_length = e.length;