diff options
author | Anthony Wang | 2024-04-23 01:42:51 -0400 |
---|---|---|
committer | Anthony Wang | 2024-04-23 01:42:51 -0400 |
commit | 3d940c0a1c9b5eee2adbbdd6f0a358e782a4df06 (patch) | |
tree | 4e54ee48ef45de9c0456d50371601bb411749763 /encoder.py | |
parent | dee89fcb301c804b340d199cf690868036f60e88 (diff) |
4-bit color for encoder, fix a ton of bugs
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( ( |