]> sigrok.org Git - pulseview.git/commitdiff
AnalogSegment: Speed up processing of interleaved sample data
authorSoeren Apel <redacted>
Sun, 28 May 2017 08:31:47 +0000 (10:31 +0200)
committerSoeren Apel <redacted>
Sun, 28 May 2017 08:31:47 +0000 (10:31 +0200)
pv/data/analogsegment.cpp

index 1bd33876cc21ac99b455f356cf8993a2aedda42e..5e42556ca8c3f01341283f909f2ffc81ed2d394a 100644 (file)
@@ -23,6 +23,7 @@
 #include <cmath>
 #include <cstdlib>
 #include <cstring>
+#include <memory>
 
 #include <algorithm>
 
@@ -37,6 +38,7 @@ using std::max_element;
 using std::min;
 using std::min_element;
 using std::pair;
+using std::unique_ptr;
 
 namespace pv {
 namespace data {
@@ -72,11 +74,17 @@ void AnalogSegment::append_interleaved_samples(const float *data,
 
        uint64_t prev_sample_count = sample_count_;
 
+       // Deinterleave the samples and add them
+       unique_ptr<float> deint_data(new float[sample_count]);
+       float *deint_data_ptr = deint_data.get();
        for (uint32_t i = 0; i < sample_count; i++) {
-               append_single_sample((void*)data);
+               *deint_data_ptr = (float)(*data);
+               deint_data_ptr++;
                data += stride;
        }
 
+       append_samples(deint_data.get(), sample_count);
+
        // Generate the first mip-map from the data
        append_payload_to_envelope_levels();