And it is now in 0.15-Beta2: return type of subtract_black() is changed to int, returns according to LibRaw convention (0 on success, error code on error)
LibRaw::raw2image() allocates imgdata.image[] array and copies data from internal storage (different for Bayer and non-bayer images) to this array.
No demosaic, no black subtration, this is for developers who want to do processing by hand.
So, three ways exists:
- unpack() + raw2image() - this produce internal data compatible with old LibRaw (0.9-0.13)
- unpack + dcraw_process() - for full processing
- only unpack() but you need to know LibRaw internals, because different data types (bayer vs non-bayer) are stored in different way.
Sure, internals may change in future LibRaw releases, so it is safer to use unpack() + raw2image, although it requires extra RAM.
1) Black should be subtracted before demosaic
2) Look into convert_to_rgb code:
to get output matrix, the rgb_cam matrix is multiplied to color space matrix. The rgb_cam is produced by cam_xyz_coeff() call
File seems ok. It was a subtle synchronization problem in my code. I was just surprised it occured in the same method all the time. Thanks for the quick reply!
Btw, I'm running on 64-bit Windows 7 and doing openBuffer, unpack, dcraw_process, and dcraw_make_mem_image and checking the return codes for each call.
In the file wf_filtering.cpp we are getting a few warnings. Not sure if they are critical or not. This is using xcode 4.3 on the mac using the apple llvm 3.1 compiler. Below is the warning with the associated line numbers.
Control may reach end of non-void function
686
& has lower precedence than ==; == will be evaluated first
1169
1332
1623
1682
1703
1720
1759
1798
1857
1895
1934
OK, I'll change LibRaw_(big)file_datastream internals to save std::string instead of just pointer. It is safer way.
0.15 still in pre-Beta state, so I may change ABI/internals without saving compatibility :)
Also, I'll add open_wfile() call (under #ifdef WIN32) in next Alpha.
I did not realize the pointer to the path was not being copied. Once I made that change, it worked. We are using the c api and I was wondering if you were going to add a wchar_t version for the libraw_open_file call on windows? Currently I am doing that myself.
Could you please specify your working environment:
- what test-code do you use, dcraw_emu (or something else from LibRaw's samples)
- or your own code
Possibly, the source of error is:
1) LibRaw_file_datastream() constructor saves the pointer to filename you pass to LibRaw::open_file()
Note, the pointer is stored, not string copied!
2) the buffer with filename (passed to open_file) is destroyed before LibRaw::unpack() called
Lossy DNG files exported by LightRoom 4 seem to crash.
The call stack is:
#0 0x0000000116801719 in LibRaw_file_datastream::jpeg_src(void*) at /Users/tbrown/Documents/ProjectsOnOne/Suite6/LibRaw/src/libraw_datastream.cpp:280
#1 0x0000000116793de9 in LibRaw::lossy_dng_load_raw() ()
#2 0x00000001167c0751 in LibRaw::unpack() ()
#3 0x00000001167bc9de in libraw_unpack ()
when calling this line of code
jas_file = fopen(fname(),"rb");
The fname() returns a garbage string so that the fopen fails and then crashes soon after.
I am using the USE_JPEG8 flag when compiling. I have upgraded to the latest version of the jpeglib. Is there something else I need to do to get this working
It looks like your code uses different structure fields alignment than in compiled libraw.dll
LibRaw.dll is compiled using Makefile.msvc with Visual Studio 2010 on 64 bit machine. There are no additional compiler flags for structure fields alignment, defaults used.
wchar_t* interface is disabled for MinGW in 0.15 Beta2
And it is now in 0.15-Beta2: return type of subtract_black() is changed to int, returns according to LibRaw convention (0 on success, error code on error)
BTW, thanks for bugreport. I'll add new processing stage to internals and subtract_black() will check that raw2image is called.
LibRaw::raw2image() allocates imgdata.image[] array and copies data from internal storage (different for Bayer and non-bayer images) to this array.
No demosaic, no black subtration, this is for developers who want to do processing by hand.
So, three ways exists:
- unpack() + raw2image() - this produce internal data compatible with old LibRaw (0.9-0.13)
- unpack + dcraw_process() - for full processing
- only unpack() but you need to know LibRaw internals, because different data types (bayer vs non-bayer) are stored in different way.
Sure, internals may change in future LibRaw releases, so it is safer to use unpack() + raw2image, although it requires extra RAM.
No, I try only call unpack(), the application works directly over raw data.
substract_black() works only over demosaicing data ?
Thank's a lot.
It looks like wchar_t strings are not supported in MinGW's libstdc++. I'll try to reproduce before next beta wiil be released.
This is LibRaw calls. So, it looks like you do not properly link with LibRaw
1) Black should be subtracted before demosaic
2) Look into convert_to_rgb code:
to get output matrix, the rgb_cam matrix is multiplied to color space matrix. The rgb_cam is produced by cam_xyz_coeff() call
Thank you for your proposal, sure it is possible
Do you called raw2image() before calling subtract_black() ?
Thanks! I'll check it out.
libraw_open_wfile/open_wfile_ex added in 0.15-Beta1
File seems ok. It was a subtle synchronization problem in my code. I was just surprised it occured in the same method all the time. Thanks for the quick reply!
Could you please check this file with dcraw_emu sample?
Both 0.14.7 and 0.15-Alpha4 (both - Windows version) works OK.
I use dcraw_emu sample for testing.
Btw, I'm running on 64-bit Windows 7 and doing openBuffer, unpack, dcraw_process, and dcraw_make_mem_image and checking the return codes for each call.
wf_debanding code is '3rd-party', contributed to LibRaw.
I'll ask author about these warnings.
In the file wf_filtering.cpp we are getting a few warnings. Not sure if they are critical or not. This is using xcode 4.3 on the mac using the apple llvm 3.1 compiler. Below is the warning with the associated line numbers.
Control may reach end of non-void function
686
& has lower precedence than ==; == will be evaluated first
1169
1332
1623
1682
1703
1720
1759
1798
1857
1895
1934
OK, I'll change LibRaw_(big)file_datastream internals to save std::string instead of just pointer. It is safer way.
0.15 still in pre-Beta state, so I may change ABI/internals without saving compatibility :)
Also, I'll add open_wfile() call (under #ifdef WIN32) in next Alpha.
I did not realize the pointer to the path was not being copied. Once I made that change, it worked. We are using the c api and I was wondering if you were going to add a wchar_t version for the libraw_open_file call on windows? Currently I am doing that myself.
Thanks for feedback.
Could you please specify your working environment:
- what test-code do you use, dcraw_emu (or something else from LibRaw's samples)
- or your own code
Possibly, the source of error is:
1) LibRaw_file_datastream() constructor saves the pointer to filename you pass to LibRaw::open_file()
Note, the pointer is stored, not string copied!
2) the buffer with filename (passed to open_file) is destroyed before LibRaw::unpack() called
Lossy DNG files exported by LightRoom 4 seem to crash.
The call stack is:
#0 0x0000000116801719 in LibRaw_file_datastream::jpeg_src(void*) at /Users/tbrown/Documents/ProjectsOnOne/Suite6/LibRaw/src/libraw_datastream.cpp:280
#1 0x0000000116793de9 in LibRaw::lossy_dng_load_raw() ()
#2 0x00000001167c0751 in LibRaw::unpack() ()
#3 0x00000001167bc9de in libraw_unpack ()
when calling this line of code
jas_file = fopen(fname(),"rb");
The fname() returns a garbage string so that the fopen fails and then crashes soon after.
I am using the USE_JPEG8 flag when compiling. I have upgraded to the latest version of the jpeglib. Is there something else I need to do to get this working
Thanks for any help you can give.
It looks like I need to set explicit alignment for public structure members.
OK.
Finally I have found a solution:
I added an alignment before some structures:
__declspec(align(8)) typedef struct
{
float iso_speed;
float shutter;
float aperture;
float focal_len;
time_t timestamp;
unsigned shot_order;
unsigned gpsdata[32];
char desc[512],
artist[64];
} libraw_imgother_t;
__declspec(align(8)) typedef struct
{
unsigned int progress_flags;
unsigned int process_warnings;
libraw_iparams_t idata;
libraw_image_sizes_t sizes;
libraw_colordata_t color;
libraw_imgother_t other;
libraw_thumbnail_t thumbnail;
libraw_rawdata_t rawdata;
ushort (*image)[4] ;
libraw_output_params_t params;
void *parent_class;
} libraw_data_t;
Everything works fine now and I am getting all correct metadata values (ISO...).
I guess, the default structure fields alignment on VS2010 is 8 bytes and not 4 bytes.
Thanks for your help :-)
It looks like your code uses different structure fields alignment than in compiled libraw.dll
LibRaw.dll is compiled using Makefile.msvc with Visual Studio 2010 on 64 bit machine. There are no additional compiler flags for structure fields alignment, defaults used.
Pages