Exiv2 / exiv2

Image metadata library and tools
http://www.exiv2.org/
Other
924 stars 278 forks source link

Canon lens handling regression in 0.28.0 #2746

Closed douzzer closed 6 months ago

douzzer commented 1 year ago

Describe the bug

Up to and including 0.27.7-release, I'm able to get correct lens detection for this lens setup in Darktable, by putting this in ~/.exiv2:

[canon]
748=Canon EF 100-400mm f/4.5-5.6L IS II USM + 1.4x extender

But with 0.28.0-release, that doesn't work anymore, and the lens is misdetected as Tamron. Nothing else I've tried has worked. In particular, when I tried patching out the conflicting Tamron lenses, Darktable reported "Lens 748 not found" or words to that effect, even though obviously the Canon 748 entry is still there. This is the patch I tried:

--- exiv2-0.28.0/src/canonmn_int.cpp.dist       2023-05-08 11:01:13.000000000 -0500
+++ exiv2-0.28.0/src/canonmn_int.cpp    2023-08-26 12:42:58.326572444 -0500
@@ -1865,8 +1865,6 @@ constexpr TagDetails canonCsLensType[] =
                                           {747, "Canon EF 100-400mm f/4.5-5.6L IS II USM"},
                                           {747, "Tamron SP 150-600mm f/5-6.3 Di VC USD G2"},  // 1
                                           {748, "Canon EF 100-400mm f/4.5-5.6L IS II USM + 1.4x"},
-                                          {748, "Tamron 100-400mm f/4.5-6.3 Di VC USD + 1.4x"},  // 1
-                                          {748, "Tamron 70-210mm f/4 Di VC USD + 2x"},           // 2
                                           {749, "Tamron 100-400mm f/4.5-6.3 Di VC USD + 2x"},
                                           {749, "Canon EF 100-400mm f/4.5-5.6L IS II USM + 2x"},  // 1
                                           {750, "Canon EF 35mm f/1.4L II USM"},

The most worrisome syndrome though is that the override entry in ~/.exiv2 is being ignored.

To Reproduce

I've posted a CR2 with this lens here

(github has a 25MB attachment limit, and doesn't allow CR2 files besides.)

I'm running Darktable 4.4.2 but it wasn't the variable, and it's detecting the lens correctly when built and linked against exiv2-0.27.7.

To see the syndrome, set up the ~/.exiv2 above, import the picture into DT, and admire the detected lens ID on the left.

Note that you'll see the no-lens-info error in the lens correction tool for both the Canon and Tamron versions of ID 748. I run a Lensfun with the correction data for the Canon setup patched in.

Expected behavior

In the left pane with the image attributes, the lens entry should read

Canon EF 100-400mm f/4.5-5.6L IS II USM + 1.4x extender

(Which is what it says when built+linked with v0.27.7, and it's what I have in my ~/.exiv2.)

Desktop (please complete the following information):

Additional context

I believe this DT issue relates: https://github.com/darktable-org/darktable/issues/14882

kmilos commented 6 months ago

@zisoft Looks like it's better to avoid switching locale altogether, especially from a library... Since exiv2 requires C++17 anyway, std::from_chars (or some custom implementation) seems to be the best option for something this "simple":

Unlike other parsing functions in C++ and C libraries, std::from_chars is locale-independent, non-allocating, and non-throwing. Only a small subset of parsing policies used by other libraries (such as std::sscanf) is provided. This is intended to allow the fastest possible implementation that is useful in common high-throughput contexts such as text-based interchange (JSON or XML).