Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibRaw 0.21.3 #7209

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 60 additions & 12 deletions rtengine/libraw/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,36 @@
2024-09-18 Alex Tutubalin <[email protected]>

LibRaw 0.21.3-Release
* new compile-time define LIBRAW_CALLOC_RAWSTORE
If defined: calloc() will be used for all big buffer
allocations to prevent uninitialized heap data leak

* Small allocations: calloc() instead of malloc() to prevent
uninitialized heap data leak

* Support for 4-component JPEG-compressed DNG files

* CR3-Qstep table: avoid wrong 64-bit code generation

* Fixed several bugs related to specially-crafted files
processing (thanks to OSS-Fuzz project)

2024-03-30 Alex Tutubalin <[email protected]>

LibRaw-snapshot-202403

* Raw format support
* Raw format support
1) Panasonic encoding 8

2) Sony YCC (Medium/Small compression) pseudo-RAW support:
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
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
-- 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
Expand All @@ -30,7 +47,7 @@
- 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
A1: support for files damaged by exiftool
- Multiple DJI and Skydio drones
- tested with multiple smartphones with DNG format recorded.

Expand All @@ -39,19 +56,19 @@
* 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
* 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
- 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
- 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
Expand All @@ -77,13 +94,13 @@

* Canon CR2 16-bit bitmap previes: do not convert from Kodak colorspace

* New compile-defined limit LIBRAW_MAX_PROFILE_SIZE_MB:
* 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.

* Check against corrupted LJPEG header in Canon sRAW decoder

* Better support for Sony metadata

* Better handling of memory allocation errors in unpack_thumb()
Expand All @@ -107,9 +124,40 @@

* tiff parser: check for IFD offset before parsing it

2023-12-19 Alex Tutubalin <[email protected]>

LibRaw 0.21.2-Release

* 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


2023-01-05 Alex Tutubalin <[email protected]>
LibRaw 0.21.1-Release
* fixed typo in panasonic metadata parser

2022-12-18 Alex Tutubalin <[email protected]>
LibRaw 0.21-Release

* Multiple fixes inspired by oss-fuzz project

2022-07-01 Alex Tutubalin <[email protected]>

LibRaw 0.21
LibRaw 0.21-Beta1

== Camera format support ==
* Phase One/Leaf IIQ-S v2 support
Expand Down
4 changes: 2 additions & 2 deletions rtengine/libraw/libraw/libraw_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 0
#define LIBRAW_VERSION_TAIL Beta1
#define LIBRAW_PATCH_VERSION 3
#define LIBRAW_VERSION_TAIL Release

