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

Canon ColorData4: for ColorDataVersion=3, SpecularWhiteLevel is most likely at 617 #233

Closed
LebedevRI opened this issue Dec 4, 2023 · 9 comments

Comments

@LebedevRI
Copy link

  if(f == ColorDataFormat::ColorData4 && ver == 3) {
    for(unsigned i = 0x0e7; i != wb->count; ++i) {
      auto val = wb->getU16(i);
      if(val >= 16384>>2 && val <= 16384)
        writeLog(DEBUG_PRIO::ERROR, "i=%04i: %i", i, val);
    }
    ThrowRDE("ver=3");
  }
~/raw-camera-samples/raw.pixls.us/Canon$ ~/rawspeed/build-Clang17-release/src/utilities/rstest/rstest EOS\ 40D/*.CR2
EOS 40D/_MG_0153.CR2                                   : starting decoding ... 
EOS 40D/_MG_0154.CR2                                   : starting decoding ... 
RawSpeed:i=0586: 7899
RawSpeed:i=0602: 9374
RawSpeed:i=0617: 13481
RawSpeed:i=0629: 5826
RawSpeed:i=0634: 4195
RawSpeed:i=0637: 4262
RawSpeed:i=0657: 8191
RawSpeed:i=0659: 8191
EOS 40D/_MG_0153.CR2                                   :  10 MB /   65 ms
RawSpeed:i=0586: 8137
RawSpeed:i=0602: 9366
RawSpeed:i=0617: 13450
RawSpeed:i=0629: 5826
RawSpeed:i=0634: 4195
RawSpeed:i=0637: 4262
RawSpeed:i=0657: 8191
RawSpeed:i=0659: 8191
EOS 40D/_MG_0154.CR2                                   :   5 MB /   80 ms
EOS 40D/_MG_0153.CR2 failed: hash/metadata mismatch
EOS 40D/_MG_0154.CR2 failed: hash/metadata mismatch
Total decoding time: 0.145s

WARNING: the following 2 tests have failed:
EOS 40D/_MG_0153.CR2 failed: hash/metadata mismatch
EOS 40D/_MG_0154.CR2 failed: hash/metadata mismatch
See rstest.log for details.

13481 and 13450 seem within ballpark for the specular white level for those files.

@LebedevRI
Copy link
Author

@boardhead

diff --git a/lib/Image/ExifTool/Canon.pm b/lib/Image/ExifTool/Canon.pm
index f3ec2434..e8a775ba 100644
--- a/lib/Image/ExifTool/Canon.pm
+++ b/lib/Image/ExifTool/Canon.pm
@@ -7494,16 +7494,21 @@ my %ciMaxFocal = (
     0x280 => { #PH
         Name => 'RawMeasuredRGGB',
         Format => 'int32u[4]',
         Notes => 'raw MeasuredRGGB values, before normalization',
         # swap words because the word ordering is big-endian, opposite to the byte ordering
         ValueConv => \&SwapWords,
         ValueConvInv => \&SwapWords,
     },
+    0x269 => {
+        Name => 'SpecularWhiteLevel',
+        Condition => '$$self{ColorDataVersion} == 3',
+        Format => 'int16u',
+    },
     0x2b4 => { #IB
         Name => 'PerChannelBlackLevel',
         Condition => '$$self{ColorDataVersion} == 4 or $$self{ColorDataVersion} == 5',
         Format => 'int16u[4]',
     },
     0x2b8 => { #IB
         Name => 'NormalWhiteLevel',
         Condition => '$$self{ColorDataVersion} == 4 or $$self{ColorDataVersion} == 5',

@LebedevRI
Copy link
Author

And it looks like that blackLevel[4] is only at 231 (0x0E7), there are no other black levels for that format+version.

LebedevRI added a commit to LebedevRI/rawspeed that referenced this issue Dec 4, 2023
LebedevRI added a commit to LebedevRI/rawspeed that referenced this issue Dec 4, 2023
LebedevRI added a commit to LebedevRI/rawspeed that referenced this issue Dec 4, 2023
@LebedevRI
Copy link
Author

(@boardhead note that this is not a duplicate of #232.)

@boardhead
Copy link
Contributor

Thanks for this. However, this seems to give inconsistent results for the 40D samples I have on hand:

exiftool ../pics/Canon*40D* -specularwhitelevel -if 'defined $specularwhitelevel' -H -firmwareversion
======== ../pics/Canon40D-1.0.4.jpg
0x0269 Specular White Level            : 16113
0x00ff Firmware Version                : 1.0.4
======== ../pics/CanonEOS40D.CR2
0x0269 Specular White Level            : 19
0x00ff Firmware Version                : 1.0.3
======== ../pics/CanonEOS40D.jpg
0x0269 Specular White Level            : 145
0x00ff Firmware Version                : 1.0.3
======== ../pics/CanonEOS40D_firmware1.0.4.CR2
0x0269 Specular White Level            : 45
0x00ff Firmware Version                : 1.0.4
======== ../pics/CanonEOS40D_firmware1.0.5.CR2
0x0269 Specular White Level            : 228
0x00ff Firmware Version                : 1.0.5
======== ../pics/CanonEOS40D_sRAW.CR2
0x0269 Specular White Level            : 816
0x00ff Firmware Version                : 1.0.3
======== ../pics/CanonEOS40D_sRAW.dng
0x0269 Specular White Level            : 816
0x00ff Firmware Version                : 1.0.3
    7 image files read
  • Phil

@LebedevRI
Copy link
Author

Oh, nice catch!
Looking at more samples, i do agree that it's not 0x0269.
What about 0x0275?

LebedevRI added a commit to darktable-org/rawspeed that referenced this issue Dec 6, 2023
As being noted in exiftool/exiftool#233,
`617` *really* doesn't look right on a wider sample set,
while `629` looks reasonable-ish (unlike `586`/`602` either).
@boardhead
Copy link
Contributor

For all my 40D samples 0x0275 is less than 7300, but for all my other Canon samples the value is greater than 9990, so I don't think this is it.

  • Phil

@LebedevRI
Copy link
Author

@cytrinox
Copy link

cytrinox commented Dec 8, 2023

Based on my research 40D Colordata has no whitepoint information. I've hardcoded whitepoint to 13600 (iirc source was dcraw.c).
https://github.com/dnglab/dnglab/blob/main/rawler/data/cameras/canon/40d.toml

Edit: FYI Reference to colordata implementation in dnglab: https://github.com/dnglab/dnglab/blob/main/rawler/src/decoders/cr2/colordata.rs#L35

@LebedevRI
Copy link
Author

Ok, looking at some more samples (@MStraeten, thank you!),
i'm going to agree that it does not seem like there's SpecularWhiteLevel
in that camera's MakerNotes (and thus, likely in any earlier cameras too).

Thank you all!

Roman

@LebedevRI LebedevRI closed this as not planned Won't fix, can't repro, duplicate, stale Dec 10, 2023
LebedevRI added a commit to darktable-org/rawspeed that referenced this issue Dec 10, 2023
After further analysis, it does not look like either one of these
is `SpecularWhiteLevel` for that camera. Probably it simply isn't there.

https://discuss.pixls.us/t/any-canon-eos-40d-users-around-a-bit-of-testing-wanted/40843
exiftool/exiftool#233

This reverts commit bd9074a.
This reverts commit ccb06f6.
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

3 participants