mirror of
https://github.com/xdsopl/robot36.git
synced 2026-01-10 10:09:59 +01:00
added decoder for Martin
This commit is contained in:
parent
4f716e76a5
commit
b68a66b4ce
|
|
@ -8,6 +8,11 @@ package xdsopl.robot36;
|
|||
|
||||
public class Martin implements Mode {
|
||||
private final int scanLineSamples;
|
||||
private final int channelSamples;
|
||||
private final int greenBeginSamples;
|
||||
private final int blueBeginSamples;
|
||||
private final int redBeginSamples;
|
||||
private final int redEndSamples;
|
||||
private final String name;
|
||||
|
||||
Martin(String name, double channelSeconds, int sampleRate) {
|
||||
|
|
@ -16,6 +21,17 @@ public class Martin implements Mode {
|
|||
double separatorSeconds = 0.000572;
|
||||
double scanLineSeconds = syncPulseSeconds + separatorSeconds + 3 * (channelSeconds + separatorSeconds);
|
||||
scanLineSamples = (int) Math.round(scanLineSeconds * sampleRate);
|
||||
channelSamples = (int) Math.round(channelSeconds * sampleRate);
|
||||
double greenBeginSeconds = syncPulseSeconds / 2 + separatorSeconds;
|
||||
greenBeginSamples = (int) Math.round(greenBeginSeconds * sampleRate);
|
||||
double greenEndSeconds = greenBeginSeconds + channelSeconds;
|
||||
double blueBeginSeconds = greenEndSeconds + separatorSeconds;
|
||||
blueBeginSamples = (int) Math.round(blueBeginSeconds * sampleRate);
|
||||
double blueEndSeconds = blueBeginSeconds + channelSeconds;
|
||||
double redBeginSeconds = blueEndSeconds + separatorSeconds;
|
||||
redBeginSamples = (int) Math.round(redBeginSeconds * sampleRate);
|
||||
double redEndSeconds = redBeginSeconds + channelSeconds;
|
||||
redEndSamples = (int) Math.round(redEndSeconds * sampleRate);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -29,13 +45,18 @@ public class Martin implements Mode {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean decodeScanLine(int[] pixelBuffer, float[] scanLineBuffer, int prevPulseIndex, int scanLineSamples) {
|
||||
if (prevPulseIndex < 0 || prevPulseIndex + scanLineSamples >= scanLineBuffer.length)
|
||||
public boolean decodeScanLine(int[] pixelBuffer, float[] scanLineBuffer, int prevPulseIndex, int ignore) {
|
||||
if (prevPulseIndex + greenBeginSamples < 0 || prevPulseIndex + redEndSamples > scanLineBuffer.length)
|
||||
return false;
|
||||
for (int i = 0; i < pixelBuffer.length; ++i) {
|
||||
int position = (i * scanLineSamples) / pixelBuffer.length + prevPulseIndex;
|
||||
int intensity = (int) Math.round(255 * Math.sqrt(scanLineBuffer[position]));
|
||||
int pixelColor = 0xff000000 | 0x00010101 * intensity;
|
||||
int position = (i * channelSamples) / pixelBuffer.length + prevPulseIndex;
|
||||
int greenPos = position + greenBeginSamples;
|
||||
int bluePos = position + blueBeginSamples;
|
||||
int redPos = position + redBeginSamples;
|
||||
int green = Math.round(255 * scanLineBuffer[greenPos]);
|
||||
int blue = Math.round(255 * scanLineBuffer[bluePos]);
|
||||
int red = Math.round(255 * scanLineBuffer[redPos]);
|
||||
int pixelColor = 0xff000000 | (red << 16) | (green << 8) | blue;
|
||||
pixelBuffer[i] = pixelColor;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue