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

Fix TileOffsets for DNGs containing one tile #6576

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

SimonSegerblomRex
Copy link
Contributor

The old code looks messed up.

Fixes #6575

rtengine/dcraw.cc Outdated Show resolved Hide resolved
@SimonSegerblomRex
Copy link
Contributor Author

SimonSegerblomRex commented Sep 5, 2022

At least this fixes the issues with decoding the file that I uploaded, but I'm not 100 % sure about what's happening... Let me know if you have any image files for regression testing.

Comment on lines -6553 to -6554
if (len == 1)
tiff_ifd[ifd].tile_width = tiff_ifd[ifd].tile_length = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this will affect the logic here:

RawTherapee/rtengine/dcraw.cc

Lines 7065 to 7066 in 2ce5b82

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

...but I'm not sure why you would like to set tile_width/tile_length to 0 or INT_MAX...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this breaks lossless JPEG decoding for some reason...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing

RawTherapee/rtengine/dcraw.cc

Lines 1136 to 1137 in 2ce5b82

if (tile_length < INT_MAX)
fseek (ifp, get4(), SEEK_SET);

seems to solve the problem for lossless JPEG encoded single tiled DNGs, but will at the same break things for some multi-tiled images...

It might also be worth looking into the logic deciding between the two functions lossless_jpeg_load_raw and lossless_dng_load_raw.

The old code looks messed up, but I'm not sure...

Fixes Beep6581#6575
@SimonSegerblomRex
Copy link
Contributor Author

SimonSegerblomRex commented Sep 6, 2022

At least this image works again with the latest patch set.

EDIT: This image is also fine.

@Thanatomanic
Copy link
Contributor

I must say, you're a brave man trying to disect and change dcraw.cc code! I will need some time to do proper checking here, especially since this code is embedded deep in the bowels of the beast, so to speak...

@SimonSegerblomRex
Copy link
Contributor Author

I must say, you're a brave man trying to disect and change dcraw.cc code! I will need some time to do proper checking here, especially since this code is embedded deep in the bowels of the beast, so to speak...

Yes, we need to be really careful... I'm not even sure if this problem is related to the singled tiled nature of the image I uploaded or something else. At least I think this change will only affect images were tile_length was set to INT_MAX (after first being set to 0...). There is one more occurrence of tile_length < INT_MAX that we might need to update.

@Entropy512 Entropy512 mentioned this pull request Sep 28, 2022
@Beep6581
Copy link
Owner

Tagging this for 6.0 as it touches radioactive elements. Let's merge as soon as 5.10 is out to allow as much time for testing as possible.

@Beep6581 Beep6581 added this to the v6.0 milestone Aug 28, 2023
@Beep6581
Copy link
Owner

@SimonSegerblomRex can you provide a list of affected cameras?

@SimonSegerblomRex
Copy link
Contributor Author

@SimonSegerblomRex can you provide a list of affected cameras?

I actually don't know of any cameras affected by the bug that I tried to fix here, but a lot of cameras could potentially be affected by this change, so I would be really careful merging this without thorough regression testing. Maybe it's better to convert this pull request to draft.

@Lawrence37
Copy link
Collaborator

5.10 has just been released. Now is a good time to merge if this is ready for broader testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Single tiled deflate compressed DNGs not decoded properly
4 participants