MalcolmRobb/dump1090 — pull request #36 by mutability (2014-09-15 00:55:57+00:00)
Title: Rearrange phase enhancement so that it handles phase errors in both directions

The idea here is to look at the known bits of the preamble and see in which direction they have leaked by looking at the amplitude of adjacent samples. This gives us the direction of the phase error between the signal and our sampling period, and a rough idea of the size of the error.

If we see energy in later-than-expected samples, our sample period must start early and include some of the previous bit period. The existing enhancement algorithm handles this, so this is basically unchanged except that the scaling factor is weighted by the size of the phase error.

If we see energy in earlier-than-expected samples, our sample period must start late and include some of the next bit period. So we need to do the same thing but in the opposite direction - each sample pair influences the *previous* sample, so work backwards through the data applying that.

In my tests this almost doubles the number of messages recovered by phase enhancement (which is consistent with the existing approach only handling one direction of phase shift)