From 4c61b7d3c3eb8d474ab54a2221eeb1a059dcd67d Mon Sep 17 00:00:00 2001 From: Lawrence Lee <45837045+Lawrence37@users.noreply.github.com> Date: Sat, 13 Apr 2024 22:44:59 -0700 Subject: [PATCH] Squashed 'rtengine/libraw/' changes from 1ef70158d..12b0e5d60 12b0e5d60 Snapshot 202403 a4c9b1981 loop parameters in remove_trailing_spaces e231b01a4 CR3-Qstep table: avoid wrong 64-bit code generation 21368133a 0.21.2 release a6f212a4a tag type => tag size mapping fixed 41506ef73 cubic_spline: better handling of non-integer data 17294b5fd extra metadata check in arq_load_raw 47d9dd8e2 Better incorrect data handling in cubic_spline 3baa51068 skip invalid pattern in xtrans_interpolate eaf63bf5f Check HL recovery coeffs before processing a14574080 limit wavelet denoise minimum size 4e597e4e9 Merge pull request #594 from pinotree/path_max 086dcb9a6 raw-identify: use fallback if PATH_MAX not available 0e105f9f8 additional check against corrupted ljpeg layout 0c8b68e9f Disable color conversion for Canon 16-bit thumbnails cd1abd695 docs/changelog: explained the case when no thumbnail is found in specific file 6fffd414b rename swapXX to libraw_swapXX to avoid name conflict af78ae48a Check against corrupted LJPEG header in Canon sRAW decoder ba780e600 Limit embedded color profile allocation/read size 122bf7c5b Wrong alloc result check for 16-bit bitmap thumbnail e6dd2709e check pana_data/buffer offset before use ae2dc5884 Check P1 quadrant linearization coeff[15] against zero f2998bacc avoid integer overflow in buffer space check 443b7fb51 prevent buffer overrun in buffer_datastream::scanf_one 35a6d3615 ensure correct T.tlength for 16b bitmap thumbnails(2) b69ea8be5 ensure correct T.tlength for 16b bitmap thumbnails 2b6eca897 Do not run sraw decoder on (crafted) bayer files 68808b57f better striped thumbnails handling 9ab70f6dc do not set shrink flag for 3/4 component images 32425dd96 allow more decoders for fuji-rotated RAWs REVERT: 1ef70158d 0.21.2 release REVERT: 62f042366 tag type => tag size mapping fixed REVERT: ee087e3fe cubic_spline: better handling of non-integer data REVERT: af755b991 extra metadata check in arq_load_raw REVERT: 0fadd8819 Better incorrect data handling in cubic_spline REVERT: d7fb66053 skip invalid pattern in xtrans_interpolate REVERT: d059ed280 Check HL recovery coeffs before processing REVERT: 104730519 limit wavelet denoise minimum size REVERT: cae09838e raw-identify: use fallback if PATH_MAX not available REVERT: d6c677608 additional check against corrupted ljpeg layout REVERT: 1001a6ac1 Disable color conversion for Canon 16-bit thumbnails REVERT: a5130b01b docs/changelog: explained the case when no thumbnail is found in specific file REVERT: 600c0c63d rename swapXX to libraw_swapXX to avoid name conflict REVERT: 299c8a11b Check against corrupted LJPEG header in Canon sRAW decoder REVERT: ec8671ad9 Limit embedded color profile allocation/read size REVERT: 5229d5942 Wrong alloc result check for 16-bit bitmap thumbnail REVERT: b278b775f check pana_data/buffer offset before use REVERT: 7f4b8d3af Check P1 quadrant linearization coeff[15] against zero REVERT: e942a7db6 avoid integer overflow in buffer space check REVERT: f6a57cfb8 prevent buffer overrun in buffer_datastream::scanf_one REVERT: 3e62ed304 ensure correct T.tlength for 16b bitmap thumbnails(2) REVERT: 8e52d81cd ensure correct T.tlength for 16b bitmap thumbnails REVERT: 8e1af15e2 Do not run sraw decoder on (crafted) bayer files REVERT: 0ace959c2 better striped thumbnails handling REVERT: 477e0719f do not set shrink flag for 3/4 component images REVERT: c8efae6c5 allow more decoders for fuji-rotated RAWs git-subtree-dir: rtengine/libraw git-subtree-split: 12b0e5d60c57bb795382fda8494fc45f683550b8 --- COPYRIGHT | 2 +- Changelog.txt | 120 +- ...ng-sdk-1_6-1_7-hide-ccVc5-definitiion.diff | 13 + GoPro/gpr_read_image.cpp-dng16.diff | 29 + GoPro/gpr_read_image.cpp-dng17.diff | 17 + GoPro/gpr_read_image.h-dng16.diff | 12 + GoPro/gpr_read_image.h-dng17.diff | 17 + Makefile.am | 3 +- Makefile.devel | 23 +- Makefile.devel.nopp | 12 +- Makefile.devel.noppr2i | 13 +- Makefile.dist | 24 +- Makefile.mingw | 13 +- Makefile.msvc | 24 +- README.DNGSDK.txt | 10 +- README.GoPro.txt | 24 +- README.md | 18 +- RawSpeed3/README.md | 1 + .../patches/05.no-phase-one-correction.patch | 16 + buildfiles/libraw.pro | 3 +- buildfiles/libraw.vcxproj | 3 + configure.ac | 22 - doc/API-C.html | 1 + doc/API-CXX.html | 4 - doc/API-datastruct.html | 52 +- doc/Install-LibRaw.html | 3 +- doc/index.html | 2 +- internal/dcraw_defs.h | 2 +- internal/dcraw_fileio_defs.h | 2 +- internal/defines.h | 10 +- internal/dmp_include.h | 2 +- internal/libraw_cameraids.h | 16 +- internal/libraw_checked_buffer.h | 28 + internal/libraw_cxx_defs.h | 34 +- internal/libraw_internal_funcs.h | 24 +- internal/losslessjpeg.h | 292 +++++ internal/var_defines.h | 3 +- internal/x3f_tools.h | 2 +- libraw/libraw.h | 16 +- libraw/libraw_alloc.h | 2 +- libraw/libraw_const.h | 23 +- libraw/libraw_datastream.h | 19 +- libraw/libraw_internal.h | 19 +- libraw/libraw_types.h | 13 +- libraw/libraw_version.h | 6 +- samples/4channels.cpp | 4 +- samples/dcraw_emu.cpp | 2 +- samples/dcraw_half.c | 2 +- samples/half_mt.c | 2 +- samples/half_mt_win32.c | 2 +- samples/mem_image_sample.cpp | 2 +- samples/multirender_test.cpp | 2 +- samples/openbayer_sample.cpp | 2 +- samples/postprocessing_benchmark.cpp | 2 +- samples/raw-identify.cpp | 2 +- samples/rawtextdump.cpp | 2 +- samples/simple_dcraw.cpp | 2 +- samples/unprocessed_raw.cpp | 2 +- src/decoders/canon_600.cpp | 2 +- src/decoders/crx.cpp | 6 +- src/decoders/decoders_dcraw.cpp | 114 +- src/decoders/decoders_libraw_dcrdefs.cpp | 3 +- src/decoders/dng.cpp | 7 +- src/decoders/fp_dng.cpp | 2 +- src/decoders/generic.cpp | 2 +- src/decoders/kodak_decoders.cpp | 2 +- src/decoders/load_mfbacks.cpp | 2 +- src/decoders/pana8.cpp | 529 ++++++++ src/decoders/smal.cpp | 2 +- src/decoders/sonycc.cpp | 318 +++++ src/decoders/unpack.cpp | 18 +- src/decoders/unpack_thumb.cpp | 111 +- src/decompressors/losslessjpeg.cpp | 391 ++++++ src/demosaic/ahd_demosaic.cpp | 2 +- src/demosaic/misc_demosaic.cpp | 2 +- src/demosaic/xtrans_demosaic.cpp | 2 +- src/integration/dngsdk_glue.cpp | 98 +- src/integration/rawspeed_glue.cpp | 84 +- src/libraw_c_api.cpp | 2 +- src/libraw_datastream.cpp | 68 +- src/metadata/adobepano.cpp | 2 +- src/metadata/canon.cpp | 33 +- src/metadata/ciff.cpp | 2 +- src/metadata/cr3_parser.cpp | 22 +- src/metadata/epson.cpp | 2 +- src/metadata/exif_gps.cpp | 2 +- src/metadata/fuji.cpp | 553 ++++---- src/metadata/hasselblad_model.cpp | 31 +- src/metadata/identify.cpp | 586 +++++---- src/metadata/identify_tools.cpp | 2 +- src/metadata/kodak.cpp | 2 +- src/metadata/leica.cpp | 15 +- src/metadata/makernotes.cpp | 2 +- src/metadata/mediumformat.cpp | 2 +- src/metadata/minolta.cpp | 2 +- src/metadata/misc_parsers.cpp | 36 +- src/metadata/nikon.cpp | 39 +- src/metadata/normalize_model.cpp | 82 +- src/metadata/olympus.cpp | 9 +- src/metadata/p1.cpp | 2 +- src/metadata/pentax.cpp | 2 +- src/metadata/samsung.cpp | 2 +- src/metadata/sony.cpp | 269 ++-- src/metadata/tiff.cpp | 257 +++- src/postprocessing/aspect_ratio.cpp | 2 +- src/postprocessing/dcraw_process.cpp | 2 +- src/postprocessing/mem_image.cpp | 2 +- src/postprocessing/postprocessing_aux.cpp | 2 +- src/postprocessing/postprocessing_ph.cpp | 2 +- src/postprocessing/postprocessing_utils.cpp | 2 +- .../postprocessing_utils_dcrdefs.cpp | 2 +- src/preprocessing/ext_preprocess.cpp | 2 +- src/preprocessing/preprocessing_ph.cpp | 2 +- src/preprocessing/raw2image.cpp | 18 +- src/preprocessing/subtract_black.cpp | 2 +- src/tables/cameralist.cpp | 72 +- src/tables/colorconst.cpp | 2 +- src/tables/colordata.cpp | 1115 +++++++++-------- src/tables/wblists.cpp | 2 +- src/utils/curves.cpp | 4 +- src/utils/decoder_info.cpp | 35 +- src/utils/init_close_utils.cpp | 17 +- src/utils/open.cpp | 64 +- src/utils/phaseone_processing.cpp | 16 +- src/utils/read_utils.cpp | 2 +- src/utils/thumb_utils.cpp | 13 +- src/utils/utils_dcraw.cpp | 2 +- src/utils/utils_libraw.cpp | 73 +- src/write/apply_profile.cpp | 2 +- src/write/file_write.cpp | 2 +- src/write/tiff_writer.cpp | 2 +- src/write/write_ph.cpp | 2 +- src/x3f/x3f_parse_process.cpp | 38 +- 133 files changed, 4307 insertions(+), 1939 deletions(-) create mode 100644 GoPro/dng-sdk-1_6-1_7-hide-ccVc5-definitiion.diff create mode 100644 GoPro/gpr_read_image.cpp-dng16.diff create mode 100644 GoPro/gpr_read_image.cpp-dng17.diff create mode 100644 GoPro/gpr_read_image.h-dng16.diff create mode 100644 GoPro/gpr_read_image.h-dng17.diff create mode 100644 RawSpeed3/patches/05.no-phase-one-correction.patch create mode 100644 internal/libraw_checked_buffer.h create mode 100644 internal/losslessjpeg.h create mode 100644 src/decoders/pana8.cpp create mode 100644 src/decoders/sonycc.cpp create mode 100644 src/decompressors/losslessjpeg.cpp diff --git a/COPYRIGHT b/COPYRIGHT index 89e8bc528..3c6f41246 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -1,6 +1,6 @@ ** LibRaw: Raw images processing library ** -Copyright (C) 2008-2021 LibRaw LLC (http://www.libraw.org, info@libraw.org) +Copyright (C) 2008-2024 LibRaw LLC (http://www.libraw.org, info@libraw.org) LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: diff --git a/Changelog.txt b/Changelog.txt index 42c2bb2b5..50fb003b5 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,37 +1,115 @@ -2023-12-19 Alex Tutubalin +2024-03-30 Alex Tutubalin - LibRaw 0.21.2-Release + LibRaw-snapshot-202403 + + * Raw format support + 1) Panasonic encoding 8 + + 2) Sony YCC (Medium/Small compression) pseudo-RAW support: + -- normal processing (3-channel RGB output) + -- or YCbCr output if LIBRAW_RAWSPECIAL_SRAW_NO_RGB bit is set + in imgdata.rawparams.specials (one may specify the + LIBRAW_RAWSPECIAL_SRAW_NO_INTERPOLATE flag too avoid Cb/Cr interpolation) + Note: if YCbCr is selected, Cb/Cr neutral points are adjusted to 8192 + (to fit histogram/range area of the Y channel) + -- RAW (pseudo-RAW) data is already white balanced, so + imgdata.color.as_shot_wb_applied is set to + LIBRAW_ASWB_APPLIED | LIBRAW_ASWB_SONY + + 3) DNG 1.7 (including JPEG-XL compression) support via Adobe DNG SDK 1.7.x integration + + 4) Canon CRN files: embedded RAW extracted + + * Camera support + - Canon EOS R6 Mark II, EOS R8, EOS R50, EOS R100, EOS Ra + - Fujifilm GFX100-II, X-T5, X-S20, X-H2, X-H2S: support of files with wrong metadata (pre 1.03 fw) + - GoPro HERO11, HERO12 (via GoPro SDK) + - Hasselblad X2D-100c + - Leica Q3, M11 Monochrom + - Nikon Z30, Z8 (HE/HE* formats are not supported) + - OM Digital OM-5 + - Panasonic DC-G9 II, DC-ZS200D / ZS220D, DC-TZ200D / TZ202D / TZ220D, DC-S5-II, DC-GH6 + - Sony A7C-II, A7CR, ILCE-6700, ZV-1M2, ZV-E1, ILCE-7RM5 (A7R-V), ILME-FX30, + A1: support for files damaged by exiftool + - Multiple DJI and Skydio drones + - tested with multiple smartphones with DNG format recorded. + + * Sony DSC-HX95: improved metadata parsing + + * Better support for cropped images from latest Fujifilm cameras + (X-H2, X-H2S, X-T5) + + * As planned in LibRaw snapshot 202101 release notes, OLD_VIDEOCAMS + support is dropped. + These cameras are no longer supported: + - old RED Cine cameras + - Canon C500 + - ARRI video/digital cinema cameras + + * JPEG-XL previews (DNG 1.7) support: + - new bit for imgdata.rawparams.options: LIBRAW_RAWOPTIONS_ALLOW_JPEGXL_PREVIEWS (not set by default) + - if the bit is set, LibRaw will perceive such previews in the same way as JPEG ones + (largest preview is selected by default, etc). + - tformat field for such preview is set to LIBRAW_THUMBNAIL_JPEGXL + - image metadata (width/height/channels count) is not parsed for JPEG-XL previews + + * New patch for RawSpeed3: 05.no-phase-one-correction.patch + this patch disables RawSpeed's PhaseOne flat field correction (not needed because + LibRaw uses own P1-metadata based correction) + + * RawSpeed3/PhaseOne compressed files: scale unpacked data to match camer black level data. + + * New imgdata.params.use_p1_correction parameter + If set to non-zero (default): PhaseOne compressed files will be corrected (linearization; defect mapping) + based on metadata contained in file. + + * New possible bit in imgdata.process_warnings: LIBRAW_WARN_VENDOR_CROP_SUGGESTED + If set: unknown/untested RAW image frame size passed to LibRaw, cropping may be incorrect. + It is suggested to use LibRaw::adjust_to_raw_inset_crop(1) for vendor specified crop. + + * Better handling of DNG RAW Previews with Stage2 opcodes + + * Added imgdata.makernotes.sony.AspectRatio field + - if parsed: contains aspect ratio (width to height) + - if not parsed: initialized to -999.f + + * Nikon Z8/HLG mode: do not add 10 bit/unknown format thumbnails to the thumb_list + + * Canon CR2 16-bit bitmap previes: do not convert from Kodak colorspace * New compile-defined limit LIBRAW_MAX_PROFILE_SIZE_MB: limits allocation/read size for embedded color profile (default: 256Mb) * Embedded color profile allocation/read size: limited by input file size. - * Multiple fixes (mostly inspired by oss-fuzz) to improve library stability and/or input checks. - - * raw-identify: use fallback if PATH_MAX not available - - * Disabled color conversion for Canon 16-bit thumbnails - - * docs/changelog: explained the case when no thumbnail is found in specific file - - * swapXX renamed to libraw_swapXX to avoid name conflict - - * better striped thumbnails handling - + * Check against corrupted LJPEG header in Canon sRAW decoder -2023-01-05 Alex Tutubalin - LibRaw 0.21.1-Release - * fixed typo in panasonic metadata parser + * Better support for Sony metadata -2022-12-18 Alex Tutubalin - LibRaw 0.21-Release + * Better handling of memory allocation errors in unpack_thumb() - * Multiple fixes inspired by oss-fuzz project + * Support for 8bit/Monochrome DNG Previews + + * LibRaw::thumbOK(): return 0 for YCbCr thumbnails (because + unpack_thumb() will always return error: no correct thumbnails + with this format found in the image samples yet) + + * Improved Sigma X3F files model recognition + + * Placeholder for DNG/YCC preview decoding: such previews are recorded + by Samsung S21 Ultra smartfone, while all present samples contains + broken data; Right now 'no preview' returned for such files. + + * Support for BW bitmap previews in LibRaw::dcraw_thumb_writer + + * Phase One: explicitly switch to monochrome mode if firmware string + contains 'Achromatic' word + + * tiff parser: check for IFD offset before parsing it 2022-07-01 Alex Tutubalin - LibRaw 0.21-Beta1 + LibRaw 0.21 == Camera format support == * Phase One/Leaf IIQ-S v2 support diff --git a/GoPro/dng-sdk-1_6-1_7-hide-ccVc5-definitiion.diff b/GoPro/dng-sdk-1_6-1_7-hide-ccVc5-definitiion.diff new file mode 100644 index 000000000..1b356d0eb --- /dev/null +++ b/GoPro/dng-sdk-1_6-1_7-hide-ccVc5-definitiion.diff @@ -0,0 +1,13 @@ +--- a/gpr_sdk/private/gpr_read_image.cpp ++++ b/gpr_sdk/private/gpr_read_image.cpp +@@ -68,8 +68,10 @@ gpr_read_image::gpr_read_image( gpr_buffer_auto* vc5_buffer ) : _vc5_buffer(vc5_ + } + + #if GPR_WRITING || GPR_READING ++#if !defined(qDNG_1_6) && !defined(qDNGSupportJXL) + const int ccVc5 = 9; // Vc5 compression type + #endif ++#endif + + void gpr_read_image::ReadTile (dng_host &host, + const dng_ifd &ifd, diff --git a/GoPro/gpr_read_image.cpp-dng16.diff b/GoPro/gpr_read_image.cpp-dng16.diff new file mode 100644 index 000000000..1761abc01 --- /dev/null +++ b/GoPro/gpr_read_image.cpp-dng16.diff @@ -0,0 +1,29 @@ +--- gpr_read_image.cpp.orig 2019-08-30 12:20:00.326653300 +0300 ++++ gpr_read_image.cpp 2019-08-31 10:43:26.568184100 +0300 +@@ -67,6 +67,10 @@ + fDecodeVC5 = true; + } + + void gpr_read_image::ReadTile (dng_host &host, + const dng_ifd &ifd, + dng_stream &stream, +@@ -77,7 +81,8 @@ + uint32 tileByteCount, + AutoPtr &compressedBuffer, + AutoPtr &uncompressedBuffer, +- AutoPtr &subTileBlockBuffer) ++ AutoPtr &subTileBlockBuffer, ++ bool usingMultipleThreads) + { + + if( ifd.fCompression == ccVc5 ) +@@ -122,7 +127,8 @@ + tileByteCount, + compressedBuffer, + uncompressedBuffer, +- subTileBlockBuffer); ++ subTileBlockBuffer, ++ usingMultipleThreads); + } + } + diff --git a/GoPro/gpr_read_image.cpp-dng17.diff b/GoPro/gpr_read_image.cpp-dng17.diff new file mode 100644 index 000000000..86f4e67b7 --- /dev/null +++ b/GoPro/gpr_read_image.cpp-dng17.diff @@ -0,0 +1,17 @@ +diff --git a/gpr_sdk/private/gpr_read_image.cpp b/gpr_sdk/private/gpr_read_image.cpp +index c611b3f..4f8fe88 100644 +--- a/gpr_sdk/private/gpr_read_image.cpp ++++ b/gpr_sdk/private/gpr_read_image.cpp +@@ -79,7 +81,12 @@ void gpr_read_image::ReadTile (dng_host &host, + uint32 plane, + uint32 planes, + uint32 tileByteCount, ++// DNG 1.7 detection ++#ifdef qDNGSupportJXL ++ std::shared_ptr &compressedBuffer, ++#else + AutoPtr &compressedBuffer, ++#endif + AutoPtr &uncompressedBuffer, + AutoPtr &subTileBlockBuffer, + bool usingMultipleThreads) diff --git a/GoPro/gpr_read_image.h-dng16.diff b/GoPro/gpr_read_image.h-dng16.diff new file mode 100644 index 000000000..413b55a51 --- /dev/null +++ b/GoPro/gpr_read_image.h-dng16.diff @@ -0,0 +1,12 @@ +--- gpr_read_image.h.orig 2019-08-30 12:20:00.326653300 +0300 ++++ gpr_read_image.h 2019-08-30 20:56:11.138246800 +0300 +@@ -56,7 +56,8 @@ + uint32 tileByteCount, + AutoPtr &compressedBuffer, + AutoPtr &uncompressedBuffer, +- AutoPtr &subTileBlockBuffer); ++ AutoPtr &subTileBlockBuffer, ++ bool usingMultipleThreads ); + }; + + #endif // GPR_READING diff --git a/GoPro/gpr_read_image.h-dng17.diff b/GoPro/gpr_read_image.h-dng17.diff new file mode 100644 index 000000000..a18db1652 --- /dev/null +++ b/GoPro/gpr_read_image.h-dng17.diff @@ -0,0 +1,17 @@ +diff --git a/gpr_sdk/private/gpr_read_image.h b/gpr_sdk/private/gpr_read_image.h +index 159310b..f7d3ce1 100644 +--- a/gpr_sdk/private/gpr_read_image.h ++++ b/gpr_sdk/private/gpr_read_image.h +@@ -54,7 +54,12 @@ public: + uint32 plane, + uint32 planes, + uint32 tileByteCount, ++// DNG 1.7 detection ++#ifdef qDNGSupportJXL ++ std::shared_ptr &compressedBuffer, ++#else + AutoPtr &compressedBuffer, ++#endif + AutoPtr &uncompressedBuffer, + AutoPtr &subTileBlockBuffer, + bool usingMultipleThreads ); diff --git a/Makefile.am b/Makefile.am index 19166b75e..c5bd647da 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,7 +30,8 @@ lib_LTLIBRARIES = lib/libraw.la lib/libraw_r.la lib_libraw_a_CPPFLAGS = -DLIBRAW_NOTHREADS -w lib_libraw_a_SOURCES = src/libraw_c_api.cpp \ src/libraw_datastream.cpp src/decoders/canon_600.cpp \ - src/decoders/crx.cpp src/decoders/decoders_dcraw.cpp \ + src/decoders/crx.cpp src/decoders/pana8.cpp src/decoders/decoders_dcraw.cpp \ + src/decoders/sonycc.cpp src/decompressors/losslessjpeg.cpp \ src/decoders/decoders_libraw_dcrdefs.cpp \ src/decoders/decoders_libraw.cpp src/decoders/dng.cpp \ src/decoders/fp_dng.cpp src/decoders/fuji_compressed.cpp \ diff --git a/Makefile.devel b/Makefile.devel index f82c007e5..73da195e3 100644 --- a/Makefile.devel +++ b/Makefile.devel @@ -33,10 +33,6 @@ CFLAGS+= -g -I. -pedantic -Wno-long-long -Wno-overflow -O3 #CFLAGS+=-DUSE_LCMS2 -I/opt/local/include #LDADD+=-L/opt/local/lib -llcms -# Jasper support for RedCine -#CFLAGS+=-DUSE_JASPER -I/opt/local/include -#LDADD+=-L/opt/local/lib -ljasper - # ZLIB support (FP dng) CFLAGS+=-DUSE_ZLIB LDADD+=-lz @@ -58,7 +54,8 @@ HEADERS=libraw/libraw.h libraw/libraw_alloc.h libraw/libraw_const.h \ LIB_OBJECTS= object/libraw_datastream.o object/libraw_c_api.o \ object/cameralist.o object/fuji_compressed.o \ - object/crx.o object/fp_dng.o object/decoders_libraw.o \ + object/crx.o object/pana8.o object/fp_dng.o object/decoders_libraw.o \ + object/sonycc.o object/losslessjpeg.o \ object/unpack.o object/unpack_thumb.o \ object/rawspeed_glue.o object/dngsdk_glue.o \ object/colorconst.o object/utils_libraw.o object/init_close_utils.o \ @@ -91,7 +88,9 @@ LIB_OBJECTS= object/libraw_datastream.o object/libraw_c_api.o \ LIB_MT_OBJECTS= object/libraw_datastream.mt.o object/libraw_c_api.mt.o \ object/cameralist.mt.o object/fuji_compressed.mt.o \ - object/crx.mt.o object/fp_dng.mt.o object/decoders_libraw.mt.o \ + object/crx.mt.o object/pana8.mt.o object/fp_dng.mt.o \ + object/sonycc.mt.o object/losslessjpeg.mt.o \ + object/decoders_libraw.mt.o \ object/unpack.mt.o object/unpack_thumb.mt.o \ object/rawspeed_glue.mt.o object/dngsdk_glue.mt.o \ object/colorconst.mt.o object/utils_libraw.mt.o \ @@ -210,6 +209,18 @@ object/crx.o: src/decoders/crx.cpp ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/crx.o src/decoders/crx.cpp object/crx.mt.o: src/decoders/crx.cpp $(HEADERS) ${CXX} -c ${CFLAGS} -o object/crx.mt.o src/decoders/crx.cpp +object/pana8.o: src/decoders/pana8.cpp + ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/pana8.o src/decoders/pana8.cpp +object/pana8.mt.o: src/decoders/pana8.cpp $(HEADERS) + ${CXX} -c ${CFLAGS} -o object/pana8.mt.o src/decoders/pana8.cpp +object/sonycc.o: src/decoders/sonycc.cpp + ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/sonycc.o src/decoders/sonycc.cpp +object/sonycc.mt.o: src/decoders/sonycc.cpp $(HEADERS) + ${CXX} -c ${CFLAGS} -o object/sonycc.mt.o src/decoders/sonycc.cpp +object/losslessjpeg.o: src/decompressors/losslessjpeg.cpp + ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/losslessjpeg.o src/decompressors/losslessjpeg.cpp +object/losslessjpeg.mt.o: src/decompressors/losslessjpeg.cpp $(HEADERS) + ${CXX} -c ${CFLAGS} -o object/losslessjpeg.mt.o src/decompressors/losslessjpeg.cpp object/decoders_dcraw.o: src/decoders/decoders_dcraw.cpp ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/decoders_dcraw.o src/decoders/decoders_dcraw.cpp object/decoders_dcraw.mt.o: src/decoders/decoders_dcraw.cpp $(HEADERS) diff --git a/Makefile.devel.nopp b/Makefile.devel.nopp index 6ece7e9e8..e84d1e9d4 100644 --- a/Makefile.devel.nopp +++ b/Makefile.devel.nopp @@ -25,9 +25,6 @@ CFLAGS+= -g -I. -pedantic -Wno-long-long -Wno-overflow -O3 #CFLAGS+=-DUSE_LCMS2 -I/opt/local/include #LDADD+=-L/opt/local/lib -llcms -# Jasper support for RedCine -#CFLAGS+=-DUSE_JASPER -I/opt/local/include -#LDADD+=-L/opt/local/lib -ljasper # JPEG support for DNG and Kodak CFLAGS+=-DUSE_JPEG -I/usr/local/include @@ -40,7 +37,8 @@ CSTFLAGS=$(CFLAGS) -DLIBRAW_NOTHREADS LIB_OBJECTS= object/libraw_datastream.o \ object/cameralist.o object/fuji_compressed.o \ - object/crx.o object/fp_dng.o object/decoders_libraw.o \ + object/crx.o object/pana8.o object/fp_dng.o object/decoders_libraw.o \ + object/sonycc.o object/losslessjpeg.o \ object/unpack.o object/unpack_thumb.o \ object/rawspeed_glue.o object/dngsdk_glue.o \ object/colorconst.o object/utils_libraw.o object/init_close_utils.o \ @@ -108,6 +106,12 @@ object/canon_600.o: src/decoders/canon_600.cpp ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/canon_600.o src/decoders/canon_600.cpp object/crx.o: src/decoders/crx.cpp ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/crx.o src/decoders/crx.cpp +object/pana8.o: src/decoders/pana8.cpp + ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/pana8.o src/decoders/pana8.cpp +object/sonycc.o: src/decoders/sonycc.cpp + ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/sonycc.o src/decoders/sonycc.cpp +object/losslessjpeg.o: src/decompressors/losslessjpeg.cpp + ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/losslessjpeg.o src/decompressors/losslessjpeg.cpp object/decoders_dcraw.o: src/decoders/decoders_dcraw.cpp ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/decoders_dcraw.o src/decoders/decoders_dcraw.cpp object/decoders_libraw_dcrdefs.o: src/decoders/decoders_libraw_dcrdefs.cpp diff --git a/Makefile.devel.noppr2i b/Makefile.devel.noppr2i index 69372877f..7fb9bc71d 100644 --- a/Makefile.devel.noppr2i +++ b/Makefile.devel.noppr2i @@ -25,10 +25,6 @@ CFLAGS+= -g -I. -pedantic -Wno-long-long -Wno-overflow -O3 #CFLAGS+=-DUSE_LCMS2 -I/opt/local/include #LDADD+=-L/opt/local/lib -llcms -# Jasper support for RedCine -#CFLAGS+=-DUSE_JASPER -I/opt/local/include -#LDADD+=-L/opt/local/lib -ljasper - # JPEG support for DNG and Kodak CFLAGS+=-DUSE_JPEG -I/usr/local/include LDADD+=-L/usr/local/lib -ljpeg @@ -40,7 +36,8 @@ CSTFLAGS=$(CFLAGS) -DLIBRAW_NOTHREADS LIB_OBJECTS= object/libraw_datastream.o \ object/cameralist.o object/fuji_compressed.o \ - object/crx.o object/fp_dng.o object/decoders_libraw.o \ + object/crx.o object/pana8.o object/fp_dng.o object/decoders_libraw.o \ + object/sonycc.o object/losslessjpeg.o \ object/unpack.o object/unpack_thumb.o \ object/rawspeed_glue.o object/dngsdk_glue.o \ object/colorconst.o object/utils_libraw.o object/init_close_utils.o \ @@ -100,6 +97,12 @@ object/canon_600.o: src/decoders/canon_600.cpp ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/canon_600.o src/decoders/canon_600.cpp object/crx.o: src/decoders/crx.cpp ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/crx.o src/decoders/crx.cpp +object/pana8.o: src/decoders/pana8.cpp + ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/pana8.o src/decoders/pana8.cpp +object/sonycc.o: src/decoders/sonycc.cpp + ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/sonycc.o src/decoders/sonycc.cpp +object/losslessjpeg.o: src/decompressors/losslessjpeg.cpp + ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/losslessjpeg.o src/decompressors/losslessjpeg.cpp object/decoders_dcraw.o: src/decoders/decoders_dcraw.cpp ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/decoders_dcraw.o src/decoders/decoders_dcraw.cpp object/decoders_libraw_dcrdefs.o: src/decoders/decoders_libraw_dcrdefs.cpp diff --git a/Makefile.dist b/Makefile.dist index 9c3e3f1c1..4fd4ba989 100644 --- a/Makefile.dist +++ b/Makefile.dist @@ -21,10 +21,6 @@ CXX=g++ # CFLAGS+=-DUSE_DNGSDK -I../dng_sdk/source # LDADDD+=-L../dng_sdk/release -ldng -lXMPCore -ljpeg -lz -# Jasper support for RedCine -#CFLAGS+=-DUSE_JASPER -I/usr/local/include -#LDADD+=-L/usr/local/lib -ljasper - # ZLIB support (FP dng) CFLAGS+=-DUSE_ZLIB LDADD+=-lz @@ -47,7 +43,8 @@ CSTFLAGS=$(CFLAGS) -DLIBRAW_NOTHREADS LIB_OBJECTS= object/libraw_datastream.o object/libraw_c_api.o \ object/cameralist.o object/fuji_compressed.o \ - object/crx.o object/fp_dng.o object/decoders_libraw.o \ + object/crx.o object/pana8.o object/fp_dng.o object/decoders_libraw.o \ + object/sonycc.o object/losslessjpeg.o \ object/unpack.o object/unpack_thumb.o \ object/rawspeed_glue.o object/dngsdk_glue.o \ object/colorconst.o object/utils_libraw.o object/init_close_utils.o \ @@ -80,7 +77,8 @@ LIB_OBJECTS= object/libraw_datastream.o object/libraw_c_api.o \ LIB_MT_OBJECTS= object/libraw_datastream.mt.o object/libraw_c_api.mt.o \ object/cameralist.mt.o object/fuji_compressed.mt.o \ - object/crx.mt.o object/fp_dng.mt.o object/decoders_libraw.mt.o \ + object/crx.mt.o object/pana8.mt.o object/fp_dng.mt.o object/decoders_libraw.mt.o \ + object/sonycc.mt.o object/losslessjpeg.mt.o \ object/unpack.mt.o object/unpack_thumb.mt.o \ object/rawspeed_glue.mt.o object/dngsdk_glue.mt.o \ object/colorconst.mt.o object/utils_libraw.mt.o \ @@ -105,7 +103,7 @@ LIB_MT_OBJECTS= object/libraw_datastream.mt.o object/libraw_c_api.mt.o \ object/tiff.mt.o object/ciff.mt.o object/mediumformat.mt.o \ object/minolta.mt.o \ object/identify_tools.mt.o \ - object/hasselblad_model.o object/normalize_model.mt.o object/identify.mt.o \ + object/hasselblad_model.mt.o object/normalize_model.mt.o object/identify.mt.o \ object/misc_parsers.mt.o object/wblists.mt.o \ object/postprocessing_aux.mt.o object/postprocessing_utils_dcrdefs.mt.o \ object/aspect_ratio.mt.o \ @@ -215,6 +213,18 @@ object/crx.o: src/decoders/crx.cpp ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/crx.o src/decoders/crx.cpp object/crx.mt.o: src/decoders/crx.cpp ${CXX} -c ${CFLAGS} -o object/crx.mt.o src/decoders/crx.cpp +object/pana8.o: src/decoders/pana8.cpp + ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/pana8.o src/decoders/pana8.cpp +object/pana8.mt.o: src/decoders/pana8.cpp $(HEADERS) + ${CXX} -c ${CFLAGS} -o object/pana8.mt.o src/decoders/pana8.cpp +object/sonycc.o: src/decoders/sonycc.cpp + ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/sonycc.o src/decoders/sonycc.cpp +object/sonycc.mt.o: src/decoders/sonycc.cpp $(HEADERS) + ${CXX} -c ${CFLAGS} -o object/sonycc.mt.o src/decoders/sonycc.cpp +object/losslessjpeg.o: src/decompressors/losslessjpeg.cpp + ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/losslessjpeg.o src/decompressors/losslessjpeg.cpp +object/losslessjpeg.mt.o: src/decompressors/losslessjpeg.cpp $(HEADERS) + ${CXX} -c ${CFLAGS} -o object/losslessjpeg.mt.o src/decompressors/losslessjpeg.cpp object/decoders_dcraw.o: src/decoders/decoders_dcraw.cpp ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/decoders_dcraw.o src/decoders/decoders_dcraw.cpp object/decoders_dcraw.mt.o: src/decoders/decoders_dcraw.cpp diff --git a/Makefile.mingw b/Makefile.mingw index f2c291e21..e9172e10f 100644 --- a/Makefile.mingw +++ b/Makefile.mingw @@ -16,10 +16,6 @@ CXX=g++ # CFLAGS+=-DUSE_DNGSDK -I../dng_sdk/source # LDADDD+=-L../dng_sdk/release -ldng -lXMPCore -ljpeg -lz -# Jasper support for RedCine -#CFLAGS+=-DUSE_JASPER -I/usr/local/include -#LDADD+=-L/usr/local/lib -ljasper - # JPEG support for lossy DNG #CFLAGS+=-DUSE_JPEG -I/usr/local/include #LDADD+=-L/usr/local/lib -ljpeg @@ -38,7 +34,8 @@ CSTFLAGS=$(CFLAGS) -DLIBRAW_NOTHREADS LIB_OBJECTS= object/libraw_datastream.o object/libraw_c_api.o \ object/cameralist.o object/fuji_compressed.o \ - object/crx.o object/fp_dng.o object/decoders_libraw.o \ + object/crx.o object/pana8.o object/fp_dng.o object/decoders_libraw.o \ + object/losslessjpeg.o object/sonycc.o \ object/unpack.o object/unpack_thumb.o \ object/rawspeed_glue.o object/dngsdk_glue.o \ object/colorconst.o object/utils_libraw.o object/init_close_utils.o \ @@ -153,6 +150,12 @@ object/canon_600.o: src/decoders/canon_600.cpp ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/canon_600.o src/decoders/canon_600.cpp object/crx.o: src/decoders/crx.cpp ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/crx.o src/decoders/crx.cpp +object/pana8.o: src/decoders/pana8.cpp + ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/pana8.o src/decoders/pana8.cpp +object/sonycc.o: src/decoders/sonycc.cpp + ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/sonycc.o src/decoders/sonycc.cpp +object/losslessjpeg.o: src/decompressors/losslessjpeg.cpp + ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/losslessjpeg.o src/decompressors/losslessjpeg.cpp object/decoders_dcraw.o: src/decoders/decoders_dcraw.cpp ${CXX} -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/decoders_dcraw.o src/decoders/decoders_dcraw.cpp object/decoders_libraw_dcrdefs.o: src/decoders/decoders_libraw_dcrdefs.cpp diff --git a/Makefile.msvc b/Makefile.msvc index c06b35f05..80bfcad05 100644 --- a/Makefile.msvc +++ b/Makefile.msvc @@ -41,7 +41,8 @@ $(LIBDLL): $(DLL) LIB_OBJECTS= object\libraw_datastream_st.obj object\libraw_c_api_st.obj \ object\cameralist_st.obj object\fuji_compressed_st.obj \ - object\crx_st.obj object\fp_dng_st.obj object\decoders_libraw_st.obj \ + object\crx_st.obj object\pana8_st.obj object\fp_dng_st.obj object\decoders_libraw_st.obj \ + object\sonycc_st.obj object\losslessjpeg_st.obj \ object\unpack_st.obj object\unpack_thumb_st.obj \ object\rawspeed_glue_st.obj object\dngsdk_glue_st.obj \ object\colorconst_st.obj object\utils_libraw_st.obj object\init_close_utils_st.obj \ @@ -74,7 +75,8 @@ LIB_OBJECTS= object\libraw_datastream_st.obj object\libraw_c_api_st.obj \ DLL_OBJECTS= object\libraw_datastream.obj object\libraw_c_api.obj \ object\cameralist.obj object\fuji_compressed.obj \ - object\crx.obj object\fp_dng.obj object\decoders_libraw.obj \ + object\crx.obj object\pana8.obj object\fp_dng.obj object\decoders_libraw.obj \ + object\sonycc.obj object\losslessjpeg.obj \ object\unpack.obj object\unpack_thumb.obj \ object\rawspeed_glue.obj object\dngsdk_glue.obj \ object\colorconst.obj object\utils_libraw.obj \ @@ -188,6 +190,24 @@ object\crx_st.obj: src\decoders\crx.cpp object\crx.obj: src\decoders\crx.cpp $(CC) $(COPT) /DLIBRAW_BUILDLIB /Fo"object\\crx.obj" /c src\decoders\crx.cpp +object\pana8_st.obj: src\decoders\pana8.cpp + $(CC) $(COPT) /DLIBRAW_NODLL /DLIBRAW_BUILDLIB /Fo"object\\pana8_st.obj" /c src\decoders\pana8.cpp + +object\pana8.obj: src\decoders\pana8.cpp + $(CC) $(COPT) /DLIBRAW_BUILDLIB /Fo"object\\pana8.obj" /c src\decoders\pana8.cpp + +object\sonycc_st.obj: src\decoders\sonycc.cpp + $(CC) $(COPT) /DLIBRAW_NODLL /DLIBRAW_BUILDLIB /Fo"object\\sonycc_st.obj" /c src\decoders\sonycc.cpp + +object\sonycc.obj: src\decoders\sonycc.cpp + $(CC) $(COPT) /DLIBRAW_BUILDLIB /Fo"object\\sonycc.obj" /c src\decoders\sonycc.cpp + +object\losslessjpeg_st.obj: src\decompressors\losslessjpeg.cpp + $(CC) $(COPT) /DLIBRAW_NODLL /DLIBRAW_BUILDLIB /Fo"object\\losslessjpeg_st.obj" /c src\decompressors\losslessjpeg.cpp + +object\losslessjpeg.obj: src\decompressors\losslessjpeg.cpp + $(CC) $(COPT) /DLIBRAW_BUILDLIB /Fo"object\\losslessjpeg.obj" /c src\decompressors\losslessjpeg.cpp + object\decoders_dcraw_st.obj: src\decoders\decoders_dcraw.cpp $(CC) $(COPT) /DLIBRAW_NODLL /DLIBRAW_BUILDLIB /Fo"object\\decoders_dcraw_st.obj" /c src\decoders\decoders_dcraw.cpp diff --git a/README.DNGSDK.txt b/README.DNGSDK.txt index 1eeabcac9..00f6ce497 100644 --- a/README.DNGSDK.txt +++ b/README.DNGSDK.txt @@ -15,8 +15,14 @@ To build LibRaw with DNG SDK specify USE_DNGSDK in defines and adjust include/linker path settings to point to DNG SDK's include and library folders. DNG SDK Version compatibility: - - Since LibRaw 0.20, DNG SDK 1.4 is required (DNG SDK 1.5 may work too, but - have not tested w/ LibRaw). + + - DNG SDK 1.6 and 1.7 are tested with LibRaw newer then 0.21 + If you want to use LibRaw with Modern DNG files please use: + -- DNG SDK 1.7 for JpegXL compressed files + -- DNG SDK 1.6+ to access Enhanced DNG frames + + - DNG SDK 1.5 may work too, but have not tested w/ LibRaw. + - Since LibRaw 0.20, DNG SDK 1.4 or newer is required - There are several DNG SDK 1.4 versions circulated, the oldest known is dated May 2012, you'll need the last one (dated June 2015). - This version is available from Adobe site: diff --git a/README.GoPro.txt b/README.GoPro.txt index 77ae15aed..5ce7c67c2 100644 --- a/README.GoPro.txt +++ b/README.GoPro.txt @@ -19,7 +19,7 @@ I. GPR SDK comes with (patched) Adobe DNG SDK source (v1.4 but outdated). II. So, you need to patch latest Adobe DNG SDK v1.4 (dated 2015), this version is available from Adobe: http://download.adobe.com/pub/adobe/dng/dng_sdk_1_4.zip - or use Adobe DNG SDK v1.6 + or use Adobe DNG SDK v1.6 or v1.7 (most likely, this apply for v1.5 too, but not tested/checked): @@ -29,17 +29,27 @@ II. So, you need to patch latest Adobe DNG SDK v1.4 (dated 2015), this version (it may not apply to any Adobe DNG SDK version, if so apply it by hands). This compression type is already handled (passed via validation) - in Adobe DNG SDK v1.6 + in Adobe DNG SDK v1.6/1.7 - b) Adobe DNG SDK v1.6 defines the ccVc5 constant in dng_tag_values.h + b) Adobe DNG SDK v1.6/1.7 defines the ccVc5 constant in dng_tag_values.h so GPR SDK's gpr_read_image.cpp will not compile due to constant redefinition - so use provided patch: LibRaw/GoPro/dng-sdk-1_6-hide-ccVc5-definitiion.diff + so use provided patch: + + For Adobe DNG SDK 1.6 (only): LibRaw/GoPro/dng-sdk-1_6-hide-ccVc5-definitiion.diff + For Adobe DNG SDK 1.6 or 1.7: LibRaw/GoPro/dng-sdk-1_6-1_7-hide-ccVc5-definitiion.diff + to use Adobe's definitiion c) Newer (than supplied w/ GPR SDK) Adobe SDK versions changes dng_read_image::ReadTile interface, please apply patches - LibRaw/GoPro/gpr_read_image.cpp.diff - and LibRaw/GoPro/gpr_read_image.h.diff to your GPR SDK code + * For all versions of Adobe DNG SDK: + + LibRaw/GoPro/gpr_read_image.cpp-dng16.diff + and LibRaw/GoPro/gpr_read_image.h-dng16.diff to your GPR SDK code + + * For Adone DNG SDK 1.7 (in addition to two -dng16.diff patches listed in previous section): + LibRaw/GoPro/gpr_read_image.h-dng16.diff + LibRaw/GoPro/gpr_read_image.h-dng17.diff d) GPR SDK's gpr_sdk/private/gpr.cpp uses own (added) dng_host method GetGPMFPayload so it will not compile with Adobes (not patched) @@ -50,6 +60,8 @@ II. So, you need to patch latest Adobe DNG SDK v1.4 (dated 2015), this version - or provide GPR's dng_host.h while building GPR SDK. (in our software we use 1st method). + + See Note VII below for detailed GPR SDK build instructions w/ Cmake III. LibRaw uses private gpr_read_image() interface diff --git a/README.md b/README.md index d7cedbe57..8f00255f7 100644 --- a/README.md +++ b/README.md @@ -16,13 +16,13 @@ The library is intended for use with programs that work with RAW files, such as: 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: +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)._ +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 @@ -35,7 +35,7 @@ The LibRaw library is distributed free of charge and with open-source code subje 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. +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. @@ -47,7 +47,7 @@ We do not guarantee that the licensing will not change in future versions of Lib * Major releases _(for example, 0.20)_ are published once every year and a half to two 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. +* 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](https://github.com/LibRaw/LibRaw). * 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). @@ -55,7 +55,7 @@ We do not guarantee that the licensing will not change in future versions of Lib * Public snapshots are published every 7-9 months in the [public GitHub repository](https://github.com/LibRaw/LibRaw). * 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 +* 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 @@ -85,15 +85,15 @@ The code that implements rendering of RAW to RGB is inherited from dcraw.c, with 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-….](https://github.com/LibRaw?tab=repositories), where they remain in their original form (but these projects are still present in our GitHub). +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-�.](https://github.com/LibRaw?tab=repositories), 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-2021 LibRaw LLC +Copyright (C) 2008-2024 LibRaw LLC -LibRaw uses code from Dave Coffin’s dcraw.c utility (without RESTRICTED/GPL2 code): +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 @@ -101,6 +101,6 @@ LibRaw uses DCB demosaic code by Jaceck Gozdz distributed under BSD license: Copyright (C) 2010, Jacek Gozdz (mailto:cuniek@kft.umcs.lublin.pl) -LibRaw uses Roland Karlsson’s X3F tools source code, licensed under BSD license: +LibRaw uses Roland Karlsson�s X3F tools source code, licensed under BSD license: Copyright (c) 2010, Roland Karlsson (roland@proxel.se) \ No newline at end of file diff --git a/RawSpeed3/README.md b/RawSpeed3/README.md index 6dd21146c..9b4b80ca5 100644 --- a/RawSpeed3/README.md +++ b/RawSpeed3/README.md @@ -19,6 +19,7 @@ They are extremely reluctant to accept 3rd-party patches to this library, theref * **02.Makernotes-processing.patch** - fixes an error in processing the Makernotes tag. * **03.remove-limits-and-logging.patch** - removes debug printing and file size limits. This patch is optional, but if you are going to decode files from cameras that were not available at the time a particular version of RawSpeed was created, then this patch can be useful. * **04.clang-cl-compatibility.patch -** fixes for compatibility with Microsoft C++ library. + * **05.no-phase-one-correction.patch -** disables RawSpeed's PhaseOne flat field correction because LibRaw implements own ## Building the RawSpeed-v3 library diff --git a/RawSpeed3/patches/05.no-phase-one-correction.patch b/RawSpeed3/patches/05.no-phase-one-correction.patch new file mode 100644 index 000000000..28fdd3bed --- /dev/null +++ b/RawSpeed3/patches/05.no-phase-one-correction.patch @@ -0,0 +1,16 @@ +diff --git a/src/librawspeed/decoders/IiqDecoder.cpp b/src/librawspeed/decoders/IiqDecoder.cpp +index 61b04e1a..b6113679 100644 +--- a/src/librawspeed/decoders/IiqDecoder.cpp ++++ b/src/librawspeed/decoders/IiqDecoder.cpp +@@ -212,9 +212,10 @@ RawImage IiqDecoder::decodeRawInternal() { + PhaseOneDecompressor p(mRaw, std::move(strips)); + mRaw->createData(); + p.decompress(); +- ++#if 0 + if (correction_meta_data.getSize() != 0 && iiq) + CorrectPhaseOneC(correction_meta_data, split_row, split_col); ++#endif + + for (int i = 0; i < 3; i++) + mRaw->metadata.wbCoeffs[i] = wb.getFloat(); diff --git a/buildfiles/libraw.pro b/buildfiles/libraw.pro index 1a5c56cee..786123f13 100644 --- a/buildfiles/libraw.pro +++ b/buildfiles/libraw.pro @@ -28,7 +28,8 @@ DEFINES+=LIBRAW_BUILDLIB SOURCES+= ../src/libraw_datastream.cpp ../src/decoders/canon_600.cpp \ ../src/decoders/crx.cpp ../src/decoders/decoders_dcraw.cpp \ - ../src/decoders/decoders_libraw_dcrdefs.cpp \ + ../src/decoders/decoders_libraw_dcrdefs.cpp ../src/decoders/pana8.cpp \ + ../src/decompressors/losslessjpeg.cpp ../src/decoders/sonycc.cpp \ ../src/decoders/decoders_libraw.cpp ../src/decoders/dng.cpp \ ../src/decoders/fp_dng.cpp ../src/decoders/fuji_compressed.cpp \ ../src/decoders/generic.cpp ../src/decoders/kodak_decoders.cpp \ diff --git a/buildfiles/libraw.vcxproj b/buildfiles/libraw.vcxproj index 574f710bc..9d3277818 100644 --- a/buildfiles/libraw.vcxproj +++ b/buildfiles/libraw.vcxproj @@ -149,6 +149,9 @@ + + + diff --git a/configure.ac b/configure.ac index 7bf5fdfd7..092182727 100644 --- a/configure.ac +++ b/configure.ac @@ -64,28 +64,6 @@ if test x$jpeg = xtrue; then ) fi -# check for Jasper (JPEG2000) support -AC_ARG_ENABLE([jasper], - [ --enable-jasper Enable Jasper (JPEG2000) support for RedCine files], - [case "${enableval}" in - yes) jasper=true ;; - no) jasper=false ;; - *) AC_MSG_ERROR([bad value ${enableval} for --enable-jasper]) ;; - esac],[jasper=true]) - -if test x$jasper = xtrue; then - AC_CHECK_LIB([jasper], [jas_init], - [ - AC_CHECK_HEADERS([jasper/jasper.h], [ - CPPFLAGS="$CPPFLAGS -DUSE_JASPER" - LIBS="$LIBS -ljasper" - AC_SUBST([PACKAGE_LIBS_PRIVATE],"-ljasper $PACKAGE_LIBS_PRIVATE") - ], AC_MSG_WARN([no jasper headers found])) - ], - AC_MSG_WARN([libjasper not found]) - ) -fi - # check if we want zlib support AC_ARG_ENABLE([zlib], [ --enable-zlib Enable zlib support for deflate compressed DNG files], diff --git a/doc/API-C.html b/doc/API-C.html index 952e54d9b..0421bed08 100644 --- a/doc/API-C.html +++ b/doc/API-C.html @@ -95,6 +95,7 @@
  • void libraw_set_bright(libraw_data_t *lr,float value);
  • void libraw_set_highlight(libraw_data_t *lr,int value);
  • void libraw_set_fbdd_noiserd(libraw_data_t *lr,int value);
  • +
  • int libraw_adjust_to_raw_inset_crop(libraw_data_t *lr, unsigned mask, float maxcrop);
  • Auxiliary Functions

    diff --git a/doc/API-CXX.html b/doc/API-CXX.html index b58ecbd3d..cf78531b2 100644 --- a/doc/API-CXX.html +++ b/doc/API-CXX.html @@ -751,10 +751,6 @@ This object is used by libjpeg for JPEG data reading from datastream.

    Returns -1 on error and 0 on success.

    -
    virtual void * make_jas_stream();
    -
    Creates LibJasper input stream (for JPEG2000 decoding). -

    returns NULL on error or data pointer on success.

    -

    Other methods
    diff --git a/doc/API-datastruct.html b/doc/API-datastruct.html index 5c2ddb3bf..1907b36b5 100644 --- a/doc/API-datastruct.html +++ b/doc/API-datastruct.html @@ -127,7 +127,8 @@ when raw2image() or dcraw_process() is called.
    libraw_output_params_t params;
    Data structure intended for management of image postprocessing (using - the dcraw emulator). Fields of this structure are described in detail below .
    libraw_callbacks_t callbacks;
    user-settable callbacks
    @@ -427,12 +428,12 @@ -

    - Note: even if no thumbnails were found in TIFF/CR3 structure, the - thumbcount field will be initialized to 1 and thumblist[0] will be - initialized to thumbnail data from the thumbnail data, so - LibRaw::unpack_thumb_ex(0) will do the same as LibRaw::unpack_thumb(). -

    +

    + Note: even if no thumbnails were found in TIFF/CR3 structure, the + thumbcount field will be initialized to 1 and thumblist[0] will be + initialized to thumbnail data from the thumbnail data, so + LibRaw::unpack_thumb_ex(0) will do the same as LibRaw::unpack_thumb(). +

    Structure libraw_lensinfo_t: parsed lens data

    The following parameters are extracted from Makernotes and EXIF, to help @@ -794,15 +795,19 @@ interpolation callback call.

    int no_interpolation;
    Disables call to demosaic code in LibRaw::dcraw_process()
    +
    int use_p1_correction;
    +
    If set to non-zero (default): PhaseOne compressed files will be corrected (linearization; defect mapping) + based on metadata contained in file.

    Structure libraw_callbacks_t: user-settable callbacks

    data_callback data_cb
    -
    Called on data error, settable via set_dataerror_handler. See C++ +
    Called on data error, settable via set_dataerror_handler. See C++ API for details.
    progress_callback progress_cb
    -
    Called on process callback, settable via set_progress_handler. See Called on process callback, settable via set_progress_handler. See C++ API for details.
    exif_parser_callback exif_cb, params: (void *context, int tag, int type, int len, unsigned int ord, void *ifp)
    @@ -978,7 +983,8 @@
    LIBRAW_BAD_CROP
    The incorrect cropping coordinates are set via params.cropbox[]: the left-top corner of cropping rectangle is outside the image. The - processing will be cancelled, all allocated resources will be freed, LIBRAW_TOO_BIG
    Raw data size exceeds data limit.
    @@ -1000,10 +1006,12 @@ file (only for formats supporting storage of several images in a file).
    LIBRAW_OUT_OF_ORDER_CALL
    -
    API functions have been called in wrong order (e.g.,
    API functions have been called in wrong order (e.g., unpack() before open_file() ) or the previous stage has ended with an error - (e.g., unpack() is called after unpack() is called after open_file() has returned an error).
    LIBRAW_NO_THUMBNAIL
    @@ -1145,7 +1153,7 @@ triplet.
    LIBRAW_THUMBNAIL_BITMAP16
    The thumbnail buffer contains the gamma-adjusted 16-bit RGB bitmap. To - get this format instead of LIBRAW_THUMBNAIL_BITMAP you + get this format instead of LIBRAW_THUMBNAIL_BITMAP you need to set LIBRAW_PROCESSING_USE_PPM16_THUMBS in processing options.
    LIBRAW_THUMBNAIL_LAYER
    @@ -1157,7 +1165,10 @@
    LIBRAW_THUMBNAIL_H265
    The thumbnail buffer contains a H.265 data frame (read from RAW file as is, no manipulations performed on it).
    -
    +
    LIBRAW_THUMBNAIL_JPEGXL
    +
    The thumbnail buffer contains a JPEG-XL data frame (read from RAW file + as is, no manipulations performed on it).
    +

    Nonstandard Situations (Warnings) during RAW Data Processing

    Some suspicious situations emerging during image processing are not fatal @@ -1210,6 +1221,10 @@

    DNG Stage2 conversion was performed
    LIBRAW_DNG_STAGE3_APPLIED
    DNG Stage3 conversion was performed
    +
    LIBRAW_WARN_VENDOR_CROP_SUGGESTED
    +
    If set: unknown/untested RAW image frame size passed to LibRaw, cropping may be incorrect. +

    It is suggested to use LibRaw::adjust_to_raw_inset_crop(1) for vendor specified crop. +
    @@ -1301,9 +1316,14 @@ plus data size is beyond filecontents. This flag enforces size+offset checks for files from known vendors (this will result into correct but smaller thumbnail selected). -
  • LIBRAW_RAWOPTIONS_CHECK_THUMBNAILS_ALL_VENDORS - same +
  • LIBRAW_RAWOPTIONS_CHECK_THUMBNAILS_ALL_VENDORS - same is above, but check is performed regardless of vendor (Make tag).
  • - +
  • LIBRAW_RAWOPTIONS_ALLOW_JPEGXL_PREVIEWS - + if set, LibRaw will perceive such previews in the same way as JPEG onesgest preview is + selected by default, etc).

    + tformat field for such preview is set to LIBRAW_THUMBNAIL_JPEGXL. Image metadata (width/height/channels count) is not parsed for JPEG-XL previews +

  • +

    diff --git a/doc/Install-LibRaw.html b/doc/Install-LibRaw.html index a65e812be..3fb1aea0e 100644 --- a/doc/Install-LibRaw.html +++ b/doc/Install-LibRaw.html @@ -16,7 +16,6 @@

    Additional libraries (optional):

    • zlib (used to decode deflated DNGs)
    • -
    • libjasper (used to decode RED files)
    • libjpeg8 (used to decode lossy DNGs and several old Kodak cameras)

    LibRaw has been tested on 32- and 64-bit Unix systems working on x86- @@ -92,7 +91,7 @@ make nmake -f Makefile.msvc
    -

    You may need to edit Makefile.msvc to provide libjpeg/zlib/libjasper +

    You may need to edit Makefile.msvc to provide libjpeg/zlib paths to INCLUDE/LIB.

    If all paths are set correctly and the include-files/libraries have been found, then the following will be compiled:

    diff --git a/doc/index.html b/doc/index.html index f58e89c03..3401fe62b 100644 --- a/doc/index.html +++ b/doc/index.html @@ -22,7 +22,7 @@

    Copyright

    -

    LibRaw library, Copyright (C) 2008-2021 LibRaw LLC (info@libraw.org)
    +

    LibRaw library, Copyright (C) 2008-2024 LibRaw LLC (info@libraw.org)
    The library includes source code from
    dcraw.c, Dave Coffin's raw photo decoder
    Copyright 1997-2016 by Dave Coffin, dcoffin a cybercom o net
    diff --git a/internal/dcraw_defs.h b/internal/dcraw_defs.h index 574f3a8bd..b53752511 100644 --- a/internal/dcraw_defs.h +++ b/internal/dcraw_defs.h @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify diff --git a/internal/dcraw_fileio_defs.h b/internal/dcraw_fileio_defs.h index 3d12edca5..68bd8581f 100644 --- a/internal/dcraw_fileio_defs.h +++ b/internal/dcraw_fileio_defs.h @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify diff --git a/internal/defines.h b/internal/defines.h index 674ad671b..a24666a8d 100644 --- a/internal/defines.h +++ b/internal/defines.h @@ -1,5 +1,5 @@ /* - Copyright 2008-2021 LibRaw LLC (info@libraw.org) + Copyright 2008-2024 LibRaw LLC (info@libraw.org) LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: @@ -23,9 +23,7 @@ it under the terms of the one of two licenses as you choose: #ifndef USE_JPEG #define NO_JPEG #endif -#ifndef USE_JASPER -#define NO_JASPER -#endif + #define DCRAW_VERSION "9.26" #ifndef _GNU_SOURCE @@ -65,13 +63,9 @@ typedef unsigned long long UINT64; #endif #ifdef NODEPS -#define NO_JASPER #define NO_JPEG #define NO_LCMS #endif -#ifndef NO_JASPER -#include /* Decode Red camera movies */ -#endif #ifndef NO_JPEG #include /* Decode compressed Kodak DC120 photos */ #endif /* and Adobe Lossy DNGs */ diff --git a/internal/dmp_include.h b/internal/dmp_include.h index 6b6b5a6c7..ab85279c2 100644 --- a/internal/dmp_include.h +++ b/internal/dmp_include.h @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify diff --git a/internal/libraw_cameraids.h b/internal/libraw_cameraids.h index 4d03006b6..419bdeaad 100644 --- a/internal/libraw_cameraids.h +++ b/internal/libraw_cameraids.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: internal/libraw_cameraids.h - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sat Aug 17, 2020 LibRaw is free software; you can redistribute it and/or modify @@ -91,6 +91,10 @@ it under the terms of the one of two licenses as you choose: #define CanonID_EOS_R7 (0x80000000ULL + 0x464ULL) #define CanonID_EOS_R10 (0x80000000ULL + 0x465ULL) #define CanonID_EOS_M50_Mark_II (0x80000000ULL + 0x468ULL) +#define CanonID_EOS_R50 (0x80000000ULL + 0x480ULL) +#define CanonID_EOS_R6m2 (0x80000000ULL + 0x481ULL) +#define CanonID_EOS_R8 (0x80000000ULL + 0x487ULL) +#define CanonID_EOS_R100 (0x80000000ULL + 0x498ULL) // CanonID_EOS_D2000C after Canon's TIFF2CR2 convertor: #define CanonID_EOS_D2000C (0x80000000ULL + 0x520ULL) @@ -160,6 +164,7 @@ it under the terms of the one of two licenses as you choose: #define OlyID_E_M1_Mark_III OlyID_str2hex("S0092") #define OlyID_E_P7 OlyID_str2hex("S0093") #define OlyID_OM_1 OlyID_str2hex("S0095") +#define OlyID_OM_5 OlyID_str2hex("S0101") #define OlyID_C_3030Z OlyID_str2hex("SX351") #define OlyID_C_5050Z OlyID_str2hex("SX558") #define OlyID_C_350Z OlyID_str2hex("SX751") @@ -303,6 +308,7 @@ it under the terms of the one of two licenses as you choose: #define SonyID_DSC_RX100M5A 0x171ULL #define SonyID_ILCE_6400 0x173ULL #define SonyID_DSC_RX0M2 0x174ULL +#define SonyID_DSC_HX95 0x175ULL #define SonyID_DSC_RX100M7 0x176ULL #define SonyID_ILCE_7RM4 0x177ULL #define SonyID_ILCE_9M2 0x178ULL @@ -317,4 +323,12 @@ it under the terms of the one of two licenses as you choose: #define SonyID_ILCE_7RM3A 0x182ULL #define SonyID_ILCE_7RM4A 0x183ULL #define SonyID_ILCE_7M4 0x184ULL +// #define SonyID_ZV_1F 0x185ULL // Sony ZV-1F doesn't save raw +#define SonyID_ILCE_7RM5 0x186ULL +#define SonyID_ILME_FX30 0x187ULL +#define SonyID_ZV_E1 0x189ULL +#define SonyID_ILCE_6700 0x18aULL +#define SonyID_ZV_1M2 0x18bULL +#define SonyID_ILCE_7CR 0x18cULL +#define SonyID_ILCE_7CM2 0x18dULL #endif diff --git a/internal/libraw_checked_buffer.h b/internal/libraw_checked_buffer.h new file mode 100644 index 000000000..a5de6fd99 --- /dev/null +++ b/internal/libraw_checked_buffer.h @@ -0,0 +1,28 @@ +#pragma once + +#include +#include "../libraw/libraw_types.h" + +class checked_buffer_t +{ +public: + // create with internal storage + checked_buffer_t(short ord, int size); + checked_buffer_t(short ord, unsigned char *dd, int ss); + ushort sget2(int offset); + void checkoffset(int off); + unsigned char operator[](int idx); + unsigned sget4(int offset); + double sgetreal(int type, int offset); + unsigned char *data() { return _data; } + + int tiff_sget(unsigned save, INT64 *tag_offset, unsigned *tag_id, unsigned *tag_type, INT64 *tag_dataoffset, + unsigned *tag_datalen, int *tag_dataunitlen); +protected: + short _order; + + private: + unsigned char *_data; + int _len; + std::vector storage; +}; diff --git a/internal/libraw_cxx_defs.h b/internal/libraw_cxx_defs.h index 164849335..d249414c0 100644 --- a/internal/libraw_cxx_defs.h +++ b/internal/libraw_cxx_defs.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: internal/libraw_cxx_defs.h - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sat Aug 17, 2020 LibRaw is free software; you can redistribute it and/or modify @@ -39,43 +39,25 @@ it under the terms of the one of two licenses as you choose: #endif #include #endif - #ifdef USE_RAWSPEED -#include -#include -#include -#include -#include -#include -extern const char *_rawspeed_data_xml[]; -extern const int RAWSPEED_DATA_COUNT; -class CameraMetaDataLR : public RawSpeed::CameraMetaData -{ -public: - CameraMetaDataLR() : CameraMetaData() {} - CameraMetaDataLR(char *filename) : RawSpeed::CameraMetaData(filename) {} - CameraMetaDataLR(char *data, int sz); -}; - -CameraMetaDataLR *make_camera_metadata(); - +void *make_camera_metadata(); +void clear_camera_metadata(void*); +void clear_rawspeed_decoder(void*); #endif -#ifdef USE_DNGSDK -#include "dng_host.h" -#include "dng_negative.h" -#include "dng_simple_image.h" -#include "dng_info.h" -#endif #define P1 imgdata.idata #define S imgdata.sizes +#ifndef LIBRAW_DNGSDK_CONFLICT #define O imgdata.params #define C imgdata.color #define T imgdata.thumbnail #define MN imgdata.makernotes +#ifndef LIBRAW_EXPAT_CONFLICT #define IO libraw_internal_data.internal_output_params #define ID libraw_internal_data.internal_data +#endif +#endif #define makeIs(idx) (imgdata.idata.maker_index == idx) #define mnCamID imgdata.lens.makernotes.CamID diff --git a/internal/libraw_internal_funcs.h b/internal/libraw_internal_funcs.h index 6abdb6bde..83337a9b9 100644 --- a/internal/libraw_internal_funcs.h +++ b/internal/libraw_internal_funcs.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: libraw_internal_funcs.h - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sat Mar 14, 2008 LibRaw is free software; you can redistribute it and/or modify @@ -88,9 +88,6 @@ it under the terms of the one of two licenses as you choose: void parsePentaxMakernotes(int base, unsigned tag, unsigned type, unsigned len, unsigned dng_writer); void parseRicohMakernotes(int base, unsigned tag, unsigned type, unsigned len, unsigned dng_writer); void parseSamsungMakernotes(int base, unsigned tag, unsigned type, unsigned len, unsigned dng_writer); -#ifdef LIBRAW_OLD_VIDEO_SUPPORT - void fixupArri(); -#endif void setSonyBodyFeatures (unsigned long long id); void parseSonyLensType2 (uchar a, uchar b); void parseSonyLensFeatures (uchar a, uchar b); @@ -204,11 +201,6 @@ it under the terms of the one of two licenses as you choose: int guess_RAFDataGeneration (uchar *RAFData_start); void parse_fuji (int offset); void parse_fuji_thumbnail(int offset); -#ifdef LIBRAW_OLD_VIDEO_SUPPORT -// RedCine - void parse_redcine(); - void redcine_load_raw(); -#endif // Rollei void rollei_load_raw(); @@ -248,9 +240,6 @@ it under the terms of the one of two licenses as you choose: void nokia_load_raw(); void android_loose_load_raw(); void android_tight_load_raw(); -#ifdef LIBRAW_OLD_VIDEO_SUPPORT - void canon_rmf_load_raw(); -#endif unsigned pana_data (int nb, unsigned *bytes); void panasonic_load_raw(); // void panasonic_16x10_load_raw(); @@ -286,6 +275,7 @@ it under the terms of the one of two licenses as you choose: void kodak_rgb_load_thumb(); void kodak_ycbcr_load_thumb(); void vc5_dng_load_raw_placeholder(); + void jxl_dng_load_raw_placeholder(); // It's a Sony (and K&M) void sony_decrypt (unsigned *data, int len, int start, int key); void sony_load_raw(); @@ -293,6 +283,7 @@ it under the terms of the one of two licenses as you choose: void sony_arw2_load_raw(); void sony_arq_load_raw(); void sony_ljpeg_load_raw(); + void sony_ycbcr_load_raw(); void samsung_load_raw(); void samsung2_load_raw(); void samsung3_load_raw(); @@ -318,6 +309,14 @@ it under the terms of the one of two licenses as you choose: void parse_raspberrypi(); #endif + void kodak_thumb_loader(); + void dng_ycbcr_thumb_loader(); +#ifdef USE_X3FTOOLS + void x3f_thumb_loader(); + INT64 x3f_thumb_size(); +#endif + + // CAM/RGB void pseudoinverse (double (*in)[3], double (*out)[3], int size); void simple_coeff (int index); @@ -383,6 +382,7 @@ it under the terms of the one of two licenses as you choose: int crxParseImageHeader(uchar *cmp1TagData, int nTrack, int size); void panasonicC6_load_raw(); void panasonicC7_load_raw(); + void panasonicC8_load_raw(); void nikon_14bit_load_raw(); diff --git a/internal/losslessjpeg.h b/internal/losslessjpeg.h new file mode 100644 index 000000000..382746be0 --- /dev/null +++ b/internal/losslessjpeg.h @@ -0,0 +1,292 @@ +/* -*- C++ -*- + * File: huffmandec.h + * Copyright (C) 2023-2024 Alex Tutubalin, LibRaw LLC + * + Lossless JPEG decoder + + Code partially backported from DNGLab's rust code + DNGLab was originally created in 2021 by Daniel Vogelbacher. + +LibRaw is free software; you can redistribute it and/or modify +it under the terms of the one of two licenses as you choose: + +1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1 + (See file LICENSE.LGPL provided in LibRaw distribution archive for details). + +2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + (See file LICENSE.CDDL provided in LibRaw distribution archive for details). + + */ +#pragma once +#include +#include + +struct BitPump // generic bit source +{ + virtual uint32_t peek(uint32_t num) = 0; + virtual void consume(uint32_t num) = 0; + + uint32_t get(uint32_t num) + { + if(num == 0) { return 0u; } + uint32_t val = peek(num); + consume(num); + return val; + } +}; + +struct ByteStreamBE // Jpeg is always big endian +{ + enum Exceptions + { + OK = 0, + EndOfBuffer = 1 + }; + + uint8_t *buffer; + unsigned size, pos; + ByteStreamBE(uint8_t *b, unsigned s) : buffer(b), size(s), pos(0) {} + ByteStreamBE() : buffer(0),size(0),pos(0){} + bool skip_to_marker(); + + uint8_t get_u8() + { + if (pos >= size) + throw EndOfBuffer; + uint8_t ret = buffer[pos]; + pos++; + return ret; + } + uint16_t get_u16() + { + if (pos + 2 > size) + throw EndOfBuffer; + uint8_t r1 = buffer[pos]; + uint8_t r2 = buffer[pos + 1]; + pos += 2; + return (r1 << 8) | r2; + } +}; + +struct BitPumpJpeg : public BitPump +{ + uint8_t *buffer; + unsigned size, pos; + uint64_t bits; + uint32_t nbits; + bool finished; + + void consume(uint32_t num) + { + if (num <= nbits) + { + nbits -= num; + bits &= (uint64_t(1) << nbits) - 1UL; + } + } + uint32_t peek(uint32_t num) + { + if (num > nbits && !finished) + { + if ((size >= 4) && pos < size && buffer[pos] != 0xff && buffer[pos + 1] != 0xff && buffer[pos + 2] != 0xff && + buffer[pos + 3] != 0xff) + { + uint64_t inbits = (uint32_t(buffer[pos]) << 24) | (uint32_t(buffer[pos + 1]) << 16) | + (uint32_t(buffer[pos + 2]) << 8) | (uint32_t(buffer[pos + 3])); + bits = (bits << 32) | inbits; + pos += 4; + nbits += 32; + } + else + { + int read_bytes = 0; + while (read_bytes < 4 && !finished) + { + uint8_t byte = 0; + if (pos >= size) + finished = true; + else + { + uint8_t nextbyte = buffer[pos]; + if (nextbyte != 0xff) + byte = nextbyte; + else if (buffer[pos + 1] == 0x00) + { + pos += 1; + byte = nextbyte; + } + else + finished = true; + }; + bits = (bits << 8) | uint64_t(byte); + pos += 1; + nbits += 8; + read_bytes += 1; + } + } + } + if(num > nbits && finished) + { + bits <<= 32; + nbits += 32; + } + return uint32_t(bits >> (nbits - num)); + } + + BitPumpJpeg(ByteStreamBE& s): buffer(s.buffer+s.pos),size(s.size-s.pos),pos(0),bits(0),nbits(0),finished(false){} +}; + + +const uint32_t LIBRAW_DECODE_CACHE_BITS = 13; +const uint64_t LIBRAW_CACHE_PRESENT_FLAG = 0x100000000L; + +struct HuffTable +{ + uint32_t bits[17]; + uint32_t huffval[256]; + uint32_t shiftval[256]; + bool dng_bug; + bool disable_cache; + uint32_t nbits; + std::vector hufftable; // len:8 << 16| huffval:8 << 8 | shift:8 + std::vector decodecache; + bool initialized; + HuffTable(); + void initval(uint32_t bits[17], uint32_t huffval[256], bool dng_bug); + + int32_t decode(BitPump& pump) + { + uint64_t cached = disable_cache ? 0 : decodecache[pump.peek(LIBRAW_DECODE_CACHE_BITS)]; + if (cached & LIBRAW_CACHE_PRESENT_FLAG) + { + uint32_t bits = (cached >> 16) & 0xff; + int16_t val = int16_t(cached & 0xffff); + if (val == -32768 && dng_bug) + { + if (bits > 16) + pump.consume(bits - 16); + } + else + pump.consume(bits); + return val; + } + else + return decode_slow1(pump); + } + + int32_t decode_slow1(BitPump &pump) + { + int32_t _diff = diff(pump, len(pump)); + return _diff; + } + + int32_t decode_slow2(BitPump & pump, uint32_t& outlen) // output: (len+shift):8, code:16 + { + uint32_t _len = len(pump); + int32_t _diff = diff(pump, _len); + uint8_t bits8 = (_len >> 16) & 0xff; + uint8_t len8 = (_len >> 8) & 0xff; + outlen = bits8 + len8; + return _diff; + } + + uint32_t len(BitPump & pump) //bits:8, len:8, shift:8 + { + uint32_t code = pump.peek(nbits); + uint32_t huffdata = hufftable[code]; + uint32_t bits = (huffdata >> 16) & 0xff; + pump.consume(bits); + return huffdata; + } + + int32_t diff(BitPump & pump, uint32_t hentry) // input: bits:8, len:8, shift:8; output: diff:i32 + { + uint32_t len = (hentry >> 8) & 0xff; + if (len == 0) + return 0; + if (len == 16) + { + if (dng_bug) + pump.get(16); + return -32768; + } + uint32_t shift = hentry & 0xff; + uint32_t fulllen = len + shift; + uint32_t bits = pump.get(len); + int32_t diff = ((bits << 1) + 1) << shift >> 1; + if ((diff & (1 << (fulllen - 1))) == 0) + { + diff -= int32_t((1 << fulllen) - ((shift == 0))); + } + return diff; + } +}; + +struct LibRaw_JpegComponentInfo +{ + unsigned id; + unsigned index; + unsigned dc_tbl; + unsigned subsample_h, subsample_v; + LibRaw_JpegComponentInfo() : id(0), index(0), dc_tbl(0), subsample_h(0), subsample_v(0) {}; + LibRaw_JpegComponentInfo(unsigned _id, unsigned _index, unsigned _dcn, unsigned _sh, unsigned _sv) + : id(_id), index(_index), dc_tbl(_dcn), subsample_h(_sh), subsample_v(_sv){}; + LibRaw_JpegComponentInfo(const LibRaw_JpegComponentInfo& q): id(q.id), index(q.index), dc_tbl(q.dc_tbl), + subsample_h(q.subsample_h),subsample_v(q.subsample_v){} +}; + +struct LibRaw_SOFInfo +{ + unsigned width, height; + unsigned cps, precision; + std::vector components; + bool csfix; + LibRaw_SOFInfo(): width(0),height(0),cps(0),precision(0),csfix(false){} + bool parse_sof(ByteStreamBE&); // true => OK, false => not OK + uint32_t parse_sos(ByteStreamBE&); // returns (predictor << 8 | point transform); if above 0xffff => error +}; + +struct LibRaw_LjpegDecompressor +{ + ByteStreamBE buffer; + LibRaw_SOFInfo sof; + uint32_t predictor, point_transform; + uint32_t datastart; + std::vector dhts; + LibRaw_LjpegDecompressor(uint8_t *b, unsigned s); + LibRaw_LjpegDecompressor(uint8_t *b, unsigned bs, bool dngbug, bool csfix); + void initialize(bool dngbug, bool csfix); + uint8_t next_marker(bool allowskip); + bool parse_dht(bool init[4], uint32_t dht_bits[4][17], uint32_t dht_huffval[4][256]); // return true on OK; + bool decode_ljpeg_422(std::vector &dest, int width, int height); + + struct State { + enum States + { + OK = 0, + NotInited = 1, + NoSOI = 2, + IncorrectPrecision = 3, + EOIReached = 4, + InvalidDHT = 5, + InvalidSOF = 6, + InvalidSOS = 7, + DQTPresent = 8 + }; + + }; + struct Marker { + enum Markers { + Stuff = 0x00, + SOF3 = 0xc3, // lossless + DHT = 0xc4, // huffman tables + SOI = 0xd8, // start of image + EOI = 0xd9, // end of image + SOS = 0xda, // start of scan + DQT = 0xdb, // quantization tables + Fill = 0xff, + }; + }; + enum State::States state; +}; + diff --git a/internal/var_defines.h b/internal/var_defines.h index 71db9c3bd..d6d5ea299 100644 --- a/internal/var_defines.h +++ b/internal/var_defines.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: var_defines.h - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sat Mar 8, 2008 * * LibRaw redefinitions of dcraw internal variables @@ -184,6 +184,7 @@ it under the terms of the one of two licenses as you choose: #define tile_length (libraw_internal_data.unpacker_data.tile_length) #define load_flags (libraw_internal_data.unpacker_data.load_flags) #define pana_encoding (libraw_internal_data.unpacker_data.pana_encoding) +#define pana8 (libraw_internal_data.unpacker_data.pana8) #define pana_bpp (libraw_internal_data.unpacker_data.pana_bpp) #define CM_found (libraw_internal_data.unpacker_data.CM_found) diff --git a/internal/x3f_tools.h b/internal/x3f_tools.h index 84bb00c00..df2c6f796 100644 --- a/internal/x3f_tools.h +++ b/internal/x3f_tools.h @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify diff --git a/libraw/libraw.h b/libraw/libraw.h index 50d4276d4..897f63f1a 100644 --- a/libraw/libraw.h +++ b/libraw/libraw.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: libraw.h - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sat Mar 8, 2008 * * LibRaw C++ interface @@ -24,11 +24,6 @@ it under the terms of the one of two licenses as you choose: #define _FILE_OFFSET_BITS 64 #endif -// Enable use old cinema cameras if USE_OLD_VIDEOCAMS defined -#ifdef USE_OLD_VIDEOCAMS -#define LIBRAW_OLD_VIDEO_SUPPORT -#endif - #ifndef LIBRAW_USE_DEPRECATED_IOSTREAMS_DATASTREAM #define LIBRAW_NO_IOSTREAMS_DATASTREAM #endif @@ -378,7 +373,9 @@ protected: int crxDecodePlane(void *, uint32_t planeNumber); virtual void crxLoadFinalizeLoopE3(void *, int); void crxConvertPlaneLineDf(void *, int); - + /* Panasonic Compression 8 parallel decoder stubs*/ + virtual void pana8_decode_loop(void*); + int pana8_decode_strip(void*, int); // return: 0 if OK, non-zero on error int FCF(int row, int col) { int rr, cc; @@ -417,12 +414,7 @@ protected: //void (LibRaw::*thumb_load_raw)(); void (LibRaw::*pentax_component_load_raw)(); - void kodak_thumb_loader(); void write_thumb_ppm_tiff(FILE *); -#ifdef USE_X3FTOOLS - void x3f_thumb_loader(); - INT64 x3f_thumb_size(); -#endif int own_filtering_supported() { return 0; } void identify(); diff --git a/libraw/libraw_alloc.h b/libraw/libraw_alloc.h index c22d99586..2a6461e42 100644 --- a/libraw/libraw_alloc.h +++ b/libraw/libraw_alloc.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: libraw_alloc.h - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sat Mar 22, 2008 * * LibRaw C++ interface diff --git a/libraw/libraw_const.h b/libraw/libraw_const.h index 61f8028b2..0d84029eb 100644 --- a/libraw/libraw_const.h +++ b/libraw/libraw_const.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: libraw_const.h - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sat Mar 8 , 2008 * LibRaw error codes LibRaw is free software; you can redistribute it and/or modify @@ -119,7 +119,8 @@ enum LibRaw_As_Shot_WB_Applied_codes LIBRAW_ASWB_CANON = 2, LIBRAW_ASWB_NIKON = 4, LIBRAW_ASWB_NIKON_SRAW = 8, - LIBRAW_ASWB_PENTAX = 16 + LIBRAW_ASWB_PENTAX = 16, + LIBRAW_ASWB_SONY = 32 }; #define tagtypeIs(typex) (type == typex) @@ -288,6 +289,7 @@ enum LibRaw_colorspace { LIBRAW_COLORSPACE_CameraGamma, LIBRAW_COLORSPACE_MonochromeLinear, LIBRAW_COLORSPACE_MonochromeGamma, + LIBRAW_COLORSPACE_Rec2020, LIBRAW_COLORSPACE_Unknown = 255 }; @@ -540,7 +542,8 @@ enum LibRaw_Sony_0x9050_Type { LIBRAW_SONY_Tag9050None = 0, LIBRAW_SONY_Tag9050a, LIBRAW_SONY_Tag9050b, - LIBRAW_SONY_Tag9050c + LIBRAW_SONY_Tag9050c, + LIBRAW_SONY_Tag9050d }; enum LIBRAW_SONY_FOCUSMODEmodes @@ -639,7 +642,8 @@ enum LibRaw_processing_options LIBRAW_RAWOPTIONS_DNG_STAGE2_IFPRESENT = 1 << 20, LIBRAW_RAWOPTIONS_DNG_STAGE3_IFPRESENT = 1 << 21, LIBRAW_RAWOPTIONS_DNG_ADD_MASKS = 1 << 22, - LIBRAW_RAWOPTIONS_CANON_IGNORE_MAKERNOTES_ROTATION = 1 << 23 + LIBRAW_RAWOPTIONS_CANON_IGNORE_MAKERNOTES_ROTATION = 1 << 23, + LIBRAW_RAWOPTIONS_ALLOW_JPEGXL_PREVIEWS = 1 << 24 }; enum LibRaw_decoder_flags @@ -682,9 +686,6 @@ enum LibRaw_warnings LIBRAW_WARN_NO_BADPIXELMAP = 1 << 8, LIBRAW_WARN_BAD_DARKFRAME_FILE = 1 << 9, LIBRAW_WARN_BAD_DARKFRAME_DIM = 1 << 10, -#ifdef LIBRAW_OLD_VIDEO_SUPPORT - LIBRAW_WARN_NO_JASPER = 1 << 11, -#endif LIBRAW_WARN_RAWSPEED_PROBLEM = 1 << 12, LIBRAW_WARN_RAWSPEED_UNSUPPORTED = 1 << 13, LIBRAW_WARN_RAWSPEED_PROCESSED = 1 << 14, @@ -697,7 +698,8 @@ enum LibRaw_warnings LIBRAW_WARN_RAWSPEED3_PROBLEM = 1 << 21, LIBRAW_WARN_RAWSPEED3_UNSUPPORTED = 1 << 22, LIBRAW_WARN_RAWSPEED3_PROCESSED = 1 << 23, - LIBRAW_WARN_RAWSPEED3_NOTLISTED = 1 << 24 + LIBRAW_WARN_RAWSPEED3_NOTLISTED = 1 << 24, + LIBRAW_WARN_VENDOR_CROP_SUGGESTED = 1 << 25 }; enum LibRaw_exceptions @@ -791,6 +793,8 @@ enum LibRaw_internal_thumbnail_formats LIBRAW_INTERNAL_THUMBNAIL_PPM, LIBRAW_INTERNAL_THUMBNAIL_PPM16, LIBRAW_INTERNAL_THUMBNAIL_X3F, + LIBRAW_INTERNAL_THUMBNAIL_DNG_YCBCR, + LIBRAW_INTERNAL_THUMBNAIL_JPEGXL }; @@ -802,7 +806,8 @@ enum LibRaw_thumbnail_formats LIBRAW_THUMBNAIL_BITMAP16 = 3, LIBRAW_THUMBNAIL_LAYER = 4, LIBRAW_THUMBNAIL_ROLLEI = 5, - LIBRAW_THUMBNAIL_H265 = 6 + LIBRAW_THUMBNAIL_H265 = 6, + LIBRAW_THUMBNAIL_JPEGXL = 7 }; enum LibRaw_image_formats diff --git a/libraw/libraw_datastream.h b/libraw/libraw_datastream.h index 0596e83a5..a978ae602 100644 --- a/libraw/libraw_datastream.h +++ b/libraw/libraw_datastream.h @@ -1,6 +1,6 @@ /* -*- C -*- * File: libraw_datastream.h - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sun Jan 18 13:07:35 2009 * * LibRaw Data stream interface @@ -95,9 +95,6 @@ public: virtual char *gets(char *, int) = 0; virtual int scanf_one(const char *, void *) = 0; virtual int eof() = 0; -#ifdef LIBRAW_OLD_VIDEO_SUPPORT - virtual void *make_jas_stream() = 0; -#endif virtual int jpeg_src(void *); virtual void buffering_off() {} /* reimplement in subclass to use parallel access in xtrans_load_raw() if @@ -133,16 +130,12 @@ protected: #ifdef LIBRAW_WIN32_UNICODEPATHS std::wstring wfilename; #endif - FILE *jas_file; public: virtual ~LibRaw_file_datastream(); LibRaw_file_datastream(const char *fname); #ifdef LIBRAW_WIN32_UNICODEPATHS LibRaw_file_datastream(const wchar_t *fname); -#endif -#ifdef LIBRAW_OLD_VIDEO_SUPPORT - virtual void *make_jas_stream(); #endif virtual int valid(); virtual int read(void *ptr, size_t size, size_t nmemb); @@ -215,9 +208,6 @@ public: #endif virtual ~LibRaw_bigfile_buffered_datastream(); virtual int valid(); -#ifdef LIBRAW_OLD_VIDEO_SUPPORT - virtual void *make_jas_stream(); -#endif virtual void buffering_off() { buffered = 0; } virtual int read(void *ptr, size_t size, size_t nmemb); virtual int eof(); @@ -266,9 +256,6 @@ public: LibRaw_buffer_datastream(const void *buffer, size_t bsize); virtual ~LibRaw_buffer_datastream(); virtual int valid(); -#ifdef LIBRAW_OLD_VIDEO_SUPPORT - virtual void *make_jas_stream(); -#endif virtual int jpeg_src(void *jpegdata); virtual int read(void *ptr, size_t sz, size_t nmemb); virtual int eof(); @@ -297,10 +284,6 @@ public: #endif virtual ~LibRaw_bigfile_datastream(); virtual int valid(); -#ifdef LIBRAW_OLD_VIDEO_SUPPORT - virtual void *make_jas_stream(); -#endif - virtual int read(void *ptr, size_t size, size_t nmemb); virtual int eof(); virtual int seek(INT64 o, int whence); diff --git a/libraw/libraw_internal.h b/libraw/libraw_internal.h index 9ed3a1790..5af31d3ab 100644 --- a/libraw/libraw_internal.h +++ b/libraw/libraw_internal.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: libraw_internal.h - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sat Mar 8 , 2008 * * LibRaw internal data structures (not visible outside) @@ -150,6 +150,22 @@ typedef struct INT64 *chunk_offsets; } crx_data_header_t; +typedef struct +{ + uint32_t tag39[6]; + uint16_t tag3A[6]; + uint16_t tag3B; + uint16_t initial[4]; + uint16_t tag40a[17], tag40b[17], tag41[17]; + uint16_t stripe_count; // 0x42 + uint16_t tag43; + INT64 stripe_offsets[5]; //0x44 + uint16_t stripe_left[5]; // 0x45 + uint32_t stripe_compressed_size[5]; //0x46 + uint16_t stripe_width[5]; //0x47 + uint16_t stripe_height[5]; +} pana8_tags_t; + typedef struct { short order; @@ -177,6 +193,7 @@ typedef struct int fuji_total_lines, fuji_total_blocks, fuji_block_width, fuji_bits, fuji_raw_type, fuji_lossless; int pana_encoding, pana_bpp; + pana8_tags_t pana8; crx_data_header_t crx_header[LIBRAW_CRXTRACKS_MAXCOUNT]; int crx_track_selected; int crx_track_count; diff --git a/libraw/libraw_types.h b/libraw/libraw_types.h index ec413b68b..57ba2097d 100644 --- a/libraw/libraw_types.h +++ b/libraw/libraw_types.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: libraw_types.h - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sat Mar 8 , 2008 * * LibRaw C data structures @@ -370,6 +370,8 @@ typedef unsigned long long UINT64; ushort DRangePriority; ushort DRangePriorityAuto; ushort DRangePriorityFixed; + char FujiModel[32 + 1]; + char FujiModel2[32 + 1]; /* tag 0x9200, converted to BrightnessCompensation @@ -509,6 +511,9 @@ typedef unsigned long long UINT64; ushort SensorWidth; ushort SensorHeight; ushort Active_D_Lighting; + unsigned PictureControlVersion; + char PictureControlName [20]; + char PictureControlBase [20]; unsigned ShotInfoVersion; short MakernotesFlip; double RollAngle; // positive is clockwise, CW @@ -675,6 +680,9 @@ typedef unsigned long long UINT64; ushort HDR[2]; ushort group2010; ushort group9050; + + ushort len_group9050; // currently, for debugging only + ushort real_iso_offset; // init in 0xffff ushort MeteringMode_offset; ushort ExposureProgram_offset; @@ -731,8 +739,10 @@ typedef unsigned long long UINT64; 3330 ARW 2.3.3 3350 ARW 2.3.5 4000 ARW 4.0 + 4010 ARW 4.0.1 */ char MetaVersion [16]; + float AspectRatio; } libraw_sony_info_t; typedef struct @@ -915,6 +925,7 @@ typedef unsigned long long UINT64; float adjust_maximum_thr; int no_auto_bright; /* -W */ int use_fuji_rotate; /* -j */ + int use_p1_correction; int green_matching; /* DCB parameters */ int dcb_iterations; diff --git a/libraw/libraw_version.h b/libraw/libraw_version.h index c6f5c72a3..143a769ad 100644 --- a/libraw/libraw_version.h +++ b/libraw/libraw_version.h @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: libraw_version.h - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Mon Sept 8, 2008 * * LibRaw C++ interface @@ -22,8 +22,8 @@ it under the terms of the one of two licenses as you choose: #define LIBRAW_MAJOR_VERSION 0 #define LIBRAW_MINOR_VERSION 21 -#define LIBRAW_PATCH_VERSION 2 -#define LIBRAW_VERSION_TAIL Release +#define LIBRAW_PATCH_VERSION 0 +#define LIBRAW_VERSION_TAIL Beta1 #define LIBRAW_SHLIB_CURRENT 23 #define LIBRAW_SHLIB_REVISION 0 diff --git a/samples/4channels.cpp b/samples/4channels.cpp index 82d40f4e0..57293a2fe 100644 --- a/samples/4channels.cpp +++ b/samples/4channels.cpp @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: 4channels.cpp - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Mon Feb 09, 2009 * * LibRaw sample @@ -44,7 +44,7 @@ int main(int ac, char *av[]) { usage: printf("4channels - LibRaw %s sample. %d cameras supported\n" - "Usage: %s [-s N] [-g] [-A] [-B] [-N] raw-files....\n" + "Usage: %s [-s N] [-g] [-A] [-B] raw-files....\n" "\t-s N - select Nth image in file (default=0)\n" "\t-g - use gamma correction with gamma 2.2 (not precise,use for " "visual inspection only)\n" diff --git a/samples/dcraw_emu.cpp b/samples/dcraw_emu.cpp index 1af82ff04..afa341558 100644 --- a/samples/dcraw_emu.cpp +++ b/samples/dcraw_emu.cpp @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: dcraw_emu.cpp - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sun Mar 23, 2008 * * LibRaw simple C++ API sample: almost complete dcraw emulator diff --git a/samples/dcraw_half.c b/samples/dcraw_half.c index 5fe56a573..233cbe0c7 100644 --- a/samples/dcraw_half.c +++ b/samples/dcraw_half.c @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: dcraw_half.c - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sat Mar 8 , 2008 * * LibRaw C API sample: emulates "dcraw -h" diff --git a/samples/half_mt.c b/samples/half_mt.c index f46c83ea8..c8cda4c7d 100644 --- a/samples/half_mt.c +++ b/samples/half_mt.c @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: halt_mt.c - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sat Mar 8, 2008 * * LibRaw C API mutithreaded sample: emulates call to "dcraw -h [-w] [-a] diff --git a/samples/half_mt_win32.c b/samples/half_mt_win32.c index b8d3943d3..85713370b 100644 --- a/samples/half_mt_win32.c +++ b/samples/half_mt_win32.c @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: halt_mt_win32.c - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sat Mar 8, 2008 * * LibRaw C API mutithreaded sample: emulates call to "dcraw -h [-w] [-a] diff --git a/samples/mem_image_sample.cpp b/samples/mem_image_sample.cpp index 1ce5b8c60..3ea315b2f 100644 --- a/samples/mem_image_sample.cpp +++ b/samples/mem_image_sample.cpp @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: mem_image.cpp - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * * LibRaw mem_image/mem_thumb API test. Results should be same (bitwise) to dcraw [-4] [-6] [-e] diff --git a/samples/multirender_test.cpp b/samples/multirender_test.cpp index 06dcec58a..a77db76db 100644 --- a/samples/multirender_test.cpp +++ b/samples/multirender_test.cpp @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: multirender_test.cpp - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Jul 10, 2011 * * LibRaw simple C++ API: creates 8 different renderings from 1 source file. diff --git a/samples/openbayer_sample.cpp b/samples/openbayer_sample.cpp index c1e46595b..a700535e1 100644 --- a/samples/openbayer_sample.cpp +++ b/samples/openbayer_sample.cpp @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: openvayer_sample.cpp - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Feb 11, 2020 * * LibRaw simple C++ API: opens bayer data (Kodak KAI-0340 sensor) from buffer, diff --git a/samples/postprocessing_benchmark.cpp b/samples/postprocessing_benchmark.cpp index 703a7a373..778c68a79 100644 --- a/samples/postprocessing_benchmark.cpp +++ b/samples/postprocessing_benchmark.cpp @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: postprocessing_benchmark.cpp - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Jul 13, 2011 * * LibRaw simple C++ API: creates 8 different renderings from 1 source file. diff --git a/samples/raw-identify.cpp b/samples/raw-identify.cpp index 31c770d34..5c5b29a8c 100644 --- a/samples/raw-identify.cpp +++ b/samples/raw-identify.cpp @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: identify.cpp - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sat Mar 8, 2008 * * LibRaw C++ demo: emulates dcraw -i [-v] diff --git a/samples/rawtextdump.cpp b/samples/rawtextdump.cpp index 62c4c6ffe..e72f59176 100644 --- a/samples/rawtextdump.cpp +++ b/samples/rawtextdump.cpp @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: raw2text.cpp - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sun Sept 01, 2020 * * LibRaw sample diff --git a/samples/simple_dcraw.cpp b/samples/simple_dcraw.cpp index f96b23cff..710252ecf 100644 --- a/samples/simple_dcraw.cpp +++ b/samples/simple_dcraw.cpp @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: simple_dcraw.cpp - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sat Mar 8, 2008 * * LibRaw simple C++ API: emulates call to "dcraw [-D] [-T] [-v] [-e] [-4]" diff --git a/samples/unprocessed_raw.cpp b/samples/unprocessed_raw.cpp index 2f30ce4cb..3060d4d5f 100644 --- a/samples/unprocessed_raw.cpp +++ b/samples/unprocessed_raw.cpp @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: unprocessed_raw.cpp - * Copyright 2009-2021 LibRaw LLC (info@libraw.org) + * Copyright 2009-2024 LibRaw LLC (info@libraw.org) * Created: Fri Jan 02, 2009 * * LibRaw sample diff --git a/src/decoders/canon_600.cpp b/src/decoders/canon_600.cpp index 59576f1ff..b6960393c 100644 --- a/src/decoders/canon_600.cpp +++ b/src/decoders/canon_600.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/decoders/crx.cpp b/src/decoders/crx.cpp index 30a702054..495c2f4e4 100644 --- a/src/decoders/crx.cpp +++ b/src/decoders/crx.cpp @@ -2032,7 +2032,7 @@ int crxMakeQStep(CrxImage *img, CrxTile *tile, int32_t *qpTable, uint32_t /*tota // not sure about this nonsense - why is it not just avg like with 2 levels? quantVal = ((quantVal < 0) * 3 + quantVal) >> 2; if (quantVal / 6 >= 6) - *qStepTbl = q_step_tbl[quantVal % 6] * (1 << (quantVal / 6 + 26)); + *qStepTbl = q_step_tbl[quantVal % 6] * (1 << ((quantVal / 6 - 6 ) & 0x1f)); else *qStepTbl = q_step_tbl[quantVal % 6] >> (6 - quantVal / 6); } @@ -2052,7 +2052,7 @@ int crxMakeQStep(CrxImage *img, CrxTile *tile, int32_t *qpTable, uint32_t /*tota { int32_t quantVal = (qpTable[row0Idx++] + qpTable[row1Idx++]) / 2; if (quantVal / 6 >= 6) - *qStepTbl = q_step_tbl[quantVal % 6] * (1 << (quantVal / 6 + 26)); + *qStepTbl = q_step_tbl[quantVal % 6] * (1 << ((quantVal / 6 - 6) & 0x1f)); else *qStepTbl = q_step_tbl[quantVal % 6] >> (6 - quantVal / 6); } @@ -2066,7 +2066,7 @@ int crxMakeQStep(CrxImage *img, CrxTile *tile, int32_t *qpTable, uint32_t /*tota for (int qpRow = 0; qpRow < qpHeight; ++qpRow) for (int qpCol = 0; qpCol < qpWidth; ++qpCol, ++qStepTbl, ++qpTable) if (*qpTable / 6 >= 6) - *qStepTbl = q_step_tbl[*qpTable % 6] * (1 << (*qpTable / 6 + 26)); + *qStepTbl = q_step_tbl[*qpTable % 6] * (1 << ((*qpTable / 6 - 6) & 0x1f)); else *qStepTbl = q_step_tbl[*qpTable % 6] >> (6 - *qpTable / 6); diff --git a/src/decoders/decoders_dcraw.cpp b/src/decoders/decoders_dcraw.cpp index 090a6b726..a6cb6b7aa 100644 --- a/src/decoders/decoders_dcraw.cpp +++ b/src/decoders/decoders_dcraw.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. @@ -1051,38 +1051,6 @@ void LibRaw::nokia_load_raw() filters = 0x4b4b4b4b; } -#ifdef LIBRAW_OLD_VIDEO_SUPPORT - -void LibRaw::canon_rmf_load_raw() -{ - int row, col, bits, orow, ocol, c; - - int *words = (int *)malloc(sizeof(int) * (raw_width / 3 + 1)); - for (row = 0; row < raw_height; row++) - { - checkCancel(); - fread(words, sizeof(int), raw_width / 3, ifp); - for (col = 0; col < raw_width - 2; col += 3) - { - bits = words[col / 3]; - FORC3 - { - orow = row; - if ((ocol = col + c - 4) < 0) - { - ocol += raw_width; - if ((orow -= 2) < 0) - orow += raw_height; - } - RAW(orow, ocol) = curve[bits >> (10 * c + 2) & 0x3ff]; - } - } - } - free(words); - maximum = curve[0x3ff]; -} -#endif - unsigned LibRaw::pana_data(int nb, unsigned *bytes) { #ifndef LIBRAW_NOTHREADS @@ -1728,83 +1696,3 @@ void LibRaw::samsung3_load_raw() } } -#ifdef LIBRAW_OLD_VIDEO_SUPPORT -void LibRaw::redcine_load_raw() -{ -#ifndef NO_JASPER - int c, row, col; - jas_stream_t *in; - jas_image_t *jimg; - jas_matrix_t *jmat; - jas_seqent_t *data; - ushort *img, *pix; - - jas_init(); - in = (jas_stream_t *)ifp->make_jas_stream(); - if (!in) - throw LIBRAW_EXCEPTION_DECODE_JPEG2000; - jas_stream_seek(in, data_offset + 20, SEEK_SET); - jimg = jas_image_decode(in, -1, 0); - if (!jimg) - { - jas_stream_close(in); - throw LIBRAW_EXCEPTION_DECODE_JPEG2000; - } - jmat = jas_matrix_create(height / 2, width / 2); - img = (ushort *)calloc((height + 2), (width + 2) * 2); - bool fastexitflag = false; - try - { - FORC4 - { - checkCancel(); - jas_image_readcmpt(jimg, c, 0, 0, width / 2, height / 2, jmat); - data = jas_matrix_getref(jmat, 0, 0); - for (row = c >> 1; row < height; row += 2) - for (col = c & 1; col < width; col += 2) - img[(row + 1) * (width + 2) + col + 1] = - data[(row / 2) * (width / 2) + col / 2]; - } - for (col = 1; col <= width; col++) - { - img[col] = img[2 * (width + 2) + col]; - img[(height + 1) * (width + 2) + col] = - img[(height - 1) * (width + 2) + col]; - } - for (row = 0; row < height + 2; row++) - { - img[row * (width + 2)] = img[row * (width + 2) + 2]; - img[(row + 1) * (width + 2) - 1] = img[(row + 1) * (width + 2) - 3]; - } - for (row = 1; row <= height; row++) - { - checkCancel(); - pix = img + row * (width + 2) + (col = 1 + (FC(row, 1) & 1)); - for (; col <= width; col += 2, pix += 2) - { - c = (((pix[0] - 0x800) << 3) + pix[-(width + 2)] + pix[width + 2] + - pix[-1] + pix[1]) >> - 2; - pix[0] = LIM(c, 0, 4095); - } - } - for (row = 0; row < height; row++) - { - checkCancel(); - for (col = 0; col < width; col++) - RAW(row, col) = curve[img[(row + 1) * (width + 2) + col + 1]]; - } - } - catch (...) - { - fastexitflag = true; - } - free(img); - jas_matrix_destroy(jmat); - jas_image_destroy(jimg); - jas_stream_close(in); - if (fastexitflag) - throw LIBRAW_EXCEPTION_CANCELLED_BY_CALLBACK; -#endif -} -#endif diff --git a/src/decoders/decoders_libraw_dcrdefs.cpp b/src/decoders/decoders_libraw_dcrdefs.cpp index 89d82595b..9ce9dd467 100644 --- a/src/decoders/decoders_libraw_dcrdefs.cpp +++ b/src/decoders/decoders_libraw_dcrdefs.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: @@ -71,7 +71,6 @@ void LibRaw::packed_tiled_dng_load_raw() } - void LibRaw::sony_ljpeg_load_raw() { unsigned trow = 0, tcol = 0, jrow, jcol, row, col; diff --git a/src/decoders/dng.cpp b/src/decoders/dng.cpp index 89537a540..4245e52f9 100644 --- a/src/decoders/dng.cpp +++ b/src/decoders/dng.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. @@ -23,6 +23,11 @@ void LibRaw::vc5_dng_load_raw_placeholder() // placeholder only, real decoding implemented in GPR SDK throw LIBRAW_EXCEPTION_DECODE_RAW; } +void LibRaw::jxl_dng_load_raw_placeholder() +{ + // placeholder only, real decoding implemented in DNG SDK + throw LIBRAW_EXCEPTION_DECODE_RAW; +} void LibRaw::adobe_copy_pixel(unsigned row, unsigned col, ushort **rp) { diff --git a/src/decoders/fp_dng.cpp b/src/decoders/fp_dng.cpp index 72631dbbd..f54a79ef3 100644 --- a/src/decoders/fp_dng.cpp +++ b/src/decoders/fp_dng.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: diff --git a/src/decoders/generic.cpp b/src/decoders/generic.cpp index 6c521d849..b286ed790 100644 --- a/src/decoders/generic.cpp +++ b/src/decoders/generic.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/decoders/kodak_decoders.cpp b/src/decoders/kodak_decoders.cpp index e4b1b3957..0706e4911 100644 --- a/src/decoders/kodak_decoders.cpp +++ b/src/decoders/kodak_decoders.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/decoders/load_mfbacks.cpp b/src/decoders/load_mfbacks.cpp index cddc33ebc..bc60e87cd 100644 --- a/src/decoders/load_mfbacks.cpp +++ b/src/decoders/load_mfbacks.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/decoders/pana8.cpp b/src/decoders/pana8.cpp new file mode 100644 index 000000000..909c9bd8b --- /dev/null +++ b/src/decoders/pana8.cpp @@ -0,0 +1,529 @@ +/* -*- C++ -*- + * File: pana8.cpp + * Copyright (C) 2022-2024 Alex Tutubalin, LibRaw LLC + * + Panasonic RawFormat=8 file decoder + +LibRaw is free software; you can redistribute it and/or modify +it under the terms of the one of two licenses as you choose: + +1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1 + (See file LICENSE.LGPL provided in LibRaw distribution archive for details). + +2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + (See file LICENSE.CDDL provided in LibRaw distribution archive for details). + + */ + +#include "../../internal/libraw_cxx_defs.h" +#include + + // in 8-byte words, 800kb +#define PANA8_BUFSIZE 102400 + +class pana8_bufio_t +{ +public: + pana8_bufio_t(LibRaw_abstract_datastream *stream, INT64 start, uint32_t len) + : data(PANA8_BUFSIZE), input(stream), baseoffset(start), begin(0), end(0), _size(len) + { + } + uint32_t size() { return ((_size+7)/8)*8; } + uint64_t getQWord(uint32_t offset) + { + if (offset >= begin && offset < end) + return data[offset - begin]; + if (!input) return 0; + refill(offset); + if (offset >= begin && offset < end) + return data[offset - begin]; + return 0; + } + void refill(uint32_t newoffset); + + std::vector data; + LibRaw_abstract_datastream *input; + INT64 baseoffset; + INT64 begin, end; + uint32_t _size; +}; + +struct pana8_param_t +{ + uint32_t range_shift, gamma_base; + uint32_t tag3A[6]; + uint32_t tag39[6]; + uint32_t tag3B; + uint32_t initial[4]; + uint32_t huff_coeff[17]; + uint32_t tag3B_2; + uint32_t noGammaFlag; + uint64_t hufftable1[17]; + uint64_t hufftable2[17]; + std::vector gammaTable; + std::vector extrahuff; + pana8_param_t(const pana8_tags_t& init); + int32_t gammaCurve(uint32_t i); + bool DecodeC8( + pana8_bufio_t& bufio, + unsigned int width, unsigned int height, + LibRaw *libraw, uint16_t left_margin); + uint32_t GetDBit(uint64_t a2); +}; + +void invertBits(void *buf, size_t size); + +void pana8_bufio_t::refill(uint32_t newoffset) +{ + if (newoffset >= begin && newoffset < end) + return; + uint32_t readwords, remainwords,toread; +#ifdef LIBRAW_USE_OPENMP +#pragma omp critical + { +#endif + input->lock(); + input->seek(baseoffset + newoffset*sizeof(int64_t), SEEK_SET); + remainwords = (_size - newoffset*sizeof(int64_t) + 7) >> 3; + toread = MIN(PANA8_BUFSIZE, remainwords); + uint32_t readbytes = input->read(data.data(), 1, toread*sizeof(uint64_t)); + readwords = (readbytes + 7) >> 3; + input->unlock(); +#ifdef LIBRAW_USE_OPENMP + } +#endif + + if (INT64(readwords) < INT64(toread) - 1LL) + throw LIBRAW_EXCEPTION_IO_EOF; + + if(readwords>0) + invertBits(data.data(), readwords * sizeof(uint64_t)); + begin = newoffset; + end = newoffset + readwords; +} + +void LibRaw::panasonicC8_load_raw() +{ + int errs = 0; + unsigned totalw = 0; + INT64 fsz = libraw_internal_data.internal_data.input->size(); + if (libraw_internal_data.unpacker_data.pana8.stripe_count > 5) errs++; + for (int i = 0; i < libraw_internal_data.unpacker_data.pana8.stripe_count && i < 5; i++) + { + if (libraw_internal_data.unpacker_data.pana8.stripe_height[i] != imgdata.sizes.raw_height) + errs++; + if (libraw_internal_data.unpacker_data.pana8.stripe_offsets[i] < 0 + || (libraw_internal_data.unpacker_data.pana8.stripe_offsets[i] + INT64((libraw_internal_data.unpacker_data.pana8.stripe_compressed_size[i] + 7u) / 8u)) > fsz) + errs++; + totalw += libraw_internal_data.unpacker_data.pana8.stripe_width[i]; + } + if (totalw != imgdata.sizes.raw_width) errs++; + if (errs) + throw LIBRAW_EXCEPTION_IO_CORRUPT; + + pana8_param_t pana8_param(libraw_internal_data.unpacker_data.pana8); + pana8_decode_loop(&pana8_param); +} + +void LibRaw::pana8_decode_loop(void *data) +{ +#ifdef LIBRAW_USE_OPENMP + int errs = 0, scount = MIN(5,libraw_internal_data.unpacker_data.pana8.stripe_count); +#pragma omp parallel for + for (int stream = 0; stream < scount; stream++) + { + if (pana8_decode_strip(data, stream)) + errs++; + } + if(errs) + throw LIBRAW_EXCEPTION_IO_CORRUPT; +#else + for (int stream = 0; stream < libraw_internal_data.unpacker_data.pana8.stripe_count && stream < 5; stream++) + if (pana8_decode_strip(data, stream)) + throw LIBRAW_EXCEPTION_IO_CORRUPT; +#endif +} + +int LibRaw::pana8_decode_strip(void* data, int stream) +{ + pana8_param_t *pana8_param = (pana8_param_t*)data; + if (!data || stream < 0 || stream > 4 || stream > libraw_internal_data.unpacker_data.pana8.stripe_count) return 1; // error + + unsigned exactbytes = (libraw_internal_data.unpacker_data.pana8.stripe_compressed_size[stream] + 7u) / 8u; + pana8_bufio_t bufio(libraw_internal_data.internal_data.input, + libraw_internal_data.unpacker_data.pana8.stripe_offsets[stream], exactbytes); + return !pana8_param->DecodeC8(bufio, libraw_internal_data.unpacker_data.pana8.stripe_width[stream], + libraw_internal_data.unpacker_data.pana8.stripe_height[stream], this, + libraw_internal_data.unpacker_data.pana8.stripe_left[stream]); +} + +struct pana8_base_t +{ + pana8_base_t() { coeff[0] = coeff[1] = coeff[2] = coeff[3] = 0; } + pana8_base_t(const pana8_base_t &s) { clone(s.coeff); } + void clone(const uint32_t *scoeff) + { // TODO: implement SSE load for SSE-enabled code + coeff[0] = scoeff[0]; + coeff[1] = scoeff[1]; + coeff[2] = scoeff[2]; + coeff[3] = scoeff[3]; + } + uint32_t coeff[4]; +}; + +bool pana8_param_t::DecodeC8(pana8_bufio_t &bufio, unsigned int width, unsigned int height, LibRaw *libraw, + uint16_t left_margin) +{ + unsigned halfwidth = width >> 1; + unsigned halfheight = height >> 1; + if (!halfwidth || !halfheight || bufio.size() < 9) + return false; // invalid input + + uint32_t datamax = tag3B_2 >> range_shift; + + pana8_base_t start_coeff; + for(int i = 0; i < 4; i++) + start_coeff.coeff[i] = initial[i] & 0xffffu; + + bool _extrahuff = (extrahuff.size() >= 0x10000); + + uint8_t *big_huff_table = 0; + if (_extrahuff) + big_huff_table = extrahuff.data(); + + uint16_t *gammatable = (gammaTable.size() >= 0x10000) && !noGammaFlag ? (uint16_t *)gammaTable.data() : 0; + +#ifdef PANA8_FULLY_BUFFERED + const uint8_t *inputbyteptr = source.data(); + uint32_t jobsz_in_qwords = source.size() >> 3; +#else + uint32_t jobsz_in_qwords = bufio.size() >> 3; +#endif + int32_t doublewidth = 4 * halfwidth; + std::vector outline(4 * doublewidth); + pana8_base_t line_base(start_coeff); + int64_t bittail = 0LL; + int32_t bitportion = 0; + uint32_t inqword = 0u; + + try + { + for (uint32_t current_row = 0; current_row < halfheight; current_row++) + { + uint8_t *outrowp = outline.data(); + pana8_base_t current_base(line_base); + + for (int32_t col = 0; col < doublewidth; col++) + { + uint64_t pixbits; + if (bitportion < 0) + { + uint32_t inqword_next = inqword + 1; + if ((int)inqword + 1 >= int(jobsz_in_qwords)) + return false; + bitportion += 64; + uint64_t inputqword = bufio.getQWord(inqword); + uint64_t inputqword_next = bufio.getQWord(inqword_next); + pixbits = (inputqword_next >> bitportion) | (inputqword << (64 - (uint8_t)(bitportion & 0xffu))); + if ((unsigned int)inqword < jobsz_in_qwords) + inqword = inqword_next; + } + else + { + if ((unsigned int)inqword >= jobsz_in_qwords) + return false; + uint64_t inputqword = bufio.getQWord(inqword); + pixbits = (inputqword >> bitportion) | bittail; + uint32_t step = (bitportion == 0); + if (!bitportion) + bitportion = 64; + inqword += step; + } + int huff_index = 0; + if (_extrahuff) + huff_index = *(uint8_t *)(big_huff_table + ((pixbits >> 48) & 0xffffu)); + else + { + huff_index = int(GetDBit(pixbits)); + datamax = tag3B_2; + } + int32_t v37 = (huff_coeff[huff_index] >> 24) & 0x1F; + uint32_t hc = huff_coeff[huff_index]; + int64_t v38 = pixbits << (((hc >> 16) & 0xffffu) & 0x1F); + uint64_t v90 = (uint32_t)(huff_index - v37); + int32_t v39 = (uint16_t)((uint64_t)v38 >> ((uint8_t)v37 - (uint8_t)huff_index)) << ((huff_coeff[huff_index] >> 24) & 0xffu); + + if (huff_index - v37 <= 0) + v39 &= 0xffff0000u; + + int32_t delta1; + if (v38 < 0) + delta1 = (uint16_t)v39; + else if (huff_index) + { + int32_t v40 = -1 << huff_index; + if ((uint8_t)v37) + delta1 = (uint16_t)v39 + v40; + else + delta1 = (uint16_t)v39 + v40 + 1; + } + else + delta1 = 0; + + uint32_t v42 = bitportion - ((huff_coeff[huff_index] >> 16) & 0x1F); + int32_t delta2 = uint8_t(v37) ? 1 << (v37 - 1) : 0; + uint32_t *destpixel = (uint32_t *)(outrowp + 16LL * (col >> 2)); + + int32_t delta = delta1 + delta2; + int32_t col_amp_3 = col & 3; +#define _LIM(a, _max_) (a < 0) ? 0 : ((a > _max_) ? _max_ : a) + if (col_amp_3 == 2) + { + int32_t val = current_base.coeff[1] + delta; + destpixel[1] = uint32_t(_LIM(val, int(datamax))); + } + else if (col_amp_3 == 1) + { + int32_t val = current_base.coeff[2] + delta; + destpixel[2] = uint32_t(_LIM(val, int(datamax))); + } + else if ((col & 3) != 0) // == 3 + { + int32_t val = current_base.coeff[3] + delta; + destpixel[3] = uint32_t(_LIM(val, int(datamax))); + } + else // 0 + { + int32_t val = current_base.coeff[0] + delta; + destpixel[0] = uint32_t(_LIM(val, int(datamax))); + } +#undef _LIM + if (huff_index <= v37) + v90 = 0LL; + bittail = v38 << v90; + bitportion = int32_t(v42 - v90); + + if (col_amp_3 == 3) + current_base.clone((uint32_t *)(outrowp + 16LL * (col >> 2))); + if (col == 3) + line_base.clone((uint32_t *)(outrowp)); + } + + int destrow = current_row * 2; + uint16_t *destrow0 = libraw->imgdata.rawdata.raw_image + (destrow * libraw->imgdata.sizes.raw_width) + left_margin; + uint16_t *destrow1 = + libraw->imgdata.rawdata.raw_image + (destrow + 1) * libraw->imgdata.sizes.raw_width + left_margin; + uint16_t *srcrow = (uint16_t *)(outrowp); + if (gammatable) + { + for (unsigned col = 0; col < width - 1; col += 2) + { + const int c6 = col * 4; + destrow0[col] = gammatable[srcrow[c6]]; + destrow0[col + 1] = gammatable[srcrow[c6 + 2]]; + destrow1[col] = gammatable[srcrow[c6 + 4]]; + destrow1[col + 1] = gammatable[srcrow[c6 + 6]]; + } + } + else + { + for (unsigned col = 0; col < width - 1; col += 2) + { + const int c6 = col * 4; + destrow0[col] = srcrow[c6]; + destrow0[col + 1] = srcrow[c6 + 2]; + destrow1[col] = srcrow[c6 + 4]; + destrow1[col + 1] = srcrow[c6 + 6]; + } + } + } + } + catch (...) // buffer read may throw an exception + { + return false; + } + return true; +} + + +uint32_t pana8_param_t::GetDBit(uint64_t a2) +{ + for (int i = 0; i < 16; i++) + { + if ((a2 & hufftable2[i]) == hufftable1[i]) + return i; + } + return uint32_t((hufftable2[16] & a2) == hufftable1[16]) ^ 0x11u; +} + +pana8_param_t::pana8_param_t(const pana8_tags_t &meta) : gammaTable(0) +{ + range_shift = gamma_base = tag3B = 0; +#ifndef ZERO +#define ZERO(a) memset(a, 0, sizeof(a)) +#endif + ZERO(tag3A); + ZERO(tag39); + ZERO(tag3A); + ZERO(initial); + ZERO(huff_coeff); + ZERO(hufftable1); + ZERO(hufftable2); +#undef ZERO + noGammaFlag = 1; + + for (int i = 0; i < 6; i++) + { + tag3A[i] = meta.tag3A[i]; + tag39[i] = meta.tag39[i]; + } + tag3B_2 = tag3B = meta.tag3B; + for(int i = 0; i < 4; i++) + initial[i] = meta.initial[i]; + + for (int i = 0; i < 17; i++) + huff_coeff[i] = (uint32_t(meta.tag41[i]) << 24) | (uint32_t(meta.tag40a[i]) << 16) | meta.tag40b[i]; + + std::vector tempGamma(0x10000); + for (unsigned i = 0; i < 0x10000; i++) + { + uint64_t val = gammaCurve(i); + tempGamma[i] = uint16_t(val & 0xffffu); + if (i != val) + noGammaFlag = 0; + } + if (!noGammaFlag) + gammaTable = tempGamma; + + int v7 = 0; + + for (unsigned hindex = 0; hindex < 17; hindex++) + { + uint32_t hc = huff_coeff[hindex]; + uint32_t hlow = (hc >> 16) & 0x1F; + int16_t v8 = 0; + if ((hc & 0x1F0000) != 0) + { + int h7 = ((hc >> 16) & 0xffffu) & 7; + if (hlow - 1 >= 7) + { + uint32_t hdiff = h7 - hlow; + v8 = 0; + do + { + v8 = (v8 << 8) | 0xFFu; + hdiff += 8; + } while (hdiff); + } + else + v8 = 0; + for (; h7; --h7) + v8 = 2 * v8 + 1; + } + + uint16_t v9 = hc & v8; + if (uint32_t(v7) < hlow) + v7 = ((huff_coeff[hindex] >> 16) & 0xFFFFu) & 0x1F; + hufftable2[hindex] = 0xFFFFULL << (64-hlow); + hufftable1[hindex] = (uint64_t)v9 << (64-hlow); + } + + if (v7 < 17) + { + if (extrahuff.size() < 0x10000) + extrahuff.resize(0x10000); + uint64_t v17 = 0LL; + + for (int j = 0LL; j != 0x10000; ++j) + { + extrahuff[j] = uint8_t(GetDBit(v17) & 0xffu); + v17 += 0x1000000000000ULL; + } + } +} + +int32_t pana8_param_t::gammaCurve(uint32_t idx) +{ + unsigned int v2 = idx | 0xFFFF0000; + if ((idx & 0x10000) == 0) + v2 = idx & 0x1FFFF; + + int v3 = gamma_base + v2; + unsigned int v4 = MIN(v3, 0xFFFF); + + int v5 = 0; + if ((v4 & 0x80000000) != 0) + v4 = 0; + + if (v4 >= (0xFFFF & tag3A[1])) + { + v5 = 1; + if (v4 >= (0xFFFF & tag3A[2])) + { + v5 = 2; + if (v4 >= (0xFFFF & tag3A[3])) + { + v5 = 3; + if (v4 >= (0xFFFF & tag3A[4])) + v5 = ((v4 | 0x500000000LL) - (uint64_t)(0xFFFF & tag3A[5])) >> 32; + } + } + } + unsigned int v6 = tag3A[v5]; + int v7 = tag39[v5]; + unsigned int v8 = v4 - (uint16_t)v6; + char v9 = v7 & 0x1F; + int64_t result = 0; + + if (v9 == 31) + { + result = v5 == 5 ? 0xFFFFLL : ((tag3A[v5 + 1] >> 16) & 0xFFFF); + return MIN( uint32_t(result), tag3B); + } + if ((v7 & 0x10) == 0) + { + if (v9 == 15) + { + result = ((v6 >> 16) & 0xFFFF); + return MIN( uint32_t(result), tag3B); + } + else if(v9!=0) + v8 = (v8 + (1 << (v9 - 1))) >> v9; + } + else + v8 <<= v7 & 0xF; + + result = v8 + ((v6 >> 16) & 0xFFFF); + return MIN( uint32_t(result), tag3B); +} + +const static uint8_t _bitRevTable[256] = { + 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0, 0x08, 0x88, 0x48, + 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8, 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, + 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4, 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, 0x1C, + 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC, 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, 0x12, 0x92, 0x52, 0xD2, + 0x32, 0xB2, 0x72, 0xF2, 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, + 0xFA, 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6, 0x0E, 0x8E, + 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE, 0x01, 0x81, 0x41, 0xC1, 0x21, + 0xA1, 0x61, 0xE1, 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1, 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, + 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9, 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, 0x15, 0x95, 0x55, + 0xD5, 0x35, 0xB5, 0x75, 0xF5, 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, + 0x7D, 0xFD, 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3, 0x0B, + 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB, 0x07, 0x87, 0x47, 0xC7, + 0x27, 0xA7, 0x67, 0xE7, 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7, 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, + 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF}; + +void invertBits(void *buf, size_t size) +{ + unsigned sz = unsigned(size / 8); + uint64_t *ptr = (uint64_t *)buf; + for (unsigned i = 0; i < sz; i++) + { + uint8_t *b = (uint8_t *)&ptr[i]; + uint64_t r = ((uint64_t)_bitRevTable[b[0]] << 56) | ((uint64_t)_bitRevTable[b[1]] << 48) | + ((uint64_t)_bitRevTable[b[2]] << 40) | ((uint64_t)_bitRevTable[b[3]] << 32) | + ((uint64_t)_bitRevTable[b[4]] << 24) | ((uint64_t)_bitRevTable[b[5]] << 16) | + ((uint64_t)_bitRevTable[b[6]] << 8) | _bitRevTable[b[7]]; + ptr[i] = r; + } +} diff --git a/src/decoders/smal.cpp b/src/decoders/smal.cpp index 2e549906e..eeab2f006 100644 --- a/src/decoders/smal.cpp +++ b/src/decoders/smal.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/decoders/sonycc.cpp b/src/decoders/sonycc.cpp new file mode 100644 index 000000000..7d3cd4174 --- /dev/null +++ b/src/decoders/sonycc.cpp @@ -0,0 +1,318 @@ +/* -*- C++ -*- + * File: sonycc.cpp + * Copyright (C) 2023-2024 Alex Tutubalin, LibRaw LLC + * + Sony YCC (small/medium lossy compressed) decoder + + Code partially backported from DNGLab's rust code + DNGLab was originally created in 2021 by Daniel Vogelbacher. + +LibRaw is free software; you can redistribute it and/or modify +it under the terms of the one of two licenses as you choose: + +1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1 + (See file LICENSE.LGPL provided in LibRaw distribution archive for details). + +2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + (See file LICENSE.CDDL provided in LibRaw distribution archive for details). + + */ + +#include "../../internal/libraw_cxx_defs.h" +#include "../../internal/losslessjpeg.h" +#include +#include + +#define ifp libraw_internal_data.internal_data.input +#define UD libraw_internal_data.unpacker_data +#define S imgdata.sizes + +struct LibRaw_SonyYCC_Decompressor : public LibRaw_LjpegDecompressor +{ + LibRaw_SonyYCC_Decompressor(uint8_t *b, unsigned s): LibRaw_LjpegDecompressor(b,s){} + bool decode_sony(std::vector &dest, int width, int height); + bool decode_sony_ljpeg_420(std::vector &dest, int width, int height); + +}; + +static +#ifdef _MSC_VER + __forceinline +#else + inline +#endif +void copy_yuv_420(uint16_t *out, uint32_t row, uint32_t col, uint32_t width, + int32_t y1, int32_t y2, int32_t y3, int32_t y4, int32_t cb, int32_t cr) +{ + uint32_t pix1 = row * width + col; + uint32_t pix2 = pix1 + 3; + uint32_t pix3 = (row + 1) * width + col; + uint32_t pix4 = pix3 + 3; + + out[pix1 + 0] = uint16_t(y1); + out[pix1 + 1] = uint16_t(cb); + out[pix1 + 2] = uint16_t(cr); + out[pix2 + 0] = uint16_t(y2); + out[pix2 + 1] = uint16_t(cb); + out[pix2 + 2] = uint16_t(cr); + out[pix3 + 0] = uint16_t(y3); + out[pix3 + 1] = uint16_t(cb); + out[pix3 + 2] = uint16_t(cr); + out[pix4 + 0] = uint16_t(y4); + out[pix4 + 1] = uint16_t(cb); + out[pix4 + 2] = uint16_t(cr); +} + + +bool LibRaw_SonyYCC_Decompressor::decode_sony_ljpeg_420(std::vector &_dest, int width, int height) +{ + if (sof.width * 3 != width || sof.height != height) + return false; + if (width % 2 || width % 6 || height % 2) + return false; + if (_dest.size() < width*height) + return false; + + HuffTable &huff1 = dhts[sof.components[0].dc_tbl]; + HuffTable &huff2 = dhts[sof.components[1].dc_tbl]; + HuffTable &huff3 = dhts[sof.components[2].dc_tbl]; + + if (!huff1.initialized || !huff2.initialized || !huff3.initialized) + return false; + + BitPumpJpeg pump(buffer); + + int32_t base = 1 << (sof.precision - point_transform - 1); + int32_t y1 = base + huff1.decode(pump); + int32_t y2 = y1 + huff1.decode(pump); + int32_t y3 = y1 + huff1.decode(pump); + int32_t y4 = y3 + huff1.decode(pump); + + int32_t cb = base + huff2.decode(pump); + int32_t cr = base + huff3.decode(pump); + + uint16_t *dest = _dest.data(); + copy_yuv_420(dest, 0, 0, width, y1, y2, y3, y4, cb, cr); + + for (uint32_t row = 0; row < height; row += 2) + { + uint32_t startcol = row == 0 ? 6 : 0; + for (uint32_t col = startcol; col < width; col += 6) + { + int32_t py1, py3, pcb, pcr; + if (col == 0) + { + uint32_t pos = (row - 2) * width; + py1 = dest[pos]; + py3 = 0; + pcb = dest[pos + 1]; + pcr = dest[pos + 2]; + } + else + { + uint32_t pos1 = row * width + col - 3; + uint32_t pos3 = (row + 1) * width + col - 3; + py1 = dest[pos1]; + py3 = dest[pos3]; + pcb = dest[pos1 + 1]; + pcr = dest[pos1 + 2]; + }; + y1 = py1 + huff1.decode(pump); + y2 = y1 + huff1.decode(pump); + y3 = ((col == 0) ? y1 : py3) + huff1.decode(pump); + y4 = y3 + huff1.decode(pump); + cb = pcb + huff2.decode(pump); + cr = pcr + huff3.decode(pump); + copy_yuv_420(dest, row, col, width, y1, y2, y3, y4, cb, cr); + } + } + return true; +} + +bool LibRaw_SonyYCC_Decompressor::decode_sony(std::vector &dest, int width, int height) +{ + if (sof.components[0].subsample_h == 2 && sof.components[0].subsample_v == 2) + { + return decode_sony_ljpeg_420(dest, width, height); + } + else if (sof.components[0].subsample_h == 2 && sof.components[0].subsample_v == 1) + return decode_ljpeg_422(dest, width, height); + else + return false; +} + +static +#ifdef _MSC_VER + __forceinline +#else + inline +#endif +void copy_ycc(ushort dst[][4], int rawwidth, int rawheight, int destrow0, int destcol0, ushort *src, + int srcwidth, // full array width is 3x + int srcheight, int steph, int stepv) +{ + if (steph < 2 && stepv < 2) + { + for (int tilerow = 0; tilerow < srcheight && destrow0 + tilerow < rawheight; tilerow++) + { + ushort(*destrow)[4] = &dst[(destrow0 + tilerow) * rawwidth + destcol0]; + for (int tilecol = 0; tilecol < srcwidth && tilecol + destcol0 < rawwidth; tilecol++) + { + int pix = (tilerow * srcwidth + tilecol) * 3; + destrow[tilecol][0] = src[pix]; + destrow[tilecol][1] = src[pix + 1] > 8192 ? src[pix + 1] - 8192 : 0; + destrow[tilecol][2] = src[pix + 2] > 8192 ? src[pix + 2] - 8192 : 0; + } + } + } + else + { + for (int tilerow = 0; tilerow < srcheight && destrow0 + tilerow < rawheight; tilerow++) + { + int destrow = destrow0 + tilerow; + ushort(*dest)[4] = &dst[destrow * rawwidth + destcol0]; + for (int tilecol = 0; tilecol < srcwidth && tilecol + destcol0 < rawwidth; tilecol++) + { + int pix = (tilerow * srcwidth + tilecol) * 3; + int destcol = destcol0 + tilecol; + dest[tilecol][0] = src[pix]; + if((destrow%stepv) == 0 && (destcol%steph)==0) + { + dest[tilecol][1] = src[pix + 1] > 8192 ? src[pix + 1] - 8192 : 0; + dest[tilecol][2] = src[pix + 2] > 8192 ? src[pix + 2] - 8192 : 0; + } + } + } + + } +} + +static +#ifdef _MSC_VER + __forceinline +#else + inline +#endif +uint16_t _lim16bit(float q) +{ + if (q < 0.f) + q = 0.f; + else if (q > 65535.f) + q = 65535.f; + return uint16_t(uint32_t(q)); +} + +static +#ifdef _MSC_VER + __forceinline +#else + inline +#endif +void ycc2rgb(uint16_t dst[][4], int rawwidth, int rawheight, int destrow0, int destcol0, ushort *src, + int srcwidth, // full array width is 3x + int srcheight) +{ + const ushort cdelta = 16383; + for (int tilerow = 0; tilerow < srcheight && destrow0 + tilerow < rawheight; tilerow++) + { + ushort(*destrow)[4] = &dst[(destrow0 + tilerow) * rawwidth + destcol0]; + for (int tilecol = 0; tilecol < srcwidth && tilecol + destcol0 < rawwidth; tilecol++) + { + int pix = (tilerow * srcwidth + tilecol) * 3; + float Y = float(src[pix]); + float Cb = float(src[pix + 1] - cdelta); + float Cr = float(src[pix + 2] - cdelta); + float R = Y + 1.40200f * Cr; + float G = Y - 0.34414f * Cb - 0.71414f * Cr; + float B = Y + 1.77200f * Cb; + destrow[tilecol][0] = _lim16bit(R); + destrow[tilecol][1] = _lim16bit(G); + destrow[tilecol][2] = _lim16bit(B); + } + } +} + +void LibRaw::sony_ycbcr_load_raw() +{ + if (!imgdata.image) + throw LIBRAW_EXCEPTION_IO_CORRUPT; + // Sony YCC RAWs are always tiled + if (UD.tile_width < 1 || UD.tile_width > S.raw_width) + throw LIBRAW_EXCEPTION_IO_CORRUPT; + if (UD.tile_length < 1 || UD.tile_length > S.raw_height) + throw LIBRAW_EXCEPTION_IO_CORRUPT; + + // calculate tile count + int tile_w = (S.raw_width + UD.tile_width - 1) / UD.tile_width; + int tile_h = (S.raw_height + UD.tile_length - 1) / UD.tile_length; + int tiles = tile_w * tile_h; + if (tiles < 1 || tiles > 1024) + throw LIBRAW_EXCEPTION_IO_CORRUPT; + + INT64 fsize = ifp->size(); + std::vector toffsets(tiles); + ifp->seek(UD.data_offset, SEEK_SET); // We're already here, but to make sure + for (int i = 0; i < tiles; i++) + toffsets[i] = get4(); + + std::vector tlengths(tiles); + ifp->seek(UD.data_size, SEEK_SET); + for (int i = 0; i < tiles; i++) + { + tlengths[i] = get4(); + if(toffsets[i]+tlengths[i] > fsize) + throw LIBRAW_EXCEPTION_IO_CORRUPT; + } + unsigned maxcomprlen = *std::max_element(tlengths.begin(), tlengths.end()); + + std::vector iobuffer(maxcomprlen+1); // Extra byte to ensure LJPEG byte stream marker search is ok + std::vector tilebuffer; + for (int tile = 0; tile < tiles; tile++) + { + ifp->seek(toffsets[tile],SEEK_SET); + int readed = ifp->read(iobuffer.data(), 1, tlengths[tile]); + if(readed != tlengths[tile]) + throw LIBRAW_EXCEPTION_IO_EOF; + LibRaw_SonyYCC_Decompressor dec(iobuffer.data(), readed); + if(dec.sof.cps != 3) // !YUV + throw LIBRAW_EXCEPTION_IO_CORRUPT; + if(dec.state != LibRaw_LjpegDecompressor::State::OK) + throw LIBRAW_EXCEPTION_IO_CORRUPT; + + unsigned tiledatatsize = UD.tile_width * UD.tile_length * 3; + if (tilebuffer.size() < tiledatatsize) + tilebuffer.resize(tiledatatsize); + + if(!dec.decode_sony(tilebuffer, UD.tile_width * 3, UD.tile_length)) + throw LIBRAW_EXCEPTION_IO_CORRUPT; + + int tilerow = tile / tile_w; + int tilecol = tile % tile_w; + if (imgdata.rawparams.specials & LIBRAW_RAWSPECIAL_SRAW_NO_RGB) + { + if(imgdata.rawparams.specials & LIBRAW_RAWSPECIAL_SRAW_NO_INTERPOLATE) + copy_ycc(imgdata.image, S.raw_width, S.raw_height, tilerow * UD.tile_length, tilecol * UD.tile_width, + tilebuffer.data(), UD.tile_width, UD.tile_length, dec.sof.components[0].subsample_h, dec.sof.components[0].subsample_v); + else + copy_ycc(imgdata.image, S.raw_width, S.raw_height, tilerow * UD.tile_length, tilecol * UD.tile_width, + tilebuffer.data(), UD.tile_width, UD.tile_length, 1, 1); + } + else + ycc2rgb(imgdata.image, S.raw_width, S.raw_height, tilerow * UD.tile_length, tilecol * UD.tile_width, + tilebuffer.data(), UD.tile_width, UD.tile_length); + } + + for (int i = 0; i < 6; i++) + imgdata.color.cblack[i] = 0; + + if (imgdata.rawparams.specials & LIBRAW_RAWSPECIAL_SRAW_NO_RGB) + { + imgdata.color.maximum = 18091; // estimated on over-exposed ISO100 frame + imgdata.color.black = 0; + } + else + { + imgdata.color.maximum = 17536; // estimated on over-exposed ISO100 frame + imgdata.color.black = 1024; + } +} diff --git a/src/decoders/unpack.cpp b/src/decoders/unpack.cpp index 38adba453..c4f3359e7 100644 --- a/src/decoders/unpack.cpp +++ b/src/decoders/unpack.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: @@ -167,8 +167,10 @@ int LibRaw::unpack(void) throw "Size mismatch"; // DECODED w/ success - if (rs3ret.filters>1) // Fuji or bayer - imgdata.rawdata.raw_image = (ushort*)rs3ret.pixeldata; + if (rs3ret.filters > 1) // Fuji or bayer + { + imgdata.rawdata.raw_image = (ushort*)rs3ret.pixeldata; + } else if (rs3ret.cpp == 4) { imgdata.rawdata.color4_image = (ushort(*)[4])rs3ret.pixeldata; @@ -189,6 +191,16 @@ int LibRaw::unpack(void) S.raw_width = rs3ret.width; S.raw_height = rs3ret.height; imgdata.process_warnings |= LIBRAW_WARN_RAWSPEED3_PROCESSED; + + if (imgdata.rawdata.raw_image && + load_raw == &LibRaw::phase_one_load_raw_c && imgdata.color.phase_one_data.format != 8) + { + // Scale data to match libraw own decoder + for (int row = 0; row < rs3ret.height; row++) + for (int col = 0; col < rs3ret.pitch / 2; col++) + imgdata.rawdata.raw_image[row * rs3ret.pitch / 2 + col] <<= 2; + } + // if (r->whitePoint > 0 && r->whitePoint < 65536) // C.maximum = r->whitePoint; } diff --git a/src/decoders/unpack_thumb.cpp b/src/decoders/unpack_thumb.cpp index 4298c3750..1082b9326 100644 --- a/src/decoders/unpack_thumb.cpp +++ b/src/decoders/unpack_thumb.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: @@ -92,12 +92,34 @@ int LibRaw::unpack_thumb(void) { return LIBRAW_NO_THUMBNAIL; } + else if (Tformat == LIBRAW_INTERNAL_THUMBNAIL_DNG_YCBCR) + { + try + { + dng_ycbcr_thumb_loader(); + T.tformat = LIBRAW_THUMBNAIL_BITMAP; + T.tcolors = 3; + SET_PROC_FLAG(LIBRAW_PROGRESS_THUMB_LOAD); + } + catch (...) + { + return LIBRAW_NO_THUMBNAIL; + } + return 0; + + } else if ((Tformat >= LIBRAW_INTERNAL_THUMBNAIL_KODAK_THUMB) && ((Tformat <= LIBRAW_INTERNAL_THUMBNAIL_KODAK_RGB))) { - kodak_thumb_loader(); - T.tformat = LIBRAW_THUMBNAIL_BITMAP; - SET_PROC_FLAG(LIBRAW_PROGRESS_THUMB_LOAD); + try { + kodak_thumb_loader(); + T.tformat = LIBRAW_THUMBNAIL_BITMAP; + SET_PROC_FLAG(LIBRAW_PROGRESS_THUMB_LOAD); + } + catch (...) + { + return LIBRAW_NO_THUMBNAIL; + } return 0; } else @@ -107,10 +129,11 @@ int LibRaw::unpack_thumb(void) { INT64 tsize = x3f_thumb_size(); if (tsize < 2048 || INT64(ID.toffset) + tsize < 1) - throw LIBRAW_EXCEPTION_IO_CORRUPT; + return LIBRAW_NO_THUMBNAIL; if (INT64(ID.toffset) + tsize > ID.input->size() + THUMB_READ_BEYOND) - throw LIBRAW_EXCEPTION_IO_EOF; + return LIBRAW_NO_THUMBNAIL; + THUMB_SIZE_CHECKT(tsize); } #else @@ -119,22 +142,30 @@ int LibRaw::unpack_thumb(void) else { if (INT64(ID.toffset) + INT64(T.tlength) < 1) - throw LIBRAW_EXCEPTION_IO_CORRUPT; + return LIBRAW_NO_THUMBNAIL; if (INT64(ID.toffset) + INT64(T.tlength) > ID.input->size() + THUMB_READ_BEYOND) - throw LIBRAW_EXCEPTION_IO_EOF; + return LIBRAW_NO_THUMBNAIL; } ID.input->seek(ID.toffset, SEEK_SET); - if (Tformat == LIBRAW_INTERNAL_THUMBNAIL_JPEG) + if (Tformat == LIBRAW_INTERNAL_THUMBNAIL_JPEG || Tformat == LIBRAW_INTERNAL_THUMBNAIL_JPEGXL) { THUMB_SIZE_CHECKTNZ(T.tlength); if (T.thumb) free(T.thumb); T.thumb = (char *)malloc(T.tlength); + if(!T.thumb) + return LIBRAW_NO_THUMBNAIL; ID.input->read(T.thumb, 1, T.tlength); unsigned char *tthumb = (unsigned char *)T.thumb; + if (Tformat == LIBRAW_INTERNAL_THUMBNAIL_JPEGXL) + { + T.tformat = LIBRAW_THUMBNAIL_JPEGXL; + SET_PROC_FLAG(LIBRAW_PROGRESS_THUMB_LOAD); + return 0; + } if (load_raw == &LibRaw::crxLoadRaw && T.tlength > 0xE0) { // Check if it is canon H.265 preview: CISZ at bytes 4-6, CISZ prefix is 000n @@ -195,7 +226,15 @@ int LibRaw::unpack_thumb(void) if (T.thumb) free(T.thumb); T.thumb = (char *)calloc(colors, tlength); + if(!T.thumb) + return LIBRAW_NO_THUMBNAIL; unsigned char *tbuf = (unsigned char *)calloc(colors, tlength); + if (!tbuf) + { + free(T.thumb); + T.thumb = 0; + return LIBRAW_NO_THUMBNAIL; + } // Avoid OOB of tbuf, should use tlength ID.input->read(tbuf, colors, tlength); if (libraw_internal_data.unpacker_data.thumb_misc >> 8 && @@ -236,24 +275,39 @@ int LibRaw::unpack_thumb(void) free(T.thumb); T.tcolors = 3; T.thumb = (char *)calloc(T.tcolors, tlength); + if (!T.thumb) + return LIBRAW_NO_THUMBNAIL; unsigned short *tbuf = (unsigned short *)calloc(2, tlength); - read_shorts(tbuf, tlength); - for (i = 0; i < tlength; i++) + if (!tbuf) { - T.thumb[i * 3] = (tbuf[i] << 3) & 0xff; - T.thumb[i * 3 + 1] = (tbuf[i] >> 5 << 2) & 0xff; - T.thumb[i * 3 + 2] = (tbuf[i] >> 11 << 3) & 0xff; + free(T.thumb); + T.thumb = 0; + return LIBRAW_NO_THUMBNAIL; } - free(tbuf); - T.tlength = T.tcolors * tlength; - T.tformat = LIBRAW_THUMBNAIL_BITMAP; - SET_PROC_FLAG(LIBRAW_PROGRESS_THUMB_LOAD); + try { + read_shorts(tbuf, tlength); + for (i = 0; i < tlength; i++) + { + T.thumb[i * 3] = (tbuf[i] << 3) & 0xff; + T.thumb[i * 3 + 1] = (tbuf[i] >> 5 << 2) & 0xff; + T.thumb[i * 3 + 2] = (tbuf[i] >> 11 << 3) & 0xff; + } + free(tbuf); + T.tlength = T.tcolors * tlength; + T.tformat = LIBRAW_THUMBNAIL_BITMAP; + SET_PROC_FLAG(LIBRAW_PROGRESS_THUMB_LOAD); + } + catch (...) + { + free(tbuf); + return LIBRAW_NO_THUMBNAIL; + } return 0; } else if (Tformat == LIBRAW_INTERNAL_THUMBNAIL_PPM) { if (t_bytesps > 1) - throw LIBRAW_EXCEPTION_IO_CORRUPT; // 8-bit thumb, but parsed for more + return LIBRAW_NO_THUMBNAIL; // 8-bit thumb, but parsed for more // bits THUMB_SIZE_CHECKWH(T.twidth, T.theight); int t_length = T.twidth * T.theight * t_colors; @@ -282,6 +336,8 @@ int LibRaw::unpack_thumb(void) if (T.thumb) free(T.thumb); T.thumb = (char *)malloc(T.tlength); + if (!T.thumb) + return LIBRAW_NO_THUMBNAIL; char *dest = T.thumb; INT64 pos = ID.input->tell(); @@ -316,6 +372,8 @@ int LibRaw::unpack_thumb(void) THUMB_SIZE_CHECKTNZ(T.tlength); T.thumb = (char *)malloc(T.tlength); + if (!T.thumb) + return LIBRAW_NO_THUMBNAIL; if (!T.tcolors) T.tcolors = t_colors; @@ -328,7 +386,7 @@ int LibRaw::unpack_thumb(void) else if (Tformat == LIBRAW_INTERNAL_THUMBNAIL_PPM16) { if (t_bytesps > 2) - throw LIBRAW_EXCEPTION_IO_CORRUPT; // 16-bit thumb, but parsed for + return LIBRAW_NO_THUMBNAIL; // 16-bit thumb, but parsed for // more bits int o_bps = (imgdata.rawparams.options & LIBRAW_RAWOPTIONS_USE_PPM16_THUMBS) ? 2 : 1; int o_length = T.twidth * T.theight * t_colors * o_bps; @@ -338,8 +396,8 @@ int LibRaw::unpack_thumb(void) THUMB_SIZE_CHECKTNZ(i_length); ushort *t_thumb = (ushort *)calloc(i_length, 1); - if (!t_thumb) - throw LIBRAW_EXCEPTION_ALLOC; + if (!t_thumb) + return LIBRAW_NO_THUMBNAIL;; ID.input->read(t_thumb, 1, i_length); if ((libraw_internal_data.unpacker_data.order == 0x4949) == (ntohs(0x1234) == 0x1234)) @@ -356,8 +414,11 @@ int LibRaw::unpack_thumb(void) else { T.thumb = (char *)malloc(o_length); - if (!T.thumb) - throw LIBRAW_EXCEPTION_ALLOC; + if (!T.thumb) + { + free(t_thumb); + return LIBRAW_NO_THUMBNAIL; + } for (int i = 0; i < o_length; i++) T.thumb[i] = t_thumb[i] >> 8; free(t_thumb); @@ -370,7 +431,7 @@ int LibRaw::unpack_thumb(void) #ifdef USE_X3FTOOLS else if (Tformat == LIBRAW_INTERNAL_THUMBNAIL_X3F) { - x3f_thumb_loader(); + x3f_thumb_loader(); // errors already catched in this call SET_PROC_FLAG(LIBRAW_PROGRESS_THUMB_LOAD); return 0; } diff --git a/src/decompressors/losslessjpeg.cpp b/src/decompressors/losslessjpeg.cpp new file mode 100644 index 000000000..538c2cb23 --- /dev/null +++ b/src/decompressors/losslessjpeg.cpp @@ -0,0 +1,391 @@ +/* -*- C++ -*- + * File: huffmandec.cpp + * Copyright (C) 2023-2024 Alex Tutubalin, LibRaw LLC + * + Lossless JPEG decoder + + Code partially backported from DNGLab's rust code + DNGLab was originally created in 2021 by Daniel Vogelbacher. + +LibRaw is free software; you can redistribute it and/or modify +it under the terms of the one of two licenses as you choose: + +1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1 + (See file LICENSE.LGPL provided in LibRaw distribution archive for details). + +2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + (See file LICENSE.CDDL provided in LibRaw distribution archive for details). + + */ + +#include "../../internal/losslessjpeg.h" +#include + +#define ZERO(a) do { memset(a,0,sizeof(a));} while(0) + +bool ByteStreamBE::skip_to_marker() // true: success, false - no marker +{ + if (pos + 2 > size) return false; + while (!(buffer[pos] == 0xff && buffer[pos + 1] != 0 && buffer[pos + 1] != 0xff)) + { + pos++; + if (pos + 2 > size) + return false; + } + pos++; + return true; +} + +LibRaw_LjpegDecompressor::LibRaw_LjpegDecompressor(uint8_t *b, unsigned bs, bool dngbug, bool csfix): buffer(b,bs), + state(State::NotInited) +{ + initialize(dngbug,csfix); +} + +LibRaw_LjpegDecompressor::LibRaw_LjpegDecompressor(uint8_t *b, unsigned bs): buffer(b,bs), + state(State::NotInited) +{ + initialize(false,false); +} + + +void LibRaw_LjpegDecompressor::initialize(bool dngbug, bool csfix) +{ + sof.csfix = csfix; + bool dht_init[4] = { false,false,false,false }; + uint32_t dht_bits[4][17]; + uint32_t dht_huffval[4][256]; + ZERO(dht_bits); + ZERO(dht_huffval); + if (next_marker(false) != Marker::SOI) + { + state = State::NoSOI; + return; + } + while (1) + { + uint8_t marker = next_marker(true); + if (marker == Marker::SOF3) + { + if (!sof.parse_sof(buffer)) + { + state = State::InvalidSOF; + return; + } + if (sof.precision > 16 || sof.precision < 12) + { + state = State::IncorrectPrecision; + return; + } + } + else if (marker == Marker::DHT) + { + bool hres = parse_dht(dht_init, dht_bits, dht_huffval); + if(!hres) + { + state = State::InvalidDHT; + return; + } + } + else if ( marker == Marker::SOS) + { + uint32_t val = sof.parse_sos(buffer); + if (val < 0x10000) + { + predictor = (val >> 8) & 0xff; + point_transform = val & 0xff; + } + else + { + state = State::InvalidSOS; + return; + } + break; + } + else if (marker == Marker::EOI) + { + state = State::EOIReached; + return; + } + else if (marker == Marker::DQT) + { + state = State::DQTPresent; + return; + } + else if(marker == Marker::Fill) + { + state = State::EOIReached; + return; + } + } + + dhts.resize(4); + for (int i = 0; i < 4; i++) + if (dht_init[i]) + dhts[i].initval(dht_bits[i], dht_huffval[i], dngbug); + datastart = buffer.pos; + state = State::OK; +} + +uint8_t LibRaw_LjpegDecompressor::next_marker(bool allowskip) +{ + if (!allowskip) + { + if (buffer.get_u8() != 0xff) + return Marker::Fill; // Error; + uint8_t mark = buffer.get_u8(); + return mark; + } + if (buffer.skip_to_marker()) + return buffer.get_u8(); + else + return Marker::Fill; +} + +bool LibRaw_LjpegDecompressor::parse_dht(bool init[4], uint32_t bits[4][17], uint32_t huffval[4][256]) +{ + uint16_t length = buffer.get_u16() - 2u; + + while (length > 0) + { + uint8_t b = buffer.get_u8(); + uint8_t tc = b >> 4; + uint8_t th = b & 0xf; + + if (tc != 0) + return false; + + if (th > 3) + return false; + + uint32_t acc = 0; + for (int i = 0; i < 16; i++) + { + bits[th][i + 1] = buffer.get_u8(); + acc += bits[th][i + 1]; + } + bits[th][0] = 0; + + if (acc > 256) + return false; + + if (length < 1 + 16 + acc) + return 0xff; + for (int i = 0; i < acc; i++) + huffval[th][i] = buffer.get_u8(); + + init[th] = true; + length -= 1 + 16 + acc; + } + return true; +} + +static +#ifdef _MSC_VER +__forceinline +#else +inline +#endif +void copy_yuv_422(uint16_t *out, uint32_t row, uint32_t col, uint32_t width, int32_t y1, int32_t y2, + int32_t cb, int32_t cr) +{ + uint32_t pix1 = row * width + col; + uint32_t pix2 = pix1 + 3; + out[pix1 + 0] = uint16_t(y1); + out[pix1 + 1] = uint16_t(cb); + out[pix1 + 2] = uint16_t(cr); + out[pix2 + 0] = uint16_t(y2); + out[pix2 + 1] = uint16_t(cb); + out[pix2 + 2] = uint16_t(cr); +} + + +bool LibRaw_LjpegDecompressor::decode_ljpeg_422(std::vector &_dest, int width, int height) +{ + if (sof.width * 3 != width || sof.height != height) + return false; + if (width % 2 || width % 6 || height % 2) + return false; + + if (_dest.size() < width * height) + return false; + + uint16_t *dest = _dest.data(); + + HuffTable &h1 = dhts[sof.components[0].dc_tbl]; + HuffTable &h2 = dhts[sof.components[1].dc_tbl]; + HuffTable &h3 = dhts[sof.components[2].dc_tbl]; + + if (!h1.initialized || !h2.initialized || !h3.initialized) + return false; + + BitPumpJpeg pump(buffer); + + int32_t base = 1 << (sof.precision - point_transform - 1); + int32_t y1 = base + h1.decode(pump); + int32_t y2 = y1 + h1.decode(pump); + int32_t cb = base + h2.decode(pump); + int32_t cr = base + h3.decode(pump); + copy_yuv_422(dest, 0, 0, width, y1, y2, cb, cr); + + for (uint32_t row = 0; row < height; row++) + { + uint32_t startcol = row == 0 ? 6 : 0; + for (uint32_t col = startcol; col < width; col += 6) + { + uint32_t pos = (col == 0) ? (row - 1) * width : row * width + col - 3; + int32_t py = dest[pos], + pcb = dest[pos + 1], + pcr = dest[pos + 2]; + int32_t y1 = py + h1.decode(pump); + int32_t y2 = y1 + h1.decode(pump); + int32_t cb = pcb + h2.decode(pump); + int32_t cr = pcr + h3.decode(pump); + copy_yuv_422(dest, row, col, width, y1, y2, cb, cr); + } + } + return true; +} + +bool LibRaw_SOFInfo::parse_sof(ByteStreamBE& input) +{ + uint32_t header_length = input.get_u16(); + precision = input.get_u8(); + height = input.get_u16(); + width = input.get_u16(); + cps = input.get_u8(); + + if (precision > 16) + return false; + if (cps > 4 || cps < 1) + return false; + if (header_length != 8 + cps * 3) + return false; + + components.clear(); + for (int i = 0; i < cps; i++) + { + unsigned id = input.get_u8(); + unsigned subs = input.get_u8(); + components.push_back(LibRaw_JpegComponentInfo(id, i, 0, (subs >> 4), (subs & 0xf) )); + input.get_u8(); + } + return true; +} + +uint32_t LibRaw_SOFInfo::parse_sos(ByteStreamBE& input) +{ + if (width == 0) + return 0x10000; + + input.get_u16(); + + uint32_t soscps = input.get_u8(); + if (cps != soscps) + return 0x10000; + for (uint32_t csi = 0; csi < cps; csi++) + { + uint32_t readcs = input.get_u8(); + uint32_t cs = csfix ? csi : readcs; // csfix might be used in MOS decoder + int cid = -1; + for(int c = 0; c < components.size(); c++) + if (components[c].id == cs) + { + cid = c; + break; + } + if (cid < 0) + return 0x10000; + + uint8_t td = input.get_u8() >> 4; + if (td > 3) + return 0x10000; + components[cid].dc_tbl = td; + } + uint8_t pred = input.get_u8(); + input.get_u8(); + uint8_t pt = input.get_u8() & 0xf; + return (pred << 8 | pt); +} + +HuffTable::HuffTable() +{ + ZERO(bits); + ZERO(huffval); + ZERO(shiftval); + dng_bug = false; + disable_cache = false; + nbits = 0; + initialized = false; +} + +struct PseudoPump : public BitPump +{ + uint64_t bits; + int32_t nbits; + PseudoPump() : bits(0), nbits(0) {} + + void set(uint32_t _bits, uint32_t nb) + { + bits = uint64_t(_bits) << 32; + nbits = nb + 32; + } + int32_t valid() { return nbits - 32; } + + uint32_t peek(uint32_t num) + { + return uint32_t((bits >> (nbits - num)) & 0xffffffffUL); + } + + void consume(uint32_t num) + { + nbits -= num; + bits &= (uint64_t(1) << nbits) - 1UL; + } +}; + +void HuffTable::initval(uint32_t _bits[17], uint32_t _huffval[256], bool _dng_bug) +{ + memmove(bits, _bits, sizeof(bits)); + memmove(huffval, _huffval, sizeof(huffval)); + dng_bug = _dng_bug; + + nbits = 16; + for(int i = 0; i < 16; i++) + { + if(bits[16 - i] != 0) + break; + nbits--; + } + hufftable.resize(1 << nbits); + for (int i = 0; i < hufftable.size(); i++) hufftable[i] = 0; + + int h = 0; + int pos = 0; + for (uint8_t len = 0; len < nbits; len++) + { + for (int i = 0; i < bits[len + 1]; i++) + { + for (int j = 0; j < (1 << (nbits - len - 1)); j++) + { + hufftable[h] = ((len+1) << 16) | (uint8_t(huffval[pos] & 0xff) << 8) | uint8_t(shiftval[pos] & 0xff); + h++; + } + pos++; + } + } + if (!disable_cache) + { + PseudoPump pump; + decodecache = std::vector(1 << LIBRAW_DECODE_CACHE_BITS,0); + for(uint32_t i = 0; i < 1 << LIBRAW_DECODE_CACHE_BITS; i++) + { + pump.set(i, LIBRAW_DECODE_CACHE_BITS); + uint32_t len; + int16_t val16 = int16_t(decode_slow2(pump,len)); + if (pump.valid() >= 0) + decodecache[i] = LIBRAW_CACHE_PRESENT_FLAG | uint64_t(((len & 0xff) << 16) | uint16_t(val16)); + } + } + initialized = true; +} diff --git a/src/demosaic/ahd_demosaic.cpp b/src/demosaic/ahd_demosaic.cpp index e743c96af..8d32d6cd1 100644 --- a/src/demosaic/ahd_demosaic.cpp +++ b/src/demosaic/ahd_demosaic.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/demosaic/misc_demosaic.cpp b/src/demosaic/misc_demosaic.cpp index d23e494d0..76b837860 100644 --- a/src/demosaic/misc_demosaic.cpp +++ b/src/demosaic/misc_demosaic.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/demosaic/xtrans_demosaic.cpp b/src/demosaic/xtrans_demosaic.cpp index 2d96c62ef..8bd1842c4 100644 --- a/src/demosaic/xtrans_demosaic.cpp +++ b/src/demosaic/xtrans_demosaic.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/integration/dngsdk_glue.cpp b/src/integration/dngsdk_glue.cpp index 494383676..0d0a9e8e3 100644 --- a/src/integration/dngsdk_glue.cpp +++ b/src/integration/dngsdk_glue.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: @@ -12,8 +12,18 @@ */ +#define LIBRAW_DNGSDK_CONFLICT 1 + #include "../../internal/libraw_cxx_defs.h" +#ifdef USE_DNGSDK +#include "dng_host.h" +#include "dng_negative.h" +#include "dng_simple_image.h" +#include "dng_info.h" +#endif + + #if defined (USE_GPRSDK) && !defined(USE_DNGSDK) #error GPR (GoPro) SDK should be used with Adobe DNG SDK #endif @@ -83,6 +93,19 @@ int LibRaw::valid_for_dngsdk() if (!imgdata.idata.dng_version) return 0; +#ifdef qDNGSupportJXL + if (libraw_internal_data.unpacker_data.tiff_compress == 52546) // regardless of flags or use_dngsdk value! + { +#ifdef qDNGSupportJXL + if (dngVersion_Current >= dngVersion_1_7_0_0) + return 1; + else +#endif + return 0; // Old DNG SDK + } +#endif + + // All DNG larger than 2GB - to DNG SDK if (libraw_internal_data.internal_data.input->size() > 2147483647ULL) return 1; @@ -95,7 +118,7 @@ int LibRaw::valid_for_dngsdk() if (libraw_internal_data.unpacker_data.tiff_compress == 34892 && libraw_internal_data.unpacker_data.tiff_bps == 8 - && libraw_internal_data.unpacker_data.tiff_samples == 3 + && (libraw_internal_data.unpacker_data.tiff_samples == 3 || libraw_internal_data.unpacker_data.tiff_samples == 1) && load_raw == &LibRaw::lossy_dng_load_raw ) { @@ -116,11 +139,13 @@ int LibRaw::valid_for_dngsdk() dng_ifd *rawIFD = search_for_ifd(info, libraw_internal_data.unpacker_data.data_offset, imgdata.sizes.raw_width, imgdata.sizes.raw_height, ifdindex,stream); if (rawIFD && ifdindex >= 0 && ifdindex == info.fMainIndex) return 1; + if (rawIFD && ifdindex >= 0 && (imgdata.rawparams.options & LIBRAW_RAWOPTIONS_DNG_ADD_PREVIEWS)) + return 1; return 0; } #ifdef USE_GPRSDK - if (load_raw == &LibRaw::vc5_dng_load_raw_placeholder) // regardless of flags or use_dngsdk value! + if (libraw_internal_data.unpacker_data.tiff_compress == 9) // regardless of flags or use_dngsdk value! return 1; #endif if (!imgdata.rawparams.use_dngsdk) @@ -184,39 +209,64 @@ int LibRaw::try_dngsdk() return LIBRAW_DATA_ERROR; AutoPtr stage2; - bool stage23used = false; + unsigned stageBits = 0; // 1=> release Stage2, 2=> change Black/Max bool zerocopy = false; - //(new dng_simple_image(rawIFD->Bounds(), rawIFD->fSamplesPerPixel, rawIFD->PixelType(), host->Allocator())); - - if (((libraw_internal_data.unpacker_data.tiff_compress == 34892 + if ( +#ifdef USE_GPRSDK + libraw_internal_data.unpacker_data.tiff_compress != 9 && +#endif + ( + ((libraw_internal_data.unpacker_data.tiff_compress == 34892 && libraw_internal_data.unpacker_data.tiff_bps == 8 && libraw_internal_data.unpacker_data.tiff_samples == 3 - && load_raw == &LibRaw::lossy_dng_load_raw) + && load_raw == &LibRaw::lossy_dng_load_raw) // JPEG DNG or JPEG DNG RAW Preview || (imgdata.rawparams.options & (LIBRAW_RAWOPTIONS_DNG_STAGE2| LIBRAW_RAWOPTIONS_DNG_STAGE3)) || ((tiff_ifd[ifdindex].dng_levels.parsedfields & (LIBRAW_DNGFM_OPCODE2| LIBRAW_DNGFM_OPCODE3)) && (imgdata.rawparams.options & (LIBRAW_RAWOPTIONS_DNG_STAGE2_IFPRESENT | LIBRAW_RAWOPTIONS_DNG_STAGE3_IFPRESENT))) ) && ifdindex >= 0) + ) { if (info.fMainIndex != ifdindex) info.fMainIndex = ifdindex; - negative->ReadStage1Image(*host, stream, info); - negative->BuildStage2Image(*host); - imgdata.process_warnings |= LIBRAW_WARN_DNG_STAGE2_APPLIED; - if ( (imgdata.rawparams.options & LIBRAW_RAWOPTIONS_DNG_STAGE3) || - ((tiff_ifd[ifdindex].dng_levels.parsedfields & LIBRAW_DNGFM_OPCODE3) && - (imgdata.rawparams.options & LIBRAW_RAWOPTIONS_DNG_STAGE3_IFPRESENT)) - ) + if (rawIFD->fNewSubFileType == 1) // Preview { - negative->BuildStage3Image(*host); - stage2.Reset((dng_simple_image*)negative->Stage3Image()); - imgdata.process_warnings |= LIBRAW_WARN_DNG_STAGE3_APPLIED; + dng_read_image reader; + AutoPtr copy2; + negative->ReadStage1Image(*host, stream, info); // Read image AND opcodes lists + copy2.Reset((dng_simple_image*) negative->Stage1Image()); + host->ApplyOpcodeList(negative->OpcodeList1(), *negative,copy2); + stageBits = 1; + if ((imgdata.rawparams.options & LIBRAW_RAWOPTIONS_DNG_STAGE2) + || ((tiff_ifd[ifdindex].dng_levels.parsedfields & LIBRAW_DNGFM_OPCODE2) && (imgdata.rawparams.options & LIBRAW_RAWOPTIONS_DNG_STAGE2_IFPRESENT)) + ) + { + host->ApplyOpcodeList(negative->OpcodeList2(), *negative, copy2); + stageBits |= 2; + } + stage2.Reset((dng_simple_image *)copy2.Get()); + copy2.Release(); } else - stage2.Reset((dng_simple_image*)negative->Stage2Image()); - stage23used = true; + { + negative->ReadStage1Image(*host, stream, info); + negative->BuildStage2Image(*host); + imgdata.process_warnings |= LIBRAW_WARN_DNG_STAGE2_APPLIED; + if ((imgdata.rawparams.options & LIBRAW_RAWOPTIONS_DNG_STAGE3) || + ((tiff_ifd[ifdindex].dng_levels.parsedfields & LIBRAW_DNGFM_OPCODE3) && + (imgdata.rawparams.options & LIBRAW_RAWOPTIONS_DNG_STAGE3_IFPRESENT)) + ) + { + negative->BuildStage3Image(*host); + stage2.Reset((dng_simple_image*)negative->Stage3Image()); + imgdata.process_warnings |= LIBRAW_WARN_DNG_STAGE3_APPLIED; + } + else + stage2.Reset((dng_simple_image*)negative->Stage2Image()); + stageBits = 3; + } } else { @@ -256,7 +306,7 @@ int LibRaw::try_dngsdk() return LIBRAW_DATA_ERROR; } } - if (stage23used) + if (stageBits & 2) { if (stage2->Planes() > 1) { @@ -277,7 +327,7 @@ int LibRaw::try_dngsdk() int pixels = stage2->Bounds().H() * stage2->Bounds().W() * pplanes; - if (ptype == ttShort && !stage23used && !is_curve_linear()) + if (ptype == ttShort && !(stageBits & 1) && !is_curve_linear()) { imgdata.rawdata.raw_alloc = malloc(pixels * TagTypeSize(ptype)); ushort *src = (ushort *)buffer.fData; @@ -307,7 +357,7 @@ int LibRaw::try_dngsdk() else { // Alloc - if ((imgdata.rawparams.options & LIBRAW_RAWOPTIONS_DNGSDK_ZEROCOPY) && !stage23used) + if ((imgdata.rawparams.options & LIBRAW_RAWOPTIONS_DNGSDK_ZEROCOPY) && !(stageBits & 1)) { zerocopy = true; } @@ -320,7 +370,7 @@ int LibRaw::try_dngsdk() S.raw_pitch = S.raw_width * pplanes * TagTypeSize(ptype); } - if (stage23used) + if (stageBits & 1) stage2.Release(); if ((ptype == ttFloat) && (imgdata.rawparams.options & LIBRAW_RAWOPTIONS_CONVERTFLOAT_TO_INT)) diff --git a/src/integration/rawspeed_glue.cpp b/src/integration/rawspeed_glue.cpp index 42561e7b8..90d461190 100644 --- a/src/integration/rawspeed_glue.cpp +++ b/src/integration/rawspeed_glue.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: @@ -12,17 +12,47 @@ */ +#define LIBRAW_EXPAT_CONFLICT #include "../../internal/libraw_cxx_defs.h" -#ifdef USE_RAWSPEED -using namespace RawSpeed; -CameraMetaDataLR::CameraMetaDataLR(char *data, int sz) : CameraMetaData() +#ifdef USE_RAWSPEED +#include +#include +#include +#include +#include +#include + +#include "../../RawSpeed/rawspeed_xmldata.cpp" +const int RAWSPEED_DATA_COUNT = (sizeof(_rawspeed_data_xml) / sizeof(_rawspeed_data_xml[0])); + + +class CameraMetaDataLR : public RawSpeed::CameraMetaData +{ +public: + CameraMetaDataLR() : CameraMetaData() {} + CameraMetaDataLR(char *filename) : RawSpeed::CameraMetaData(filename) {} + CameraMetaDataLR(char *data, int sz); +}; + + +#define P1 imgdata.idata +#define S imgdata.sizes +#define O imgdata.params +#define C imgdata.color +#define T imgdata.thumbnail +#define MN imgdata.makernotes +#define IO libraw_internal_data.internal_output_params +#define ID libraw_internal_data.internal_data + + +CameraMetaDataLR::CameraMetaDataLR(char *data, int sz) : RawSpeed::CameraMetaData() { ctxt = xmlNewParserCtxt(); if (ctxt == NULL) { - ThrowCME("CameraMetaData:Could not initialize context."); + RawSpeed::ThrowCME("CameraMetaData:Could not initialize context."); } xmlResetLastError(); @@ -30,7 +60,7 @@ CameraMetaDataLR::CameraMetaDataLR(char *data, int sz) : CameraMetaData() if (doc == NULL) { - ThrowCME("CameraMetaData: XML Document could not be parsed successfully. " + RawSpeed::ThrowCME("CameraMetaData: XML Document could not be parsed successfully. " "Error was: %s", ctxt->lastError.message); } @@ -43,7 +73,7 @@ CameraMetaDataLR::CameraMetaDataLR(char *data, int sz) : CameraMetaData() } else { - ThrowCME("CameraMetaData: XML file does not validate. DTD Error was: %s", + RawSpeed::ThrowCME("CameraMetaData: XML file does not validate. DTD Error was: %s", ctxt->lastError.message); } } @@ -52,7 +82,7 @@ CameraMetaDataLR::CameraMetaDataLR(char *data, int sz) : CameraMetaData() cur = xmlDocGetRootElement(doc); if (xmlStrcmp(cur->name, (const xmlChar *)"Cameras")) { - ThrowCME("CameraMetaData: XML document of the wrong type, root node is not " + RawSpeed::ThrowCME("CameraMetaData: XML document of the wrong type, root node is not " "cameras."); return; } @@ -62,13 +92,13 @@ CameraMetaDataLR::CameraMetaDataLR(char *data, int sz) : CameraMetaData() { if ((!xmlStrcmp(cur->name, (const xmlChar *)"Camera"))) { - Camera *camera = new Camera(doc, cur); + RawSpeed::Camera *camera = new RawSpeed::Camera(doc, cur); addCamera(camera); // Create cameras for aliases. for (unsigned int i = 0; i < camera->aliases.size(); i++) { - addCamera(new Camera(camera, i)); + addCamera(new RawSpeed::Camera(camera, i)); } } cur = cur->next; @@ -81,7 +111,7 @@ CameraMetaDataLR::CameraMetaDataLR(char *data, int sz) : CameraMetaData() ctxt = 0; } -CameraMetaDataLR *make_camera_metadata() +void *make_camera_metadata() { int len = 0, i; for (i = 0; i < RAWSPEED_DATA_COUNT; i++) @@ -117,7 +147,22 @@ CameraMetaDataLR *make_camera_metadata() return ret; } -#endif +void clear_rawspeed_decoder(void* _rawspeed_decoder) +{ + RawSpeed::RawDecoder *d = + static_cast(_rawspeed_decoder); + if(d) + delete d; +} + +void clear_camera_metadata(void* _rawspeed_camerameta) +{ + CameraMetaDataLR *cmeta = + static_cast(_rawspeed_camerameta); + if(cmeta) + delete cmeta; +} + int LibRaw::set_rawspeed_camerafile(char * filename) { @@ -181,9 +226,9 @@ int LibRaw::try_rawspeed() if (!_rawspeed_buffer) throw LIBRAW_EXCEPTION_ALLOC; ID.input->read(_rawspeed_buffer, _rawspeed_buffer_sz, 1); - FileMap map((uchar8 *)_rawspeed_buffer, _rawspeed_buffer_sz); - RawParser t(&map); - RawDecoder *d = 0; + RawSpeed::FileMap map((RawSpeed::uchar8 *)_rawspeed_buffer, _rawspeed_buffer_sz); + RawSpeed::RawParser t(&map); + RawSpeed::RawDecoder *d = 0; CameraMetaDataLR *meta = static_cast(_rawspeed_camerameta); d = t.getDecoder(); @@ -203,7 +248,7 @@ int LibRaw::try_rawspeed() { d->checkSupport(meta); } - catch (const RawDecoderException &e) + catch (const RawSpeed::RawDecoderException &e) { imgdata.process_warnings |= LIBRAW_WARN_RAWSPEED_UNSUPPORTED; throw e; @@ -211,7 +256,7 @@ int LibRaw::try_rawspeed() _rawspeed_decoder = static_cast(d); d->decodeRaw(); d->decodeMetaData(meta); - RawImage r = d->mRaw; + RawSpeed::RawImage r = d->mRaw; if (r->errors.size() > 0 && !rawspeed_ignore_errors) { delete d; @@ -243,7 +288,7 @@ int LibRaw::try_rawspeed() if (_rawspeed_decoder) { // set sizes - iPoint2D rsdim = r->getUncroppedDim(); + RawSpeed::iPoint2D rsdim = r->getUncroppedDim(); S.raw_pitch = r->pitch; S.raw_width = rsdim.x; S.raw_height = rsdim.y; @@ -254,7 +299,7 @@ int LibRaw::try_rawspeed() _rawspeed_buffer = 0; imgdata.process_warnings |= LIBRAW_WARN_RAWSPEED_PROCESSED; } - catch (const RawDecoderException &RDE) + catch (const RawSpeed::RawDecoderException &RDE) { imgdata.process_warnings |= LIBRAW_WARN_RAWSPEED_PROBLEM; if (_rawspeed_buffer) @@ -284,3 +329,4 @@ int LibRaw::try_rawspeed() return LIBRAW_NOT_IMPLEMENTED; #endif } +#endif diff --git a/src/libraw_c_api.cpp b/src/libraw_c_api.cpp index 4e85ec293..2609fef70 100644 --- a/src/libraw_c_api.cpp +++ b/src/libraw_c_api.cpp @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: libraw_c_api.cpp - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * Created: Sat Mar 8 , 2008 * * LibRaw C interface diff --git a/src/libraw_datastream.cpp b/src/libraw_datastream.cpp index 60593b42f..33182253d 100644 --- a/src/libraw_datastream.cpp +++ b/src/libraw_datastream.cpp @@ -1,6 +1,6 @@ /* -*- C++ -*- * File: libraw_datastream.cpp - * Copyright 2008-2021 LibRaw LLC (info@libraw.org) + * Copyright 2008-2024 LibRaw LLC (info@libraw.org) * * LibRaw C++ interface (implementation) @@ -27,11 +27,6 @@ #include "libraw/libraw_types.h" #include "libraw/libraw_datastream.h" #include -#ifdef USE_JASPER -#include /* Decode RED camera movies */ -#else -#define NO_JASPER -#endif #ifdef USE_JPEG #include #include @@ -156,20 +151,12 @@ int LibRaw_abstract_datastream::jpeg_src(void *jpegdata) #ifndef LIBRAW_NO_IOSTREAMS_DATASTREAM // == LibRaw_file_datastream == -LibRaw_file_datastream::~LibRaw_file_datastream() -{ - if (jas_file) - fclose(jas_file); -} - LibRaw_file_datastream::LibRaw_file_datastream(const char *fname) : filename(fname), _fsize(0) #ifdef LIBRAW_WIN32_UNICODEPATHS , wfilename() #endif - , - jas_file(NULL) { if (filename.size() > 0) { @@ -200,7 +187,7 @@ LibRaw_file_datastream::LibRaw_file_datastream(const char *fname) } #ifdef LIBRAW_WIN32_UNICODEPATHS LibRaw_file_datastream::LibRaw_file_datastream(const wchar_t *fname) - : filename(), wfilename(fname), jas_file(NULL), _fsize(0) + : filename(), wfilename(fname), _fsize(0) { if (wfilename.size() > 0) { @@ -330,26 +317,6 @@ const char *LibRaw_file_datastream::fname() #undef LR_STREAM_CHK -#ifdef LIBRAW_OLD_VIDEO_SUPPORT -void *LibRaw_file_datastream::make_jas_stream() -{ -#ifdef NO_JASPER - return NULL; -#else -#ifdef LIBRAW_WIN32_UNICODEPATHS - if (wfname()) - { - jas_file = _wfopen(wfname(), L"rb"); - return jas_stream_fdopen(fileno(jas_file), "rb"); - } - else -#endif - { - return jas_stream_fopen(fname(), "rb"); - } -#endif -} -#endif #endif // == LibRaw_buffer_datastream @@ -478,16 +445,6 @@ int LibRaw_buffer_datastream::eof() } int LibRaw_buffer_datastream::valid() { return buf ? 1 : 0; } -#ifdef LIBRAW_OLD_VIDEO_SUPPORT -void *LibRaw_buffer_datastream::make_jas_stream() -{ -#ifdef NO_JASPER - return NULL; -#else - return jas_stream_memopen((char *)buf + streampos, streamsize - streampos); -#endif -} -#endif int LibRaw_buffer_datastream::jpeg_src(void *jpegdata) { @@ -642,17 +599,6 @@ const char *LibRaw_bigfile_datastream::fname() return filename.size() > 0 ? filename.c_str() : NULL; } -#ifdef LIBRAW_OLD_VIDEO_SUPPORT -void *LibRaw_bigfile_datastream::make_jas_stream() -{ -#ifdef NO_JASPER - return NULL; -#else - return jas_stream_fdopen(fileno(f), "rb"); -#endif -} -#endif - // == LibRaw_windows_datastream #ifdef LIBRAW_WIN32_CALLS @@ -820,16 +766,6 @@ const char *LibRaw_bigfile_buffered_datastream::fname() return filename.size() > 0 ? filename.c_str() : NULL; } -#ifdef LIBRAW_OLD_VIDEO_SUPPORT -void *LibRaw_bigfile_buffered_datastream::make_jas_stream() -{ -#ifdef NO_JASPER - return NULL; -#else - return NULL; -#endif -} -#endif INT64 LibRaw_bigfile_buffered_datastream::readAt(void *ptr, size_t size, INT64 off) { diff --git a/src/metadata/adobepano.cpp b/src/metadata/adobepano.cpp index 689c24a4e..ee1d2c8a1 100644 --- a/src/metadata/adobepano.cpp +++ b/src/metadata/adobepano.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify diff --git a/src/metadata/canon.cpp b/src/metadata/canon.cpp index 012ecb09a..eab35e0e8 100644 --- a/src/metadata/canon.cpp +++ b/src/metadata/canon.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify @@ -108,11 +108,15 @@ void LibRaw::setCanonBodyFeatures(unsigned long long id) ilm.CameraFormat = LIBRAW_FORMAT_APSC; ilm.CameraMount = LIBRAW_MOUNT_Canon_EF_M; } - else if ((id == CanonID_EOS_R) || - (id == CanonID_EOS_RP) || - (id == CanonID_EOS_R3) || - (id == CanonID_EOS_R5) || - (id == CanonID_EOS_R6)) + else if ( + (id == CanonID_EOS_R) + || (id == CanonID_EOS_RP) + || (id == CanonID_EOS_R3) + || (id == CanonID_EOS_R5) + || (id == CanonID_EOS_R6) + || (id == CanonID_EOS_R6m2) + || (id == CanonID_EOS_R8) + ) { ilm.CameraFormat = LIBRAW_FORMAT_FF; ilm.CameraMount = LIBRAW_MOUNT_Canon_RF; @@ -120,8 +124,12 @@ void LibRaw::setCanonBodyFeatures(unsigned long long id) ilm.LensMount = LIBRAW_MOUNT_Canon_EF; } - else if ((id == CanonID_EOS_R7) || - (id == CanonID_EOS_R10)) + else if ( + (id == CanonID_EOS_R7) + || (id == CanonID_EOS_R10) + || (id == CanonID_EOS_R50) + || (id == CanonID_EOS_R100) + ) { ilm.CameraFormat = LIBRAW_FORMAT_APSC; ilm.CameraMount = LIBRAW_MOUNT_Canon_RF; @@ -955,6 +963,7 @@ void LibRaw::parseCanonMakernotes(unsigned tag, unsigned /*type*/, unsigned len, imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_1to1; break; case 2: + case 0x102: imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_4to3; break; case 7: @@ -1234,9 +1243,9 @@ void LibRaw::parseCanonMakernotes(unsigned tag, unsigned /*type*/, unsigned len, break; case 1820: // M50; ColorDataSubVer: 16 - case 1824: // R; ColorDataSubVer: 17 + case 1824: // R, Ra; ColorDataSubVer: 17 case 1816: // RP, 250D, SX70 HS; ColorDataSubVer: 18 - // M6 Mark II, M200, 90D, G5 X Mark II, G7 X Mark III, 850D; ColorDataSubVer: 19 + // R100, M6 Mark II, M200, 90D, G5 X Mark II, G7 X Mark III, 850D; ColorDataSubVer: 19 imCanon.ColorDataVer = 9; AsShot_Auto_MeasuredWB(0x0047); CR3_ColorData(0x0047); @@ -1244,14 +1253,14 @@ void LibRaw::parseCanonMakernotes(unsigned tag, unsigned /*type*/, unsigned len, case 1770: // R5 CRM case 2024: // -1D X Mark III; ColorDataSubVer: 32 - case 3656: // R5, R6; ColorDataSubVer: 33 + case 3656: // R5, R6; ColorDataSubVer: 33 imCanon.ColorDataVer = 10; AsShot_Auto_MeasuredWB(0x0055); CR3_ColorData(0x0055); break; case 3973: // R3; ColorDataSubVer: 34 - case 3778: // R7, R10; ColorDataSubVer: 48 + case 3778: // R6 Mark II, R7, R8, R10, R50; ColorDataSubVer: 48 imCanon.ColorDataVer = 11; AsShot_Auto_MeasuredWB(0x0069); diff --git a/src/metadata/ciff.cpp b/src/metadata/ciff.cpp index 2c59b11e7..b3c43066d 100644 --- a/src/metadata/ciff.cpp +++ b/src/metadata/ciff.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/metadata/cr3_parser.cpp b/src/metadata/cr3_parser.cpp index 52061e9c7..4b0d1d195 100644 --- a/src/metadata/cr3_parser.cpp +++ b/src/metadata/cr3_parser.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify @@ -138,6 +138,7 @@ void LibRaw::selectCRXTrack() else return; // No RAW track index + int ctmdcount = 0; // Frame selected: parse CTMD metadata for (int i = 0, trackcnt = 0; i <= maxTrack && i < LIBRAW_CRXTRACKS_MAXCOUNT; i++) { @@ -149,6 +150,7 @@ void LibRaw::selectCRXTrack() if (fsel) selectCRXFrame(i, fsel); parseCR3_CTMD(i); + ctmdcount++; } else if (d->MediaType == 2) // JPEG { @@ -228,6 +230,10 @@ void LibRaw::selectCRXTrack() } if (tiff_idx >= 0) flip = tiff_ifd[tiff_idx].t_flip; + + if (ctmdcount == 1 && imgdata.makernotes.canon.multishot[0] && imgdata.makernotes.canon.multishot[1]) + for (int c = 0; c < 4; c++) + cam_mul[c] = 1024; } } @@ -443,6 +449,7 @@ int LibRaw::parseCR3(INT64 oAtomList, char UIID[16]; uchar CMP1[85]; + uchar thdr[4]; uchar CDI1[60]; char HandlerType[5], MediaFormatID[5]; uint32_t relpos_inDir, relpos_inBox; @@ -463,6 +470,11 @@ int LibRaw::parseCR3(INT64 oAtomList, err = 0; order = 0x4d4d; fseek(ifp, oAtom, SEEK_SET); + if (nesting == 0) + { + fread(thdr, 1, 4, ifp); + fseek(ifp, oAtom, SEEK_SET); + } szAtom = get4(); FORC4 nmAtom[c] = AtomNameStack[nesting * 4 + c] = fgetc(ifp); AtomNameStack[(nesting + 1) * 4] = '\0'; @@ -478,6 +490,14 @@ int LibRaw::parseCR3(INT64 oAtomList, if (!AtomType) { + if (nesting == 0) + { + if(!memcmp(thdr,"II*\0",4) || !memcmp(thdr,"MM*\0",4)) + { + err = 0; + goto fin; + } + } err = 1; } diff --git a/src/metadata/epson.cpp b/src/metadata/epson.cpp index 427d98e9c..5537c9752 100644 --- a/src/metadata/epson.cpp +++ b/src/metadata/epson.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: diff --git a/src/metadata/exif_gps.cpp b/src/metadata/exif_gps.cpp index 7fb3b53ff..bc59371e5 100644 --- a/src/metadata/exif_gps.cpp +++ b/src/metadata/exif_gps.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/metadata/fuji.cpp b/src/metadata/fuji.cpp index feb394ef6..30e64c2ea 100644 --- a/src/metadata/fuji.cpp +++ b/src/metadata/fuji.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. @@ -17,6 +17,8 @@ */ #include "../../internal/dcraw_defs.h" +#include "../../internal/libraw_checked_buffer.h" + int LibRaw::guess_RAFDataGeneration (uchar *RAFData_start) // returns offset to first valid width/height pair { @@ -53,8 +55,9 @@ int LibRaw::guess_RAFDataGeneration (uchar *RAFData_start) // returns offset to - same conditions as for RAFData gen. 3, but also adds WRTS in bytes 4..7 - contains a table of 3+2*13 values; first 3 values look like WHW - H in WHW group has a different meaning if the shot is taken in crop 2 mode - GFX 100, GFX 100S, GFX 50R, GFX 50S, GFX 50S II - X-E2S, X-E3, X-H1, X-S10 + GFX 100, GFX 100S, GFX 100 II + GFX 50R, GFX 50S, GFX 50S II + X-E2S, X-E3, X-H1, X-S10, X-H2 X-T2, X-T3, X-T4, X-T20, X-T30 X-Pro2, X-Pro3 X100F, X100V @@ -96,16 +99,51 @@ int LibRaw::guess_RAFDataGeneration (uchar *RAFData_start) // returns offset to imFuji.RAFDataVersion = b23; } -// printf ("RAFDataVersion: 0x%04x, RAFDataGeneration: %d\n", -// imFuji.RAFDataVersion, imFuji.RAFDataGeneration); +//printf ("ID: 0x%llx, RAFDataVersion: 0x%04x, RAFDataGeneration: %d\n", +//ilm.CamID, imFuji.RAFDataVersion, imFuji.RAFDataGeneration); return offsetWH_inRAFData; } +class fuji_wb_checked_buffer_t : public checked_buffer_t +{ +public: + bool isWB(unsigned offset) + { + return sget2(offset) != 0 && sget2(offset + 2) != 0 && sget2(offset + 4) != 0 && sget2(offset + 6) != 0 && + sget2(offset + 8) != 0 && sget2(offset + 10) != 0 && sget2(offset) != 0xff && sget2(offset + 2) != 0xff && + sget2(offset + 4) != 0xff && sget2(offset + 6) != 0xff && sget2(offset + 8) != 0xff && + sget2(offset + 10) != 0xff && sget2(offset) == sget2(offset + 6) && sget2(offset) < sget2(offset + 2) && + sget2(offset) < sget2(offset + 4) && sget2(offset) < sget2(offset + 8) && sget2(offset) < sget2(offset + 10) + ; + } + fuji_wb_checked_buffer_t(short ord, int size) : checked_buffer_t(ord, size) {} + void set_order(short o) { _order = o; } +}; + +struct tag2wb_t +{ + unsigned tag; + int wb; +} tag2wbtable[] = +{ + {0x2000, LIBRAW_WBI_Auto }, + {0x2100, LIBRAW_WBI_FineWeather }, + {0x2200, LIBRAW_WBI_Shade}, + {0x2300, LIBRAW_WBI_FL_D }, + {0x2301, LIBRAW_WBI_FL_N}, + {0x2302, LIBRAW_WBI_FL_W }, + {0x2310, LIBRAW_WBI_FL_WW}, + {0x2311, LIBRAW_WBI_FL_L}, + {0x2400, LIBRAW_WBI_Tungsten}, + {0x2410, LIBRAW_WBI_Flash} +}; +const int tag2wbtable_size = sizeof(tag2wbtable) / sizeof(tag2wbtable[0]); + + void LibRaw::parseAdobeRAFMakernote() { - uchar *PrivateMknBuf; unsigned posPrivateMknBuf=0; /* clang warns about not inited value */ unsigned PrivateMknLength; unsigned PrivateOrder; @@ -117,27 +155,7 @@ void LibRaw::parseAdobeRAFMakernote() int posWB; int c; -#define CHECKSPACE_ABS3(s1, s2, s3) \ - if (INT64(s1) + INT64(s2) + INT64(s3) > INT64(PrivateMknLength)) \ - { \ - free(PrivateMknBuf); \ - return; \ - } - -#define CHECKSPACE_ABS2(s1,s2) \ - if (INT64(s1) + INT64(s2) > INT64(PrivateMknLength)) \ - { \ - free(PrivateMknBuf); \ - return; \ - } - -#define CHECKSPACE(s) \ - if (INT64(posPrivateMknBuf) + INT64(s) > INT64(PrivateMknLength)) \ - { \ - free(PrivateMknBuf); \ - return; \ - } - +#if 0 #define isWB(posWB) \ sget2(posWB) != 0 && sget2(posWB + 2) != 0 && sget2(posWB + 4) != 0 && \ sget2(posWB + 6) != 0 && sget2(posWB + 8) != 0 && \ @@ -147,16 +165,15 @@ void LibRaw::parseAdobeRAFMakernote() sget2(posWB + 10) != 0xff && sget2(posWB) == sget2(posWB + 6) && \ sget2(posWB) < sget2(posWB + 2) && sget2(posWB) < sget2(posWB + 4) && \ sget2(posWB) < sget2(posWB + 8) && sget2(posWB) < sget2(posWB + 10) +#endif #define get_average_WB(wb_index) \ - CHECKSPACE(8); \ FORC4 icWBC[wb_index][GRGB_2_RGBG(c)] = \ - sget2(PrivateMknBuf + posPrivateMknBuf + (c << 1)); \ + PrivateMknBuf.sget2(posPrivateMknBuf + (c << 1)); \ if ((PrivateTagBytes == 16) && average_WBData) { \ - CHECKSPACE(16); \ FORC4 icWBC[wb_index][GRGB_2_RGBG(c)] = \ (icWBC[wb_index][GRGB_2_RGBG(c)] + \ - sget2(PrivateMknBuf + posPrivateMknBuf + (c << 1)+8)) /2; \ + PrivateMknBuf.sget2(posPrivateMknBuf + (c << 1)+8)) /2; \ } \ if (use_WBcorr_coeffs) { \ icWBC[wb_index][0] *= wbR_corr; \ @@ -189,11 +206,11 @@ void LibRaw::parseAdobeRAFMakernote() PrivateMknLength = get4(); // At least 0x36 bytes because of memcpy(imFuji.RAFVersion, PrivateMknBuf + 0x32, 4); - if ((PrivateMknLength >= 0x36) && (PrivateMknLength < 10240000) && - (PrivateMknBuf = (uchar *)malloc(PrivateMknLength + 1024))) // 1024b for safety + if ((PrivateMknLength >= 0x36) && (PrivateMknLength < 10240000)) // 1024b for safety { - fread(PrivateMknBuf, PrivateMknLength, 1, ifp); - memcpy(imFuji.SerialSignature, PrivateMknBuf + 6, 0x0c); + fuji_wb_checked_buffer_t PrivateMknBuf(order, PrivateMknLength+1024); + fread(PrivateMknBuf.data(), PrivateMknLength, 1, ifp); + memcpy(imFuji.SerialSignature, PrivateMknBuf.data() + 6, 0x0c); imFuji.SerialSignature[0x0c] = 0; memcpy(imFuji.SensorID, imFuji.SerialSignature + 0x06, 0x04); imFuji.SensorID[0x04] = 0; @@ -201,25 +218,22 @@ void LibRaw::parseAdobeRAFMakernote() while (isdigit(imFuji.SerialSignature[c]) && (c>0)) c--; ilm.CamID = unique_id = (unsigned long long)atoi(imFuji.SerialSignature+c+1); - memcpy(model, PrivateMknBuf + 0x12, 0x20); + memcpy(model, PrivateMknBuf.data() + 0x12, 0x20); model[0x20] = 0; - memcpy(imFuji.RAFVersion, PrivateMknBuf + 0x32, 4); + memcpy(imFuji.RAFVersion, PrivateMknBuf.data() + 0x32, 4); imFuji.RAFVersion[4] = 0; - PrivateOrder = sget2(PrivateMknBuf); + PrivateOrder = PrivateMknBuf.sget2(0); unsigned s, l; - s = ifd_start = sget4(PrivateMknBuf +2)+6; - CHECKSPACE(INT64(ifd_start)+4LL); - l = ifd_len = sget4(PrivateMknBuf +ifd_start); - CHECKSPACE_ABS3(ifd_start, ifd_len, 4); + s = ifd_start = PrivateMknBuf.sget4(2)+6; + l = ifd_len = PrivateMknBuf.sget4(ifd_start); - if (!sget4(PrivateMknBuf+ifd_start+ifd_len+4)) + if (!PrivateMknBuf.sget4(ifd_start+ifd_len+4)) FujiShotSelect = 0; if ((FujiShotSelect == 1) && (PrivateMknLength > ifd_len*2)) { ifd_start += (ifd_len+4); - CHECKSPACE_ABS2(ifd_start, 4); - ifd_len = sget4(PrivateMknBuf +ifd_start); + ifd_len = PrivateMknBuf.sget4(ifd_start); if ((ifd_start+ifd_len) > PrivateMknLength) { ifd_start = s; ifd_len = l; @@ -227,12 +241,10 @@ void LibRaw::parseAdobeRAFMakernote() } } else FujiShotSelect = 0; - CHECKSPACE_ABS3(ifd_start, 4, 4); - PrivateEntries = sget4(PrivateMknBuf + ifd_start + 4); + PrivateEntries = PrivateMknBuf.sget4(ifd_start + 4); if ((PrivateEntries > 1000) || ((PrivateOrder != 0x4d4d) && (PrivateOrder != 0x4949))) { - free(PrivateMknBuf); return; } posPrivateMknBuf = (ifd_start+8); @@ -246,68 +258,35 @@ void LibRaw::parseAdobeRAFMakernote() **/ while (PrivateEntries--) { - order = 0x4d4d; - CHECKSPACE(4); - PrivateTagID = sget2(PrivateMknBuf + posPrivateMknBuf); - PrivateTagBytes = sget2(PrivateMknBuf + posPrivateMknBuf + 2); + PrivateMknBuf.set_order(0x4d4d); + order = 0x4d4d; + PrivateTagID = PrivateMknBuf.sget2(posPrivateMknBuf); + PrivateTagBytes = PrivateMknBuf.sget2(posPrivateMknBuf + 2); posPrivateMknBuf += 4; - order = PrivateOrder; + PrivateMknBuf.set_order(PrivateOrder); + order = PrivateOrder; - if (PrivateTagID == 0x2000) - { - get_average_WB(LIBRAW_WBI_Auto); - } - else if (PrivateTagID == 0x2100) - { - get_average_WB(LIBRAW_WBI_FineWeather); - } - else if (PrivateTagID == 0x2200) - { - get_average_WB(LIBRAW_WBI_Shade); - } - else if (PrivateTagID == 0x2300) - { - get_average_WB(LIBRAW_WBI_FL_D); - } - else if (PrivateTagID == 0x2301) - { - get_average_WB(LIBRAW_WBI_FL_N); - } - else if (PrivateTagID == 0x2302) - { - get_average_WB(LIBRAW_WBI_FL_W); - } - else if (PrivateTagID == 0x2310) - { - get_average_WB(LIBRAW_WBI_FL_WW); - } - else if (PrivateTagID == 0x2311) - { - get_average_WB(LIBRAW_WBI_FL_L); - } - else if (PrivateTagID == 0x2400) - { - get_average_WB(LIBRAW_WBI_Tungsten); - } - else if (PrivateTagID == 0x2410) - { - get_average_WB(LIBRAW_WBI_Flash); - } + if (PrivateTagID >= 0x2000 && PrivateTagID <= 0x2410) + { + for(int q = 0; q < tag2wbtable_size; q++) + if (tag2wbtable[q].tag == PrivateTagID) + { + get_average_WB(tag2wbtable[q].wb); + break; + } + } else if (PrivateTagID == 0x2f00) { - CHECKSPACE(4); - int nWBs = MIN(sget4(PrivateMknBuf + posPrivateMknBuf), 6); + int nWBs = MIN(PrivateMknBuf.sget4(posPrivateMknBuf), 6); posWB = posPrivateMknBuf + 4; for (int wb_ind = LIBRAW_WBI_Custom1; wb_ind < LIBRAW_WBI_Custom1+nWBs; wb_ind++) { - CHECKSPACE_ABS2(posWB, 8); FORC4 icWBC[wb_ind][GRGB_2_RGBG(c)] = - sget2(PrivateMknBuf + posWB + (c << 1)); + PrivateMknBuf.sget2(posWB + (c << 1)); if ((PrivateTagBytes >= unsigned(4+16*nWBs)) && average_WBData) { posWB += 8; - CHECKSPACE_ABS2(posWB, 8); FORC4 icWBC[wb_ind][GRGB_2_RGBG(c)] = (icWBC[wb_ind][GRGB_2_RGBG(c)] + - sget2(PrivateMknBuf + posWB + (c << 1))) /2; + PrivateMknBuf.sget2(posWB + (c << 1))) /2; } if (use_WBcorr_coeffs) { icWBC[wb_ind][0] *= wbR_corr; @@ -325,49 +304,48 @@ void LibRaw::parseAdobeRAFMakernote() ((PrivateTagBytes == 8) || (PrivateTagBytes == 16))) { imFuji.BlackLevel[0] = PrivateTagBytes / 2; - CHECKSPACE(10); FORC4 imFuji.BlackLevel[GRGB_2_RGBG(c)+1] = - sget2(PrivateMknBuf + posPrivateMknBuf + (c << 1)); + PrivateMknBuf.sget2(posPrivateMknBuf + (c << 1)); if (imFuji.BlackLevel[0] == 8) { - CHECKSPACE(18); FORC4 imFuji.BlackLevel[GRGB_2_RGBG(c) + 5] = - sget2(PrivateMknBuf + posPrivateMknBuf + (c << 1) + 8); + PrivateMknBuf.sget2(posPrivateMknBuf + (c << 1) + 8); } } else if (PrivateTagID == 0x9650) { - CHECKSPACE(4); - short a = (short)sget2(PrivateMknBuf + posPrivateMknBuf); - float b = fMAX(1.0f, sget2(PrivateMknBuf + posPrivateMknBuf + 2)); + short a = (short)PrivateMknBuf.sget2(posPrivateMknBuf); + float b = fMAX(1.0f, PrivateMknBuf.sget2(posPrivateMknBuf + 2)); imFuji.ExpoMidPointShift = a / b; imCommon.ExposureCalibrationShift += imFuji.ExpoMidPointShift; } else if ((PrivateTagID == 0xc000) && (PrivateTagBytes > 3) && (PrivateTagBytes < 10240000)) { - order = 0x4949; + PrivateMknBuf.set_order(0x4949); + order = 0x4949; if (PrivateTagBytes != 4096) // not one of Fuji X-A3, X-A5, X-A7, X-A10, X-A20, X-T100, X-T200, XF10 { int is34 = 0; - CHECKSPACE(8); - guess_RAFDataGeneration (PrivateMknBuf + posPrivateMknBuf); -// printf ("RAFDataVersion: 0x%04x, RAFDataGeneration: %d\n", -// imFuji.RAFDataVersion, imFuji.RAFDataGeneration); + PrivateMknBuf.checkoffset(posPrivateMknBuf + 8); // will raise exception if no space + guess_RAFDataGeneration (PrivateMknBuf.data() + posPrivateMknBuf); + +//printf ("ID: 0x%llx, RAFDataVersion: 0x%04x, RAFDataGeneration: %d\n", +//ilm.CamID, imFuji.RAFDataVersion, imFuji.RAFDataGeneration); for (posWB = 0; posWB < (int)PrivateTagBytes - 16; posWB++) { - CHECKSPACE_ABS2(posWB, 12); - if ((!memcmp(PrivateMknBuf + posWB, "TSNERDTS", 8) && - (sget2(PrivateMknBuf + posWB + 10) > 125))) + PrivateMknBuf.checkoffset(posWB + 12); // will raise exception if no space + if ((!memcmp(PrivateMknBuf.data() + posWB, "TSNERDTS", 8) && + (PrivateMknBuf.sget2( posWB + 10) > 125))) { posWB += 10; icWBC[LIBRAW_WBI_Auto][1] = icWBC[LIBRAW_WBI_Auto][3] = - sget2(PrivateMknBuf + posWB); + PrivateMknBuf.sget2(posWB); icWBC[LIBRAW_WBI_Auto][0] = - sget2(PrivateMknBuf + posWB + 2); + PrivateMknBuf.sget2(posWB + 2); icWBC[LIBRAW_WBI_Auto][2] = - sget2(PrivateMknBuf + posWB + 4); + PrivateMknBuf.sget2(posWB + 4); break; } } @@ -375,16 +353,20 @@ void LibRaw::parseAdobeRAFMakernote() if ((imFuji.RAFDataVersion == 0x0260) || // X-Pro3, GFX 100S (imFuji.RAFDataVersion == 0x0261) || // X100V, GFX 50S II (imFuji.RAFDataVersion == 0x0262) || // X-T4 - (imFuji.RAFDataVersion == 0x0264) || // X-S10 - (imFuji.RAFDataVersion == 0x0265) || // X-E4 + (imFuji.RAFDataVersion == 0x0263) || // X-H2s + (imFuji.RAFDataVersion == 0x0264) || // X-S10, X-H2 + (imFuji.RAFDataVersion == 0x0265) || // X-E4, X-T5 (imFuji.RAFDataVersion == 0x0266) || // X-T30 II + (imFuji.RAFDataVersion == 0x0267) || // GFX 100 II !strcmp(model, "X-Pro3") || - !strcmp(model, "GFX 100S") || - !strcmp(model, "GFX100S") || - !strcmp(model, "GFX 50S II") || - !strcmp(model, "GFX50S II") || + !strcmp(model, "GFX 100 II") || !strcmp(model, "GFX100 II") || + !strcmp(model, "GFX 100S") || !strcmp(model, "GFX100S") || + !strcmp(model, "GFX 50S II") || !strcmp(model, "GFX50S II") || !strcmp(model, "X100V") || + !strcmp(model, "X-H2") || + !strcmp(model, "X-H2S") || !strcmp(model, "X-T4") || + !strcmp(model, "X-T5") || !strcmp(model, "X-E4") || !strcmp(model, "X-T30 II") || !strcmp(model, "X-S10")) @@ -464,16 +446,11 @@ void LibRaw::parseAdobeRAFMakernote() } else if (imFuji.RAFDataVersion == 0x025f) // X-T30, GFX 50R, GFX 100 (? RAFDataVersion 0x045f) { - if (!strcmp(model, "X-T30")) { - CHECKSPACE(0x20b8 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x20b8)) + if (!strcmp(model, "X-T30")) { + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x20b8)) wb_section_offset = 0x20b8; - else - { - CHECKSPACE(0x20c8 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x20c8)) + else if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x20c8)) wb_section_offset = 0x20c8; - } } else if (!strcmp(model, "GFX 50R")) wb_section_offset = 0x1424; @@ -496,16 +473,34 @@ void LibRaw::parseAdobeRAFMakernote() } else if (imFuji.RAFDataVersion == 0x0262) // X-T4 { - wb_section_offset = 0x21c8; + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x21c8)) + wb_section_offset = 0x21c8; + else if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x21cc)) + wb_section_offset = 0x21cc; } - else if (imFuji.RAFDataVersion == 0x0264) // X-S10 + else if (imFuji.RAFDataVersion == 0x0263) // X-H2S { - wb_section_offset = 0x21de; + wb_section_offset = 0x0b40; } - else if ((imFuji.RAFDataVersion == 0x0265) || // X-E4 - (imFuji.RAFDataVersion == 0x0266)) // X-T30 II + else if (imFuji.RAFDataVersion == 0x0264) // X-S10, X-H2 { - wb_section_offset = 0x21cc; + if (!strcmp(model, "X-S10")) + wb_section_offset = 0x21de; + else if (!strcmp(model, "X-H2")) + wb_section_offset = 0x0b3e; + } + else if ((imFuji.RAFDataVersion == 0x0265) || // X-E4, X-T5 + (imFuji.RAFDataVersion == 0x0266)) // X-T30 II, X-S20 + { + if (!strcmp(model, "X-T5") || + !strcmp(model, "X-S20")) + wb_section_offset = 0x0c72; + else + wb_section_offset = 0x21cc; + } + else if (imFuji.RAFDataVersion == 0x0267) // GFX 100 II + { + wb_section_offset = 0x0cae; } else if (imFuji.RAFDataVersion == 0x0355) // X-E2S { @@ -515,168 +510,166 @@ void LibRaw::parseAdobeRAFMakernote() /* try for unknown RAF Data versions */ else if (!strcmp(model, "X-Pro2")) { - CHECKSPACE(0x135c + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x135c)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x135c)) wb_section_offset = 0x135c; } else if (!strcmp(model, "X100F")) { - CHECKSPACE(0x1370 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x1370)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x1370)) wb_section_offset = 0x1370; } else if (!strcmp(model, "X-E1")) { - CHECKSPACE(0x13ac + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x13ac)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x13ac)) wb_section_offset = 0x13ac; } else if (!strcmp(model, "X-T2") || !strcmp(model, "X-T20")) { - CHECKSPACE(0x13dc + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x13dc)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x13dc)) wb_section_offset = 0x13dc; } else if (!strcmp(model, "X20") || !strcmp(model, "X100S")) { - CHECKSPACE(0x1410 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x1410)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x1410)) wb_section_offset = 0x1410; } else if (!strcmp(model, "XQ1") || !strcmp(model, "XQ2")) { - CHECKSPACE(0x1414+ 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x1414)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x1414)) wb_section_offset = 0x1414; } else if (!strcmp(model, "X-E3")) { - CHECKSPACE(0x141c + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x141c)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x141c)) wb_section_offset = 0x141c; } else if (!strcmp(model, "GFX 50S") || !strcmp(model, "GFX 50R")) { - CHECKSPACE(0x1424 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x1424)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x1424)) wb_section_offset = 0x1424; } - else if (!strcmp(model, "GFX 50S II") || !strcmp(model, "GFX50S II")) { - CHECKSPACE(0x214c + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x214c)) + else if (!strcmp(model, "GFX 50S II") || + !strcmp(model, "GFX50S II")) { + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x214c)) wb_section_offset = 0x214c; } else if (!strcmp(model, "X30") || !strcmp(model, "X100T")) { - CHECKSPACE(0x1444 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x1444)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x1444)) wb_section_offset = 0x1444; } else if (!strcmp(model, "X-M1") || !strcmp(model, "X-A1") || !strcmp(model, "X-A2")) { - CHECKSPACE(0x1474 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x1474)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x1474)) wb_section_offset = 0x1474; } else if (!strcmp(model, "X-E2") || !strcmp(model, "X-H1")) { - CHECKSPACE(0x1480 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x1480)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x1480)) wb_section_offset = 0x1480; } else if (!strcmp(model, "X-T1")) { - CHECKSPACE(0x14b0 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x14b0)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x14b0)) wb_section_offset = 0x14b0; } else if (!strcmp(model, "X70")) { - CHECKSPACE(0x17b4 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x17b4)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x17b4)) wb_section_offset = 0x17b4; } else if (!strcmp(model, "X-T10")) { - CHECKSPACE(0x1824 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x1824)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x1824)) wb_section_offset = 0x1824; } else if (!strcmp(model, "X-E2S")) { - CHECKSPACE(0x1840 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x1840)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x1840)) wb_section_offset = 0x1840; } else if (!strcmp(model, "X-T3")) { - CHECKSPACE(0x2014 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x2014)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x2014)) wb_section_offset = 0x2014; } else if (!strcmp(model, "X100V")) { - CHECKSPACE(0x2078 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x2078)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x2078)) wb_section_offset = 0x2078; } else if (!strcmp(model, "X-T30")) { - CHECKSPACE(0x20b8 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x20b8)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x20b8)) wb_section_offset = 0x20b8; - else - { - CHECKSPACE(0x20c8 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x20c8)) - wb_section_offset = 0x20c8; - } + else if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x20c8)) + wb_section_offset = 0x20c8; } else if (!strcmp(model, "GFX 100")) { - CHECKSPACE(0x20e4 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x20e4)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x20e4)) wb_section_offset = 0x20e4; } else if (!strcmp(model, "X-Pro3")) { - CHECKSPACE(0x20e8 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x20e8)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x20e8)) wb_section_offset = 0x20e8; } - else if (!strcmp(model, "GFX100S") || !strcmp(model, "GFX 100S")) + else if (!strcmp(model, "GFX100S") || + !strcmp(model, "GFX 100S")) { - CHECKSPACE(0x2108 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x2108)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x2108)) wb_section_offset = 0x2108; } else if (!strcmp(model, "X-T4")) { - CHECKSPACE(0x21c8 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x21c8)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x21c8)) wb_section_offset = 0x21c8; + else if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x21cc)) + wb_section_offset = 0x21cc; } else if ((!strcmp(model, "X-E4")) || (!strcmp(model, "X-T30 II"))) { - CHECKSPACE(0x21cc + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x21cc)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x21cc)) wb_section_offset = 0x21cc; } else if (!strcmp(model, "X-S10")) { - CHECKSPACE(0x21de + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x21de)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x21de)) wb_section_offset = 0x21de; } + else if (!strcmp(model, "X-H2")) + { + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x0b3e)) + wb_section_offset = 0x0b3e; + } + else if (!strcmp(model, "X-H2S")) + { + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x0b40)) + wb_section_offset = 0x0b40; + } + else if (!strcmp(model, "X-T5") || + !strcmp(model, "X-S20")) + { + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x0c72)) + wb_section_offset = 0x0c72; + } + else if (!strcmp(model, "GFX 100 II") || + !strcmp(model, "GFX100 II")) + { + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x0cae)) + wb_section_offset = 0x0cae; + } + /* no RAF Data version for the models below */ else if (!strcmp(model, "FinePix X100")) // X100 0 0x19f0 0x19e8 { @@ -687,15 +680,10 @@ void LibRaw::parseAdobeRAFMakernote() wb_section_offset = 0x19f0; else { - CHECKSPACE(0x19e8 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x19e8)) + if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x19e8)) wb_section_offset = 0x19e8; - else - { - CHECKSPACE(0x19f0 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x19f0)) - wb_section_offset = 0x19f0; - } + else if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x19f0)) + wb_section_offset = 0x19f0; } } else if (!strcmp(model, "X-Pro1")) // X-Pro1 0 0x13a4 @@ -704,34 +692,22 @@ void LibRaw::parseAdobeRAFMakernote() !strcmp(imFuji.RAFVersion, "0101") || !strcmp(imFuji.RAFVersion, "0204")) wb_section_offset = 0x13a4; - else - { - CHECKSPACE(0x13a4 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x13a4)) - wb_section_offset = 0x13a4; - } + else if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x13a4)) + wb_section_offset = 0x13a4; } else if (!strcmp(model, "XF1")) // XF1 0 0x138c { if (!strcmp(imFuji.RAFVersion, "0100")) wb_section_offset = 0x138c; - else - { - CHECKSPACE(0x138c + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x138c)) - wb_section_offset = 0x138c; - } + else if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x138c)) + wb_section_offset = 0x138c; } else if (!strcmp(model, "X-S1")) // X-S1 0 0x1284 { if (!strcmp(imFuji.RAFVersion, "0100")) wb_section_offset = 0x1284; - else - { - CHECKSPACE(0x1284 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x1284)) - wb_section_offset = 0x1284; - } + else if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x1284)) + wb_section_offset = 0x1284; } else if (!strcmp(model, "X10")) // X10 0 0x1280 0x12d4 { @@ -740,76 +716,46 @@ void LibRaw::parseAdobeRAFMakernote() wb_section_offset = 0x1280; else if (!strcmp(imFuji.RAFVersion, "0103")) wb_section_offset = 0x12d4; - else - { - CHECKSPACE(0x1280 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x1280)) + else if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x1280)) wb_section_offset = 0x1280; - else - { - CHECKSPACE(0x12d4 + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x12d4)) - wb_section_offset = 0x12d4; - } - } + else if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x12d4)) + wb_section_offset = 0x12d4; } else if (!strcmp(model, "XF1")) // XF1 0 0x138c { if (!strcmp(imFuji.RAFVersion, "0100")) wb_section_offset = 0x138c; - else - { - CHECKSPACE(0x138c + 12); - if (isWB(PrivateMknBuf + posPrivateMknBuf + 0x138c)) - wb_section_offset = 0x138c; - } + else if (PrivateMknBuf.isWB(posPrivateMknBuf + 0x138c)) + wb_section_offset = 0x138c; } - if (wb_section_offset) - { - CHECKSPACE(INT64(wb_section_offset) + 12LL); - } - - if (wb_section_offset && - isWB(PrivateMknBuf + posPrivateMknBuf + wb_section_offset)) + if (wb_section_offset && PrivateMknBuf.isWB(posPrivateMknBuf + wb_section_offset)) { if (!imFuji.RAFDataVersion) { posWB = posPrivateMknBuf + wb_section_offset - 6; - CHECKSPACE_ABS2(posWB, 6); - icWBC[LIBRAW_WBI_Auto][1] = - icWBC[LIBRAW_WBI_Auto][3] = - sget2(PrivateMknBuf + posWB); - icWBC[LIBRAW_WBI_Auto][0] = - sget2(PrivateMknBuf + posWB + 2); - icWBC[LIBRAW_WBI_Auto][2] = - sget2(PrivateMknBuf + posWB + 4); + icWBC[LIBRAW_WBI_Auto][1] = icWBC[LIBRAW_WBI_Auto][3] = PrivateMknBuf.sget2(posWB); + icWBC[LIBRAW_WBI_Auto][0] = PrivateMknBuf.sget2(posWB + 2); + icWBC[LIBRAW_WBI_Auto][2] = PrivateMknBuf.sget2(posWB + 4); } posWB = posPrivateMknBuf + wb_section_offset; for (int wb_ind = 0; wb_ind < (int)Fuji_wb_list1.size(); posWB += 6, wb_ind++) { - CHECKSPACE_ABS2(posWB, 6); - icWBC[Fuji_wb_list1[wb_ind]][1] = - icWBC[Fuji_wb_list1[wb_ind]][3] = - sget2(PrivateMknBuf + posWB); - icWBC[Fuji_wb_list1[wb_ind]][0] = - sget2(PrivateMknBuf + posWB + 2); - icWBC[Fuji_wb_list1[wb_ind]][2] = - sget2(PrivateMknBuf + posWB + 4); + icWBC[Fuji_wb_list1[wb_ind]][1] = icWBC[Fuji_wb_list1[wb_ind]][3] = PrivateMknBuf.sget2(posWB); + icWBC[Fuji_wb_list1[wb_ind]][0] = PrivateMknBuf.sget2(posWB + 2); + icWBC[Fuji_wb_list1[wb_ind]][2] = PrivateMknBuf.sget2(posWB + 4); } int found = 0; if (is34) posWB += 0x30; posWB += 0xc0; - CHECKSPACE_ABS2(posWB, 2); - ushort Gval = sget2(PrivateMknBuf + posWB); + ushort Gval = PrivateMknBuf.sget2(posWB); for (int posEndCCTsection = posWB; posEndCCTsection < (posWB + 30); posEndCCTsection += 6) { - CHECKSPACE_ABS2(posEndCCTsection, 2); - if (sget2(PrivateMknBuf + posEndCCTsection) != Gval) + if (PrivateMknBuf.sget2(posEndCCTsection) != Gval) { if (is34) wb_section_offset = posEndCCTsection - 34*3*2; // 34 records, 3 2-byte values in a record @@ -824,11 +770,10 @@ void LibRaw::parseAdobeRAFMakernote() { for (int iCCT = 0; iCCT < 31; iCCT++) { - CHECKSPACE_ABS2(wb_section_offset, iCCT*6+6); icWBCCTC[iCCT][0] = FujiCCT_K[iCCT]; - icWBCCTC[iCCT][1] = sget2(PrivateMknBuf + wb_section_offset + iCCT * 6 + 2); - icWBCCTC[iCCT][2] = icWBCCTC[iCCT][4] = sget2(PrivateMknBuf + wb_section_offset + iCCT * 6); - icWBCCTC[iCCT][3] = sget2(PrivateMknBuf + wb_section_offset + iCCT * 6 + 4); + icWBCCTC[iCCT][1] = PrivateMknBuf.sget2(wb_section_offset + iCCT * 6 + 2); + icWBCCTC[iCCT][2] = icWBCCTC[iCCT][4] = PrivateMknBuf.sget2(wb_section_offset + iCCT * 6); + icWBCCTC[iCCT][3] = PrivateMknBuf.sget2(wb_section_offset + iCCT * 6 + 4); } } } @@ -842,18 +787,17 @@ void LibRaw::parseAdobeRAFMakernote() posWB = posPrivateMknBuf + 0x200; for (int wb_ind = 0; wb_ind < 42; wb_ind++) { - CHECKSPACE_ABS2(posWB, 24); - nWB = sget4(PrivateMknBuf + posWB); + nWB = PrivateMknBuf.sget4(posWB); posWB += 4; - tWB = sget4(PrivateMknBuf + posWB); + tWB = PrivateMknBuf.sget4(posWB); posWB += 4; - wb[0] = sget4(PrivateMknBuf + posWB) << 1; + wb[0] = PrivateMknBuf.sget4(posWB) << 1; posWB += 4; - wb[1] = sget4(PrivateMknBuf + posWB); + wb[1] = PrivateMknBuf.sget4(posWB); posWB += 4; - wb[3] = sget4(PrivateMknBuf + posWB); + wb[3] = PrivateMknBuf.sget4(posWB); posWB += 4; - wb[2] = sget4(PrivateMknBuf + posWB) << 1; + wb[2] = PrivateMknBuf.sget4(posWB) << 1; posWB += 4; if (tWB && (iCCT < 255)) @@ -878,12 +822,8 @@ void LibRaw::parseAdobeRAFMakernote() } posPrivateMknBuf += PrivateTagBytes; } - free(PrivateMknBuf); } #undef get_average_WB -#undef CHECKSPACE -#undef CHECKSPACE_ABS2 -#undef CHECKSPACE_ABS3 } void LibRaw::parseFujiMakernotes(unsigned tag, unsigned type, unsigned len, @@ -1046,7 +986,7 @@ void LibRaw::parseFujiMakernotes(unsigned tag, unsigned type, unsigned len, imFuji.ShutterType = get2(); break; case 0x1100: - imFuji.AutoBracketing = get2(); // AutoBracketing = 6 for pixel shift mode + imFuji.AutoBracketing = get2(); // AutoBracketing = 6 for pixel shift mode break; case 0x1101: imFuji.SequenceNumber = get2(); @@ -1114,6 +1054,12 @@ void LibRaw::parseFujiMakernotes(unsigned tag, unsigned type, unsigned len, case 0x1445: imFuji.DRangePriorityFixed = get2(); break; + case 0x1447: + stmread(imFuji.FujiModel, len, ifp); + break; + case 0x1448: + stmread(imFuji.FujiModel2, len, ifp); + break; } return; } @@ -1292,45 +1238,14 @@ void LibRaw::parse_fuji(int offset) imFuji.ExpoMidPointShift = a / b; imCommon.ExposureCalibrationShift += imFuji.ExpoMidPointShift; } - else if (tag == 0x2000) // WB_GRGBLevelsAuto + if (tag >= 0x2000 && tag <= 0x2410) { - get_average_WB(LIBRAW_WBI_Auto); - } - else if (tag == 0x2100) // WB_GRGBLevelsDaylight - { - get_average_WB(LIBRAW_WBI_FineWeather); - } - else if (tag == 0x2200) // WB_GRGBLevelsCloudy - { - get_average_WB(LIBRAW_WBI_Shade); - } - else if (tag == 0x2300) // WB_GRGBLevelsDaylightFluor - { - get_average_WB(LIBRAW_WBI_FL_D); - } - else if (tag == 0x2301) // WB_GRGBLevelsDayWhiteFluor - { - get_average_WB(LIBRAW_WBI_FL_N); - } - else if (tag == 0x2302) // WB_GRGBLevelsWhiteFluorescent - { - get_average_WB(LIBRAW_WBI_FL_W); - } - else if (tag == 0x2310) // WB_GRGBLevelsWarmWhiteFluor - { - get_average_WB(LIBRAW_WBI_FL_WW); - } - else if (tag == 0x2311) // WB_GRGBLevelsLivingRoomWarmWhiteFluor - { - get_average_WB(LIBRAW_WBI_FL_L); - } - else if (tag == 0x2400) // WB_GRGBLevelsTungsten - { - get_average_WB(LIBRAW_WBI_Tungsten); - } - else if (tag == 0x2410) - { - get_average_WB(LIBRAW_WBI_Flash); + for (int q = 0; q < tag2wbtable_size; q++) + if (tag2wbtable[q].tag == tag) + { + get_average_WB(tag2wbtable[q].wb); + break; + } } else if (tag == 0x2f00) // WB_GRGBLevels { diff --git a/src/metadata/hasselblad_model.cpp b/src/metadata/hasselblad_model.cpp index b20da5efa..042a63fbe 100644 --- a/src/metadata/hasselblad_model.cpp +++ b/src/metadata/hasselblad_model.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify @@ -43,9 +43,10 @@ void LibRaw::process_Hassy_Lens (int LensMount) { // focal1*10000ULL + focal2*10 + version; char *ps; int c; - char *q = strchr(imgdata.lens.Lens, ' '); - if(!q) return ; - c = atoi(q+1); + char *q = strchr(imgdata.lens.Lens, ' '); + if (!q) + return; + c = atoi(q +1); if (!c) return; @@ -315,6 +316,11 @@ static const char *Hasselblad_SensorEnclosures[] = { strcpy(imHassy.Sensor, "-100c"); cpynorm("100-17-Coated5"); + } else if ((imHassy.SensorCode == 20) && + (imHassy.CoatingCode == 6)) { + strcpy(imHassy.Sensor, "-100c"); + cpynorm("100-20-Coated6"); + } else if ((raw_width == 4090) || // V96C ((raw_width == 4096) && (raw_height == 4096)) || ((raw_width == 4088) && (raw_height == 4088)) || // Adobe crop @@ -446,12 +452,20 @@ static const char *Hasselblad_SensorEnclosures[] = { } else if (((raw_width == 12000) && (raw_height == 8816)) || ((raw_width == 11608) && (raw_height == 8708)) || // Adobe crop - ((raw_width == 11600) && (raw_height == 8700))) { // Phocus crop + ((raw_width == 11600) && (raw_height == 8700))) { // Phocus crop strcpy(imHassy.Sensor, "-100c"); cpynorm("100-17-Coated5"); if (!imHassy.SensorCode) imHassy.SensorCode = 17; if (!imHassy.CoatingCode) imHassy.CoatingCode = 5; + } else if (((raw_width == 11904) && (raw_height == 8842)) || // X2D 100C + ((raw_width == 11664) && (raw_height == 8750)) || // Adobe crop + ((raw_width == 11656) && (raw_height == 8742))) { // Phocus crop + strcpy(imHassy.Sensor, "-100c"); + cpynorm("100-20-Coated6"); + if (!imHassy.SensorCode) imHassy.SensorCode = 20; + if (!imHassy.CoatingCode) imHassy.CoatingCode = 6; + } if (raw_width == 4090) @@ -470,7 +484,8 @@ static const char *Hasselblad_SensorEnclosures[] = { ((raw_width == 8384) && (raw_height == 6304)) || ((raw_width == 9044) && (raw_height == 6732)) || ((raw_width == 10320) && (raw_height == 7752)) || - ((raw_width == 12000) && (raw_height == 8816)) + ((raw_width == 12000) && (raw_height == 8816)) || + ((raw_width == 11904) && (raw_height == 8842)) ) imHassy.uncropped = 1; @@ -533,6 +548,10 @@ static const char *Hasselblad_SensorEnclosures[] = { } } } + +// printf (">> SensorCode: %d, CoatingCode: %d, Sensor: %s\n", imHassy.SensorCode, imHassy.CoatingCode, imHassy.Sensor); +// printf (">> raw_width: %d, raw_height: %d\n", raw_width, raw_height); + if (normalized_model[0] && !CM_found) CM_found = adobe_coeff(maker_index, normalized_model); } diff --git a/src/metadata/identify.cpp b/src/metadata/identify.cpp index aabbf85c1..bb43081bc 100644 --- a/src/metadata/identify.cpp +++ b/src/metadata/identify.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. @@ -42,8 +42,8 @@ static const struct {LIBRAW_CAMERAMAKER_Nikon, "Nikon"}, {LIBRAW_CAMERAMAKER_Nokia, "Nokia"}, {LIBRAW_CAMERAMAKER_Olympus, "Olympus"}, - {LIBRAW_CAMERAMAKER_OmDigital, "OM Digital"}, - {LIBRAW_CAMERAMAKER_Ricoh, "Ricoh"}, + {LIBRAW_CAMERAMAKER_OmDigital, "OM Digital"}, + {LIBRAW_CAMERAMAKER_Ricoh, "Ricoh"}, {LIBRAW_CAMERAMAKER_Pentax, "Pentax"}, {LIBRAW_CAMERAMAKER_PhaseOne, "Phase One"}, {LIBRAW_CAMERAMAKER_PhaseOne, "PhaseOne"}, @@ -130,50 +130,6 @@ const char *LibRaw::cameramakeridx2maker(unsigned maker) } -#ifdef LIBRAW_OLD_VIDEO_SUPPORT -void LibRaw::fixupArri() -{ - struct alist_t - { - const char *a_model; - const char *a_software; - ushort a_width,a_height; - int a_black; - unsigned a_filters; - float a_aspect; - } - alist[] = - { - {"ALEXA65", "Alexa65 XT", 6560 ,3100, 256,0x49494949,1.f}, - - {"ALEXALF", "Alexa LF Plus W", 3840 ,2160, 256,0x49494949,1.0f }, - {"ALEXALF", "Alexa LF Plus W", 4448 ,1856, 256,0x49494949,0.75f }, - {"ALEXALF", "Alexa LF Plus W", 4448 ,3096, 256,0x49494949,1.f }, - - {"ALEXA", "Alexa Plus 4:3 SXT", 2880 ,1620, 256,0x61616161,.75f}, - {"ALEXA", "Alexa Plus 4:3 SXT", 3168 ,1782, 256,0x61616161,0.75f}, - {"ALEXA", "Alexa Plus 4:3 SXT", 3424 ,2202, 256,0x61616161,1.f}, - {"ALEXA", "Alexa Plus 4:3 SXT", 2592 ,2160, 256,0x61616161,1.12f}, - - {"ALEXA", "Alexa Plus 4:3 XT", 2592 ,2160, 256,0x61616161,1.12f}, - {"ALEXA", "Alexa Plus 4:3 XT", 2880 ,2160, 256,0x61616161,1.f}, - {"ALEXA", "Alexa Plus 4:3 XT", 2880 ,1620, 256,0x61616161,0.75f}, - {"ALEXA", "Alexa Plus 4:3 XT", 3424 ,2202, 256,0x61616161,1.f}, - }; - for(int i = 0; i < int(sizeof(alist)/sizeof(alist[0])); i++) - if(!strncasecmp(model,alist[i].a_model,strlen(alist[i].a_model)) && software - && !strncasecmp(software,alist[i].a_software,strlen(alist[i].a_software)) - && width == alist[i].a_width && height == alist[i].a_height) - { - filters = alist[i].a_filters; - black = alist[i].a_black; - pixel_aspect = alist[i].a_aspect; - strcpy(model,software); - software[0]=0; - return; - } -} -#endif /* Identify which camera created this file, and set global variables accordingly. @@ -208,7 +164,7 @@ void LibRaw::identify() { 4176, 3062, 96, 17, 8, 0, 0, 16, 0, 7, 0x49 }, // 19 "PowerShot SX50 HS" { 4192, 3062, 96, 17, 24, 0, 0, 16, 0, 0, 0x49 }, // 20 "PowerShot G16", "PowerShot S120" { 4312, 2876, 22, 18, 0, 2 }, // 21 "EOS 450D" - { 4352, 2850, 144, 46, 0, 0 }, // 22 APS-C crop mode: "EOS R" + { 4352, 2850, 144, 46, 0, 0 }, // 22 APS-C crop mode: "EOS R", "EOS Ra" { 4352, 2874, 62, 18, 0, 0 }, // 23 "EOS 1100D" { 4476, 2954, 90, 34, 0, 0 }, // 24 "EOS 5D" { 4480, 3348, 12, 10, 36, 12, 0, 0, 0, 18, 0x49 }, // 25 "PowerShot G10" @@ -231,174 +187,175 @@ void LibRaw::identify() { 5920, 3950, 122, 80, 2, 0 }, // 42 "EOS 5D Mark III" { 6096, 4051, 76, 35, 0, 0 }, // 43 "EOS 1500D" { 6096, 4056, 72, 34, 0, 0 }, // 44 "EOS M3", "EOS 760D", "EOS 750D" - { 6288, 4056, 264, 36, 0, 0 }, // 45 "EOS M5", "EOS M100", "EOS M6", "PowerShot G1 X Mark III", "EOS 80D", "EOS 800D", "EOS 77D", "EOS 200D", "EOS 250D", "EOS M50" + { 6288, 4056, 264, 36, 0, 0 }, // 45 "EOS M5", "EOS M100", "EOS M6", "PowerShot G1 X Mark III", "EOS 80D", "EOS 800D", "EOS 77D", "EOS 200D", "EOS 250D", "EOS M50", "EOS R100" { 6384, 4224, 120, 44, 0, 0 }, // 46 "EOS 6D Mark II", "EOS RP" { 6880, 4544, 136, 42, 0, 0 }, // 47 "EOS 5D Mark IV" - { 6888, 4546, 146, 48, 0, 0 }, // 48 "EOS R" + { 6888, 4546, 146, 48, 0, 0 }, // 48 "EOS R", "EOS Ra" { 7128, 4732, 144, 72, 0, 0 }, // 49 "EOS M6 II", "EOS 90D" { 8896, 5920, 160, 64, 0, 0 }, // 50 "EOS 5DS", "EOS 5DS R" - { 6192, 4152, 160, 120, 0, 0}, // EOS R3 - { 6192, 4060, 168, 52, 24, 8, 16,48,32,0,} // EOS R10 + { 6192, 4152, 160, 120, 0, 0}, // EOS R3 + { 6192, 4060, 168, 52, 24, 8, 16,48,32,0}, // EOS R10 + { 6188, 4120, 154, 96, 12, 0, 16, 48, 32, 0}, // EOS R6mk2 }; static const libraw_custom_camera_t const_table[] = { - { 786432, 1024, 768, 0, 0, 0, 0, 0, 0x94, 0, 0, "AVT", "F-080C" }, - { 1447680, 1392, 1040, 0, 0, 0, 0, 0, 0x94, 0, 0, "AVT", "F-145C" }, - { 1920000, 1600, 1200, 0, 0, 0, 0, 0, 0x94, 0, 0, "AVT", "F-201C" }, - { 5067304, 2588, 1958, 0, 0, 0, 0, 0, 0x94, 0, 0, "AVT", "F-510C" }, - { 5067316, 2588, 1958, 0, 0, 0, 0, 0, 0x94, 0, 0, "AVT", "F-510C", 12 }, - { 10134608, 2588, 1958, 0, 0, 0, 0, 9, 0x94, 0, 0, "AVT", "F-510C" }, - { 10134620, 2588, 1958, 0, 0, 0, 0, 9, 0x94, 0, 0, "AVT", "F-510C", 12 }, - { 16157136, 3272, 2469, 0, 0, 0, 0, 9, 0x94, 0, 0, "AVT", "F-810C" }, - { 3995136, 1632, 1224, 0, 0, 0, 0, 8, 0x61, 0, 1, "AgfaPhoto", "DC-833m" }, - { 15980544, 3264, 2448, 0, 0, 0, 0, 8, 0x61, 0, 1, "AgfaPhoto", "DC-833m" }, - { 9631728, 2532, 1902, 0, 0, 0, 0, 96, 0x61, 0, 0, "Alcatel", "5035D" }, - { 31850496, 4608, 3456, 0, 0, 0, 0, 0, 0x94, 0, 0, "GITUP", "GIT2 4:3" }, - { 23887872, 4608, 2592, 0, 0, 0, 0, 0, 0x94, 0, 0, "GITUP", "GIT2 16:9" }, - { 32257024, 4624, 3488, 8, 2, 16, 2, 0, 0x94, 0, 0, "GITUP", "GIT2P 4:3" }, - { 24192768, 4624, 2616, 8, 2, 16, 2, 0, 0x94, 0, 0, "GITUP", "GIT2P 16:9" }, - { 18016000, 4000, 2252, 0, 0, 0, 0, 0, 0x94, 0, 0, "GITUP", "G3DUO 16:9" }, + { 786432, 1024, 768, 0, 0, 0, 0, 0, 0x94, 0, 0, "AVT", "F-080C" }, + { 1447680, 1392, 1040, 0, 0, 0, 0, 0, 0x94, 0, 0, "AVT", "F-145C" }, + { 1920000, 1600, 1200, 0, 0, 0, 0, 0, 0x94, 0, 0, "AVT", "F-201C" }, + { 5067304, 2588, 1958, 0, 0, 0, 0, 0, 0x94, 0, 0, "AVT", "F-510C" }, + { 5067316, 2588, 1958, 0, 0, 0, 0, 0, 0x94, 0, 0, "AVT", "F-510C", 12 }, + { 10134608, 2588, 1958, 0, 0, 0, 0, 9, 0x94, 0, 0, "AVT", "F-510C" }, + { 10134620, 2588, 1958, 0, 0, 0, 0, 9, 0x94, 0, 0, "AVT", "F-510C", 12 }, + { 16157136, 3272, 2469, 0, 0, 0, 0, 9, 0x94, 0, 0, "AVT", "F-810C" }, + { 3995136, 1632, 1224, 0, 0, 0, 0, 8, 0x61, 0, 1, "AgfaPhoto", "DC-833m" }, + { 15980544, 3264, 2448, 0, 0, 0, 0, 8, 0x61, 0, 1, "AgfaPhoto", "DC-833m" }, + { 9631728, 2532, 1902, 0, 0, 0, 0, 96, 0x61, 0, 0, "Alcatel", "5035D" }, + { 31850496, 4608, 3456, 0, 0, 0, 0, 0, 0x94, 0, 0, "GITUP", "GIT2 4:3" }, + { 23887872, 4608, 2592, 0, 0, 0, 0, 0, 0x94, 0, 0, "GITUP", "GIT2 16:9" }, + { 32257024, 4624, 3488, 8, 2, 16, 2, 0, 0x94, 0, 0, "GITUP", "GIT2P 4:3" }, + { 24192768, 4624, 2616, 8, 2, 16, 2, 0, 0x94, 0, 0, "GITUP", "GIT2P 16:9" }, + { 18016000, 4000, 2252, 0, 0, 0, 0, 0, 0x94, 0, 0, "GITUP", "G3DUO 16:9" }, // {24000000, 4000, 3000, 0, 0, 0, 0, 0, 0x94, 0, 0, "GITUP", // "G3DUO 4:3"}, // Conflict w/ Samsung WB550 // Android Raw dumps id start // File Size in bytes Horizontal Res Vertical Flag then bayer order eg // 0x16 bbgr 0x94 rggb - { 1540857, 2688, 1520, 0, 0, 0, 0, 1, 0x61, 0, 0, "Samsung", "S3" }, - { 2658304, 1212, 1096, 0, 0, 0, 0, 1, 0x16, 0, 0, "LG", "G3FrontMipi" }, - { 2842624, 1296, 1096, 0, 0, 0, 0, 1, 0x16, 0, 0, "LG", "G3FrontQCOM" }, - { 2969600, 1976, 1200, 0, 0, 0, 0, 1, 0x16, 0, 0, "Xiaomi", "MI3wMipi" }, - { 3170304, 1976, 1200, 0, 0, 0, 0, 1, 0x16, 0, 0, "Xiaomi", "MI3wQCOM" }, - { 3763584, 1584, 1184, 0, 0, 0, 0, 96, 0x61, 0, 0, "I_Mobile", "I_StyleQ6" }, - { 5107712, 2688, 1520, 0, 0, 0, 0, 1, 0x61, 0, 0, "OmniVisi", "UltraPixel1" }, - { 5382640, 2688, 1520, 0, 0, 0, 0, 1, 0x61, 0, 0, "OmniVisi", "UltraPixel2" }, - { 5664912, 2688, 1520, 0, 0, 0, 0, 1, 0x61, 0, 0, "OmniVisi", "4688" }, - { 5664912, 2688, 1520, 0, 0, 0, 0, 1, 0x61, 0, 0, "OmniVisi", "4688" }, - { 5364240, 2688, 1520, 0, 0, 0, 0, 1, 0x61, 0, 0, "OmniVisi", "4688" }, - { 6299648, 2592, 1944, 0, 0, 0, 0, 1, 0x16, 0, 0, "OmniVisi", "OV5648" }, - { 6721536, 2592, 1944, 0, 0, 0, 0, 0, 0x16, 0, 0, "OmniVisi", "OV56482" }, - { 6746112, 2592, 1944, 0, 0, 0, 0, 0, 0x16, 0, 0, "HTC", "OneSV" }, - { 9631728, 2532, 1902, 0, 0, 0, 0, 96, 0x61, 0, 0, "Sony", "5mp" }, - { 9830400, 2560, 1920, 0, 0, 0, 0, 96, 0x61, 0, 0, "NGM", "ForwardArt" }, - { 10186752, 3264, 2448, 0, 0, 0, 0, 1, 0x94, 0, 0, "Sony", "IMX219-mipi 8mp" }, - { 10223360, 2608, 1944, 0, 0, 0, 0, 96, 0x16, 0, 0, "Sony", "IMX" }, - { 10782464, 3282, 2448, 0, 0, 0, 0, 0, 0x16, 0, 0, "HTC", "MyTouch4GSlide" }, - { 10788864, 3282, 2448, 0, 0, 0, 0, 0, 0x16, 0, 0, "Xperia", "L" }, - { 15967488, 3264, 2446, 0, 0, 0, 0, 96, 0x16, 0, 0, "OmniVison", "OV8850" }, - { 16224256, 4208, 3082, 0, 0, 0, 0, 1, 0x16, 0, 0, "LG", "G3MipiL" }, - { 16424960, 4208, 3120, 0, 0, 0, 0, 1, 0x16, 0, 0, "IMX135", "MipiL" }, - { 17326080, 4164, 3120, 0, 0, 0, 0, 1, 0x16, 0, 0, "LG", "G3LQCom" }, - { 17522688, 4212, 3120, 0, 0, 0, 0, 0, 0x16, 0, 0, "Sony", "IMX135-QCOM" }, - { 19906560, 4608, 3456, 0, 0, 0, 0, 1, 0x16, 0, 0, "Gione", "E7mipi" }, - { 19976192, 5312, 2988, 0, 0, 0, 0, 1, 0x16, 0, 0, "LG", "G4" }, - { 20389888, 4632, 3480, 0, 0, 0, 0, 1, 0x16, 0, 0, "Xiaomi", "RedmiNote3Pro" }, - { 20500480, 4656, 3496, 0, 0, 0, 0, 1, 0x94, 0, 0, "Sony", "IMX298-mipi 16mp" }, - { 21233664, 4608, 3456, 0, 0, 0, 0, 1, 0x16, 0, 0, "Gione", "E7qcom" }, - { 26023936, 4192, 3104, 0, 0, 0, 0, 96, 0x94, 0, 0, "THL", "5000" }, - { 26257920, 4208, 3120, 0, 0, 0, 0, 96, 0x94, 0, 0, "Sony", "IMX214" }, - { 26357760, 4224, 3120, 0, 0, 0, 0, 96, 0x61, 0, 0, "OV", "13860" }, - { 41312256, 5248, 3936, 0, 0, 0, 0, 96, 0x61, 0, 0, "Meizu", "MX4" }, - { 42923008, 5344, 4016, 0, 0, 0, 0, 96, 0x61, 0, 0, "Sony", "IMX230" }, + { 1540857, 2688, 1520, 0, 0, 0, 0, 1, 0x61, 0, 0, "Samsung", "S3" }, + { 2658304, 1212, 1096, 0, 0, 0, 0, 1, 0x16, 0, 0, "LG", "G3FrontMipi" }, + { 2842624, 1296, 1096, 0, 0, 0, 0, 1, 0x16, 0, 0, "LG", "G3FrontQCOM" }, + { 2969600, 1976, 1200, 0, 0, 0, 0, 1, 0x16, 0, 0, "Xiaomi", "MI3wMipi" }, + { 3170304, 1976, 1200, 0, 0, 0, 0, 1, 0x16, 0, 0, "Xiaomi", "MI3wQCOM" }, + { 3763584, 1584, 1184, 0, 0, 0, 0, 96, 0x61, 0, 0, "I_Mobile", "I_StyleQ6" }, + { 5107712, 2688, 1520, 0, 0, 0, 0, 1, 0x61, 0, 0, "OmniVisi", "UltraPixel1" }, + { 5382640, 2688, 1520, 0, 0, 0, 0, 1, 0x61, 0, 0, "OmniVisi", "UltraPixel2" }, + { 5664912, 2688, 1520, 0, 0, 0, 0, 1, 0x61, 0, 0, "OmniVisi", "4688" }, + { 5664912, 2688, 1520, 0, 0, 0, 0, 1, 0x61, 0, 0, "OmniVisi", "4688" }, + { 5364240, 2688, 1520, 0, 0, 0, 0, 1, 0x61, 0, 0, "OmniVisi", "4688" }, + { 6299648, 2592, 1944, 0, 0, 0, 0, 1, 0x16, 0, 0, "OmniVisi", "OV5648" }, + { 6721536, 2592, 1944, 0, 0, 0, 0, 0, 0x16, 0, 0, "OmniVisi", "OV56482" }, + { 6746112, 2592, 1944, 0, 0, 0, 0, 0, 0x16, 0, 0, "HTC", "OneSV" }, + { 9631728, 2532, 1902, 0, 0, 0, 0, 96, 0x61, 0, 0, "Sony", "5mp" }, + { 9830400, 2560, 1920, 0, 0, 0, 0, 96, 0x61, 0, 0, "NGM", "ForwardArt" }, + { 10186752, 3264, 2448, 0, 0, 0, 0, 1, 0x94, 0, 0, "Sony", "IMX219-mipi 8mp" }, + { 10223360, 2608, 1944, 0, 0, 0, 0, 96, 0x16, 0, 0, "Sony", "IMX" }, + { 10782464, 3282, 2448, 0, 0, 0, 0, 0, 0x16, 0, 0, "HTC", "MyTouch4GSlide" }, + { 10788864, 3282, 2448, 0, 0, 0, 0, 0, 0x16, 0, 0, "Xperia", "L" }, + { 15967488, 3264, 2446, 0, 0, 0, 0, 96, 0x16, 0, 0, "OmniVison", "OV8850" }, + { 16224256, 4208, 3082, 0, 0, 0, 0, 1, 0x16, 0, 0, "LG", "G3MipiL" }, + { 16424960, 4208, 3120, 0, 0, 0, 0, 1, 0x16, 0, 0, "IMX135", "MipiL" }, + { 17326080, 4164, 3120, 0, 0, 0, 0, 1, 0x16, 0, 0, "LG", "G3LQCom" }, + { 17522688, 4212, 3120, 0, 0, 0, 0, 0, 0x16, 0, 0, "Sony", "IMX135-QCOM" }, + { 19906560, 4608, 3456, 0, 0, 0, 0, 1, 0x16, 0, 0, "Gione", "E7mipi" }, + { 19976192, 5312, 2988, 0, 0, 0, 0, 1, 0x16, 0, 0, "LG", "G4" }, + { 20389888, 4632, 3480, 0, 0, 0, 0, 1, 0x16, 0, 0, "Xiaomi", "RedmiNote3Pro" }, + { 20500480, 4656, 3496, 0, 0, 0, 0, 1, 0x94, 0, 0, "Sony", "IMX298-mipi 16mp" }, + { 21233664, 4608, 3456, 0, 0, 0, 0, 1, 0x16, 0, 0, "Gione", "E7qcom" }, + { 26023936, 4192, 3104, 0, 0, 0, 0, 96, 0x94, 0, 0, "THL", "5000" }, + { 26257920, 4208, 3120, 0, 0, 0, 0, 96, 0x94, 0, 0, "Sony", "IMX214" }, + { 26357760, 4224, 3120, 0, 0, 0, 0, 96, 0x61, 0, 0, "OV", "13860" }, + { 41312256, 5248, 3936, 0, 0, 0, 0, 96, 0x61, 0, 0, "Meizu", "MX4" }, + { 42923008, 5344, 4016, 0, 0, 0, 0, 96, 0x61, 0, 0, "Sony", "IMX230" }, // Android Raw dumps id end - { 20137344, 3664, 2748, 0, 0, 0, 0, 0x40, 0x49, 0, 0, "Aptina", "MT9J003", 0xffff }, - { 2868726, 1384, 1036, 0, 0, 0, 0, 64, 0x49, 0, 8, "Baumer", "TXG14", 1078 }, - { 6553440, 2664, 1968, 4, 4, 44, 4, 40, 0x94, 0, 2, "Canon", "PowerShot A460" }, // chdk hack - { 9243240, 3152, 2346, 12, 7, 44, 13, 40, 0x49, 0, 2, "Canon", "PowerShot A470" }, // chdk hack - { 6653280, 2672, 1992, 10, 6, 42, 2, 40, 0x94, 0, 2, "Canon", "PowerShot A530" }, // chdk hack - { 6573120, 2672, 1968, 12, 8, 44, 0, 40, 0x94, 0, 2, "Canon", "PowerShot A610" }, // chdk hack - { 9219600, 3152, 2340, 36, 12, 4, 0, 40, 0x94, 0, 2, "Canon", "PowerShot A620" }, // chdk hack - { 10383120, 3344, 2484, 12, 6, 44, 6, 40, 0x94, 0, 2, "Canon", "PowerShot A630" }, // chdk hack - { 12945240, 3736, 2772, 12, 6, 52, 6, 40, 0x94, 0, 2, "Canon", "PowerShot A640" }, // chdk hack - { 15636240, 4104, 3048, 48, 12, 24, 12, 40, 0x94, 0, 2, "Canon", "PowerShot A650 IS" }, // chdk hack - { 10341600, 3336, 2480, 6, 5, 32, 3, 40, 0x94, 0, 2, "Canon", "PowerShot A720 IS" }, // chdk hack - { 24724224, 4704, 3504, 8, 16, 56, 8, 40, 0x49, 0, 2, "Canon", "PowerShot A3300 IS" }, // chdk hack - { 18763488, 4104, 3048, 10, 22, 82, 22, 8, 0x49, 0, 0, "Canon", "PowerShot D10" }, // ? chdk hack ? - { 19493760, 4160, 3124, 104, 12, 8, 66, 40, 0x49, 0, 2, "Canon", "PowerShot S100" }, // chdk hack CRW - { 7710960, 2888, 2136, 44, 8, 4, 0, 40, 0x94, 0, 2, "Canon", "PowerShot S3 IS" }, // chdk hack - { 5298000, 2400, 1766, 12, 12, 44, 2, 40, 0x94, 0, 2, "Canon", "PowerShot SD300" }, // chdk hack - { 18653760, 4080, 3048, 24, 12, 24, 12, 40, 0x94, 0, 2, "Canon", "PowerShot SX20 IS" }, // chdk hack - { 21936096, 4464, 3276, 25, 10, 73, 12, 40, 0x16, 0, 2, "Canon", "PowerShot SX30 IS" }, // chdk hack - { 19167840, 4176, 3060, 96, 16, 8, 0, 40, 0x94, 0, 2, "Canon", "PowerShot SX40 HS" }, // chdk hack CR2 - { 15467760, 3720, 2772, 6, 12, 30, 0, 40, 0x94, 0, 2, "Canon", "PowerShot SX110 IS" }, // chdk hack - { 15534576, 3728, 2778, 12, 9, 44, 9, 40, 0x94, 0, 2, "Canon", "PowerShot SX120 IS" }, // chdk hack - { 19131120, 4168, 3060, 92, 16, 4, 1, 40, 0x94, 0, 2, "Canon", "PowerShot SX220 HS" }, // chdk hack - { 31663200, 5344, 3950, 96, 18, 0, 0, 40, 0x94, 0, 2, "Canon", "PowerShot SX710 HS" }, // chdk hack - { 30858240, 5248, 3920, 8, 16, 56, 16, 40, 0x94, 0, 2, "Canon", "IXUS 160" }, // chdk hack - { 1976352, 1632, 1211, 0, 2, 0, 1, 0, 0x94, 0, 1, "Casio", "QV-2000UX" }, - { 3217760, 2080, 1547, 0, 0, 10, 1, 0, 0x94, 0, 1, "Casio", "QV-3*00EX" }, - { 6218368, 2585, 1924, 0, 0, 9, 0, 0, 0x94, 0, 1, "Casio", "QV-5700" }, - { 7816704, 2867, 2181, 0, 0, 34, 36, 0, 0x16, 0, 1, "Casio", "EX-Z60" }, - { 2937856, 1621, 1208, 0, 0, 1, 0, 0, 0x94, 7, 13, "Casio", "EX-S20" }, - { 4948608, 2090, 1578, 0, 0, 32, 34, 0, 0x94, 7, 1, "Casio", "EX-S100" }, - { 6054400, 2346, 1720, 2, 0, 32, 0, 0, 0x94, 7, 1, "Casio", "QV-R41" }, - { 7426656, 2568, 1928, 0, 0, 0, 0, 0, 0x94, 0, 1, "Casio", "EX-P505" }, - { 7530816, 2602, 1929, 0, 0, 22, 0, 0, 0x94, 7, 1, "Casio", "QV-R51" }, - { 7542528, 2602, 1932, 0, 0, 32, 0, 0, 0x94, 7, 1, "Casio", "EX-Z50" }, - { 7562048, 2602, 1937, 0, 0, 25, 0, 0, 0x16, 7, 1, "Casio", "EX-Z500" }, - { 7753344, 2602, 1986, 0, 0, 32, 26, 0, 0x94, 7, 1, "Casio", "EX-Z55" }, - { 9313536, 2858, 2172, 0, 0, 14, 30, 0, 0x94, 7, 1, "Casio", "EX-P600" }, - { 10834368, 3114, 2319, 0, 0, 27, 0, 0, 0x94, 0, 1, "Casio", "EX-Z750" }, - { 10843712, 3114, 2321, 0, 0, 25, 0, 0, 0x94, 0, 1, "Casio", "EX-Z75" }, - { 10979200, 3114, 2350, 0, 0, 32, 32, 0, 0x94, 7, 1, "Casio", "EX-P700" }, - { 12310144, 3285, 2498, 0, 0, 6, 30, 0, 0x94, 0, 1, "Casio", "EX-Z850" }, - { 12489984, 3328, 2502, 0, 0, 47, 35, 0, 0x94, 0, 1, "Casio", "EX-Z8" }, - { 15499264, 3754, 2752, 0, 0, 82, 0, 0, 0x94, 0, 1, "Casio", "EX-Z1050" }, - { 18702336, 4096, 3044, 0, 0, 24, 0, 80, 0x94, 7, 1, "Casio", "EX-ZR100" }, - { 7684000, 2260, 1700, 0, 0, 0, 0, 13, 0x94, 0, 1, "Casio", "QV-4000" }, - { 787456, 1024, 769, 0, 1, 0, 0, 0, 0x49, 0, 0, "Creative", "PC-CAM 600" }, - { 28829184, 4384, 3288, 0, 0, 0, 0, 36, 0x61, 0, 0, "DJI" }, - { 15151104, 4608, 3288, 0, 0, 0, 0, 0, 0x94, 0, 0, "Matrix" }, - { 3840000, 1600, 1200, 0, 0, 0, 0, 65, 0x49, 0, 0, "Foculus", "531C" }, - { 307200, 640, 480, 0, 0, 0, 0, 0, 0x94, 0, 0, "Generic" }, - { 62464, 256, 244, 1, 1, 6, 1, 0, 0x8d, 0, 0, "Kodak", "DC20" }, - { 124928, 512, 244, 1, 1, 10, 1, 0, 0x8d, 0, 0, "Kodak", "DC20" }, - { 1652736, 1536, 1076, 0, 52, 0, 0, 0, 0x61, 0, 0, "Kodak", "DCS200" }, - { 4159302, 2338, 1779, 1, 33, 1, 2, 0, 0x94, 0, 0, "Kodak", "C330" }, - { 4162462, 2338, 1779, 1, 33, 1, 2, 0, 0x94, 0, 0, "Kodak", "C330", 3160 }, - { 2247168, 1232, 912, 0, 0, 16, 0, 0, 0x00, 0, 0, "Kodak", "C330" }, - { 3370752, 1232, 912, 0, 0, 16, 0, 0, 0x00, 0, 0, "Kodak", "C330" }, - { 6163328, 2864, 2152, 0, 0, 0, 0, 0, 0x94, 0, 0, "Kodak", "C603" }, - { 6166488, 2864, 2152, 0, 0, 0, 0, 0, 0x94, 0, 0, "Kodak", "C603", 3160 }, - { 460800, 640, 480, 0, 0, 0, 0, 0, 0x00, 0, 0, "Kodak", "C603" }, - { 9116448, 2848, 2134, 0, 0, 0, 0, 0, 0x00, 0, 0, "Kodak", "C603" }, - { 12241200, 4040, 3030, 2, 0, 0, 13, 0, 0x49, 0, 0, "Kodak", "12MP" }, - { 12272756, 4040, 3030, 2, 0, 0, 13, 0, 0x49, 0, 0, "Kodak", "12MP", 31556 }, - { 18000000, 4000, 3000, 0, 0, 0, 0, 0, 0x00, 0, 0, "Kodak", "12MP" }, - { 614400, 640, 480, 0, 3, 0, 0, 64, 0x94, 0, 0, "Kodak", "KAI-0340" }, - { 15360000, 3200, 2400, 0, 0, 0, 0, 96, 0x16, 0, 0, "Lenovo", "A820" }, - { 3884928, 1608, 1207, 0, 0, 0, 0, 96, 0x16, 0, 0, "Micron", "2010", 3212 }, - { 1138688, 1534, 986, 0, 0, 0, 0, 0, 0x61, 0, 0, "Minolta", "RD175", 513 }, - { 1581060, 1305, 969, 0, 0, 18, 6, 6, 0x1e, 4, 1, "Nikon", "E900" }, // "diag raw" hack - { 2465792, 1638, 1204, 0, 0, 22, 1, 6, 0x4b, 5, 1, "Nikon", "E950" }, // "diag raw" hack; possibly also Nikon E700, E800, E775; + { 20137344, 3664, 2748, 0, 0, 0, 0, 64, 0x49, 0, 0, "Aptina", "MT9J003", 0xffff }, + { 2868726, 1384, 1036, 0, 0, 0, 0, 64, 0x49, 0, 8, "Baumer", "TXG14", 1078 }, + { 6553440, 2664, 1968, 4, 4, 44, 4, 40, 0x94, 0, 2, "Canon", "PowerShot A460" }, // chdk hack + { 9243240, 3152, 2346, 12, 7, 44, 13, 40, 0x49, 0, 2, "Canon", "PowerShot A470" }, // chdk hack + { 6653280, 2672, 1992, 10, 6, 42, 2, 40, 0x94, 0, 2, "Canon", "PowerShot A530" }, // chdk hack + { 6573120, 2672, 1968, 12, 8, 44, 0, 40, 0x94, 0, 2, "Canon", "PowerShot A610" }, // chdk hack + { 9219600, 3152, 2340, 36, 12, 4, 0, 40, 0x94, 0, 2, "Canon", "PowerShot A620" }, // chdk hack + { 10383120, 3344, 2484, 12, 6, 44, 6, 40, 0x94, 0, 2, "Canon", "PowerShot A630" }, // chdk hack + { 12945240, 3736, 2772, 12, 6, 52, 6, 40, 0x94, 0, 2, "Canon", "PowerShot A640" }, // chdk hack + { 15636240, 4104, 3048, 48, 12, 24, 12, 40, 0x94, 0, 2, "Canon", "PowerShot A650 IS" }, // chdk hack + { 10341600, 3336, 2480, 6, 5, 32, 3, 40, 0x94, 0, 2, "Canon", "PowerShot A720 IS" }, // chdk hack + { 24724224, 4704, 3504, 8, 16, 56, 8, 40, 0x49, 0, 2, "Canon", "PowerShot A3300 IS" }, // chdk hack + { 18763488, 4104, 3048, 10, 22, 82, 22, 8, 0x49, 0, 0, "Canon", "PowerShot D10" }, // ? chdk hack ? + { 19493760, 4160, 3124, 104, 12, 8, 66, 40, 0x49, 0, 2, "Canon", "PowerShot S100" }, // chdk hack CRW + { 7710960, 2888, 2136, 44, 8, 4, 0, 40, 0x94, 0, 2, "Canon", "PowerShot S3 IS" }, // chdk hack + { 5298000, 2400, 1766, 12, 12, 44, 2, 40, 0x94, 0, 2, "Canon", "PowerShot SD300" }, // chdk hack + { 18653760, 4080, 3048, 24, 12, 24, 12, 40, 0x94, 0, 2, "Canon", "PowerShot SX20 IS" }, // chdk hack + { 21936096, 4464, 3276, 25, 10, 73, 12, 40, 0x16, 0, 2, "Canon", "PowerShot SX30 IS" }, // chdk hack + { 19167840, 4176, 3060, 96, 16, 8, 0, 40, 0x94, 0, 2, "Canon", "PowerShot SX40 HS" }, // chdk hack CR2 + { 15467760, 3720, 2772, 6, 12, 30, 0, 40, 0x94, 0, 2, "Canon", "PowerShot SX110 IS" }, // chdk hack + { 15534576, 3728, 2778, 12, 9, 44, 9, 40, 0x94, 0, 2, "Canon", "PowerShot SX120 IS" }, // chdk hack + { 19131120, 4168, 3060, 92, 16, 4, 1, 40, 0x94, 0, 2, "Canon", "PowerShot SX220 HS" }, // chdk hack + { 31663200, 5344, 3950, 96, 18, 0, 0, 40, 0x94, 0, 2, "Canon", "PowerShot SX710 HS" }, // chdk hack + { 30858240, 5248, 3920, 8, 16, 56, 16, 40, 0x94, 0, 2, "Canon", "IXUS 160" }, // chdk hack + { 1976352, 1632, 1211, 0, 2, 0, 1, 0, 0x94, 0, 1, "Casio", "QV-2000UX" }, + { 3217760, 2080, 1547, 0, 0, 10, 1, 0, 0x94, 0, 1, "Casio", "QV-3*00EX" }, + { 6218368, 2585, 1924, 0, 0, 9, 0, 0, 0x94, 0, 1, "Casio", "QV-5700" }, + { 7816704, 2867, 2181, 0, 0, 34, 36, 0, 0x16, 0, 1, "Casio", "EX-Z60" }, + { 2937856, 1621, 1208, 0, 0, 1, 0, 0, 0x94, 7, 13, "Casio", "EX-S20" }, + { 4948608, 2090, 1578, 0, 0, 32, 34, 0, 0x94, 7, 1, "Casio", "EX-S100" }, + { 6054400, 2346, 1720, 2, 0, 32, 0, 0, 0x94, 7, 1, "Casio", "QV-R41" }, + { 7426656, 2568, 1928, 0, 0, 0, 0, 0, 0x94, 0, 1, "Casio", "EX-P505" }, + { 7530816, 2602, 1929, 0, 0, 22, 0, 0, 0x94, 7, 1, "Casio", "QV-R51" }, + { 7542528, 2602, 1932, 0, 0, 32, 0, 0, 0x94, 7, 1, "Casio", "EX-Z50" }, + { 7562048, 2602, 1937, 0, 0, 25, 0, 0, 0x16, 7, 1, "Casio", "EX-Z500" }, + { 7753344, 2602, 1986, 0, 0, 32, 26, 0, 0x94, 7, 1, "Casio", "EX-Z55" }, + { 9313536, 2858, 2172, 0, 0, 14, 30, 0, 0x94, 7, 1, "Casio", "EX-P600" }, + { 10834368, 3114, 2319, 0, 0, 27, 0, 0, 0x94, 0, 1, "Casio", "EX-Z750" }, + { 10843712, 3114, 2321, 0, 0, 25, 0, 0, 0x94, 0, 1, "Casio", "EX-Z75" }, + { 10979200, 3114, 2350, 0, 0, 32, 32, 0, 0x94, 7, 1, "Casio", "EX-P700" }, + { 12310144, 3285, 2498, 0, 0, 6, 30, 0, 0x94, 0, 1, "Casio", "EX-Z850" }, + { 12489984, 3328, 2502, 0, 0, 47, 35, 0, 0x94, 0, 1, "Casio", "EX-Z8" }, + { 15499264, 3754, 2752, 0, 0, 82, 0, 0, 0x94, 0, 1, "Casio", "EX-Z1050" }, + { 18702336, 4096, 3044, 0, 0, 24, 0, 80, 0x94, 7, 1, "Casio", "EX-ZR100" }, + { 7684000, 2260, 1700, 0, 0, 0, 0, 13, 0x94, 0, 1, "Casio", "QV-4000" }, + { 787456, 1024, 769, 0, 1, 0, 0, 0, 0x49, 0, 0, "Creative", "PC-CAM 600" }, + { 28829184, 4384, 3288, 0, 0, 0, 0, 36, 0x61, 0, 0, "DJI" }, + { 15151104, 4608, 3288, 0, 0, 0, 0, 0, 0x94, 0, 0, "Matrix" }, + { 3840000, 1600, 1200, 0, 0, 0, 0, 65, 0x49, 0, 0, "Foculus", "531C" }, + { 307200, 640, 480, 0, 0, 0, 0, 0, 0x94, 0, 0, "Generic" }, + { 62464, 256, 244, 1, 1, 6, 1, 0, 0x8d, 0, 0, "Kodak", "DC20" }, + { 124928, 512, 244, 1, 1, 10, 1, 0, 0x8d, 0, 0, "Kodak", "DC20" }, + { 1652736, 1536, 1076, 0, 52, 0, 0, 0, 0x61, 0, 0, "Kodak", "DCS200" }, + { 4159302, 2338, 1779, 1, 33, 1, 2, 0, 0x94, 0, 0, "Kodak", "C330" }, + { 4162462, 2338, 1779, 1, 33, 1, 2, 0, 0x94, 0, 0, "Kodak", "C330", 3160 }, + { 2247168, 1232, 912, 0, 0, 16, 0, 0, 0x00, 0, 0, "Kodak", "C330" }, + { 3370752, 1232, 912, 0, 0, 16, 0, 0, 0x00, 0, 0, "Kodak", "C330" }, + { 6163328, 2864, 2152, 0, 0, 0, 0, 0, 0x94, 0, 0, "Kodak", "C603" }, + { 6166488, 2864, 2152, 0, 0, 0, 0, 0, 0x94, 0, 0, "Kodak", "C603", 3160 }, + { 460800, 640, 480, 0, 0, 0, 0, 0, 0x00, 0, 0, "Kodak", "C603" }, + { 9116448, 2848, 2134, 0, 0, 0, 0, 0, 0x00, 0, 0, "Kodak", "C603" }, + { 12241200, 4040, 3030, 2, 0, 0, 13, 0, 0x49, 0, 0, "Kodak", "12MP" }, + { 12272756, 4040, 3030, 2, 0, 0, 13, 0, 0x49, 0, 0, "Kodak", "12MP", 31556 }, + { 18000000, 4000, 3000, 0, 0, 0, 0, 0, 0x00, 0, 0, "Kodak", "12MP" }, + { 614400, 640, 480, 0, 3, 0, 0, 64, 0x94, 0, 0, "Kodak", "KAI-0340" }, + { 15360000, 3200, 2400, 0, 0, 0, 0, 96, 0x16, 0, 0, "Lenovo", "A820" }, + { 3884928, 1608, 1207, 0, 0, 0, 0, 96, 0x16, 0, 0, "Micron", "2010", 3212 }, + { 1138688, 1534, 986, 0, 0, 0, 0, 0, 0x61, 0, 0, "Minolta", "RD175", 513 }, + { 1581060, 1305, 969, 0, 0, 18, 6, 6, 0x1e, 4, 1, "Nikon", "E900" }, // "diag raw" hack + { 2465792, 1638, 1204, 0, 0, 22, 1, 6, 0x4b, 5, 1, "Nikon", "E950" }, // "diag raw" hack; possibly also Nikon E700, E800, E775; // Olympus C-2020Z - { 2940928, 1616, 1213, 0, 0, 0, 7, 30, 0x94, 0, 1, "Nikon", "E2100" }, // "diag raw" hack; also Nikon E2500 - { 4771840, 2064, 1541, 0, 0, 0, 1, 6, 0xe1, 0, 1, "Nikon", "E990" }, // "diag raw" hack; possibly also Nikon E880, E885, E995; + { 2940928, 1616, 1213, 0, 0, 0, 7, 30, 0x94, 0, 1, "Nikon", "E2100" }, // "diag raw" hack; also Nikon E2500 + { 4771840, 2064, 1541, 0, 0, 0, 1, 6, 0xe1, 0, 1, "Nikon", "E990" }, // "diag raw" hack; possibly also Nikon E880, E885, E995; // Olympus C-3030Z - { 4775936, 2064, 1542, 0, 0, 0, 0, 30, 0x94, 0, 1, "Nikon", "E3700" }, // "diag raw" hack; Nikon E3100, E3200, E3500; + { 4775936, 2064, 1542, 0, 0, 0, 0, 30, 0x94, 0, 1, "Nikon", "E3700" }, // "diag raw" hack; Nikon E3100, E3200, E3500; // Pentax "Optio 33WR"; possibly also Olympus C-740UZ - { 5865472, 2288, 1709, 0, 0, 0, 1, 6, 0xb4, 0, 1, "Nikon", "E4500" }, // "diag raw" hack; possibly also Olympus C-4040Z - { 5869568, 2288, 1710, 0, 0, 0, 0, 6, 0x16, 0, 1, "Nikon", "E4300" }, // "diag raw" hack; also Minolta "DiMAGE Z2" - { 7438336, 2576, 1925, 0, 0, 0, 1, 6, 0xb4, 0, 1, "Nikon", "E5000" }, // also Nikon E5700 - { 8998912, 2832, 2118, 0, 0, 0, 0, 30, 0x94, 7, 1, "Nikon", "COOLPIX S6" }, // "diag raw" hack - { 5939200, 2304, 1718, 0, 0, 0, 0, 30, 0x16, 0, 0, "Olympus", "C-770UZ" }, // possibly also Olympus C-4100Z, C-765UZ - { 3178560, 2064, 1540, 0, 0, 0, 0, 0, 0x94, 0, 1, "Pentax", "Optio S V1.01" }, - { 4841984, 2090, 1544, 0, 0, 22, 0, 0, 0x94, 7, 1, "Pentax", "Optio S" }, - { 6114240, 2346, 1737, 0, 0, 22, 0, 0, 0x94, 7, 1, "Pentax", "Optio S4" }, - { 10702848, 3072, 2322, 0, 0, 0, 21, 30, 0x94, 0, 1, "Pentax", "Optio 750Z" }, - { 4147200, 1920, 1080, 0, 0, 0, 0, 0, 0x49, 0, 0, "Photron", "BC2-HD" }, - { 4151666, 1920, 1080, 0, 0, 0, 0, 0, 0x49, 0, 0, "Photron", "BC2-HD", 8 }, - { 13248000, 2208, 3000, 0, 0, 0, 0, 13, 0x61, 0, 0, "Pixelink", "A782" }, - { 6291456, 2048, 1536, 0, 0, 0, 0, 96, 0x61, 0, 0, "RoverShot", "3320AF" }, - { 311696, 644, 484, 0, 0, 0, 0, 0, 0x16, 0, 8, "ST Micro", "STV680 VGA" }, - { 16098048, 3288, 2448, 0, 0, 24, 0, 9, 0x94, 0, 1, "Samsung", "S85" }, // hack - { 16215552, 3312, 2448, 0, 0, 48, 0, 9, 0x94, 0, 1, "Samsung", "S85" }, // hack - { 20487168, 3648, 2808, 0, 0, 0, 0, 13, 0x94, 5, 1, "Samsung", "WB550" }, - { 24000000, 4000, 3000, 0, 0, 0, 0, 13, 0x94, 5, 1, "Samsung", "WB550" }, - { 12582980, 3072, 2048, 0, 0, 0, 0, 33, 0x61, 0, 0, "Sinar", "", 68 }, // Sinarback 23; same res. as Leaf Volare & Cantare - { 33292868, 4080, 4080, 0, 0, 0, 0, 33, 0x61, 0, 0, "Sinar", "", 68 }, // Sinarback 44 - { 44390468, 4080, 5440, 0, 0, 0, 0, 33, 0x61, 0, 0, "Sinar", "", 68 }, // Sinarback 54 - { 1409024, 1376, 1024, 0, 0, 1, 0, 0, 0x49, 0, 0, "Sony", "XCD-SX910CR" }, - { 2818048, 1376, 1024, 0, 0, 1, 0, 97, 0x49, 0, 0, "Sony", "XCD-SX910CR" }, + { 5865472, 2288, 1709, 0, 0, 0, 1, 6, 0xb4, 0, 1, "Nikon", "E4500" }, // "diag raw" hack; possibly also Olympus C-4040Z + { 5869568, 2288, 1710, 0, 0, 0, 0, 6, 0x16, 0, 1, "Nikon", "E4300" }, // "diag raw" hack; also Minolta "DiMAGE Z2" + { 7438336, 2576, 1925, 0, 0, 0, 1, 6, 0xb4, 0, 1, "Nikon", "E5000" }, // also Nikon E5700 + { 8998912, 2832, 2118, 0, 0, 0, 0, 30, 0x94, 7, 1, "Nikon", "COOLPIX S6" }, // "diag raw" hack + { 5939200, 2304, 1718, 0, 0, 0, 0, 30, 0x16, 0, 0, "Olympus", "C-770UZ" }, // possibly also Olympus C-4100Z, C-765UZ + { 3178560, 2064, 1540, 0, 0, 0, 0, 0, 0x94, 0, 1, "Pentax", "Optio S V1.01" }, + { 4841984, 2090, 1544, 0, 0, 22, 0, 0, 0x94, 7, 1, "Pentax", "Optio S" }, + { 6114240, 2346, 1737, 0, 0, 22, 0, 0, 0x94, 7, 1, "Pentax", "Optio S4" }, + { 10702848, 3072, 2322, 0, 0, 0, 21, 30, 0x94, 0, 1, "Pentax", "Optio 750Z" }, + { 4147200, 1920, 1080, 0, 0, 0, 0, 0, 0x49, 0, 0, "Photron", "BC2-HD" }, + { 4151666, 1920, 1080, 0, 0, 0, 0, 0, 0x49, 0, 0, "Photron", "BC2-HD", 8 }, + { 13248000, 2208, 3000, 0, 0, 0, 0, 13, 0x61, 0, 0, "Pixelink", "A782" }, + { 6291456, 2048, 1536, 0, 0, 0, 0, 96, 0x61, 0, 0, "RoverShot", "3320AF" }, + { 311696, 644, 484, 0, 0, 0, 0, 0, 0x16, 0, 8, "ST Micro", "STV680 VGA" }, + { 16098048, 3288, 2448, 0, 0, 24, 0, 9, 0x94, 0, 1, "Samsung", "S85" }, // hack + { 16215552, 3312, 2448, 0, 0, 48, 0, 9, 0x94, 0, 1, "Samsung", "S85" }, // hack + { 20487168, 3648, 2808, 0, 0, 0, 0, 13, 0x94, 5, 1, "Samsung", "WB550" }, + { 24000000, 4000, 3000, 0, 0, 0, 0, 13, 0x94, 5, 1, "Samsung", "WB550" }, + { 12582980, 3072, 2048, 0, 0, 0, 0, 33, 0x61, 0, 0, "Sinar", "", 68 }, // Sinarback 23; same res. as Leaf Volare & Cantare + { 33292868, 4080, 4080, 0, 0, 0, 0, 33, 0x61, 0, 0, "Sinar", "", 68 }, // Sinarback 44 + { 44390468, 4080, 5440, 0, 0, 0, 0, 33, 0x61, 0, 0, "Sinar", "", 68 }, // Sinarback 54 + { 1409024, 1376, 1024, 0, 0, 1, 0, 0, 0x49, 0, 0, "Sony", "XCD-SX910CR" }, + { 2818048, 1376, 1024, 0, 0, 1, 0, 97, 0x49, 0, 0, "Sony", "XCD-SX910CR" }, }; libraw_custom_camera_t @@ -638,50 +595,6 @@ void LibRaw::identify() mask[0][3] = 1; filters = 0x61616161; } -#ifdef LIBRAW_OLD_VIDEO_SUPPORT - else if (!memcmp(head, "ARRI", 4)) - { - order = 0x4949; - fseek(ifp, 20, SEEK_SET); - width = get4(); - height = get4(); - strcpy(make, "ARRI"); - fseek(ifp, 668, SEEK_SET); - fread(model, 1, 64, ifp); - model[63] = 0; - fseek(ifp, 760, SEEK_SET); - fread(software, 1, 64, ifp); - if((unsigned char)software[0] == 0xff) software[0] = 0; - software[63] = 0; - data_offset = 4096; - load_raw = &LibRaw::packed_load_raw; - load_flags = 88; - filters = 0x61616161; - fixupArri(); - } - else if (!memcmp(head, "XPDS", 4)) - { - order = 0x4949; - fseek(ifp, 0x800, SEEK_SET); - fread(make, 1, 41, ifp); - raw_height = get2(); - raw_width = get2(); - fseek(ifp, 56, SEEK_CUR); - fread(model, 1, 30, ifp); - data_offset = 0x10000; - load_raw = &LibRaw::canon_rmf_load_raw; - gamma_curve(0, 12.25, 1, 1023); - } - else if (!memcmp(head + 4, "RED1", 4)) - { - strcpy(make, "Red"); - strcpy(model, "One"); - parse_redcine(); - load_raw = &LibRaw::redcine_load_raw; - gamma_curve(1 / 2.4, 12.92, 1, 4095); - filters = 0x49494949; - } -#endif else if (!memcmp(head, "DSC-Image", 9)) parse_rollei(); else if (!memcmp(head, "PWAD", 4)) @@ -1008,6 +921,11 @@ void LibRaw::identify() case 9: load_raw = &LibRaw::vc5_dng_load_raw_placeholder; break; +#endif +#ifdef USE_DNGSDK + case 52546: + load_raw = &LibRaw::jxl_dng_load_raw_placeholder; + break; #endif case 34892: load_raw = &LibRaw::lossy_dng_load_raw; @@ -1250,15 +1168,6 @@ dng_skip: if (dng_version && (tiff_samples < 1 || tiff_samples > 4)) is_raw = 0; // we do not handle DNGs with more than 4 values per pixel -#ifdef LIBRAW_OLD_VIDEO_SUPPORT -#ifdef NO_JASPER - if (load_raw == &LibRaw::redcine_load_raw) - { - is_raw = 0; - imgdata.process_warnings |= LIBRAW_WARN_NO_JASPER; - } -#endif -#endif #ifdef NO_JPEG if (load_raw == &LibRaw::kodak_jpeg_load_raw || load_raw == &LibRaw::lossy_dng_load_raw) @@ -2342,11 +2251,59 @@ void LibRaw::identify_finetune_dcr(char head[64], int fsize, int flen) case 4992: // X-E2S, X-E2, X-T10, X-T1, X100S, X100T, X70 left_margin = 4; break; + case 7872: // X-H2, full image + switch (FujiCropMode) + { + case 0: // no crop + top_margin = 6; + left_margin = 0; + width = 7752; + height = 5178; + break; + default: + /* try to guess from crop inset*/ + if (imgdata.sizes.raw_inset_crops[0].cwidth > 0 && imgdata.sizes.raw_inset_crops[0].cwidth <= raw_width && + imgdata.sizes.raw_inset_crops[0].cheight > 0 && imgdata.sizes.raw_inset_crops[0].cheight <= raw_height) + { + top_margin = imgdata.sizes.raw_inset_crops[0].ctop; + left_margin = imgdata.sizes.raw_inset_crops[0].cleft; + width = imgdata.sizes.raw_inset_crops[0].cwidth; + height = imgdata.sizes.raw_inset_crops[0].cheight; + } + break; + } + break; case 6336: // X-H2S - top_margin = 6; - left_margin = 0; - width = 6264; - height = 4176; + switch (FujiCropMode) + { + case 0: // no crop + top_margin = 6; + left_margin = 0; + if(!strcasecmp(model,"X-S20")) + width = 6252; + else + width = 6264; + height = 4176; + break; + case 2: /* sports finder*/ + case 4: /* Electronic shutter crop */ + left_margin = 630; + top_margin = 0; + height = 3348; + width = 5004; + break; + default: + /* try to guess from crop inset*/ + if (imgdata.sizes.raw_inset_crops[0].cwidth > 0 && imgdata.sizes.raw_inset_crops[0].cwidth <= raw_width + && imgdata.sizes.raw_inset_crops[0].cheight > 0 && imgdata.sizes.raw_inset_crops[0].cheight <= raw_height) + { + top_margin = imgdata.sizes.raw_inset_crops[0].ctop; + left_margin = imgdata.sizes.raw_inset_crops[0].cleft; + width = imgdata.sizes.raw_inset_crops[0].cwidth; + height = imgdata.sizes.raw_inset_crops[0].cheight; + } + break; + } break; case 6384: // X-T3, X-T4, X100V, X-S10, X-T30, X-Pro3 top_margin = 0; @@ -2363,7 +2320,7 @@ void LibRaw::identify_finetune_dcr(char head[64], int fsize, int flen) height = raw_height; break; case 4: // electronic shutter, high speed mode (1.25x crop) - left_margin = 624; + left_margin = 624; width = 5004; break; } @@ -2382,7 +2339,8 @@ void LibRaw::identify_finetune_dcr(char head[64], int fsize, int flen) case 11808: // GFX 100; no crop left_margin = 0; width = raw_width - 146; - height = raw_height - (top_margin = 2); + height = raw_height - 8; + top_margin = 2; if (tiff_bps == 16) maximum = 0xffff; default: @@ -2429,7 +2387,17 @@ void LibRaw::identify_finetune_dcr(char head[64], int fsize, int flen) flip = 6; break; default: - /* insert model name-based width/height/margins/etc. assignments */ + /* insert model name-based width/height/margins/etc. assignments */ + + /* raw_inset_crops default*/ + if (imgdata.sizes.raw_inset_crops[0].cwidth > 0 && imgdata.sizes.raw_inset_crops[0].cwidth <= raw_width && + imgdata.sizes.raw_inset_crops[0].cheight > 0 && imgdata.sizes.raw_inset_crops[0].cheight <= raw_height) + { + top_margin = imgdata.sizes.raw_inset_crops[0].ctop; + left_margin = imgdata.sizes.raw_inset_crops[0].cleft; + width = imgdata.sizes.raw_inset_crops[0].cwidth; + height = imgdata.sizes.raw_inset_crops[0].cheight; + } break; } } @@ -2690,6 +2658,13 @@ void LibRaw::identify_finetune_dcr(char head[64], int fsize, int flen) top_margin = 108; height = raw_height - top_margin; } + else if ((imHassy.SensorCode == 20) && imHassy.uncropped) + { // Hasselblad X2D-100c + left_margin = 124; + width = 11664; + top_margin = 92; + height = raw_height - top_margin; + } if (tiff_samples > 1) { @@ -2855,7 +2830,40 @@ void LibRaw::identify_finetune_dcr(char head[64], int fsize, int flen) load_raw = &LibRaw::sony_load_raw; } - else if (raw_width == 3984) { // Sony DSC-R1; + else if ((unique_id == SonyID_ILCE_7RM5) || (unique_id == SonyID_ILCE_7CR)) + { + if (raw_width == 6304) + { + /* nothing: APS-C Uncompressed, handled in open_datastream*/ + } + else if (raw_width == 6656) /* 7RM5 Lossy compressed, medium */ + { + width = 6272; + height = 4180; + } + else if (raw_width == 9728) // FF, Lossless compresssed + { + width = 9566; + height = 6374; + } + else if (raw_width == 5120) // APS-C??/Lossy-Small? + { + width = 4776; + height = 3180; + } + else if (raw_width == 9600) + { + width = raw_width - 36; + } + else + { + width = raw_width - 32; // fallback + imgdata.process_warnings |= LIBRAW_WARN_VENDOR_CROP_SUGGESTED; + + } + } + else if (raw_width == 3984) + { // Sony DSC-R1; width = 3925; order = 0x4d4d; @@ -2870,7 +2878,7 @@ void LibRaw::identify_finetune_dcr(char head[64], int fsize, int flen) } else if (raw_width == 4928) { - // Sony DSLR-A580, NEX-C3, SLT-A35, DSC-HX99, SLT-A55, + // Sony DSLR-A580, NEX-C3, SLT-A35, DSC-HX99, DSC-HX95, SLT-A55, // NEX-5N, SLT-A37, SLT-A57, NEX-F3, NEX-6, NEX-5R, NEX-3N, NEX-5T; if (height < 3280) width -= 8; @@ -2904,10 +2912,18 @@ void LibRaw::identify_finetune_dcr(char head[64], int fsize, int flen) width -= 32; } - else if (raw_width == 9600) { // Sony ILCE-7RM4 + else if (raw_width == 9600) { // Sony ILCE-7RM4 && 7RM5 width -= 32; } + else if (unique_id == SonyID_ZV_E1) + { + if (raw_width == 4608 && raw_height == 3072) // SonyID_ZV_E1 + { + width = 4256; + height = 2846; + } + } else if(unique_id == SonyID_ILCE_1) { if (raw_width == 8704 && raw_height == 6144) // ILCE-1 FF@Compressed @@ -2928,20 +2944,62 @@ void LibRaw::identify_finetune_dcr(char head[64], int fsize, int flen) { width -= 28; } + else if (raw_width == 5632) // Lossy/Medium + { + width -= 4; + height = 3756; + } + else if (raw_width == 4608) // Lossy/small + { + width = 4332; + height = 2892; + } + else + imgdata.process_warnings |= LIBRAW_WARN_VENDOR_CROP_SUGGESTED; + + /* need samples for lossy small/medium w/ APC crop*/ } - else if (unique_id == SonyID_ILCE_7M4) + else if ((unique_id == SonyID_ILCE_7M4)|| (unique_id == SonyID_ILCE_7CM2)) { - if (raw_width == 7168 && raw_height == 5120) // ILCE-1 FF@Compressed + if (raw_width == 7168 && raw_height == 5120) { width = 7028; height = 4688; } + else if (raw_width == 5120) // Lossy/Medium + { + width = 4624; + height = 3080; + } + else if (raw_width == 3584) // Lossy/Small + { + width = 3516; + height = 2344; + } else if (raw_width == 7040) // FF uncompressed/lossy { width -= 12; } + else + imgdata.process_warnings |= LIBRAW_WARN_VENDOR_CROP_SUGGESTED; /* FIXME: need APS-C samples, both losslesscompressed and uncompressed or lossy */ } + else if (unique_id == SonyID_ILCE_6700) + { + if (raw_width == 6656) + { + width = 6272; + height = 4168; + } + else if (raw_width == 6272) // APS-C uncompressed + { + width = raw_width - 32; + } + else // fallback + { + width = raw_width - 32; + } + } else if (!strcmp(model, "DSLR-A100")) { if (width == 3880) { diff --git a/src/metadata/identify_tools.cpp b/src/metadata/identify_tools.cpp index 28a1d69c8..caf1cddf0 100644 --- a/src/metadata/identify_tools.cpp +++ b/src/metadata/identify_tools.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/metadata/kodak.cpp b/src/metadata/kodak.cpp index 1193eac32..2c4419778 100644 --- a/src/metadata/kodak.cpp +++ b/src/metadata/kodak.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: diff --git a/src/metadata/leica.cpp b/src/metadata/leica.cpp index cda4b0c63..182537485 100644 --- a/src/metadata/leica.cpp +++ b/src/metadata/leica.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: @@ -48,7 +48,7 @@ void LibRaw::setLeicaBodyFeatures(int LeicaMakernoteSignature) ilm.FocalType = LIBRAW_FT_ZOOM_LENS; } else if ((LeicaMakernoteSignature == - 0x0200) || // M10, M10-D, M10-R, "S (Typ 007)", M11 + 0x0200) || // M10, M10-D, M10-R, "S (Typ 007)", M11, "M11 Monochrom" (LeicaMakernoteSignature == 0x02ff) || // "M (Typ 240)", "M (Typ 262)", "M-D (Typ 262)", // "M Monochrom (Typ 246)", "S (Typ 006)", "S-E (Typ 006)", S2, S3 @@ -68,6 +68,7 @@ void LibRaw::setLeicaBodyFeatures(int LeicaMakernoteSignature) } else if ((LeicaMakernoteSignature == 0x0600) || // "T (Typ 701)", TL (LeicaMakernoteSignature == 0x0900) || // SL2, "SL2-S", "SL (Typ 601)", CL, Q2, "Q2 MONO" + (LeicaMakernoteSignature == 0x0a00) || // Q3 (LeicaMakernoteSignature == 0x1a00)) // TL2 { if ((model[0] == 'S') || (model[6] == 'S')) @@ -82,7 +83,8 @@ void LibRaw::setLeicaBodyFeatures(int LeicaMakernoteSignature) ilm.CameraMount = LIBRAW_MOUNT_LPS_L; } else if (((model[0] == 'Q') || (model[6] == 'Q')) && - ((model[1] == '2') || (model[7] == '2'))) + (((model[1] == '2') || (model[7] == '2')) || + ((model[1] == '3') || (model[7] == '3')))) { ilm.CameraFormat = ilm.LensFormat = LIBRAW_FORMAT_FF; ilm.CameraMount = ilm.LensMount = LIBRAW_MOUNT_FixedLens; @@ -206,6 +208,7 @@ void LibRaw::parseLeicaMakernote(int base, int uptag, unsigned MakernoteTagType) (LeicaMakernoteSignature != 0x0200) && (LeicaMakernoteSignature != 0x0800) && (LeicaMakernoteSignature != 0x0900) && + (LeicaMakernoteSignature != 0x0a00) && (LeicaMakernoteSignature != 0x02ff)) base = ftell(ifp) - 8; } @@ -297,7 +300,7 @@ void LibRaw::parseLeicaMakernote(int base, int uptag, unsigned MakernoteTagType) parseLeicaLensName(len); } } - else if (LeicaMakernoteSignature == 0x0200) // M10, M10-D, M10-R, "S (Typ 007)", M11 + else if (LeicaMakernoteSignature == 0x0200) // M10, M10-D, M10-R, "S (Typ 007)", M11, "M11 Monochrom" { if ((tag == 0x035a) && (fabs(ilm.CurAp) < 0.17f)) { @@ -331,8 +334,10 @@ void LibRaw::parseLeicaMakernote(int base, int uptag, unsigned MakernoteTagType) } } else if ((LeicaMakernoteSignature == 0x0800) || // "Q (Typ 116)" - (LeicaMakernoteSignature == 0x0900)) // SL2, "SL2-S", "SL (Typ 601)", + (LeicaMakernoteSignature == 0x0900) || // SL2, "SL2-S", "SL (Typ 601)", // CL, Q2, "Q2 MONO" + (LeicaMakernoteSignature == 0x0a00) // Q3 + ) { if ((tag == 0x0304) && (len == 1) && ((c = fgetc(ifp)) != 0) && (ilm.CameraMount == LIBRAW_MOUNT_LPS_L)) diff --git a/src/metadata/makernotes.cpp b/src/metadata/makernotes.cpp index b8ed4d3c7..728acd7d5 100644 --- a/src/metadata/makernotes.cpp +++ b/src/metadata/makernotes.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/metadata/mediumformat.cpp b/src/metadata/mediumformat.cpp index 6bb8705d9..c3d3dbeca 100644 --- a/src/metadata/mediumformat.cpp +++ b/src/metadata/mediumformat.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/metadata/minolta.cpp b/src/metadata/minolta.cpp index c8224332c..aa40a9b03 100644 --- a/src/metadata/minolta.cpp +++ b/src/metadata/minolta.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/metadata/misc_parsers.cpp b/src/metadata/misc_parsers.cpp index 7d6e2f447..1aea57e6f 100644 --- a/src/metadata/misc_parsers.cpp +++ b/src/metadata/misc_parsers.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. @@ -92,40 +92,6 @@ int LibRaw::canon_s2is() return 0; } -#ifdef LIBRAW_OLD_VIDEO_SUPPORT -void LibRaw::parse_redcine() -{ - unsigned i, len, rdvo; - - order = 0x4d4d; - is_raw = 0; - fseek(ifp, 52, SEEK_SET); - width = get4(); - height = get4(); - fseek(ifp, 0, SEEK_END); - fseek(ifp, -(i = ftello(ifp) & 511), SEEK_CUR); - if (get4() != i || get4() != 0x52454f42) - { - fseek(ifp, 0, SEEK_SET); - while ((len = get4()) != (unsigned)EOF) - { - if (get4() == 0x52454456) - if (is_raw++ == shot_select) - data_offset = ftello(ifp) - 8; - fseek(ifp, len - 8, SEEK_CUR); - } - } - else - { - rdvo = get4(); - fseek(ifp, 12, SEEK_CUR); - is_raw = get4(); - fseeko(ifp, rdvo + 8 + shot_select * 4, SEEK_SET); - data_offset = get4(); - } -} -#endif - void LibRaw::parse_cine() { unsigned off_head, off_setup, off_image, i, temp; diff --git a/src/metadata/nikon.cpp b/src/metadata/nikon.cpp index c0c90f81c..f0fb655d9 100644 --- a/src/metadata/nikon.cpp +++ b/src/metadata/nikon.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: @@ -128,7 +128,7 @@ void LibRaw::processNikonLensData(uchar *LensData, unsigned len) i = 8; break; case 58: // "Z 6", "Z 6 II", "Z 7", "Z 7 II", "Z 50", D780, "Z 5", "Z fc" - case 108: // "Z 9" + case 108: // "Z 9", "Z 30", "Z 8" if (model[6] == 'Z') ilm.CameraMount = LIBRAW_MOUNT_Nikon_Z; if (imNikon.HighSpeedCropFormat != 12) @@ -144,6 +144,8 @@ void LibRaw::processNikonLensData(uchar *LensData, unsigned len) (ilm.LensID == 11) || (ilm.LensID == 12) || (ilm.LensID == 26) + || (ilm.LensID == 41) + || (ilm.LensID == 43) ) ilm.LensFormat = LIBRAW_FORMAT_APSC; else ilm.LensFormat = LIBRAW_FORMAT_FF; if (ilm.MaxAp4CurFocal < 0.7f) @@ -519,6 +521,9 @@ uchar *cj_block, *ck_block; case 2: imCommon.ColorSpace = LIBRAW_COLORSPACE_AdobeRGB; break; + case 4: + imCommon.ColorSpace = LIBRAW_COLORSPACE_Rec2020; + break; default: imCommon.ColorSpace = LIBRAW_COLORSPACE_Unknown; break; @@ -535,6 +540,22 @@ uchar *cj_block, *ck_block; { imNikon.Active_D_Lighting = get2(); } + else if (tag == 0x0023) + { + FORC4 imNikon.PictureControlVersion = + imNikon.PictureControlVersion * 10 + fgetc(ifp) - '0'; + if ((imNikon.PictureControlVersion >= 300) && + (imNikon.PictureControlVersion <= 399)) + { + fseek(ifp, 4, SEEK_CUR); + } + stmread (imNikon.PictureControlName, 20, ifp); + stmread (imNikon.PictureControlBase, 20, ifp); + if (!strncmp(imNikon.PictureControlBase, "STANDARD(HLG)", 13)) + { + imCommon.ExposureCalibrationShift -= 2; + } + } else if (tag == 0x003b) { // WB for multi-exposure (ME); all 1s for regular exposures imNikon.ME_WB[0] = getreal(type); @@ -849,17 +870,19 @@ free(ck_block); OrientationOffset = sget4_order(morder, ShotInfo_buf+0x9c); break; - case 800: // Z 6, Z 7, ShotInfoZ7II, Roll/Pitch/Yaw - case 801: // Z 50, ShotInfoZ7II, Roll/Pitch/Yaw - case 802: // Z 5, ShotInfoZ7II, Roll/Pitch/Yaw - case 803: // Z 6_2, Z 7_2, ShotInfoZ7II, Roll/Pitch/Yaw - case 804: // Z fc ShotInfoZ7II, Roll/Pitch/Yaw + case 800: // "Z 6", "Z 7", ShotInfoZ7II, Roll/Pitch/Yaw + case 801: // "Z 50", ShotInfoZ7II, Roll/Pitch/Yaw + case 802: // "Z 5", ShotInfoZ7II, Roll/Pitch/Yaw + case 803: // "Z 6_2", "Z 7_2", ShotInfoZ7II, Roll/Pitch/Yaw + case 804: // "Z fc" ShotInfoZ7II, Roll/Pitch/Yaw OrientationOffset = sget4_order(morder, ShotInfo_buf+0x98); break; - case 805: // Z 9, ShotInfoZ9, Roll/Pitch/Yaw + case 805: // "Z 9", ShotInfoZ9, Roll/Pitch/Yaw OrientationOffset = sget4_order(morder, ShotInfo_buf+0x84); break; + case 807: // "Z 30" + break; } if (OrientationOffset && ((OrientationOffset+12) 6) && strncmp(imgdata.color.UniqueCameraModel+6, "PowerShot", 9)) { - for (i = 0; i < int(sizeof unique / sizeof *unique); i++) - { - if (!strcmp(unique[i].t_model, imgdata.color.UniqueCameraModel+6)) + if (!strcmp(model, "EOS Ra")) { + ilm.CamID = unique_id = CanonID_EOS_R; + strcpy(normalized_model, model); + // try_xml = 1; // ?? + } else { + for (i = 0; i < int(sizeof unique / sizeof *unique); i++) { - ilm.CamID = unique_id = unique[i].id; - strcpy(normalized_model, unique[i].t_model); - try_xml = 1; - break; + if (!strcmp(unique[i].t_model, imgdata.color.UniqueCameraModel+6)) + { + ilm.CamID = unique_id = unique[i].id; + strcpy(normalized_model, unique[i].t_model); + try_xml = 1; + break; + } } } } @@ -1017,6 +1044,35 @@ void LibRaw::GetNormalizedModel() } } +/* +char pgroup9050 = '-'; +char cameratype[16] = "unknown"; +switch (imSony.CameraType) { + case LIBRAW_SONY_DSC: strcpy(cameratype, "DSC"); break; + case LIBRAW_SONY_DSLR: strcpy(cameratype, "DSLR"); break; + case LIBRAW_SONY_NEX: strcpy(cameratype, "NEX"); break; + case LIBRAW_SONY_SLT: strcpy(cameratype, "SLT"); break; + case LIBRAW_SONY_ILCE: strcpy(cameratype, "ILCE"); break; + case LIBRAW_SONY_ILCA: strcpy(cameratype, "ILCA"); break; +} +switch (imSony.group9050) { + case LIBRAW_SONY_Tag9050a: + pgroup9050 = 'a'; + break; + case LIBRAW_SONY_Tag9050b: + pgroup9050 = 'b'; + break; + case LIBRAW_SONY_Tag9050c: + pgroup9050 = 'c'; + break; + case LIBRAW_SONY_Tag9050d: + pgroup9050 = 'd'; + break; +} +printf("catchme\t%s\t%s\t%s\t9050%c\t%d\t%d\n", + model, normalized_model, cameratype, pgroup9050, imSony.len_group9050, imSony.FileFormat); +*/ + } else if (makeIs(LIBRAW_CAMERAMAKER_Kodak)) { remove_caseSubstr (normalized_model, (char *)"EasyShare"); remove_caseSubstr (normalized_model, (char *)"ZOOM"); @@ -1191,7 +1247,9 @@ void LibRaw::GetNormalizedModel() ilm.CameraMount = LIBRAW_MOUNT_Fuji_GF; } else if (!strncmp(normalized_model, "X-", 2) && - (strncmp(normalized_model, "X-S1", 4) || !strncmp(normalized_model, "X-S10", 5))) + (strncmp(normalized_model, "X-S1", 4) || + !strncmp(normalized_model, "X-S10", 5) || + !strncmp(normalized_model, "X-S20", 5))) { ilm.CameraFormat = LIBRAW_FORMAT_APSC; ilm.CameraMount = LIBRAW_MOUNT_Fuji_X; diff --git a/src/metadata/olympus.cpp b/src/metadata/olympus.cpp index 6c427137b..1a49a66d1 100644 --- a/src/metadata/olympus.cpp +++ b/src/metadata/olympus.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: @@ -19,9 +19,10 @@ void LibRaw::setOlympusBodyFeatures(unsigned long long id) { ilm.CamID = id; - if ((id == OlyID_E_1) || - (id == OlyID_E_300) || - ((id & 0x00ffff0000ULL) == 0x0030300000ULL)) + if ((id == OlyID_E_1) || + (id == OlyID_E_300) || + (id == OlyID_AIR_A01) || + ((id & 0xffff000000ULL) == 0x5330000000ULL)) { ilm.CameraFormat = LIBRAW_FORMAT_FT; diff --git a/src/metadata/p1.cpp b/src/metadata/p1.cpp index a3867b8c9..7382e108d 100644 --- a/src/metadata/p1.cpp +++ b/src/metadata/p1.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify diff --git a/src/metadata/pentax.cpp b/src/metadata/pentax.cpp index 705fd84c9..ae238d0aa 100644 --- a/src/metadata/pentax.cpp +++ b/src/metadata/pentax.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify diff --git a/src/metadata/samsung.cpp b/src/metadata/samsung.cpp index 5c595e8ba..26fd58f4d 100644 --- a/src/metadata/samsung.cpp +++ b/src/metadata/samsung.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify diff --git a/src/metadata/sony.cpp b/src/metadata/sony.cpp index ea568b5ff..b63d0495d 100644 --- a/src/metadata/sony.cpp +++ b/src/metadata/sony.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: @@ -14,6 +14,7 @@ #include "../../internal/dcraw_defs.h" #include "../../internal/libraw_cameraids.h" +#include "../../internal/libraw_checked_buffer.h" static ushort saneSonyCameraInfo(uchar a, uchar b, uchar c, uchar d, uchar e, uchar f) @@ -295,6 +296,8 @@ void LibRaw::setSonyBodyFeatures(unsigned long long id) LIBRAW_SONY_Tag2010i, 0x0320, 0x019f, 0x024b, 0x024c, 0x0208}, {SonyID_DSC_RX0M2, LIBRAW_FORMAT_1INCH, LIBRAW_MOUNT_FixedLens, LIBRAW_SONY_DSC, LIBRAW_MOUNT_FixedLens, LIBRAW_SONY_Tag2010i, 0x0320, 0xffff, 0x024b, 0x024c, 0x0208}, + {SonyID_DSC_HX95, LIBRAW_FORMAT_1div2p3INCH, LIBRAW_MOUNT_FixedLens, LIBRAW_SONY_DSC, LIBRAW_MOUNT_FixedLens, + LIBRAW_SONY_Tag2010i, 0x0320, 0xffff, 0x024b, 0x024c, 0x0208}, {SonyID_DSC_RX100M7, LIBRAW_FORMAT_1INCH, LIBRAW_MOUNT_FixedLens, LIBRAW_SONY_DSC, LIBRAW_MOUNT_FixedLens, LIBRAW_SONY_Tag2010i, 0x0320, 0xffff, 0x024b, 0x024c, 0x0208}, {SonyID_ILCE_7RM4, LIBRAW_FORMAT_FF, LIBRAW_MOUNT_Sony_E, LIBRAW_SONY_ILCE, LIBRAW_MOUNT_Unknown, @@ -326,8 +329,25 @@ void LibRaw::setSonyBodyFeatures(unsigned long long id) LIBRAW_SONY_Tag2010i, 0x0320, 0x019f, 0x024b, 0x024c, 0x0208}, {SonyID_ILCE_7M4, LIBRAW_FORMAT_FF, LIBRAW_MOUNT_Sony_E, LIBRAW_SONY_ILCE, LIBRAW_MOUNT_Unknown, LIBRAW_SONY_Tag2010None, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff}, + {SonyID_ILCE_7RM5, LIBRAW_FORMAT_FF, LIBRAW_MOUNT_Sony_E, LIBRAW_SONY_ILCE, LIBRAW_MOUNT_Unknown, + LIBRAW_SONY_Tag2010None, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff}, + {SonyID_ILME_FX30, LIBRAW_FORMAT_APSC, LIBRAW_MOUNT_Sony_E, LIBRAW_SONY_ILCE, LIBRAW_MOUNT_Unknown, + LIBRAW_SONY_Tag2010None, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff}, + {SonyID_ZV_E1, LIBRAW_FORMAT_FF, LIBRAW_MOUNT_Sony_E, LIBRAW_SONY_ILCE, LIBRAW_MOUNT_Unknown, + LIBRAW_SONY_Tag2010None, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff}, + {SonyID_ILCE_6700, LIBRAW_FORMAT_APSC, LIBRAW_MOUNT_Sony_E, LIBRAW_SONY_ILCE, LIBRAW_MOUNT_Unknown, + LIBRAW_SONY_Tag2010None, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff}, + {SonyID_ZV_1M2, LIBRAW_FORMAT_1INCH, LIBRAW_MOUNT_FixedLens, LIBRAW_SONY_DSC, LIBRAW_MOUNT_FixedLens, + LIBRAW_SONY_Tag2010i, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff}, + + {SonyID_ILCE_7CR, LIBRAW_FORMAT_FF, LIBRAW_MOUNT_Sony_E, LIBRAW_SONY_ILCE, LIBRAW_MOUNT_Unknown, + LIBRAW_SONY_Tag2010None, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff}, + {SonyID_ILCE_7CM2, LIBRAW_FORMAT_FF, LIBRAW_MOUNT_Sony_E, LIBRAW_SONY_ILCE, LIBRAW_MOUNT_Unknown, + LIBRAW_SONY_Tag2010None, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff}, }; ilm.CamID = id; + int isPreProductionFW = 0; + if (!strcmp(model, "MODEL-NAME")) isPreProductionFW = 1; if (id == SonyID_DSC_R1) { @@ -364,8 +384,8 @@ void LibRaw::setSonyBodyFeatures(unsigned long long id) case SonyID_ILCE_7C: case SonyID_ILCE_7M3: case SonyID_ILCE_7RM2: - case SonyID_ILCE_7RM3A: case SonyID_ILCE_7RM3: + case SonyID_ILCE_7RM3A: case SonyID_ILCE_7RM4: case SonyID_ILCE_7RM4A: case SonyID_ILCE_7SM2: @@ -373,23 +393,50 @@ void LibRaw::setSonyBodyFeatures(unsigned long long id) case SonyID_ILCE_9M2: case SonyID_ILCA_99M2: case SonyID_ZV_E10: - imSony.group9050 = LIBRAW_SONY_Tag9050b; - break; - case SonyID_ILCE_7SM3: - case SonyID_ILCE_1: - case SonyID_ILME_FX3: - case SonyID_ILCE_7M4: - imSony.group9050 = LIBRAW_SONY_Tag9050c; - break; - default: - if ((imSony.CameraType != LIBRAW_SONY_DSC) && - (imSony.CameraType != LIBRAW_SONY_DSLR)) + if (!isPreProductionFW) + { + imSony.group9050 = LIBRAW_SONY_Tag9050b; // length: 944 bytes + } + else + { imSony.group9050 = LIBRAW_SONY_Tag9050a; + imSony.ImageCount3_offset = 0xffff; // not valid + } + break; + case SonyID_ILCE_1: + case SonyID_ILCE_7M4: + case SonyID_ILCE_7RM5: + case SonyID_ILCE_7SM3: + case SonyID_ILME_FX3: + if (!isPreProductionFW) + { + imSony.group9050 = LIBRAW_SONY_Tag9050c; // length: 256 bytes + } + else + { + imSony.group9050 = LIBRAW_SONY_Tag9050a; + imSony.ImageCount3_offset = 0xffff; // not valid + } + break; + case SonyID_ZV_E1: + case SonyID_ILCE_6700: + case SonyID_ILCE_7CR: + case SonyID_ILCE_7CM2: + imSony.group9050 = LIBRAW_SONY_Tag9050d; + break; + default: // see also process_Sony_0x9050 + if ( + (imSony.CameraType != LIBRAW_SONY_DSC) && + (imSony.CameraType != LIBRAW_SONY_DSLR) + ) + imSony.group9050 = LIBRAW_SONY_Tag9050a; // length: 3072 or 944 bytes else imSony.group9050 = LIBRAW_SONY_Tag9050None; break; } + if (isPreProductionFW) return; + char *sbstr = strstr(software, " v"); if (sbstr != NULL) { @@ -421,12 +468,6 @@ void LibRaw::setSonyBodyFeatures(unsigned long long id) imSony.ImageCount3_offset = 0x01b6; } } - - if ((id == SonyID_ILCE_7SM3) && - !strcmp(model, "MODEL-NAME")) { - imSony.group9050 = LIBRAW_SONY_Tag9050a; - } - } void LibRaw::parseSonyLensType2(uchar a, uchar b) @@ -575,9 +616,39 @@ void LibRaw::process_Sony_0x0116(uchar *buf, ushort len, unsigned long long id) void LibRaw::process_Sony_0x2010(uchar *buf, ushort len) { - if (imSony.group2010 == LIBRAW_SONY_Tag2010None) return; + ushort ar_offset = 0; + if (imSony.group2010 == LIBRAW_SONY_Tag2010e) { + if (ilm.CamID == SonyID_DSC_RX100) { + ar_offset = 0x1a88; + } else { + ar_offset = 0x192c; + } + } else if (imSony.group2010 == LIBRAW_SONY_Tag2010f) { + ar_offset = 0x192c; + } else if (imSony.group2010 == LIBRAW_SONY_Tag2010g) { + ar_offset = 0x1958; + } else if (imSony.group2010 == LIBRAW_SONY_Tag2010h) { + ar_offset = 0x192c; + } else if (imSony.group2010 == LIBRAW_SONY_Tag2010i) { + ar_offset = 0x188c; + } + if (ar_offset != 0) { + int s = (int)SonySubstitution[buf[ar_offset]]; + if (s == 0) { + imSony.AspectRatio = LIBRAW_IMAGE_ASPECT_16to9; + } else if (s == 1) { + imSony.AspectRatio = LIBRAW_IMAGE_ASPECT_4to3; + } else if (s == 2) { + imSony.AspectRatio = LIBRAW_IMAGE_ASPECT_3to2; + } else if (s == 3) { + imSony.AspectRatio = LIBRAW_IMAGE_ASPECT_1to1; + } else { + imSony.AspectRatio = (float)s; + } + } + if ((imSony.real_iso_offset != 0xffff) && (len >= (imSony.real_iso_offset + 2)) && (imCommon.real_ISO < 0.1f)) { @@ -612,10 +683,23 @@ void LibRaw::process_Sony_0x9050(uchar *buf, ushort len, unsigned long long id) uchar s[4]; int c; - if ((imSony.group9050 == LIBRAW_SONY_Tag9050None) && + + if ( + (imSony.group9050 == LIBRAW_SONY_Tag9050None) && (imSony.CameraType != LIBRAW_SONY_DSC) && - (imSony.CameraType != LIBRAW_SONY_DSLR)) + (imSony.CameraType != LIBRAW_SONY_DSLR) + ) { imSony.group9050 = LIBRAW_SONY_Tag9050a; + } + +/* +printf ("==>> Tag9050, len: 0x%04x, type: %s\n", len, + imSony.group9050==LIBRAW_SONY_Tag9050None?"None": + imSony.group9050==LIBRAW_SONY_Tag9050a?"9050a": + imSony.group9050==LIBRAW_SONY_Tag9050b?"9050b": + imSony.group9050==LIBRAW_SONY_Tag9050c?"9050c": + imSony.group9050==LIBRAW_SONY_Tag9050d?"9050d":"---"); +*/ if (imSony.group9050 == LIBRAW_SONY_Tag9050None) return; @@ -639,16 +723,30 @@ void LibRaw::process_Sony_0x9050(uchar *buf, ushort len, unsigned long long id) if ((imSony.group9050 == LIBRAW_SONY_Tag9050b) || (imSony.group9050 == LIBRAW_SONY_Tag9050c)) { - if (len <= 0x8d) return; - unsigned long long b88 = SonySubstitution[buf[0x88]]; - unsigned long long b89 = SonySubstitution[buf[0x89]]; - unsigned long long b8a = SonySubstitution[buf[0x8a]]; - unsigned long long b8b = SonySubstitution[buf[0x8b]]; - unsigned long long b8c = SonySubstitution[buf[0x8c]]; - unsigned long long b8d = SonySubstitution[buf[0x8d]]; + unsigned start_InternalBodySerial = 0x88; + if (id == SonyID_ILCE_1) start_InternalBodySerial += 2; + if (len <= start_InternalBodySerial+5) return; + unsigned long long b88 = SonySubstitution[buf[start_InternalBodySerial]]; + unsigned long long b89 = SonySubstitution[buf[start_InternalBodySerial+1]]; + unsigned long long b8a = SonySubstitution[buf[start_InternalBodySerial+2]]; + unsigned long long b8b = SonySubstitution[buf[start_InternalBodySerial+3]]; + unsigned long long b8c = SonySubstitution[buf[start_InternalBodySerial+4]]; + unsigned long long b8d = SonySubstitution[buf[start_InternalBodySerial+5]]; sprintf(imgdata.shootinginfo.InternalBodySerial, "%06llx", (b88 << 40) + (b89 << 32) + (b8a << 24) + (b8b << 16) + (b8c << 8) + b8d); + } else if (imSony.group9050 == LIBRAW_SONY_Tag9050d) { + unsigned start_InternalBodySerial = 0x38; + if (len <= start_InternalBodySerial+5) return; + unsigned long long b38 = SonySubstitution[buf[start_InternalBodySerial]]; + unsigned long long b39 = SonySubstitution[buf[start_InternalBodySerial+1]]; + unsigned long long b4a = SonySubstitution[buf[start_InternalBodySerial+2]]; + unsigned long long b4b = SonySubstitution[buf[start_InternalBodySerial+3]]; + unsigned long long b4c = SonySubstitution[buf[start_InternalBodySerial+4]]; + unsigned long long b4d = SonySubstitution[buf[start_InternalBodySerial+5]]; + sprintf(imgdata.shootinginfo.InternalBodySerial, "%06llx", + (b38 << 40) + (b39 << 32) + (b4a << 24) + (b4b << 16) + (b4c << 8) + b4d); + } else if (imSony.group9050 == LIBRAW_SONY_Tag9050a) { if ((ilm.CameraMount == LIBRAW_MOUNT_Sony_E) && (id != SonyID_NEX_5N) && @@ -780,7 +878,10 @@ void LibRaw::process_Sony_0x9400(uchar *buf, ushort len, unsigned long long /*id (bufx == 0x24) || (bufx == 0x26) || (bufx == 0x28) || - (bufx == 0x31)) && + (bufx == 0x31) || + (bufx == 0x32) || + (bufx == 0x33)) + && (len >= 0x1f)) // 0x9400 'c' version { imSony.Sony0x9400_version = 0xc; @@ -1009,13 +1110,13 @@ void LibRaw::parseSonyMakernotes( uchar *&table_buf_0x940c, ushort &table_buf_0x940c_len, uchar *&table_buf_0x940e, ushort &table_buf_0x940e_len) { - ushort lid, a, c, d; uchar *table_buf; uchar uc; uchar s[2]; int LensDataValid = 0; unsigned uitemp; + ushort u16temp; // printf ("==>> tag 0x%x, len %d, type %d, model =%s=, cam.id 0x%llx, cam.type %d, =%s=\n", // tag, len, type, model, ilm.CamID, imSony.CameraType, imSony.MetaVersion); @@ -1041,6 +1142,7 @@ void LibRaw::parseSonyMakernotes( if (table_buf_0x9050_len) { + imSony.len_group9050 = table_buf_0x9050_len; process_Sony_0x9050(table_buf_0x9050, table_buf_0x9050_len, unique_id); free(table_buf_0x9050); table_buf_0x9050_len = 0; @@ -1498,6 +1600,19 @@ void LibRaw::parseSonyMakernotes( case 1: case 2: case 3: imgdata.shootinginfo.FocusMode++; break; case 4: imgdata.shootinginfo.FocusMode +=2; break; } + lid = 0x55 << 1; + u16temp = ((ushort)table_buf[lid]) << 8 | ((ushort)table_buf[lid + 1]); + switch (u16temp) { + case 1: + imSony.AspectRatio = LIBRAW_IMAGE_ASPECT_3to2; + break; + case 2: + imSony.AspectRatio = LIBRAW_IMAGE_ASPECT_16to9; + break; + default: + imSony.AspectRatio = (float)u16temp; + break; + } if (!imCommon.ColorSpace || (imCommon.ColorSpace == LIBRAW_COLORSPACE_Unknown)) { lid = 0x83 << 1; @@ -1530,12 +1645,36 @@ void LibRaw::parseSonyMakernotes( case 1: case 2: case 3: imgdata.shootinginfo.FocusMode++; break; case 4: imgdata.shootinginfo.FocusMode +=2; break; } + lid = 0x55 << 1; + u16temp = ((ushort)table_buf[lid]) << 8 | ((ushort)table_buf[lid + 1]); + switch (u16temp) { + case 1: + imSony.AspectRatio = LIBRAW_IMAGE_ASPECT_3to2; + break; + case 2: + imSony.AspectRatio = LIBRAW_IMAGE_ASPECT_16to9; + break; + default: + imSony.AspectRatio = (float)u16temp; + break; + } lid = 0x7e << 1; imgdata.shootinginfo.DriveMode = table_buf[lid + 1]; break; case 1536: // a560 a580 a33 a35 a55 NEX-3 NEX-5 NEX-5C NEX-C3 NEX-VG10E case 2048: // a450 a500 a550 // CameraSettings3 are little endian + switch (table_buf[0x0a]) { + case 4: + imSony.AspectRatio = LIBRAW_IMAGE_ASPECT_3to2; + break; + case 8: + imSony.AspectRatio = LIBRAW_IMAGE_ASPECT_16to9; + break; + default: + imSony.AspectRatio = (float)table_buf[0x0a]; + break; + } switch (table_buf[0x0e]) { case 1: imCommon.ColorSpace = LIBRAW_COLORSPACE_sRGB; @@ -1751,6 +1890,7 @@ void LibRaw::parseSonyMakernotes( if (ilm.CamID) { + imSony.len_group9050 = table_buf_0x9050_len; process_Sony_0x9050(table_buf_0x9050, table_buf_0x9050_len, ilm.CamID); free(table_buf_0x9050); table_buf_0x9050_len = 0; @@ -1968,73 +2108,6 @@ void LibRaw::parseSonyMakernotes( } } -class checked_buffer_t -{ -public: - // create with internal storage - checked_buffer_t(short ord, int size) : _order(ord), storage(size+64) { - _data = storage.data(); - _len = size; - } - checked_buffer_t(short ord, unsigned char *dd, int ss): _order(ord), _data(dd),_len(ss){} - - ushort sget2(int offset) - { - checkoffset(offset + 2); - return libraw_sget2_static(_order, _data + offset); - } - void checkoffset(int off) - { - if (off >= _len) throw LIBRAW_EXCEPTION_IO_EOF; - } - unsigned char operator [] (int idx) - { - checkoffset(idx); - return _data[idx]; - } - unsigned sget4(int offset) - { - checkoffset(offset+4); - return libraw_sget4_static(_order, _data + offset); - } - double sgetreal(int type, int offset) - { - int sz = libraw_tagtype_dataunit_bytes(type); - checkoffset(offset + sz); - return libraw_sgetreal_static(_order, type, _data + offset); - } - - unsigned char *data() { return _data; } - - int tiff_sget(unsigned save, INT64 *tag_offset, - unsigned *tag_id, unsigned *tag_type, INT64 *tag_dataoffset, - unsigned *tag_datalen, int *tag_dataunitlen) - { - if ((((*tag_offset) + 12) > _len) || (*tag_offset < 0)) { // abnormal, tag buffer overrun - return -1; - } - int pos = *tag_offset; - *tag_id = sget2(pos); pos += 2; - *tag_type = sget2(pos); pos += 2; - *tag_datalen = sget4(pos); pos += 4; - *tag_dataunitlen = libraw_tagtype_dataunit_bytes(*tag_type); - if ((*tag_datalen * (*tag_dataunitlen)) > 4) { - *tag_dataoffset = sget4(pos) - save; - if ((*tag_dataoffset + *tag_datalen) > _len) { // abnormal, tag data buffer overrun - return -2; - } - } - else *tag_dataoffset = *tag_offset + 8; - *tag_offset += 12; - return 0; - } - -private: - short _order; - unsigned char *_data; - int _len; - std::vector storage; -}; void LibRaw::parseSonySR2(uchar *_cbuf_SR2, unsigned SR2SubIFDOffset, unsigned SR2SubIFDLength, unsigned dng_writer) diff --git a/src/metadata/tiff.cpp b/src/metadata/tiff.cpp index c34b86470..9c1650c1a 100644 --- a/src/metadata/tiff.cpp +++ b/src/metadata/tiff.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. @@ -65,7 +65,6 @@ int LibRaw::parse_tiff_ifd(int base) len, order, ifp, base); fseek(ifp, savepos, SEEK_SET); } - if (!is_pana_raw) { /* processing of EXIF tags that collide w/ PanasonicRaw tags */ switch (tag) @@ -114,6 +113,13 @@ int LibRaw::parse_tiff_ifd(int base) tiff_ifd[ifd].bps = jh.bits; tiff_ifd[ifd].samples = 1; } + else if (!dng_version && !strcasecmp(make, "SONY") && tiff_ifd[ifd].phint == 6 && + tiff_ifd[ifd].comp == 7 && tiff_ifd[ifd].samples == 3) // Sony/lossless YCbCr + { + tiff_ifd[ifd].comp = 6; + tiff_ifd[ifd].bps = jh.bits; + // tiff_ifd[ifd].samples = 3; // no change + } else { tiff_ifd[ifd].comp = 6; @@ -189,16 +195,15 @@ int LibRaw::parse_tiff_ifd(int base) pana_black[tag - 0x001c] = get2(); break; case 0x002d: /* 45, RawFormat */ - /* pana_encoding: tag 0x002d (45dec) - not used - DMC-LX1/FZ30/FZ50/L1/LX1/LX2 + /* pana_encoding: tag 0x002d (45dec) not used - DMC-LX1/FZ30/FZ50/L1/LX1/LX2 2 - RAW DMC-FZ8/FZ18 3 - RAW DMC-L10 - 4 - RW2 for most other models, including G9 in "pixel shift off" - mode and YUNEEC CGO4 (must add 15 to black levels for - RawFormat == 4) 5 - RW2 DC-GH5s; G9 in "pixel shift on" - mode 6 - RW2 DC-S1, DC-S1R in "pixel shift off" - mode 7 - RW2 DC-S1R (probably DC-S1 too) in - "pixel shift on" mode + 4 - RW2 for most other models, including G9 in "pixel shift off" mode and YUNEEC CGO4 + (must add 15 to black levels for RawFormat == 4) + 5 - RW2 DC-GH5s; G9 in "pixel shift on" mode + 6 - RW2 DC-S1, DC-S1R in "pixel shift off" mode + 7 - RW2 DC-S1R (probably DC-S1 too) in "pixel shift on" mode + 8 - RW2 DC-GH6, DC-S5M2 */ pana_encoding = get2(); break; @@ -220,7 +225,140 @@ int LibRaw::parse_tiff_ifd(int base) if (iso_speed == 65535) iso_speed = get4(); break; - case 0x011c: /* 284, Gamma */ + case 0x0039: + if (type == LIBRAW_EXIFTAG_TYPE_UNDEFINED && len == 26) + { + ushort cnt = get2(); + if (cnt > 6) + cnt = 6; + for (i = 0; i < cnt; i++) + pana8.tag39[i] = get4(); + } + break; + case 0x003A: + if (type == LIBRAW_EXIFTAG_TYPE_UNDEFINED && len == 26) + { + ushort cnt = get2(); + if (cnt > 6) + cnt = 6; + for (i = 0; i < cnt; i++) + { + get2(); + pana8.tag3A[i] = get2(); + } + } + break; + case 0x003B: + if (type == LIBRAW_EXIFTAG_TYPE_SHORT && len == 1) + pana8.tag3B = get2(); + break; + case 0x003C: + case 0x003D: + case 0x003E: + case 0x003F: + if (type == LIBRAW_EXIFTAG_TYPE_SHORT && len == 1) + pana8.initial[tag - 0x3c] = get2(); + break; + case 0x0040: + if (type == LIBRAW_EXIFTAG_TYPE_UNDEFINED && len == 70) + { + ushort count = get2(); + if (count > 17) count = 17; + for (i = 0; i < count; i++) + { + ushort v1 = get2(); + if (v1 > 16u) v1 = 16u; + pana8.tag40a[i] = v1; + ushort v2 = get2(); + if (v2 > 0xfffu) + v2 = 0xfffu; + pana8.tag40b[i] = v2; + } + } + break; + case 0x0041: + if (type == LIBRAW_EXIFTAG_TYPE_UNDEFINED && len == 36) + { + ushort count = get2(); + if (count > 17) + count = 17; + for (i = 0; i < count; i++) + { + ushort v1 = get2(); + if (v1 > 0x40u) v1 = 64; + pana8.tag41[i] = v1; + } + } + break; + case 0x0042: + if (type == LIBRAW_EXIFTAG_TYPE_SHORT && len == 1) + { + ushort val = get2(); + if (val > 5) + val = 5; + pana8.stripe_count = val; + } + break; + case 0x0043: + if (type == LIBRAW_EXIFTAG_TYPE_SHORT && len == 1) + { + ushort val = get2(); + if (val > 5) + val = 5; + pana8.tag43 = val; + } + break; + case 0x0044: + if (type == LIBRAW_EXIFTAG_TYPE_UNDEFINED && len == 50) + { + ushort count = get2(); + if (count > 5) + count = 5; + for (i = 0; i < count; i++) + pana8.stripe_offsets[i] = get4(); + } + break; + case 0x0045: + if (type == LIBRAW_EXIFTAG_TYPE_UNDEFINED && len == 50) + { + ushort count = get2(); + if (count > 5) + count = 5; + for (i = 0; i < count; i++) + pana8.stripe_left[i] = get4(); + } + break; + case 0x0046: + if (type == LIBRAW_EXIFTAG_TYPE_UNDEFINED && len == 50) + { + ushort count = get2(); + if (count > 5) + count = 5; + for (i = 0; i < count; i++) + pana8.stripe_compressed_size[i] = get4(); + } + break; + case 0x0047: + if (type == LIBRAW_EXIFTAG_TYPE_UNDEFINED && len == 26) + { + ushort count = get2(); + if (count > 5) + count = 5; + for (i = 0; i < count; i++) + pana8.stripe_width[i] = get2(); + } + break; + case 0x0048: + if (type == LIBRAW_EXIFTAG_TYPE_UNDEFINED && len == 26) + { + ushort count = get2(); + if (count > 5) + count = 5; + for (i = 0; i < count; i++) + pana8.stripe_height[i] = get2(); + } + break; + case 0x011c: /* 284, Gamma */ { int n = get2(); if (n >= 1024) @@ -1008,20 +1146,23 @@ int LibRaw::parse_tiff_ifd(int base) (imFuji.RAFDataVersion == 0x0261) || // X100V, GFX 50S II (imFuji.RAFDataVersion == 0x0262) || // X-T4 (imFuji.RAFDataVersion == 0x0263) || // X-H2S - (imFuji.RAFDataVersion == 0x0264) || // X-S10 - (imFuji.RAFDataVersion == 0x0265) || // X-E4 - (imFuji.RAFDataVersion == 0x0266) || // X-T30 II + (imFuji.RAFDataVersion == 0x0264) || // X-S10, X-H2 + (imFuji.RAFDataVersion == 0x0265) || // X-E4, X-T5 + (imFuji.RAFDataVersion == 0x0266) || // X-T30 II, X-S20 + (imFuji.RAFDataVersion == 0x0267) || // GFX 100 II !strcmp(model, "X-Pro3") || - !strcmp(model, "GFX 100S") || - !strcmp(model, "GFX100S") || - !strcmp(model, "GFX 50S II") || - !strcmp(model, "GFX50S II") || + !strcmp(model, "GFX100 II") || !strcmp(model, "GFX 100 II") || + !strcmp(model, "GFX100S") || !strcmp(model, "GFX 100S") || + !strcmp(model, "GFX50S II") || !strcmp(model, "GFX 50S II") || !strcmp(model, "X100V") || !strcmp(model, "X-T4") || !strcmp(model, "X-H2S") || + !strcmp(model, "X-H2") || !strcmp(model, "X-E4") || + !strcmp(model, "X-T5") || !strcmp(model, "X-T30 II") || - !strcmp(model, "X-S10")) + !strcmp(model, "X-S10") || + !strcmp(model, "X-S20")) // is34 cameras have 34 CCT values instead of 31, manual still claims 2500 to 10000 K // aligned 3000 K to Incandescent, as it is usual w/ other Fujifilm cameras is34 = 1; @@ -1055,7 +1196,7 @@ int LibRaw::parse_tiff_ifd(int base) fj -= 93; if (is34) fj -= 9; -// printf ("wb start in DNG: 0x%04x\n", fj*2-0x4e); +//printf ("wb start in DNG: 0x%04x\n", fj*2-0x4e); for (int iCCT = 0, ofst = fj; iCCT < 31; iCCT++, ofst += 3) { @@ -1386,7 +1527,13 @@ int LibRaw::parse_tiff_ifd(int base) if (!strncmp(mbuf, "RAF ", 4)) { // Fujifilm Raw, AdobeRAF - parseAdobeRAFMakernote(); + try { + parseAdobeRAFMakernote(); // May raise exception for out-of buffer reads + } + catch (...) + { + // just ignore it + } } if (!strncmp(mbuf, "SR2 ", 4)) @@ -1579,7 +1726,7 @@ int ifd_size_t_cmp(const void *a, const void *b) : (bi->databits < ai->databits ? -1 : 0); } -static LibRaw_internal_thumbnail_formats tiff2thumbformat(int _comp, int _phint, int _bps, const char *_make); +static LibRaw_internal_thumbnail_formats tiff2thumbformat(int _comp, int _phint, int _bps, const char *_make, bool isDNG); void LibRaw::apply_tiff() { @@ -1640,7 +1787,7 @@ void LibRaw::apply_tiff() // Preview: 0x1 or 0x10001 || ((tiff_ifd[i].newsubfiletype & 0xffff) == 1 && (imgdata.rawparams.options & LIBRAW_RAWOPTIONS_DNG_ADD_PREVIEWS)) - // Transparency mask: 0x4 + // Transparency mask: 0x4 || ((tiff_ifd[i].newsubfiletype & 0xffff) == 4 && (imgdata.rawparams.options & LIBRAW_RAWOPTIONS_DNG_ADD_MASKS))) { @@ -1676,7 +1823,7 @@ void LibRaw::apply_tiff() (arr[q].ifdi & 0xff)); // add inverted frame # to ensure same // sort order for similar sized frames. if (tiff_ifd[ifdidx].phint == 4) - arr[q].databits /= 4; // Force lower bit count for Transp. mask images + arr[q].databits /= 4; // Force lower bit count for Transp. mask images } qsort(arr, MIN(ifdc, LIBRAW_IFD_MAXCOUNT * 2), sizeof(arr[0]), ifd_size_t_cmp); @@ -1773,7 +1920,13 @@ void LibRaw::apply_tiff() if (tiff_ifd[i].phint == 2 && tiff_ifd[i].extrasamples > 0 && tiff_ifd[i].samples > 3) continue; // SKIP RGB+Alpha IFDs - if ((tiff_ifd[i].comp != 6 || tiff_ifd[i].samples != 3) && + if (!strncasecmp(make, "Sony", 4) && tiff_ifd[i].bps == 8 && tiff_ifd[i].phint == 6 && tiff_ifd[i].comp == 7 && + tiff_ifd[i].samples == 3 && tiff_ifd[i].newsubfiletype == 1) + continue; // Sony RGB preview + + if ((tiff_ifd[i].comp != 6 || tiff_ifd[i].samples != 3 || + (tiff_ifd[i].comp == 6 && tiff_ifd[i].samples == 3 && !strncasecmp(make, "Sony", 4) && tiff_ifd[i].bps >=12) + ) && unsigned(tiff_ifd[i].t_width | tiff_ifd[i].t_height) < 0x10000 && (unsigned)tiff_ifd[i].bps < 33 && (unsigned)tiff_ifd[i].samples < 13 && ns && @@ -1952,9 +2105,25 @@ void LibRaw::apply_tiff() case 6: case 7: case 99: - if (!dng_version && tiff_compress == 6 && !strcasecmp(make, "SONY")) - load_raw = &LibRaw::sony_ljpeg_load_raw; - else + if (!dng_version && tiff_compress == 6 && !strcasecmp(make, "SONY")) + { + if (tiff_ifd[raw].phint == 6 && tiff_ifd[raw].bps >= 12 && tiff_ifd[raw].samples == 3) + { + load_raw = &LibRaw::sony_ycbcr_load_raw; + filters = 0; + colors = 3; + } + else + load_raw = &LibRaw::sony_ljpeg_load_raw; + } + // Allow A1/Compression=7 + else if(!dng_version && tiff_compress == 7 && !strcasecmp(make, "SONY") && + (!strcasecmp(model,"ILCE-1") || !strncasecmp(model, "ILCE-7",6) + || !strncasecmp(model, "ILCE-9", 6) // Most likely ILCE-9 will use tiff_compr=7 this w/ updated FW + ) && + tiff_bps == 14 && tiff_samples == 1) + load_raw = &LibRaw::sony_ljpeg_load_raw; + else load_raw = &LibRaw::lossless_jpeg_load_raw; break; case 262: @@ -2024,7 +2193,7 @@ void LibRaw::apply_tiff() load_flags = (((INT64(raw_width) * 3ULL / 2ULL) + 15ULL) / 16ULL) * 16ULL; // bytes per row } - else if (!strncmp(model, "NIKON Z 9", 9) && tiff_ifd[raw].offset) + else if ((!strncmp(model, "NIKON Z 9", 9) || !strncmp(model, "NIKON Z 8", 9)) && tiff_ifd[raw].offset) { INT64 pos = ftell(ifp); unsigned char cmp[] = "CONTACT_INTOPIX"; // 15 @@ -2062,6 +2231,12 @@ void LibRaw::apply_tiff() break; case 8: break; +#ifdef USE_DNGSDK + case 52546: + if (dng_version) + break; /* Compression=9 supported for dng if we compiled with GPR SDK */ + /* Else: fallthrough */ +#endif #ifdef USE_GPRSDK case 9: if (dng_version) @@ -2076,6 +2251,7 @@ void LibRaw::apply_tiff() if (((tiff_samples == 3 && tiff_ifd[raw].bytes && !(tiff_bps == 16 && !strncmp(make, "Leaf", 4)) && // Allow Leaf/16bit/3color files + !(tiff_ifd[raw].comp == 6 && tiff_ifd[raw].phint == 6 && tiff_bps >= 12 && !strncasecmp(make,"Sony",4)) && // Sony YCbCr tiff_bps != 14 && (tiff_compress & -16) != 32768) || (tiff_bps == 8 && strncmp(make, "Phase", 5) && @@ -2093,8 +2269,8 @@ void LibRaw::apply_tiff() if (imgdata.rawparams.options & LIBRAW_RAWOPTIONS_CHECK_THUMBNAILS_ALL_VENDORS) fsizecheck = ifp->size(); - else if ((imgdata.rawparams.options & LIBRAW_RAWOPTIONS_CHECK_THUMBNAILS_KNOWN_VENDORS) - && !strncasecmp(make,"Ricoh",5)) + else if ((imgdata.rawparams.options & LIBRAW_RAWOPTIONS_CHECK_THUMBNAILS_KNOWN_VENDORS) && + (!strncasecmp(make, "Ricoh", 5) || (dng_version && !strncasecmp(make, "Samsung", 7)))) fsizecheck = ifp->size(); for (i = 0; i < (int)tiff_nifds; i++) @@ -2104,6 +2280,7 @@ void LibRaw::apply_tiff() tiff_ifd[i].samples == 1)) /* Allow 1-bps JPEGs */ && tiff_ifd[i].bps > 0 && tiff_ifd[i].bps < 33 && tiff_ifd[i].phint != 32803 && tiff_ifd[i].phint != 34892 && + (tiff_ifd[i].comp != 52546 || (imgdata.rawparams.options & LIBRAW_RAWOPTIONS_ALLOW_JPEGXL_PREVIEWS)) && unsigned(tiff_ifd[i].t_width | tiff_ifd[i].t_height) < 0x10000 && tiff_ifd[i].comp != 34892) { @@ -2150,7 +2327,7 @@ void LibRaw::apply_tiff() { int idx = imgdata.thumbs_list.thumbcount; imgdata.thumbs_list.thumblist[idx].tformat = tiff2thumbformat(tiff_ifd[i].comp, tiff_ifd[i].phint, - tiff_ifd[i].bps, make); + tiff_ifd[i].bps, make, dng_version); imgdata.thumbs_list.thumblist[idx].twidth = tiff_ifd[i].t_width; imgdata.thumbs_list.thumblist[idx].theight = tiff_ifd[i].t_height; imgdata.thumbs_list.thumblist[idx].tflip = tiff_ifd[i].t_flip; @@ -2164,23 +2341,27 @@ void LibRaw::apply_tiff() if (thm >= 0) { thumb_misc |= tiff_ifd[thm].samples << 5; - thumb_format = tiff2thumbformat(tiff_ifd[thm].comp, tiff_ifd[thm].phint, tiff_ifd[thm].bps, make); + thumb_format = tiff2thumbformat(tiff_ifd[thm].comp, tiff_ifd[thm].phint, tiff_ifd[thm].bps, make, dng_version); } } -static LibRaw_internal_thumbnail_formats tiff2thumbformat(int _comp, int _phint, int _bps, const char *_make) +static LibRaw_internal_thumbnail_formats tiff2thumbformat(int _comp, int _phint, int _bps, const char *_make, bool isDNG) { switch (_comp) { case 0: return LIBRAW_INTERNAL_THUMBNAIL_LAYER; case 1: - if (_bps <= 8) - return LIBRAW_INTERNAL_THUMBNAIL_PPM; - else if (!strncmp(_make, "Imacon", 6)) - return LIBRAW_INTERNAL_THUMBNAIL_PPM16; + if (_bps <= 8) + return LIBRAW_INTERNAL_THUMBNAIL_PPM; + else if (!strncmp(_make, "Imacon", 6)) + return LIBRAW_INTERNAL_THUMBNAIL_PPM16; + else if (isDNG && _phint == 6 && _bps == 12) + return LIBRAW_INTERNAL_THUMBNAIL_DNG_YCBCR; else return LIBRAW_INTERNAL_THUMBNAIL_KODAK_THUMB; + case 52546: + return LIBRAW_INTERNAL_THUMBNAIL_JPEGXL; case 65000: return _phint == 6 ? LIBRAW_INTERNAL_THUMBNAIL_KODAK_YCBCR : LIBRAW_INTERNAL_THUMBNAIL_KODAK_RGB; } diff --git a/src/postprocessing/aspect_ratio.cpp b/src/postprocessing/aspect_ratio.cpp index 7e0dfd098..e5165e9bf 100644 --- a/src/postprocessing/aspect_ratio.cpp +++ b/src/postprocessing/aspect_ratio.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/postprocessing/dcraw_process.cpp b/src/postprocessing/dcraw_process.cpp index e8eff1317..8b3d77cf6 100644 --- a/src/postprocessing/dcraw_process.cpp +++ b/src/postprocessing/dcraw_process.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: diff --git a/src/postprocessing/mem_image.cpp b/src/postprocessing/mem_image.cpp index 9f70d671b..4c17994df 100644 --- a/src/postprocessing/mem_image.cpp +++ b/src/postprocessing/mem_image.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: diff --git a/src/postprocessing/postprocessing_aux.cpp b/src/postprocessing/postprocessing_aux.cpp index c8c53fa66..e0fd33521 100644 --- a/src/postprocessing/postprocessing_aux.cpp +++ b/src/postprocessing/postprocessing_aux.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/postprocessing/postprocessing_ph.cpp b/src/postprocessing/postprocessing_ph.cpp index 3af0939dd..4e2947402 100644 --- a/src/postprocessing/postprocessing_ph.cpp +++ b/src/postprocessing/postprocessing_ph.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * Placeholder functions to build LibRaw w/o postprocessing tools diff --git a/src/postprocessing/postprocessing_utils.cpp b/src/postprocessing/postprocessing_utils.cpp index 986b5bbfa..f944adb4c 100644 --- a/src/postprocessing/postprocessing_utils.cpp +++ b/src/postprocessing/postprocessing_utils.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: diff --git a/src/postprocessing/postprocessing_utils_dcrdefs.cpp b/src/postprocessing/postprocessing_utils_dcrdefs.cpp index 98ea0618e..cddc292ab 100644 --- a/src/postprocessing/postprocessing_utils_dcrdefs.cpp +++ b/src/postprocessing/postprocessing_utils_dcrdefs.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/preprocessing/ext_preprocess.cpp b/src/preprocessing/ext_preprocess.cpp index 8f2ec4957..e9020751c 100644 --- a/src/preprocessing/ext_preprocess.cpp +++ b/src/preprocessing/ext_preprocess.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/preprocessing/preprocessing_ph.cpp b/src/preprocessing/preprocessing_ph.cpp index 44868ed55..f296feecb 100644 --- a/src/preprocessing/preprocessing_ph.cpp +++ b/src/preprocessing/preprocessing_ph.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * Placeholder functions to build LibRaw w/o postprocessing and preprocessing calls diff --git a/src/preprocessing/raw2image.cpp b/src/preprocessing/raw2image.cpp index 702cf2902..703d02c17 100644 --- a/src/preprocessing/raw2image.cpp +++ b/src/preprocessing/raw2image.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify @@ -61,12 +61,14 @@ int LibRaw::raw2image(void) { raw2image_start(); - if (is_phaseone_compressed() && imgdata.rawdata.raw_alloc) + bool free_p1_buffer = false; + if (is_phaseone_compressed() && (imgdata.rawdata.raw_alloc || (imgdata.process_warnings & LIBRAW_WARN_RAWSPEED3_PROCESSED))) { phase_one_allocate_tempbuffer(); + free_p1_buffer = true; int rc = phase_one_subtract_black((ushort *)imgdata.rawdata.raw_alloc, imgdata.rawdata.raw_image); - if (rc == 0) + if (rc == 0 && imgdata.params.use_p1_correction) rc = phase_one_correct(); if (rc != 0) { @@ -180,7 +182,7 @@ int LibRaw::raw2image(void) } // Free PhaseOne separate copy allocated at function start - if (is_phaseone_compressed()) + if (free_p1_buffer) { phase_one_free_tempbuffer(); } @@ -306,14 +308,16 @@ int LibRaw::raw2image_ex(int do_subtract_black) try { raw2image_start(); + bool free_p1_buffer = false; // Compressed P1 files with bl data! - if (is_phaseone_compressed() && imgdata.rawdata.raw_alloc) + if (is_phaseone_compressed() && (imgdata.rawdata.raw_alloc || (imgdata.process_warnings & LIBRAW_WARN_RAWSPEED3_PROCESSED))) { phase_one_allocate_tempbuffer(); + free_p1_buffer = true; int rc = phase_one_subtract_black((ushort *)imgdata.rawdata.raw_alloc, imgdata.rawdata.raw_image); - if (rc == 0) + if (rc == 0 && imgdata.params.use_p1_correction) rc = phase_one_correct(); if (rc != 0) { @@ -528,7 +532,7 @@ int LibRaw::raw2image_ex(int do_subtract_black) } // Free PhaseOne separate copy allocated at function start - if (is_phaseone_compressed()) + if (free_p1_buffer) { phase_one_free_tempbuffer(); } diff --git a/src/preprocessing/subtract_black.cpp b/src/preprocessing/subtract_black.cpp index 42bbe4fac..5539d9643 100644 --- a/src/preprocessing/subtract_black.cpp +++ b/src/preprocessing/subtract_black.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify diff --git a/src/tables/cameralist.cpp b/src/tables/cameralist.cpp index da7f48164..86c88894a 100644 --- a/src/tables/cameralist.cpp +++ b/src/tables/cameralist.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: @@ -13,12 +13,6 @@ */ #include "../../internal/libraw_cxx_defs.h" -#ifdef USE_RAWSPEED -/* we need separate file for that */ -#include "../../RawSpeed/rawspeed_xmldata.cpp" -const int RAWSPEED_DATA_COUNT = - (sizeof(_rawspeed_data_xml) / sizeof(_rawspeed_data_xml[0])); -#endif // clang-format off // Supported cameras: static const char *static_camera_list[] = { @@ -36,21 +30,16 @@ static const char *static_camera_list[] = { "Apple iPhone X", "Apple iPhone 12 Pro", "Apple iPhone 12 Pro Max", - "Apple iPhone 13 Pro", + "Apple iPhone 13", + "Apple iPhone 14", "Apple QuickTake 100", "Apple QuickTake 150", "Apple QuickTake 200", -#ifdef LIBRAW_OLD_VIDEO_SUPPORT - "ARRI ALEXA", - "ARRI ALEXA65", - "ARRI ALEXA LF", - "ARRI ALEXA XT", - "ARRI ALEXA SXT", -#endif "ASUS ZenPhone4", "ASUS ZenPhone6", "AutelRobotics XB015", "AutelRobotics XT705 (EVO II)", + "AutelRobotics XL720 (EVO Lite+)", "AVT F-080C", "AVT F-145C", "AVT F-201C", @@ -153,12 +142,17 @@ static const char *static_camera_list[] = { "Canon PowerShot SX20 IS (CHDK hack)", "Canon PowerShot SX30 IS (CHDK hack)", "Canon EOS R", + "Canon EOS Ra", "Canon EOS RP", "Canon EOS R3", "Canon EOS R5", "Canon EOS R6", + "Canon EOS R6 Mark II", "Canon EOS R7", + "Canon EOS R8", "Canon EOS R10", + "Canon EOS R50", + "Canon EOS R100", "Canon EOS D30", "Canon EOS D60", "Canon EOS 5DS", @@ -205,9 +199,6 @@ static const char *static_camera_list[] = { "Canon EOS 1300D / Rebel T6 / Kiss X80", "Canon EOS 1500D / 2000D / Rebel T7 / Kiss X90", "Canon EOS 3000D / 4000D / Rebel T100", -#ifdef LIBRAW_OLD_VIDEO_SUPPORT - "Canon EOS C500", -#endif "Canon EOS D2000", "Canon EOS M", "Canon EOS M2", @@ -291,11 +282,18 @@ static const char *static_camera_list[] = { "Digital Bolex D16", "Digital Bolex D16M", "DJI 4384x3288", + "DJI Inspire 3", "DJI Mavic Air", - "DJI Mavic Air2", + "DJI Mavic Air 2", "DJI Mavic Air 2S", - "DJI Mavic Mini2", + "DJI Mavic Air 3", + "DJI Mavic Mini 2", + "DJI Mavic Mini 3", + "DJI Mavic Mini 3 Pro", + "DJI Mavic 2 Pro", "DJI Mavic 3", + "DJI Mavic 3 Classic", + "DJI Mavic 3 Pro", "DJI Osmo Action", "DJI Pocket", "DJI Phantom4 Pro/Pro+", @@ -342,11 +340,13 @@ static const char *static_camera_list[] = { "FujiFilm GFX 50S II", "FujiFilm GFX 50R", "FujiFilm GFX 100", + "FujiFilm GFX 100 II", "FujiFilm GFX 100S", "FujiFilm X-Pro1", "FujiFilm X-Pro2", "FujiFilm X-Pro3", "FujiFilm X-S1", + "FujiFilm X-S20", "FujiFilm XQ1", "FujiFilm XQ2", "FujiFilm X100", @@ -374,6 +374,7 @@ static const char *static_camera_list[] = { "FujiFilm XF1", "FujiFilm XF10", "FujiFilm X-H1", + "FujiFilm X-H2", "FujiFilm X-H2S", "FujiFilm X-T1", "FujiFilm X-S10", @@ -381,6 +382,7 @@ static const char *static_camera_list[] = { "FujiFilm X-T2", "FujiFilm X-T3", "FujiFilm X-T4", + "FujiFilm X-T5", "FujiFilm X-T10", "FujiFilm X-T20", "FujiFilm X-T30", @@ -398,6 +400,7 @@ static const char *static_camera_list[] = { "Google Pixel 4 XL", "Google Pixel 4a (5G)", "Google Pixel 5", + "Google Pixel 7a", #ifdef USE_GPRSDK "GoPro Fusion", "GoPro HERO5", @@ -406,6 +409,8 @@ static const char *static_camera_list[] = { "GoPro HERO8", "GoPro HERO9", "GoPro HERO10", + "GoPro HERO11", + "GoPro HERO12", #endif "Hasselblad H2D-22", "Hasselblad H2D-39", @@ -443,6 +448,7 @@ static const char *static_camera_list[] = { "Hasselblad HV", "Hasselblad X1D", "Hasselblad X1D II 50C", + "Hasselblad X2D 100C", "HTC UltraPixel", "HTC MyTouch 4G", "HTC One (A9)", @@ -587,6 +593,7 @@ static const char *static_camera_list[] = { "Leica M10-R", "Leica M10 Monochrom", "Leica M11", + "Leica M11 Monochrom", "Leica M (Typ 240)", "Leica M (Typ 262)", "Leica Monochrom (Typ 240)", @@ -599,6 +606,7 @@ static const char *static_camera_list[] = { "Leica Q-P", "Leica Q2", "Leica Q2 Monochrom", + "Leica Q3", "Leica S", "Leica S2", "Leica S3", @@ -710,7 +718,9 @@ static const char *static_camera_list[] = { "Nikon Z 6 II", "Nikon Z 7", "Nikon Z 7 II", + "Nikon Z 8 (HE/HE* formats are not supported yet)", "Nikon Z 9 (HE/HE* formats are not supported yet)", + "Nikon Z 30", "Nikon Z 50", "Nikon Z fc", "Nikon 1 AW1", @@ -843,6 +853,7 @@ static const char *static_camera_list[] = { "Olympus XZ-2", "Olympus XZ-10", "OM Digital Solutions OM-1", + "OM Digital Solutions OM-5", "OmniVision 4688", "OmniVision OV5647", "OmniVision OV5648", @@ -882,6 +893,7 @@ static const char *static_camera_list[] = { "Panasonic DMC-G7 / G70", "Panasonic DMC-G8 / G80 / G81 / G85", "Panasonic DC-G9", + "Panasonic DC-G9 Mark II", "Panasonic DC-G90 / G95 / G91 / G99", "Panasonic DC-G100 / G110", "Panasonic DMC-GF1", @@ -899,6 +911,7 @@ static const char *static_camera_list[] = { "Panasonic DC-GH5", "Panasonic DC-GH5S", "Panasonic DC-GH5 Mark II", + "Panasonic DC-GH6", "Panasonic DMC-GM1", "Panasonic DMC-GM1s", "Panasonic DMC-GM5", @@ -924,6 +937,7 @@ static const char *static_camera_list[] = { "Panasonic DC-S1H", "Panasonic DC-S1R", "Panasonic DC-S5", + "Panasonic DC-S5 MkII", "Panasonic DMC-ZS40, DMC-TZ60 / TZ61", "Panasonic DMC-ZS50, DMC-TZ70 / TZ71", "Panasonic DMC-ZS60, DMC-TZ80 / TZ81 / TZ82 / TZ85", @@ -931,6 +945,7 @@ static const char *static_camera_list[] = { "Panasonic DC-ZS80, DC-TZ95 / TZ96 / TZ97", "Panasonic DMC-ZS100 / ZS110, DMC-TZ100 / TZ101 / TZ110, DMC-TX1", "Panasonic DC-ZS200 / ZS220, DC-TZ200 / TZ202 / TZ220, DC-TX2", + "Panasonic DC-ZS200D / ZS220D, DC-TZ200D / TZ202D / TZ220D", "PARROT Anafi", "PARROT Bebop 2", "PARROT Bebop Drone", @@ -955,6 +970,7 @@ static const char *static_camera_list[] = { "Pentax K-3", "Pentax K-3 Mark II", "Pentax K-3 Mark III", +// "Pentax K-3 Mark III Monochrome", "Pentax K-30", "Pentax K-5", "Pentax K-5 II", @@ -1035,11 +1051,6 @@ static const char *static_camera_list[] = { "Ricoh GXR Ricoh Lens A16 24-85mm F3.5-5.5", "Ricoh GXR Ricoh Lens S10 24-72mm F2.5-4.4 VC", "Ricoh GXR Ricoh Lens P10 28-300 mm F3.5-5.6 VC", -#ifdef LIBRAW_OLD_VIDEO_SUPPORT -#ifndef NO_JASPER - "Redcode R3D format", -#endif -#endif "Rollei d530flex", "RoverShot 3320af", "Samsung EX1 / TL500", @@ -1060,6 +1071,7 @@ static const char *static_camera_list[] = { "Samsung Galaxy S9+ (SM-G965U / 965F)", "Samsung Galaxy S10 (SM-G973F)", "Samsung Galaxy S10+ (SM-G975U)", + "Samsung Galaxy S22 Ultra (SM-S908B)", "Samsung NX1", "Samsung NX5", "Samsung NX10", @@ -1088,6 +1100,7 @@ static const char *static_camera_list[] = { "Seitz Roundshot D3", "Seitz Roundshot D2X", "Seitz Roundshot D2Xs", + "Skydio 2+", "Sigma fp", #ifdef USE_X3FTOOLS "Sigma SD9 (raw decode only)", @@ -1138,12 +1151,15 @@ static const char *static_camera_list[] = { "Sony ILCE-7M3 (A7 III)", "Sony ILCE-7M4 (A7 IV)", "Sony ILCE-7C (A7C)", + "Sony ILCE-7CR (A7CR)", + "Sony ILCE-7CM2 (A7C II)", "Sony ILCE-7R (A7R)", "Sony ILCE-7RM2 (A7R II)", "Sony ILCE-7RM3 (A7R III)", "Sony ILCE-7RM3A (A7R IIIA)", "Sony ILCE-7RM4 (A7R IV)", "Sony ILCE-7RM4A (A7R IVA)", + "Sony ILCE-7RM5 (A7R V)", "Sony ILCE-7S (A7S)", "Sony ILCE-7SM2 (A7S II)", "Sony ILCE-7SM3 (A7S III)", @@ -1161,6 +1177,7 @@ static const char *static_camera_list[] = { "Sony ILCE-6400", "Sony ILCE-6500", "Sony ILCE-6600", + "Sony ILCE-6700", "Sony ILCE-QX1", "Sony DSC-F828", "Sony DSC-HX95", @@ -1234,7 +1251,10 @@ static const char *static_camera_list[] = { "Sony Xperia 5 II (XQ-AS52)", "Sony Xperia L", "Sony Xperia 1 III", + "Sony Xperia 1 IV (XQ-CT54)", "Sony ZV-1 (DCZV1/B)", + "Sony ZV-1M2", + "Sony ZV-E1", "Sony ZV-E10", "STV680 VGA", "PtGrey GRAS-50S5C", @@ -1246,6 +1266,8 @@ static const char *static_camera_list[] = { "YUNEEC CGO3", "YUNEEC CGO3P", "YUNEEC CGO4", + "Xiaomi 12S Ultra (2203121C)", + "Xiaomi 13 Pro (2210132G)", "Xiaomi MI3", "Xiaomi MI 8", "Xiaomi MI 9 Lite", diff --git a/src/tables/colorconst.cpp b/src/tables/colorconst.cpp index ad5a649cf..5e178e2d6 100644 --- a/src/tables/colorconst.cpp +++ b/src/tables/colorconst.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: diff --git a/src/tables/colordata.cpp b/src/tables/colordata.cpp index fc9f100f7..25d27a3a4 100644 --- a/src/tables/colordata.cpp +++ b/src/tables/colordata.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. @@ -31,601 +31,622 @@ int LibRaw::adobe_coeff(unsigned make_idx, const char *t_model, const char *prefix; int t_black, t_maximum, trans[12]; } table[] = { - { LIBRAW_CAMERAMAKER_Agfa, "DC-833m", 0, 0, - { 11438,-3762,-1115,-2409,9914,2497,-1227,2295,5300 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Agfa, "DC-833m", 0, 0, + { 11438,-3762,-1115,-2409,9914,2497,-1227,2295,5300 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Apple, "QuickTake", 0, 0, - { 21392,-5653,-3353,2406,8010,-415,7166,1427,2078 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Apple, "QuickTake", 0, 0, + { 21392,-5653,-3353,2406,8010,-415,7166,1427,2078 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Broadcom, "RPi IMX219", 66, 0x3ff, - { 5302,1083,-728,-5320,14112,1699,-863,2371,5136 } }, /* LibRaw */ - { LIBRAW_CAMERAMAKER_Broadcom, "RPi OV5647", 16, 0x3ff, - { 12782,-4059,-379,-478,9066,1413,1340,1513,5176 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Broadcom, "RPi IMX219", 66, 0x3ff, + { 5302,1083,-728,-5320,14112,1699,-863,2371,5136 } }, /* LibRaw */ + { LIBRAW_CAMERAMAKER_Broadcom, "RPi OV5647", 16, 0x3ff, + { 12782,-4059,-379,-478,9066,1413,1340,1513,5176 } }, /* DJC */ { LIBRAW_CAMERAMAKER_Broadcom, "Pi", 16, 0x3ff, { 12782,-4059,-379,-478,9066,1413,1340,1513,5176 } }, /* DJC */ #ifdef USE_6BY9RPI // this code normalizes model to LIBRAW_CAMERAMAKER_RaspberryPi - { LIBRAW_CAMERAMAKER_RaspberryPi, "RP_imx477", 0, 0, // Do not set black, it is set at parser to 256 or 64 - { 5603, -1351, -600, -2872, 11180, 2132, 600, 453, 5821 } }, /* PyDNG */ - { LIBRAW_CAMERAMAKER_RaspberryPi, "RP_imx", 66, 0x3ff, - { 5302,1083,-728,-5320,14112,1699,-863,2371,5136 } }, /* LibRaw */ - { LIBRAW_CAMERAMAKER_RaspberryPi, "ov5647", 16, 0x3ff, - { 12782,-4059,-379,-478,9066,1413,1340,1513,5176 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_RaspberryPi, "RP_imx477", 0, 0, // Do not set black, it is set at parser to 256 or 64 + { 5603, -1351, -600, -2872, 11180, 2132, 600, 453, 5821 } }, /* PyDNG */ + { LIBRAW_CAMERAMAKER_RaspberryPi, "RP_imx", 66, 0x3ff, + { 5302,1083,-728,-5320,14112,1699,-863,2371,5136 } }, /* LibRaw */ + { LIBRAW_CAMERAMAKER_RaspberryPi, "ov5647", 16, 0x3ff, + { 12782,-4059,-379,-478,9066,1413,1340,1513,5176 } }, /* DJC */ #endif - { LIBRAW_CAMERAMAKER_Canon, "EOS D30", 0, 0, - { 9900,-2771,-1324,-7072,14229,3140,-2790,3344,8861 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS D60", 0, 0xfa0, - { 6211,-1358,-896,-8557,15766,3012,-3001,3507,8567 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 5DS", 0, 0x3c96, // same CMs: 5DS, "5DS R" */ - { 6250,-711,-808,-5153,12794,2636,-1249,2198,5610 } }, // v.2 - { LIBRAW_CAMERAMAKER_Canon, "EOS 5D Mark IV", 0, 0, - { 6446,-366,-864,-4436,12204,2513,-952,2496,6348 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 5D Mark III", 0, 0x3c80, - { 6722,-635,-963,-4287,12460,2028,-908,2162,5668 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 5D Mark II", 0, 0x3cf0, - { 4716,603,-830,-7798,15474,2480,-1496,1937,6651 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 5D", 0, 0xe6c, - { 6347,-479,-972,-8297,15954,2480,-1968,2131,7649 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 6D Mark II", 0, 0x38de, - { 6875,-970,-932,-4691,12459,2501,-874,1953,5809 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 6D", 0, 0x3c82, - { 7034,-804,-1014,-4420,12564,2058,-851,1994,5758 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 77D", 0, 0, - { 7377,-742,-998,-4235,11981,2549,-673,1918,5538 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 7D Mark II", 0, 0x3510, - { 7268,-1082,-969,-4186,11839,2663,-825,2029,5839 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 7D", 0, 0x3510, - { 6844,-996,-856,-3876,11761,2396,-593,1772,6198 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 850D", 0, 0, - { 9079,-1923,-1236,-4677,12454,2492,-922,2319,5565}}, - { LIBRAW_CAMERAMAKER_Canon, "EOS 800D", 0, 0, - { 6970,-512,-968,-4425,12161,2553,-739,1982,5601 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 80D", 0, 0, - { 7457,-671,-937,-4849,12495,2643,-1213,2354,5492 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 10D", 0, 0xfa0, - { 8250,-2044,-1127,-8092,15606,2664,-2893,3453,8348 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 250D", 0, 0, - { 9079,-1923,-1236,-4677,12454,2492,-922,2319,5565 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 200D", 0, 0, - { 7377,-742,-998,-4235,11981,2549,-673,1918,5538 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 20Da", 0, 0, - { 14155,-5065,-1382,-6550,14633,2039,-1623,1824,6561 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 20D", 0, 0xfff, - { 6599,-537,-891,-8071,15783,2424,-1983,2234,7462 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 30D", 0, 0, - { 6257,-303,-1000,-7880,15621,2396,-1714,1904,7046 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 40D", 0, 0x3f60, - { 6071,-747,-856,-7653,15365,2441,-2025,2553,7315 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 50D", 0, 0x3d93, - { 4920,616,-593,-6493,13964,2784,-1774,3178,7005 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 60Da", 0, 0x2ff7, - { 17492,-7240,-2023,-1791,10323,1701,-186,1329,5406 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 60D", 0, 0x2ff7, - { 6719,-994,-925,-4408,12426,2211,-887,2129,6051 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 70D", 0, 0x3bc7, - { 7034,-804,-1014,-4420,12564,2058,-851,1994,5758 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 100D", 0, 0x350f, - { 6602,-841,-939,-4472,12458,2247,-975,2039,6148 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 300D", 0, 0xfa0, - { 8250,-2044,-1127,-8092,15606,2664,-2893,3453,8348 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 350D", 0, 0xfff, - { 6018,-617,-965,-8645,15881,2975,-1530,1719,7642 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 3000D", 0, 0, - { 6939,-1016,-866,-4428,12473,2177,-1175,2178,6162 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 400D", 0, 0xe8e, - { 7054,-1501,-990,-8156,15544,2812,-1278,1414,7796 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 450D", 0, 0x390d, - { 5784,-262,-821,-7539,15064,2672,-1982,2681,7427 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 500D", 0, 0x3479, - { 4763,712,-646,-6821,14399,2640,-1921,3276,6561 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 550D", 0, 0x3dd7, - { 6941,-1164,-857,-3825,11597,2534,-416,1540,6039 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 600D", 0, 0x3510, - { 6461,-907,-882,-4300,12184,2378,-819,1944,5931 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 650D", 0, 0x354d, - { 6602,-841,-939,-4472,12458,2247,-975,2039,6148 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 750D", 0, 0x3c00, - { 6362,-823,-847,-4426,12109,2616,-743,1857,5635 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 760D", 0, 0x3c00, - { 6362,-823,-847,-4426,12109,2616,-743,1857,5635 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 700D", 0, 0x3c00, - { 6602,-841,-939,-4472,12458,2247,-975,2039,6148 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 90D", 0, 0, - { 11498, -3759, -1516, -5073, 12954, 2349, -892, 1867, 6118}}, - { LIBRAW_CAMERAMAKER_Canon, "EOS 1000D", 0, 0xe43, - { 6771,-1139,-977,-7818,15123,2928,-1244,1437,7533 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 1100D", 0, 0x3510, - { 6444,-904,-893,-4563,12308,2535,-903,2016,6728 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 1200D", 0, 0x37c2, - { 6461,-907,-882,-4300,12184,2378,-819,1944,5931 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 1300D", 0, 0x37c2, - { 6939,-1016,-866,-4428,12473,2177,-1175,2178,6162 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS 1500D", 0, 0, - { 8300,-2110,-1120,-4917,12694,2482,-938,2141,5666 } }, // v.2 + { LIBRAW_CAMERAMAKER_Canon, "EOS D30", 0, 0, + { 9900,-2771,-1324,-7072,14229,3140,-2790,3344,8861 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS D60", 0, 0xfa0, + { 6211,-1358,-896,-8557,15766,3012,-3001,3507,8567 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 5DS", 0, 0x3c96, // same CMs: 5DS, "5DS R" */ + { 6250,-711,-808,-5153,12794,2636,-1249,2198,5610 } }, // v.2 + { LIBRAW_CAMERAMAKER_Canon, "EOS 5D Mark IV", 0, 0, + { 6446,-366,-864,-4436,12204,2513,-952,2496,6348 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 5D Mark III", 0, 0x3c80, + { 6722,-635,-963,-4287,12460,2028,-908,2162,5668 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 5D Mark II", 0, 0x3cf0, + { 4716,603,-830,-7798,15474,2480,-1496,1937,6651 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 5D", 0, 0xe6c, + { 6347,-479,-972,-8297,15954,2480,-1968,2131,7649 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 6D Mark II", 0, 0x38de, + { 6875,-970,-932,-4691,12459,2501,-874,1953,5809 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 6D", 0, 0x3c82, + { 7034,-804,-1014,-4420,12564,2058,-851,1994,5758 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 77D", 0, 0, + { 7377,-742,-998,-4235,11981,2549,-673,1918,5538 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 7D Mark II", 0, 0x3510, + { 7268,-1082,-969,-4186,11839,2663,-825,2029,5839 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 7D", 0, 0x3510, + { 6844,-996,-856,-3876,11761,2396,-593,1772,6198 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 850D", 0, 0, + { 9079,-1923,-1236,-4677,12454,2492,-922,2319,5565}}, + { LIBRAW_CAMERAMAKER_Canon, "EOS 800D", 0, 0, + { 6970,-512,-968,-4425,12161,2553,-739,1982,5601 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 80D", 0, 0, + { 7457,-671,-937,-4849,12495,2643,-1213,2354,5492 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 10D", 0, 0xfa0, + { 8250,-2044,-1127,-8092,15606,2664,-2893,3453,8348 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 250D", 0, 0, + { 9079,-1923,-1236,-4677,12454,2492,-922,2319,5565 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 200D", 0, 0, + { 7377,-742,-998,-4235,11981,2549,-673,1918,5538 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 20Da", 0, 0, + { 14155,-5065,-1382,-6550,14633,2039,-1623,1824,6561 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 20D", 0, 0xfff, + { 6599,-537,-891,-8071,15783,2424,-1983,2234,7462 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 30D", 0, 0, + { 6257,-303,-1000,-7880,15621,2396,-1714,1904,7046 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 40D", 0, 0x3f60, + { 6071,-747,-856,-7653,15365,2441,-2025,2553,7315 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 50D", 0, 0x3d93, + { 4920,616,-593,-6493,13964,2784,-1774,3178,7005 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 60Da", 0, 0x2ff7, + { 17492,-7240,-2023,-1791,10323,1701,-186,1329,5406 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 60D", 0, 0x2ff7, + { 6719,-994,-925,-4408,12426,2211,-887,2129,6051 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 70D", 0, 0x3bc7, + { 7034,-804,-1014,-4420,12564,2058,-851,1994,5758 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 100D", 0, 0x350f, + { 6602,-841,-939,-4472,12458,2247,-975,2039,6148 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 300D", 0, 0xfa0, + { 8250,-2044,-1127,-8092,15606,2664,-2893,3453,8348 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 350D", 0, 0xfff, + { 6018,-617,-965,-8645,15881,2975,-1530,1719,7642 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 3000D", 0, 0, + { 6939,-1016,-866,-4428,12473,2177,-1175,2178,6162 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 400D", 0, 0xe8e, + { 7054,-1501,-990,-8156,15544,2812,-1278,1414,7796 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 450D", 0, 0x390d, + { 5784,-262,-821,-7539,15064,2672,-1982,2681,7427 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 500D", 0, 0x3479, + { 4763,712,-646,-6821,14399,2640,-1921,3276,6561 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 550D", 0, 0x3dd7, + { 6941,-1164,-857,-3825,11597,2534,-416,1540,6039 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 600D", 0, 0x3510, + { 6461,-907,-882,-4300,12184,2378,-819,1944,5931 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 650D", 0, 0x354d, + { 6602,-841,-939,-4472,12458,2247,-975,2039,6148 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 750D", 0, 0x3c00, + { 6362,-823,-847,-4426,12109,2616,-743,1857,5635 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 760D", 0, 0x3c00, + { 6362,-823,-847,-4426,12109,2616,-743,1857,5635 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 700D", 0, 0x3c00, + { 6602,-841,-939,-4472,12458,2247,-975,2039,6148 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 90D", 0, 0, + { 11498, -3759, -1516, -5073, 12954, 2349, -892, 1867, 6118}}, + { LIBRAW_CAMERAMAKER_Canon, "EOS 1000D", 0, 0xe43, + { 6771,-1139,-977,-7818,15123,2928,-1244,1437,7533 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 1100D", 0, 0x3510, + { 6444,-904,-893,-4563,12308,2535,-903,2016,6728 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 1200D", 0, 0x37c2, + { 6461,-907,-882,-4300,12184,2378,-819,1944,5931 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 1300D", 0, 0x37c2, + { 6939,-1016,-866,-4428,12473,2177,-1175,2178,6162 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS 1500D", 0, 0, + { 8300,-2110,-1120,-4917,12694,2482,-938,2141,5666 } }, // v.2 - { LIBRAW_CAMERAMAKER_Canon, "EOS RP", 0, 0, - { 8608,-2097,-1178,-5425,13265,2383,-1149,2238,5680 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS R3", 0, 0, - { 9423,-2839,-1195,-4532,12377,2415,-483,1374,5276 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS R5", 0, 0, - { 9766,-2953,-1254,-4276,12116,2433,-437,1336,5131 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS R6", 0, 0, - { 8293,-1611,-1132,-4759,12711,2275,-1013,2415,5509 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS RP", 0, 0, + { 8608,-2097,-1178,-5425,13265,2383,-1149,2238,5680 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS R3", 0, 0, + { 9423,-2839,-1195,-4532,12377,2415,-483,1374,5276 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS R50", 0, 0, + { 9269, -2012, -1107, -3990, 11762, 2527, -569, 2093, 4913 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS R100", 0, 0, + { 8230, -1515, -1032, -4179, 12005, 2454, -649, 2076, 4711 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS R5", 0, 0, + { 9766,-2953,-1254,-4276,12116,2433,-437,1336,5131 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS R6 Mark II", 0, 0, + { 9539, -2795, -1224, -4175, 11998, 2458, -465, 1755,6048 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS R6", 0, 0, + { 8293,-1611,-1132,-4759,12711,2275,-1013,2415,5509 } }, { LIBRAW_CAMERAMAKER_Canon, "EOS R7", 0, 0, { 10424, -3138, -1300, -4221, 11938, 2584, -547, 1658, 6183 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS R8", 0, 0, + { 9539, -2795, -1224, -4175, 11998, 2458, -465, 1755, 6048 } }, { LIBRAW_CAMERAMAKER_Canon, "EOS R10", 0, 0, { 9269, -2012, -1107, -3990, 11762, 2527, -569, 2093, 4913 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS Ra", 0, 0, + { 22880,-11531,-2223,-2034,10469,1809, 316,1401,5769 } }, { LIBRAW_CAMERAMAKER_Canon, "EOS R", 0, 0, - { 8293,-1789,-1094,-5025,12925,2327,-1199,2769,6108 } }, // v.2 + { 8293,-1789,-1094,-5025,12925,2327,-1199,2769,6108 } }, // v.2 - { LIBRAW_CAMERAMAKER_Canon, "EOS M6 Mark II", 0, 0, - { 11498,-3759,-1516,-5073,12954,2349,-892,1867,6118 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS M6", 0, 0, - { 8532,-701,-1167,-4095,11879,2508,-797,2424,7010 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS M50 Mark II", 0, 0, - { 10463,-2173,-1437,-4856,12635,2482,-1216,2915,7237 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS M50", 0, 0, - { 8532,-701,-1167,-4095,11879,2508,-797,2424,7010 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS M5", 0, 0, - { 8532,-701,-1167,-4095,11879,2508,-797,2424,7010 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS M3", 0, 0, - { 6362,-823,-847,-4426,12109,2616,-743,1857,5635 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS M200", 0, 0, - { 10463,-2173,-1437,-4856,12635,2482,-1216,2915,7237 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS M2", 0, 0, - { 6400,-480,-888,-5294,13416,2047,-1296,2203,6137 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS M100", 0, 0, - { 8532,-701,-1167,-4095,11879,2508,-797,2424,7010 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS M10", 0, 0, - { 6400,-480,-888,-5294,13416,2047,-1296,2203,6137 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS M", 0, 0, - { 6602,-841,-939,-4472,12458,2247,-975,2039,6148 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS M6 Mark II", 0, 0, + { 11498,-3759,-1516,-5073,12954,2349,-892,1867,6118 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS M6", 0, 0, + { 8532,-701,-1167,-4095,11879,2508,-797,2424,7010 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS M50 Mark II", 0, 0, + { 10463,-2173,-1437,-4856,12635,2482,-1216,2915,7237 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS M50", 0, 0, + { 8532,-701,-1167,-4095,11879,2508,-797,2424,7010 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS M5", 0, 0, + { 8532,-701,-1167,-4095,11879,2508,-797,2424,7010 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS M3", 0, 0, + { 6362,-823,-847,-4426,12109,2616,-743,1857,5635 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS M200", 0, 0, + { 10463,-2173,-1437,-4856,12635,2482,-1216,2915,7237 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS M2", 0, 0, + { 6400,-480,-888,-5294,13416,2047,-1296,2203,6137 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS M100", 0, 0, + { 8532,-701,-1167,-4095,11879,2508,-797,2424,7010 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS M10", 0, 0, + { 6400,-480,-888,-5294,13416,2047,-1296,2203,6137 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS M", 0, 0, + { 6602,-841,-939,-4472,12458,2247,-975,2039,6148 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS-1Ds Mark III", 0, 0x3bb0, - { 5859,-211,-930,-8255,16017,2353,-1732,1887,7448 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS-1Ds Mark II", 0, 0xe80, - { 6517,-602,-867,-8180,15926,2378,-1618,1771,7633 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS-1D Mark IV", 0, 0x3bb0, - { 6014,-220,-795,-4109,12014,2361,-561,1824,5787 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS-1D Mark III", 0, 0x3bb0, - { 6291,-540,-976,-8350,16145,2311,-1714,1858,7326 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS-1D Mark II N", 0, 0xe80, - { 6240,-466,-822,-8180,15825,2500,-1801,1938,8042 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS-1D Mark II", 0, 0xe80, - { 6264,-582,-724,-8312,15948,2504,-1744,1919,8664 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS-1Ds", 0, 0xe20, - { 3925,4060,-1739,-8973,16552,2545,-3287,3945,8243 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS-1D C", 0, 0x3c4e, - { 6847,-614,-1014,-4669,12737,2139,-1197,2488,6846 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS-1D X Mark III", 0, 0, - { 8971, -2022, -1242, -5405, 13249, 2380, -1280, 2483, 6072}}, - { LIBRAW_CAMERAMAKER_Canon, "EOS-1D X Mark II", 0, 0x3c4e, - { 7596,-978,-967,-4808,12571,2503,-1398,2567,5752 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS-1D X", 0, 0x3c4e, - { 6847,-614,-1014,-4669,12737,2139,-1197,2488,6846 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS-1D", 0, 0xe20, - { 6806,-179,-1020,-8097,16415,1687,-3267,4236,7690 } }, - { LIBRAW_CAMERAMAKER_Canon, "EOS C500", 853, 0, - { 17851,-10604,922,-7425,16662,763,-3660,3636,22278 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Canon, "EOS-1Ds Mark III", 0, 0x3bb0, + { 5859,-211,-930,-8255,16017,2353,-1732,1887,7448 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS-1Ds Mark II", 0, 0xe80, + { 6517,-602,-867,-8180,15926,2378,-1618,1771,7633 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS-1D Mark IV", 0, 0x3bb0, + { 6014,-220,-795,-4109,12014,2361,-561,1824,5787 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS-1D Mark III", 0, 0x3bb0, + { 6291,-540,-976,-8350,16145,2311,-1714,1858,7326 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS-1D Mark II N", 0, 0xe80, + { 6240,-466,-822,-8180,15825,2500,-1801,1938,8042 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS-1D Mark II", 0, 0xe80, + { 6264,-582,-724,-8312,15948,2504,-1744,1919,8664 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS-1Ds", 0, 0xe20, + { 3925,4060,-1739,-8973,16552,2545,-3287,3945,8243 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS-1D C", 0, 0x3c4e, + { 6847,-614,-1014,-4669,12737,2139,-1197,2488,6846 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS-1D X Mark III", 0, 0, + { 8971, -2022, -1242, -5405, 13249, 2380, -1280, 2483, 6072}}, + { LIBRAW_CAMERAMAKER_Canon, "EOS-1D X Mark II", 0, 0x3c4e, + { 7596,-978,-967,-4808,12571,2503,-1398,2567,5752 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS-1D X", 0, 0x3c4e, + { 6847,-614,-1014,-4669,12737,2139,-1197,2488,6846 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS-1D", 0, 0xe20, + { 6806,-179,-1020,-8097,16415,1687,-3267,4236,7690 } }, + { LIBRAW_CAMERAMAKER_Canon, "EOS C500", 853, 0, + { 17851,-10604,922,-7425,16662,763,-3660,3636,22278 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Canon, "IXUS 160", 0, 0, - { 11657,-3781,-1136,-3544,11262,2283,-160,1219,4700 } }, /* DJC */ - {LIBRAW_CAMERAMAKER_Canon, "PowerShot 600", 0, 0, - { -3822,10019,1311,4085,-157,3386,-5341,10829,4812,-1969,10969,1126 } }, + { LIBRAW_CAMERAMAKER_Canon, "IXUS 160", 0, 0, + { 11657,-3781,-1136,-3544,11262,2283,-160,1219,4700 } }, /* DJC */ + {LIBRAW_CAMERAMAKER_Canon, "PowerShot 600", 0, 0, + { -3822,10019,1311,4085,-157,3386,-5341,10829,4812,-1969,10969,1126 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot A3300 IS", 0, 0, - { 10826,-3654,-1023,-3215,11310,1906,0,999,4960 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Canon, "PowerShot A460", 0, 0, - { 6493,-2338,-885,-1589,5934,697,-445,1368,2543 } }, // CHDK - { LIBRAW_CAMERAMAKER_Canon, "PowerShot A470", 0, 0, - { 12513,-4407,-1242,-2680,10276,2405,-878,2215,4734 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Canon, "PowerShot A530", 0, 0, - { 7252,-2405,-1223,-2102,6560,523,-112,704,3007 } }, // CHDK - { LIBRAW_CAMERAMAKER_Canon, "PowerShot A50", 0, 0, - { -6233,10706,1825,3260,821,3980,-6512,10745,6287,-2539,12232,262 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot A5", 0, 0, - { -5707,10308,2002,2662,1829,4139,-6265,11063,6033,-2659,11911,593 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot A610", 0, 0, - { 15591,-6402,-1592,-5365,13198,2168,-1300,1824,5075 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Canon, "PowerShot A620", 0, 0, - { 15265,-6193,-1558,-4125,12116,2010,-888,1639,5220 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Canon, "PowerShot A630", 0, 0, - { 14201,-5308,-1757,-6087,14472,1617,-2191,3105,5348 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Canon, "PowerShot A640", 0, 0, - { 13124,-5329,-1390,-3602,11658,1944,-1612,2863,4885 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Canon, "PowerShot A650 IS", 0, 0, - { 9427,-3036,-959,-2581,10671,1911,-1039,1982,4430 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Canon, "PowerShot A720 IS", 0, 0, - { 14573,-5482,-1546,-1266,9799,1468,-1040,1912,3810 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Canon, "PowerShot A3300 IS", 0, 0, + { 10826,-3654,-1023,-3215,11310,1906,0,999,4960 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Canon, "PowerShot A460", 0, 0, + { 6493,-2338,-885,-1589,5934,697,-445,1368,2543 } }, // CHDK + { LIBRAW_CAMERAMAKER_Canon, "PowerShot A470", 0, 0, + { 12513,-4407,-1242,-2680,10276,2405,-878,2215,4734 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Canon, "PowerShot A530", 0, 0, + { 7252,-2405,-1223,-2102,6560,523,-112,704,3007 } }, // CHDK + { LIBRAW_CAMERAMAKER_Canon, "PowerShot A50", 0, 0, + { -6233,10706,1825,3260,821,3980,-6512,10745,6287,-2539,12232,262 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot A5", 0, 0, + { -5707,10308,2002,2662,1829,4139,-6265,11063,6033,-2659,11911,593 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot A610", 0, 0, + { 15591,-6402,-1592,-5365,13198,2168,-1300,1824,5075 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Canon, "PowerShot A620", 0, 0, + { 15265,-6193,-1558,-4125,12116,2010,-888,1639,5220 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Canon, "PowerShot A630", 0, 0, + { 14201,-5308,-1757,-6087,14472,1617,-2191,3105,5348 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Canon, "PowerShot A640", 0, 0, + { 13124,-5329,-1390,-3602,11658,1944,-1612,2863,4885 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Canon, "PowerShot A650 IS", 0, 0, + { 9427,-3036,-959,-2581,10671,1911,-1039,1982,4430 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Canon, "PowerShot A720 IS", 0, 0, + { 14573,-5482,-1546,-1266,9799,1468,-1040,1912,3810 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Canon, "PowerShot D10", 127, 0, - { 14052,-5229,-1156,-1325,9420,2252,-498,1957,4116 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Canon, "PowerShot D10", 127, 0, + { 14052,-5229,-1156,-1325,9420,2252,-498,1957,4116 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G10", 0, 0, - { 11093,-3906,-1028,-5047,12492,2879,-1003,1750,5561 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G11", 0, 0, - { 12177,-4817,-1069,-1612,9864,2049,-98,850,4471 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G12", 0, 0, - { 13244,-5501,-1248,-1508,9858,1935,-270,1083,4366 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G15", 0, 0, - { 7474,-2301,-567,-4056,11456,2975,-222,716,4181 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G16", 0, 0, - { 8020,-2687,-682,-3704,11879,2052,-965,1921,5556 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G1 X Mark III", 0, 0, - { 8532,-701,-1167,-4095,11879,2508,-797,2424,7010 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G1 X Mark II", 0, 0, - { 7378,-1255,-1043,-4088,12251,2048,-876,1946,5805 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G1 X", 0, 0, - { 7378,-1255,-1043,-4088,12251,2048,-876,1946,5805 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G1", 0, 0, - { -5686,10300,2223,4725,-1157,4383,-6128,10783,6163,-2688,12093,604 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G2", 0, 0, - { 9194,-2787,-1059,-8098,15657,2608,-2610,3064,7867 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G3 X", 0, 0, - { 9701,-3857,-921,-3149,11537,1817,-786,1817,5147 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G3", 0, 0, - { 9326,-2882,-1084,-7940,15447,2677,-2620,3090,7740 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G5 X Mark II",0, 0, - { 11629, -5713, -914, -2706, 11090, 1842, -206, 1225, 5515 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G5 X",0, 0, - { 9602,-3823,-937,-2984,11495,1675,-407,1415,5049 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G5", 0, 0, - { 9869,-2972,-942,-7314,15098,2369,-1898,2536,7282 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G6", 0, 0, - { 9876,-3774,-871,-7613,14807,3071,-1448,1305,7485 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G7 X Mark III", 0, 0, - { 11629, -5713, -914, -2706, 11090, 1842, -206, 1225, 5515 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G7 X Mark II", 0, 0, - { 9602,-3823,-937,-2984,11495,1675,-407,1415,5049 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G7 X", 0, 0, - { 9602,-3823,-937,-2984,11495,1675,-407,1415,5049 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G9 X Mark II", 0, 0, - { 10056,-4131,-944,-2576,11143,1625,-238,1294,5179 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G9 X",0, 0, - { 9602,-3823,-937,-2984,11495,1675,-407,1415,5049 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot G9", 0, 0, - { 7368,-2141,-598,-5621,13254,2625,-1418,1696,5743 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G10", 0, 0, + { 11093,-3906,-1028,-5047,12492,2879,-1003,1750,5561 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G11", 0, 0, + { 12177,-4817,-1069,-1612,9864,2049,-98,850,4471 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G12", 0, 0, + { 13244,-5501,-1248,-1508,9858,1935,-270,1083,4366 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G15", 0, 0, + { 7474,-2301,-567,-4056,11456,2975,-222,716,4181 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G16", 0, 0, + { 8020,-2687,-682,-3704,11879,2052,-965,1921,5556 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G1 X Mark III", 0, 0, + { 8532,-701,-1167,-4095,11879,2508,-797,2424,7010 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G1 X Mark II", 0, 0, + { 7378,-1255,-1043,-4088,12251,2048,-876,1946,5805 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G1 X", 0, 0, + { 7378,-1255,-1043,-4088,12251,2048,-876,1946,5805 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G1", 0, 0, + { -5686,10300,2223,4725,-1157,4383,-6128,10783,6163,-2688,12093,604 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G2", 0, 0, + { 9194,-2787,-1059,-8098,15657,2608,-2610,3064,7867 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G3 X", 0, 0, + { 9701,-3857,-921,-3149,11537,1817,-786,1817,5147 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G3", 0, 0, + { 9326,-2882,-1084,-7940,15447,2677,-2620,3090,7740 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G5 X Mark II",0, 0, + { 11629, -5713, -914, -2706, 11090, 1842, -206, 1225, 5515 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G5 X",0, 0, + { 9602,-3823,-937,-2984,11495,1675,-407,1415,5049 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G5", 0, 0, + { 9869,-2972,-942,-7314,15098,2369,-1898,2536,7282 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G6", 0, 0, + { 9876,-3774,-871,-7613,14807,3071,-1448,1305,7485 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G7 X Mark III", 0, 0, + { 11629, -5713, -914, -2706, 11090, 1842, -206, 1225, 5515 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G7 X Mark II", 0, 0, + { 9602,-3823,-937,-2984,11495,1675,-407,1415,5049 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G7 X", 0, 0, + { 9602,-3823,-937,-2984,11495,1675,-407,1415,5049 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G9 X Mark II", 0, 0, + { 10056,-4131,-944,-2576,11143,1625,-238,1294,5179 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G9 X",0, 0, + { 9602,-3823,-937,-2984,11495,1675,-407,1415,5049 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot G9", 0, 0, + { 7368,-2141,-598,-5621,13254,2625,-1418,1696,5743 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot S2 IS", 0, 0, - { 5477,-1435,-992,-1868,6639,510,-58,792,2670 } }, // CHDK - { LIBRAW_CAMERAMAKER_Canon, "PowerShot S3 IS", 0, 0, - { 14062,-5199,-1446,-4712,12470,2243,-1286,2028,4836 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Canon, "PowerShot S30", 0, 0, - { 10744,-3813,-1142,-7962,15966,2075,-2492,2805,7744 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot S40", 0, 0, - { 8606,-2573,-949,-8237,15489,2974,-2649,3076,9100 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot S45", 0, 0, // + - { 8251,-2410,-964,-8047,15430,2823,-2380,2824,8119 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot S50", 0, 0, - { 8979,-2658,-871,-7721,15500,2357,-1773,2366,6634 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot S60", 0, 0, - { 8794,-2482,-797,-7804,15403,2572,-1422,1996,7083 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot S70", 0, 0, - { 9976,-3810,-832,-7115,14463,2906,-901,989,7889 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot S90", 0, 0, - { 12374,-5016,-1049,-1677,9902,2078,-83,852,4683 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot S95", 0, 0, - { 13440,-5896,-1279,-1236,9598,1931,-180,1001,4651 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot S120", 0, 0, - { 6961,-1685,-695,-4625,12945,1836,-1114,2152,5518 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot S110", 0, 0, - { 8039,-2643,-654,-3783,11230,2930,-206,690,4194 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot S100", 0, 0, - { 7968,-2565,-636,-2873,10697,2513,180,667,4211 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot S2 IS", 0, 0, + { 5477,-1435,-992,-1868,6639,510,-58,792,2670 } }, // CHDK + { LIBRAW_CAMERAMAKER_Canon, "PowerShot S3 IS", 0, 0, + { 14062,-5199,-1446,-4712,12470,2243,-1286,2028,4836 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Canon, "PowerShot S30", 0, 0, + { 10744,-3813,-1142,-7962,15966,2075,-2492,2805,7744 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot S40", 0, 0, + { 8606,-2573,-949,-8237,15489,2974,-2649,3076,9100 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot S45", 0, 0, // + + { 8251,-2410,-964,-8047,15430,2823,-2380,2824,8119 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot S50", 0, 0, + { 8979,-2658,-871,-7721,15500,2357,-1773,2366,6634 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot S60", 0, 0, + { 8794,-2482,-797,-7804,15403,2572,-1422,1996,7083 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot S70", 0, 0, + { 9976,-3810,-832,-7115,14463,2906,-901,989,7889 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot S90", 0, 0, + { 12374,-5016,-1049,-1677,9902,2078,-83,852,4683 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot S95", 0, 0, + { 13440,-5896,-1279,-1236,9598,1931,-180,1001,4651 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot S120", 0, 0, + { 6961,-1685,-695,-4625,12945,1836,-1114,2152,5518 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot S110", 0, 0, + { 8039,-2643,-654,-3783,11230,2930,-206,690,4194 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot S100", 0, 0, + { 7968,-2565,-636,-2873,10697,2513,180,667,4211 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot SD300", 0, 0, - { 6526,-1720,-1075,-1390,5945,602,-90,820,2380 } }, // CHDK + { LIBRAW_CAMERAMAKER_Canon, "PowerShot SD300", 0, 0, + { 6526,-1720,-1075,-1390,5945,602,-90,820,2380 } }, // CHDK - { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX1 IS", 0, 0, - { 6578,-259,-502,-5974,13030,3309,-308,1058,4970 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX20 IS", 0, 0, - { 8275,-2904,-1260,-128,5305,505,51,481,2450 } }, // CHDK - { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX30 IS", 0, 0, - { 13014,-4698,-1026,-2001,9615,2386,-164,1423,3759 } }, // CHDK - { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX40 HS", 0, 0, - { 54480,-17404,-8039,-7505,44044,1136,-580,7158,11891 } }, // CHDK - { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX50 HS", 0, 0, - { 12432,-4753,-1247,-2110,10691,1629,-412,1623,4926 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX60 HS", 0, 0, - { 13161,-5451,-1344,-1989,10654,1531,-47,1271,4955 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX70 HS", 0, 0, - { 18285,-8907,-1951,-1845,10688,1323,364,1101,5139 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX110 IS", 0, 0, - { 14134,-5576,-1527,-1991,10719,1273,-1158,1929,3581 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX120 IS", 0, 0, - { 7286,-2242,-1047,41,4401,457,269,684,1864 } }, // CHDK - { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX220 HS", 0, 0, - { 13898,-5076,-1447,-1405,10109,1297,-244,1860,3687 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX710 HS", 0, 0, - { 13161,-5451,-1344,-1989,10654,1531,-47,1271,4955 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX1 IS", 0, 0, + { 6578,-259,-502,-5974,13030,3309,-308,1058,4970 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX20 IS", 0, 0, + { 8275,-2904,-1260,-128,5305,505,51,481,2450 } }, // CHDK + { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX30 IS", 0, 0, + { 13014,-4698,-1026,-2001,9615,2386,-164,1423,3759 } }, // CHDK + { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX40 HS", 0, 0, + { 54480,-17404,-8039,-7505,44044,1136,-580,7158,11891 } }, // CHDK + { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX50 HS", 0, 0, + { 12432,-4753,-1247,-2110,10691,1629,-412,1623,4926 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX60 HS", 0, 0, + { 13161,-5451,-1344,-1989,10654,1531,-47,1271,4955 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX70 HS", 0, 0, + { 18285,-8907,-1951,-1845,10688,1323,364,1101,5139 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX110 IS", 0, 0, + { 14134,-5576,-1527,-1991,10719,1273,-1158,1929,3581 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX120 IS", 0, 0, + { 7286,-2242,-1047,41,4401,457,269,684,1864 } }, // CHDK + { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX220 HS", 0, 0, + { 13898,-5076,-1447,-1405,10109,1297,-244,1860,3687 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Canon, "PowerShot SX710 HS", 0, 0, + { 13161,-5451,-1344,-1989,10654,1531,-47,1271,4955 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot Pro1", 0, 0, - { 10062,-3522,-1000,-7643,15117,2730,-765,817,7322 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot Pro70", 34, 0, - { -5106,10695,1576,3820,53,4566,-6497,10736,6701,-3336,11887,1394 } }, - { LIBRAW_CAMERAMAKER_Canon, "PowerShot Pro90", 0, 0, - { -5912,10768,2288,4612,-989,4333,-6153,10897,5944,-2907,12288,624 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot Pro1", 0, 0, + { 10062,-3522,-1000,-7643,15117,2730,-765,817,7322 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot Pro70", 34, 0, + { -5106,10695,1576,3820,53,4566,-6497,10736,6701,-3336,11887,1394 } }, + { LIBRAW_CAMERAMAKER_Canon, "PowerShot Pro90", 0, 0, + { -5912,10768,2288,4612,-989,4333,-6153,10897,5944,-2907,12288,624 } }, - { LIBRAW_CAMERAMAKER_Casio, "EX-F1", 0, 0, - { 9084,-2016,-848,-6711,14351,2570,-1059,1725,6135 } }, - { LIBRAW_CAMERAMAKER_Casio, "EX-FH100", 0, 0, - { 12771,-4179,-1558,-2149,10938,1375,-453,1751,4494 } }, - { LIBRAW_CAMERAMAKER_Casio, "EX-S20", 0, 0, - { 11634,-3924,-1128,-4968,12954,2015,-1588,2648,7206 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Casio, "EX-Z750", 0, 0, - { 10819,-3873,-1099,-4903,13730,1175,-1755,3751,4632 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_Casio, "EX-Z10", 128, 0xfff, - { 9790,-3338,-603,-2321,10222,2099,-344,1273,4799 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Casio, "EX-F1", 0, 0, + { 9084,-2016,-848,-6711,14351,2570,-1059,1725,6135 } }, + { LIBRAW_CAMERAMAKER_Casio, "EX-FH100", 0, 0, + { 12771,-4179,-1558,-2149,10938,1375,-453,1751,4494 } }, + { LIBRAW_CAMERAMAKER_Casio, "EX-S20", 0, 0, + { 11634,-3924,-1128,-4968,12954,2015,-1588,2648,7206 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Casio, "EX-Z750", 0, 0, + { 10819,-3873,-1099,-4903,13730,1175,-1755,3751,4632 } }, /* DJC */ + { LIBRAW_CAMERAMAKER_Casio, "EX-Z10", 128, 0xfff, + { 9790,-3338,-603,-2321,10222,2099,-344,1273,4799 } }, /* DJC */ - { LIBRAW_CAMERAMAKER_CINE, "650", 0, 0, - { 3390,480,-500,-800,3610,340,-550,2336,1192 } }, - { LIBRAW_CAMERAMAKER_CINE, "660", 0, 0, - { 3390,480,-500,-800,3610,340,-550,2336,1192 } }, + { LIBRAW_CAMERAMAKER_CINE, "650", 0, 0, + { 3390,480,-500,-800,3610,340,-550,2336,1192 } }, + { LIBRAW_CAMERAMAKER_CINE, "660", 0, 0, + { 3390,480,-500,-800,3610,340,-550,2336,1192 } }, { LIBRAW_CAMERAMAKER_CINE, "", 0, 0, /* empty camera name*/ - { 20183,-4295,-423,-3940,15330,3985,-280,4870,9800 } }, + { 20183,-4295,-423,-3940,15330,3985,-280,4870,9800 } }, - { LIBRAW_CAMERAMAKER_Contax, "N Digital", 0, 0xf1e, - { 7777,1285,-1053,-9280,16543,2916,-3677,5679,7060 } }, + { LIBRAW_CAMERAMAKER_Contax, "N Digital", 0, 0xf1e, + { 7777,1285,-1053,-9280,16543,2916,-3677,5679,7060 } }, - { LIBRAW_CAMERAMAKER_DXO, "ONE", 0, 0, - { 6596,-2079,-562,-4782,13016,1933,-970,1581,5181 } }, + { LIBRAW_CAMERAMAKER_DXO, "ONE", 0, 0, + { 6596,-2079,-562,-4782,13016,1933,-970,1581,5181 } }, - { LIBRAW_CAMERAMAKER_Epson, "R-D1", 0, 0, // same CMs: R-D1, R-D1s, R-D1x - { 6827,-1878,-732,-8429,16012,2564,-704,592,7145 } }, + { LIBRAW_CAMERAMAKER_Epson, "R-D1", 0, 0, // same CMs: R-D1, R-D1s, R-D1x + { 6827,-1878,-732,-8429,16012,2564,-704,592,7145 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "DBP for GX680", -128, 0x0fff, - { 12741,-4916,-1420,-8510,16791,1715,-1767,2302,7771 } }, /* temp, copy from S2Pro */ + { LIBRAW_CAMERAMAKER_Fujifilm, "DBP for GX680", -128, 0x0fff, + { 12741,-4916,-1420,-8510,16791,1715,-1767,2302,7771 } }, /* temp, copy from S2Pro */ - { LIBRAW_CAMERAMAKER_Fujifilm, "E550", 0, 0, - { 11044,-3888,-1120,-7248,15167,2208,-1531,2276,8069 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "E900", 0, 0, - { 9183,-2526,-1078,-7461,15071,2574,-2022,2440,8639 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "F5", 0, 0, // F500EXR/F505EXR; F550EXR - { 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "F6", 0, 0, // F600EXR/F605EXR; F660EXR - { 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "F77", 0, 0xfe9, // F770EXR/F775EXR - { 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "F7", 0, 0, // same CMs: F700, F710EXR - { 10004,-3219,-1201,-7036,15047,2107,-1863,2565,7736 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "F810", 0, 0, - { 11044,-3888,-1120,-7248,15167,2208,-1531,2276,8069 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "F8", 0, 0, // F800EXR - { 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "F900EXR", 0, 0, - { 12085,-4727,-953,-3257,11489,2002,-511,2046,4592 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "E550", 0, 0, + { 11044,-3888,-1120,-7248,15167,2208,-1531,2276,8069 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "E900", 0, 0, + { 9183,-2526,-1078,-7461,15071,2574,-2022,2440,8639 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "F5", 0, 0, // F500EXR/F505EXR; F550EXR + { 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "F6", 0, 0, // F600EXR/F605EXR; F660EXR + { 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "F77", 0, 0xfe9, // F770EXR/F775EXR + { 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "F7", 0, 0, // same CMs: F700, F710EXR + { 10004,-3219,-1201,-7036,15047,2107,-1863,2565,7736 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "F810", 0, 0, + { 11044,-3888,-1120,-7248,15167,2208,-1531,2276,8069 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "F8", 0, 0, // F800EXR + { 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "F900EXR", 0, 0, + { 12085,-4727,-953,-3257,11489,2002,-511,2046,4592 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "GFX 100", 0, 0, // same CMs: "GFX 100", "GFX 100S"/"GFX100S", "GFX 100 IR" - { 16212,-8423,-1583,-4336,12583,1937,-195,726,6199 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "GFX 50", 0, 0, // same CMs: "GFX 50S", "GFX 50R", "GFX 50S II" - { 11756,-4754,-874,-3056,11045,2305,-381,1457,6006 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "GFX 100 II", 0, 0, + { 12806,-5779,-1110,-3546,11507,2318,-177,996,5715 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "GFX 100", 0, 0, // same CMs: "GFX 100", "GFX 100S"/"GFX100S", "GFX 100 IR" + { 16212,-8423,-1583,-4336,12583,1937,-195,726,6199 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "GFX 50", 0, 0, // same CMs: "GFX 50S", "GFX 50R", "GFX 50S II" + { 11756,-4754,-874,-3056,11045,2305,-381,1457,6006 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "HS10", 0, 0xf68, - { 12440,-3954,-1183,-1123,9674,1708,-83,1614,4086 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "HS2", 0, 0, // HS20EXR/HS22EXR - { 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "HS3", 0, 0, // HS30EXR/HS33EXR/HS35EXR - { 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "HS50EXR", 0, 0, - { 12085,-4727,-953,-3257,11489,2002,-511,2046,4592 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "HS10", 0, 0xf68, + { 12440,-3954,-1183,-1123,9674,1708,-83,1614,4086 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "HS2", 0, 0, // HS20EXR/HS22EXR + { 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "HS3", 0, 0, // HS30EXR/HS33EXR/HS35EXR + { 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "HS50EXR", 0, 0, + { 12085,-4727,-953,-3257,11489,2002,-511,2046,4592 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "IS-1", 0, 0, - { 21461,-10807,-1441,-2332,10599,1999,289,875,7703 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "IS Pro", 0, 0, - { 12300,-5110,-1304,-9117,17143,1998,-1947,2448,8100 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "IS-1", 0, 0, + { 21461,-10807,-1441,-2332,10599,1999,289,875,7703 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "IS Pro", 0, 0, + { 12300,-5110,-1304,-9117,17143,1998,-1947,2448,8100 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "S5000", 0, 0, - { 8754,-2732,-1019,-7204,15069,2276,-1702,2334,6982 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "S5100", 0, 0, - { 11940,-4431,-1255,-6766,14428,2542,-993,1165,7421 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "S5200", 0, 0, // S5200/S5600 - { 9636,-2804,-988,-7442,15040,2589,-1803,2311,8621 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "S6", 0, 0, // S6000fd/S6500fd - { 12628,-4887,-1401,-6861,14996,1962,-2198,2782,7091 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "S7000", 0, 0, - { 10190,-3506,-1312,-7153,15051,2238,-2003,2399,7505 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "S9000", 0, 0, // S9000/S9500 - { 10491,-3423,-1145,-7385,15027,2538,-1809,2275,8692 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "S9100", 0, 0, // S9100/S9600 - { 12343,-4515,-1285,-7165,14899,2435,-1895,2496,8800 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "S5000", 0, 0, + { 8754,-2732,-1019,-7204,15069,2276,-1702,2334,6982 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "S5100", 0, 0, + { 11940,-4431,-1255,-6766,14428,2542,-993,1165,7421 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "S5200", 0, 0, // S5200/S5600 + { 9636,-2804,-988,-7442,15040,2589,-1803,2311,8621 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "S6", 0, 0, // S6000fd/S6500fd + { 12628,-4887,-1401,-6861,14996,1962,-2198,2782,7091 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "S7000", 0, 0, + { 10190,-3506,-1312,-7153,15051,2238,-2003,2399,7505 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "S9000", 0, 0, // S9000/S9500 + { 10491,-3423,-1145,-7385,15027,2538,-1809,2275,8692 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "S9100", 0, 0, // S9100/S9600 + { 12343,-4515,-1285,-7165,14899,2435,-1895,2496,8800 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "S100FS", -514, 0, - { 11521,-4355,-1065,-6524,13767,3058,-1466,1984,6045 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "S100FS", -514, 0, + { 11521,-4355,-1065,-6524,13767,3058,-1466,1984,6045 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "S20Pro", 0, 0, - { 10004,-3219,-1201,-7036,15047,2107,-1863,2565,7736 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "S20", -512, 0x3fff, // S200EXR/S205EXR - { 11401,-4498,-1312,-5088,12751,2613,-838,1568,5941 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "S20Pro", 0, 0, + { 10004,-3219,-1201,-7036,15047,2107,-1863,2565,7736 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "S20", -512, 0x3fff, // S200EXR/S205EXR + { 11401,-4498,-1312,-5088,12751,2613,-838,1568,5941 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "SL1000", 0, 0, - { 11705,-4262,-1107,-2282,10791,1709,-555,1713,4945 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "SL1000", 0, 0, + { 11705,-4262,-1107,-2282,10791,1709,-555,1713,4945 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "S1", 0, 0, - { 12297,-4882,-1202,-2106,10691,1623,-88,1312,4790 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "S2Pro", -128, 0, - { 12741,-4916,-1420,-8510,16791,1715,-1767,2302,7771 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "S3Pro", 0, 0, - { 11807,-4612,-1294,-8927,16968,1988,-2120,2741,8006 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "S5Pro", 0, 0, - { 12300,-5110,-1304,-9117,17143,1998,-1947,2448,8100 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "S1", 0, 0, + { 12297,-4882,-1202,-2106,10691,1623,-88,1312,4790 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "S2Pro", -128, 0, + { 12741,-4916,-1420,-8510,16791,1715,-1767,2302,7771 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "S3Pro", 0, 0, + { 11807,-4612,-1294,-8927,16968,1988,-2120,2741,8006 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "S5Pro", 0, 0, + { 12300,-5110,-1304,-9117,17143,1998,-1947,2448,8100 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X100F", 0, 0, - { 11434,-4948,-1210,-3746,12042,1903,-666,1479,5235 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X100S", 0, 0, - { 10592,-4262,-1008,-3514,11355,2465,-870,2025,6386 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X100T", 0, 0, - { 10592,-4262,-1008,-3514,11355,2465,-870,2025,6386 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X100V", 0, 0, - { 13426,-6334,-1177,-4244,12136,2371,580,1303,5980 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X100", 0, 0, - { 12161,-4457,-1069,-5034,12874,2400,-795,1724,6904 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X100F", 0, 0, + { 11434,-4948,-1210,-3746,12042,1903,-666,1479,5235 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X100S", 0, 0, + { 10592,-4262,-1008,-3514,11355,2465,-870,2025,6386 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X100T", 0, 0, + { 10592,-4262,-1008,-3514,11355,2465,-870,2025,6386 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X100V", 0, 0, + { 13426,-6334,-1177,-4244,12136,2371,580,1303,5980 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X100", 0, 0, + { 12161,-4457,-1069,-5034,12874,2400,-795,1724,6904 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X10", 0, 0, - { 13509,-6199,-1254,-4430,12733,1865,-331,1441,5022 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X20", 0, 0, - { 11768,-4971,-1133,-4904,12927,2183,-480,1723,4605 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X30", 0, 0, - { 12328,-5256,-1144,-4469,12927,1675,-87,1291,4351 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X70", 0, 0, - { 10450,-4329,-878,-3217,11105,2421,-752,1758,6519 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X10", 0, 0, + { 13509,-6199,-1254,-4430,12733,1865,-331,1441,5022 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X20", 0, 0, + { 11768,-4971,-1133,-4904,12927,2183,-480,1723,4605 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X30", 0, 0, + { 12328,-5256,-1144,-4469,12927,1675,-87,1291,4351 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X70", 0, 0, + { 10450,-4329,-878,-3217,11105,2421,-752,1758,6519 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "XF10", 0, 0, - { 11673,-4760,-1041,-3988,12058,2166,-771,1417,5569 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "XF1", 0, 0, - { 13509,-6199,-1254,-4430,12733,1865,-331,1441,5022 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "XF10", 0, 0, + { 11673,-4760,-1041,-3988,12058,2166,-771,1417,5569 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "XF1", 0, 0, + { 13509,-6199,-1254,-4430,12733,1865,-331,1441,5022 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "XQ", 0, 0, // same CMs: XQ1, XQ2 - { 9252,-2704,-1064,-5893,14265,1717,-1101,2341,4349 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "XQ", 0, 0, // same CMs: XQ1, XQ2 + { 9252,-2704,-1064,-5893,14265,1717,-1101,2341,4349 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-Pro1", 0, 0, - { 10413,-3996,-993,-3721,11640,2361,-733,1540,6011 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-Pro2", 0, 0, - { 11434,-4948,-1210,-3746,12042,1903,-666,1479,5235 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-Pro3", 0, 0, - { 13426,-6334,-1177,-4244,12136,2371,580,1303,5980 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-Pro1", 0, 0, + { 10413,-3996,-993,-3721,11640,2361,-733,1540,6011 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-Pro2", 0, 0, + { 11434,-4948,-1210,-3746,12042,1903,-666,1479,5235 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-Pro3", 0, 0, + { 13426,-6334,-1177,-4244,12136,2371,580,1303,5980 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-A10", 0, 0, - { 11540,-4999,-991,-2949,10963,2278,-382,1049,5605} }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-A20", 0, 0, - { 11540,-4999,-991,-2949,10963,2278,-382,1049,5605} }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-A1", 0, 0, - { 11086,-4555,-839,-3512,11310,2517,-815,1341,5940 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-A2", 0, 0, - { 10763,-4560,-917,-3346,11311,2322,-475,1135,5843 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-A3", 0, 0, - { 12407,-5222,-1086,-2971,11116,2120,-294,1029,5284 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-A5", 0, 0, - { 11673,-4760,-1041,-3988,12058,2166,-771,1417,5569 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-A7", 0, 0, - { 15055,-7391,-1274,-4062,12071,2238,-610,1217,6147 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-E1", 0, 0, - { 10413,-3996,-993,-3721,11640,2361,-733,1540,6011 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-E2S", 0, 0, - { 11562,-5118,-961,-3022,11007,2311,-525,1569,6097 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-E2", 0, 0, - { 8458,-2451,-855,-4597,12447,2407,-1475,2482,6526 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-E3", 0, 0, - { 11434,-4948,-1210,-3746,12042,1903,-666,1479,5235 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-E4", 0, 0, - { 13426, -6334, -1177, -4244, 12136, 2371, -580, 1303, 5980 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-H1", 0, 0, - { 11434,-4948,-1210,-3746,12042,1903,-666,1479,5235 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-A10", 0, 0, + { 11540,-4999,-991,-2949,10963,2278,-382,1049,5605} }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-A20", 0, 0, + { 11540,-4999,-991,-2949,10963,2278,-382,1049,5605} }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-A1", 0, 0, + { 11086,-4555,-839,-3512,11310,2517,-815,1341,5940 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-A2", 0, 0, + { 10763,-4560,-917,-3346,11311,2322,-475,1135,5843 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-A3", 0, 0, + { 12407,-5222,-1086,-2971,11116,2120,-294,1029,5284 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-A5", 0, 0, + { 11673,-4760,-1041,-3988,12058,2166,-771,1417,5569 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-A7", 0, 0, + { 15055,-7391,-1274,-4062,12071,2238,-610,1217,6147 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-E1", 0, 0, + { 10413,-3996,-993,-3721,11640,2361,-733,1540,6011 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-E2S", 0, 0, + { 11562,-5118,-961,-3022,11007,2311,-525,1569,6097 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-E2", 0, 0, + { 8458,-2451,-855,-4597,12447,2407,-1475,2482,6526 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-E3", 0, 0, + { 11434,-4948,-1210,-3746,12042,1903,-666,1479,5235 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-E4", 0, 0, + { 13426, -6334, -1177, -4244, 12136, 2371, -580, 1303, 5980 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-H1", 0, 0, + { 11434,-4948,-1210,-3746,12042,1903,-666,1479,5235 } }, { LIBRAW_CAMERAMAKER_Fujifilm, "X-H2S", 0, 0, + { 12836, -5909, -1032, -3087, 11132, 2236, -35, 872, 5330 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-H2", 0, 0, + { 11809, -5358, -1141, -4248, 12164, 2343, -514, 1097, 5848 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-M1", 0, 0, + { 10413,-3996,-993,-3721,11640,2361,-733,1540,6011 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-S20", 0, 0, { 12836, -5909, -1032, -3087, 11132, 2236, -35, 872, 5330 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-M1", 0, 0, - { 10413,-3996,-993,-3721,11640,2361,-733,1540,6011 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-S10", 0, 0, - { 13426,-6334,-1177,-4244,12136,2371,-580,1303,5980 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-S1", 0, 0, - { 13509,-6199,-1254,-4430,12733,1865,-331,1441,5022 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-S10", 0, 0, + { 13426,-6334,-1177,-4244,12136,2371,-580,1303,5980 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-S1", 0, 0, + { 13509,-6199,-1254,-4430,12733,1865,-331,1441,5022 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-T100", 0, 0, - { 11673,-4760,-1041,-3988,12058,2166,-771,1417,5569 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-T1", 0, 0, /* same CMs: X-T1, "X-T1IR", "X-T1 IR", X-T10 */ - { 8458,-2451,-855,-4597,12447,2407,-1475,2482,6526 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-T200", 0, 0, - { 15055,-7391,-1274,-4062,12071,2238,-610,1217,6147 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-T2", 0, 0, // same CMs: X-T2, X-T20 - { 11434,-4948,-1210,-3746,12042,1903,-666,1479,5235 } }, - { LIBRAW_CAMERAMAKER_Fujifilm, "X-T3", 0, 0, // same CMs: X-T3, X-T30, "X-T30 II" - { 13426,-6334,-1177,-4244,12136,2371,580,1303,5980 } }, // v.2 - { LIBRAW_CAMERAMAKER_Fujifilm, "X-T4", 0, 0, - { 13426,-6334,-1177,-4244,12136,2371,580,1303,5980 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-T100", 0, 0, + { 11673,-4760,-1041,-3988,12058,2166,-771,1417,5569 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-T1", 0, 0, /* same CMs: X-T1, "X-T1IR", "X-T1 IR", X-T10 */ + { 8458,-2451,-855,-4597,12447,2407,-1475,2482,6526 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-T200", 0, 0, + { 15055,-7391,-1274,-4062,12071,2238,-610,1217,6147 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-T2", 0, 0, // same CMs: X-T2, X-T20 + { 11434,-4948,-1210,-3746,12042,1903,-666,1479,5235 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-T3", 0, 0, // same CMs: X-T3, X-T30, "X-T30 II" + { 13426,-6334,-1177,-4244,12136,2371,580,1303,5980 } }, // v.2 + { LIBRAW_CAMERAMAKER_Fujifilm, "X-T4", 0, 0, + { 13426,-6334,-1177,-4244,12136,2371,580,1303,5980 } }, + { LIBRAW_CAMERAMAKER_Fujifilm, "X-T5", 0, 0, + { 11809, -5358, -1141, -4248, 12164, 2343, -514, 1097, 5848 } }, - { LIBRAW_CAMERAMAKER_GITUP, "G3DUO", 130, 62000, - { 8489,-2583,-1036,-8051,15583,2643,-1307,1407,7354 } }, + { LIBRAW_CAMERAMAKER_GITUP, "G3DUO", 130, 62000, + { 8489,-2583,-1036,-8051,15583,2643,-1307,1407,7354 } }, - { LIBRAW_CAMERAMAKER_GITUP, "GIT2P", 4160, 0, - { 8489,-2583,-1036,-8051,15583,2643,-1307,1407,7354 } }, - { LIBRAW_CAMERAMAKER_GITUP, "GIT2", 3200, 0, - { 8489,-2583,-1036,-8051,15583,2643,-1307,1407,7354 } }, + { LIBRAW_CAMERAMAKER_GITUP, "GIT2P", 4160, 0, + { 8489,-2583,-1036,-8051,15583,2643,-1307,1407,7354 } }, + { LIBRAW_CAMERAMAKER_GITUP, "GIT2", 3200, 0, + { 8489,-2583,-1036,-8051,15583,2643,-1307,1407,7354 } }, - { LIBRAW_CAMERAMAKER_GoPro, "HERO5 Black", 0, 0, - { 10344,-4210,-620,-2315,10625,1948,93,1058,5541 } }, + { LIBRAW_CAMERAMAKER_GoPro, "HERO5 Black", 0, 0, + { 10344,-4210,-620,-2315,10625,1948,93,1058,5541 } }, - {LIBRAW_CAMERAMAKER_Hasselblad, "L1D-20c", 0, 0, - { 7310, -2746, -646, -2991, 10847, 2469, 163, 585, 6324}}, + {LIBRAW_CAMERAMAKER_Hasselblad, "L1D-20c", 0, 0, + { 7310, -2746, -646, -2991, 10847, 2469, 163, 585, 6324}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "16-Uncoated-3FR", 0, 0, - { 8519, -3260, -280, -5081, 13459, 1738, -1449, 2960, 7809}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "16-Uncoated-FFF", 0, 0, - { 8068, -2959, -108, -5788, 13608, 2389, -1002, 2237, 8162}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "16-Uncoated", 0, 0, - { 8519, -3260, -280, -5081, 13459, 1738, -1449, 2960, 7809}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "16-Uncoated-3FR", 0, 0, + { 8519, -3260, -280, -5081, 13459, 1738, -1449, 2960, 7809}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "16-Uncoated-FFF", 0, 0, + { 8068, -2959, -108, -5788, 13608, 2389, -1002, 2237, 8162}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "16-Uncoated", 0, 0, + { 8519, -3260, -280, -5081, 13459, 1738, -1449, 2960, 7809}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "22-Uncoated-3FR", 0, 0, - { 8523, -3257, -280, -5078, 13458, 1743, -1449, 2961, 7809}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "22-Uncoated-FFF", 0, 0, - { 8068, -2959, -108, -5788, 13608, 2389, -1002, 2237, 8162}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "22-Uncoated", 0, 0, - { 8519, -3260, -280, -5081, 13459, 1738, -1449, 2960, 7809}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "22-Uncoated-3FR", 0, 0, + { 8523, -3257, -280, -5078, 13458, 1743, -1449, 2961, 7809}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "22-Uncoated-FFF", 0, 0, + { 8068, -2959, -108, -5788, 13608, 2389, -1002, 2237, 8162}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "22-Uncoated", 0, 0, + { 8519, -3260, -280, -5081, 13459, 1738, -1449, 2960, 7809}}, - {LIBRAW_CAMERAMAKER_Hasselblad, "31-Uncoated-FFF", 0, 0, - { 5155, -1201, 200, -5841, 13197, 2950, -1101, 2317, 6988}}, - {LIBRAW_CAMERAMAKER_Hasselblad, "31-Uncoated", 0, 0, - { 5458, -1448, 145, -4479, 12338, 2401, -1659, 3086, 6710}}, + {LIBRAW_CAMERAMAKER_Hasselblad, "31-Uncoated-FFF", 0, 0, + { 5155, -1201, 200, -5841, 13197, 2950, -1101, 2317, 6988}}, + {LIBRAW_CAMERAMAKER_Hasselblad, "31-Uncoated", 0, 0, + { 5458, -1448, 145, -4479, 12338, 2401, -1659, 3086, 6710}}, - {LIBRAW_CAMERAMAKER_Hasselblad, "39-Uncoated-3FR", 0, 0, - { 3904, -100, 262, -4318, 12407, 2128, -1598, 3594, 6233}}, - {LIBRAW_CAMERAMAKER_Hasselblad, "39-Uncoated-FFF", 0, 0, - { 4739, -932, 295, -4829, 12220, 2952, -1027, 2341, 7083}}, - {LIBRAW_CAMERAMAKER_Hasselblad, "39-Uncoated", 0, 0, - { 3894, -110, 287, -4672, 12610, 2295, -2092, 4100, 6196}}, + {LIBRAW_CAMERAMAKER_Hasselblad, "39-Uncoated-3FR", 0, 0, + { 3904, -100, 262, -4318, 12407, 2128, -1598, 3594, 6233}}, + {LIBRAW_CAMERAMAKER_Hasselblad, "39-Uncoated-FFF", 0, 0, + { 4739, -932, 295, -4829, 12220, 2952, -1027, 2341, 7083}}, + {LIBRAW_CAMERAMAKER_Hasselblad, "39-Uncoated", 0, 0, + { 3894, -110, 287, -4672, 12610, 2295, -2092, 4100, 6196}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "39-Coated-3FR", 0, 0, - { 5427, -1147, 173, -3834, 12073, 1969, -1444, 3320, 5621}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "39-Coated-FFF", 0, 0, - { 5323, -1233, 399, -4926, 12362, 2894, -856, 2471, 5961}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "39-Coated", 0, 0, - { 3857, 452, -46, -6008, 14477, 1596, -2627, 4481, 5718}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "39-Coated-3FR", 0, 0, + { 5427, -1147, 173, -3834, 12073, 1969, -1444, 3320, 5621}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "39-Coated-FFF", 0, 0, + { 5323, -1233, 399, -4926, 12362, 2894, -856, 2471, 5961}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "39-Coated", 0, 0, + { 3857, 452, -46, -6008, 14477, 1596, -2627, 4481, 5718}}, - {LIBRAW_CAMERAMAKER_Hasselblad, "40-Coated5-3FR", 0, 0, - { 7014, -2067, -540, -4821, 13016, 1980, -1663, 3089, 6940}}, - {LIBRAW_CAMERAMAKER_Hasselblad, "40-Coated5-FFF", 0, 0, - { 5963, -1357, -172, -5439, 12762, 3007, -964, 2222, 7172}}, - {LIBRAW_CAMERAMAKER_Hasselblad, "40-Coated5", 0, 0, - { 6159, -1402, -177, -5439, 12762, 3007, -955, 2200, 7104}}, + {LIBRAW_CAMERAMAKER_Hasselblad, "40-Coated5-3FR", 0, 0, + { 7014, -2067, -540, -4821, 13016, 1980, -1663, 3089, 6940}}, + {LIBRAW_CAMERAMAKER_Hasselblad, "40-Coated5-FFF", 0, 0, + { 5963, -1357, -172, -5439, 12762, 3007, -964, 2222, 7172}}, + {LIBRAW_CAMERAMAKER_Hasselblad, "40-Coated5", 0, 0, + { 6159, -1402, -177, -5439, 12762, 3007, -955, 2200, 7104}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "40-Coated-3FR", 0, 0, - { 6550, -1681, -399, -4626, 12598, 2257, -1807, 3354, 6486}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "40-Coated-FFF", 0, 0, - { 6041, -1375, -174, -5439, 10000, 3007, -930, 2145, 6923}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "40-Coated", 0, 0, - { 6159, -1402, -177, -5439, 12762, 3007, -955, 2200, 7104}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "40-Coated-3FR", 0, 0, + { 6550, -1681, -399, -4626, 12598, 2257, -1807, 3354, 6486}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "40-Coated-FFF", 0, 0, + { 6041, -1375, -174, -5439, 10000, 3007, -930, 2145, 6923}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "40-Coated", 0, 0, + { 6159, -1402, -177, -5439, 12762, 3007, -955, 2200, 7104}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "50-Coated5-3FR", 0, 0, - { 5707, -693, -382, -4285, 12669, 1773, -1615, 3519, 5410}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "50-Coated5-FFF", 0, 0, - { 5263, -612, 39, -4950, 12426, 2843, -935, 2423, 5941}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "50-Coated5", 0, 0, - { 5656, -659, -346, -3923, 12306, 1791, -1602, 3509, 5442}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "50-Coated5-3FR", 0, 0, + { 5707, -693, -382, -4285, 12669, 1773, -1615, 3519, 5410}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "50-Coated5-FFF", 0, 0, + { 5263, -612, 39, -4950, 12426, 2843, -935, 2423, 5941}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "50-Coated5", 0, 0, + { 5656, -659, -346, -3923, 12306, 1791, -1602, 3509, 5442}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "50-Coated-3FR", 0, 0, - { 5656, -659, -346, -3923, 12305, 1790, -1602, 3509, 5442}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "50-Coated-FFF", 0, 0, - { 5280, -614, 39, -4950, 12426, 2843, -939, 2434, 5968}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "50-Coated", 0, 0, - { 5656, -659, -346, -3923, 12306, 1791, -1602, 3509, 5442}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "50-Coated-3FR", 0, 0, + { 5656, -659, -346, -3923, 12305, 1790, -1602, 3509, 5442}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "50-Coated-FFF", 0, 0, + { 5280, -614, 39, -4950, 12426, 2843, -939, 2434, 5968}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "50-Coated", 0, 0, + { 5656, -659, -346, -3923, 12306, 1791, -1602, 3509, 5442}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "50-15-Coated5-II-3FR", 0, 0, - { 10887, -6152, 1034, -3564, 12412, 4224, 63, 626, 10123}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "50-15-Coated5-II-FFF", 0, 0, - { 4932, -835, 141, -4878, 11868, 3437, -1138, 1961, 7067}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "50-15-Coated5-II", 0, 0, - { 8737, -4937, 830, -2860, 9961, 3390, 51, 502, 8124}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "50-15-Coated5-II-3FR", 0, 0, + { 10887, -6152, 1034, -3564, 12412, 4224, 63, 626, 10123}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "50-15-Coated5-II-FFF", 0, 0, + { 4932, -835, 141, -4878, 11868, 3437, -1138, 1961, 7067}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "50-15-Coated5-II", 0, 0, + { 8737, -4937, 830, -2860, 9961, 3390, 51, 502, 8124}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "50-15-Coated5", 0, 0, - { 4932,-835,141,-4878,11868,3437,-1138,1961,7067 } }, + { LIBRAW_CAMERAMAKER_Hasselblad, "50-15-Coated5", 0, 0, + { 4932,-835,141,-4878,11868,3437,-1138,1961,7067 } }, - { LIBRAW_CAMERAMAKER_Hasselblad, "60-Coated-3FR", 0, 0, - { 9296, 336, -1088, -6442, 14323, 2289, -1433, 2942, 5756}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "60-Coated", 0, 0, - { 9662, -684, -279, -4903, 12293, 2950, -344, 1669, 6024}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "60-Coated-3FR", 0, 0, + { 9296, 336, -1088, -6442, 14323, 2289, -1433, 2942, 5756}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "60-Coated", 0, 0, + { 9662, -684, -279, -4903, 12293, 2950, -344, 1669, 6024}}, - { LIBRAW_CAMERAMAKER_Hasselblad, "100-17-Coated5", 0, 0, - { 5110, -1357, -308, -5573, 12835, 3077, -1279, 2025, 7010}}, + { LIBRAW_CAMERAMAKER_Hasselblad, "100-17-Coated5", 0, 0, + { 5110, -1357, -308, -5573, 12835, 3077, -1279, 2025, 7010}}, - { LIBRAW_CAMERAMAKER_HTC, "One A9", 64, 1023, + { LIBRAW_CAMERAMAKER_Hasselblad, "100-20-Coated6", 0, 0, + { 6468,-1899,-545,-4526,12267,2542,-388,1276,6096 } }, + + { LIBRAW_CAMERAMAKER_HTC, "One A9", 64, 1023, { 101,-20,-2,-11,145,41,-24,1,56 } }, /* this is FM1 transposed */ { LIBRAW_CAMERAMAKER_Imacon, "Ixpress", 0, 0, @@ -994,6 +1015,8 @@ int LibRaw::adobe_coeff(unsigned make_idx, const char *t_model, { LIBRAW_CAMERAMAKER_Nikon, "Df", 0, 0, { 8598,-2848,-857,-5618,13606,2195,-1002,1773,7137 } }, + { LIBRAW_CAMERAMAKER_Nikon, "Z 30", 0, 0, + { 10339,-3822,-890,-4183,12023,2436,-671,1638,7049 } }, { LIBRAW_CAMERAMAKER_Nikon, "Z 50", 0, 0, { 11640,-4829,-1079,-5107,13006,2325,-972,1711,7380 } }, { LIBRAW_CAMERAMAKER_Nikon, "Z 5", 0, 0, @@ -1002,7 +1025,9 @@ int LibRaw::adobe_coeff(unsigned make_idx, const char *t_model, { 9943,-3269,-839,-5323,13269,2259,-1198,2083,7557 } }, // 'Z 6'(v.2), 'Z 6_2' { LIBRAW_CAMERAMAKER_Nikon, "Z 7", 0, 0, { 13705,-6004,-1400,-5464,13568,2062,-940,1706,7618 } }, // 'Z 7'(v.2), 'Z 7_2' - { LIBRAW_CAMERAMAKER_Nikon, "Z 9", 0, 0, + { LIBRAW_CAMERAMAKER_Nikon, "Z 8", 0, 0, + {11423,-4564,-1123,-4816,12895,2119,-210,1061,7282 } }, + { LIBRAW_CAMERAMAKER_Nikon, "Z 9", 0, 0, { 13389,-6049,-1441,-4544,12757,1969,229,498,7390 } }, { LIBRAW_CAMERAMAKER_Nikon, "Z fc", 0, 0, { 11640,-4829,-1079,-5107,13006,2325,-972,1711,7380 } }, @@ -1156,6 +1181,9 @@ int LibRaw::adobe_coeff(unsigned make_idx, const char *t_model, { LIBRAW_CAMERAMAKER_Olympus, "OM-1", 0, 0, { 9488, -3984, -714, -2887, 10945, 2229, -137, 960, 5786 } }, + { LIBRAW_CAMERAMAKER_Olympus, "OM-5", 0, 0, + { 11896, -5110, -1076, -3181, 11378, 2048, -519, 1224, 5166 } }, + { LIBRAW_CAMERAMAKER_OmniVison, "", 16, 0x3ff, { 12782,-4059,-379,-478,9066,1413,1340,1513,5176 } }, /* DJC */ @@ -1240,6 +1268,8 @@ int LibRaw::adobe_coeff(unsigned make_idx, const char *t_model, { 9397,-3719,-805,-5425,13326,2309,-972,1715,6034 } }, {LIBRAW_CAMERAMAKER_Panasonic, "DC-S1", 0, 0, { 9744,-3905,-779,-4899,12807,2324,-798,1630,5827 } }, + { LIBRAW_CAMERAMAKER_Panasonic, "DC-S5M2", 0, 0, + { 10308, -4206, -783, -4088, 12102, 2229, -125, 1051, 5912 } }, {LIBRAW_CAMERAMAKER_Panasonic, "DC-S5", 0, 0, { 9744,-3905,-779,-4899,12807,2324,-798,1630,5827 } }, @@ -1335,6 +1365,10 @@ int LibRaw::adobe_coeff(unsigned make_idx, const char *t_model, { 7610,-2780,-576,-4614,12195,2733,-1375,2393,6490 } }, { LIBRAW_CAMERAMAKER_Panasonic, "DMC-G8", -15, 0xfff, { 7610,-2780,-576,-4614,12195,2733,-1375,2393,6490 } }, + + {LIBRAW_CAMERAMAKER_Panasonic, "DC-G9M2", 0, 0, + {8325,-3456,-623,-4330,12089,2528,-860,2646,5984}}, + { LIBRAW_CAMERAMAKER_Panasonic, "DC-G9", -15, 0, { 7685,-2375,-634,-3687,11700,2249,-748,1546,5111 } }, @@ -1352,6 +1386,8 @@ int LibRaw::adobe_coeff(unsigned make_idx, const char *t_model, { 9300, -3659, -755, -2981, 10988, 2287, -190, 1077, 5016 } }, { LIBRAW_CAMERAMAKER_Panasonic, "DC-GH5", -15, 0, { 7641,-2336,-605,-3218,11299,2187,-485,1338,5121 } }, + { LIBRAW_CAMERAMAKER_Panasonic, "DC-GH6", -2048, 0, + { 7949,-3491,-710,-3435,11681,1977,-503,1622,5065} }, { LIBRAW_CAMERAMAKER_Panasonic, "DMC-GM1", -15, 0, { 6770,-1895,-744,-5232,13145,2303,-1664,2691,5703 } }, @@ -1612,10 +1648,12 @@ int LibRaw::adobe_coeff(unsigned make_idx, const char *t_model, { LIBRAW_CAMERAMAKER_Sony, "DSC-HX9", -800, 0, // same CMs: DSC-HX95, DSC-HX99 { 13076,-5686,-1481,-4027,12851,1251,-167,725,4937 } }, - { LIBRAW_CAMERAMAKER_Sony, "ZV-1", -800, 0, + { LIBRAW_CAMERAMAKER_Sony, "ZV-1", -800, 0, // same CMs: ZV-1, ZV-1B, ZV-1M2 { 8280,-2987,-703,-3531,11645,2133,-550,1542,5312 } }, { LIBRAW_CAMERAMAKER_Sony, "ZV-E10", 0, 0, { 6355,-2067,-490,-3653,11542,2400,-406,1258,5506 } }, + { LIBRAW_CAMERAMAKER_Sony, "ZV-E1", 0, 0, + { 6912,-2127,-469,-4470,12175,2587,-398,1478,6492 } }, { LIBRAW_CAMERAMAKER_Sony, "DSC-RX100M7", -800, 0, {10315, -4390, -937, -4859, 12734, 2365, -734, 1537, 5997 } }, @@ -1677,6 +1715,9 @@ int LibRaw::adobe_coeff(unsigned make_idx, const char *t_model, { LIBRAW_CAMERAMAKER_Sony, "ILCE-1", 0, 0, { 8161, -2947, -739, -4811, 12668, 2389, -437, 1229, 6524}}, + + { LIBRAW_CAMERAMAKER_Sony, "ILCE-7RM5", 0, 0, + { 8200, -2976, -719, -4296, 12053, 2532, -429, 1282, 5774 } }, { LIBRAW_CAMERAMAKER_Sony, "ILCE-7RM4", 0, 0, // same CMs: ILCE-7RM4, ILCE-7RM4A { 7662, -2686,-660,-5240, 12965,2530, -796, 1508, 6167 } }, { LIBRAW_CAMERAMAKER_Sony, "ILCE-7RM3", 0, 0, // same CMs: ILCE-7RM3, ILCE-7RM3A @@ -1691,6 +1732,11 @@ int LibRaw::adobe_coeff(unsigned make_idx, const char *t_model, { LIBRAW_CAMERAMAKER_Sony, "ILCE-7S", 0, 0, // same CMs: ILCE-7S, ILCE-7SM2 { 5838,-1430,-246,-3497,11477,2297,-748,1885,5778 } }, + { LIBRAW_CAMERAMAKER_Sony, "ILCE-7CR", 0, 0, + { 8200,-2976,-719,-4296,12053,2532,-429,1282,5774 } }, // temp + + { LIBRAW_CAMERAMAKER_Sony, "ILCE-7CM2", 0, 0, + { 7460,-2365,-588,-5687,13442,2474,-624,1156,6584 } }, // temp { LIBRAW_CAMERAMAKER_Sony, "ILCE-7C", 0, 0, { 7374,-2389,-551,-5435,13162,2519,-1006,1795,6552 } }, @@ -1714,9 +1760,14 @@ int LibRaw::adobe_coeff(unsigned make_idx, const char *t_model, { 5973,-1695,-419,-3826,11797,2293,-639,1398,5789 } }, { LIBRAW_CAMERAMAKER_Sony, "ILCE-6600", 0, 0, { 7657,-2847,-607,-4083,11966,2389,-684,1418,5844 } }, + { LIBRAW_CAMERAMAKER_Sony, "ILCE-6700", 0, 0, + { 6972,-2408,-600,-4330,12101,2515,-388,1277,5847 } }, + { LIBRAW_CAMERAMAKER_Sony, "ILCE", 0, 0, // same CMs: ILCE-3000, ILCE-5000, ILCE-5100, ILCE-6000, ILCE-QX1 { 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } }, + { LIBRAW_CAMERAMAKER_Sony, "ILME-FX30", 0, 0, + { 6972, -2408, -600, -4330, 12101, 2515, -388, 1277, 5847 } }, { LIBRAW_CAMERAMAKER_Sony, "ILME-FX3", 0, 0, { 6912, -2127, -469, -4470, 12175, 2587, -398, 1478, 6492 } }, diff --git a/src/tables/wblists.cpp b/src/tables/wblists.cpp index 1f8ae172b..53206047f 100644 --- a/src/tables/wblists.cpp +++ b/src/tables/wblists.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify it under the terms of the one of two licenses as you choose: diff --git a/src/utils/curves.cpp b/src/utils/curves.cpp index b14f19b79..58a1436f4 100644 --- a/src/utils/curves.cpp +++ b/src/utils/curves.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. @@ -38,7 +38,7 @@ void LibRaw::cubic_spline(const int *x_, const int *y_, const int len) for (i = len - 1; i > 0; i--) { float _div = x[i] - x[i - 1]; - if (fabs(_div) < 1.0e-15) + if (fabsf(_div) < 1.0e-15f) _div = 1; b[i] = (y[i] - y[i - 1]) / _div; d[i - 1] = _div; diff --git a/src/utils/decoder_info.cpp b/src/utils/decoder_info.cpp index cc440db4d..3abc35e9b 100644 --- a/src/utils/decoder_info.cpp +++ b/src/utils/decoder_info.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify @@ -46,6 +46,13 @@ int LibRaw::get_decoder_info(libraw_decoder_info_t *d_info) d_info->decoder_name = "vc5_dng_load_raw_placeholder()"; #ifndef USE_GPRSDK d_info->decoder_flags = LIBRAW_DECODER_UNSUPPORTED_FORMAT; +#endif + } + else if (load_raw == &LibRaw::jxl_dng_load_raw_placeholder) + { + d_info->decoder_name = "jxl_dng_load_raw_placeholder()"; +#ifndef USE_DNGSDK + d_info->decoder_flags = LIBRAW_DECODER_UNSUPPORTED_FORMAT; #endif } else if (load_raw == &LibRaw::canon_600_load_raw) @@ -138,7 +145,7 @@ int LibRaw::get_decoder_info(libraw_decoder_info_t *d_info) else if (load_raw == &LibRaw::phase_one_load_raw_c) { d_info->decoder_name = "phase_one_load_raw_c()"; - d_info->decoder_flags = LIBRAW_DECODER_TRYRAWSPEED3; /* FIXME: need to make sure correction not applied*/ + d_info->decoder_flags = imgdata.color.phase_one_data.format == 5 ? 0: LIBRAW_DECODER_TRYRAWSPEED3; /* Use only with patched RawSpeed3; */ } else if (load_raw == &LibRaw::phase_one_load_raw_s) { @@ -194,13 +201,6 @@ int LibRaw::get_decoder_info(libraw_decoder_info_t *d_info) d_info->decoder_name = "nokia_load_raw()"; d_info->decoder_flags = LIBRAW_DECODER_FIXEDMAXC; } -#ifdef LIBRAW_OLD_VIDEO_SUPPORT - else if (load_raw == &LibRaw::canon_rmf_load_raw) - { - // UNTESTED - d_info->decoder_name = "canon_rmf_load_raw()"; - } -#endif else if (load_raw == &LibRaw::panasonic_load_raw) { d_info->decoder_name = "panasonic_load_raw()"; @@ -215,6 +215,10 @@ int LibRaw::get_decoder_info(libraw_decoder_info_t *d_info) { d_info->decoder_name = "panasonicC7_load_raw()"; } + else if (load_raw == &LibRaw::panasonicC8_load_raw) + { + d_info->decoder_name = "panasonicC8_load_raw()"; + } else if (load_raw == &LibRaw::olympus_load_raw) { d_info->decoder_name = "olympus_load_raw()"; @@ -295,6 +299,12 @@ int LibRaw::get_decoder_info(libraw_decoder_info_t *d_info) { d_info->decoder_name = "sony_ljpeg_load_raw()"; } + else if (load_raw == &LibRaw::sony_ycbcr_load_raw) + { + d_info->decoder_name = "sony_ycbcr_load_raw()"; + d_info->decoder_flags = LIBRAW_DECODER_LEGACY_WITH_MARGINS; + + } else if (load_raw == &LibRaw::sony_arw_load_raw) { d_info->decoder_name = "sony_arw_load_raw()"; @@ -337,13 +347,6 @@ int LibRaw::get_decoder_info(libraw_decoder_info_t *d_info) d_info->decoder_name = "smal_v9_load_raw()"; d_info->decoder_flags = LIBRAW_DECODER_FIXEDMAXC; } -#ifdef LIBRAW_OLD_VIDEO_SUPPORT - else if (load_raw == &LibRaw::redcine_load_raw) - { - d_info->decoder_name = "redcine_load_raw()"; - d_info->decoder_flags = LIBRAW_DECODER_HASCURVE; - } -#endif else if (load_raw == &LibRaw::x3f_load_raw) { d_info->decoder_name = "x3f_load_raw()"; diff --git a/src/utils/init_close_utils.cpp b/src/utils/init_close_utils.cpp index 26478d88c..fffab4de6 100644 --- a/src/utils/init_close_utils.cpp +++ b/src/utils/init_close_utils.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify @@ -46,10 +46,7 @@ LibRaw::LibRaw(unsigned int flags) : memmgr(1024) _x3f_data = NULL; #ifdef USE_RAWSPEED - CameraMetaDataLR *camerameta = - make_camera_metadata(); // May be NULL in case of exception in - // make_camera_metadata() - _rawspeed_camerameta = static_cast(camerameta); + _rawspeed_camerameta = make_camera_metadata(); #endif callbacks.data_cb = (flags & LIBRAW_OPTIONS_NO_DATAERR_CALLBACK) ? NULL @@ -79,6 +76,7 @@ LibRaw::LibRaw(unsigned int flags) : memmgr(1024) imgdata.params.output_color = 1; imgdata.params.output_bps = 8; imgdata.params.use_fuji_rotate = 1; + imgdata.params.use_p1_correction = 1; imgdata.params.exp_shift = 1.0; imgdata.params.auto_bright_thr = LIBRAW_DEFAULT_AUTO_BRIGHTNESS_THRESHOLD; imgdata.params.adjust_maximum_thr = LIBRAW_DEFAULT_ADJUST_MAXIMUM_THRESHOLD; @@ -118,9 +116,7 @@ LibRaw::~LibRaw() #ifdef USE_RAWSPEED if (_rawspeed_camerameta) { - CameraMetaDataLR *cmeta = - static_cast(_rawspeed_camerameta); - delete cmeta; + clear_camera_metadata(_rawspeed_camerameta); _rawspeed_camerameta = NULL; } #endif @@ -292,14 +288,13 @@ void LibRaw::recycle() MN.sony.AFMicroAdjValue = 0x7f; MN.sony.AFMicroAdjOn = -1; MN.sony.AFMicroAdjRegisteredLenses = 0xff; + MN.sony.AspectRatio = -999.f; _exitflag = 0; #ifdef USE_RAWSPEED if (_rawspeed_decoder) { - RawSpeed::RawDecoder *d = - static_cast(_rawspeed_decoder); - delete d; + clear_rawspeed_decoder(_rawspeed_decoder); } _rawspeed_decoder = 0; #endif diff --git a/src/utils/open.cpp b/src/utils/open.cpp index 12b0cb878..a1c1917cf 100644 --- a/src/utils/open.cpp +++ b/src/utils/open.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify @@ -488,6 +488,56 @@ int LibRaw::open_datastream(LibRaw_abstract_datastream *stream) ) return LIBRAW_FILE_UNSUPPORTED; } + // Remove unsupported Nikon thumbnails + if (makeIs(LIBRAW_CAMERAMAKER_Nikon) && !strncasecmp(imgdata.idata.model, "Z 8",3) && + imgdata.thumbs_list.thumbcount > 1) + { + int tgtidx = 0; + for (int idx = 0; idx < imgdata.thumbs_list.thumbcount && idx < LIBRAW_THUMBNAIL_MAXCOUNT; idx++) + { + int bps = imgdata.thumbs_list.thumblist[idx].tmisc & 0x1f; + if (bps > 8) // remove high-bit thumbs + { + // nothing: just skip this item + } + else + { + if (tgtidx < idx) + { + memmove(&imgdata.thumbs_list.thumblist[tgtidx], &imgdata.thumbs_list.thumblist[idx], + sizeof(imgdata.thumbs_list.thumblist[idx])); + tgtidx++; + } + else // same index, just assign next tgtidx + tgtidx = idx + 1; + } + } + if (tgtidx > 0 && tgtidx < imgdata.thumbs_list.thumbcount) + { + int selidx = 0; + INT64 maximgbits = INT64(imgdata.thumbs_list.thumblist[0].twidth) * + INT64(imgdata.thumbs_list.thumblist[0].theight) * INT64(imgdata.thumbs_list.thumblist[0].tmisc & 0x1f); + for (int i = 1; i < tgtidx; i++) + { + INT64 imgbits = INT64(imgdata.thumbs_list.thumblist[i].twidth) * + INT64(imgdata.thumbs_list.thumblist[i].theight) * + INT64(imgdata.thumbs_list.thumblist[i].tmisc & 0x1f); + if (imgbits > maximgbits) + { + selidx = i; + maximgbits = imgbits; + } + } + libraw_internal_data.internal_data.toffset = imgdata.thumbs_list.thumblist[selidx].toffset; + imgdata.thumbnail.tlength = imgdata.thumbs_list.thumblist[selidx].tlength; + libraw_internal_data.unpacker_data.thumb_format = imgdata.thumbs_list.thumblist[selidx].tformat; + imgdata.thumbnail.twidth = imgdata.thumbs_list.thumblist[selidx].twidth; + imgdata.thumbnail.theight = imgdata.thumbs_list.thumblist[selidx].theight; + libraw_internal_data.unpacker_data.thumb_misc = imgdata.thumbs_list.thumblist[selidx].tmisc; + // find another largest thumb and copy it to single thumbnail data + } + imgdata.thumbs_list.thumbcount = tgtidx > 0 ? tgtidx : 1; + } // promote the old single thumbnail to the thumbs_list if not present already if (imgdata.thumbs_list.thumbcount < LIBRAW_THUMBNAIL_MAXCOUNT) @@ -571,7 +621,8 @@ int LibRaw::open_datastream(LibRaw_abstract_datastream *stream) if (load_raw == &LibRaw::panasonic_load_raw) { if (libraw_internal_data.unpacker_data.pana_encoding == 6 || - libraw_internal_data.unpacker_data.pana_encoding == 7) + libraw_internal_data.unpacker_data.pana_encoding == 7 || + libraw_internal_data.unpacker_data.pana_encoding == 8) { for (int i = 0; i < 3; i++) imgdata.color.cblack[i] = @@ -612,6 +663,13 @@ int LibRaw::open_datastream(LibRaw_abstract_datastream *stream) else imgdata.idata.raw_count = 0; // incorrect size } + else if (libraw_internal_data.unpacker_data.pana_encoding == 8) + { + if (libraw_internal_data.unpacker_data.pana8.stripe_count > 0) + load_raw = &LibRaw::panasonicC8_load_raw; + else + imgdata.idata.raw_count = 0; // incorrect stripes count + } } #define NIKON_14BIT_SIZE(rw, rh) \ @@ -1087,6 +1145,8 @@ int LibRaw::open_datastream(LibRaw_abstract_datastream *stream) ((MN.pentax.MultiExposure & 0x01) == 1)) imgdata.color.as_shot_wb_applied = LIBRAW_ASWB_APPLIED | LIBRAW_ASWB_PENTAX; + else if (makeIs(LIBRAW_CAMERAMAKER_Sony) && load_raw == &LibRaw::sony_ycbcr_load_raw) + imgdata.color.as_shot_wb_applied = LIBRAW_ASWB_APPLIED | LIBRAW_ASWB_SONY; else imgdata.color.as_shot_wb_applied = 0; diff --git a/src/utils/phaseone_processing.cpp b/src/utils/phaseone_processing.cpp index b82988b69..6c7339223 100644 --- a/src/utils/phaseone_processing.cpp +++ b/src/utils/phaseone_processing.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. @@ -18,15 +18,23 @@ #include "../../internal/libraw_cxx_defs.h" + void LibRaw::phase_one_allocate_tempbuffer() { // Allocate temp raw_image buffer - imgdata.rawdata.raw_image = (ushort *)malloc(S.raw_pitch * S.raw_height); + if (imgdata.process_warnings & LIBRAW_WARN_RAWSPEED3_PROCESSED) + { + // Processed by RawSpeed, raw_image contains ptr to rawspeed internals + imgdata.rawdata.raw_alloc = imgdata.rawdata.raw_image; // save for data processing and future reuse + } + imgdata.rawdata.raw_image = (ushort *)malloc(S.raw_pitch * S.raw_height); } void LibRaw::phase_one_free_tempbuffer() { - free(imgdata.rawdata.raw_image); - imgdata.rawdata.raw_image = (ushort *)imgdata.rawdata.raw_alloc; + free(imgdata.rawdata.raw_image); + imgdata.rawdata.raw_image = (ushort *)imgdata.rawdata.raw_alloc; + if (imgdata.process_warnings & LIBRAW_WARN_RAWSPEED3_PROCESSED) + imgdata.rawdata.raw_alloc = 0; } int LibRaw::phase_one_subtract_black(ushort *src, ushort *dest) diff --git a/src/utils/read_utils.cpp b/src/utils/read_utils.cpp index 974ffc07b..c934344c1 100644 --- a/src/utils/read_utils.cpp +++ b/src/utils/read_utils.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/utils/thumb_utils.cpp b/src/utils/thumb_utils.cpp index b468b0b06..98184e759 100644 --- a/src/utils/thumb_utils.cpp +++ b/src/utils/thumb_utils.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify @@ -14,6 +14,13 @@ */ #include "../../internal/libraw_cxx_defs.h" +#include + +void LibRaw::dng_ycbcr_thumb_loader() +{ + // Placeholder: the only known camera w/ YCC previews in DNG provides broken files + throw LIBRAW_EXCEPTION_UNSUPPORTED_FORMAT; +} void LibRaw::kodak_thumb_loader() { @@ -267,7 +274,9 @@ int LibRaw::thumbOK(INT64 maxsz) return 0; // No thumb for raw > 4Gb-1 int tsize = 0; int tcol = (T.tcolors > 0 && T.tcolors < 4) ? T.tcolors : 3; - if (Tformat == LIBRAW_INTERNAL_THUMBNAIL_JPEG) + if (Tformat == LIBRAW_INTERNAL_THUMBNAIL_DNG_YCBCR) + return 0; // Temp: unless we get correct DNG w/ YCBCR preview + else if (Tformat == LIBRAW_INTERNAL_THUMBNAIL_JPEG) tsize = T.tlength; else if (Tformat == LIBRAW_INTERNAL_THUMBNAIL_PPM) tsize = tcol * T.twidth * T.theight; diff --git a/src/utils/utils_dcraw.cpp b/src/utils/utils_dcraw.cpp index 97d14552e..fd3085cc1 100644 --- a/src/utils/utils_dcraw.cpp +++ b/src/utils/utils_dcraw.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/utils/utils_libraw.cpp b/src/utils/utils_libraw.cpp index 15a7b6551..dc81d0dd3 100644 --- a/src/utils/utils_libraw.cpp +++ b/src/utils/utils_libraw.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify @@ -14,6 +14,7 @@ */ #include "../../internal/libraw_cxx_defs.h" +#include "../../internal/libraw_checked_buffer.h" #ifdef __cplusplus extern "C" @@ -229,7 +230,8 @@ unsigned LibRaw::capabilities() int LibRaw::is_sraw() { return load_raw == &LibRaw::canon_sraw_load_raw || - load_raw == &LibRaw::nikon_load_sraw; + load_raw == &LibRaw::nikon_load_sraw || + load_raw == &LibRaw::sony_ycbcr_load_raw; } int LibRaw::is_coolscan_nef() { @@ -245,6 +247,8 @@ int LibRaw::sraw_midpoint() { if (load_raw == &LibRaw::canon_sraw_load_raw) return 8192; + else if (load_raw == &LibRaw::sony_ycbcr_load_raw) + return 8192; // adjusted as in canon sRAW else if (load_raw == &LibRaw::nikon_load_sraw) return 2048; else @@ -671,3 +675,68 @@ void LibRaw::libraw_swab(void *arr, size_t len) #endif } + +checked_buffer_t::checked_buffer_t(short ord, int size) : _order(ord), storage(size + 64) +{ + _data = storage.data(); + _len = size; +} +checked_buffer_t::checked_buffer_t(short ord, unsigned char *dd, int ss) : _order(ord), _data(dd), _len(ss) {} + +ushort checked_buffer_t::sget2(int offset) +{ + checkoffset(offset + 2); + return libraw_sget2_static(_order, _data + offset); +} +void checked_buffer_t::checkoffset(int off) +{ + if (off >= _len) + throw LIBRAW_EXCEPTION_IO_EOF; +} +unsigned char checked_buffer_t::operator[](int idx) +{ + checkoffset(idx); + return _data[idx]; +} +unsigned checked_buffer_t::sget4(int offset) +{ + checkoffset(offset + 4); + return libraw_sget4_static(_order, _data + offset); +} + +double checked_buffer_t::sgetreal(int type, int offset) +{ + int sz = libraw_tagtype_dataunit_bytes(type); + checkoffset(offset + sz); + return libraw_sgetreal_static(_order, type, _data + offset); +} + +int checked_buffer_t::tiff_sget(unsigned save, INT64 *tag_offset, unsigned *tag_id, unsigned *tag_type, INT64 *tag_dataoffset, + unsigned *tag_datalen, int *tag_dataunitlen) +{ + if ((((*tag_offset) + 12) > _len) || (*tag_offset < 0)) + { // abnormal, tag buffer overrun + return -1; + } + int pos = *tag_offset; + *tag_id = sget2(pos); + pos += 2; + *tag_type = sget2(pos); + pos += 2; + *tag_datalen = sget4(pos); + pos += 4; + *tag_dataunitlen = libraw_tagtype_dataunit_bytes(*tag_type); + if ((*tag_datalen * (*tag_dataunitlen)) > 4) + { + *tag_dataoffset = sget4(pos) - save; + if ((*tag_dataoffset + *tag_datalen) > _len) + { // abnormal, tag data buffer overrun + return -2; + } + } + else + *tag_dataoffset = *tag_offset + 8; + *tag_offset += 12; + return 0; +} + diff --git a/src/write/apply_profile.cpp b/src/write/apply_profile.cpp index 0bcb16dca..9c8a9fd98 100644 --- a/src/write/apply_profile.cpp +++ b/src/write/apply_profile.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/write/file_write.cpp b/src/write/file_write.cpp index bf17ea2b4..ce9073d13 100644 --- a/src/write/file_write.cpp +++ b/src/write/file_write.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/write/tiff_writer.cpp b/src/write/tiff_writer.cpp index 895b18e52..f8a126af2 100644 --- a/src/write/tiff_writer.cpp +++ b/src/write/tiff_writer.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw uses code from dcraw.c -- Dave Coffin's raw photo decoder, dcraw.c is copyright 1997-2018 by Dave Coffin, dcoffin a cybercom o net. diff --git a/src/write/write_ph.cpp b/src/write/write_ph.cpp index 8151f108f..1c77470f8 100644 --- a/src/write/write_ph.cpp +++ b/src/write/write_ph.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * Placeholder functions to build LibRaw w/o postprocessing and preprocessing calls diff --git a/src/x3f/x3f_parse_process.cpp b/src/x3f/x3f_parse_process.cpp index 354e46737..e704d069f 100644 --- a/src/x3f/x3f_parse_process.cpp +++ b/src/x3f/x3f_parse_process.cpp @@ -1,5 +1,5 @@ /* -*- C++ -*- - * Copyright 2019-2021 LibRaw LLC (info@libraw.org) + * Copyright 2019-2024 LibRaw LLC (info@libraw.org) * LibRaw is free software; you can redistribute it and/or modify @@ -223,10 +223,15 @@ void LibRaw::parse_x3f() else { // No property list - if (imgdata.sizes.raw_width == 5888 || imgdata.sizes.raw_width == 2944 || - imgdata.sizes.raw_width == 6656 || imgdata.sizes.raw_width == 3328 || - imgdata.sizes.raw_width == 5504 || - imgdata.sizes.raw_width == 2752) // Quattro + // sd Quattro H: 6656x4480, 3328x2240, 5504x3680, 2752x1840 + // dpN Quattro: 5888x3672, 2944x1836 + // sd Quattro: 5888x3776, 2944x1888 + if ((imgdata.sizes.raw_width == 5888) || // Quattro: dp0, dp1, dp2, sd + (imgdata.sizes.raw_width == 2944) || // Quattro: dp0, dp1, dp2, sd + (imgdata.sizes.raw_width == 6656) || // sd Quattro H + (imgdata.sizes.raw_width == 3328) || // sd Quattro H + (imgdata.sizes.raw_width == 5504) || // sd Quattro H APS-C + (imgdata.sizes.raw_width == 2752)) // sd Quattro H APS-C { imgdata.idata.raw_count = 1; load_raw = &LibRaw::x3f_load_raw; @@ -254,15 +259,24 @@ void LibRaw::parse_x3f() } else if (fndsd) { - snprintf(imgdata.idata.model, 64, "%s", fndsd); - } + unsigned char *fndsdQH = (unsigned char *)lr_memmem(fndsd, 20, "sd Quattro H", 12); + if (fndsdQH) + snprintf(imgdata.idata.model, 64, "%s", fndsdQH); + else + snprintf(imgdata.idata.model, 64, "%s", fndsd); + } else #endif - if (imgdata.sizes.raw_width == 6656 || - imgdata.sizes.raw_width == 3328) - strcpy(imgdata.idata.model, "sd Quattro H"); - else - strcpy(imgdata.idata.model, "dp2 Quattro"); + if ((imgdata.sizes.raw_width == 6656) || + (imgdata.sizes.raw_width == 3328) || + (imgdata.sizes.raw_width == 5504) || + (imgdata.sizes.raw_width == 2752)) + strcpy(imgdata.idata.model, "sd Quattro H"); + else if ((imgdata.sizes.raw_height == 3776) || + (imgdata.sizes.raw_height == 1888)) + strcpy(imgdata.idata.model, "sd Quattro"); + else // defaulting to dp2 Quattro + strcpy(imgdata.idata.model, "dp2 Quattro"); } // else }