For -H 2 and -H 9 the results are bitwise the same for dcraw and dcraw_emu (from 0.13.5) and my sample image (something with blown clouds)
The difference may be in auto-maximum feature in LibRaw (very useful for some cameras). To turn this feature off use -c 0 switch when running dcraw_emu:
four_color_rgb value is saved in the beginning of dcraw_process() call, may be changed by half_size setting, but restored again at the end of dcraw_process(), just before return. (LibRaw 0.13.5)
Could you please provide sample code with errorneous four_color_rgb/half_size behaviour?
You're right, positive exposure shift without highlights compression will not affect entire image with default processing options, because data will be scaled to full 0..65535 range on postprocessing.
Anyway, positive exposure correcton is useful if
1) Manual data scaling is selected
2) Or highlights compression is non-zero.
Thank you for four_color/half_size report, I'll check.
Sorry for delayed answer, just returned from long vacation trip to Mongolia without any internet access....
According to configure output, your Xcode package is not installed correctly. The gcc is unable to compile small test program:
configure:2940: g++ conftest.cpp >&5
ld: library not found for -lcrt1.10.6.o
I've tested the configure script under 10.6.8 with Xcode 4.x without any minor problem. I've used Xcode 3.x several months ago without any problem too.
Iliah, You say "It looks like the time spent in postprocessing to get more details and counter-act artifacts might be better spent if demosaicking prepares a cleaner and more detailed image to start with. The processing time difference between integer and floating point implementations of demosaicking most of the times is less than 5 seconds, which is substantially less compared to the time spent on image editing to get close to the same result. Try it, and you will see. "
How does one go about "trying it" to see? What about this comment:
"For float data output we need to change entire processing pipeline to floating point." from http://www.libraw.org/about?
The problem is very simple:
- you have set half_size=1 *after* unpack is called. So for the very first run the half_size is not set for unpack stage but set for postprocessing stage.
But half_size option is heavily used on unpack() stage (only 1/4 of image array allocated, pixel data placement is very different).
You need to move
rawProcessor_.imgdata.params.half_size = 1;
line above of unpack() call.
Memory manager is used (and inlined) only within LibRaw::* calls.
These calls (including constructor) are not inlined, so there are no problem with it.
There *was* a problem with LibRaw::make_mem_image() call in previous versions of LibRaw: if you're allocated mem_image within LibRaw and free() it within your app, you're in trouble. The problem is fixed in 0.12 or 0.11 or so by providing extra call ..clear_mem_image()
But the problem was *not* random, it appear every time and within free() call, not in memchr() as in your case.
Like LibRaw expose libraw_memmgr memmgr; i think memmgr use malloc and free from crt associated with application. Not with crt associated with the dll. Internally that can cause CRT error.
I test with my application. I've always a crash in memchr. But i think it's a multithread error with edsdk and COM initialization.
libraw (.a, .so) is compiled with -DLIBRAW_NOTHREADS, so some internal decoder buffers are static. This is faster, but this library is not reentrant. You may use it in multithreaded environment, but not for decoding several files in parallel
libraw_r is compiled with -pthread and without LIBRAW_NOTHREADS define, so all I/O calls are made via thread-safe version and decoder storage is allocated within LibRaw class. So, extra locks, extra indirection for storage, but thread-safe.
Yes, memory manager is exposed to public. But the code that uses memory manager is entirely within DLL, including LibRaw class constructor and all methods.
The problem may occur only with link time code generation, but LibRaw.DLL do not use it.
Anyway, 4 different DLLs should solve the problem.
I thinks if you use pimpl idiom on LibRaw class you can remove this problem.
If i understand correctly the error, your libraw_memmgr implementation is declared in .h and is inlined.
So when you use it in application free and malloc are not the same that use in the dll.
For -H 2 and -H 9 the results are bitwise the same for dcraw and dcraw_emu (from 0.13.5) and my sample image (something with blown clouds)
The difference may be in auto-maximum feature in LibRaw (very useful for some cameras). To turn this feature off use -c 0 switch when running dcraw_emu:
dcraw_emu -c 0 -H 2
Unfortunately, I'm unable to download your sample, file not found.
four_color_rgb value is saved in the beginning of dcraw_process() call, may be changed by half_size setting, but restored again at the end of dcraw_process(), just before return. (LibRaw 0.13.5)
Could you please provide sample code with errorneous four_color_rgb/half_size behaviour?
You're right, positive exposure shift without highlights compression will not affect entire image with default processing options, because data will be scaled to full 0..65535 range on postprocessing.
Anyway, positive exposure correcton is useful if
1) Manual data scaling is selected
2) Or highlights compression is non-zero.
Thank you for four_color/half_size report, I'll check.
Sorry for delayed answer, just returned from long vacation trip to Mongolia without any internet access....
Thanks for report, to be tested.
Sorry for delayed answer, summer is vacation time.
According to configure output, your Xcode package is not installed correctly. The gcc is unable to compile small test program:
configure:2940: g++ conftest.cpp >&5
ld: library not found for -lcrt1.10.6.o
I've tested the configure script under 10.6.8 with Xcode 4.x without any minor problem. I've used Xcode 3.x several months ago without any problem too.
Well, those comments are for raw converter developers.
Where is the floating point implementation?
Elle Stone
Iliah, You say "It looks like the time spent in postprocessing to get more details and counter-act artifacts might be better spent if demosaicking prepares a cleaner and more detailed image to start with. The processing time difference between integer and floating point implementations of demosaicking most of the times is less than 5 seconds, which is substantially less compared to the time spent on image editing to get close to the same result. Try it, and you will see. "
How does one go about "trying it" to see? What about this comment:
"For float data output we need to change entire processing pipeline to floating point." from http://www.libraw.org/about?
Elle Stone
The data scaling is performed before interpolation.
So, there is no way to get debayered and unscaled data. You may remove call to scale colors or rewrite this call (LibRaw::scale_colors) if you wish.
Take a look at the method "LoadRawImage" at https://valelab.ucsf.edu/svn/micromanager2/trunk/DeviceAdapters/Tethered... )
Perfect, everything works. Thank you!
The problem is very simple:
- you have set half_size=1 *after* unpack is called. So for the very first run the half_size is not set for unpack stage but set for postprocessing stage.
But half_size option is heavily used on unpack() stage (only 1/4 of image array allocated, pixel data placement is very different).
You need to move
rawProcessor_.imgdata.params.half_size = 1;
line above of unpack() call.
The case is confirmed, your code really produces different first image (have not looked into it, but see by different MD5 sums).
Thanks again for your bug report. I'll write another comment here when bug will be fixed
I'm using LibRaw 0.13.1. I've tested on Windows and macosx; and in each case there is a difference between the first and the second decoded image.
Thanks for bug report.
It looks very strange for me because I use half_mode in my programs without any problem, but I'll test your code sample.
What version of LibRaw do you use?
If i read doc, i can use it's memory stream which received file :/ but random crash appear. It's like stream size is incorrect (and it's possible ^^).
Now it's works perfectly for me when i'm embded my memory to edsdk MemoryStream.
For edsdk, you probably wait a long time before receive an answer...
Is is possible, that ESDK memory is protected from outside access and only ESDK call may use it?
Unfortunately, I've no reply from Canon-Europe yet, so cannot look into ESDK.
Memory manager is used (and inlined) only within LibRaw::* calls.
These calls (including constructor) are not inlined, so there are no problem with it.
There *was* a problem with LibRaw::make_mem_image() call in previous versions of LibRaw: if you're allocated mem_image within LibRaw and free() it within your app, you're in trouble. The problem is fixed in 0.12 or 0.11 or so by providing extra call ..clear_mem_image()
But the problem was *not* random, it appear every time and within free() call, not in memchr() as in your case.
Good news.
If i use my memory to dowload cr2 file with edsdk, i haven't crash :D
thanks.
Like LibRaw expose libraw_memmgr memmgr; i think memmgr use malloc and free from crt associated with application. Not with crt associated with the dll. Internally that can cause CRT error.
I test with my application. I've always a crash in memchr. But i think it's a multithread error with edsdk and COM initialization.
thanks for help.
No-no.
libraw (.a, .so) is compiled with -DLIBRAW_NOTHREADS, so some internal decoder buffers are static. This is faster, but this library is not reentrant. You may use it in multithreaded environment, but not for decoding several files in parallel
libraw_r is compiled with -pthread and without LIBRAW_NOTHREADS define, so all I/O calls are made via thread-safe version and decoder storage is allocated within LibRaw class. So, extra locks, extra indirection for storage, but thread-safe.
Not reentrant version is several percent faster.
Yes, memory manager is exposed to public. But the code that uses memory manager is entirely within DLL, including LibRaw class constructor and all methods.
The problem may occur only with link time code generation, but LibRaw.DLL do not use it.
Anyway, 4 different DLLs should solve the problem.
In the best, is that i understand.
I thinks if you use pimpl idiom on LibRaw class you can remove this problem.
If i understand correctly the error, your libraw_memmgr implementation is declared in .h and is inlined.
So when you use it in application free and malloc are not the same that use in the dll.
http://support.microsoft.com/kb/140584/en-us
Pages