Skip to content

Commit

Permalink
Fix regression with demosaiced DNGs caused by 831a9bb
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Entropy512 committed Mar 17, 2024
1 parent e8ed392 commit 52b7dac
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions rtengine/rawimagesource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ void RawImageSource::getWBMults(const ColorTemp &ctemp, const RAWParams &raw, st

void RawImageSource::getImage(const ColorTemp &ctemp, int tran, Imagefloat* image, const PreviewProps &pp, const ToneCurveParams &hrp, const RAWParams &raw)
{
assert(rawData.getHeight() == H && rawData.getWidth() == W);
assert(rawData.getHeight() == H && !(rawData.getWidth() % W));

MyMutex::MyLock lock(getImageMutex);

Expand Down Expand Up @@ -1747,7 +1747,7 @@ void RawImageSource::preprocess(const RAWParams &raw, const LensProfParams &lens

void RawImageSource::demosaic(const RAWParams &raw, bool autoContrast, double &contrastThreshold, bool cache)
{
assert(rawData.getHeight() == H && rawData.getWidth() == W);
assert(rawData.getHeight() == H && !(rawData.getWidth() % W));

MyTime t1, t2;
t1.set();
Expand Down Expand Up @@ -3842,7 +3842,7 @@ void RawImageSource::hlRecovery(const std::string &method, float* red, float* gr

void RawImageSource::getAutoExpHistogram(LUTu & histogram, int& histcompr)
{
assert(rawData.getHeight() == H && rawData.getWidth() == W);
assert(rawData.getHeight() == H && !(rawData.getWidth() % W));

// BENCHFUN
histcompr = 3;
Expand Down Expand Up @@ -7487,7 +7487,7 @@ void RawImageSource::getrgbloc(int begx, int begy, int yEn, int xEn, int cx, int

void RawImageSource::getAutoWBMultipliersitc(bool extra, double & tempref, double & greenref, double & tempitc, double & greenitc, float &temp0, float &delta, int &bia, int &dread, int &kcam, int &nocam, float &studgood, float &minchrom, int &kmin, float &minhist, float &maxhist, int begx, int begy, int yEn, int xEn, int cx, int cy, int bf_h, int bf_w, double & rm, double & gm, double & bm, const WBParams & wbpar, const ColorManagementParams & cmp, const RAWParams & raw, const ToneCurveParams &hrp)
{
assert(rawData.getHeight() == H && rawData.getWidth() == W);
assert(rawData.getHeight() == H && !(rawData.getWidth() % W));

// BENCHFUN
constexpr double clipHigh = 64000.0;
Expand Down Expand Up @@ -7713,7 +7713,7 @@ void RawImageSource::getAutoWBMultipliersitc(bool extra, double & tempref, doubl

void RawImageSource::getAutoWBMultipliers(double &rm, double &gm, double &bm)
{
assert(rawData.getHeight() == H && rawData.getWidth() == W);
assert(rawData.getHeight() == H && !(rawData.getWidth() % W));

// BENCHFUN
constexpr double clipHigh = 64000.0;
Expand Down Expand Up @@ -7931,7 +7931,7 @@ void RawImageSource::getAutoWBMultipliers(double &rm, double &gm, double &bm)

ColorTemp RawImageSource::getSpotWB(std::vector<Coord2D> &red, std::vector<Coord2D> &green, std::vector<Coord2D> &blue, int tran, double equal, StandardObserver observer)
{
assert(rawData.getHeight() == H && rawData.getWidth() == W);
assert(rawData.getHeight() == H && !(rawData.getWidth() % W));

int x;
int y;
Expand Down Expand Up @@ -8319,7 +8319,7 @@ bool RawImageSource::isGainMapSupported() const

void RawImageSource::applyDngGainMap(const float black[4], const std::vector<GainMap> &gainMaps)
{
assert(rawData.getHeight() == H && rawData.getWidth() == W);
assert(rawData.getHeight() == H && !(rawData.getWidth() % W));

// now we can apply each gain map to raw_data
array2D<float> mvals[2][2];
Expand Down

0 comments on commit 52b7dac

Please sign in to comment.