That is a very common optimization and is not likely to be the issue. The problem is usually found in the expression itself, commonly either the right-side array element is undefined or the result overflows the variable.
On the 6th iteration of that loop the result of this expression is undefined:
Can you point me to a matrix that "libraw" will use to convert DNG file? (to XYZ) The "cam_xyz" contain all zeros, there should be some matrix being used.
gcc preprocessor does not count blank and comment lines, and I gave the wrong code section. sorry.
I pulled the rest of the warnings from the build log:
/tmp/portage/portage/media-libs/libraw-0.18.5/work/LibRaw-0.18.5/src/libraw_cxx.cpp: In member function ‘virtual int LibRaw::open_datastream(LibRaw_abstract_datastream*)’:
I finally found the culprit of the crash: the thread executing LibRaw ran out of stack space! I observed LibRaw crashing internally when I single step into the actual decoder for DNG.
By replacing "LibRaw rawProcessor;" with "LibRaw *rawProcessor = new LibRaw;", the crash went away :)
output_color sets output color space (0 - no conversion, 1 - convert to sRGB, etc)
If you use same camera color profile (e.g built-in into LibRaw, or use_camera_matrix and camera matrix does not change between shots), it is safe to use some conversion.
What about "imgdata.params.output_color" ? I noticed it is producing different outputs if I set it to 0 (RAW) or 1 (sRGB). I would like the output to be linear as I am already setting gamm[0] = gamm[1] = 1, but looks like this parameter is override some options..
This will result into full build infrastructure sharing:
- other libraries used (jpeg, xml2)
- complete build environment share to make sure your app compiled with same compiler/same settings to ensure same offsets in libraw structures
I don't think it is the file, because when use_rawspeed = 0 , LibRaw has no problem loading this file.
Would you be so kindly post links to the libraw_r.a and librawspeed.a compiled for macOS so I can download them to try out? PM me if it is not convenient to do it in the forum post.
camera matrix should be the same unless changed by camera based on temperature or self-calibration (may be some high-end digital backs?)
camera WB will change from shot to shot, indeed.
So, you may get camera multiplicators for the first shot in sequence and re-use it for next shots (user_mul).
Same with black level: it may change from shot to shot (e.g. Panasonic or Canon cameras), so get it for first shot then reuse (user_black, user_cblack)
You need to apply white balance (usually, before demosaic stage)
That is a very common optimization and is not likely to be the issue. The problem is usually found in the expression itself, commonly either the right-side array element is undefined or the result overflows the variable.
On the 6th iteration of that loop the result of this expression is undefined:
imgdata.idata.xtrans
Hi Alex,
Thanks for the quick reply!
Can you point me to a matrix that "libraw" will use to convert DNG file? (to XYZ) The "cam_xyz" contain all zeros, there should be some matrix being used.
Regards,
Mio
what is wrong with
loop if both xtrans and xtrans_abs are [6][6] arrays, so xtrans[0][35] is equal to xtrans[5][5]?
"libraw" does not average/weight DNG color data
cmatrix is camera color data, it used according to use_camera_matrix value.
gcc preprocessor does not count blank and comment lines, and I gave the wrong code section. sorry.
I pulled the rest of the warnings from the build log:
/tmp/portage/portage/media-libs/libraw-0.18.5/work/LibRaw-0.18.5/src/libraw_cxx.cpp: In member function ‘virtual int LibRaw::open_datastream(LibRaw_abstract_datastream*)’:
/tmp/portage/portage/media-libs/libraw-0.18.5/work/LibRaw-0.18.5/src/libraw_cxx.cpp:1784:64: warning: iteration 6 invokes undefined behavior [-Waggressive-loop-optimizations]
imgdata.idata.xtrans[0]
what 'iteration 6' mean in this context?
Hi, I'm getting the following warning from gcc-6.4.0 in libraw_cpp.cxx:
* /tmp/portage/portage/media-libs/libraw-0.18.5/work/LibRaw-0.18.5/src/libraw_cxx.cpp:1784:64: warning: iteration 6 invokes undefined behavior [-Waggressive-loop-optimizations]
CFLAGS="-O2 -march=native -ftree-vectorize -mprefer-avx128 -mvzeroupper -fstack-protector -ftree-loop-distribution -ftree-loop-distribute-patterns -pipe"
Code:
static inline void unpack28bytesto16x16ns(unsigned char *src, unsigned short *dest)
{
dest[0] = (src[3] << 6) | (src[2] >> 2);
dest[1] = ((src[2] & 0x3) << 12) | (src[1] << 4) | (src[0] >> 4);
dest[2] = (src[0] & 0xf) << 10 | (src[7] << 2) | (src[6] >> 6);
dest[3] = ((src[6] & 0x3f) << 8) | src[5];
dest[4] = (src[4] << 6) | (src[11] >> 2);
dest[5] = ((src[11] & 0x3) << 12) | (src[10] << 4) | (src[9] >> 4);
dest[6] = (src[9] & 0xf) << 10 | (src[8] << 2) | (src[15] >> 6);
dest[7] = ((src[15] & 0x3f) << 8) | src[14];
dest[8] = (src[13] << 6) | (src[12] >> 2);
dest[9] = ((src[12] & 0x3) << 12) | (src[19] << 4) | (src[18] >> 4);
dest[10] = (src[18] & 0xf) << 10 | (src[17] << 2) | (src[16] >> 6);
dest[11] = ((src[16] & 0x3f) << 8) | src[23]; ## line 1784
dest[12] = (src[22] << 6) | (src[21] >> 2);
dest[13] = ((src[21] & 0x3) << 12) | (src[20] << 4) | (src[27] >> 4);
dest[14] = (src[27] & 0xf) << 10 | (src[26] << 2) | (src[25] >> 6);
dest[15] = ((src[25] & 0x3f) << 8) | src[24];
}
use samples/unprocessed_raw.cpp as a starting point
Thanks for the quick response.
I found the answer to my question. It's very simple. For L *, use gamm [0] = 1/3 and gamm [1] = 9.033.
With best wishes, Konstantin
Output curve is used only on output phase (dcraw_make_mem_image or dcraw_ppm_tiff_writer)
So, you may modify source and replace calls to gamma_curve(...) by own output curve creation.
No direct way in LibRaw to do that, we'll consider to add some interface for user-defined curve in 0.19 release.
all postprocessing is done at dcraw_process() step.
Unpack only unpacks (uncompress for compressed formats) raw data and stores it without any modification
You mean demosaic the X-Trans CFA is done at the dcraw_process() step?
unpack only unpacks raw data ('as is')
interpolation is performed on dcraw_process() step
To use bilinear set
half_size to 0
user_qual to 0
So how do I specify bilinear filter?
When I execute unpack(), does it perform demosaic of the X-Trans CFA automatically?
Use bilinear. It is fast enough (but not perfect too)
Like the output of FastRawViewer?
What is criteria for 'best'?
Glad to hear.
Yes, LibRaw object is large
I finally found the culprit of the crash: the thread executing LibRaw ran out of stack space! I observed LibRaw crashing internally when I single step into the actual decoder for DNG.
By replacing "LibRaw rawProcessor;" with "LibRaw *rawProcessor = new LibRaw;", the crash went away :)
output_color sets output color space (0 - no conversion, 1 - convert to sRGB, etc)
If you use same camera color profile (e.g built-in into LibRaw, or use_camera_matrix and camera matrix does not change between shots), it is safe to use some conversion.
Thank you Alex,
What about "imgdata.params.output_color" ? I noticed it is producing different outputs if I set it to 0 (RAW) or 1 (sRGB). I would like the output to be linear as I am already setting gamm[0] = gamm[1] = 1, but looks like this parameter is override some options..
This will result into full build infrastructure sharing:
- other libraries used (jpeg, xml2)
- complete build environment share to make sure your app compiled with same compiler/same settings to ensure same offsets in libraw structures
Looks impossible.
I don't think it is the file, because when use_rawspeed = 0 , LibRaw has no problem loading this file.
Would you be so kindly post links to the libraw_r.a and librawspeed.a compiled for macOS so I can download them to try out? PM me if it is not convenient to do it in the forum post.
Thanks!
camera matrix should be the same unless changed by camera based on temperature or self-calibration (may be some high-end digital backs?)
camera WB will change from shot to shot, indeed.
So, you may get camera multiplicators for the first shot in sequence and re-use it for next shots (user_mul).
Same with black level: it may change from shot to shot (e.g. Panasonic or Canon cameras), so get it for first shot then reuse (user_black, user_cblack)
Also, set adjust_maximum_thr to 0.f
Pages