Thanks - this was a helpful clue. I tried compiling it using a slightly less old version of Visual Studio - VS 2013 - and it worked perfectly.
Thanks for your help and for your excellent library. Stay safe.
return this->operator(_fpos - _bstart);
We compile 32-bit libraw for 32-bit RawDigger using MSVC 2010 with no such problem.
data() member is listed for std::vector since C++11
We are happy to accept additions if they do not violate the general ideology of the library and solve a problem of interest to more than one user.
Please use github pull requests for such a contributions.
Delphi/other language wrappers are out of our interest because we'll unable to support such improvements.
OK, I understand. Sorry, I'm new to LibRaw.
If I do the changes/additions, will it be merged in the distribution for next revision?
My current work is to create a Delphi wrapper so that LibRaw can be easily used by Delphi developers. This wrapper will be open-source and made available in a GitHub repository (Or even better - if it is possible directly - in the LibRaw repository).
> LibRaw should....
LibRaw is open-source, we welcome contributions from other developers
The problem is that I use the LibRaw.dll and his C API (My code is written with Delphi). And there is no access [as far as I can see] to the data structure required to implement a tiff writer. So I have to implement it is C++ and expose the function in the C API dll. The final effect is that my application will have to use a special DLL. I don't like the idea.
IMO LibRaw should expose a complete unicode API which is standard nowadays.
Yes, ppm_tiff_writer is a sample code only to allow LibRaw samples to write output files.
You may re-implement it, or use dcraw_mem_image() to create in-memory bitmap and save it using your own code.
LibRaw::open_file(wchar_t *) has to be used to open a file having Unicode filename. But LibRaw::dcraw_ppm_tiff_writer has no unicode version. Am I supposed to write my own or is there a work around?
BTW: I am working under Windows and all filenames are Unicode.
Windows: use LibRaw::open_file(wchar_t *)
macOS: LibRaw::open_file(char*) accepts UTF-8 filenames.
Other operating system: do not know :), you probably may need to implement own LibRaw datastream.
Yes, this is expected speed-up for huffman compressed files.
Managed to turned off sanitizer and RawSpeed 3 is about 20-40+% faster than RawSpeed v1. Sony A7RM4 RAW decode speed is like 2x.
Address sanitizer is still on. I need to find ways to disable it in the RawSpeed3 source code (not sure how right now).
Do you see speed improvements with RAWSpeed 3 in general? Is it faster than the original RAWSpeed or does it simply offer more RAW file decode for different camera brands?
I'm also unsure. Do you still use address sanitizer?
I recompiled without USE_RAWSPEED_BITS and RawSpeed3 appeared to have been called when I decode a certain Sony ARW images.
But performance is terrible. Like 4.5x slower.
Not sure what is going on.
1) Sorry, we do not offer advice on building RawSpeed3 as mentioned in the provided README
It is definitely possible to build it w/o address sanitizer.
We're not Cmake users, so I do not know what is 'target_sources(rawspeed_get_number_of_processor_cores....' message
2) LIBRAW_DECODER_TRYRAWSPEED3 bit is set in get_decoder_info() code. There is no way to change it from your app and no need for that.
LIBRAW_DECODER_TRYRAWSPEED3 bit is set only for decoders that are definitely faster in RawSpeed3, not for all decoders provided by the library (for example, it is mostly useless to decode unpacked/uncompressed data via RawSpeed3: it uses additional memory buffer for the decoded file with little or no benefit)
3) If you compile LibRaw with USE_RAWSPEED_BITS define, you need to set LIBRAW_RAWSPEEDV3_USE bit in imgdata.rawparams.use_rawspeed
If you compile LibRaw with just USE_RAWSPEED3 define, imgdata.rawparams.use_rawspeed=1 is enough.
It was actually step 2 on how to add the files.
Anyway, I've it figured out so it is now compiled correctly. There was an error in the 01. patch, it should remove 'final' from CameraMetaData, and not adding to it.
There is also another error in CMakeLists.txt in RawSpeed-v3/src/librawspeed/common:
target_sources(rawspeed_get_number_of_processor_cores should be set to PUBLIC not PRIVATE. Or else it libraw would not link (can't find rawspeed_get_number_of_processor_cores).
There is one addition error in converting the cameras.xml file to cameras.cpp file. A null character was added in the last line of the cpp file. It won't compile unless it is removed. The null char was preceding the last line "";
I also need to add -fsanitize=address compile option to Makefile.dist, as RawSpeed3 source code automatically detect and enable -fsanitize=address compile flag, and it'll not link unless the same is specified in libraw and my code.
Now that I got it to compile and link, how do I specify RawSpeed3 during runtime?
I set imgdata.rawparams.use_rawspeed = 1 and for all the RAW files I tried, it doesn't decode them with RawSpeed3, including Sony ARW files or Nikon Z camera RAW files.
The doc mentioned about:
RawSpeed-v3 support is controlled via libraw_decoder_info.t->flags (LIBRAW_DECODER_TRYRAWSPEED3 bit).
First of all, there is no libraw_decoder_info.t->flags, but there is libraw_decoder_info_t->decoder_flags.
I assume you're referring to this decoder_flags?
I can assign decoder_flags = LIBRAW_DECODER_TRYRAWSPEED3, but how do I pass the libraw_decoder_info_t data structure to the raw processor so that it knows I want it to try RawSpeed3?
There is a get_decoder_info() function, but not a set_decoder_info().
Quote from RawSpeed3/README.md:
To make a file with camera definitions, run the command (you can add it to the build system): sh ./rawspeed3_c_api/rsxml2c.sh < path/to/RawSpeed/data/cameras.xml > rawspeed3_c_api/cameras.cpp
The rsxml2c.sh script requires cat, tr, and sed unix command-line utilities installed, there is no specific version requirements.
Add the resulting file (LibRaw/RawSpeed3/rawspeed3_c_api/cameras.cpp) and LibRaw/RawSpeed3/rawspeed3_c_api/rawspeed3_capi.cpp, to the build of the RawSpeed-v3 (dynamic) library, which you learned to build in the previous step. If building Windows DLL: rawspeed3_capi.cpp should be compiled with -DRAWSPEED_BUILDLIB to create dll export entries automatically.
To check that everything works, you can use the LibRaw/RawSpeed3/rawspeed3_c_api/rawspeed3_capi_test.cpp test program, it should be possible to build it and link with RawSpeed-v3 (+ C-API); and after that this test program should be ready to decode RAW files passed to it from command line.
Please clarify what is not clear in the steps quoted above.
Yes, this seems to do the trick. Thanks.
Have you tried, from the link I suggested, https://www.libraw.org/docs/Samples-LibRaw.html :
This key sets params.adjust_maximum_thr parameter.
Use -c 0 to completely disable automatic maximum calculation.
Default value: 0.75"
dcraw_emu -W -c 0 -g 1 0
gives linear response to varying exposure time. Thanks.
I'm not sure what you mean, but by linear behaviour I mean that if I take images of the same identical subject with the same illumination, but with different exposure times, and then plot pixel value VS exposure time, the curve is linear (if gamma is 1). In the plot I attached to the original post you can see this behaviour.