diff options
Diffstat (limited to 'encoder.py')
-rw-r--r-- | encoder.py | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -23,11 +23,11 @@ args = parser.parse_args() cheight = cwidth = max(args.height // 10, args.width // 10) midwidth = args.width - 2 * cwidth frame_size = args.height * args.width - 4 * cheight * cwidth +# Divide by 2 for 4-bit color frame_xor = np.arange(frame_size // 2, dtype=np.uint8) # reedsolo breaks message into 255-byte chunks # raptorq can add up to 4 extra bytes -# Divide by 2 for 4-bit color -rs_size = frame_size - (frame_size // 2 + 254) // 255 * int(args.level * 255) - 4 +rs_size = frame_size // 2 - (frame_size // 2 + 254) // 255 * int(args.level * 255) - 4 with open(args.input, "rb") as f: data = f.read() @@ -55,7 +55,7 @@ def get_frame(): # 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(np.reshape(frame, (len(frame) // 255, 255)), "F")[: frame_size // 2] ^ frame_xor + frame = np.ravel(frame.reshape(len(frame) // 255, 255), "F")[: frame_size // 2] ^ frame_xor frame = np.ravel(np.column_stack((frame >> 4, frame & 0b1111))) frame = np.concatenate( ( |