X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Flogicdatasnapshot.cpp;h=1799c2f418f14daf27670d9f06b4b8549442ac8a;hp=2b3e8cae7c06b4e8c3e125a941d2d2cb865c5f4c;hb=e3374498baf2b2a05889cab370442ff326b390b3;hpb=cef18fc6160f8f5055f2617fbe06eb082c2a7bd5 diff --git a/pv/logicdatasnapshot.cpp b/pv/logicdatasnapshot.cpp index 2b3e8cae..1799c2f4 100644 --- a/pv/logicdatasnapshot.cpp +++ b/pv/logicdatasnapshot.cpp @@ -121,7 +121,7 @@ void LogicDataSnapshot::append_payload_to_mipmap() } // Compute higher level mipmaps - for(int level = 1; level < ScaleStepCount; level++) + for(unsigned int level = 1; level < ScaleStepCount; level++) { MipMapLevel &m = _mip_map[level]; const MipMapLevel &ml = _mip_map[level-1]; @@ -169,11 +169,11 @@ uint64_t LogicDataSnapshot::get_sample(uint64_t index) const void LogicDataSnapshot::get_subsampled_edges( std::vector &edges, - int64_t start, int64_t end, + uint64_t start, uint64_t end, float min_length, int sig_index) { - int64_t index = start; - int level; + uint64_t index = start; + unsigned int level; bool last_sample; bool fast_forward; @@ -184,8 +184,8 @@ void LogicDataSnapshot::get_subsampled_edges( assert(sig_index >= 0); assert(sig_index < SR_MAX_NUM_PROBES); - const int64_t block_length = (int64_t)max(min_length, 1.0f); - const int min_level = max((int)floorf(logf(min_length) / + const uint64_t block_length = (uint64_t)max(min_length, 1.0f); + const unsigned int min_level = max((int)floorf(logf(min_length) / LogMipMapScaleFactor) - 1, 0); const uint64_t sig_mask = 1ULL << sig_index; @@ -206,8 +206,7 @@ void LogicDataSnapshot::get_subsampled_edges( const uint64_t final_index = min(end, pow2_ceil(index, MipMapScalePower)); - for(index; - index < final_index && + for(; index < final_index && (index & ~(~0 << MipMapScalePower)) != 0; index++) { @@ -312,7 +311,7 @@ void LogicDataSnapshot::get_subsampled_edges( // do a linear search for the next transition within the // block if(min_length < MipMapScaleFactor) { - for(index; index < end; index++) { + for(; index < end; index++) { const bool sample = (get_sample(index) & sig_mask) != 0; if(sample != last_sample) @@ -350,10 +349,10 @@ uint64_t LogicDataSnapshot::get_subsample(int level, uint64_t offset) const _unit_size * offset); } -int64_t LogicDataSnapshot::pow2_ceil(int64_t x, unsigned int power) +uint64_t LogicDataSnapshot::pow2_ceil(uint64_t x, unsigned int power) { - const int64_t p = 1 << power; - return ((x < 0) ? x : (x + p - 1)) / p * p; + const uint64_t p = 1 << power; + return (x + p - 1) / p * p; } } // namespace pv