Skip to content
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

SRW: Keep scale for lossy compressed v3 images #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cytrinox
Copy link

@cytrinox cytrinox commented May 5, 2022

While integrating srw support into dnglab, I stumbled across this little bug. The Samsung NX500 (see raw samples at raw.pixls.us) produces 12 and 14 bit images with lossy or lossless compression. For lossy, the srw3 scale parameter is used to rescale the pixels. The scale is recalculated every 64 pixels. Resetting the scale to zero in other cases leads to invalid images.

Output of an image decoded with invalid scale values:

grafik

Feel free to modify this PR for your needs.

Just FYI: I've played around the srw3 decoder and I'm not sure if it is properly implemented. The diff and out values are all clamped to u16. If the calculation is done entirely with i32 and after full decompression everything is clamped to u16, the checksum for the output is different. And again different when only one row (in the for-height loop) is keept as i32 and then clamped and copied into the out buffer. So three methods, three different outputs. I don't see any visible difference, I just wonder what's the correct method is. I can't find a source at opensource.samsung.com.

The scale is recalculated every 64 pixels. Resetting the scale
to zero in other cases leads to invalid images.
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

Successfully merging this pull request may close these issues.

None yet

1 participant