preserve scope position on decoder reconstruction

pull/11/head
Ahmet Inan 2024-04-25 18:43:03 +02:00
rodzic 8325abf6a2
commit cdf12d2c09
3 zmienionych plików z 8 dodań i 7 usunięć

Wyświetl plik

@ -34,7 +34,6 @@ public class Decoder {
private final ArrayList<Mode> syncPulse20msModes;
public Mode lastMode;
public int curLine;
private int curSample;
private int lastSyncPulseIndex;
private int lastScanLineSamples;
@ -135,11 +134,11 @@ public class Decoder {
if (!okay)
return;
for (int row = 0; row < pixelBuffer.height; ++row) {
System.arraycopy(pixelBuffer.pixels, row * pixelBuffer.width, scopeBuffer.pixels, scopeBuffer.width * curLine, pixelBuffer.width);
Arrays.fill(scopeBuffer.pixels, scopeBuffer.width * curLine + pixelBuffer.width, scopeBuffer.width * curLine + scopeBuffer.width, 0);
System.arraycopy(pixelBuffer.pixels, row * pixelBuffer.width, scopeBuffer.pixels, scopeBuffer.width * (curLine + scopeBuffer.height / 2), pixelBuffer.width);
Arrays.fill(scopeBuffer.pixels, scopeBuffer.width * (curLine + scopeBuffer.height / 2) + pixelBuffer.width, scopeBuffer.width * (curLine + scopeBuffer.height / 2) + scopeBuffer.width, 0);
curLine = (curLine + 1) % (scopeBuffer.height / 2);
System.arraycopy(pixelBuffer.pixels, row * pixelBuffer.width, scopeBuffer.pixels, scopeBuffer.width * scopeBuffer.line, pixelBuffer.width);
Arrays.fill(scopeBuffer.pixels, scopeBuffer.width * scopeBuffer.line + pixelBuffer.width, scopeBuffer.width * scopeBuffer.line + scopeBuffer.width, 0);
System.arraycopy(pixelBuffer.pixels, row * pixelBuffer.width, scopeBuffer.pixels, scopeBuffer.width * (scopeBuffer.line + scopeBuffer.height / 2), pixelBuffer.width);
Arrays.fill(scopeBuffer.pixels, scopeBuffer.width * (scopeBuffer.line + scopeBuffer.height / 2) + pixelBuffer.width, scopeBuffer.width * (scopeBuffer.line + scopeBuffer.height / 2) + scopeBuffer.width, 0);
scopeBuffer.line = (scopeBuffer.line + 1) % (scopeBuffer.height / 2);
}
}

Wyświetl plik

@ -62,7 +62,7 @@ public class MainActivity extends AppCompatActivity {
public void onPeriodicNotification(AudioRecord audioRecord) {
audioRecord.read(recordBuffer, 0, recordBuffer.length, AudioRecord.READ_BLOCKING);
if (decoder.process(recordBuffer, recordChannel)) {
scopeBitmap.setPixels(scopeBuffer.pixels, scopeBuffer.width * decoder.curLine, scopeBuffer.width, 0, 0, scopeBuffer.width, scopeBuffer.height / 2);
scopeBitmap.setPixels(scopeBuffer.pixels, scopeBuffer.width * scopeBuffer.line, scopeBuffer.width, 0, 0, scopeBuffer.width, scopeBuffer.height / 2);
scopeView.invalidate();
setStatus(decoder.lastMode.getName());
}

Wyświetl plik

@ -10,10 +10,12 @@ public class PixelBuffer {
public int[] pixels;
public int width;
public int height;
public int line;
PixelBuffer(int width, int height) {
this.width = width;
this.height = height;
this.line = 0;
this.pixels = new int[width * height];
}
}