diff options
Diffstat (limited to 'gr-blocks/lib')
-rw-r--r-- | gr-blocks/lib/pack_k_bits.cc | 11 | ||||
-rw-r--r-- | gr-blocks/lib/unpack_k_bits.cc | 11 |
2 files changed, 22 insertions, 0 deletions
diff --git a/gr-blocks/lib/pack_k_bits.cc b/gr-blocks/lib/pack_k_bits.cc index d0123f5a09..ad6e78ae18 100644 --- a/gr-blocks/lib/pack_k_bits.cc +++ b/gr-blocks/lib/pack_k_bits.cc @@ -54,6 +54,17 @@ namespace gr { } } + void + pack_k_bits::pack_rev(unsigned char *bytes, const unsigned char *bits, int nbytes) const + { + for(int i = 0; i < nbytes; i++) { + bytes[i] = 0x00; + for(unsigned int j = 0; j < d_k; j++) { + bytes[i] |= (0x01 & bits[i*d_k+j])<<j; + } + } + } + } /* namespace kernel */ } /* namespace blocks */ } /* namespace gr */ diff --git a/gr-blocks/lib/unpack_k_bits.cc b/gr-blocks/lib/unpack_k_bits.cc index f274cf5b60..a9ae4dae11 100644 --- a/gr-blocks/lib/unpack_k_bits.cc +++ b/gr-blocks/lib/unpack_k_bits.cc @@ -55,6 +55,17 @@ namespace gr { } } + void + unpack_k_bits::unpack_rev(unsigned char *bits, const unsigned char *bytes, int nbytes) const + { + int n = 0; + for(int i = 0; i < nbytes; i++) { + unsigned int t = bytes[i]; + for(int j = 0; j < d_k; j++) + bits[n++] = (t >> j) & 0x01; + } + } + int unpack_k_bits::k() const { |