Giter Site home page Giter Site logo

libraw / libraw Goto Github PK

View Code? Open in Web Editor NEW
1.1K 68.0 269.0 14.09 MB

LibRaw is a library for reading RAW files from digital cameras

Home Page: www.libraw.org

License: Other

Perl 0.06% QMake 0.30% C++ 97.97% C 0.91% Shell 0.09% Makefile 0.26% M4 0.40%

libraw's Introduction

LibRaw

Library for reading and processing of RAW digicam images

The LibRaw library provides a simple and unified interface for extracting out of RAW files generated by digital photo cameras the following:

  • RAW data (pixel values)
  • Metadata necessary for processing RAW (geometry, CFA / Bayer pattern, black level, white balance, etc.)
  • Embedded preview / thumbnail.

The library is intended for use with programs that work with RAW files, such as:

  • RAW viewers
  • RAW converters
  • RAW data analyzers
  • Software for stitching and compositing multi-frame aggregates like panoramas and image stacks.

Using the LibRaw library allows one to focus on the substantive part of processing the data contained in RAW files, without getting distracted by the wide variety of RAW file and metadata formats, compression algorithms, etc.

The library's development is focused on:

  • Support for new cameras and formats
  • Improving extraction of metadata necessary for RAW processing
  • Providing an interface for reading other types of metadata.

Additionally, the LibRaw library offers some basic RAW conversion, intended for cases when such conversion is not the main function of the LibRaw-using application (for example: a viewer for 500+ graphic file formats, including RAW). These methods are inherited from the Dave Coffin's dcraw.c utility (see below the "Project history" section); their further development is not currently planned, because we do not consider production-quality rendering to be in the scope of LibRaw's functionality (the methods are retained for compatibility with prior versions and for rapid-fire testing of RAW support and other aspects).

Licensing

The LibRaw library is distributed free of charge and with open-source code subject to two licenses:

1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1

2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0

To use the LibRaw library in an application, you can choose the license that better suits your needs.

If you modify/add/improve the LibRaw source code, then your patches can only be included into the library's official source code if you agree to it being distributed under both of the above licenses.

We do not guarantee that the licensing will not change in future versions of LibRaw.

Update policy

Major/minor releases

  • Major releases (for example, 0.20) are published once every year and a half to three years.
  • When the first public beta version of a major release is published, the list of supported cameras and formats is frozen; we try (but do not guarantee) to freeze the API/ABI as well.
  • The public major release contains only that code which has been sufficiently tested on a wide user base (including in our commercial products). Something very new may not be included in it (but it will probably be included in a public snapshot, see below).
  • Minor updates (0.20.1, 0.20.2) do not change the API/ABI and new cameras are not added; generally they are just bugfixes.
  • Bugfixes are published as soon as possible in the public GitHub repository.
  • Minor version increments: these are generally published if a serious error has been fixed, one that potentially affects many library users (for example, a possible stack overflow).

