Demosaicing seems not multi-threaded...

Hello,

I'm currently working on a scientific code that performs correlations to assess displacements between pairs of RAW images. I say that the RAW images come from a PhaseOne IQ180 because it may be the cause of my problem: the demosaicing seems not be accelerated with OpenMP.

To make the test, I compiled libraw with OpenMP activated (and with a compiler that support OpenMP).
During demosaicing, only one core (over the 8 cores I've got) works, maybe excepted at the very beginning where all cores seem to work at about, let say, 20% for a quick moment (as htop suggests). I tried to set different values to the system variable OMP_NUM_THREADS, but it does not change the behavior.

My questions are:
Am I doing something wrong?
Is the demosaicing procedure for PhaseOne raw format fully parallelized?

Thank you for the insights you can give me, and congratulation for the time spent in developing libraw.
Vincent Richefeu

Forums: 

Libraw contains several

Libraw contains several demosaic methods. Which one do you use?

-- Alex Tutubalin @LibRaw LLC

I've made the tests for

I've made the tests for OpenMP with the model 1 (which is the model that I use most often).
I never use model 0 because it makes the accuracy of tracked displacement worse; and never go after model 3.

'model 1' is 'VNG

'model 1' is 'VNG interpolation', right? This interpolation is not OpenMP accelerated in LibRaw.

-- Alex Tutubalin @LibRaw LLC

Yes, 'model 1' means

Yes, 'model 1' means 'iProcessor.imgdata.params.user_qual = 1' in my question.
Thank you for replying, it's good to know (I didn't find this information in the documentation).
After some rapid tests, it appears indeed that 'only' the interpolations 5 to 9 are OpenMP accelerated.
Thank you again!

If you build libraw *without*

If you build libraw *without* additional 'demosaic packs', then interpolations from 5 to 10 are not compiled in (and library will fallback to user_qual=3, AHD interpolation)
OpenMP accelerated are:
ppg interpolation (user_qual = 2) and AHD (user_qual=3)

-- Alex Tutubalin @LibRaw LLC

Right! I've made my tests too

Right! I've made my tests too quickly.
Is user_qual set to 3 by libraw if the user set it to 9 for example (without additional demoniac packs)?
Anyway, it is now clear. Thank you very much for answering.

Yes, fallback to AHD (user

Yes, fallback to AHD (user_qual=3) is explicitly stated in docs:
===
Values 5-9 are useful only if "LibRaw demosaic pack GPL2" compiled in (see README.demosaic-packs in your distribution for details). Value 10 is useful only if LibRaw compiled with "LibRaw demosaic pack GPL3". If some interpolation method is unsupported because LibRaw compiled without corresponding demosaic pack, AHD interpolation will be used without any notice.
===
http://www.libraw.org/docs/API-datastruct-eng.html#libraw_output_params_t

-- Alex Tutubalin @LibRaw LLC

I understand that fallback to

I understand that fallback to AHD is automatic when 'libraw can not do otherwise'.
But my question was about the value stored by user_qual after dcraw_process.

I've made this test: set user_qual to 18 (to be sure to activate the fallback to AHD), call of dcraw_process, and then display the value of user_qual which were still 18. So, is there a solution to know if the fallback has actually happened?

Good question :)

Good question :)

I'll add bits to imgdata.process_warning field in coming LibRaw 0.17

-- Alex Tutubalin @LibRaw LLC

Thank you!

Thank you!
I've seen the field LIBRAW_WARN_FALLBACK_TO_AHD in LibRaw 0.17.
I suppose that testing (imgdata.process_warning & LIBRAW_WARN_FALLBACK_TO_AHD) after processing will allow one to display a warning.

Yes, check for this bit if

Yes, check for this bit if you're worried about AHD fallback

-- Alex Tutubalin @LibRaw LLC