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 regression with demosaiced DNGs caused by 831a9bbd #6997

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

Conversation

Entropy512
Copy link
Contributor

Demosaiced DNGs (aka LinearRAW PhotometricInterpretation) have 3 samples per pixel, so rawData.getWidth() returns triple the width Only throw an assert if getWidth is not a multiple of W. This new implementation assumes that getWidth() will never be zero when getHeight() is nonzero

Fixes #6996

@Lawrence37 Lawrence37 added this to the v5.11 milestone Mar 17, 2024
@Lawrence37
Copy link
Collaborator

It's probably best to refactor these checks (including the first if-statement in getRawValues) to use a function that checks the validity of the dimensions.

bool checkRawDataDimensions(const array2D<float> &rawData, const RawImage &rawImage, int width, int height)
{
    const int colors = (rawImage.getSensorType() == ST_BAYER ||
                           rawImage.getSensorType() == ST_FUJI_XTRANS ||
                           rawImage.get_colors() == 1)
                           ? 1
                           : 3;
    return rawData.getHeight() == height && rawData.getWidth() == colors * width;
}

@Entropy512
Copy link
Contributor Author

Great! Thanks for the suggestions including where to get the equivalent of SamplesPerPixel. I've had a few too many Tasty Beverages for tonight, I'll work on this refactor tomorrow.

Uses a new function checkRawDataDimensions as suggested/written by @Lawrence37 to verify that image dimensions are correct.

Fixes Beep6581#6996
Comment on lines +745 to +754
bool checkRawDataDimensions(const array2D<float> &rawData, const RawImage &rawImage, int width, int height)
{
const int colors = (rawImage.getSensorType() == rtengine::ST_BAYER ||
rawImage.getSensorType() == rtengine::ST_FUJI_XTRANS ||
rawImage.get_colors() == 1)
? 1
: 3;
return rawData.getHeight() == height && rawData.getWidth() == colors * width;
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to put this in the anonymous namespace at the top of the file.

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.

Demosaiced DNGs fail to load since commit 831a9bbd
2 participants