Change code to use 64-bit variables for decoding
This commit is contained in:
parent
909adf0d59
commit
cc6b5c9123
|
@ -22,7 +22,7 @@ typedef int (databits_encoder)(
|
|||
|
||||
typedef unsigned int (databits_decoder)(
|
||||
char *dataout_p, unsigned int dataout_size,
|
||||
unsigned int bits, unsigned int n_databits );
|
||||
unsigned long long bits, unsigned int n_databits );
|
||||
|
||||
|
||||
int
|
||||
|
@ -30,7 +30,7 @@ databits_encode_ascii8( unsigned int *databits_outp, char char_out );
|
|||
|
||||
unsigned int
|
||||
databits_decode_ascii8( char *dataout_p, unsigned int dataout_size,
|
||||
unsigned int bits, unsigned int n_databits );
|
||||
unsigned long long bits, unsigned int n_databits );
|
||||
|
||||
|
||||
#include "baudot.h"
|
||||
|
@ -40,7 +40,7 @@ databits_decode_ascii8( char *dataout_p, unsigned int dataout_size,
|
|||
|
||||
unsigned int
|
||||
databits_decode_baudot( char *dataout_p, unsigned int dataout_size,
|
||||
unsigned int bits, unsigned int n_databits );
|
||||
unsigned long long bits, unsigned int n_databits );
|
||||
|
||||
|
||||
int
|
||||
|
@ -48,11 +48,11 @@ databits_encode_binary( unsigned int *databits_outp, char char_out );
|
|||
|
||||
unsigned int
|
||||
databits_decode_binary( char *dataout_p, unsigned int dataout_size,
|
||||
unsigned int bits, unsigned int n_databits );
|
||||
unsigned long long bits, unsigned int n_databits );
|
||||
|
||||
|
||||
unsigned int
|
||||
databits_decode_callerid( char *dataout_p, unsigned int dataout_size,
|
||||
unsigned int bits, unsigned int n_databits );
|
||||
unsigned long long bits, unsigned int n_databits );
|
||||
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ databits_encode_ascii8( unsigned int *databits_outp, char char_out )
|
|||
/* returns nbytes decoded */
|
||||
unsigned int
|
||||
databits_decode_ascii8( char *dataout_p, unsigned int dataout_size,
|
||||
unsigned int bits, unsigned int n_databits )
|
||||
unsigned long long bits, unsigned int n_databits )
|
||||
{
|
||||
if ( ! dataout_p ) // databits processor reset: noop
|
||||
return 0;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
/* returns nbytes decoded */
|
||||
unsigned int
|
||||
databits_decode_baudot( char *dataout_p, unsigned int dataout_size,
|
||||
unsigned int bits, unsigned int n_databits )
|
||||
unsigned long long bits, unsigned int n_databits )
|
||||
{
|
||||
if ( ! dataout_p ) { // databits processor reset: reset Baudot state
|
||||
baudot_reset();
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
// returns nbytes decoded
|
||||
unsigned int
|
||||
databits_decode_binary( char *dataout_p, unsigned int dataout_size,
|
||||
unsigned int bits, unsigned int n_databits )
|
||||
unsigned long long bits, unsigned int n_databits )
|
||||
{
|
||||
if ( ! dataout_p ) // databits processor reset: noop
|
||||
return 0;
|
||||
|
|
|
@ -157,7 +157,7 @@ decode_cid_reset()
|
|||
/* returns nbytes decoded */
|
||||
unsigned int
|
||||
databits_decode_callerid( char *dataout_p, unsigned int dataout_size,
|
||||
unsigned int bits, unsigned int n_databits )
|
||||
unsigned long long bits, unsigned int n_databits )
|
||||
{
|
||||
if ( ! dataout_p ) // databits processor reset
|
||||
return decode_cid_reset();
|
||||
|
@ -183,7 +183,7 @@ databits_decode_callerid( char *dataout_p, unsigned int dataout_size,
|
|||
// Collect input bytes until we've collected as many as the message
|
||||
// length byte says there will be, plus two (the message type byte
|
||||
// and the checksum byte)
|
||||
unsigned int cid_msglen = cid_buf[1];
|
||||
unsigned long long cid_msglen = cid_buf[1];
|
||||
if ( cid_ndata < cid_msglen + 2)
|
||||
return 0;
|
||||
|
||||
|
|
14
src/fsk.c
14
src/fsk.c
|
@ -178,13 +178,13 @@ fsk_bit_analyze( fsk_plan *fskp, float *samples, unsigned int bit_nsamples,
|
|||
static float
|
||||
fsk_frame_analyze( fsk_plan *fskp, float *samples, float samples_per_bit,
|
||||
int n_bits, const char *expect_bits_string,
|
||||
unsigned int *bits_outp, float *ampl_outp )
|
||||
unsigned long long *bits_outp, float *ampl_outp )
|
||||
{
|
||||
unsigned int bit_nsamples = (float)(samples_per_bit + 0.5);
|
||||
|
||||
unsigned int bit_values[32];
|
||||
float bit_sig_mags[32];
|
||||
float bit_noise_mags[32];
|
||||
unsigned int bit_values[64];
|
||||
float bit_sig_mags[64];
|
||||
float bit_noise_mags[64];
|
||||
unsigned int bit_begin_sample;
|
||||
int bitnum;
|
||||
|
||||
|
@ -453,9 +453,9 @@ fsk_find_frame( fsk_plan *fskp, float *samples, unsigned int frame_nsamples,
|
|||
unsigned int try_step_nsamples,
|
||||
float try_confidence_search_limit,
|
||||
const char *expect_bits_string,
|
||||
unsigned int *bits_outp,
|
||||
unsigned long long *bits_outp,
|
||||
float *ampl_outp,
|
||||
unsigned int *frame_start_outp
|
||||
unsigned long long *frame_start_outp
|
||||
)
|
||||
{
|
||||
int expect_n_bits = strlen(expect_bits_string);
|
||||
|
@ -482,7 +482,7 @@ fsk_find_frame( fsk_plan *fskp, float *samples, unsigned int frame_nsamples,
|
|||
continue;
|
||||
|
||||
float c, ampl_out;
|
||||
unsigned int bits_out = 0;
|
||||
unsigned long long bits_out = 0;
|
||||
debug_log("try fsk_frame_analyze at t=%d\n", t);
|
||||
c = fsk_frame_analyze(fskp, samples+t, samples_per_bit,
|
||||
expect_n_bits, expect_bits_string,
|
||||
|
|
|
@ -65,9 +65,9 @@ fsk_find_frame( fsk_plan *fskp, float *samples, unsigned int frame_nsamples,
|
|||
unsigned int try_step_nsamples,
|
||||
float try_confidence_search_limit,
|
||||
const char *expect_bits_string,
|
||||
unsigned int *bits_outp,
|
||||
unsigned long long *bits_outp,
|
||||
float *ampl_outp,
|
||||
unsigned int *frame_start_outp
|
||||
unsigned long long *frame_start_outp
|
||||
);
|
||||
|
||||
int
|
||||
|
|
|
@ -1011,7 +1011,7 @@ main( int argc, char*argv[] )
|
|||
// start--v v--stop
|
||||
// char *expect_bits_string = "10dddddddd1";
|
||||
//
|
||||
char expect_bits_string[32];
|
||||
char expect_bits_string[64];
|
||||
char start_bit_value = invert_start_stop ? '1' : '0';
|
||||
char stop_bit_value = invert_start_stop ? '0' : '1';
|
||||
int j = 0;
|
||||
|
@ -1062,10 +1062,10 @@ main( int argc, char*argv[] )
|
|||
try_step_nsamples = 1;
|
||||
|
||||
float confidence, amplitude;
|
||||
unsigned int bits = 0;
|
||||
unsigned long long bits = 0;
|
||||
/* Note: frame_start_sample is actually the sample where the
|
||||
* prev_stop bit begins (since the "frame" includes the prev_stop). */
|
||||
unsigned int frame_start_sample = 0;
|
||||
unsigned long long frame_start_sample = 0;
|
||||
|
||||
unsigned int try_first_sample;
|
||||
float try_confidence_search_limit;
|
||||
|
@ -1179,8 +1179,8 @@ main( int argc, char*argv[] )
|
|||
try_step_nsamples = 1;
|
||||
try_confidence_search_limit = INFINITY;
|
||||
float confidence2, amplitude2;
|
||||
unsigned int bits2;
|
||||
unsigned int frame_start_sample2;
|
||||
unsigned long long bits2;
|
||||
unsigned long long frame_start_sample2;
|
||||
confidence2 = fsk_find_frame(fskp, samplebuf, expect_nsamples,
|
||||
try_first_sample,
|
||||
try_max_nsamples,
|
||||
|
|
Loading…
Reference in New Issue