For byte swapping use something like ntohs() (actually this converts from big endian to your machine/host endianness, so it might be a noop if your machine is big endian as well) or, depending on your system/compiler, some incarnation of the bswap16() intrinsic/bultin function (e.g. __builtin_bswap16() for GCC, _byteswap_ushort() for MSVC, etc.)
Thank you again for your answers.
Actually, yes the data is encoded in int16.
I was able to read it in python swap bit ordering to bi endian. Any idea how I can achieve this in c++ ?
Also my guess for taking 2 bites with go for two consecutive bytes. Does this seam reasonable. I don' have all format specifications in hand.
Also, if your file is 2 bytes per pixel, uncompressed, you do not need LibRaw to read source data values. Your values are already here (in unsigned short format, probably you may need big/little-endian swap; I know nothing about your images and your camera)
Thank you Alex for your answer. I tried with open_bayer as I think the raw file has no metadata. With the code bellow I could see that readb as 1280000 values instead of 640000 for an image 800x8000. The final result with dcraw_process is not satisfactory. I wonder If and how I could retrieve the unpacked values and do the conversion myself.
FILE *in = fopen(fname, "rb");
fseek(in, 0, SEEK_END);
unsigned fsz = ftell(in);
unsigned char *buffer = (unsigned char *)malloc(fsz);
if (!buffer)
return 2;
fseek(in, 0, SEEK_SET);
unsigned readb = fread(buffer, 1, fsz, in);
if (readb != fsz)
return 3;
std::cout << "readb" << readb << std::endl;
LibRaw rp;
rp.imgdata.params.output_tiff = 1;
int ret = rp.open_bayer(buffer, fsz, 800, 800, 0, 0, 0, 0, 0,
LIBRAW_OPENBAYER_BGGR, 0, 0, 0);
if (ret != LIBRAW_SUCCESS)
return 4;
if ((ret = rp.unpack()) != LIBRAW_SUCCESS)
printf("Unpack error: %d\n", ret);
if ((ret = rp.dcraw_process()) != LIBRAW_SUCCESS)
printf("Processing error: %d\n", ret);
char outfn[256];
sprintf(outfn, "%s.tif", fname);
if (LIBRAW_SUCCESS != (ret = rp.dcraw_ppm_tiff_writer(outfn)))
printf("Cannot write %s: %s\n", outfn, libraw_strerror(ret));
else
printf("Created %s\n", outfn);
ret = rp.dcraw_process();
// Check for error using LIBRAW_SUCCESS. I never get an error here
ret = rp.dcraw_ppm_tiff_writer(fname);
Microsoft RAW extension is produced by Microsoft, we're not involved in this process in any way (Microsoft uses the public version of LibRaw).
So, we're completely not responsible for MS RAW Extension.
I have the exact same issue with A7VI RAWs and the Microsoft RAW extension.
I figured out it's related to the new Sony lossless compressed RAW format.
A7IV compress or uncompressed RAW are displayed fine, but A7IV lossless compress RAWs are not displayed at all.
The LibRAW blog post from 22. Oct. 2021 says the new Sony losslesss compressed RAW format is now supported.
My guess would be Microsoft RAW extension includes a version that is too old.
So its been almost a year and the public snapshot seems not to be out there. When can we expect full Sony A1 Raw file support for uncompressed raw, lossless compressed raw and compressed raw? Thank you.
By default, LibRaw extracts ActiveArea image (3040x2014)
Suppose we are discussing the latest public version (https://github.com/LibRaw/LibRaw, master branch):
DefaultCrop tags are parsed into imgdata.sizes.raw_inset_crops[0]
This crop can be applied via: LibRaw::adjust_to_raw_inset_crop(1)
BUT:
DefaultCrop top/left in this specific file is odd and will be rounded to nearest even margin, so image will be cropped to 3007x1999 starting at 16,8
There is no way to avoid this in current LibRaw (this change was implemented in LibRaw 0.20)
You may switch to LibRaw pre-0.20 (0.19 or so) with LIBRAW_PROCESSING_USE_DNG_DEFAULT_CROP flag set to params.raw_processing_options
Greetings, everyone. I have fond memories of this project and the learning involved. But I also have emails coming in requesting permission to view my tables with their expired links. For every person that requests access, Google tells me
"_____@whatever.com is requesting access to a file via an old link, which is no longer valid due to a security update. Share the file with this person directly, or copy and send the new link in sharing settings."
The email from my original account was shut down years ago, but I hosted the files on a permanent account. So here are updated links for each of the resources. Here's to another four years of, hopefully, helping people out.
Also @ajohnson was very, very correct about the DHT artifacts in dark regions. Spent a whole what, day?, half a day?, in 2019, cross-examining the algorithms and the rest of the project and unfortunately it was all DHT!
Okay, yes, thanks... for now, I will not try more on Cygwin... building is completely broken it seems in that environment with the GNU compiler. (With the MingGW compiler on Cywgwin and the mingw makefile it does work but does not solve my character encoding issues.)
Thank you, I was able to fix the swab issue, but much more compile errors after that... so it seams it is rather nasty to compile with Cygwin. I tried different compilers and versions but have not been very succesfull...
procflags of open_bayer() should also do the swap for you in the above example: https://www.libraw.org/docs/API-CXX.html#open_bayer
For byte swapping use something like ntohs() (actually this converts from big endian to your machine/host endianness, so it might be a noop if your machine is big endian as well) or, depending on your system/compiler, some incarnation of the bswap16() intrinsic/bultin function (e.g. __builtin_bswap16() for GCC, _byteswap_ushort() for MSVC, etc.)
Thank you again for your answers.
Actually, yes the data is encoded in int16.
I was able to read it in python swap bit ordering to bi endian. Any idea how I can achieve this in c++ ?
Also my guess for taking 2 bites with go for two consecutive bytes. Does this seam reasonable. I don' have all format specifications in hand.
Also, if your file is 2 bytes per pixel, uncompressed, you do not need LibRaw to read source data values. Your values are already here (in unsigned short format, probably you may need big/little-endian swap; I know nothing about your images and your camera)
If your input data is 16 bit (2 bytes per pixel), 1,280,000 bytes is expected....
Thank you Alex for your answer. I tried with open_bayer as I think the raw file has no metadata. With the code bellow I could see that readb as 1280000 values instead of 640000 for an image 800x8000. The final result with dcraw_process is not satisfactory. I wonder If and how I could retrieve the unpacked values and do the conversion myself.
-2 is: LIBRAW_FILE_UNSUPPORTED
If your 'raw' file is just a sensor dump without metadata consider using open_bayer() call
Microsoft RAW extension is produced by Microsoft, we're not involved in this process in any way (Microsoft uses the public version of LibRaw).
So, we're completely not responsible for MS RAW Extension.
You may try to use our FastRawViewer instead.
I have the exact same issue with A7VI RAWs and the Microsoft RAW extension.
I figured out it's related to the new Sony lossless compressed RAW format.
A7IV compress or uncompressed RAW are displayed fine, but A7IV lossless compress RAWs are not displayed at all.
The LibRAW blog post from 22. Oct. 2021 says the new Sony losslesss compressed RAW format is now supported.
My guess would be Microsoft RAW extension includes a version that is too old.
So you're talking about Microsoft RAW Extension, right?
Using Windows 11 for importing and cataloguing, I cant view any Sony a7iv raw files. I can open them in photoshop, but I dont like shooting raw & jpeg
What software (that uses LibRaw for RAW support) do you use?
Just wondering if an approximate date is known for next update to include Sony a7iv ILCE-7M4. Thanks
There is separate project on github: https://github.com/LibRaw/LibRaw-cmake
Note: we (LibRaw team) is not responsible for it and do not provide any support for it.
Could you please provide some sample file that illustrates the issue?
Right now we're unable to reproduce it, Kodak DC40/50 files (that uses radc decoder) loads correctly in RawDigger (that uses LibRaw): https://www.dropbox.com/s/qw6o57ikv3mls1n/Screenshot%202022-03-06%2017.4...
Sony ILCE-1 is fully supported in 202110 snapshot:
Supported camera list: https://www.libraw.org/supported-cameras-libraw-202110
Announce page: https://www.libraw.org/news/libraw-202110-snapshot
So its been almost a year and the public snapshot seems not to be out there. When can we expect full Sony A1 Raw file support for uncompressed raw, lossless compressed raw and compressed raw? Thank you.
OK, understood.
DNG file metatata:
| | 1) ImageWidth = 3040
| | 2) ImageHeight = 2014
| | 21) DefaultCropOrigin = 15 7 (15/1 7/1)
| | 22) DefaultCropSize = 3008 2000 (3008/1 2000/1)
| | 27) ActiveArea = 0 0 2014 3040
By default, LibRaw extracts ActiveArea image (3040x2014)
Suppose we are discussing the latest public version (https://github.com/LibRaw/LibRaw, master branch):
DefaultCrop tags are parsed into imgdata.sizes.raw_inset_crops[0]
This crop can be applied via: LibRaw::adjust_to_raw_inset_crop(1)
BUT:
DefaultCrop top/left in this specific file is odd and will be rounded to nearest even margin, so image will be cropped to 3007x1999 starting at 16,8
There is no way to avoid this in current LibRaw (this change was implemented in LibRaw 0.20)
You may switch to LibRaw pre-0.20 (0.19 or so) with LIBRAW_PROCESSING_USE_DNG_DEFAULT_CROP flag set to params.raw_processing_options
Raw file
https://data.csail.mit.edu/graphics/fivek/img/dng/a0001-jmac_DSC1459.dng
TIFF file
https://data.csail.mit.edu/graphics/fivek/img/tiff16_c/a0001-jmac_DSC145...
Could you please provide some sample file?
Hi support,
Just wanted you to know that this topic is solved as far as I am concerned. Cygwin building did not work though whatever I tried.
I tried Cygwin because my MingW solution broke correct character encoding with your change of file loading on the windows platform in
LibRaw 0.20.1 changes
Windows support/Windows unicode (wchar_t*) filenames support
I have everything working now with full unicode support using the Microsoft Visual Studio compiler.
Thank you very much for your great work on Libraw ;-)
Mabula
Greetings, everyone. I have fond memories of this project and the learning involved. But I also have emails coming in requesting permission to view my tables with their expired links. For every person that requests access, Google tells me
The email from my original account was shut down years ago, but I hosted the files on a permanent account. So here are updated links for each of the resources. Here's to another four years of, hopefully, helping people out.
Also @ajohnson was very, very correct about the DHT artifacts in dark regions. Spent a whole what, day?, half a day?, in 2019, cross-examining the algorithms and the rest of the project and unfortunately it was all DHT!
Fence / Roof comparison:
https://drive.google.com/file/d/0ByFHxc7qU-svVXd6MVEzN0pUajQ/view?usp=sh...
Light comparison:
https://drive.google.com/file/d/0ByFHxc7qU-svQlAwMlZubFJvelk/view?usp=sh...
Cone comparison:
https://drive.google.com/file/d/0ByFHxc7qU-svR2NETGNocWRwUkk/view?usp=sh...
Track line comparison:
https://drive.google.com/file/d/0ByFHxc7qU-svb1ROZXlmWGdTbUE/view?usp=sh...
Black / white checker comparison (animated GIF!):
https://drive.google.com/file/d/0ByFHxc7qU-svUHBPZjUycUxhOGM/view?usp=sh...
Summary table with performance times (on a decently large 16bit image):
https://drive.google.com/file/d/0ByFHxc7qU-svRkVhWGdYTnlOdE0/view?usp=sh...
Okay, yes, thanks... for now, I will not try more on Cygwin... building is completely broken it seems in that environment with the GNU compiler. (With the MingGW compiler on Cywgwin and the mingw makefile it does work but does not solve my character encoding issues.)
Hi kmilos,
Using MingW was what I did before, but was wondering if I could get things to work using Cygwin.
With MingW on Windows I am having serious character encoding issues since the new Libraw versions related to :
https://www.libraw.org/node/2692
and thus
https://github.com/LibRaw/LibRaw/commit/30595a731f3bea78f0410426b73ef3af...
I was able now to turn on unicode in MingW using: https://sourceforge.net/p/mingw-w64/wiki2/Unicode%20apps/
Needed to alter libraw.h and now I can use wchar_t but still not working with asian characters...
So still trying. Do you have any suggestions how to make it work with MingW and wchar_t file path?
Hi Alex,
Thank you, I was able to fix the swab issue, but much more compile errors after that... so it seams it is rather nasty to compile with Cygwin. I tried different compilers and versions but have not been very succesfull...
Mabula
Pages