Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5265d8311585
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 299eaac2ecbd
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on May 12, 2020

  1. Copy the full SHA
    cd646d0 View commit details
  2. Copy the full SHA
    299eaac View commit details
Showing with 40 additions and 41 deletions.
  1. +40 −41 scopeprotocols/EyeDecoder2.cpp
81 changes: 40 additions & 41 deletions scopeprotocols/EyeDecoder2.cpp
Original file line number Diff line number Diff line change
@@ -106,30 +106,6 @@ void EyeCapture2::Normalize()

for(size_t i=0; i<len; i++)
m_outdata[i] = m_accumdata[i] * norm;

//Once the output is normalized, check for any rows with no bin hits due to roundoff and interpolate into them.
for(size_t y=1; y+1 < m_height; y++)
{
bool empty = true;
for(size_t x=0; x<m_width; x++)
{
if(m_accumdata[y*m_width + x])
{
empty = false;
break;
}
}

if(empty)
{
for(size_t x=0; x<m_width; x++)
{
float out1 = m_outdata[(y-1)*m_width + x];
float out2 = m_outdata[(y+1)*m_width + x];
m_outdata[y*m_width + x] = (out1 + out2) / 2;
}
}
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -393,11 +369,16 @@ void EyeDecoder2::Refresh()
double awidth = 0;
int64_t nwidth = 0;
float yscale = m_height / m_channels[0]->GetVoltageRange();
int64_t hwidth = m_width / 2;
float fwidth = m_width / 2.0f;
float ymid = m_height / 2;
for(auto& samp : waveform->m_samples)
float yoff = -center*yscale + ymid;
for(size_t i=0; i<waveform->m_samples.size()-1; i++)
{
//Stop when we get to the end
auto& samp = waveform->m_samples[i];
auto& nsamp = waveform->m_samples[i+1];

//Stop when we get to the end of the clock
if(iclock + 1 >= clock->GetDepth())
break;

@@ -408,10 +389,9 @@ void EyeDecoder2::Refresh()
awidth += twidth;
nwidth ++;

//Find time of this sample
int64_t tstart = samp.m_offset * waveform->m_timescale + waveform->m_triggerPhase;

//Find time of this sample.
//If it's past the end of the current UI, increment the clock
int64_t tstart = samp.m_offset * waveform->m_timescale + waveform->m_triggerPhase;
int64_t offset = tstart - tclock;
if(offset < 0)
continue;
@@ -420,13 +400,6 @@ void EyeDecoder2::Refresh()
iclock ++;
offset -= twidth;
}
//LogDebug("offset = %ld, twidth = %ld\n",offset, twidth);

//Find (and sanity check) the Y coordinate
size_t pixel_y = round( ((samp.m_sample - center) * yscale) + ymid );
if(pixel_y >= m_height)
continue;
int64_t* row = data + pixel_y*m_width;

//Sampling clock is the middle of the UI, not the start.
//Anything more than half a UI right of the clock is negative.
@@ -436,15 +409,41 @@ void EyeDecoder2::Refresh()
if(offset < -halfwidth)
continue;

//Interpolate voltage
int64_t dt = (nsamp.m_offset - samp.m_offset) * waveform->m_timescale;
float scale = fwidth / twidth;
float pixel_x_f = offset * scale;
float pixel_x_fround = floor(pixel_x_f);
float dx_frac = (pixel_x_f - pixel_x_fround ) / (dt * scale );
int64_t pixel_x_round = pixel_x_fround + hwidth;

float dv = nsamp.m_sample - samp.m_sample;
float nominal_voltage = samp.m_sample + dv*dx_frac;

//Find (and sanity check) the Y coordinate
float nominal_pixel_y = nominal_voltage*yscale + yoff;
size_t y1 = floor(nominal_pixel_y);
if((y1+1) >= m_height)
continue;

//Calculate how much of the pixel's intensity to put in each row
float yfrac = nominal_pixel_y - y1;
int bin2 = yfrac*64;
int bin1 = 64-bin2;
int64_t* row1 = data + y1*m_width;
int64_t* row2 = row1 + m_width;

//Plot each point 3 times for center/left/right portions of the eye
//Map -twidth to +twidth to 0...m_width
int64_t xpos[] = {offset, offset + twidth, -twidth + offset };
float scale = fwidth / twidth;
int64_t tscale = round(twidth*scale);
int64_t xpos[] = {pixel_x_round, pixel_x_round + tscale, -tscale + pixel_x_round};
for(auto x : xpos)
{
size_t pixel_x = round((x + twidth) * scale);
if(pixel_x < m_width)
row[pixel_x] ++;
if( (x < (int64_t)m_width) && (x >= 0) )
{
row1[x] += bin1;
row2[x] += bin2;
}
}
}
m_uiWidth = round(awidth / nwidth);