Public snapshots

  • Public snapshots are published every 9-18 months in the public GitHub repository.
  • These versions contain support for new cameras that was added after the previous major release. The API/ABI of public snapshots is not frozen, and may change.
  • Public snapshots are always tested on a fairly large user base, and may be considered suitable for use in programs that work with files with known origins (that is, recorded directly by users' digital cameras). However, public snapshots should not be considered sufficiently reliable for processing files that are specially constructed for vulnerability testing; that is, they should not be used in public services that allow for anonymous processing of files of unknown provenance

Support and feedback

  • You can submit a bug report in one of the following ways:
  • Questions can be asked on the forum, through the feedback form, and via the email indicated above.
    Please do not use Issues on GitHub for questions; it is intended specifically for problem reports.
  • We prefer to process additions to the source code via the Pull Requests on GitHub.

We cannot guarantee any response to requests submitted via the above methods. If you need a guaranteed response for a bug report and/or for extending technical support, please use the Extended Support option.

Project history

The LibRaw project was launched in 2008, based on the dcraw.c (Dave Coffin) utility, with its goals being to:

  • Convert dcraw.c into a library that could be used by other programs, while also somewhat improving the structure of dcraw.c (removing global variables, making it thread-safe, etc.)
  • Import changes made to dcraw.c
  • Improve/expand the extraction of metadata.

Unfortunately, support for dcraw.c was reduced to a minimum in 2015, and completely ceased in 2018. Since then, support for new cameras (including support for new formats) has been done entirely by the LibRaw team.

The code that implements rendering of RAW to RGB is inherited from dcraw.c, without major changes (though a set of changes was implemented to speed up and parallelize this code).

In the early-to-mid 2010s, we gladly expanded post-processing implemented in LibRaw, and readily accepted the input of outside developers (new/improved methods for debayerization/demosaicing, systematic noise reduction etc.).

Experience has shown that the LibRaw team cannot support this added code on their own, while contributors do not provide support and development of the code they suggest and it ends up abandoned. As such, the majority of the modifications that are implemented by people outside the LibRaw team was moved to the LibRaw-demosaic-pack-..., where they remain in their original form (but these projects are still present in our GitHub).

Thus, we arrive at our current status, described in the first part of this text.

Copyrights and Acknowledgements

Copyright (C) 2008-2024 LibRaw LLC

LibRaw uses code from Dave Coffin's dcraw.c utility (without RESTRICTED/GPL2 code):

Copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net

LibRaw uses DCB demosaic code by Jaceck Gozdz distributed under BSD license:

Copyright (C) 2010, Jacek Gozdz (mailto:[email protected])

LibRaw uses Roland Karlsson's X3F tools source code, licensed under BSD license:

Copyright (c) 2010, Roland Karlsson ([email protected])

libraw's People

Contributors

akhuettel avatar alextutubalin avatar cgilles avatar corec avatar danielkaneider avatar dktrkranz avatar dlemstra avatar emmenlau avatar iiborg avatar jabbervorx avatar jamiepinheiro avatar joankaradimov avatar kmilos avatar libraw avatar markreidvfx avatar maslbl4 avatar ncruces avatar pablosichert avatar paolobarbolini avatar petrminar avatar phries avatar pinotree avatar pjanx avatar radhermit avatar samwhited avatar sashashura avatar sizeofvoid avatar thesamesam avatar tpetazzoni avatar vtorri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libraw's Issues

Support HDR DNG images from HDRMerge

I will paste the correspondence I had via email, as it is good to have this public so that other people can take part in the discussion.

On 8/14/2014 1:32 PM, Beep6581 wrote:
Hi

HDRMerge is an awesome FOSS program from Javier Celaya for generating a high
dynamic range raw image in the DNG format from a bracketed raw set.
https://github.com/jcelaya/hdrmerge

Please add support for correctly reading the thumbnails and embedded preview
from these raw images. They follow standards and should therefore be
supported.
You can download a sample image here:
http://rawtherapee.com/shared/test_images/hdrmerge_045.dng

I was informed I should ask you directly:
https://bugs.kde.org/show_bug.cgi?id=338081
As I can't find your bug tracker anywhere, I'm doing this via direct contact.
If you have one, please file the request on my behalf.

Kind regards

On 2014-08-14 04:57, Alex Tutubalin wrote:

Hi,

LibRaw's main goal is RAW data decoding, so LibRaw::open_file() call
will return 'success' only if known RAW data is found in file.
Unfortunately, high-bit integer and floating point RAWs (DNGs) are not
supported due to LibRaw's internals specifics.

So, there is no way to support thumbnails/previews in unsupported
format without API break.

You may use some EXIF management library (e.g. exiv2) to extract
metadata and previews.

Alex Tutubalin, LibRaw team

These HDR DNG images are raw, they are not demosaiced. Furthermore, they are structured "by the book" as per the DNG specification. This includes the embedded JPEG thumbnail and preview.
My request is that libraw at least allows the extraction of these embedded JPEG thumbnails and preview images (I was lead to believe by Caulier Gilles that digiKam relies on libraw to extract these embedded JPEGs - is this correct?) if raw decoding and demosaicing is not possible.

Kind regards

Building for Visual Studio 2015 x64

Hi! I'm trying to build with VS2015 - the solution included on github works fine for 32 bits but I'm not sure how to make it do a 64-bit build. I tried making a new configuration in Visual Studio but the resulting DLLs don't work with my 64-bit program.

Version 0.17 on the website has a CMakeLists.txt file included which allows me to generate a VS2015 x64 solution. Is this possible for the development version 0.18 on Github?

Thanks a lot.

USE_DNGSDK

What is the impact of USE_DNGSDK as LibRaw can read DNG without the SDK?

If you'd prefer this on the forum, just let me know.

Also if I somehow missed documentation on it, just point me that way.

Thumbnails for Olympus raw (ORF) in Digikam albumview are blurred with libraw 0.17 and 0.18

Hi libraw team,

Gilles Caulier from the digikam team asked me to report this problem here. It is already discussed in:

https://bugs.kde.org/show_bug.cgi?id=368862

It seems that libraw 0.17 and 0.18 in combination with digikam shows blurred previews, i.e. the smaller preview (with 120x160px) is extracted instead of 3200x2400px. As a result digikam shows only a very blurred thumbnail in albumview.

Guenther

floating point exception in dcraw_common.cpp

There is a floating point exception in dcraw_common.cpp of libRAW. It will lead to remote denial of service attack.
command to reproduce: ./simple_dcraw crash-2fee14cdebd7dd87eb80e53f6618b3befcd13d31.
the latest version is vulnerable. other versions may also be affected.

warning: core file may not match specified executable file.
[New LWP 25437]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `/root/Desktop/fuzz/src/LibRaw/bin/.libs/lt-simple_dcraw ../libfuzz/crash-2fee14'.
Program terminated with signal SIGFPE, Arithmetic exception.
#0  0x00007fa4c3cb4d3e in LibRaw::identify (this=0x7fffe493a7b0) at internal/dcraw_common.cpp:15913
15913       raw_height = height + (top_margin = i / (width * tiff_bps / 8) - height);
(gdb) bt
#0  0x00007fa4c3cb4d3e in LibRaw::identify (this=0x7fffe493a7b0) at internal/dcraw_common.cpp:15913
#1  0x00007fa4c3cf2b78 in LibRaw::open_datastream (this=0x7fffe493a7b0, stream=0x1c5ddc0) at src/libraw_cxx.cpp:1965
#2  0x00007fa4c3cf0b02 in LibRaw::open_file (this=0x7fffe493a7b0, fname=0x7fffe49c57cd "../libfuzz/crash-2fee14cdebd7dd87eb80e53f6618b3befcd13d31", max_buf_size=262144000) at src/libraw_cxx.cpp:1033
#3  0x00000000004012cf in main (ac=2, av=0x7fffe49c4628) at samples/simple_dcraw.cpp:121
(gdb) 

the poc file attached: crash-2fee14cdebd7dd87eb80e53f6618b3befcd13d31.zip

user_flip can't be reverted between multiple open/recycle calls

I'm calling the following sequence:

rawProcessor->open_datastream(...)
rawProcessor->imgdata.params.user_flip = 0;
rawProcessor->adjust_sizes_info_only();
rawProcessor->recycle();

rawProcessor->open_datastream(...)
rawProcessor->imgdata.params.output_bps = 16;
rawProcessor->imgdata.params.document_mode = 2;
rawProcessor->imgdata.params.shot_select = 0;
rawProcessor->imgdata.params.user_flip = -1;
rawProcessor->unpack();

After that, rawProcessor->imgdata.rawdata.sizes.flip is still zero, even for roted images. Setting user_flip back to undefined has no effect.

CVE-2017-14348 Heap buffer overflow in LibRaw::processCanonCameraInfo

Sample: http://bugs.fi/media/afl/libraw/libraw-0.18.3-heap-buffer-overflow-processCanonCameraInfo.cr2
Credit: Henri Salo from Nixu Corporation
Tools: afl-2.51b, afl-utils, GCC AddressSanitizer

./raw-identify 3cf207558915d72a1a77ae9c8ed55b7496c2131e
=================================================================
==12072==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200000ee31 at pc 0x7febd8ff396d bp 0x7ffc53c69e20 sp 0x7ffc53c69e18
WRITE of size 1 at 0x60200000ee31 thread T0
    #0 0x7febd8ff396c in LibRaw::processCanonCameraInfo(unsigned int, unsigned char*, unsigned int) internal/dcraw_common.cpp:5892
    #1 0x7febd9046da9 in LibRaw::parse_makernote(int, int) internal/dcraw_common.cpp:8330
    #2 0x7febd905de27 in LibRaw::parse_exif(int) internal/dcraw_common.cpp:9836
    #3 0x7febd902f3fd in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10717
    #4 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #5 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #6 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #7 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #8 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #9 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #10 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #11 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #12 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #13 0x7febd903d7ea in LibRaw::parse_tiff(int) internal/dcraw_common.cpp:11254
    #14 0x7febd908b0cc in LibRaw::identify() internal/dcraw_common.cpp:14124
    #15 0x7febd91b26c6 in LibRaw::open_datastream(LibRaw_abstract_datastream*) src/libraw_cxx.cpp:1737
    #16 0x7febd91be1b2 in LibRaw::open_file(char const*, long long) src/libraw_cxx.cpp:972
    #17 0x4016a9 in main samples/raw-identify.cpp:141
    #18 0x7febd781db44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b44)
    #19 0x408459 (/home/afl/builds/libraw/0.18.3/bin/raw-identify+0x408459)

0x60200000ee31 is located 0 bytes to the right of 1-byte region [0x60200000ee30,0x60200000ee31)
allocated by thread T0 here:
    #0 0x7febd94cb73f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5473f)
    #1 0x7febd915b15b in libraw_memmgr::malloc(unsigned long) libraw/libraw_alloc.h:39
    #2 0x7febd915b15b in LibRaw::malloc(unsigned long) src/libraw_cxx.cpp:475
    #3 0x7febd9045d5e in LibRaw::parse_makernote(int, int) internal/dcraw_common.cpp:8316
    #4 0x7febd905de27 in LibRaw::parse_exif(int) internal/dcraw_common.cpp:9836
    #5 0x7febd902f3fd in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10717
    #6 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #7 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #8 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #9 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #10 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #11 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #12 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #13 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #14 0x7febd90342c1 in LibRaw::parse_tiff_ifd(int) internal/dcraw_common.cpp:10550
    #15 0x7febd903d7ea in LibRaw::parse_tiff(int) internal/dcraw_common.cpp:11254
    #16 0x7febd908b0cc in LibRaw::identify() internal/dcraw_common.cpp:14124
    #17 0x7febd91b26c6 in LibRaw::open_datastream(LibRaw_abstract_datastream*) src/libraw_cxx.cpp:1737
    #18 0x7febd91be1b2 in LibRaw::open_file(char const*, long long) src/libraw_cxx.cpp:972
    #19 0x4016a9 in main samples/raw-identify.cpp:141
    #20 0x7febd781db44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b44)

SUMMARY: AddressSanitizer: heap-buffer-overflow internal/dcraw_common.cpp:5892 LibRaw::processCanonCameraInfo(unsigned int, unsigned char*, unsigned int)
Shadow bytes around the buggy address:
  0x0c047fff9d70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9d80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9d90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9da0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9db0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c047fff9dc0: fa fa fa fa fa fa[01]fa fa fa 00 07 fa fa fd fd
  0x0c047fff9dd0: fa fa fd fd fa fa 00 04 fa fa 00 04 fa fa 00 04
  0x0c047fff9de0: fa fa 00 04 fa fa 00 04 fa fa 00 04 fa fa 00 04
  0x0c047fff9df0: fa fa 00 04 fa fa 00 04 fa fa 00 04 fa fa 00 fa
  0x0c047fff9e00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fff9e10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Contiguous container OOB:fc
  ASan internal:           fe
==12072==ABORTING

imgdata.color data structure not getting filled

I use the camera matrix data in calculating an approximate temperature and tint from the camera white balance multipliers.

However, at least on one computer of mine (I'm on vacation, using my laptop instead of my main dev computer) LibRaw is giving me unrealistic values.

For example, imgdata.color.rgb_cam, the particular matrix I need, is turning out to be the following for all cameras, whereas it used to be unique for most every camera model and had rows summing to 1.0:

3.5002e-18 3.55442e-18 3.60863e-18
3.71705e-18 3.77126e-18 3.82547e-18
3.93389e-18 3.9881e-18 4.04231e-18

versus (for the Canon 5D)

1.80831 -0.927391 0.11908
-0.0172622 1.31479 -0.297526
0.0581242 -0.34987 1.29175

The strange thing is that every version of LibRaw since 0.17.0 up to and including the just-released 0.18.0 is having the same issue, even though on my other computer, 0.17.0 works just fine (I did submit a bug report on 0.17.0 just over a year ago). On this computer, 0.16.2 and earlier works.

Can you think of any reason this might be?

Configure recurses outside build dir in release tarball.

Basically, there's a relative ../ in your autotools setup that's making it back completely out of the build directory and execute finds in the peers of the build directory, including hidden directories. This is for release tarball LibRaw-0.18.1.tar.gz. Problem is repeatable. The default untarring was not altered and autoreconf was not run upon the package. Source URL: http://www.libraw.org/data/LibRaw-0.18.1.tar.gz

I imagine it could create issues if there's a supporting lib untarred in a neighboring directory and it pulls a header from there instead of /usr/include. Copy of configure output below.

checking pkg-config is at least version 0.9.0... yes
checking for LCMS2... yes
find: '../.Trash-1000': Permission denied
find: '../other/temp/etc-backup/polkit-1/rules.d': Permission denied
find: '../other/temp/etc-backup/sudoers.d': Permission denied
configure: WARNING: Unable to find working LibRaw-demosaic-pack-GPL2 in , disabling the feature. Use --enable-demosaic-pack-gpl2=directory to override
find: '../.Trash-1000': Permission denied
find: '../other/temp/etc-backup/polkit-1/rules.d': Permission denied
find: '../other/temp/etc-backup/sudoers.d': Permission denied
configure: WARNING: Unable to find working LibRaw-demosaic-pack-GPL3 in , disabling the feature. Use --enable-demosaic-pack-gpl3=directory to override
checking that generated files are newer than configure... done
configure: creating ./config.status

Build for iOS

Hi there,

Is there anyway that I can build the lib to static file (libraw_r.a) that support architecture arm64,armv7, armv7s?

Thanks

Fails to build with GCC-6

> internal/dcraw_common.cpp:4539:3: error: narrowing conversion of '136' from 'int' to 'signed char' inside { } [-Wnarrowing]
> internal/dcraw_common.cpp:4539:3: error: narrowing conversion of '128' from 'int' to 'signed char' inside { } [-Wnarrowing]
> internal/dcraw_common.cpp:4539:3: error: narrowing conversion of '136' from 'int' to 'signed char' inside { } [-Wnarrowing]
> internal/dcraw_common.cpp:4539:3: error: narrowing conversion of '128' from 'int' to 'signed char' inside { } [-Wnarrowing]
> internal/dcraw_common.cpp:4539:3: error: narrowing conversion of '136' from 'int' to 'signed char' inside { } [-Wnarrowing]
> Makefile:862: recipe for target 'internal/dcraw_common.lo' failed
> make[1]: *** [internal/dcraw_common.lo] Error 1

More info can be found at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=811744

wf_filtering.cpp

Lots of expressions of the form

(S.width & 1 == 1)

and

(S.height & 1 == 1)

Given the precedence of == over &, this is the same as:

((S.width & 1) != 0) // or alternatively: (S.width & 1)

and

((S.height & 1) != 0) // or alternatively: (S.height & 1)

The advantage of the latter forumulations is that you avoid compiler warnings from -Wparentheses. In my opinion it is also clearer.

Cannot compile 0.18 with MSVC 2010

Since 0.18 I can't compile using MSVC 2010 anymore. 0.17 worked fine. I get the following errors:

[ 14%] Building CXX object CMakeFiles/raw_r.dir/internal/dcraw_common.cpp.obj
cl : Command line warning D9025 : overriding '/W3' with '/w'
dcraw_common.cpp
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2267) : error C2146: syntax error : missing ';' before identifier 'umode'
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2267) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2267) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2268) : error C2146: syntax error : missing ';' before identifier 'uwidth'
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2268) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2268) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2269) : error C2146: syntax error : missing ';' before identifier 'uheight'
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2269) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2269) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2270) : error C2146: syntax error : missing ';' before identifier 'padding_right'
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2270) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2270) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2271) : error C2146: syntax error : missing ';' before identifier 'padding_down'
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2271) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2271) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2272) : error C2146: syntax error : missing ';' before identifier 'unknown_block'
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2272) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2272) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2273) : error C2146: syntax error : missing ';' before identifier 'transform'
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2273) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2273) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2274) : error C2146: syntax error : missing ';' before identifier 'format'
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2274) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2274) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2275) : error C2146: syntax error : missing ';' before identifier 'bayer_order'
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2275) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2275) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2276) : error C2146: syntax error : missing ';' before identifier 'bayer_format'
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2276) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2276) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2279) : error C2039: 'bayer_order' : is not a member of 'LibRaw::parse_broadcom::<unnamed-type-header>'
        C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2266) : see declaration of 'LibRaw::parse_broadcom::<unnamed-type-header>'
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2282) : error C2039: 'uwidth' : is not a member of 'LibRaw::parse_broadcom::<unnamed-type-header>'
        C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2266) : see declaration of 'LibRaw::parse_broadcom::<unnamed-type-header>'
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2282) : error C2039: 'padding_right' : is not a member of 'LibRaw::parse_broadcom::<unnamed-type-header>'
        C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2266) : see declaration of 'LibRaw::parse_broadcom::<unnamed-type-header>'
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2283) : error C2039: 'uwidth' : is not a member of 'LibRaw::parse_broadcom::<unnamed-type-header>'
        C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2266) : see declaration of 'LibRaw::parse_broadcom::<unnamed-type-header>'
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2284) : error C2039: 'uheight' : is not a member of 'LibRaw::parse_broadcom::<unnamed-type-header>'
        C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2266) : see declaration of 'LibRaw::parse_broadcom::<unnamed-type-header>'
C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2287) : error C2039: 'bayer_order' : is not a member of 'LibRaw::parse_broadcom::<unnamed-type-header>'
        C:\projects\rawpy\external\LibRaw\internal\dcraw_common.cpp(2266) : see declaration of 'LibRaw::parse_broadcom::<unnamed-type-header>'
NMAKE : fatal error U1077: 'c:\PROGRA~2\MICROS~2.0\VC\bin\amd64\cl.exe' : return code '0x2'

Is this easy to fix?

fatal error LNK1169: one or more multiply defined symbols found

I've updated LibRaw to 0.18 in my project. Now I have a compiler error:

MSVCRTD.lib(MSVCR120D.dll) : error LNK2005: _strnlen already defined in dcraw_common.obj
fatal error LNK1169: one or more multiply defined symbols found

Maybe it's not a good idea to name functions like existing functions in STDlib.

[Feature Request]Uncompressed RAW of Sony ARW?

Hi, upon the release of Sony A7 Mark 2 series of cameras, Sony provides a new file format, namely Uncompressed RAW. It's still in Sony ARW container but is not decodable by LibRAW 0.18. Any plan to add it on the list?

Please backport CVE-2017-6886+CVE-2017-6887 fix to 0.17-stable branch too

Hi!

As maintainer of LibRaw in Debian, I need to patch the package in actual testing (going to become Debian 9 "Stretch" within few days) which is based on 0.17.2 release.
While I've already packaged 0.18.2 release and it will hit testing/buster and unstable/sid once stretch will become stable, I have some concerns with backporting d7c3d2c commit, because the codebase is quite different.
Would it be feasible for you to backport that change on 0.17-stable branch, at least?

Thanks in advance for the efforts.

Stack out of bounds read in internal/dcraw_common.cpp(kodak_65000_load_raw)

Command to reproduce: simple_dcraw crash-kodak_65000_load_raw_out-of-bounds-read
crash-kodak_65000_load_raw_out-of-bounds-read.zip

=================================================================
==229209==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffffff73ee2 at pc 0x7ffff778df6e bp 0x7ffffff72730 sp 0x7ffffff72728
READ of size 2 at 0x7ffffff73ee2 thread T0
    #0 0x7ffff778df6d in LibRaw::kodak_65000_load_raw() /root/Desktop/fuzz/src/LibRaw/internal/dcraw_common.cpp:3731:34
    #1 0x7ffff7a96515 in LibRaw::unpack() /root/Desktop/fuzz/src/LibRaw/src/libraw_cxx.cpp:2807:7
    #2 0x52d0a3 in main /root/Desktop/fuzz/src/LibRaw/samples/simple_dcraw.cpp:126:31
    #3 0x7ffff6273f44 in __libc_start_main /build/eglibc-SvCtMH/eglibc-2.19/csu/libc-start.c:287
    #4 0x41b6db in _start (/root/Desktop/fuzz/src/LibRaw/bin/.libs/simple_dcraw+0x41b6db)

Address 0x7ffffff73ee2 is located in stack of thread T0 at offset 1058 in frame
    #0 0x52b7df in main /root/Desktop/fuzz/src/LibRaw/samples/simple_dcraw.cpp:56

  This frame has 3 object(s):
    [32, 1056) 'outfn' (line 60) <== Memory access at offset 1058 overflows this variable
    [1184, 2208) 'thumbfn' (line 60)
    [2336, 566928) 'RawProcessor' (line 62)
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow /root/Desktop/fuzz/src/LibRaw/internal/dcraw_common.cpp:3731:34 in LibRaw::kodak_65000_load_raw()
Shadow bytes around the buggy address:
  0x10007ffe6780: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10007ffe6790: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10007ffe67a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10007ffe67b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10007ffe67c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10007ffe67d0: 00 00 00 00 00 00 00 00 00 00 00 00[f2]f2 f2 f2
  0x10007ffe67e0: f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 00 00 00 00
  0x10007ffe67f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10007ffe6800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10007ffe6810: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10007ffe6820: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==229209==ABORTING

gdb debug output:

(gdb) bt
#0  0x00000000004fdc04 in __asan::ReportGenericError(unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned int, bool) ()
#1  0x00000000004fe9f3 in __asan_report_load2 ()
#2  0x00007ffff778df6e in LibRaw::kodak_65000_load_raw (this=0x7ffffff743e0) at internal/dcraw_common.cpp:3731
#3  0x00007ffff7a96516 in LibRaw::unpack (this=0x7ffffff743e0) at src/libraw_cxx.cpp:2807
#4  0x000000000052d0a4 in main (ac=2, av=0x7fffffffe3a8) at samples/simple_dcraw.cpp:126
(gdb) f 2
#2  0x00007ffff778df6e in LibRaw::kodak_65000_load_raw (this=0x7ffffff743e0) at internal/dcraw_common.cpp:3731
3731	        if ((RAW(row, col + i) = curve[ret ? buf[i] : (pred[i & 1] += buf[i])]) >> 12)
(gdb) p ret ? buf[i] : (pred[i & 1] += buf[i])
$5 = -544416
(gdb) p pred
$6 = {-544416, 32767}
(gdb) p buf[i]
$7 = 17376
(gdb) 

we could see that the index of curve is a large negative number -544416, leads out of bounds read.

"configure" file is missing from the root of the project on master

"configure" file is missing from the root of the project on master.

Steps to reproduce:

  • Do git clone https://github.com/LibRaw/LibRaw.git
  • Do cd LibRaw
  • Do ./configure

Expected results:

The config script runs.

Actual results:

-bash: ./configure: No such file or directory

problem compiling internal/dcraw_common.cpp when jpeg but no jpeg 8

If you build with --enable-jpeg, and the jpeglib.h file has jpeg support but not jpeg 8.0 support (so no jpeg_mem_src), the build will fail when trying to compile internal/dcraw_common.cpp. The following patch fixes that:

$ diff -u internal/dcraw_common.cpp{.orig,}
--- internal/dcraw_common.cpp.orig 2015-11-24 07:17:22.000000000 -0800
+++ internal/dcraw_common.cpp 2016-03-05 18:44:09.000000000 -0800
@@ -2570,7 +2570,7 @@
#undef FORYX
#undef PREDICTOR

-#ifdef NO_JPEG
+#ifndef USE_JPEG8
void CLASS kodak_jpeg_load_raw() {}
void CLASS lossy_dng_load_raw() {}
#else

linker error win32/LibRaw_buffer_datastream

Compiling LibRaw 0.14beta4 results in the following error for me:

error LNK2001: unresolved external symbol "public: virtual void * __thiscall LibRaw_buffer_datastream::make_jas_stream(void)" (?make_jas_stream@LibRaw_buffer_datastream@@UAEPAXXZ)

This is caused of I create my own stream implementation, but do not override the method tempbuffer_open(). As I only include libraw_datastream.h and not libraw_cxx.cpp I get the above linker error. So please make either

  • make_jas_stream() not abstract in LibRaw_abstract_datastream or
  • move the implementation of LibRaw_buffer_datastream::make_jas_stream() into libraw_datastream.h

Regards, Jens

A Stack Buffer Overflow was discovered in internal/dcraw_common.cpp

A Stack Buffer Overflow was discovered in internal/dcraw_common.cpp:5685(LibRaw::xtrans_interpolate). It could allow remote denial of service
and code execution attack.

command to reproduce: ./simple_dcraw crash-xtrans_interpolate-stack-overflow
the latest version is vulnerable. other versions may also be affected.

the sanitizer output:

==96836==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffc31555040 at pc 0x7fb90cf370b4 bp 0x7ffc31554f50 sp 0x7ffc31554f48
WRITE of size 4 at 0x7ffc31555040 thread T0
    #0 0x7fb90cf370b3 in LibRaw::xtrans_interpolate(int) /root/Desktop/fuzz/src/LibRaw/internal/dcraw_common.cpp:5836:29
    #1 0x7fb90d230469 in LibRaw::dcraw_process() /root/Desktop/fuzz/src/LibRaw/src/libraw_cxx.cpp:4829:9
    #2 0x514e1e in main /root/Desktop/fuzz/src/LibRaw/samples/simple_dcraw.cpp:159:24
    #3 0x7fb90b9dff44 in __libc_start_main /build/eglibc-SvCtMH/eglibc-2.19/csu/libc-start.c:287
    #4 0x41a6bb in _start (/root/Desktop/fuzz/src/LibRaw/bin/.libs/lt-simple_dcraw+0x41a6bb)

Address 0x7ffc31555040 is located in stack of thread T0 at offset 224 in frame
    #0 0x7fb90cf3192f in LibRaw::xtrans_interpolate(int) /root/Desktop/fuzz/src/LibRaw/internal/dcraw_common.cpp:5686

  This frame has 5 object(s):
    [32, 64) 'hm' (line 5688)
    [96, 112) 'avg' (line 5688)
    [128, 224) 'color' (line 5688) <== Memory access at offset 224 overflows this variable
    [256, 544) 'allhex' (line 5693)
    [608, 632) 'diff' (line 5697)
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow /root/Desktop/fuzz/src/LibRaw/internal/dcraw_common.cpp:5836:29 in LibRaw::xtrans_interpolate(int)
Shadow bytes around the buggy address:
  0x1000062a29b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000062a29c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000062a29d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000062a29e0: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
  0x1000062a29f0: 00 00 00 00 f2 f2 f2 f2 00 00 f2 f2 00 00 00 00
=>0x1000062a2a00: 00 00 00 00 00 00 00 00[f2]f2 f2 f2 00 00 00 00
  0x1000062a2a10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000062a2a20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000062a2a30: f2 f2 f2 f2 f2 f2 f2 f2 00 00 00 f3 f3 f3 f3 f3
  0x1000062a2a40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x1000062a2a50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==96836==ABORTING

in internal/dcraw_common.cpp:5688 (xtrans_interpolate), color was defined as:

  int val, ndir, pass, hm[8], avg[4], color[3][8];

with the input testcase in gdb, we could see that the h is 3, which leads stack overflow

(gdb) f 2
#2  0x0000000000650838 in LibRaw::xtrans_interpolate (this=0x7ffffff72c60, passes=3) at internal/dcraw_common.cpp:5836
5836	                color[h][d] = g + rix[i << c][h] + rix[-i << c][h];
(gdb) p h
$24 = 3
(gdb) p d
$25 = 0

Large camera matrix differences between 0.16 and 0.17 for Canon 6D

The camera matrix in dcraw_common.cpp has changed for the Canon 6D and it's throwing off the white balance.

It used to be:

{ 7034,-804,-1014,-4420,12564,2058,-851,1994,5758 }

Now it is:

{ 8621,-2197,-787,-3150,11358,912,-1161,2400,4836 }

Any reason for this?

It seems that at the time of this commit, 127bffb, dcraw had for the 6D matrix

{ 8624,-2197,-788,-3150,11361,912,-1161,2401,4838 }

Then, this commit changed it to its current value: 004ac61.

In my use of LibRaw, I'm currently using the reference (daylight?) multipliers (pre_mul) to normalize the camera's white balance multipliers used for that photo (cam_mul) in order to determine the Kelvin temperature and tint values, but they're waaaay off with the new matrix.

The latest dcraw.c file from the source is back to the older matrix.

Huge issue in dcraw_common.cpp, function does not return.

After SHA 35158cb (26 jan), you removed the return statement in phase_one_correct(). This results in huge memory problems for big phase one files and multicore processing, or a magic combination of the former. Please fix asap.

Fix: Re-add return statement.

  return 0;
#ifdef LIBRAW_LIBRARY_BUILD
  }
  catch (...)
  {
      return LIBRAW_CANCELLED_BY_CALLBACK;
  }
#endif
}

image

Olympus / wrong color count

At images of type Olympus C5050Z / C8080WZ / SP350 / SP500UZ imgdata.idata.colors has a suspicious high value.

Bring back cmake

I'm a bit shocked by your recent commits that remove cmake support. I used this to easily compile LibRaw under Mac and Windows without fiddling in makefiles. I thought it worked perfectly, why did you remove it? Do you want to replace it by something else? Otherwise this would make life just harder..

cmake: Remove LibXML2 requirement for rawspeed

Rawspeed doesn't need libxml2 anymore, instead it bundles pugixml. I cannot run cmake on Windows with rawspeed support because it requires LibXML2 to enable rawspeed. Please remove this requirement, it is not needed anymore.

msvc compilation and zlib

Hi,

it seems that zlib was added as a dependency for libraw. Are there any plans to add the library to the currently supported build systems. For now it seems that compilation on msvc using that Makefile.msvc doesn't support any zlib path yet.
What are the steps to compile current trunk using msvc?

How to get metadata?

Hi,

I am using LibRaw to load raw images,
but I think that it is insufficient to obtain file metadata.
I saw the source code, but it does not seem to be an exhaustive implementation like Exiv 2.

How do you solve it?

Libraw fails to build

My system:
Fedora 25
kernel version 4.11.6-201.fc25.x86_64
gcc version gcc version 6.3.1 20161221 (Red Hat 6.3.1-1) (GCC)
Libraw version 0.18.2

I'm trying to install LibRaw on my system but running into errors when running make. The error message is:
Makefile:714: recipe for target 'bin/dcraw_half' failed
make: *** [bin/dcraw_half] Error 1

See attached for full text. I read somewhere libraw wasn't tested for gcc was not tested for gcc versions higher than 4.x, is that true? Also, this link #56 refers to a patch to libraw to be included in the next libraw .18 update, has that been included? And finally, is there a solution for my issue? Thanks in advance.
makefile.txt

Can't develop Canon EOS 50D SRAW1 CR2 files

Hello,

I have just discovered that I am not able to a develop Canon EOS 50D SRAW1 CR2 files in digiKam using libraw 0.18 beta1 or libraw 0.18. RAW and SRAW2 are working as expected.

Here is a SRAW1 sample image to test with:
https://drive.google.com/file/d/0B9V6P-GSf0KUTjZCSkk0QjZ3bW8/view

Here is a screenshoot from when trying to develop the above image in digiKam:
https://drive.google.com/file/d/0B9V6P-GSf0KUeEpCTHQzY2VhelU/view?usp=sharing

It has been working with earlier version. Don't know when this dysfunction was introduced though.

/Anders

SONY ILCE-7M2 white levels

Hey

I compiled HDRMerge against libraw-0.17.2 and the white levels for my SONY ILCE-7M2 are auto-detected very incorrectly, leading to a completely broken image. It seems that libraw detects them as 17220, at least for this bracketed set: https://filebin.net/3pdvjg3hmgds7x4j

I can't currently test libraw-0.18.0 or git.

Yesterday I measured the white levels of the 7M2 using compressed and uncompressed raw files with and without long exposure noise reduction, you can find the results along with the measurement samples here: Beep6581/RawTherapee#3601

Kind regards

P.S. Those links will expire in 2 months.

Please replace Jasper by OpenJPEG

Jasper is the "reference implementation of the codec specified in the JPEG-2000 Part-1 standard" (from https://www.ece.uvic.ca/~frodo/jasper/). Sadly, it also has incomplete JPEG-2000 support and is now unmaintained.

OpenJPEG is "an open-source JPEG-2000 codec written in C" (from http://www.openjpeg.org).
It has better JPEG-2000 support and has the advantage of still being maintained.
Code is placed under BSD license, details here:

https://github.com/uclouvain/openjpeg/blob/master/LICENSE

Following the request on the Debian BTS (https://bugs.debian.org/818204) to drop the Jasper support as it's going to be removed from the Debian archives before the next Debian stable release, please consider the switch.

Olympus TG-4 wrong distortion in raw

I've got problems with distortion in raw on my Olympus TG-4 camera. Only Adobe (Photoshop/Lightroom) and brand Olympus Viewer software can show me correct result.

There is the samples:
That is Olympus jpeg (correct): http://pasteboard.co/Cn6bL8XF.jpg
That is Adobe version (correct): http://pasteboard.co/CoLK1K1t.jpg
That is LibRaw (18.2) (digikam 5.5 / FastRawViewer 1.3.9) (incorrect): http://pasteboard.co/CnxTGZRo.jpg

Also, dcraw (XnView 2.39), RawTherapee(5.0), CyberLink PhotoDirector 8, CaptureOne 10 all got same problem with curved horizon

original raw: https://goo.gl/vgP6cV
all samples: https://goo.gl/Z7rQzI

camera firmware 2.0
Windows 10 x64
And I've got a lot of samples like this if you need...

There is a floating point exception in dcraw_common.cpp of libRAW.

Triggered by "./multirender_test POC1"

Description of problem:

There is a floating point exception in dcraw_common.cpp of libRAW.

Version-Release number of selected component (if applicable):

<= latest version

How reproducible:

./multirender_test POC1

Steps to Reproduce:

$ ./multirender_test POC1
Processing file POC1
Floating point exception

The GDB debugging information is as follows:

$ ./multirender_test POC1
gdb-peda$ r
...

Breakpoint 1, LibRaw::kodak_radc_load_raw (this=0x7ffffff9d6e8) at internal/dcraw_common.cpp:2751
2751 val = (buf[c][y+1][x] << 4) / mul[c];
gdb-peda$ c 11
Will ignore next 10 crossings of breakpoint 1. Continuing.

Breakpoint 1, LibRaw::kodak_radc_load_raw (this=0x7ffffff9d6e8) at internal/dcraw_common.cpp:2751
2751 val = (buf[c][y+1][x] << 4) / mul[c];
gdb-peda$ n

Program received signal SIGFPE, Arithmetic exception.

[----------------------------------registers-----------------------------------]
RAX: 0x1f70
RBX: 0x0
RCX: 0x2afa
RDX: 0x0
RSI: 0x7ffff7fda0d0 --> 0x1
RDI: 0x7ffff7d952c0 --> 0x1
RBP: 0x602878 --> 0x6028a0 --> 0x0
RSP: 0x7ffffff993a0 --> 0x0
RIP: 0x7ffff7a65e2b (LibRaw::kodak_radc_load_raw()+7259: idiv DWORD PTR [rsp+0x9c])
R8 : 0x7ffffff99dec --> 0x11380f00121d10bd
R9 : 0x0
R10: 0x7ffffff99dec --> 0x11380f00121d10bd
R11: 0x14
R12: 0x0
R13: 0x7ffffff9d6e8 --> 0x7ffff7d94a30 --> 0x7ffff7b48e10 (LibRaw::open_datastream(LibRaw_abstract_datastream*): push rbp)
R14: 0x0
R15: 0x300
EFLAGS: 0x10202 (carry parity adjust zero sign trap INTERRUPT direction overflow)
[-------------------------------------code-------------------------------------]
0x7ffff7a65e1f LibRaw::kodak_radc_load_raw()+7247: movsx eax,WORD PTR [rax+rbx*2+0x304]
0x7ffff7a65e27 LibRaw::kodak_radc_load_raw()+7255: shl eax,0x4
0x7ffff7a65e2a LibRaw::kodak_radc_load_raw()+7258: cdq
=> 0x7ffff7a65e2b LibRaw::kodak_radc_load_raw()+7259: idiv DWORD PTR [rsp+0x9c]
0x7ffff7a65e32 LibRaw::kodak_radc_load_raw()+7266: test eax,eax
0x7ffff7a65e34 LibRaw::kodak_radc_load_raw()+7268: mov r15d,0x0
0x7ffff7a65e3a LibRaw::kodak_radc_load_raw()+7274: cmovns r15w,ax
0x7ffff7a65e3f LibRaw::kodak_radc_load_raw()+7279: mov r13,rbp
[------------------------------------stack-------------------------------------]
0000| 0x7ffffff993a0 --> 0x0
0008| 0x7ffffff993a8 --> 0x700000000
0016| 0x7ffffff993b0 --> 0x90000000c ('\x0c')
0024| 0x7ffffff993b8 --> 0x8
0032| 0x7ffffff993c0 --> 0x7ffffff9a6fa --> 0x0
0040| 0x7ffffff993c8 --> 0x304
0048| 0x7ffffff993d0 --> 0x7ffffff9a6f8 --> 0x0
0056| 0x7ffffff993d8 --> 0x0
[------------------------------------------------------------------------------]
Legend: code, data, rodata, value
Stopped reason: SIGFPE
0x00007ffff7a65e2b in LibRaw::kodak_radc_load_raw (this=0x7ffffff9d6e8) at internal/dcraw_common.cpp:2751
2751 val = (buf[c][y+1][x] << 4) / mul[c];
gdb-peda$ x/xw ($rsp+0x9c)
0x7ffffff9943c: 0x00000000
gdb-peda$

The vulnerability was triggered in function LibRaw::kodak_radc_load_raw (this=0x7ffffff9d6e8) at internal/dcraw_common.cpp:2751
2749 for (y=0; y < 2; y++)
2750 for (x=0; x < width/2; x++) {
2751 val = (buf[c][y+1][x] << 4) / mul[c];
2752 if (val < 0) val = 0;
2753 if (c) RAW(row+y2+c-1,x2+2-c) = val;
2754 else RAW(row+r2+y,x2+y) = val;
2755 }

Actual results:

crash

Expected results:

crash

Additional info:

Credits:

This vulnerability is detected by team OWL337, with our custom fuzzer collAFL. Please contact [email protected] and [email protected] if you need more info about the team, the tool or the vulnerability.

POC1.zip

Part of expression always true

  1. dcraw_common.cpp 7846
is_raw += (i = get4()) && 1;

may be necessary "&"?

  1. dcraw_common.cpp 8271
if (!load_raw && (maximum = 0xfff))

"maximum = 0xfff" always true.

Camera WB for Sony NEX not loaded when LibRaw 0.14.7 is built with GCC 4.8

When building LibRaw 0.14.7 with GCC 4.8 it seems as though the white balance from the camera is not loaded correctly for ARWs from Sony NEX cameras. I've tried it with ARWs from NEX-5 and NEX-7.

I'm using ArchLinux 64-bit, and when using the libraw package from the community repository (built before switching to GCC 4.8) I get these camera multipliers from "raw-identify -v" (from this NEX-7 ARW):

Daylight multipliers: 2.753504 0.922004 1.151218
Camera multipliers: 2636.000000 1024.000000 1776.000000 1024.000000
Color sources /Legend: (U)nknown, (I)nit, (CO)nstant, (L)oaded, (CA)lculated/:
    curve=L; rgb_cam=CO; cmatrix=I, pre_mul=CO, cam_mul=L

I get the same result if I build the package myself with Clang 3.2. If I build the package with GCC 4.8 I no longer get the camera multipliers in the output though, and "cam_mul=I".

This means that both Darktable and RawTherapee from the ArchLinux repositories no longer loads the correct camera WB for Sony NEX ARWs, since those packages are now built with GCC 4.8.

Failed to build / LibRaw

I'm trying to build libraw 0.17.1
but, I can't build this lib following error message.
I can't find error. Anyone know this error?

---------

Platform.

---------

hostname = z400c77
uname -m = x86_64
uname -r = 2.6.18-348.el5
uname -s = Linux
uname -v = #1 SMP Wed Nov 28 21:22:00 EST 2012

/usr/bin/uname -p = unknown
/bin/uname -X = unknown

/bin/arch = x86_64
/usr/bin/arch -k = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo = unknown
/bin/machine = unknown
/usr/bin/oslevel = unknown

/bin/universe = unknown

$ ./configure --prefix=/user/hjnoh/local/libraw --enable-jasper --enable-jpeg
depbase=echo internal/dcraw_common.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||';
/bin/sh ./libtool --tag=CXX --mode=compile g++ -DPACKAGE_NAME="LibRaw" -DPACKAGE_TARNAME="libraw" -DPACKAGE_VERSION="0.17.1" -DPACKAGE_STRING="LibRaw\ 0.17.1" -DPACKAGE_BUGREPORT="[email protected]" -DPACKAGE_URL="http://www.libraw.org\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DHAVE_JPEGLIB_H=1 -I. -I/usr/local/include -DUSE_JPEG -DUSE_LCMS -I../LibRaw-demosaic-pack-GPL2-0.17.1 -DLIBRAW_DEMOSAIC_PACK_GPL2 -I../LibRaw-demosaic-pack-GPL3-0.17.1 -DLIBRAW_DEMOSAIC_PACK_GPL3 -g -O2 -fopenmp -MT internal/dcraw_common.lo -MD -MP -MF $depbase.Tpo -c -o internal/dcraw_common.lo internal/dcraw_common.cpp &&
mv -f $depbase.Tpo $depbase.Plo
libtool: compile: g++ -DPACKAGE_NAME="LibRaw" -DPACKAGE_TARNAME="libraw" -DPACKAGE_VERSION="0.17.1" "-DPACKAGE_STRING="LibRaw 0.17.1"" -DPACKAGE_BUGREPORT="[email protected]" -DPACKAGE_URL="http://www.libraw.org\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DHAVE_JPEGLIB_H=1 -I. -I/usr/local/include -DUSE_JPEG -DUSE_LCMS -I../LibRaw-demosaic-pack-GPL2-0.17.1 -DLIBRAW_DEMOSAIC_PACK_GPL2 -I../LibRaw-demosaic-pack-GPL3-0.17.1 -DLIBRAW_DEMOSAIC_PACK_GPL3 -g -O2 -fopenmp -MT internal/dcraw_common.lo -MD -MP -MF internal/.deps/dcraw_common.Tpo -c internal/dcraw_common.cpp -fPIC -DPIC -o internal/.libs/dcraw_common.o
internal/dcraw_common.cpp: In member function 'void LibRaw::canon_600_auto_wb()':
internal/dcraw_common.cpp:307: warning: converting to 'int' from 'double'
internal/dcraw_common.cpp: In member function 'void LibRaw::nikon_yuv_load_raw()':
internal/dcraw_common.cpp:1243: warning: converting to 'int' from 'double'
internal/dcraw_common.cpp:1244: warning: converting to 'int' from 'double'
internal/dcraw_common.cpp:1245: warning: converting to 'int' from 'double'
internal/dcraw_common.cpp:1246: warning: converting to 'ushort' from 'float'
internal/dcraw_common.cpp: In member function 'void LibRaw::phase_one_flat_field(int, int)':
internal/dcraw_common.cpp:1454: warning: converting to 'unsigned int' from 'float'
internal/dcraw_common.cpp: In member function 'int LibRaw::phase_one_correct()':
internal/dcraw_common.cpp:1509: warning: converting to 'ushort' from 'float'
internal/dcraw_common.cpp:1517: warning: converting to 'ushort' from 'float'
internal/dcraw_common.cpp:1542: warning: converting to 'short unsigned int' from 'double'
internal/dcraw_common.cpp:1547: warning: converting to 'short unsigned int' from 'double'
internal/dcraw_common.cpp:1625: warning: converting to 'int' from 'float'
internal/dcraw_common.cpp:1688: warning: converting to 'int' from 'float'
internal/dcraw_common.cpp:1697: warning: converting to 'int' from 'float'
internal/dcraw_common.cpp: In member function 'void LibRaw::phase_one_load_raw_c()':
internal/dcraw_common.cpp:1826: warning: converting to 'ushort' from 'double'
internal/dcraw_common.cpp: In member function 'void LibRaw::kodak_radc_load_raw()':
internal/dcraw_common.cpp:2501: warning: converting to 'ushort' from 'double'
internal/dcraw_common.cpp: In member function 'void LibRaw::kodak_jpeg_load_raw()':
internal/dcraw_common.cpp:2667: error: 'jpeg_mem_src' was not declared in this scope
internal/dcraw_common.cpp: In member function 'void LibRaw::lossy_dng_load_raw()':
internal/dcraw_common.cpp:2745: warning: converting to 'ushort' from 'double'
internal/dcraw_common.cpp: In member function 'void LibRaw::gamma_curve(double, double, int, int)':
internal/dcraw_common.cpp:3821: warning: converting to 'ushort' from 'double'
internal/dcraw_common.cpp: In member function 'void LibRaw::wavelet_denoise()':
internal/dcraw_common.cpp:4121: warning: converting to 'ushort' from 'float'
internal/dcraw_common.cpp:4153: warning: converting to 'ushort' from 'double'
internal/dcraw_common.cpp: In member function 'void LibRaw::green_matching()':
internal/dcraw_common.cpp:4202: warning: converting to 'ushort' from 'float'
internal/dcraw_common.cpp: In member function 'void LibRaw::scale_colors()':
internal/dcraw_common.cpp:4342: warning: converting to 'unsigned int' from 'float'
internal/dcraw_common.cpp:4346: warning: converting to 'unsigned int' from 'float'
internal/dcraw_common.cpp:4352: warning: converting to 'ushort' from 'float'
internal/dcraw_common.cpp: In member function 'void LibRaw::cielab(ushort_, short int_)':
internal/dcraw_common.cpp:4754: warning: converting to 'short int' from 'float'
internal/dcraw_common.cpp:4755: warning: converting to 'short int' from 'float'
internal/dcraw_common.cpp:4756: warning: converting to 'short int' from 'float'
internal/dcraw_common.cpp: In member function 'void LibRaw::blend_highlights()':
internal/dcraw_common.cpp:5402: warning: converting to 'int' from 'float'
internal/dcraw_common.cpp:5422: warning: converting to 'ushort' from 'float'
internal/dcraw_common.cpp: In member function 'void LibRaw::recover_highlights()':
internal/dcraw_common.cpp:5444: warning: converting to 'int' from 'float'
internal/dcraw_common.cpp:5471: warning: converting to 'int' from 'float'
internal/dcraw_common.cpp:5502: warning: converting to 'int' from 'float'
internal/dcraw_common.cpp: In member function 'void LibRaw::parse_makernote(int, int)':
internal/dcraw_common.cpp:8129: warning: converting to 'int' from 'double'
internal/dcraw_common.cpp:8130: warning: converting to 'int' from 'double'
internal/dcraw_common.cpp: In member function 'int LibRaw::parse_tiff_ifd(int)':
internal/dcraw_common.cpp:9380: warning: converting to 'unsigned int' from 'double'
internal/dcraw_common.cpp:9384: warning: converting to 'unsigned int' from 'double'
internal/dcraw_common.cpp:9389: warning: converting to 'unsigned int' from 'double'
internal/dcraw_common.cpp:9397: warning: converting to 'unsigned int' from 'double'
internal/dcraw_common.cpp: In member function 'void LibRaw::identify()':
internal/dcraw_common.cpp:12647: warning: converting to 'int' from 'float'
internal/dcraw_common.cpp:12648: warning: converting to 'int' from 'float'
internal/dcraw_common.cpp: In member function 'void LibRaw::convert_to_rgb()':
internal/dcraw_common.cpp:13402: warning: converting to 'unsigned int' from 'double'
internal/dcraw_common.cpp: In member function 'virtual void LibRaw::fuji_rotate()':
internal/dcraw_common.cpp:13462: warning: converting to 'ushort' from 'double'
internal/dcraw_common.cpp:13463: warning: converting to 'ushort' from 'double'
internal/dcraw_common.cpp:13473: warning: converting to 'unsigned int' from 'float'
internal/dcraw_common.cpp:13474: warning: converting to 'unsigned int' from 'float'
internal/dcraw_common.cpp:13482: warning: converting to 'ushort' from 'float'
internal/dcraw_common.cpp: In member function 'void LibRaw::stretch()':
internal/dcraw_common.cpp:13509: warning: converting to 'ushort' from 'double'
internal/dcraw_common.cpp:13513: warning: converting to 'int' from 'double'
internal/dcraw_common.cpp:13517: warning: converting to 'ushort' from 'double'
internal/dcraw_common.cpp:13521: warning: converting to 'ushort' from 'double'
internal/dcraw_common.cpp:13525: warning: converting to 'int' from 'double'
internal/dcraw_common.cpp:13529: warning: converting to 'ushort' from 'double'
internal/dcraw_common.cpp: In member function 'void LibRaw::tiff_head(tiff_hdr_, int)':
internal/dcraw_common.cpp:13608: warning: passing 'float' for argument 5 to 'void LibRaw::tiff_set(ushort_, ushort, ushort, int, int)'
internal/dcraw_common.cpp:13627: warning: converting to 'int' from 'float'
internal/dcraw_common.cpp:13628: warning: converting to 'int' from 'float'
internal/dcraw_common.cpp:13629: warning: converting to 'int' from 'float'
internal/dcraw_common.cpp: In member function 'void LibRaw::write_ppm_tiff()':
internal/dcraw_common.cpp:13700: warning: converting to 'int' from 'float'
internal/dcraw_common.cpp:13711: warning: passing 'float' for argument 4 to 'void LibRaw::gamma_curve(double, double, int, int)'
make: *** [internal/dcraw_common.lo] Error 1

crashes within recycle

calling dcraw_emu (LibRaw 0.14beta4) on Canon 1D MK III sample result in crash for me. Backtrace:

Program received signal SIGABRT, Aborted.
0x0012e416 in __kernel_vsyscall ()
(gdb) bt
#0 0x0012e416 in __kernel_vsyscall ()
#1 0x0036ae71 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2 0x0036e34e in abort () at abort.c:92
#3 0x003a1577 in __libc_message (do_abort=2, fmt=0x47a8ac "*** glibc detected *** %s: %s: 0x%s ***\n")

at ../sysdeps/unix/sysv/linux/libc_fatal.c:189

#4 0x003ab961 in malloc_printerr (action=, str=, ptr=0xb6bf8008)

at malloc.c:6283

#5 0x003ac10e in munmap_chunk (p=0xb6bf8000) at malloc.c:3540
#6 0x00164f90 in free (this=0xbffb8254, p=0xb6bf8008) at ./libraw/libraw_alloc.h:62
#7 LibRaw::free (this=0xbffb8254, p=0xb6bf8008) at src/libraw_cxx.cpp:232
#8 0x0016519d in LibRaw::recycle (this=0xbffb8254) at src/libraw_cxx.cpp:277
#9 0x08049f8e in main (argc=2, argv=0xbffff3a4) at samples/dcraw_emu.cpp:516

Sigma Quattro (LIBRAW_FILE_UNSUPPORTED)

With the pre-compiled binary I can successfully extract a thumb from all of my Sigma files, so they definitely work. However, in my own code I'm getting LIBRAW_FILE_UNSUPPORTED only for quattro. Earlier headers decode fine.

I've tried to step through, but Android Studio fails miserably with dcraw_common, taking 40+ seconds to step. I've confirmed that FOVb is pulled from the header. I was hoping you could point me to breakpoints I might be able to check that would lead to LIBRAW_FILE_UNSUPPORTED. Thanks!

Version 0.16.0 doesn't include the cmake build fixes

Hey,

Please release a 0.16.1, as for some reason, version 0.16.0 didn't include a179784 which means that cmake builds in upstream are broken. I just noticed this in arch (they changed to cmake for building libraw). This breaks all autotools projects using libraw, and to be honest, it should have been included in 0.16.0.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.