From: Soeren Apel Date: Sun, 15 Mar 2020 21:25:45 +0000 (+0100) Subject: Use separate logic output muxing vectors for each decoder X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=76da6e9e2168f2f2c599d48ab587a48d2a110107;p=pulseview.git Use separate logic output muxing vectors for each decoder --- diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 2de6fbee..24059f9e 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -386,6 +386,7 @@ void DecodeSignal::update_output_signals() shared_ptr logic_data = make_shared(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(); shared_ptr logic_segment = make_shared( *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; diff --git a/pv/data/decodesignal.hpp b/pv/data/decodesignal.hpp index ca9f9e96..f02f0921 100644 --- a/pv/data/decodesignal.hpp +++ b/pv/data/decodesignal.hpp @@ -265,6 +265,7 @@ private: bool decode_paused_; map> output_logic_; + map> output_logic_muxed_data_; vector< shared_ptr> output_signals_; }; diff --git a/pv/data/logicsegment.cpp b/pv/data/logicsegment.cpp index d02a23a2..739b2b9e 100644 --- a/pv/data/logicsegment.cpp +++ b/pv/data/logicsegment.cpp @@ -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& destination) { - static vector 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(); } } diff --git a/pv/data/logicsegment.hpp b/pv/data/logicsegment.hpp index 2b67c0ed..35e8eca9 100644 --- a/pv/data/logicsegment.hpp +++ b/pv/data/logicsegment.hpp @@ -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& destination); void get_samples(int64_t start_sample, int64_t end_sample, uint8_t* dest) const;