Porównaj commity

...

3 Commity

Autor SHA1 Wiadomość Data
pabr 9b552f6f3f Avoid GCC warning. 2022-10-16 22:21:31 +02:00
pabr 8e1dbf708a Fix read-after-free. 2022-10-16 22:02:03 +02:00
pabr d31da23df2 leandvb: Support float64 input 2022-10-16 21:54:40 +02:00
3 zmienionych plików z 24 dodań i 7 usunięć

Wyświetl plik

@ -48,7 +48,7 @@ struct config {
enum {
INPUT_U8, INPUT_S8,
INPUT_S12, INPUT_S16,
INPUT_F32
INPUT_F32, INPUT_F64
} input_format;
float float_scale; // Scaling factor for float data.
bool loop_input;
@ -331,6 +331,17 @@ struct runtime_common {
amp = 2.0;
break;
}
case config::INPUT_F64: {
pipebuf<cf64> *p_stdin =
new pipebuf<cf64>(sch, "stdin", BUF_BASEBAND+cfg.input_buffer);
file_reader<cf64> *r_stdin =
new file_reader<cf64>(sch, 0, *p_stdin);
r_stdin->loop = cfg.loop_input;
scaler<float,cf64,cf32> *r_scale =
new scaler<float,cf64,cf32>(sch, cfg.float_scale, *p_stdin, *p_rawiq);
amp = 2.0;
break;
}
default:
fail("Input format not implemented");
}
@ -1368,6 +1379,7 @@ void usage(const char *name, FILE *f, int c, const char *info=NULL) {
" --s12 Input format is 12/16-bit signed (PlutoSDR, LimeSDR)\n"
" --s16 Input format is 16-bit signed\n"
" --f32 Input format is 32-bit float (gqrx)\n"
" --f64 Input format is 64-bit float\n"
" -f HZ Input sample rate (Hz, default: 2.4e6)\n"
" --loop Repeat (stdin must be a file)\n"
" --inpipe INT Resize stdin pipe (bytes)\n"
@ -1598,6 +1610,8 @@ int main(int argc, const char *argv[]) {
cfg.input_format = config::INPUT_S16;
else if ( ! strcmp(argv[i], "--f32") )
cfg.input_format = config::INPUT_F32;
else if ( ! strcmp(argv[i], "--f64") )
cfg.input_format = config::INPUT_F64;
else if ( ! strcmp(argv[i], "--float-scale") && i+1<argc )
cfg.float_scale = atof(argv[++i]);
else if ( ! strcmp(argv[i], "--loop") )

Wyświetl plik

@ -50,14 +50,14 @@ struct udp_output : runnable {
{
const char *sep = strchr(udpaddr, ':');
if ( ! sep ) fail("Expected IP:PORT");
int port = atoi(sep+1);
addr.sin_port = ntohs(port);
char *ipaddr = strndup(udpaddr, sep-udpaddr);
if ( sch->verbose )
fprintf(stderr, "Sending UDP to %s:%d\n", ipaddr, port);
int res = inet_aton(ipaddr, &addr.sin_addr);
free(ipaddr);
if ( ! res ) fatal("inet_aton");
int port = atoi(sep+1);
addr.sin_port = ntohs(port);
if ( sch->verbose )
fprintf(stderr, "Sending UDP to %s:%d\n", ipaddr, port);
}
if ( connect(sock,(sockaddr*)&addr,sizeof(addr)) < 0 ) fatal("connect");
}

Wyświetl plik

@ -32,6 +32,7 @@ namespace leansdr {
typedef complex<u16> cu16;
typedef complex<s16> cs16;
typedef complex<f32> cf32;
typedef complex<float> cf64;
//////////////////////////////////////////////////////////////////////
@ -871,7 +872,8 @@ namespace leansdr {
ss_out = _ss_out ? new pipewriter<float>(*_ss_out) : NULL;
mer_out = _mer_out ? new pipewriter<float>(*_mer_out) : NULL;
cstln_out = _cstln_out ? new pipewriter<cf32>(*_cstln_out) : NULL;
memset(hist, 0, sizeof(hist));
for ( int i=0; i<sizeof(hist)/sizeof(hist[0]); ++i )
hist[i].p = hist[i].c = 0;
}
void set_omega(float _omega, float tol=10e-6) {
@ -1110,7 +1112,8 @@ namespace leansdr {
set_freq(0);
freq_out = _freq_out ? new pipewriter<float>(*_freq_out) : NULL;
cstln_out = _cstln_out ? new pipewriter< complex<T> >(*_cstln_out) : NULL;
memset(hist, 0, sizeof(hist));
for ( int i=0; i<sizeof(hist)/sizeof(hist[0]); ++i )
hist[i].p = hist[i].c = 0;
init_lookup_tables();
}