cam_xyz ColorMatrix2 mismatch

I've been trying to debug some issues that I've been experiencing on Canon 6D files, and started comparing the matrices shown by raw-identify on the original .cr2 and that same file converted to .dng. Based on this post, my understanding was that cam_xyz should exactly match ColorMatrix2. However, here is what I see for one such raw file (the numbers are the same for all the files I've tested):

Original CR2:

Camera2RGB matrix:
1.7944 -0.5655 -0.2289
-0.2979 1.5021 -0.2042
0.0735 -0.6031 1.5296

XYZ->CamRGB matrix:
0.8621 -0.2197 -0.0787
-0.3150 1.1358 0.0912
-0.1161 0.2400 0.4836

Converted DNG:

Camera2RGB matrix:
1.9125 -1.0587 0.1461
-0.2249 1.6465 -0.4217
0.0099 -0.5093 1.4995

XYZ->CamRGB matrix:
0.8621 -0.2197 -0.0787
-0.3150 1.1358 0.0912
-0.1161 0.2400 0.4836

DNG Illuminant 1: Illuminant A
DNG Illuminant 2: D65
camRGB -> sRGB Matrix:
1.9125 -0.2249 0.0099
-1.0587 1.6465 -0.5093
0.1461 -0.4217 1.4995

DNG color matrix 1:
0.7546 -0.1435 -0.0929
-0.3846 1.1488 0.2692
-0.0332 0.1209 0.6370

DNG color matrix 2:
0.7034 -0.0804 -0.1014
-0.4420 1.2564 0.2058
-0.0851 0.1994 0.5758

[...]

To date I had been using cam_xyz as if it were ColorMatrix2, approximately following the DNG rendering guidelines and it had worked ok. But for 6D files this doesn't work, since the cam_xyz matrix doesn't seem to match. If I manually enter the values from the DNG color matrix 2 above into my test program, I get results that (more or less) match what I'm expecting.

Is this just an errant entry in the adobe_coeffs function? Or is there something further I need to do to extract the correct ColorMatrix2 from libraw?

Thanks for your help, and as always, thanks for creating such a great piece of software!

Forums: 

Dear Sir:

Dear Sir:

> cam_xyz should exactly match ColorMatrix2

No, cam_xyz is taken from the standard data, ColorMatrix2 is taken from the particular dng file.

At the time we put the standard data into adobe_coeff under "Canon EOS 6D" the matrix that Adobe had in their profile was not particularly good. You can replace the matrix with the one you prefer and recompile.

--
Iliah Borg

Follow-up Questions

Ah, got it. Thanks for getting back to me. I've got a few follow-up questions:

1. Is there a list of cameras for which the matrices are known to be not particularly good so that we can work on improving them?
2. Would you accept a PR to update the matrix for the 6D to the values above?
3. When you say "standard data" -- what does that mean? Based on the comments in the code, my understanding was that the matrices were mostly extracted from DNGs, however it seems that the 6D values came from somewhere else?

For what it's worth, this particular matrix was pretty far off (it was mapping reds to a weird shade of almost orange); I don't know about the general case, but I do think it would be worthwhile to fix this matrix in particular.

Thanks again,

James.

Dear Sir:

Dear Sir:

1. We suggest that every software developer decides for himself how to proceed ;)
2. Most probably.
3. LibRaw supports more cameras than Adobe do in their public releases. For the cameras that are supported by Adobe we mostly use Adobe matrices. Normally we add comments when we don't.

The "off" look depends a lot on how one maps values to RGB working space. If simple clipping (especially to sRGB) is used and the tone curve is "simple", things may be indeed off.

On a side note, LibRaw is not meant to be a full-fledged raw converter, the colour rendering is there just for the purpose of having a preview.

--
Iliah Borg