From 06d1d2773bce45c79039f6d99ac2198e536e60c5 Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Tue, 24 Aug 2021 15:03:48 -0600 Subject: [PATCH 1/2] change the packets per sample calculation for 2-bit files. This is complicated and I botched it before. Hopefully someone with access to 2-bit samples can test this --- .../adapters/two_bit_packed_file_signal_source.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc index ae8226dfd..d693df215 100644 --- a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc @@ -99,9 +99,16 @@ std::tuple TwoBitPackedFileSignalSource::itemTypeToSize() return std::make_tuple(item_size, is_complex_t); } -// Each sample is 2 bits; if the item_type() is char, then the size is 8/2 = 4 packets per sample -// If the item_type() is short, then the size is 16/2 = 8 packets per sample -double TwoBitPackedFileSignalSource::packetsPerSample() const { return item_size() / 2.0; } +// item_size() reports in bytes. Each sample is 2 bits, so the size is 8/2 = 4 packets per +// byte times the size of each item. A complex file has I and Q interleaved, so there are +// half as many (complex) samples as float +double TwoBitPackedFileSignalSource::packetsPerSample() const +{ + auto packets = item_size() * 4.0; + if (is_complex()) packets /= 2; + return packets; +} + gnss_shared_ptr TwoBitPackedFileSignalSource::source() const { return char_to_float_; } void TwoBitPackedFileSignalSource::create_file_source_hook() From 530684d2419b8df51713fec9ad725e49c4b77ea7 Mon Sep 17 00:00:00 2001 From: Jim Melton Date: Wed, 22 Sep 2021 20:02:36 -0600 Subject: [PATCH 2/2] make clang-tidy happy --- .../adapters/two_bit_packed_file_signal_source.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc index d693df215..ebcb95d96 100644 --- a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc @@ -105,7 +105,10 @@ std::tuple TwoBitPackedFileSignalSource::itemTypeToSize() double TwoBitPackedFileSignalSource::packetsPerSample() const { auto packets = item_size() * 4.0; - if (is_complex()) packets /= 2; + if (is_complex()) + { + packets /= 2; + } return packets; }