X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fdata%2Flogicsnapshot.cpp;h=e6fd26e33b68f742a8547894487ddf7f719a5bd3;hb=479bcabe6b4d0b1f51984085d9944ce6b03ed07c;hp=5665d35f8c3d58916b3df6ed41c11227f13d39cf;hpb=5cef1ea3c6a3ed3851c631354bf9168a154179dc;p=pulseview.git diff --git a/pv/data/logicsnapshot.cpp b/pv/data/logicsnapshot.cpp index 5665d35f..e6fd26e3 100644 --- a/pv/data/logicsnapshot.cpp +++ b/pv/data/logicsnapshot.cpp @@ -70,14 +70,17 @@ void LogicSnapshot::append_payload( append_payload_to_mipmap(); } -void LogicSnapshot::reallocate_mip_map(MipMapLevel &m) +void LogicSnapshot::reallocate_mipmap_level(MipMapLevel &m) { const uint64_t new_data_length = ((m.length + MipMapDataUnit - 1) / MipMapDataUnit) * MipMapDataUnit; if (new_data_length > m.data_length) { m.data_length = new_data_length; - m.data = realloc(m.data, new_data_length * _unit_size); + + // Padding is added to allow for the uint64_t write word + m.data = realloc(m.data, new_data_length * _unit_size + + sizeof(uint64_t)); } } @@ -98,14 +101,12 @@ void LogicSnapshot::append_payload_to_mipmap() if (m0.length == prev_length) return; - reallocate_mip_map(m0); + reallocate_mipmap_level(m0); dest_ptr = (uint8_t*)m0.data + prev_length * _unit_size; // Iterate through the samples to populate the first level mipmap - accumulator = 0; - diff_counter = MipMapScaleFactor; - const uint8_t *end_src_ptr = (uint8_t*)_data + + const uint8_t *const end_src_ptr = (uint8_t*)_data + m0.length * _unit_size * MipMapScaleFactor; for (src_ptr = (uint8_t*)_data + prev_length * _unit_size * MipMapScaleFactor; @@ -140,12 +141,12 @@ void LogicSnapshot::append_payload_to_mipmap() if (m.length == prev_length) break; - reallocate_mip_map(m); + reallocate_mipmap_level(m); // Subsample the level lower level src_ptr = (uint8_t*)ml.data + _unit_size * prev_length * MipMapScaleFactor; - const uint8_t *end_dest_ptr = + const uint8_t *const end_dest_ptr = (uint8_t*)m.data + _unit_size * m.length; for (dest_ptr = (uint8_t*)m.data + _unit_size * prev_length; @@ -204,7 +205,10 @@ void LogicSnapshot::get_subsampled_edges( { //----- Continue to search -----// level = min_level; - fast_forward = true; + + // We cannot fast-forward if there is no mip-map data at + // at the minimum level. + fast_forward = (_mip_map[level].data != NULL); if (min_length < MipMapScaleFactor) { @@ -241,7 +245,8 @@ void LogicSnapshot::get_subsampled_edges( // We can fast forward only if there was no change const bool sample = (get_sample(index) & sig_mask) != 0; - fast_forward = last_sample == sample; + if (last_sample != sample) + fast_forward = false; } if (fast_forward) {