only shift if possible

pull/11/head
Ahmet Inan 2024-04-21 06:41:48 +02:00
rodzic 844dc6a0b3
commit 38f0521158
1 zmienionych plików z 11 dodań i 8 usunięć

Wyświetl plik

@ -145,14 +145,17 @@ public class Decoder {
}
for (int i = 0; i < lines.length; ++i)
copyLines(mode.decodeScanLine(evenBuffer, oddBuffer, scanLineBuffer, pulses[i], lines[i]));
int shift = pulses[pulses.length - 1] - (meanSamples * 3) / 4;
adjustSyncPulses(last5msSyncPulses, shift);
adjustSyncPulses(last9msSyncPulses, shift);
adjustSyncPulses(last20msSyncPulses, shift);
int endSample = curSample;
curSample = 0;
for (int i = shift; i < endSample; ++i)
scanLineBuffer[curSample++] = scanLineBuffer[i];
int reserve = (meanSamples * 3) / 4;
int shift = pulses[pulses.length - 1] - reserve;
if (shift > reserve) {
adjustSyncPulses(last5msSyncPulses, shift);
adjustSyncPulses(last9msSyncPulses, shift);
adjustSyncPulses(last20msSyncPulses, shift);
int endSample = curSample;
curSample = 0;
for (int i = shift; i < endSample; ++i)
scanLineBuffer[curSample++] = scanLineBuffer[i];
}
return true;
}