mirror of https://gerrit.osmocom.org/osmo-tetra
Added basic AFC as implemented by SQ5BPF into float_to_bits.c
The AFC implementation by SQ5BPF as used in his fork of osmo-tetra significantly increases reception quality. A simple test yields 14545 valid CRCs as opposed to 11934 when AFC is not used. I added the AFC to float_to_bits, the functionality can be activated with the -a flag. Change-Id: I1c9343b83739108a1e423c4880e1dc7964656529
This commit is contained in:
parent
d5bfc8e74a
commit
f258b1d7d7
|
@ -73,25 +73,47 @@ static void sym_int2bits(int sym, uint8_t *ret)
|
||||||
|
|
||||||
// size of IO buffers (number of elements)
|
// size of IO buffers (number of elements)
|
||||||
#define BUF_SIZE 1024
|
#define BUF_SIZE 1024
|
||||||
|
#define MAXVAL 5.0
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int fd, fd_out, opt;
|
int fd, fd_out, opt;
|
||||||
|
|
||||||
int opt_verbose = 0;
|
int opt_verbose = 0;
|
||||||
|
int opt_afc = 0;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "v")) != -1) {
|
float filter = 0;
|
||||||
|
float filter_val = 0.0001;
|
||||||
|
float filter_goal = 0;
|
||||||
|
int sym;
|
||||||
|
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "vaf:F:")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'v':
|
case 'v':
|
||||||
opt_verbose = 1;
|
opt_verbose = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'a':
|
||||||
|
opt_afc = 1;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
filter_val = atof(optarg);
|
||||||
|
break;
|
||||||
|
case 'F':
|
||||||
|
filter_goal = atof(optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc <= optind+1) {
|
if (argc <= optind+1) {
|
||||||
fprintf(stderr, "Usage: %s [-v] <infile> <outfile>\n", argv[0]);
|
fprintf(stderr, "Usage: %s [-v] [-a] [-f filter_val] [-F filter_goal] <infile> <outfile>\n", argv[0]);
|
||||||
|
fprintf(stderr, "-v verbose, print bits to stdout\n");
|
||||||
|
fprintf(stderr, "-a turn on pseudo-afc (automatic frequency correction)\n");
|
||||||
|
fprintf(stderr, "-f pseudo-afc averaging filter constant (default 0.0001)\n");
|
||||||
|
fprintf(stderr, "-F pseudo-afc filter goal (default: 0)\n");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +141,16 @@ int main(int argc, char **argv)
|
||||||
rc /= sizeof(*fl);
|
rc /= sizeof(*fl);
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < rc; ++i) {
|
for (i = 0; i < rc; ++i) {
|
||||||
int sym = process_sym_fl(fl[i]);
|
|
||||||
|
if ((fl[i] > -MAXVAL) && (fl[i] < MAXVAL)) {
|
||||||
|
filter = filter * (1.0 - filter_val) + (fl[i] - filter_goal) * filter_val;
|
||||||
|
}
|
||||||
|
if (opt_afc) {
|
||||||
|
sym = process_sym_fl(fl[i]-filter);
|
||||||
|
} else {
|
||||||
|
sym = process_sym_fl(fl[i]);
|
||||||
|
}
|
||||||
|
|
||||||
sym_int2bits(sym, bits + i*2);
|
sym_int2bits(sym, bits + i*2);
|
||||||
//printf("%2d %1u %1u %f\n", rc, bits[0], bits[1], fl);
|
//printf("%2d %1u %1u %f\n", rc, bits[0], bits[1], fl);
|
||||||
if (opt_verbose) {
|
if (opt_verbose) {
|
||||||
|
|
Loading…
Reference in New Issue