8000 pack14 crashes (fix included) · Issue #81 · schoolpost/PiDNG · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

pack14 crashes (fix included) #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
OParczyk opened this issue Mar 9, 2024 · 1 comment
Open

pack14 crashes (fix included) #81

OParczyk opened this issue Mar 9, 2024 · 1 comment

Comments

@OParczyk
Copy link
OParczyk commented Mar 9, 2024

When trying to save 14b raw data as a dng (see #75 for why I have to do that) PiDNG crashes:

out[:, ::7] = data[:, ::6] >> 6
    ~~~^^^^^^^^
ValueError: could not broadcast input array from shape (3000,502) into shape (3000,752)

This is due to the packing algorithm being just plain wrong. I'd propose the following fix, which works just fine for me:

def pack14(data : np.ndarray) -> np.ndarray:
    out = np.zeros((data.shape[0], int(data.shape[1]*(1.75))), dtype=np.uint8)
    out[:, ::7] = data[:, ::4] >> 6
    out[:, 1::7] = ((data[:, ::4] & 0b0000000000111111) << 2)
    out[:, 1::7] += data[:, 1::4] >> 12
    out[:, 2::7] = ((data[:, 1::4] & 0b0000111111110000) >> 4)
    out[:, 3::7] = ((data[:, 1::4] & 0b0000000000001111) << 4)
    out[:, 3::7] += data[:, 2::4] >> 10
    out[:, 4::7] = ((data[:, 2::4] & 0b0000001111111100) >> 2)
    out[:, 5::7] = ((data[:, 2::4] & 0b0000000000000011) << 6)
    out[:, 5::7] += data[:, 3::4] >> 8
    out[:, 6::7] = data[:, 3::4] & 0b0000000011111111
    return out

If wanted I could create a pull request for it, in which case I'd probably propose a couple other changes here to make these functions more robust.

@G-DP
Copy link
G-DP commented Mar 28, 2024

OParczyk, you're my hero. Thank you for this contribution!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0