]> sigrok.org Git - pulseview.git/commitdiff
SignalBase: Make ConversionBlockSize a class constant
authorSoeren Apel <redacted>
Fri, 5 May 2017 20:09:42 +0000 (22:09 +0200)
committerUwe Hermann <redacted>
Wed, 5 Jul 2017 22:37:04 +0000 (00:37 +0200)
pv/data/signalbase.cpp
pv/data/signalbase.hpp

index bbb7fdc36382c82c76b8305c866a5c221454aeef..621a3dda3560216fa3508594ccda5ff5e55deaae 100644 (file)
@@ -38,6 +38,7 @@ namespace pv {
 namespace data {
 
 const int SignalBase::ColourBGAlpha = 8 * 256 / 100;
+const uint64_t SignalBase::ConversionBlockSize = 4096;
 
 SignalBase::SignalBase(shared_ptr<sigrok::Channel> channel, ChannelType channel_type) :
        channel_(channel),
@@ -239,8 +240,6 @@ uint8_t SignalBase::convert_a2l_schmitt_trigger(float lo_thr, float hi_thr,
 void SignalBase::conversion_thread_proc(QObject* segment, uint64_t start_sample,
        uint64_t end_sample)
 {
-       const uint64_t block_size = 4096;
-
        // TODO Support for multiple segments is missing
 
        if ((channel_type_ == AnalogChannel) &&
@@ -279,7 +278,7 @@ void SignalBase::conversion_thread_proc(QObject* segment, uint64_t start_sample,
                tie(min_v, max_v) = asegment->get_min_max();
 
                vector<uint8_t> lsamples;
-               lsamples.reserve(block_size);
+               lsamples.reserve(ConversionBlockSize);
 
                uint64_t i = start_sample;
 
@@ -287,12 +286,12 @@ void SignalBase::conversion_thread_proc(QObject* segment, uint64_t start_sample,
                        const float threshold = (min_v + max_v) * 0.5;  // middle between min and max
 
                        // Convert as many sample blocks as we can
-                       while ((end_sample - i) > block_size) {
-                               const float* asamples = asegment->get_samples(i, i + block_size);
-                               for (uint32_t j = 0; j < block_size; j++)
+                       while ((end_sample - i) > ConversionBlockSize) {
+                               const float* asamples = asegment->get_samples(i, i + ConversionBlockSize);
+                               for (uint32_t j = 0; j < ConversionBlockSize; j++)
                                        lsamples.push_back(convert_a2l_threshold(threshold, asamples[j]));
                                lsegment->append_payload(lsamples.data(), lsamples.size());
-                               i += block_size;
+                               i += ConversionBlockSize;
                                lsamples.clear();
                                delete[] asamples;
                        }
@@ -314,12 +313,12 @@ void SignalBase::conversion_thread_proc(QObject* segment, uint64_t start_sample,
                        uint8_t state = 0;  // TODO Use value of logic sample n-1 instead of 0
 
                        // Convert as many sample blocks as we can
-                       while ((end_sample - i) > block_size) {
-                               const float* asamples = asegment->get_samples(i, i + block_size);
-                               for (uint32_t j = 0; j < block_size; j++)
+                       while ((end_sample - i) > ConversionBlockSize) {
+                               const float* asamples = asegment->get_samples(i, i + ConversionBlockSize);
+                               for (uint32_t j = 0; j < ConversionBlockSize; j++)
                                        lsamples.push_back(convert_a2l_schmitt_trigger(lo_thr, hi_thr, asamples[j], state));
                                lsegment->append_payload(lsamples.data(), lsamples.size());
-                               i += block_size;
+                               i += ConversionBlockSize;
                                lsamples.clear();
                                delete[] asamples;
                        }
index f70c934fb0eacdc8374b1d341ac50c17a96bef87..90a13555fb41938db36eb6063aef096bc6da20ef 100644 (file)
@@ -65,6 +65,7 @@ public:
 
 private:
        static const int ColourBGAlpha;
+       static const uint64_t ConversionBlockSize;
 
 public:
        SignalBase(shared_ptr<sigrok::Channel> channel, ChannelType channel_type);