SHARE
TWEET

Untitled

a guest Nov 17th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from numpy import concatenate
  2. from reed_solomon import encode as rs_encode, decode as rs_decode, BITS_PER_BLOCK, MESSAGE_BITS_PER_BLOCK
  3. from viterbi import encode as v_encode, decode as v_decode, trellis
  4. from utils import blockify
  5.  
  6.  
  7. def encode(bits):
  8.     rs_encoded_bits = rs_encode(bits)
  9.     rs_encoded_blocks = blockify(rs_encoded_bits, BITS_PER_BLOCK)
  10.     v_encoded_blocks = []
  11.     for block in rs_encoded_blocks:
  12.         v_encoded_blocks.append(v_encode(block))
  13.     return concatenate(v_encoded_blocks)
  14.  
  15.  
  16. def decode(bits):
  17.     v_encoded_block_num_bits = BITS_PER_BLOCK * trellis.n // trellis.k
  18.     v_encoded_blocks = blockify(bits, v_encoded_block_num_bits)
  19.     rs_encoded_blocks = []
  20.     for block in v_encoded_blocks:
  21.         rs_encoded_blocks.append(v_decode(block))
  22.     original_blocks = []
  23.     for block in rs_encoded_blocks:
  24.         original_blocks.append(rs_decode(block))
  25.     return concatenate(original_blocks)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top