Change code to use 64-bit variables for decoding

This commit is contained in:
Marcos Vives Del Sol 2014-08-15 13:56:57 +02:00 committed by Kamal Mostafa
parent 909adf0d59
commit cc6b5c9123
8 changed files with 24 additions and 24 deletions

View File

@ -22,7 +22,7 @@ typedef int (databits_encoder)(
typedef unsigned int (databits_decoder)( typedef unsigned int (databits_decoder)(
char *dataout_p, unsigned int dataout_size, char *dataout_p, unsigned int dataout_size,
unsigned int bits, unsigned int n_databits ); unsigned long long bits, unsigned int n_databits );
int int
@ -30,7 +30,7 @@ databits_encode_ascii8( unsigned int *databits_outp, char char_out );
unsigned int unsigned int
databits_decode_ascii8( char *dataout_p, unsigned int dataout_size, 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" #include "baudot.h"
@ -40,7 +40,7 @@ databits_decode_ascii8( char *dataout_p, unsigned int dataout_size,
unsigned int unsigned int
databits_decode_baudot( char *dataout_p, unsigned int dataout_size, 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 int
@ -48,11 +48,11 @@ databits_encode_binary( unsigned int *databits_outp, char char_out );
unsigned int unsigned int
databits_decode_binary( char *dataout_p, unsigned int dataout_size, 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 unsigned int
databits_decode_callerid( char *dataout_p, unsigned int dataout_size, 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 );

View File

@ -34,7 +34,7 @@ databits_encode_ascii8( unsigned int *databits_outp, char char_out )
/* returns nbytes decoded */ /* returns nbytes decoded */
unsigned int unsigned int
databits_decode_ascii8( char *dataout_p, unsigned int dataout_size, 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 if ( ! dataout_p ) // databits processor reset: noop
return 0; return 0;

View File

@ -28,7 +28,7 @@
/* returns nbytes decoded */ /* returns nbytes decoded */
unsigned int unsigned int
databits_decode_baudot( char *dataout_p, unsigned int dataout_size, 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 if ( ! dataout_p ) { // databits processor reset: reset Baudot state
baudot_reset(); baudot_reset();

View File

@ -28,7 +28,7 @@
// returns nbytes decoded // returns nbytes decoded
unsigned int unsigned int
databits_decode_binary( char *dataout_p, unsigned int dataout_size, 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 if ( ! dataout_p ) // databits processor reset: noop
return 0; return 0;

View File

@ -157,7 +157,7 @@ decode_cid_reset()
/* returns nbytes decoded */ /* returns nbytes decoded */
unsigned int unsigned int
databits_decode_callerid( char *dataout_p, unsigned int dataout_size, 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 if ( ! dataout_p ) // databits processor reset
return decode_cid_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 // Collect input bytes until we've collected as many as the message
// length byte says there will be, plus two (the message type byte // length byte says there will be, plus two (the message type byte
// and the checksum 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) if ( cid_ndata < cid_msglen + 2)
return 0; return 0;

View File

@ -178,13 +178,13 @@ fsk_bit_analyze( fsk_plan *fskp, float *samples, unsigned int bit_nsamples,
static float static float
fsk_frame_analyze( fsk_plan *fskp, float *samples, float samples_per_bit, fsk_frame_analyze( fsk_plan *fskp, float *samples, float samples_per_bit,
int n_bits, const char *expect_bits_string, 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_nsamples = (float)(samples_per_bit + 0.5);
unsigned int bit_values[32]; unsigned int bit_values[64];
float bit_sig_mags[32]; float bit_sig_mags[64];
float bit_noise_mags[32]; float bit_noise_mags[64];
unsigned int bit_begin_sample; unsigned int bit_begin_sample;
int bitnum; int bitnum;
@ -453,9 +453,9 @@ fsk_find_frame( fsk_plan *fskp, float *samples, unsigned int frame_nsamples,
unsigned int try_step_nsamples, unsigned int try_step_nsamples,
float try_confidence_search_limit, float try_confidence_search_limit,
const char *expect_bits_string, const char *expect_bits_string,
unsigned int *bits_outp, unsigned long long *bits_outp,
float *ampl_outp, float *ampl_outp,
unsigned int *frame_start_outp unsigned long long *frame_start_outp
) )
{ {
int expect_n_bits = strlen(expect_bits_string); 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; continue;
float c, ampl_out; 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); debug_log("try fsk_frame_analyze at t=%d\n", t);
c = fsk_frame_analyze(fskp, samples+t, samples_per_bit, c = fsk_frame_analyze(fskp, samples+t, samples_per_bit,
expect_n_bits, expect_bits_string, expect_n_bits, expect_bits_string,

View File

@ -65,9 +65,9 @@ fsk_find_frame( fsk_plan *fskp, float *samples, unsigned int frame_nsamples,
unsigned int try_step_nsamples, unsigned int try_step_nsamples,
float try_confidence_search_limit, float try_confidence_search_limit,
const char *expect_bits_string, const char *expect_bits_string,
unsigned int *bits_outp, unsigned long long *bits_outp,
float *ampl_outp, float *ampl_outp,
unsigned int *frame_start_outp unsigned long long *frame_start_outp
); );
int int

View File

@ -1011,7 +1011,7 @@ main( int argc, char*argv[] )
// start--v v--stop // start--v v--stop
// char *expect_bits_string = "10dddddddd1"; // 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 start_bit_value = invert_start_stop ? '1' : '0';
char stop_bit_value = invert_start_stop ? '0' : '1'; char stop_bit_value = invert_start_stop ? '0' : '1';
int j = 0; int j = 0;
@ -1062,10 +1062,10 @@ main( int argc, char*argv[] )
try_step_nsamples = 1; try_step_nsamples = 1;
float confidence, amplitude; float confidence, amplitude;
unsigned int bits = 0; unsigned long long bits = 0;
/* Note: frame_start_sample is actually the sample where the /* Note: frame_start_sample is actually the sample where the
* prev_stop bit begins (since the "frame" includes the prev_stop). */ * 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; unsigned int try_first_sample;
float try_confidence_search_limit; float try_confidence_search_limit;
@ -1179,8 +1179,8 @@ main( int argc, char*argv[] )
try_step_nsamples = 1; try_step_nsamples = 1;
try_confidence_search_limit = INFINITY; try_confidence_search_limit = INFINITY;
float confidence2, amplitude2; float confidence2, amplitude2;
unsigned int bits2; unsigned long long bits2;
unsigned int frame_start_sample2; unsigned long long frame_start_sample2;
confidence2 = fsk_find_frame(fskp, samplebuf, expect_nsamples, confidence2 = fsk_find_frame(fskp, samplebuf, expect_nsamples,
try_first_sample, try_first_sample,
try_max_nsamples, try_max_nsamples,