#include <extdef.h>
#include <cassert>
-#include <cstring>
-#include <cstdlib>
#include <cmath>
+#include <cstdlib>
+#include <cstring>
#include "logic.hpp"
#include "logicsegment.hpp"
using std::recursive_mutex;
using std::max;
using std::min;
-using std::pair;
using std::shared_ptr;
using std::vector;
const int LogicSegment::MipMapScalePower = 4;
const int LogicSegment::MipMapScaleFactor = 1 << MipMapScalePower;
const float LogicSegment::LogMipMapScaleFactor = logf(MipMapScaleFactor);
-const uint64_t LogicSegment::MipMapDataUnit = 64*1024; // bytes
+const uint64_t LogicSegment::MipMapDataUnit = 64 * 1024; // bytes
-LogicSegment::LogicSegment(pv::data::Logic& owner, shared_ptr<sigrok::Logic> data,
+LogicSegment::LogicSegment(pv::data::Logic& owner, unsigned int unit_size,
uint64_t samplerate) :
- Segment(samplerate, data->unit_size()),
+ Segment(samplerate, unit_size),
owner_(owner),
last_append_sample_(0)
{
- lock_guard<recursive_mutex> lock(mutex_);
memset(mip_map_, 0, sizeof(mip_map_));
- append_payload(data);
}
LogicSegment::~LogicSegment()
assert(unit_size_ == logic->unit_size());
assert((logic->data_length() % unit_size_) == 0);
+ append_payload(logic->data_pointer(), logic->data_length());
+}
+
+void LogicSegment::append_payload(void *data, uint64_t data_size)
+{
+ assert((data_size % unit_size_) == 0);
+
lock_guard<recursive_mutex> lock(mutex_);
uint64_t prev_sample_count = sample_count_;
- uint64_t sample_count = logic->data_length() / unit_size_;
+ uint64_t sample_count = data_size / unit_size_;
- append_samples(logic->data_pointer(), sample_count);
+ append_samples(data, sample_count);
// Generate the first mip-map from the data
append_payload_to_mipmap();
lock_guard<recursive_mutex> lock(mutex_);
- return get_raw_samples(start_sample, (end_sample-start_sample));
+ return get_raw_samples(start_sample, (end_sample - start_sample));
}
SegmentLogicDataIterator* LogicSegment::begin_sample_iteration(uint64_t start)
// Compute higher level mipmaps
for (unsigned int level = 1; level < ScaleStepCount; level++) {
MipMapLevel &m = mip_map_[level];
- const MipMapLevel &ml = mip_map_[level-1];
+ const MipMapLevel &ml = mip_map_[level - 1];
// Expand the data buffer to fit the new samples
prev_length = m.length;