summaryrefslogtreecommitdiff
path: root/gr-fec
diff options
context:
space:
mode:
authorDaniel Estévez <daniel@destevez.net>2017-08-02 22:19:33 +0200
committerDaniel Estévez <daniel@destevez.net>2017-08-02 22:46:13 +0200
commit81a7988f38b291b75e81b32b9a882e16965b1020 (patch)
tree0276b4b6d80cdbe8ecbf713c2dd9ee20052cd3fd /gr-fec
parent3b3a403e8871bdb83f8cd9bdc904626de14a7cca (diff)
Support negative polynomials in cc_encoder
Negative polynomials are already supported in cc_decoder. Inverting the sign of the polynomial in a convolutional code is just a convention to invert the output bit corresponding to that polynomial.
Diffstat (limited to 'gr-fec')
-rw-r--r--gr-fec/lib/cc_encoder_impl.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/gr-fec/lib/cc_encoder_impl.cc b/gr-fec/lib/cc_encoder_impl.cc
index 75d7dcd66b..9585d5fcd5 100644
--- a/gr-fec/lib/cc_encoder_impl.cc
+++ b/gr-fec/lib/cc_encoder_impl.cc
@@ -179,7 +179,7 @@ namespace gr {
for(unsigned int i = 0; i < d_frame_size; ++i) {
my_state = (my_state << 1) | (in[i] & 1);
for(unsigned int j = 0; j < d_rate; ++j) {
- out[i * d_rate + j] = parity(my_state & d_polys[j]) == 0 ? 0 : 1;
+ out[i * d_rate + j] = (d_polys[j] < 0) ^ parity(my_state & abs(d_polys[j])) ? 1 : 0;
}
}
@@ -187,7 +187,7 @@ namespace gr {
for(unsigned int i = 0; i < d_k - 1; ++i) {
my_state = (my_state << 1) | ((d_start_state >> (d_k - 2 - i)) & 1);
for(unsigned int j = 0; j < d_rate; ++j) {
- out[(i + d_frame_size) * d_rate + j] = parity(my_state & d_polys[j]) == 0 ? 0 : 1;
+ out[(i + d_frame_size) * d_rate + j] = (d_polys[j] < 0) ^ parity(my_state & abs(d_polys[j])) ? 1 : 0;
}
}
}