Add new comment

After half a day of playing

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?

Kuro