Bug 378804

Summary: lensfun uses only one core, pls. parallize [patch]
Product: [Applications] digikam Reporter: Hans-Peter <hans-ph>
Component: Plugin-Editor-LensCorrectionAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: wishlist CC: caulier.gilles, metzpinguin
Priority: NOR    
Version: 5.5.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 5.6.0
Attachments: Parallel processing of stage 1,2,3 of Lensfun filter.
Screenshot of wrong result at init with Geometry correction selected.
Screenshot of good result after to apply Distorsion + Geometry corrections, and finally let's Geometry alone selected...
Test JPEG image to reproduce the dysfunction.
lensfunfilter.patch

Description Hans-Peter 2017-04-15 09:55:17 UTC
i noticed that automatic lens correction (currently DK 5.5) is very slow and
uses only one CPU core. When doing this in Gimp (lensfun-plugin), its way
faster and uses all cores.

This is in Manjaro on a Core-i5

So please enable all cores (port to QtConcurrent).

Thanks
Comment 1 caulier.gilles 2017-04-17 13:06:55 UTC
Created attachment 105056 [details]
Parallel processing of stage 1,2,3 of Lensfun filter.

The patch attached process in parallel all filters used with Lensfun interface.

The image is cut as portions, depending of CPU available and forked on each core with QtConcurent. 

It still certainly a race condition at init. Sometime the final redering is corrupted at the first time, but changing a settings give a good result finaly.

So the main changes are here, but a polish is required before to be applied on git/master.

Gilles Caulier
Comment 2 caulier.gilles 2017-04-17 13:08:50 UTC
Maik,

If you can reproduce the problem, please take a look in code. Personalty, i don't see the dysfunction. Perhaps the problem is located on front of filter, when the GUI scan metadata to found right settings from image... 

Gilles
Comment 3 caulier.gilles 2017-04-17 13:13:47 UTC
I identified that Geometry correction introduce the problem at first time when option is only selected.

After to select Distortion, for ex, all is fine. Deselecting Distortion and only select Geometry give a good result.

Gilles
Comment 4 caulier.gilles 2017-04-17 13:14:38 UTC
Created attachment 105057 [details]
Screenshot of wrong result at init with Geometry correction selected.
Comment 5 caulier.gilles 2017-04-17 13:16:04 UTC
Created attachment 105058 [details]
Screenshot of good result after to apply Distorsion + Geometry corrections, and finally let's Geometry alone selected...
Comment 6 caulier.gilles 2017-04-17 13:18:20 UTC
Created attachment 105059 [details]
Test JPEG image to reproduce the dysfunction.
Comment 7 Maik Qualmann 2017-04-17 15:33:36 UTC
Yes, I can confirm the dysfunction. Another thing is the chromatic aberration correction. Does not look correct either. I'm looking at it tonight.

Maik
Comment 8 Maik Qualmann 2017-04-17 17:46:23 UTC
Created attachment 105063 [details]
lensfunfilter.patch

fix vignetting / color correction and distortion / geometry corrections.

Maik
Comment 9 caulier.gilles 2017-04-17 20:31:32 UTC
Comment on attachment 105063 [details]
lensfunfilter.patch

You have right Maik,

This version of the patch fix the problem. I forget to catch loop variable at end of last filter stage. 

So you can apply this patch over git/master now, and close this entry.

Thanks

Gilles
Comment 10 Maik Qualmann 2017-04-17 20:58:19 UTC
Git commit 0238f8a8234154b3d4c8877de94b72505f55ad7d by Maik Qualmann.
Committed on 17/04/2017 at 20:57.
Pushed by mqualmann into branch 'master'.

use QtConcurrent to parallelize the Lensfun filter and use all CPU cores
FIXED-IN: 5.6.0

M  +2    -1    NEWS
M  +119  -87   libs/dimg/filters/lens/lensfunfilter.cpp
M  +3    -0    libs/dimg/filters/lens/lensfunfilter.h

https://commits.kde.org/digikam/0238f8a8234154b3d4c8877de94b72505f55ad7d