kopia lustrzana https://github.com/xdsopl/robot36
be consistent with begin and end samples
rodzic
68ff54c214
commit
00a9ddb21a
|
@ -9,11 +9,12 @@ package xdsopl.robot36;
|
|||
public class PaulDon implements Mode {
|
||||
private final int scanLineSamples;
|
||||
private final int channelSamples;
|
||||
private final int beginSamples;
|
||||
private final int yEvenBeginSamples;
|
||||
private final int vAvgBeginSamples;
|
||||
private final int uAvgBeginSamples;
|
||||
private final int yOddBeginSamples;
|
||||
private final int yOddEndSamples;
|
||||
private final int endSamples;
|
||||
private final String name;
|
||||
|
||||
PaulDon(String name, double channelSeconds, int sampleRate) {
|
||||
|
@ -25,6 +26,7 @@ public class PaulDon implements Mode {
|
|||
channelSamples = (int) Math.round(channelSeconds * sampleRate);
|
||||
double yEvenBeginSeconds = syncPulseSeconds / 2 + syncPorchSeconds;
|
||||
yEvenBeginSamples = (int) Math.round(yEvenBeginSeconds * sampleRate);
|
||||
beginSamples = yEvenBeginSamples;
|
||||
double vAvgBeginSeconds = yEvenBeginSeconds + channelSeconds;
|
||||
vAvgBeginSamples = (int) Math.round(vAvgBeginSeconds * sampleRate);
|
||||
double uAvgBeginSeconds = vAvgBeginSeconds + channelSeconds;
|
||||
|
@ -32,7 +34,7 @@ public class PaulDon implements Mode {
|
|||
double yOddBeginSeconds = uAvgBeginSeconds + channelSeconds;
|
||||
yOddBeginSamples = (int) Math.round(yOddBeginSeconds * sampleRate);
|
||||
double yOddEndSeconds = yOddBeginSeconds + channelSeconds;
|
||||
yOddEndSamples = (int) Math.round(yOddEndSeconds * sampleRate);
|
||||
endSamples = (int) Math.round(yOddEndSeconds * sampleRate);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,7 +49,7 @@ public class PaulDon implements Mode {
|
|||
|
||||
@Override
|
||||
public int decodeScanLine(int[] evenBuffer, int[] oddBuffer, float[] scanLineBuffer, int prevPulseIndex, int scanLineSamples) {
|
||||
if (prevPulseIndex + yEvenBeginSamples < 0 || prevPulseIndex + yOddEndSamples > scanLineBuffer.length)
|
||||
if (prevPulseIndex + beginSamples < 0 || prevPulseIndex + endSamples > scanLineBuffer.length)
|
||||
return 0;
|
||||
for (int i = 0; i < evenBuffer.length; ++i) {
|
||||
int position = (i * channelSamples) / evenBuffer.length + prevPulseIndex;
|
||||
|
|
|
@ -23,7 +23,7 @@ public class RawDecoder implements Mode {
|
|||
|
||||
@Override
|
||||
public int decodeScanLine(int[] evenBuffer, int[] oddBuffer, float[] scanLineBuffer, int prevPulseIndex, int scanLineSamples) {
|
||||
if (prevPulseIndex < 0 || prevPulseIndex + scanLineSamples >= scanLineBuffer.length)
|
||||
if (prevPulseIndex < 0 || prevPulseIndex + scanLineSamples > scanLineBuffer.length)
|
||||
return 0;
|
||||
for (int i = 0; i < evenBuffer.length; ++i) {
|
||||
int position = (i * scanLineSamples) / evenBuffer.length + prevPulseIndex;
|
||||
|
|
|
@ -10,10 +10,11 @@ public class Robot_72_Color implements Mode {
|
|||
private final int scanLineSamples;
|
||||
private final int luminanceSamples;
|
||||
private final int chrominanceSamples;
|
||||
private final int beginSamples;
|
||||
private final int yBeginSamples;
|
||||
private final int vBeginSamples;
|
||||
private final int uBeginSamples;
|
||||
private final int uEndSamples;
|
||||
private final int endSamples;
|
||||
|
||||
Robot_72_Color(int sampleRate) {
|
||||
double syncPulseSeconds = 0.009;
|
||||
|
@ -28,6 +29,7 @@ public class Robot_72_Color implements Mode {
|
|||
chrominanceSamples = (int) Math.round(chrominanceSeconds * sampleRate);
|
||||
double yBeginSeconds = syncPulseSeconds / 2 + syncPorchSeconds;
|
||||
yBeginSamples = (int) Math.round(yBeginSeconds * sampleRate);
|
||||
beginSamples = yBeginSamples;
|
||||
double yEndSeconds = yBeginSeconds + luminanceSeconds;
|
||||
double vBeginSeconds = yEndSeconds + separatorSeconds + porchSeconds;
|
||||
vBeginSamples = (int) Math.round(vBeginSeconds * sampleRate);
|
||||
|
@ -35,7 +37,7 @@ public class Robot_72_Color implements Mode {
|
|||
double uBeginSeconds = vEndSeconds + separatorSeconds + porchSeconds;
|
||||
uBeginSamples = (int) Math.round(uBeginSeconds * sampleRate);
|
||||
double uEndSeconds = uBeginSeconds + chrominanceSeconds;
|
||||
uEndSamples = (int) Math.round(uEndSeconds * sampleRate);
|
||||
endSamples = (int) Math.round(uEndSeconds * sampleRate);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,7 +52,7 @@ public class Robot_72_Color implements Mode {
|
|||
|
||||
@Override
|
||||
public int decodeScanLine(int[] evenBuffer, int[] oddBuffer, float[] scanLineBuffer, int prevPulseIndex, int scanLineSamples) {
|
||||
if (prevPulseIndex + yBeginSamples < 0 || prevPulseIndex + uEndSamples > scanLineBuffer.length)
|
||||
if (prevPulseIndex + beginSamples < 0 || prevPulseIndex + endSamples > scanLineBuffer.length)
|
||||
return 0;
|
||||
for (int i = 0; i < evenBuffer.length; ++i) {
|
||||
int yPos = yBeginSamples + (i * luminanceSamples) / evenBuffer.length + prevPulseIndex;
|
||||
|
|
Ładowanie…
Reference in New Issue