Skip to content

Commit

Permalink
Merge pull request #95 from wiedehopf/master
Browse files Browse the repository at this point in the history
rtl-sdr: avoid redundant float operations
  • Loading branch information
TLeconte authored Aug 4, 2022
2 parents 5545e54 + ba7d1ad commit 9edcce0
Showing 1 changed file with 31 additions and 18 deletions.
49 changes: 31 additions & 18 deletions rtl.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
// rtlMult 192 // 2.4000 Ms/s
// rtlMult 200 // 2.5000 Ms/s

#define RTLMULTMAX 320 // this is well beyond the rtl-sdr capabilities

static rtlsdr_dev_t *dev = NULL;
static int status = 0;
static int rtlInBufSize = 0;
Expand Down Expand Up @@ -203,6 +205,10 @@ int initRtl(char **argv, int optind)
dev_index = verbose_device_search(argv[optind]);
optind++;

if (rtlMult > RTLMULTMAX) {
fprintf(stderr, "rtlMult can't be larger than 360\n");
return 1;
}

rtlInBufSize = RTLOUTBUFSZ * rtlMult * 2;
rtlInRate = INTRATE * rtlMult;
Expand Down Expand Up @@ -320,30 +326,37 @@ static void in_callback(unsigned char *rtlinbuff, uint32_t nread, void *ctx)
}
status=0;

for (n = 0; n < nbch; n++) {
channel_t *ch = &(channel[n]);
int i,m;
float complex D,*wf;
// code requires this relationship set in initRtl:
// rtlInBufSize = RTLOUTBUFSZ * rtlMult * 2;

wf = ch->wf;
m=0;
for (i = 0; i < rtlInBufSize;) {
int ind;
float complex vb[RTLMULTMAX];
int i = 0;
for (int m = 0; m < RTLOUTBUFSZ; m++) {
for (int ind = 0; ind < rtlMult; ind++) {
float r, g;

D = 0;
for (ind = 0; ind < rtlMult; ind++) {
float r, g;
float complex v;
r = (float)rtlinbuff[i] - 127.37f; i++;
g = (float)rtlinbuff[i] - 127.37f; i++;

vb[ind]=r+g*I;
}

r = (float)rtlinbuff[i] - (float)127.37; i++;
g = (float)rtlinbuff[i] - (float)127.37; i++;
for (n = 0; n < nbch; n++) {
channel_t *ch = &(channel[n]);
float complex D,*wf;

v=r+g*I;
D+=v*wf[ind];
wf = ch->wf;
D = 0;
for (int ind = 0; ind < rtlMult; ind++) {
D += vb[ind] * wf[ind];
}
ch->dm_buffer[m++]=cabsf(D);
ch->dm_buffer[m]=cabsf(D);
}
demodMSK(ch,m);
}

for (n = 0; n < nbch; n++) {
channel_t *ch = &(channel[n]);
demodMSK(ch,RTLOUTBUFSZ);
}
}

Expand Down

0 comments on commit 9edcce0

Please sign in to comment.