1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-27 15:26:33 -04:00

GLScope redesign: ScopeVis: call processTrace method with multiple input iterator and length

This commit is contained in:
f4exb 2021-05-31 14:30:10 +02:00
parent 3908599463
commit ef4a13f31d
2 changed files with 41 additions and 30 deletions

View File

@ -240,46 +240,51 @@ void ScopeVis::feed(const std::vector<SampleVector::const_iterator>& vbegin, int
return;
}
const SampleVector::const_iterator& cbegin = vbegin[0];
const SampleVector::const_iterator end = cbegin + nbSamples;
if (m_freeRun) {
m_triggerLocation = end - cbegin;
m_triggerLocation = nbSamples;
}
else if (m_triggerState == TriggerTriggered) {
m_triggerLocation = end - cbegin;
m_triggerLocation = nbSamples;
}
else if (m_triggerState == TriggerUntriggered) {
m_triggerLocation = 0;
}
else {
m_triggerLocation = end - cbegin;
m_triggerLocation = nbSamples;
}
SampleVector::const_iterator begin(cbegin);
SampleVector::const_iterator begin(vbegin[0]);
//const SampleVector::const_iterator end = vbegin[0] + nbSamples;
int triggerPointToEnd;
int remainder = nbSamples;
std::vector<SampleVector::const_iterator> nvbegin(vbegin);
while (begin < end)
//while (begin < end)
while (remainder > 0)
{
if (end - begin < m_traceSize) // buffer smaller than trace size (end - bagin) < m_traceSize
if (remainder < (int) m_traceSize) // buffer smaller than trace size (end - bagin) < m_traceSize
{
triggerPointToEnd = -1;
processTrace(begin, end, triggerPointToEnd); // use all buffer
processTrace(nvbegin, remainder, triggerPointToEnd); // use all buffer
m_triggerLocation = triggerPointToEnd < 0 ? 0 : triggerPointToEnd; // trim negative values
m_triggerLocation = m_triggerLocation > end - begin ? end - begin : m_triggerLocation; // trim past begin values
m_triggerLocation = m_triggerLocation > remainder ? remainder : m_triggerLocation; // trim past begin values
begin = end; // effectively breaks out the loop
remainder = 0; // effectively breaks out the loop
}
else // trace size fits in buffer
{
triggerPointToEnd = -1;
processTrace(begin, begin + m_traceSize, triggerPointToEnd); // use part of buffer to fit trace size
processTrace(nvbegin, m_traceSize, triggerPointToEnd); // use part of buffer to fit trace size
//m_triggerPoint = begin + m_traceSize - triggerPointToEnd;
m_triggerLocation = end - begin + m_traceSize - triggerPointToEnd; // should always refer to end iterator
m_triggerLocation = remainder + m_traceSize - triggerPointToEnd; // should always refer to end iterator
m_triggerLocation = m_triggerLocation < 0 ? 0 : m_triggerLocation; // trim negative values
m_triggerLocation = m_triggerLocation > end - begin ? end - begin : m_triggerLocation; // trim past begin values
m_triggerLocation = m_triggerLocation > remainder ? remainder : m_triggerLocation; // trim past begin values
begin += m_traceSize;
for (auto begin : nvbegin) {
begin += m_traceSize;
}
remainder -= m_traceSize;
}
}
@ -306,13 +311,14 @@ void ScopeVis::processMemoryTrace()
}
}
void ScopeVis::processTrace(const SampleVector::const_iterator& cbegin, const SampleVector::const_iterator& end, int& triggerPointToEnd)
void ScopeVis::processTrace(const std::vector<SampleVector::const_iterator>& vbegin, int length, int& triggerPointToEnd)
{
SampleVector::const_iterator begin(cbegin);
SampleVector::const_iterator begin(vbegin[0]);
const SampleVector::const_iterator end(begin + length);
// memory storage
m_traceDiscreteMemory.current().write(cbegin, end);
m_traceDiscreteMemory.current().write(begin, end);
// Removed in 4.2.4 may cause trigger bug
// if (m_traceDiscreteMemory.current().absoluteFill() < m_traceSize)
@ -450,7 +456,10 @@ void ScopeVis::processTrace(const SampleVector::const_iterator& cbegin, const Sa
{
int mTriggerPointToEnd = -1;
processTrace(mbegin, mend, mTriggerPointToEnd);
// FIXME:
std::vector<SampleVector::const_iterator> vbegin;
vbegin.push_back(mbegin);
processTrace(vbegin, remainder, mTriggerPointToEnd);
if (mTriggerPointToEnd >= 0) {
triggerPointToEnd = mTriggerPointToEnd;

View File

@ -530,31 +530,33 @@ private:
TraceBuffer m_traceBuffer;
SampleVector::iterator m_endPoint;
TraceBackBuffer()
{
TraceBackBuffer() {
m_endPoint = m_traceBuffer.getCurrent();
}
void resize(uint32_t size)
{
void resize(uint32_t size) {
m_traceBuffer.resize(size);
}
void reset()
{
void reset() {
m_traceBuffer.reset();
}
void write(const SampleVector::const_iterator begin, const SampleVector::const_iterator end)
{
void write(const SampleVector::const_iterator begin, const SampleVector::const_iterator end) {
m_traceBuffer.write(begin, end);
}
void write(const SampleVector::const_iterator begin, int nbSamples) {
m_traceBuffer.write(begin, begin + nbSamples);
}
unsigned int absoluteFill() const {
return m_traceBuffer.absoluteFill();
}
SampleVector::iterator current() { return m_traceBuffer.getCurrent(); }
SampleVector::iterator current() {
return m_traceBuffer.getCurrent();
}
QByteArray serialize() const
{
@ -1065,7 +1067,7 @@ private:
/**
* Process a sample trace which length is at most the trace length (m_traceSize)
*/
void processTrace(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, int& triggerPointToEnd);
void processTrace(const std::vector<SampleVector::const_iterator>& vbegin, int length, int& triggerPointToEnd);
/**
* process a trace in memory at current trace index in memory