Simplified flag_bits logic
This commit is contained in:
6
main.py
6
main.py
@@ -130,21 +130,17 @@ class BZZCompressor:
|
|||||||
# hitting an index out of bounds error
|
# hitting an index out of bounds error
|
||||||
flag_bits = data[index] + 0x100
|
flag_bits = data[index] + 0x100
|
||||||
index = index + 1
|
index = index + 1
|
||||||
# used to track how far in flag_bits we are
|
|
||||||
counter = 8
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while num_flags > 0:
|
while num_flags > 0:
|
||||||
carry = bin(flag_bits)[-1]
|
carry = bin(flag_bits)[-1]
|
||||||
flag_bits = flag_bits >> 1
|
flag_bits = flag_bits >> 1
|
||||||
counter = counter - 1
|
|
||||||
|
|
||||||
# if we are down to only 0 bits, we are out of file-driven data
|
# if we are down to only 0 bits, we are out of file-driven data
|
||||||
# Here we collect more flag bits and re-iterate the loop
|
# Here we collect more flag bits and re-iterate the loop
|
||||||
if counter == 0:
|
if flag_bits == 1:
|
||||||
flag_bits = data[index] + 0x100
|
flag_bits = data[index] + 0x100
|
||||||
index = index + 1
|
index = index + 1
|
||||||
counter = 8
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Carry means the next byte is raw data, no weird placement or indexing
|
# Carry means the next byte is raw data, no weird placement or indexing
|
||||||
|
Reference in New Issue
Block a user