janalysis/jpeg.py
def _run_length_encode(serial_list):
    """Perform run length encoding on a serialized block."""
    serial_index = 0
    run_length = []
    while serial_index < 64:
        if serial_index == 0:
            value = serial_list[serial_index]
            run_length.append((get_magnitude_dc(value),
                               get_ones_complement_bit_string(value)))
            serial_index += 1
            continue
        zero_count = 0
        while serial_index < 64 and serial_list[serial_index] == 0:
            zero_count += 1
            serial_index += 1
        if serial_index == 64:  # Rest of the block is zero
            run_length.append((0x00, ''))
            break
        while zero_count > 15:  # Encode as 16 zeroes as needed till nonzero
            run_length.append((0xF0, ''))
            zero_count -= 16
        nonzero_value = serial_list[serial_index]
        zero_count <<= 4
        zrl = zero_count | get_magnitude_dc(nonzero_value)
        run_length.append((zrl,
                           get_ones_complement_bit_string(nonzero_value)))
        serial_index += 1
    return run_length
Perform run length encoding on a serialized block.
Perform run length encoding on a serialized block.
Perform run length encoding on a serialized block .
def _run_length_encode(serial_list):
    serial_index = 0
    run_length = []
    while serial_index < 64:
        if serial_index == 0:
            value = serial_list[serial_index]
            run_length.append((get_magnitude_dc(value),
                               get_ones_complement_bit_string(value)))
            serial_index += 1
            continue
        zero_count = 0
        while serial_index < 64 and serial_list[serial_index] == 0:
            zero_count += 1
            serial_index += 1
        if serial_index == 64:  
            run_length.append((0x00, ''))
            break
        while zero_count > 15:  
            run_length.append((0xF0, ''))
            zero_count -= 16
        nonzero_value = serial_list[serial_index]
        zero_count <<= 4
        zrl = zero_count | get_magnitude_dc(nonzero_value)
        run_length.append((zrl,
                           get_ones_complement_bit_string(nonzero_value)))
        serial_index += 1
    return run_length
def _run_length_encode ( serial_list ) : serial_index = 0 run_length = [ ] while serial_index < 64 : if serial_index == 0 : value = serial_list [ serial_index ] run_length . append ( ( get_magnitude_dc ( value ) , get_ones_complement_bit_string ( value ) ) ) serial_index += 1 continue zero_count = 0 while serial_index < 64 and serial_list [ serial_index ] == 0 : zero_count += 1 serial_index += 1 if serial_index == 64 : run_length . append ( ( 0x00 , '' ) ) break while zero_count > 15 : run_length . append ( ( 0xF0 , '' ) ) zero_count -= 16 nonzero_value = serial_list [ serial_index ] zero_count <<= 4 zrl = zero_count | get_magnitude_dc ( nonzero_value ) run_length . append ( ( zrl , get_ones_complement_bit_string ( nonzero_value ) ) ) serial_index += 1 return run_length
Perform run length encoding on a serialized block.
Perform run length encoding on a serialized block .
"""Perform run length encoding on a serialized block.""" # Rest of the block is zero # Encode as 16 zeroes as needed till nonzero
serial_list