]> sigrok.org Git - pulseview.git/commitdiff
Use separate logic output muxing vectors for each decoder
authorSoeren Apel <redacted>
Sun, 15 Mar 2020 21:25:45 +0000 (22:25 +0100)
committerSoeren Apel <redacted>
Sat, 13 Feb 2021 21:37:41 +0000 (22:37 +0100)
pv/data/decodesignal.cpp
pv/data/decodesignal.hpp
pv/data/logicsegment.cpp
pv/data/logicsegment.hpp

index 2de6fbeedd8dff0f266d17caad65125fa0e78817..24059f9e3af0d83bfa53f08e5bba7f92e5477ce0 100644 (file)
@@ -386,6 +386,7 @@ void DecodeSignal::update_output_signals()
                                shared_ptr<Logic> logic_data = make_shared<Logic>(logic_channels.size());
                                logic_data->set_samplerate(get_samplerate());
                                output_logic_[dec->get_srd_decoder()] = logic_data;
+                               output_logic_muxed_data_[dec->get_srd_decoder()] = vector<uint8_t>();
 
                                shared_ptr<LogicSegment> logic_segment = make_shared<data::LogicSegment>(
                                        *logic_data, 0, (logic_data->num_channels() + 7) / 8, get_samplerate());
@@ -1755,7 +1756,8 @@ void DecodeSignal::logic_output_callback(srd_proto_data *pdata, void *decode_sig
        for (unsigned int i = pdata->start_sample; i < pdata->end_sample; i++)
                data.emplace_back(*((uint8_t*)pdl->data));
 
-       last_segment->append_subsignal_payload(pdl->logic_class, data.data(), data.size());
+       last_segment->append_subsignal_payload(pdl->logic_class, data.data(),
+               data.size(), ds->output_logic_muxed_data_.at(decc));
 
        qInfo() << "Received logic output state change for class" << pdl->logic_class << "from decoder" \
                << QString::fromUtf8(decc->name) << "from" << pdata->start_sample << "to" << pdata->end_sample;
index ca9f9e96f652d7247d1856567990cb0c24f9914b..f02f0921eba142809a2e096794c0f8128af3ed44 100644 (file)
@@ -265,6 +265,7 @@ private:
        bool decode_paused_;
 
        map<const srd_decoder*, shared_ptr<Logic>> output_logic_;
+       map<const srd_decoder*, vector<uint8_t>> output_logic_muxed_data_;
        vector< shared_ptr<SignalBase>> output_signals_;
 };
 
index d02a23a28ad7856262b3f889e599a896404dcfbf..739b2b9ee2a97652de2d4d4e3530041c1613af2c 100644 (file)
@@ -363,30 +363,28 @@ void LogicSegment::append_payload(void *data, uint64_t data_size)
                        prev_sample_count + 1, prev_sample_count + 1);
 }
 
-void LogicSegment::append_subsignal_payload(unsigned int index, void *data, uint64_t data_size)
+void LogicSegment::append_subsignal_payload(unsigned int index, void *data,
+       uint64_t data_size, vector<uint8_t>& destination)
 {
-       static vector<uint8_t> merged_data;  // To preserve intermediate data across calls
-
        if (index == 0)
-               for (uint64_t i = 0; i < data_size * unit_size_; i++)
-                       merged_data.emplace_back(0);
+               destination.resize(data_size * unit_size_, 0);
 
        // Set the bits for this sub-signal where needed
        // Note: the bytes in *data must either be 0 or 1, nothing else
        unsigned int index_byte_offs = index / 8;
-       uint8_t* output_data = merged_data.data() + index_byte_offs;
+       uint8_t* output_data = destination.data() + index_byte_offs;
        uint8_t* input_data = (uint8_t*)data;
 
        for (uint64_t i = 0; i < data_size; i++) {
-               assert((i * unit_size_ + index_byte_offs) < merged_data.size());
+               assert((i * unit_size_ + index_byte_offs) < destination.size());
                *output_data |= (input_data[i] << index);
                output_data += unit_size_;
        }
 
        if (index == owner_.num_channels() - 1) {
                // We gathered sample data of all sub-signals, let's append it
-               append_payload(merged_data.data(), merged_data.size());
-               merged_data.clear();
+               append_payload(destination.data(), destination.size());
+               destination.clear();
        }
 }
 
index 2b67c0edb81ddad6165597499bf4d704d185a483..35e8eca95f9212091475e2b0bd2bd77fd593e7f8 100644 (file)
@@ -96,7 +96,8 @@ public:
         * is constant for every invokation for 0..n. The number of samples
         * hence may only change when index is 0.
         */
-       void append_subsignal_payload(unsigned int index, void *data, uint64_t data_size);
+       void append_subsignal_payload(unsigned int index, void *data,
+               uint64_t data_size, vector<uint8_t>& destination);
 
        void get_samples(int64_t start_sample, int64_t end_sample, uint8_t* dest) const;