Always use phase enhancement; silently ignore --phase-enhance if given.

This commit is contained in:
Oliver Jowett 2016-05-31 11:47:57 +01:00
parent 93c135ea66
commit d419b62a65
8 changed files with 6 additions and 59 deletions

View file

@ -34,9 +34,6 @@ PPM=
# If yes, enable sampling at 2.4MHz. Otherwise, 2.0MHz is used.
OVERSAMPLE=
# If yes, enables phase-enhancement of messages
PHASE_ENHANCE=
#
# Decoding options
#

View file

@ -26,7 +26,6 @@ if [ -e $CONFIGFILE ]; then
db_set_yn $NAME/rtlsdr-oversample "$OVERSAMPLE"
db_set_yn $NAME/decode-fixcrc "$FIX_CRC"
db_set_yn $NAME/decode-phase-enhance "$PHASE_ENHANCE"
db_set $NAME/decode-lat "$LAT"
db_set $NAME/decode-lon "$LON"
db_set $NAME/decode-max-range "$MAX_RANGE"

View file

@ -77,7 +77,6 @@ case "$1" in
subvar rtlsdr-ppm PPM
subvar_yn rtlsdr-oversample OVERSAMPLE
subvar_yn decode-fixcrc FIX_CRC
subvar_yn decode-phase-enhance PHASE_ENHANCE
subvar decode-lat LAT
subvar decode-lon LON
subvar decode-max-range MAX_RANGE

View file

@ -69,13 +69,6 @@ Description: Fix detected CRC errors?
Type: boolean
Default: true
Template: dump1090-mutability/decode-phase-enhance
Description: Apply phase enhancement?
dump1090 can attempt to correct for messages that are received
out-of-phase from the sampling rate, at the expense of taking more CPU.
Type: boolean
Default: true
Template: dump1090-mutability/decode-lat
Description: Latitude of receiver, in decimal degrees:
If the location of the receiver is provided, dump1090 can do

View file

@ -880,8 +880,8 @@ void demodulate2000(struct mag_buf *mag) {
}
}
// Retry with phase correction if enabled, necessary and possible.
if (Modes.phase_enhance && (!message_ok || mm.correctedbits > 0) && !use_correction && j && detectOutOfPhase(pPreamble)) {
// Retry with phase correction if necessary and possible.
if ((!message_ok || mm.correctedbits > 0) && !use_correction && j && detectOutOfPhase(pPreamble)) {
use_correction = 1; j--;
} else {
use_correction = 0;

View file

@ -118,33 +118,6 @@ static inline int correlate_check_4(uint16_t *m) {
abs(correlate_phase2(&m[10]));
}
// Work out the best phase offset to use for the given message.
static int best_phase(uint16_t *m) {
int test;
int best = -1;
int bestval = (m[0] + m[1] + m[2] + m[3] + m[4] + m[5]); // minimum correlation quality we will accept
// empirical testing suggests that 4..8 is the best range to test for here
// (testing a wider range runs the danger of picking the wrong phase for
// a message that would otherwise be successfully decoded - the correlation
// functions can match well with a one symbol / half bit offset)
// this is consistent with the peak detection which should produce
// the first data symbol with phase offset 4..8
test = correlate_check_4(&m[0]);
if (test > bestval) { bestval = test; best = 4; }
test = correlate_check_0(&m[1]);
if (test > bestval) { bestval = test; best = 5; }
test = correlate_check_1(&m[1]);
if (test > bestval) { bestval = test; best = 6; }
test = correlate_check_2(&m[1]);
if (test > bestval) { bestval = test; best = 7; }
test = correlate_check_3(&m[1]);
if (test > bestval) { bestval = test; best = 8; }
return best;
}
//
// Given 'mlen' magnitude samples in 'm', sampled at 2.4MHz,
// try to demodulate some Mode S messages.
@ -170,7 +143,7 @@ void demodulate2400(struct mag_buf *mag)
uint16_t *preamble = &m[j];
int high;
uint32_t base_signal, base_noise;
int initial_phase, first_phase, last_phase, try_phase;
int try_phase;
int msglen;
// Look for a message starting at around sample 0 with phase offset 3..7
@ -252,22 +225,10 @@ void demodulate2400(struct mag_buf *mag)
continue;
}
if (Modes.phase_enhance) {
first_phase = 4;
last_phase = 8; // try all phases
} else {
// Crosscorrelate against the first few bits to find a likely phase offset
initial_phase = best_phase(&preamble[19]);
if (initial_phase < 0) {
continue; // nothing satisfactory
}
first_phase = last_phase = initial_phase; // try only the phase we think it is
}
// try all phases
Modes.stats_current.demod_preambles++;
bestmsg = NULL; bestscore = -2; bestphase = -1;
for (try_phase = first_phase; try_phase <= last_phase; ++try_phase) {
for (try_phase = 4; try_phase <= 8; ++try_phase) {
uint16_t *pPtr;
int phase, i, score, bytelen;

View file

@ -702,7 +702,6 @@ void showHelp(void) {
"--fix Enable single-bits error correction using CRC\n"
"--no-fix Disable single-bits error correction using CRC\n"
"--no-crc-check Disable messages with broken CRC (discouraged)\n"
"--phase-enhance Enable phase enhancement\n"
#ifdef ALLOW_AGGRESSIVE
"--aggressive More CPU for more messages (two bits fixes, ...)\n"
#endif
@ -964,7 +963,7 @@ int main(int argc, char **argv) {
} else if (!strcmp(argv[j],"--no-crc-check")) {
Modes.check_crc = 0;
} else if (!strcmp(argv[j],"--phase-enhance")) {
Modes.phase_enhance = 1;
// Ignored, always enabled
} else if (!strcmp(argv[j],"--raw")) {
Modes.raw = 1;
} else if (!strcmp(argv[j],"--net")) {

View file

@ -282,7 +282,6 @@ struct { // Internal state
// Configuration
char *filename; // Input form file, --ifile option
int oversample;
int phase_enhance; // Enable phase enhancement if true
int nfix_crc; // Number of crc bit error(s) to correct
int check_crc; // Only display messages with good CRC
int raw; // Raw output format