-
Notifications
You must be signed in to change notification settings - Fork 269
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
Potential problem with compressed high ISO CR3 #624
Comments
I can confirm that there is some sort of problem.
I've not tested it with libraw itself but I can reproduce all this problems with dnglab/rawler. If I filter out too big shift values and assume 1 in such cases, the image output looks "okay". Maybe this issue (in libraw context like darktable issues) can only be triggered by some compiler or code optimizations which has an impact on the output of the shl operator? Same problem for the issue reported here: https://discuss.pixls.us/t/cr3-import-into-darktable-4-6-0/41172/7 |
Here are some more results: Problematic line(s) are:
For quantVal = 36 or quantVal = 40, there is an overflow because it results in: When replacing shift left by rotate left, multiplier is 1 and image looks correct: And same issue for the image linked in this issue when multiplier is 0: @LibRaw Please excuse that I've not using libraw directly but debugging the problem with dnglab was so much easier for me 😄 PS: in libraw the relevant line is used 3 times (for each image level 1..3). Edit: CR3 file for first example: https://discuss.pixls.us/uploads/short-url/6hX4kSJfZLX1VTer9DpteiQPRph.CR3 |
Investigated via debugger, disassembly and Intel Software manual
So, for 32-bit code shl eax,cl(=0x20) is equal to NOP :) Conclusion: 0x1f mask should be added to the shift value to allow accurate 64-bit execution. |
If I understand correctly, RawDigger is compiled as 32 bit app and the shift becomes a NOP on 32 bit targets. But on 64 bit it should still be a 32 bit operand (quantVal), so why is it zero in this case? BTW, I assume the code can be simplified because
To be honest - I've no idea why such big values should be used in this IQ step. In this branch, the shift bits is always >=26. |
RawDigger is compiled as 64-bit app. |
Do I understand correctly that wrapping_shl for 32-bit type is val << (shift & 0x1f) ? |
Yes.
|
Although we're still unable to reproduce the problem with any compiler we use, this patch will fix it even if (wrong) 64-bit shift generated: e231b01 |
darktable 4.6.0 uses LibRaw and displays compressed CR3 images in very poor quality under certain circumstances.
This was observed on compressed RAWs created with a Canon EOS R6 Mark II with high ISO (25.600) values.
These images have clear stair-stepping effects and severe loss of detail.
In a certain way, the problem can't be a bug because the EOS R6 Mark II is not yet officially supported by LibRaw. However, as I understand it, the lack of support is more of a color management issue and less of a problem that CR3 cannot be processed in general. Also, I've only noticed these issues with high ISO images so far. You should at least keep an eye on the issue while making LibRaw officially available for the EOS R6 Mark II.
darktable screenshot of a compressed CR3 (CRAW) taken with EOS R6 Mark II:
![grafik](https://private-user-images.githubusercontent.com/17358088/293056643-854d7a34-05f8-42fb-a08c-ff3a8a2430aa.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgzMDg2MTQsIm5iZiI6MTcxODMwODMxNCwicGF0aCI6Ii8xNzM1ODA4OC8yOTMwNTY2NDMtODU0ZDdhMzQtMDVmOC00MmZiLWEwOGMtZmYzYThhMjQzMGFhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjEzVDE5NTE1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE2MzI4NmYxMWE3YjQzNjIwZjQ5MzQ4YzA4ODUzNzBkYzZiNTk5ZDYzYjc1YjBkODA3YjZhNzVhOTk4N2Y5NGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.bFeDD6mFjiVSPz7KZZT0-PHenGNfJIHIhwhr_veA5Bc)
darktable screenshot of an uncompressed CR3 with the exact same camera settings otherwise:
![grafik](https://private-user-images.githubusercontent.com/17358088/293056780-5dad4e3d-7ede-40ed-a218-80c6cab5e92e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgzMDg2MTQsIm5iZiI6MTcxODMwODMxNCwicGF0aCI6Ii8xNzM1ODA4OC8yOTMwNTY3ODAtNWRhZDRlM2QtN2VkZS00MGVkLWEyMTgtODBjNmNhYjVlOTJlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjEzVDE5NTE1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZiN2U3Y2Y2Mjk4ODc3YjBkODRmMjI3ZDQzMzgwMzhiNzBhNWM0MzEzYTNkZDcxNmI1NmZjYTNjNDVkMWE1OGEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.e9Knq9WwxMudC_0MW8-AY6med7r8YYVpOnk6r47EE4E)
The problem has already been discussed in detail at darktable and it seems to be an issue with LibRaw. The problem was also identified with RawTherapy, which also uses LibRaw.
See previous discussion at darktable with lots of information and examples linked there:
darktable-org/darktable#15955.
If you convert the CR3 images to DNG, then the DNG images are displayed normally by darktable.
The CR3 images also look as they should in Canon Digital Photos Professional.
The text was updated successfully, but these errors were encountered: