diff options
author | Anthony Wang | 2024-04-23 13:23:56 -0400 |
---|---|---|
committer | Anthony Wang | 2024-04-23 13:23:56 -0400 |
commit | 4b698588160ca5a9e8dacf8de105f50b0f7e3c6c (patch) | |
tree | 1a12562e2004140ea451bc5d31203f341c44919f /encoder.py | |
parent | 3d940c0a1c9b5eee2adbbdd6f0a358e782a4df06 (diff) |
Move find_corner to global namespace, use erase_pos for better ECC
Diffstat (limited to 'encoder.py')
-rw-r--r-- | encoder.py | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -33,8 +33,7 @@ with open(args.input, "rb") as f: data = f.read() rsc = RSCodec(int(args.level * 255)) encoder = Encoder.with_defaults(data, rs_size) -# This formula is wrong 🤷 -packets = encoder.get_encoded_packets(int(len(data) / rs_size * args.level)) +packets = encoder.get_encoded_packets(int(len(data) / rs_size * (1 / (1 - args.level) - 1))) # Make corners wcorner = np.pad(np.full((cheight - 1, cwidth - 1), 0b1111), ((0, 1), (0, 1))) @@ -52,10 +51,11 @@ def get_frame(): global idx frame = np.array(rsc.encode(packets[idx])) idx = (idx + 1) % len(packets) + frame = np.pad(frame, (0, frame_size // 2 - len(frame))) ^ frame_xor # Add 4 bytes, pad frame to be multiple of 255 frame = np.pad(frame, (0, (len(frame) + 258) // 255 * 255 - len(frame))) # Space out elements in each size 255 chunk - frame = np.ravel(frame.reshape(len(frame) // 255, 255), "F")[: frame_size // 2] ^ frame_xor + frame = np.ravel(frame.reshape(len(frame) // 255, 255), "F")[: frame_size // 2] frame = np.ravel(np.column_stack((frame >> 4, frame & 0b1111))) frame = np.concatenate( ( |