Skip to content

Commit 9776a55

Browse files
committed
On the frame autobalance
1 parent dcc26f4 commit 9776a55

5 files changed

Lines changed: 30 additions & 23 deletions

File tree

JavaGUI/jni/TSDRLibraryNDK.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ void read_async(float *buf, int width, int height, void *ctx) {
119119
for (i = 0; i < context->pixelsize; i++) {
120120
int col = (inverted) ? (255 - (int) (*(buf++) * 255.0f)) : ((int) (*(buf++) * 255.0f));
121121
if (col > 255) col = 255; else if (col < 0) col = 0;
122-
*(data++) = col | (col << 8) | (col << 16) | (0xFF << 24);
122+
*(data++) = col | (col << 8) | (col << 16);
123123
}
124124

125125
// release elements

JavaGUI/src/martin/tempest/core/TSDRLibrary.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public interface FrameReadyCallback {
209209
*/
210210
private void fixSize(final int x, final int y) {
211211
if (bimage == null || bimage.getWidth() != x || bimage.getHeight() != y) {
212-
bimage = new BufferedImage(x, y, BufferedImage.TYPE_INT_ARGB);
212+
bimage = new BufferedImage(x, y, BufferedImage.TYPE_INT_RGB);
213213
pixels = ((DataBufferInt) bimage.getRaster().getDataBuffer()).getData();
214214
width = x;
215215
height = y;

JavaGUI/src/martin/tempest/gui/Main.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ private void setFrameRate(final double val) {
494494
private void onKeyboardKeyPressed(final KeyEvent e) {
495495
final int keycode = e.getKeyCode();
496496

497-
if (!e.isShiftDown()) {
497+
if (e.isShiftDown()) {
498498
switch (keycode) {
499499
case KeyEvent.VK_LEFT:
500500
btnLeft.doHold();
@@ -515,10 +515,10 @@ private void onKeyboardKeyPressed(final KeyEvent e) {
515515
}
516516
} else {
517517
switch (keycode) {
518-
case KeyEvent.VK_LEFT:
518+
case KeyEvent.VK_RIGHT:
519519
btnHigherFramerate.doHold();
520520
break;
521-
case KeyEvent.VK_RIGHT:
521+
case KeyEvent.VK_LEFT:
522522
btnLowerFramerate.doHold();
523523
break;
524524
case KeyEvent.VK_UP:
@@ -534,7 +534,7 @@ private void onKeyboardKeyPressed(final KeyEvent e) {
534534
private void onKeyboardKeyReleased(final KeyEvent e) {
535535
final int keycode = e.getKeyCode();
536536

537-
if (!e.isShiftDown()) {
537+
if (e.isShiftDown()) {
538538
switch (keycode) {
539539
case KeyEvent.VK_LEFT:
540540
btnLeft.doRelease();
@@ -553,11 +553,11 @@ private void onKeyboardKeyReleased(final KeyEvent e) {
553553
}
554554
} else {
555555
switch (keycode) {
556-
case KeyEvent.VK_LEFT:
556+
case KeyEvent.VK_RIGHT:
557557
btnLeft.doRelease();
558558
btnHigherFramerate.doRelease();
559559
break;
560-
case KeyEvent.VK_RIGHT:
560+
case KeyEvent.VK_LEFT:
561561
btnRight.doRelease();
562562
btnLowerFramerate.doRelease();
563563
break;

TSDRPlugin_Mirics/src/TSDRPlugin_Mirics.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ int tsdrplugin_readasync(tsdrplugin_readasync_function cb, void *ctx) {
7979
err = mir_sdr_ReadPacket(&xi[id*sps], &xq[id*sps], &fs, &grc, &rfc, &fsc);
8080
if (fs > frame)
8181
dropped += fs - frame;
82+
// else if (fs < frame) {
83+
// // wrapped around
84+
// dropped += 2147483647 - frame;
85+
// dropped += fs;
86+
// }
8287
frame = fs + sps;
8388
if (err != 0) break;
8489
}

TempestSDR/src/TSDRLibrary.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,12 @@ void videodecodingthread(void * ctx) {
121121
int sizetopoll = height * width;
122122
float * buffer = (float *) malloc(sizeof(float) * bufsize);
123123
float * screenbuffer = (float *) malloc(sizeof(float) * bufsize);
124-
125-
float pmax, pmin;
124+
for (i = 0; i < bufsize; i++) screenbuffer[i] = 0.0f;
126125

127126
while (context->this->running) {
128-
float max = -9999999999999;
129-
float min = 9999999999999;
130-
const float span = (pmax == pmin) ? (0) : (pmax - pmin);
131-
const float lowpassvalue = context->this->motionblur;
132-
const float antilowpassvalue = 1.0f - lowpassvalue;
127+
128+
const double lowpassvalue = context->this->motionblur;
129+
const double antilowpassvalue = 1.0 - lowpassvalue;
133130

134131
if (context->this->height != height || context->this->width != width) {
135132
height = context->this->height;
@@ -140,22 +137,27 @@ void videodecodingthread(void * ctx) {
140137
bufsize = sizetopoll;
141138
buffer = (float *) realloc(buffer, sizeof(float) * bufsize);
142139
screenbuffer = (float *) realloc(screenbuffer, sizeof(float) * bufsize);
140+
for (i = 0; i < bufsize; i++) screenbuffer[i] = 0.0f;
143141
}
144142
}
145143

146144
if (cb_rem_blocking(&context->circbuf, buffer, sizetopoll) == CB_OK) {
147145

148-
for (i = 0; i < sizetopoll; i++) {
149-
float val = screenbuffer[i] * lowpassvalue + buffer[i] * antilowpassvalue;
150-
146+
float max = buffer[0];
147+
float min = max;
148+
for (i = 1; i < sizetopoll; i++) {
149+
const float val = buffer[i];
151150
if (val > max) max = val; else if (val < min) min = val;
152-
screenbuffer[i] = (val - pmin) / span;
153151
}
154152

155-
context->cb(screenbuffer, width, height, context->ctx);
153+
const float span = max - min;
156154

157-
pmax = max;
158-
pmin = min;
155+
for (i = 0; i < sizetopoll; i++) {
156+
const float val = (buffer[i] - min) / span;
157+
screenbuffer[i] = screenbuffer[i] * lowpassvalue + val * antilowpassvalue;
158+
}
159+
160+
context->cb(screenbuffer, width, height, context->ctx);
159161
}
160162
}
161163

@@ -301,7 +303,7 @@ void process(float *buf, uint32_t len, void *ctx, int dropped) {
301303

302304

303305
// section for manual syncing
304-
const int syncoffset = context->this->syncoffset;
306+
const int syncoffset = -context->this->syncoffset;
305307
if (syncoffset > 0)
306308
context->dropped += syncoffset;
307309
else if (syncoffset < 0)

0 commit comments

Comments
 (0)