X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=logicdatasnapshot.cpp;h=9cc7819f2b178a9ba4ca2df2bec128607164da56;hp=e751b9d1cd6ae3528311913b7a284fdafaa123b2;hb=b2bcbe51febaef24a211ed19bc61408c8fbdc399;hpb=0b02e0578cf750906b20848d98e73b21c23eda42 diff --git a/logicdatasnapshot.cpp b/logicdatasnapshot.cpp index e751b9d1..9cc7819f 100644 --- a/logicdatasnapshot.cpp +++ b/logicdatasnapshot.cpp @@ -233,8 +233,7 @@ void LogicDataSnapshot::get_subsampled_edges( // Check if we reached the last block at this level, // or if there was a change in this block if(offset >= _mip_map[level].length || - (*(uint64_t*)((uint8_t*)_mip_map[level].data + - _unit_size * offset) & sig_mask)) + (get_subsample(level, offset) & sig_mask)) break; if((offset & ~(~0 << MipMapScalePower)) == 0) @@ -268,8 +267,7 @@ void LogicDataSnapshot::get_subsampled_edges( // Check if we reached the last block at this level, // or if there was a change in this block if(offset >= _mip_map[level].length || - (*(uint64_t*)((uint8_t*)_mip_map[level].data + - _unit_size * offset) & sig_mask)) + (get_subsample(level, offset) & sig_mask)) { // Zoom in unless we reached the minimum zoom if(level == min_level) @@ -323,7 +321,16 @@ void LogicDataSnapshot::get_subsampled_edges( get_sample(end) & sig_mask)); } -int64_t LogicDataSnapshot::pow2_ceil(int64_t x, int power) +uint64_t LogicDataSnapshot::get_subsample(int level, uint64_t offset) const { - return ((x >> power) + 1) << power; + assert(level >= 0); + assert(_mip_map[level].data); + return *(uint64_t*)((uint8_t*)_mip_map[level].data + + _unit_size * offset); +} + +int64_t LogicDataSnapshot::pow2_ceil(int64_t x, unsigned int power) +{ + const int64_t p = 1 << power; + return ((x < 0) ? x : (x + p - 1)) / p * p; }