diff --git a/DSView/pv/data/logicsnapshot.cpp b/DSView/pv/data/logicsnapshot.cpp index f50fd8f0..a58bd06e 100644 --- a/DSView/pv/data/logicsnapshot.cpp +++ b/DSView/pv/data/logicsnapshot.cpp @@ -1171,22 +1171,56 @@ bool LogicSnapshot::has_data(int sig_index) int LogicSnapshot::get_block_num() { - return (_ring_sample_count >> LeafBlockPower) + - ((_ring_sample_count & LeafMask) != 0); + // return (_ring_sample_count >> LeafBlockPower) + + // ((_ring_sample_count & LeafMask) != 0); + + int block = _ring_sample_count / LeafBlockSamples; + if (_ring_sample_count % LeafBlockSamples != 0){ + block++; + } + if (_loop_offset % LeafBlockSamples != 0){ + block++; + } + + return block; } uint64_t LogicSnapshot::get_block_size(int block_index) { - assert(block_index < get_block_num()); + int block_num = get_block_num(); - if (block_index < get_block_num() - 1) { - return LeafBlockSamples / 8; - } else { - if (_ring_sample_count % LeafBlockSamples == 0) + assert(block_index < block_num); + + if (_loop_offset > 0) + { + if (block_index > 0 && block_index < block_num - 1) { return LeafBlockSamples / 8; - else - return (_ring_sample_count % LeafBlockSamples) / 8; + } + else if (block_index == 0){ + if (_loop_offset % LeafBlockSamples == 0) + return LeafBlockSamples / 8; + else + return (LeafBlockSamples - _loop_offset % LeafBlockSamples) / 8; + } + else{ + uint64_t ring_sample_count = _ring_sample_count + _loop_offset; + if (ring_sample_count % LeafBlockSamples == 0) + return LeafBlockSamples / 8; + else + return (ring_sample_count % LeafBlockSamples) / 8; + } } + else{ + if (block_index < block_num - 1) { + return LeafBlockSamples / 8; + } + else { + if (_ring_sample_count % LeafBlockSamples == 0) + return LeafBlockSamples / 8; + else + return (_ring_sample_count % LeafBlockSamples) / 8; + } + } } uint8_t *LogicSnapshot::get_block_buf(int block_index, int sig_index, bool &sample) @@ -1198,6 +1232,10 @@ uint8_t *LogicSnapshot::get_block_buf(int block_index, int sig_index, bool &samp sample = 0; return NULL; } + + int block_index0 = block_index; + block_index += _loop_offset / LeafBlockSamples; + uint64_t index = block_index / RootScale; uint8_t pos = block_index % RootScale; uint8_t *lbp = (uint8_t*)_ch_data[order][index].lbp[pos]; @@ -1205,6 +1243,11 @@ uint8_t *LogicSnapshot::get_block_buf(int block_index, int sig_index, bool &samp if (lbp == NULL) sample = (_ch_data[order][index].value & 1ULL << pos) != 0; + if (lbp != NULL && _loop_offset > 0 && block_index0 == 0) + { + lbp += (_loop_offset % LeafBlockSamples) / 8; + } + return lbp; } diff --git a/DSView/pv/storesession.cpp b/DSView/pv/storesession.cpp index cda11e4b..16fa4b55 100644 --- a/DSView/pv/storesession.cpp +++ b/DSView/pv/storesession.cpp @@ -225,6 +225,7 @@ void StoreSession::save_logic(pv::data::LogicSnapshot *logic_snapshot) _unit_count = logic_snapshot->get_sample_count() / 8 * to_save_probes; num = logic_snapshot->get_block_num(); + dsv_info("total bytes:%llu", _unit_count); for(auto s : _session->get_signals()) { @@ -238,6 +239,7 @@ void StoreSession::save_logic(pv::data::LogicSnapshot *logic_snapshot) uint8_t *buf = logic_snapshot->get_block_buf(i, ch_index, sample); uint64_t size = logic_snapshot->get_block_size(i); bool need_malloc = (buf == NULL); + if (need_malloc) { buf = (uint8_t *)malloc(size); if (buf == NULL) { @@ -264,6 +266,8 @@ void StoreSession::save_logic(pv::data::LogicSnapshot *logic_snapshot) return; } _units_stored += size; + dsv_info("read bytes:%llu, size:%llu,block:%d", _units_stored, size, i); + if (need_malloc) free(buf); progress_updated(); diff --git a/DSView/pv/ui/fun.cpp b/DSView/pv/ui/fun.cpp index 6e3b721a..27a8b545 100644 --- a/DSView/pv/ui/fun.cpp +++ b/DSView/pv/ui/fun.cpp @@ -98,9 +98,6 @@ namespace ui for(auto o : comboxs) { o->setFont(font); - - // int h = o->sizeHint().height() + 50; - //o->setMinimumHeight(h); } auto labels = wid->findChildren();