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

Single tiled deflate compressed DNGs not decoded properly #6575

Open
SimonSegerblomRex opened this issue Sep 5, 2022 · 3 comments · May be fixed by #6576
Open

Single tiled deflate compressed DNGs not decoded properly #6575

SimonSegerblomRex opened this issue Sep 5, 2022 · 3 comments · May be fixed by #6576
Labels
scope: file format Camera or image file formats

Comments

@SimonSegerblomRex
Copy link
Contributor

SimonSegerblomRex commented Sep 5, 2022

Short description

I just tried opening a DNG using deflate compression with only one tile. If fails miserably since tile_length is set to INT_MAX before reaching this if statement:

if (tile_length < INT_MAX) {

Steps to reproduce

  1. Open the attached DNG (with the latest commit on dev)
  2. Notice how you only get an image containing zeros since (since tile_offset, tile_length, and tile_width are messed up)

This is were things get messed up:

RawTherapee/rtengine/dcraw.cc

Lines 6551 to 6554 in 2ce5b82

case 324: /* TileOffsets */
tiff_ifd[ifd].offset = len > 1 ? ftell(ifp) : get4();
if (len == 1)
tiff_ifd[ifd].tile_width = tiff_ifd[ifd].tile_length = 0;

Followed by:

RawTherapee/rtengine/dcraw.cc

Lines 7065 to 7066 in 2ce5b82

if (!tile_width ) tile_width = INT_MAX;
if (!tile_length) tile_length = INT_MAX;

Expected behavior

The attached image should be decoded properly.

Additional information
Version: 5.8-3139-g2ce5b827c
Branch: dev
Commit: 2ce5b82
Commit date: 2022-08-30
Compiler: cc 10.2.1
Processor: x86_64
System: Linux
Bit depth: 64 bits
Gtkmm: V3.24.2
Lensfun: V0.3.2.0
Build type: release
Build flags: -std=c++11 -march=native -Werror=unused-label -Werror=delete-incomplete -fno-math-errno -Wno-attributes -Wall -Wuninitialized -Wcast-qual -Wno-deprecated-declarations -Wno-unused-result -Wunused-macros -fopenmp -Werror=unknown-pragmas -O3 -DNDEBUG -ftree-vectorize
Link flags: -march=native
OpenMP support: ON
MMAP support: ON
Build OS: Linux 5.10.0-16-amd64 x86_64
Build date: Mon, 05 Sep 2022 09:39:15 +0000 UTC
Build epoch: 1662370755
Build UUID:

SimonSegerblomRex added a commit to SimonSegerblomRex/RawTherapee that referenced this issue Sep 5, 2022
SimonSegerblomRex added a commit to SimonSegerblomRex/RawTherapee that referenced this issue Sep 5, 2022
The old code looks messed up, but I'm not sure...

Fixes Beep6581#6575
SimonSegerblomRex added a commit to SimonSegerblomRex/RawTherapee that referenced this issue Sep 6, 2022
The old code looks messed up, but I'm not sure...

Fixes Beep6581#6575
@SimonSegerblomRex SimonSegerblomRex changed the title Something odd with TileOffsets Single tiled deflate compressed DNGs not decoded properly Sep 6, 2022
@Lawrence37 Lawrence37 added the scope: file format Camera or image file formats label Jun 25, 2023
@Beep6581
Copy link
Owner

Beep6581 commented Aug 8, 2023

Which cameras and software produce deflate-compressed DNGs?

@SimonSegerblomRex
Copy link
Contributor Author

Which cameras and software produce deflate-compressed DNGs?

I haven't come across any deflate compressed DNGs in the wild. This issue was just something I noticed when playing with the different options in the DNG specification. dcraw.cc is fragile, so we need to be really careful changing anything in there.

@kmilos
Copy link
Contributor

kmilos commented Aug 10, 2023

Which cameras and software produce deflate-compressed DNGs?

For example HDRMerge produces 16/24/32-bit float deflate compressed DNGs. Not sure what it does re striping/tiling...

I haven't come across any deflate compressed DNGs in the wild.

There are HDRMerge samples on https://raw.pixls.us/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: file format Camera or image file formats
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants
@kmilos @Beep6581 @SimonSegerblomRex @Lawrence37 and others