#define LIBRAW_SHLIB_CURRENT 23
#define LIBRAW_SHLIB_REVISION 0
Expand Down
16 changes: 11 additions & 5 deletions rtengine/libraw/src/decoders/decoders_dcraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ void LibRaw::nokia_load_raw()
if (raw_stride)
dwide = raw_stride;
#endif
std::vector<uchar> data(dwide * 2 + 4);
std::vector<uchar> data(dwide * 2 + 4,0);
for (row = 0; row < raw_height; row++)
{
checkCancel();
Expand Down Expand Up @@ -1066,11 +1066,17 @@ unsigned LibRaw::pana_data(int nb, unsigned *bytes)
int byte;

if (!nb && !bytes)
return vpos = 0;
{
memset(buf, 0, sizeof(buf));
return vpos = 0;
}
if (load_flags > 0x4000)
throw LIBRAW_EXCEPTION_IO_BADFILE;

if (!vpos)
{
fread(buf + load_flags, 1, 0x4000 - load_flags, ifp);
if(load_flags < 0x4000)
fread(buf + load_flags, 1, 0x4000 - load_flags, ifp);
fread(buf, 1, load_flags, ifp);
}

Expand Down Expand Up @@ -1409,7 +1415,7 @@ void LibRaw::sony_load_raw()

void LibRaw::sony_arw_load_raw()
{
std::vector<ushort> huff_buffer(32770);
std::vector<ushort> huff_buffer(32770,0);
ushort* huff = &huff_buffer[0];
static const ushort tab[18] = {0xf11, 0xf10, 0xe0f, 0xd0e, 0xc0d, 0xb0c,
0xa0b, 0x90a, 0x809, 0x708, 0x607, 0x506,
Expand Down Expand Up @@ -1441,7 +1447,7 @@ void LibRaw::sony_arw2_load_raw()
ushort pix[16];
int row, col, val, max, min, imax, imin, sh, bit, i;

data = (uchar *)malloc(raw_width + 1);
data = (uchar *)calloc(raw_width + 1,1);
try
{
for (row = 0; row < height; row++)
Expand Down
25 changes: 17 additions & 8 deletions rtengine/libraw/src/decoders/decoders_libraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,20 @@ void LibRaw::sony_arq_load_raw()

void LibRaw::pentax_4shot_load_raw()
{
ushort *plane = (ushort *)malloc(imgdata.sizes.raw_width *
imgdata.sizes.raw_height * sizeof(ushort));
#ifdef LIBRAW_CALLOC_RAWSTORE
ushort *plane = (ushort *)calloc(size_t(imgdata.sizes.raw_width) *
size_t(imgdata.sizes.raw_height), sizeof(ushort));
#else
ushort *plane = (ushort *)malloc(size_t(imgdata.sizes.raw_width) *
size_t(imgdata.sizes.raw_height) * sizeof(ushort));
#endif
int alloc_sz = imgdata.sizes.raw_width * (imgdata.sizes.raw_height + 16) * 4 *
sizeof(ushort);
#ifdef LIBRAW_CALLOC_RAWSTORE
ushort(*result)[4] = (ushort(*)[4])calloc(alloc_sz,1);
#else
ushort(*result)[4] = (ushort(*)[4])malloc(alloc_sz);
#endif
struct movement_t
{
int row, col;
Expand Down Expand Up @@ -197,7 +206,7 @@ void LibRaw::nikon_14bit_load_raw()
(unsigned)(ceilf((float)(S.raw_width * 7 / 4) / 16.0)) *
16; // 14512; // S.raw_width * 7 / 4;
const unsigned pitch = S.raw_pitch ? S.raw_pitch / 2 : S.raw_width;
unsigned char *buf = (unsigned char *)malloc(linelen);
unsigned char *buf = (unsigned char *)calloc(linelen,1);
for (int row = 0; row < S.raw_height; row++)
{
unsigned bytesread =
Expand All @@ -216,7 +225,7 @@ void LibRaw::fuji_14bit_load_raw()
{
const unsigned linelen = S.raw_width * 7 / 4;
const unsigned pitch = S.raw_pitch ? S.raw_pitch / 2 : S.raw_width;
unsigned char *buf = (unsigned char *)malloc(linelen);
unsigned char *buf = (unsigned char *)calloc(linelen,1);

for (int row = 0; row < S.raw_height; row++)
{
Expand Down Expand Up @@ -247,7 +256,7 @@ void LibRaw::nikon_load_padded_packed_raw() // 12 bit per pixel, padded to 16
libraw_internal_data.unpacker_data.load_flags > 64000)
return;
unsigned char *buf =
(unsigned char *)malloc(libraw_internal_data.unpacker_data.load_flags);
(unsigned char *)calloc(libraw_internal_data.unpacker_data.load_flags,1);
for (int row = 0; row < S.raw_height; row++)
{
checkCancel();
Expand Down Expand Up @@ -478,7 +487,7 @@ void LibRaw::panasonicC7_load_raw()
const int rowstep = 16;
int pixperblock = libraw_internal_data.unpacker_data.pana_bpp == 14 ? 9 : 10;
int rowbytes = imgdata.sizes.raw_width / pixperblock * 16;
unsigned char *iobuf = (unsigned char *)malloc(rowbytes * rowstep);
unsigned char *iobuf = (unsigned char *)calloc(rowbytes * rowstep,1);
for (int row = 0; row < imgdata.sizes.raw_height - rowstep + 1;
row += rowstep)
{
Expand Down Expand Up @@ -540,7 +549,7 @@ void LibRaw::unpacked_load_raw_fuji_f700s20()
libraw_internal_data.internal_data.input->seek(-row_size, SEEK_CUR);
base_offset = row_size; // in bytes
}
unsigned char *buffer = (unsigned char *)malloc(row_size * 2);
unsigned char *buffer = (unsigned char *)calloc(row_size,2);
for (int row = 0; row < imgdata.sizes.raw_height; row++)
{
read_shorts((ushort *)buffer, imgdata.sizes.raw_width * 2);
Expand All @@ -554,7 +563,7 @@ void LibRaw::nikon_load_sraw()
{
// We're already seeked to data!
unsigned char *rd =
(unsigned char *)malloc(3 * (imgdata.sizes.raw_width + 2));
(unsigned char *)calloc(3 * (imgdata.sizes.raw_width + 2),1);
if (!rd)
throw LIBRAW_EXCEPTION_ALLOC;
try
Expand Down
18 changes: 9 additions & 9 deletions rtengine/libraw/src/decoders/decoders_libraw_dcrdefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ void LibRaw::sony_ljpeg_load_raw()
break;
try
{
for (row = jrow = 0; jrow < (unsigned)jh.high; jrow++, row += 2)
for (row = jrow = 0; jrow < (unsigned)jh.high && trow+row < raw_height-1; jrow++, row += 2)
{
checkCancel();
ushort(*rowp)[4] = (ushort(*)[4])ljpeg_row(jrow, &jh);
for (col = jcol = 0; jcol < (unsigned)jh.wide; jcol++, col += 2)
for (col = jcol = 0; jcol < (unsigned)jh.wide && tcol+col < raw_width-1; jcol++, col += 2)
{
RAW(trow + row, tcol + col) = rowp[jcol][0];
RAW(trow + row, tcol + col + 1) = rowp[jcol][1];
Expand Down Expand Up @@ -129,7 +129,7 @@ void LibRaw::nikon_coolscan_load_raw()

int bypp = tiff_bps <= 8 ? 1 : 2;
int bufsize = width * clrs * bypp;
unsigned char *buf = (unsigned char *)malloc(bufsize);
unsigned char *buf = (unsigned char *)calloc(bufsize,1);
unsigned short *ubuf = (unsigned short *)buf;

if (tiff_bps <= 8)
Expand Down Expand Up @@ -228,7 +228,7 @@ void LibRaw::android_tight_load_raw()
int bwide, row, col, c;

bwide = -(-5 * raw_width >> 5) << 3;
data = (uchar *)malloc(bwide);
data = (uchar *)calloc(bwide,1);
for (row = 0; row < raw_height; row++)
{
if (fread(data, 1, bwide, ifp) < bwide)
Expand All @@ -246,7 +246,7 @@ void LibRaw::android_loose_load_raw()
UINT64 bitbuf = 0;

bwide = (raw_width + 5) / 6 << 3;
data = (uchar *)malloc(bwide);
data = (uchar *)calloc(bwide,1);
for (row = 0; row < raw_height; row++)
{
if (fread(data, 1, bwide, ifp) < bwide)
Expand Down Expand Up @@ -289,7 +289,7 @@ void LibRaw::rpi_load_raw8()
dwide = raw_width;
else
dwide = raw_stride;
data = (uchar *)malloc(dwide * 2);
data = (uchar *)calloc(dwide, 2);
for (row = 0; row < raw_height; row++) {
if (fread(data + dwide, 1, dwide, ifp) < dwide) derror();
FORC(dwide) data[c] = data[dwide + (c ^ rev)];
Expand Down Expand Up @@ -320,7 +320,7 @@ void LibRaw::rpi_load_raw12()
dwide = (raw_width * 3 + 1) / 2;
else
dwide = raw_stride;
data = (uchar *)malloc(dwide * 2);
data = (uchar *)calloc(dwide, 2);
for (row = 0; row < raw_height; row++) {
if (fread(data + dwide, 1, dwide, ifp) < dwide) derror();
FORC(dwide) data[c] = data[dwide + (c ^ rev)];
Expand Down Expand Up @@ -351,7 +351,7 @@ void LibRaw::rpi_load_raw14()
dwide = ((raw_width * 7) + 3) >> 2;
else
dwide = raw_stride;
data = (uchar *)malloc(dwide * 2);
data = (uchar *)calloc(dwide, 2);
for (row = 0; row < raw_height; row++) {
if (fread(data + dwide, 1, dwide, ifp) < dwide) derror();
FORC(dwide) data[c] = data[dwide + (c ^ rev)];
Expand Down Expand Up @@ -386,7 +386,7 @@ void LibRaw::rpi_load_raw16()
dwide = (raw_width * 2);
else
dwide = raw_stride;
data = (uchar *)malloc(dwide * 2);
data = (uchar *)calloc(dwide, 2);
for (row = 0; row < raw_height; row++) {
if (fread(data + dwide, 1, dwide, ifp) < dwide) derror();
FORC(dwide) data[c] = data[dwide + (c ^ rev)];
Expand Down
Loading
Loading