Skip to content

Commit

Permalink
fixed shifting of filter history in fifth_order()
Browse files Browse the repository at this point in the history
fifth_order() filters and decimates by two, and therefore always shifts
by two input samples for every output sample. However, for the first
output sample, it shifted the state from the previous call to
fifth_order() by only one input sample, and it never used the last
sample in its input buffer.
  • Loading branch information
v15n committed Apr 27, 2017
1 parent 0b456b5 commit a2a8e78
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions rtl_ais.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,21 +154,21 @@ static void fifth_order(int16_t *data, int length, int16_t *hist)
{
int i;
int16_t a, b, c, d, e, f;
a = hist[1];
b = hist[2];
c = hist[3];
d = hist[4];
e = hist[5];
f = data[0];
a = hist[2];
b = hist[3];
c = hist[4];
d = hist[5];
e = data[0];
f = data[2];
/* a downsample should improve resolution, so don't fully shift */
data[0] = (a + (b+e)*5 + (c+d)*10 + f) >> 4;
for (i=4; i<length; i+=4) {
a = c;
b = d;
c = e;
d = f;
e = data[i-2];
f = data[i];
e = data[i];
f = data[i+2];
data[i/2] = (a + (b+e)*5 + (c+d)*10 + f) >> 4;
}
/* archive */
Expand Down

0 comments on commit a2a8e78

Please sign in to comment.