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: 83e4fb3b6fa8
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 927f8bbb5a3f
Choose a head ref
  • 9 commits
  • 1 file changed
  • 1 contributor

Commits on Nov 6, 2020

  1. Copy the full SHA
    33aa903 View commit details
  2. EyePattern: more aggressive early-outs to minimize wasted math. Preco…

    …mputed X time scale multiplication
    azonenberg committed Nov 6, 2020
    Copy the full SHA
    90b268c View commit details
  3. Copy the full SHA
    28b434d View commit details
  4. Copy the full SHA
    9589b34 View commit details
  5. Copy the full SHA
    5a6a6cb View commit details
  6. Copy the full SHA
    4a9ce0d View commit details
  7. Copy the full SHA
    6e744ec View commit details
  8. Copy the full SHA
    1f45579 View commit details
  9. Copy the full SHA
    927f8bb View commit details
Showing with 32 additions and 38 deletions.
  1. +32 −38 scopeprotocols/EyePattern.cpp
70 changes: 32 additions & 38 deletions scopeprotocols/EyePattern.cpp
Original file line number Diff line number Diff line change
@@ -446,79 +446,73 @@ void EyePattern::Refresh()

uint32_t prng = 0xdeadbeef;

//Process the eye
size_t cend = clock_edges.size();
//Precompute some scaling factors
float yscale = m_height / GetVoltageRange();
float ymid = m_height / 2;
float yoff = -center*yscale + ymid;
float xtimescale = waveform->m_timescale * m_xscale;
float xscale_div255 = m_xscale / 255.0f;
float xscale_div2 = m_xscale / 2;

//Process the eye
size_t cend = clock_edges.size() - 1;
size_t iclock = 0;
size_t wend = waveform->m_samples.size()-1;
int64_t ymax = m_height - 1;
int64_t xmax = m_width;
if(m_xscale > FLT_EPSILON)
{
for(size_t i=0; i<wend; i++)
for(size_t i=0; i<wend && iclock < cend; i++)
{
//Stop when we get to the end of the clock
if(iclock + 1 >= cend)
break;

//Find time of this sample.
//If it's past the end of the current UI, move to the next clock edge
int64_t tnext = clock_edges[iclock + 1];
int64_t twidth = tnext - clock_edges[iclock];
int64_t tstart = waveform->m_offsets[i] * waveform->m_timescale + waveform->m_triggerPhase;
int64_t offset = tstart - clock_edges[iclock];
if(offset < -10)
continue;
size_t nextclk = iclock + 1;
int64_t tnext = clock_edges[nextclk];
int64_t twidth = tnext - clock_edges[iclock];
if(offset > twidth)
{
//Move to the next clock edge
iclock ++;
if(iclock + 1 >= cend)
if(iclock >= cend)
break;

//Figure out the offset to the next edge
offset = tstart - tnext;
}

//LogDebug("%zu, %zd\n", i, offset);

//Interpolate voltage
int64_t dt = (waveform->m_offsets[i+1] - waveform->m_offsets[i]) * waveform->m_timescale;
//Antialiasing: jitter the fractional X position by up to 1ps to fill in blank spots
int64_t dt = waveform->m_offsets[i+1] - waveform->m_offsets[i];
float pixel_x_f = (offset - m_xoff) * m_xscale;
float pixel_x_fround = floor(pixel_x_f);
float dv = waveform->m_samples[i+1] - waveform->m_samples[i];
float dx_frac = (pixel_x_f - pixel_x_fround ) / (dt * m_xscale );
float nominal_voltage = waveform->m_samples[i] + dv*dx_frac;

//Antialiasing: jitter the fractional X position by up to 1ps to fill in blank spots
pixel_x_f -= m_xscale * 0.5;
pixel_x_f += (prng & 0xff) * m_xscale / 255.0f;
float dx_frac = (pixel_x_f - pixel_x_fround ) / (dt * xtimescale );
pixel_x_f += (prng & 0xff) * xscale_div255 - xscale_div2;
prng = 0x343fd * prng + 0x269ec3;

//LogDebug("%zu, %zd, %f\n", i, offset, pixel_x_f);
//Early out if off the end of the plot
int64_t pixel_x_round = round(pixel_x_f);
if(pixel_x_round >= xmax)
continue;

//Find (and sanity check) the Y coordinate
//Interpolate voltage, early out if clipping
float dv = waveform->m_samples[i+1] - waveform->m_samples[i];
float nominal_voltage = waveform->m_samples[i] + dv*dx_frac;
float nominal_pixel_y = nominal_voltage*yscale + yoff;
size_t y1 = static_cast<size_t>(nominal_pixel_y);
if(y1 >= (m_height-1))
int64_t y1 = static_cast<size_t>(nominal_pixel_y);
if( (y1 >= ymax) || (y1 < 0) )
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;
float yfrac = nominal_pixel_y - floor(nominal_pixel_y);
int64_t bin2 = yfrac * 64;
int64_t* pix = data + y1*m_width + pixel_x_round;

//Plot each point (this only draws the right half of the eye, we copy to the left later)
int64_t pixel_x_round = round(pixel_x_f);
if( (pixel_x_round+1 < (int64_t)m_width) && (pixel_x_round >= 0) )
{
row1[pixel_x_round+0] += bin1 * dx_frac;
row1[pixel_x_round+1] += bin1 * (1-dx_frac);
row2[pixel_x_round+0] += bin2 * dx_frac;
row2[pixel_x_round+1] += bin2 * (1-dx_frac);
}
pix[0] += 64 - bin2;
pix[m_width] += bin2;
}
}