From 44e120ee2b3dc506ee0263541cce4c8c637df91f Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Thu, 22 Dec 2022 17:38:21 +0800 Subject: [PATCH] Decode the data while collection the data --- DSView/pv/data/decoderstack.cpp | 34 ++++++++++++++++++++++---------- DSView/pv/data/logicsnapshot.cpp | 12 ++++++----- DSView/pv/sigsession.cpp | 2 -- DSView/pv/view/decodetrace.cpp | 2 ++ 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/DSView/pv/data/decoderstack.cpp b/DSView/pv/data/decoderstack.cpp index c164459c..45262f77 100644 --- a/DSView/pv/data/decoderstack.cpp +++ b/DSView/pv/data/decoderstack.cpp @@ -452,14 +452,17 @@ void DecoderStack::do_decode_work() if (data == NULL) return; - // Check we have a snapshot of data - const auto &snapshots = data->get_snapshots(); - if (snapshots.empty()) - return; + if (_session->is_realtime_mode() == false) + { + // Check we have a snapshot of data + const auto &snapshots = data->get_snapshots(); + if (snapshots.empty()) + return; - _snapshot = snapshots.front(); - if (_snapshot->empty()) - return; + _snapshot = snapshots.front(); + if (_snapshot->empty()) + return; + } // Get the samplerate _samplerate = data->samplerate(); @@ -512,13 +515,24 @@ void DecoderStack::decode_data(const uint64_t decode_start, const uint64_t decod if( i >= decode_end){ dsv_info("%s", "decode data index have been end"); } + + std::vector chunk; + std::vector chunk_const; while(i < decode_end && !_no_memory && !status->_bStop) { - std::vector chunk; - std::vector chunk_const; + chunk.clear(); + chunk_const.clear(); + uint64_t chunk_end = decode_end; + // Wait the data is ready. + if (!_is_capture_end && i == _snapshot->get_ring_sample_count()) + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + continue; + } + for (int j =0 ; j < logic_di->dec_num_channels; j++) { int sig_index = logic_di->dec_channelmap[j]; @@ -609,7 +623,7 @@ void DecoderStack::execute_decode_stack() assert(session); // Get the intial sample count - _sample_count = _snapshot->get_sample_count(); + _sample_count = _snapshot->get_ring_sample_count(); // Create the decoders for(auto dec : _stack) diff --git a/DSView/pv/data/logicsnapshot.cpp b/DSView/pv/data/logicsnapshot.cpp index 2d0d1b2d..e5d7f5a8 100644 --- a/DSView/pv/data/logicsnapshot.cpp +++ b/DSView/pv/data/logicsnapshot.cpp @@ -477,12 +477,14 @@ void LogicSnapshot::calc_mipmap(unsigned int order, uint8_t index0, uint8_t inde } const uint8_t *LogicSnapshot::get_samples(uint64_t start_sample, uint64_t &end_sample, int sig_index) -{ - uint64_t sample_count = _sample_count; - assert(start_sample < sample_count); - assert(end_sample <= sample_count); +{ + assert(start_sample < _ring_sample_count); assert(start_sample <= end_sample); + if (end_sample >= _ring_sample_count){ + end_sample = _ring_sample_count - 1; + } + int order = get_ch_order(sig_index); uint64_t index0 = start_sample >> (LeafBlockPower + RootScalePower); uint64_t index1 = (start_sample & RootMask) >> LeafBlockPower; @@ -492,7 +494,7 @@ const uint8_t *LogicSnapshot::get_samples(uint64_t start_sample, uint64_t &end_s (index1 << LeafBlockPower) + ~(~0ULL << LeafBlockPower); - end_sample = min(end_sample + 1, sample_count); + end_sample = min(end_sample + 1, _ring_sample_count); if (order == -1 || _ch_data[order][index0].lbp[index1] == NULL) return NULL; diff --git a/DSView/pv/sigsession.cpp b/DSView/pv/sigsession.cpp index 186bebfc..e7292ffc 100644 --- a/DSView/pv/sigsession.cpp +++ b/DSView/pv/sigsession.cpp @@ -487,7 +487,6 @@ namespace pv // On real-time mode, create the decode task when capture started. if (is_realtime_mode()) { - de->decoder()->frame_ended(); de->frame_ended(); add_decode_task(de); } @@ -1998,7 +1997,6 @@ namespace pv // If is not the real-time mode, try to create all decode tasks. if (is_realtime_mode() == false){ - de->decoder()->frame_ended(); de->frame_ended(); add_decode_task(de); } diff --git a/DSView/pv/view/decodetrace.cpp b/DSView/pv/view/decodetrace.cpp index 0e22122a..be18874c 100644 --- a/DSView/pv/view/decodetrace.cpp +++ b/DSView/pv/view/decodetrace.cpp @@ -663,6 +663,8 @@ void DecodeTrace::frame_ended() _decode_cursor2 = 0; } + decoder()->frame_ended(); + for(auto dec : _decoder_stack->stack()) { dec->set_decode_region(_decode_start, _decode_end); dec->commit();