From bd4d5ff3d459d95f4a4f30fab8a9e17e41deeda8 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Fri, 12 May 2023 01:42:25 +0800 Subject: [PATCH] cabana: fix the frequency was incorrect when replay from a specified segment (#28165) old-commit-hash: f01652cc41590b08371a98f84f36d67f262c428a --- tools/cabana/streams/abstractstream.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/cabana/streams/abstractstream.cc b/tools/cabana/streams/abstractstream.cc index 355e65b6c5..701ecbb258 100644 --- a/tools/cabana/streams/abstractstream.cc +++ b/tools/cabana/streams/abstractstream.cc @@ -165,7 +165,8 @@ static inline QColor blend(const QColor &a, const QColor &b) { void CanData::compute(const char *can_data, const int size, double current_sec, double playback_speed, const QList &mask, uint32_t in_freq) { ts = current_sec; ++count; - freq = in_freq == 0 ? count / std::max(1.0, current_sec) : in_freq; + const double sec_to_first_event = current_sec - (can->allEvents().front()->mono_time / 1e9 - can->routeStartTime()); + freq = in_freq == 0 ? count / std::max(1.0, sec_to_first_event) : in_freq; if (dat.size() != size) { dat.resize(size); bit_change_counts.resize(size);