diff --git a/demod_2400.c b/demod_2400.c index ffd7ed9..8f5ace7 100644 --- a/demod_2400.c +++ b/demod_2400.c @@ -52,72 +52,6 @@ static inline int slice_phase4(uint16_t *m) { return m[0] + 5 * m[1] - 5 * m[2] - m[3]; } -static inline int correlate_phase0(uint16_t *m) { - return slice_phase0(m) * 26; -} -static inline int correlate_phase1(uint16_t *m) { - return slice_phase1(m) * 38; -} -static inline int correlate_phase2(uint16_t *m) { - return slice_phase2(m) * 38; -} -static inline int correlate_phase3(uint16_t *m) { - return slice_phase3(m) * 26; -} -static inline int correlate_phase4(uint16_t *m) { - return slice_phase4(m) * 19; -} - -// -// These functions work out the correlation quality for the 10 symbols (5 bits) starting at m[0] + given phase offset. -// This is used to find the right phase offset to use for decoding. -// - -static inline int correlate_check_0(uint16_t *m) { - return - abs(correlate_phase0(&m[0])) + - abs(correlate_phase2(&m[2])) + - abs(correlate_phase4(&m[4])) + - abs(correlate_phase1(&m[7])) + - abs(correlate_phase3(&m[9])); -} - -static inline int correlate_check_1(uint16_t *m) { - return - abs(correlate_phase1(&m[0])) + - abs(correlate_phase3(&m[2])) + - abs(correlate_phase0(&m[5])) + - abs(correlate_phase2(&m[7])) + - abs(correlate_phase4(&m[9])); -} - -static inline int correlate_check_2(uint16_t *m) { - return - abs(correlate_phase2(&m[0])) + - abs(correlate_phase4(&m[2])) + - abs(correlate_phase1(&m[5])) + - abs(correlate_phase3(&m[7])) + - abs(correlate_phase0(&m[10])); -} - -static inline int correlate_check_3(uint16_t *m) { - return - abs(correlate_phase3(&m[0])) + - abs(correlate_phase0(&m[3])) + - abs(correlate_phase2(&m[5])) + - abs(correlate_phase4(&m[7])) + - abs(correlate_phase1(&m[10])); -} - -static inline int correlate_check_4(uint16_t *m) { - return - abs(correlate_phase4(&m[0])) + - abs(correlate_phase1(&m[3])) + - abs(correlate_phase3(&m[5])) + - abs(correlate_phase0(&m[8])) + - abs(correlate_phase2(&m[10])); -} - // // Given 'mlen' magnitude samples in 'm', sampled at 2.4MHz, // try to demodulate some Mode S messages.