Skip to content

Commit

Permalink
RT crashes on loading Hasselblad H6D-100cMS pixelshift files, fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
heckflosse committed Sep 1, 2019
1 parent a5cba62 commit 5ea18ef
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 6 deletions.
36 changes: 34 additions & 2 deletions rtengine/rawimagesource.cc
Expand Up @@ -999,11 +999,43 @@ int RawImageSource::load (const Glib::ustring &fname, bool firstFrameOnly)
if (errCode) {
return errCode;
}
numFrames = firstFrameOnly ? 1 : ri->getFrameCount();
numFrames = firstFrameOnly ? (numFrames < 7 ? 1 : ri->getFrameCount()) : ri->getFrameCount();

errCode = 0;

if(numFrames > 1) {
if(numFrames >= 7) {
// special case to avoid crash when loading Hasselblad H6D-100cMS pixelshift files
// limit to 6 frames and skip first frame, as first frame is not bayer
if (firstFrameOnly) {
numFrames = 1;
} else {
numFrames = 6;
}
#ifdef _OPENMP99
#pragma omp parallel
#endif
{
int errCodeThr = 0;
#ifdef _OPENMP99
#pragma omp for nowait
#endif
for(unsigned int i = 0; i < numFrames; ++i) {
if(i == 0) {
riFrames[i] = ri;
errCodeThr = riFrames[i]->loadRaw (true, i + 1, true, plistener, 0.8);
} else {
riFrames[i] = new RawImage(fname);
errCodeThr = riFrames[i]->loadRaw (true, i + 1);
}
}
#ifdef _OPENMP99
#pragma omp critical
#endif
{
errCode = errCodeThr ? errCodeThr : errCode;
}
}
} else if(numFrames > 1) {
#ifdef _OPENMP
#pragma omp parallel
#endif
Expand Down
6 changes: 3 additions & 3 deletions rtengine/rawimagesource.h
Expand Up @@ -74,13 +74,13 @@ class RawImageSource : public ImageSource
bool rgbSourceModified;

RawImage* ri; // Copy of raw pixels, NOT corrected for initial gain, blackpoint etc.
RawImage* riFrames[4] = {nullptr};
RawImage* riFrames[6] = {nullptr};
unsigned int currFrame = 0;
unsigned int numFrames = 0;
int flatFieldAutoClipValue = 0;
array2D<float> rawData; // holds preprocessed pixel values, rowData[i][j] corresponds to the ith row and jth column
array2D<float> *rawDataFrames[4] = {nullptr};
array2D<float> *rawDataBuffer[3] = {nullptr};
array2D<float> *rawDataFrames[6] = {nullptr};
array2D<float> *rawDataBuffer[5] = {nullptr};

// the interpolated green plane:
array2D<float> green;
Expand Down
11 changes: 11 additions & 0 deletions rtengine/rtthumbnail.cc
Expand Up @@ -547,6 +547,17 @@ Thumbnail* Thumbnail::loadFromRaw (const Glib::ustring& fname, RawMetaDataLocati
return nullptr;
}

if (ri->getFrameCount() == 7) {
// special case for Hasselblad H6D-100cMS pixelshift files
// first frame is not bayer, load second frame
int r = ri->loadRaw (1, 1, 0);

if ( r ) {
delete ri;
sensorType = ST_NONE;
return nullptr;
}
}
sensorType = ri->getSensorType();

int width = ri->get_width();
Expand Down
2 changes: 1 addition & 1 deletion rtgui/bayerprocess.cc
Expand Up @@ -729,7 +729,7 @@ void BayerProcess::FrameCountChanged(int n, int frameNum)

imageNumber->remove_all();
imageNumber->append("1");
for (int i = 2; i <= std::min(n, 4); ++i) {
for (int i = 2; i <= std::min(n, 6); ++i) {
std::ostringstream entry;
entry << i;
imageNumber->append(entry.str());
Expand Down

0 comments on commit 5ea18ef

Please sign in to comment.