DngDecoder: default white level for floats is simply 1#636
Conversation
|
I don't think this is better. |
Better or not is not relevant - it is what the SDK does. |
in addition to the SDK source code, this is also written in the standard: https://helpx.adobe.com/content/dam/help/en/photoshop/pdf/DNG_Spec_1_7_1_0.pdf#page=29 |
|
I'm fully aware of that, and none of that is a relevant argument here, |
|
The spec is somewhat ambiguous: says 1.0 but type is SHORT/LONG. The SDK removes the ambiguity for me. |
|
Spec says default is 1.0 for float, it doesn’t say it’s the only possible value. |
Does SDK really store |
|
Yep, see the link. |
|
Aha. But as i have said, i don't see how that is relevant here. |
|
It's the correct default value 3rd parties could assume and rely on, just like 2^bps-1. |
|
Is this a practical or theoretical concern? |
|
For example, darktable-org/darktable#16206 relies on either the float DNG file itself carries WhiteLevel=1, or rawspeed feeds it a 1 if absent. |
|
Once again, the fact that SDK returns We are not required to be bug-for-bug compatible with some other library. There is absolutely no reason whatsoever why that idiotic behavior DNG spec does not say that for FP DNG's, white level of Likewise, there's inversion of cause and effect ordering there. |
The DNG spec text says the default value for float files is 1.0, not 65535.0, nor 65536.0... I don't think there's anything arbitrary/magic here. That's like saying one can return a random number in the integer case, while the spec says it's 2^bps-1? Let's just remove both defaults then? And yes, the previous PR was a bit hasty before the dust settled down, sorry about that. |
Once again, there is a confusion/conflation of the specification, I never argued that the default isn't 1.0, i only said that we can't represent float white level, |
|
#638 either makes things slightly more sufferable, or worse. |
I feel it's overcomplicating things... |
|
After sleeping on this, the wordiage that should have been here, and would have helped, is: One-line commit messages (and PR descriptions) suck. But even with that, #638 is correct. |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #636 +/- ##
===========================================
+ Coverage 60.78% 60.80% +0.01%
===========================================
Files 266 266
Lines 15947 15947
Branches 2047 2047
===========================================
+ Hits 9694 9696 +2
+ Misses 6125 6123 -2
Partials 128 128
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Formally, yes. But thanks for reconsidering, I feel it makes sense and is the pragmatic thing to do here. I'll improve the commit message. Shall I put those comments in the code as well? |
9a9db10 to
d935c65
Compare
Yes, i think something like this should be best: |
1. We divide by white level to normalize the image s.t. the 1.0 becomes the white level. 2. In DNG spec, white level is always an integer, there can not be a non-integral white level. 3. Additionally, no white level for FP DNG's means that it is pre-normalized (default is 1.0). Therefore, we can surmise that a) FP DNG's never have white level of <1.0 b) FP DNG's always have integral white level c) if FP DNG has a white level of `w`, it is always correct to divide by float(w) to normalize the image ... therefore, we can, as an optimization, store FP DNG white level as an integer. This matches DNG SDK behavior.
|
@kmilos Thank you! |
Therefore, we can surmise that
a) FP DNG's never have white level of <1.0
b) FP DNG's always have integral white level
c) if FP DNG has a white level of
w, it is always correct to divide byfloat(w)to normalize the image... therefore, we can, as an optimization, store FP DNG white level as an integer.
This matches DNG SDK behavior.