mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2025-01-23 13:42:55 +08:00
fix: Store the data on loop mode,but can't restore the wave from file
This commit is contained in:
parent
2a2a8e4df6
commit
1b0d714fee
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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<QLabel*>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user