From: Soeren Apel Date: Thu, 12 Dec 2019 20:31:34 +0000 (+0100) Subject: Allow more than 256 binary output classes X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=ac9494eff3ebc74ae7a87746a4d8668c68f32b52;p=pulseview.git Allow more than 256 binary output classes --- diff --git a/pv/data/decode/decoder.cpp b/pv/data/decode/decoder.cpp index 8e7ffb50..14d298d2 100644 --- a/pv/data/decode/decoder.cpp +++ b/pv/data/decode/decoder.cpp @@ -42,7 +42,7 @@ Decoder::Decoder(const srd_decoder *const dec) : decoder_inst_(nullptr) { // Query the decoder outputs - uint8_t i = 0; + uint32_t i = 0; for (GSList *l = dec->binary; l; l = l->next) { char **bin_class = (char**)l->data; char *name = bin_class[0]; @@ -184,12 +184,12 @@ void Decoder::invalidate_decoder_inst() decoder_inst_ = nullptr; } -uint8_t Decoder::get_binary_class_count() const +uint32_t Decoder::get_binary_class_count() const { return bin_classes_.size(); } -const DecodeBinaryClassInfo* Decoder::get_binary_class(uint8_t id) const +const DecodeBinaryClassInfo* Decoder::get_binary_class(uint32_t id) const { return &(bin_classes_.at(id)); } diff --git a/pv/data/decode/decoder.hpp b/pv/data/decode/decoder.hpp index 2a7ef11e..bc1673c9 100644 --- a/pv/data/decode/decoder.hpp +++ b/pv/data/decode/decoder.hpp @@ -63,7 +63,7 @@ struct DecodeChannel struct DecodeBinaryClassInfo { - uint8_t bin_class_id; + uint32_t bin_class_id; char* name; char* description; }; @@ -97,8 +97,8 @@ public: srd_decoder_inst* create_decoder_inst(srd_session *session); void invalidate_decoder_inst(); - uint8_t get_binary_class_count() const; - const DecodeBinaryClassInfo* get_binary_class(uint8_t id) const; + uint32_t get_binary_class_count() const; + const DecodeBinaryClassInfo* get_binary_class(uint32_t id) const; private: const srd_decoder *const decoder_; diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 9fddfdf9..ad5a27a9 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -535,7 +535,7 @@ void DecodeSignal::get_annotation_subset( } uint32_t DecodeSignal::get_binary_data_chunk_count(uint32_t segment_id, - const Decoder* dec, uint8_t bin_class_id) const + const Decoder* dec, uint32_t bin_class_id) const { try { const DecodeSegment *segment = &(segments_.at(segment_id)); @@ -551,7 +551,7 @@ uint32_t DecodeSignal::get_binary_data_chunk_count(uint32_t segment_id, } void DecodeSignal::get_binary_data_chunk(uint32_t segment_id, - const Decoder* dec, uint8_t bin_class_id, uint32_t chunk_id, + const Decoder* dec, uint32_t bin_class_id, uint32_t chunk_id, const vector **dest, uint64_t *size) { try { @@ -569,7 +569,7 @@ void DecodeSignal::get_binary_data_chunk(uint32_t segment_id, } void DecodeSignal::get_binary_data_chunks_merged(uint32_t segment_id, - const Decoder* dec, uint8_t bin_class_id, uint64_t start_sample, + const Decoder* dec, uint32_t bin_class_id, uint64_t start_sample, uint64_t end_sample, vector *dest) const { assert(dest != nullptr); @@ -610,7 +610,7 @@ void DecodeSignal::get_binary_data_chunks_merged(uint32_t segment_id, } const DecodeBinaryClass* DecodeSignal::get_binary_data_class(uint32_t segment_id, - const data::decode::Decoder* dec, uint8_t bin_class_id) const + const data::decode::Decoder* dec, uint32_t bin_class_id) const { try { const DecodeSegment *segment = &(segments_.at(segment_id)); @@ -1347,9 +1347,9 @@ void DecodeSignal::create_decode_segment() // Prepare our binary output classes for (const shared_ptr& dec : stack_) { - uint8_t n = dec->get_binary_class_count(); + uint32_t n = dec->get_binary_class_count(); - for (uint8_t i = 0; i < n; i++) + for (uint32_t i = 0; i < n; i++) segments_.back().binary_classes.push_back( {dec.get(), dec->get_binary_class(i), vector()}); } diff --git a/pv/data/decodesignal.hpp b/pv/data/decodesignal.hpp index 5755c80e..1fe696eb 100644 --- a/pv/data/decodesignal.hpp +++ b/pv/data/decodesignal.hpp @@ -159,15 +159,15 @@ public: uint32_t segment_id, uint64_t start_sample, uint64_t end_sample) const; uint32_t get_binary_data_chunk_count(uint32_t segment_id, - const data::decode::Decoder* dec, uint8_t bin_class_id) const; + const data::decode::Decoder* dec, uint32_t bin_class_id) const; void get_binary_data_chunk(uint32_t segment_id, const data::decode::Decoder* dec, - uint8_t bin_class_id, uint32_t chunk_id, const vector **dest, + uint32_t bin_class_id, uint32_t chunk_id, const vector **dest, uint64_t *size); void get_binary_data_chunks_merged(uint32_t segment_id, const data::decode::Decoder* dec, - uint8_t bin_class_id, uint64_t start_sample, uint64_t end_sample, + uint32_t bin_class_id, uint64_t start_sample, uint64_t end_sample, vector *dest) const; const DecodeBinaryClass* get_binary_data_class(uint32_t segment_id, - const data::decode::Decoder* dec, uint8_t bin_class_id) const; + const data::decode::Decoder* dec, uint32_t bin_class_id) const; virtual void save_settings(QSettings &settings) const; diff --git a/pv/views/decoder_output/view.cpp b/pv/views/decoder_output/view.cpp index 8bce3745..d8bbb03a 100644 --- a/pv/views/decoder_output/view.cpp +++ b/pv/views/decoder_output/view.cpp @@ -223,8 +223,8 @@ void View::on_selected_decoder_changed(int index) if (signal_) { // Populate binary class selector - uint8_t bin_classes = decoder_->get_binary_class_count(); - for (uint8_t i = 0; i < bin_classes; i++) { + uint32_t bin_classes = decoder_->get_binary_class_count(); + for (uint32_t i = 0; i < bin_classes; i++) { const data::decode::DecodeBinaryClassInfo* class_info = decoder_->get_binary_class(i); class_selector_->addItem(class_info->name, QVariant::fromValue(i)); } @@ -238,7 +238,7 @@ void View::on_selected_decoder_changed(int index) void View::on_selected_class_changed(int index) { - bin_class_id_ = class_selector_->itemData(index).value(); + bin_class_id_ = class_selector_->itemData(index).value(); update_data(); } diff --git a/pv/views/decoder_output/view.hpp b/pv/views/decoder_output/view.hpp index 58aec954..23023efb 100644 --- a/pv/views/decoder_output/view.hpp +++ b/pv/views/decoder_output/view.hpp @@ -81,7 +81,7 @@ private: data::DecodeSignal *signal_; const data::decode::Decoder *decoder_; - uint8_t bin_class_id_; + uint32_t bin_class_id_; }; } // namespace decoder_output