reduce pixel width for fast scan lines

pull/11/head
Ahmet Inan 2024-04-25 13:30:52 +02:00
rodzic 7766ee26ba
commit e1cebdab3c
2 zmienionych plików z 11 dodań i 2 usunięć

Wyświetl plik

@ -66,7 +66,7 @@ public class Decoder {
double scanLineToleranceSeconds = 0.001;
scanLineToleranceSamples = (int) Math.round(scanLineToleranceSeconds * sampleRate);
scanLineReserveSamples = sampleRate;
rawMode = new RawDecoder();
rawMode = new RawDecoder(sampleRate);
lastMode = rawMode;
lastScanLineSamples = (int) Math.round(0.150 * sampleRate);
syncPulse5msModes = new ArrayList<>();

Wyświetl plik

@ -8,8 +8,12 @@ package xdsopl.robot36;
public class RawDecoder implements Mode {
private final ExponentialMovingAverage lowPassFilter;
private final int smallPictureMaxSamples;
private final int mediumPictureMaxSamples;
RawDecoder() {
RawDecoder(int sampleRate) {
smallPictureMaxSamples = (int) Math.round(0.125 * sampleRate);
mediumPictureMaxSamples = (int) Math.round(0.175 * sampleRate);
lowPassFilter = new ExponentialMovingAverage();
}
@ -32,6 +36,10 @@ public class RawDecoder implements Mode {
if (syncPulseIndex < 0 || syncPulseIndex + scanLineSamples > scanLineBuffer.length)
return false;
int horizontalPixels = pixelBuffer.width;
if (scanLineSamples < smallPictureMaxSamples)
horizontalPixels /= 2;
if (scanLineSamples < mediumPictureMaxSamples)
horizontalPixels /= 2;
lowPassFilter.cutoff(horizontalPixels, 2 * scanLineSamples, 2);
lowPassFilter.reset();
for (int i = 0; i < scanLineSamples; ++i)
@ -43,6 +51,7 @@ public class RawDecoder implements Mode {
int position = (i * scanLineSamples) / horizontalPixels;
pixelBuffer.pixels[i] = ColorConverter.GRAY(scratchBuffer[position]);
}
pixelBuffer.width = horizontalPixels;
pixelBuffer.height = 1;
return true;
}