]> sigrok.org Git - pulseview.git/blobdiff - logicdatasnapshot.cpp
Added LogicDataSnapshot::get_subsample helper function
[pulseview.git] / logicdatasnapshot.cpp
index 5301abf59d04d6920892a5b6bfaa143ebf04c9ad..9cc7819f2b178a9ba4ca2df2bec128607164da56 100644 (file)
@@ -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,6 +321,14 @@ void LogicDataSnapshot::get_subsampled_edges(
                get_sample(end) & sig_mask));
 }
 
+uint64_t LogicDataSnapshot::get_subsample(int level, uint64_t offset) const
+{
+       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;