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)
But you have successfully used RawSpeed in FastRawViewer under the Mac, right? I'm a registered user of FastRawViewer, and my DNG file doesn't crash it.
After half a day of playing around with it, I still get a crash whenever a DNG file is decoded.
Below is how I compile librawspeed and libraw (this is under macOS):
For RawSpeed:
- Unpack the rawspeed-master.zip file
- Copy it to the same folder that stores LibRaw-x.xx.x
- Rename it to RawSpeed
- Copy the patch files from LibRaw/RawSpeed to RawSpeed/RawSpeed directory
- Run patch < rawspeed.cpucount-unix.patch
- Edit Common.cpp and cut and paste the the function int rawspeed_get_number_of_processor_cores() to the end of the file, outside of the #elif
- Run patch < rawspeed.qmake-pro-files.patch
- Run qmake -makefile rawspeed-lib.pro
- Edit DngDecoderSlices, find the line with jpeg_read_header(&info, TRUE). Cast TRUE with (boolean)
- Edit RawDecoderThread.h, change 'uint32 taskNo' to 'int32 taskNo'
- Edit the Makefile. Change -mmacosx-version-min= to the version you want (such as 10.9)
- Run make
For LibRaw:
- Edit Makefile.dist
- Uncomment the two lines under '# RawSpeed Support'
- Add -mmacosx-version-min=xx.x to CFLAGS+=
- Uncomment the lines 'Demosaic Pack GPL2 and GPL3'
- Run make -f Makefile.dist
There were some warnings when compiling RawSpeed. The most notable one is bit shifting a negative number. This is undefined by the gcc compiler. This warning is in LJpegDecompressor.cpp. I tried changing -32768 to 0b1000000000000000, but the crash persists.
I found that sometime I can decode the DNG file and have it displayed on the screen. But my app crashes just by sitting there idle for a few seconds. Other times, my app crashes right at the line "rawProcessor.unpack()". It seems that the code in RawSpeed in decoding DNG file is corrupting some memory locations, and when some background garbage collection occurs, the app crashed.
As soon as I set 'imgdata.params.use_rawspeed = 0', DNG files are decoded correctly without any crash at all.
Perhaps you have fixed something in the master branch of RawSpeed to allow successful decoding of DNG files?
After a lot of trials and errors by following your instructions above, I've finally managed to compile RawSpeed into a library and recompiled libraw to use it.
I can see a speedup of 2x with Canon CR2 files, but not so much for NEF, and I think there is no support for X-Trans.
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
I do not see any problems with this file. Tested with RawDigger under both Windows and OS X.
But you have successfully used RawSpeed in FastRawViewer under the Mac, right? I'm a registered user of FastRawViewer, and my DNG file doesn't crash it.
But anyway, here is the link to the DNG file:
https://www.dropbox.com/s/zg6785bm9err9gf/DJI_0329.DNG?dl=0
Thanks.
LibRaw team is not responsible for RawSpeed bugs.
Meanwhile, if you provide sample file that crashes RawSpeed I'll take a look (under Windows/MSVC 2010 because it my main development platform).
After half a day of playing around with it, I still get a crash whenever a DNG file is decoded.
Below is how I compile librawspeed and libraw (this is under macOS):
For RawSpeed:
- Unpack the rawspeed-master.zip file
- Copy it to the same folder that stores LibRaw-x.xx.x
- Rename it to RawSpeed
- Copy the patch files from LibRaw/RawSpeed to RawSpeed/RawSpeed directory
- Run patch < rawspeed.cpucount-unix.patch
- Edit Common.cpp and cut and paste the the function int rawspeed_get_number_of_processor_cores() to the end of the file, outside of the #elif
- Run patch < rawspeed.qmake-pro-files.patch
- Run qmake -makefile rawspeed-lib.pro
- Edit DngDecoderSlices, find the line with jpeg_read_header(&info, TRUE). Cast TRUE with (boolean)
- Edit RawDecoderThread.h, change 'uint32 taskNo' to 'int32 taskNo'
- Edit the Makefile. Change -mmacosx-version-min= to the version you want (such as 10.9)
- Run make
For LibRaw:
- Edit Makefile.dist
- Uncomment the two lines under '# RawSpeed Support'
- Add -mmacosx-version-min=xx.x to CFLAGS+=
- Uncomment the lines 'Demosaic Pack GPL2 and GPL3'
- Run make -f Makefile.dist
There were some warnings when compiling RawSpeed. The most notable one is bit shifting a negative number. This is undefined by the gcc compiler. This warning is in LJpegDecompressor.cpp. I tried changing -32768 to 0b1000000000000000, but the crash persists.
I found that sometime I can decode the DNG file and have it displayed on the screen. But my app crashes just by sitting there idle for a few seconds. Other times, my app crashes right at the line "rawProcessor.unpack()". It seems that the code in RawSpeed in decoding DNG file is corrupting some memory locations, and when some background garbage collection occurs, the app crashed.
As soon as I set 'imgdata.params.use_rawspeed = 0', DNG files are decoded correctly without any crash at all.
Perhaps you have fixed something in the master branch of RawSpeed to allow successful decoding of DNG files?
I reverted the patch for rawspeed.uncompressed-color-dng.patch, then RawSpeed no longer crashes on DNG files.
But now it crashes on decoding Olympus ORF files. So something is definitely wrong...
I just experienced crashes when I decoded DNG and Olympus ORF files with RawSpeed turned on.
I've installed the rawspeed.uncompressed-color-dng.patch. So what else am I missing?
Could you please provide sample DNG to look into it?
if rawspeed has decoded the file, this bit is turned on:
imgdata.process_warnings |= LIBRAW_WARN_RAWSPEED_PROCESSED;
(this is not warning, just info)
After a lot of trials and errors by following your instructions above, I've finally managed to compile RawSpeed into a library and recompiled libraw to use it.
I can see a speedup of 2x with Canon CR2 files, but not so much for NEF, and I think there is no support for X-Trans.
Although README.RawSpeed.txt does not look fresh, RawSpeed master branch was not updated from 2014 too.
Can you update the file README.RawSpeed.txt? It is out of date and I've been trying all weekend using the instructions there without success.
Compiling RawSpeed to a library is a problem, because there is no makefile or configure file. I'm trying to do this under macOS.
Pages