To make my project LibRaw work (QT / Windows 10) with last release Libraw 0.21.2 and Unicode,
i added these 3 lines in the file libraw.h before compiling Librairy.
The wchar_t* string is passed directly to Win32/CreateFileW
So, if you're able to use other Win32 file API calls, it should work for LibRaw too.
UPD: on modern windows, all interfaces are unicode already, starting from wmain/_tmain program 1st function, so there is no need to convert anything from/to 8-bit strings.
LibRaw's goal is to read RAW data and metadata, as explained on this site 1st page: https://www.libraw.org/
Postprocessing is indeed imported from dcraw, there is no other postprocessing in LibRaw.
If one want to process RAW data in own code: LibRaw::open_file()/unpack() is enough for that.
Just looking for a quick comment on what is gained using the non-dcraw API. I have read through most of the documentation and it seems to me that they can achieve similar functionality. I get the impression that the libraw dcraw API was meant to ease migration efforts from the original dcraw.
I don't see an inherent benefit between the two methods reading the the documentation, which is why I'm curious.
I suspect if I were using more of libraw's processing tools it would make sense to use the non-dcraw api, but I'd like to confirm that.
I wasn't sure if the other methods are perhaps faster or have better support. I just want to make sure I understand what options exist and why I would use one over the other.
This is not string pooling, this should be linker identical code folding (designed to merge same methods of different classes, e.g. templates)
So, two originally different function pointers are the same in the optimized code.
Tried the linker option. No change.
This is not available for libraries (I link LibRaw as a static lib). But setting the options in my DLL which links to LibRaw made no change.
I've tried that. No change :-(
Visual Studio 2022 17.8.1
I've also disabled the optimization for the get_decoder_info() function and even for the declarations for vc5_dng_load_raw_placeholder() and jxl_dng_load_raw_placeholder() in the header.
Did a full rebuild of LibRaw each time, just in case.
No change in the name returned!
I then moved the call to get_decoder_info into a separate function in my code (returns true if the options should be added) and wrapped that in optimize off / on.
Same result. Still returned the wrong name.
I think this is something really strange with Maximum Optimization that somehow rolls things together on a more global level. Normal Optimization works, so I'll use that for now. Until you maybe change the code to work around this somehow.
void LibRaw::vc5_dng_load_raw_placeholder()
{
// placeholder only, real decoding implemented in GPR SDK
throw LIBRAW_EXCEPTION_UNSUPPORTED_FORMAT;
}
void LibRaw::jxl_dng_load_raw_placeholder()
{
// placeholder only, real decoding implemented in DNG SDK
throw LIBRAW_EXCEPTION_UNSUPPORTED_FORMAT;
}
Looks like Visual studio detects this, compiles as single function, so else if (load_raw == &LibRaw::vc5_dng_load_raw_placeholder)
and else if (load_raw == &LibRaw::jxl_dng_load_raw_placeholder)
Are both true....
Looks like
1) these functions should be separated in additional code unit
2) All optimizations should be disabled at least for common compilers (gcc, clang, visual studio).
I've tested this and it seems to be some kind of code generation / optimization issue with Visual C++ 2022...?
I create LibRaw as a static library.
When I use the debug build, the decoder_name returned is "jxl_dng_load_raw_placeholder()".
When I compile the release build with optimizations disabled (/Od) or set to Optimizations (Favor Speed) (/Ox), the decoder_name returned is also "jxl_dng_load_raw_placeholder()".
But when I build release with Maximum Optimization (Favor Speed) (/O2), the decoder_name is set to "vc5_dng_load_raw_placeholder()"
Looking at the LibRaw source, this should only happen when USE_GPRSDK is defined (it is not in my build) so I can only assume that there is some sort of compiler error or wrong jump produced when optimizing that case statement when the /O2 is enabled.
vc5_dng_load_raw_placeholder is GoPro files decoder name. It was not mentioned in my reply; Also this name should not be returned in get_decoder_info() for both release and debug (unless you load DLL with different LibRaw version....)
and compare the dinfo->name with "jxl_dng_load_raw_placeholder()" and "vc5_dng_load_raw_placeholder()", as you suggested (I hope I understood you correctly).
And this works very well for the problem image. In the debug built.
When I switch to the release built (Visual C++ 2022), the dinfo->name returned is "lossy_dng_load_raw()" for some reason I don't understand yet. I will prepare a release build with debug symbols so I can trace into this. The preprocessor defines etc. the same for both builds.
When I also set the new opcode flags when "lossy_dng_load_raw()" is returned in dinfo->name, the image looks good in the release build too.
Followup: could you please share some file sample(s) to check if metadata extracted correctly or not
LibRaw is about RAW data and metadata extraction.
Existing postprocessing code is intended mostly for testing purposes, there is no plans to improve it.
This is clearly stated on this site main page.
Hello Alex !
Thank you for your help.
To make my project LibRaw work (QT / Windows 10) with last release Libraw 0.21.2 and Unicode,
i added these 3 lines in the file libraw.h before compiling Librairy.
# define LIBRAW_WIN32_CALLS
# define __INTEL_COMPILER
# define LIBRAW_WIN32_UNICODEPATHS
May be one or two #define are required for my computer.
So i can open Raw file with a filename QString (16bits)
const wchar_t *array = (const wchar_t*)filename.utf16();
int ret = this->processor->open_file( array) ;
if( ret != LIBRAW_SUCCESS )
return false ;
Best regards,
Luciano
>> I tried various conversions
The wchar_t* string is passed directly to Win32/CreateFileW
So, if you're able to use other Win32 file API calls, it should work for LibRaw too.
UPD: on modern windows, all interfaces are unicode already, starting from wmain/_tmain program 1st function, so there is no need to convert anything from/to 8-bit strings.
Our update/release schedule policy is provided on this site homepage: https://www.libraw.org/#updatepolicy
We know nothing about darktable update schedule.
LibRaw's goal is to read RAW data and metadata, as explained on this site 1st page: https://www.libraw.org/
Postprocessing is indeed imported from dcraw, there is no other postprocessing in LibRaw.
If one want to process RAW data in own code: LibRaw::open_file()/unpack() is enough for that.
Just looking for a quick comment on what is gained using the non-dcraw API. I have read through most of the documentation and it seems to me that they can achieve similar functionality. I get the impression that the libraw dcraw API was meant to ease migration efforts from the original dcraw.
I don't see an inherent benefit between the two methods reading the the documentation, which is why I'm curious.
I suspect if I were using more of libraw's processing tools it would make sense to use the non-dcraw api, but I'd like to confirm that.
Do you have a specific question or do you asking to re-tell the entire documentation in other words?
I wasn't sure if the other methods are perhaps faster or have better support. I just want to make sure I understand what options exist and why I would use one over the other.
If everything works for you and you are happy with the result, what else do you want to improve?
and, also, samples/unprocessed_raw sample
https://www.libraw.org/docs/API-datastruct-eng.html#libraw_rawdata_t
Thanks for the info.
I've another question which is the other way around:
Can I decompress a compressed Fuji RAF file and get the uncompressed X-Trans sensor data buffer from LibRaw?
Do I call unpack() and then get the uncompressed sensor data from somewhere?
Is it in rawProcessor.imgdata.rawdata?
I've tried all the options that could make a difference, but there are not that many options in the Librarian when compiling LibRaw as a static lib.
I've settled to compile LibRaw with Ox instead O2 and that works just fine. Maybe it's a tick slower than it could, but I think it's fine.
Do you have a big spam problem? The post form always tells me to take more time filling the form. Maybe I type too fast ;-)
This is not string pooling, this should be linker identical code folding (designed to merge same methods of different classes, e.g. templates)
So, two originally different function pointers are the same in the optimized code.
We'll return to this but not immediately
Tried the linker option. No change.
This is not available for libraries (I link LibRaw as a static lib). But setting the options in my DLL which links to LibRaw made no change.
I've also played with string pooling and the other options that differ (https://learn.microsoft.com/en-us/cpp/build/reference/o1-o2-minimize-siz...) between Optimization (Speed) which works and Maximize Optimization (Speed) which does not work. Without any success.
I'll stick to /Ox /Ob2 /Oi /Ot for now.
Looks like this is linker option, not compiler: https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-...(v=vs.110)?redirectedfrom=MSDN
/OPT:NOICF should help.
We'll try to address this issue in some way, but not immediately (will try to use #pragma comment(linker...)
I've tried that. No change :-(
Visual Studio 2022 17.8.1
I've also disabled the optimization for the
get_decoder_info()
function and even for the declarations for vc5_dng_load_raw_placeholder() and jxl_dng_load_raw_placeholder() in the header.Did a full rebuild of LibRaw each time, just in case.
No change in the name returned!
I then moved the call to get_decoder_info into a separate function in my code (returns true if the options should be added) and wrapped that in optimize off / on.
Same result. Still returned the wrong name.
I think this is something really strange with Maximum Optimization that somehow rolls things together on a more global level. Normal Optimization works, so I'll use that for now. Until you maybe change the code to work around this somehow.
#pragma optimize( "", off )
before
void LibRaw::vc5_dng_load_raw_placeholder()
and
#pragma optimize( "", on )
before
void LibRaw::adobe_copy_pixel(unsigned row, unsigned col, ushort **rp)
(in src/decoders/dng.cpp)
Will probably fix the issue.
These pragmas are Visual Studio specific; we'll implement wider solution in the next update
Looks interesting.
In fact, both functions have the same body:
Looks like Visual studio detects this, compiles as single function, so
else if (load_raw == &LibRaw::vc5_dng_load_raw_placeholder)
and
else if (load_raw == &LibRaw::jxl_dng_load_raw_placeholder)
Are both true....
Looks like
1) these functions should be separated in additional code unit
2) All optimizations should be disabled at least for common compilers (gcc, clang, visual studio).
I've tested this and it seems to be some kind of code generation / optimization issue with Visual C++ 2022...?
I create LibRaw as a static library.
When I use the debug build, the decoder_name returned is "jxl_dng_load_raw_placeholder()".
When I compile the release build with optimizations disabled (/Od) or set to Optimizations (Favor Speed) (/Ox), the decoder_name returned is also "jxl_dng_load_raw_placeholder()".
But when I build release with Maximum Optimization (Favor Speed) (/O2), the decoder_name is set to "vc5_dng_load_raw_placeholder()"
Looking at the LibRaw source, this should only happen when USE_GPRSDK is defined (it is not in my build) so I can only assume that there is some sort of compiler error or wrong jump produced when optimizing that case statement when the /O2 is enabled.
LibRaw::open_bayer() is what you're probably looking for.
vc5_dng_load_raw_placeholder is GoPro files decoder name. It was not mentioned in my reply; Also this name should not be returned in get_decoder_info() for both release and debug (unless you load DLL with different LibRaw version....)
I've got this working, following your instructions.
I call:
and compare the dinfo->name with "jxl_dng_load_raw_placeholder()" and "vc5_dng_load_raw_placeholder()", as you suggested (I hope I understood you correctly).
And this works very well for the problem image. In the debug built.
When I switch to the release built (Visual C++ 2022), the dinfo->name returned is "lossy_dng_load_raw()" for some reason I don't understand yet. I will prepare a release build with debug symbols so I can trace into this. The preprocessor defines etc. the same for both builds.
When I also set the new opcode flags when "lossy_dng_load_raw()" is returned in dinfo->name, the image looks good in the release build too.
Any idea?
Followup:
Sorry for wrong info: STAG2/3_IFPRESENT are documented in Changelog only for now: https://github.com/LibRaw/LibRaw/blob/master/Changelog.txt#L250-L257
Pages