Segfault fixed when opening Fuji cropped raw. Fixes #6312
This commit is contained in:
Lawrence37 2024-02-04 15:47:28 -08:00 committed by GitHub
commit f65e428e7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 48 additions and 3 deletions

View File

@ -1596,7 +1596,10 @@ Camera constants:
{ // Quality A, samples provided by Daniel Catalina (#5839) and pi99y (#5860)
"make_model": [ "FUJIFILM X-T3", "FUJIFILM X-PRO3" ],
"dcraw_matrix": [ 13426,-6334,-1177,-4244,12136,2371,-580,1303,5980 ], // DNG_v11, standard_v2 d65
"raw_crop": [ 0, 5, 6252, 4176],
"raw_crop" : [
{ "frame" : [6384, 4182], "crop": [ 0, 5, 6252, 4176] },
{ "frame" : [6384, 3348], "crop": [624, 0, 5004, 3348] }
],
"white": [ 16170, 16275, 16170 ] // typical safe-margins with LENR
// negligible aperture scaling effect
},

View File

@ -5775,6 +5775,8 @@ nf: order = 0x4949;
cam_mul[0] = get2() / 256.0;
if (tag == 0x1018 || tag == 0x20400100)
cam_mul[2] = get2() / 256.0;
if (tag == 0x104D)
read_crop.crop_mode = (CropMode)get2();
if (tag == 0x2011 && len == 2) {
get2_256:
order = 0x4d4d;
@ -7652,15 +7654,27 @@ void CLASS parse_fuji (int offset)
tag = get2();
len = get2();
save = ftell(ifp);
// tag 0x100 = 256 RawImageFullSize RT
if (tag == 0x100) {
raw_height = get2();
raw_width = get2();
// RawImageCroppedSize 0x111 = 273 (including borders) RT
} else if (tag == 0x111) { // RT
read_crop.height = get2(); // RT
read_crop.width = get2(); // RT
// RawImageTopLeft 0x110 = 272 (top margin first, then left margin) RT
} else if (tag == 0x110){ // RT
read_crop.top_margin = get2(); // RT
read_crop.left_margin = get2(); // RT
// 0x115 = 277 RawImageAspectRatio RT
} else if (tag == 0x121) {
height = get2();
if ((width = get2()) == 4284) width += 3;
// tag 0x130 = 304 FujiLayout RT
} else if (tag == 0x130) {
fuji_layout = fgetc(ifp) >> 7;
fuji_width = !(fgetc(ifp) & 8);
// tag 0x131 = 305 XTransLayout RT
} else if (tag == 0x131) {
filters = 9;
FORC(36) xtrans_abs[0][35-c] = fgetc(ifp) & 3;
@ -7674,8 +7688,18 @@ void CLASS parse_fuji (int offset)
height = get4();
order = c;
}
// 0x9650 = 38480 RawExposureBias RT
fseek (ifp, save+len, SEEK_SET);
}
if (read_crop.crop_mode != CropMode::NA) { // RT
height = read_crop.height; // RT
width = read_crop.width; // RT
top_margin = read_crop.top_margin; // RT
left_margin = read_crop.left_margin; // RT
} // RT
height <<= fuji_layout;
width >>= fuji_layout;
}
@ -10133,8 +10157,12 @@ canon_a5:
width = raw_width = 6016;
height = raw_height = 4014;
} else if (!strcmp(model, "X-Pro3") || !strcmp(model, "X-T3") || !strcmp(model, "X-T30") || !strcmp(model, "X-T4") || !strcmp(model, "X100V") || !strcmp(model, "X-S10")) {
width = raw_width = 6384;
height = raw_height = 4182;
raw_width = 6384; // RT
raw_height = 4182; // RT
if (read_crop.crop_mode == CropMode::NA) { // RT
width = raw_width; // RT
height = raw_height; // RT
} // RT
} else if (!strcmp(model, "DBP for GX680")) { // Special case for #4204
width = raw_width = 5504;
height = raw_height = 3856;

View File

@ -76,6 +76,20 @@ public:
}
protected:
enum class CropMode : std::uint_fast16_t { // RT
NA = 0, // RT
FullFrameOnGfx = 1, // RT
SportsFinderMode = 2, // RT
ElectronicShutter1_25xCrop = 4 // RT
}; // RT
// stores the cropdata read from the file RT
struct CropData { // RT
std::uint_fast16_t width, // RT
height, // RT
top_margin, // RT
left_margin; // RT
CropMode crop_mode = CropMode::NA; // RT
} read_crop; // RT
int exif_base, ciff_base, ciff_len;
rtengine::IMFILE *ifp;
FILE *ofp;