File indexing completed on 2025-01-05 03:56:59

0001 /* -*- C++ -*-
0002  * Copyright 2019-2021 LibRaw LLC (info@libraw.org)
0003  *
0004 
0005  LibRaw is free software; you can redistribute it and/or modify
0006  it under the terms of the one of two licenses as you choose:
0007 
0008 1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
0009    (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
0010 
0011 2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
0012    (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
0013 
0014  */
0015 
0016 #include "../../internal/dcraw_defs.h"
0017 #include "../../internal/libraw_cameraids.h"
0018 
0019   static const struct {
0020     const int idx;
0021     const char *FormatName;
0022   } HassyRawFormat[] = {
0023     { LIBRAW_HF_Unknown, "Unknown"},
0024     { LIBRAW_HF_3FR, "-3FR"},
0025     { LIBRAW_HF_FFF, "-FFF"},
0026     { LIBRAW_HF_Imacon, "Imacon"},
0027     { LIBRAW_HF_HasselbladDNG, "hDNG"},
0028     { LIBRAW_HF_AdobeDNG, "aDNG"},
0029     { LIBRAW_HF_AdobeDNG_fromPhocusDNG, "a(hDNG)"},
0030   };
0031 
0032 const char* LibRaw::HassyRawFormat_idx2HR(unsigned idx) // HR means "human-readable"
0033 {
0034     for (int i = 0; i < int(sizeof HassyRawFormat / sizeof *HassyRawFormat); i++)
0035         if((unsigned)HassyRawFormat[i].idx == idx)
0036             return HassyRawFormat[i].FormatName;
0037     return 0;
0038 }
0039 
0040 void LibRaw::process_Hassy_Lens (int LensMount) {
0041 // long long unsigned id =
0042 //    mount*100000000ULL + series*10000000ULL +
0043 //    focal1*10000ULL + focal2*10 + version;
0044   char *ps;
0045   int c;
0046   char *q =  strchr(imgdata.lens.Lens, ' ');
0047   if(!q) return ;
0048   c = atoi(q+1);
0049   if (!c)
0050     return;
0051 
0052   if (LensMount == LIBRAW_MOUNT_Hasselblad_H) {
0053     if (imgdata.lens.Lens[2] == ' ') // HC lens
0054       ilm.LensID = LensMount*100000000ULL + 10000000ULL;
0055     else                             // HCD lens
0056       ilm.LensID = LensMount*100000000ULL + 20000000ULL;
0057     ilm.LensFormat = LIBRAW_FORMAT_645;
0058   } else if (LensMount == LIBRAW_MOUNT_Hasselblad_XCD) {
0059     ilm.LensFormat = LIBRAW_FORMAT_CROP645;
0060     ilm.LensID = LensMount*100000000ULL;
0061   } else
0062     return;
0063 
0064   ilm.LensMount = LensMount;
0065   ilm.LensID += c*10000ULL;
0066   if ((ps=strchr(imgdata.lens.Lens, '-'))) {
0067     ilm.FocalType = LIBRAW_FT_ZOOM_LENS;
0068     ilm.LensID += atoi(ps+1)*10ULL;
0069   } else {
0070     ilm.FocalType = LIBRAW_FT_PRIME_LENS;
0071     ilm.LensID += c*10ULL;
0072   }
0073   if (strstr(imgdata.lens.Lens, "III"))
0074     ilm.LensID += 3ULL;
0075   else if (strstr(imgdata.lens.Lens, "II"))
0076     ilm.LensID += 2ULL;
0077 }
0078 
0079 void LibRaw::parseHassyModel() {
0080 
0081 static const char *Hasselblad_Ctrl[] = { // manually selectable options only
0082   "ELD", "ELX", "Winder CW", "CW", "Pinhole", "Flash Sync",
0083   "SWC", "200 (Mod)", "200", "500 Mech.", "500", "H Series",
0084   "H-Series", "H1", "H2", "Black Box", "LENSCONTROL S", "LENSCTRL S", "Generic",
0085 };
0086 
0087 static const char *Hasselblad_SensorEnclosures[] = {
0088   "CFH", "CFV", "CFV", "CFII", "CF", "Ixpress",
0089 };
0090 
0091   char tmp_model[64];
0092   const char *ps;
0093   char *eos;
0094   int c;
0095   int nPix = raw_width*raw_height;
0096   int add_MP_toName = 1;
0097   int norm_model_isSet = 0;
0098 
0099   if (model[0] == ' ')
0100     memmove(model, model+1, MIN(sizeof(model)-1,strlen(model)));
0101 
0102   imHassy.HostBody[0] = 0;
0103   if ((ps = strrchr(model, '/')))
0104     strcpy(imHassy.HostBody, ps+1);
0105   else if ((ps = strrchr(imgdata.color.LocalizedCameraModel, '/')))
0106     strcpy(imHassy.HostBody, ps+1);
0107   else if ((ps = strrchr(imgdata.color.UniqueCameraModel, '/')))
0108     strcpy(imHassy.HostBody, ps+1);
0109   else if ((ps = strrchr(imHassy.SensorUnitConnector, '/')))
0110     strcpy(imHassy.HostBody, ps+1);
0111   if (imHassy.HostBody[0]) {
0112     if ((eos = strrchr(imHassy.HostBody, '-')))
0113       *eos = 0;
0114   }
0115 
0116   if (!imHassy.format) {
0117     if (dng_version) {
0118       if (!strncmp(software, "Adobe", 5)) {
0119         if (!imgdata.color.OriginalRawFileName[0] ||
0120             !imgdata.color.LocalizedCameraModel[0] ||
0121             !strcasestr(imgdata.color.UniqueCameraModel, "coated"))
0122           imHassy.format = LIBRAW_HF_AdobeDNG_fromPhocusDNG;
0123         else
0124           imHassy.format = LIBRAW_HF_AdobeDNG;
0125       } else imHassy.format = LIBRAW_HF_HasselbladDNG;
0126     } else if ((imHassy.nIFD_CM[0] != -1) &&
0127                (imHassy.nIFD_CM[1] == -1) &&
0128                !imHassy.mnColorMatrix[0][0]) {
0129       imHassy.format = LIBRAW_HF_3FR;
0130     } else imHassy.format = LIBRAW_HF_FFF;
0131   }
0132 
0133   if (imHassy.SensorUnitConnector[0]) {
0134     char buf[64];
0135     if (!strncmp(imHassy.SensorUnitConnector, "Hasselblad ", 11))
0136       memmove(imHassy.SensorUnitConnector, imHassy.SensorUnitConnector+11, 64-11);
0137     strcpy(buf, imHassy.SensorUnitConnector);
0138     if ((eos = strrchr(buf, '/'))) {
0139       *eos = 0;
0140       if ((eos = strrchr(buf, ' '))) {
0141         *eos = 0;
0142         strcpy (imHassy.SensorUnitConnector, buf);
0143       }
0144     }
0145   }
0146 
0147   if (imHassy.format == LIBRAW_HF_AdobeDNG) { // Adobe DNG, use LocalizedCameraModel
0148       imgdata.color.LocalizedCameraModel[63] = 0; // make sure it's 0-terminated
0149     if ((ps = strrchr(imgdata.color.LocalizedCameraModel, '-')))
0150       c = ps-imgdata.color.LocalizedCameraModel;
0151     else c = int(strlen(imgdata.color.LocalizedCameraModel));
0152     int cc = MIN(c, (int)sizeof(tmp_model)-1);
0153     memcpy(tmp_model, imgdata.color.LocalizedCameraModel,cc);
0154     tmp_model[cc] = 0;
0155     if (strcasestr(imgdata.color.UniqueCameraModel, "coated")) {
0156       strncpy(normalized_model, imgdata.color.UniqueCameraModel,sizeof(imgdata.color.UniqueCameraModel)-1);
0157       normalized_model[sizeof(imgdata.color.UniqueCameraModel) - 1] = 0;
0158       norm_model_isSet = 1;
0159     }
0160       if (!strncmp(normalized_model, "Hasselblad ", 11))
0161         memmove(normalized_model, normalized_model+11, 64-11);
0162   } else {
0163     if ((ps = strrchr(imgdata.color.UniqueCameraModel, '/'))) {
0164       c = ps-imgdata.color.UniqueCameraModel;
0165     }
0166     else c = int(strlen(imgdata.color.UniqueCameraModel));
0167     int cc = MIN(c, (int)sizeof(tmp_model)-1);
0168     memcpy(tmp_model, imgdata.color.UniqueCameraModel,cc);
0169     tmp_model[cc] = 0;
0170   }
0171   if (!strncasecmp(tmp_model, "Hasselblad ", 11))
0172     memmove(tmp_model, tmp_model+11, 64-11);
0173 
0174   strncpy(imHassy.CaptureSequenceInitiator, model,31);
0175   imHassy.CaptureSequenceInitiator[31] = 0;
0176   if ((eos = strrchr(imHassy.CaptureSequenceInitiator, '/'))) {
0177     *eos = 0;
0178   }
0179 // check if model tag contains manual CaptureSequenceInitiator info:
0180   FORC(int(sizeof Hasselblad_Ctrl / sizeof *Hasselblad_Ctrl)) {
0181     if (strcasestr(model, Hasselblad_Ctrl[c])) {
0182 // yes, fill 'model' with sensor unit data
0183       strncpy(model, tmp_model,63);
0184       model[63] = 0;
0185       break;
0186     }
0187   }
0188 
0189   if (!imHassy.HostBody[0]) {
0190     ps = strchr(model, '-');
0191     if (ps) {                  // check if model contains both host body and sensor version, resolution, MS info
0192       strncpy(imHassy.SensorUnit, model,63);
0193       memcpy(imHassy.HostBody, model, ps-model);
0194       imHassy.HostBody[ps-model] = 0;
0195       if (!strncmp(ps-2, "II-", 3))
0196         ps -=2;
0197       strncpy(imHassy.Sensor, ps,7);
0198       imHassy.Sensor[7] = 0;
0199       add_MP_toName = 0;
0200     } else { // model contains host body only
0201       strncpy(imHassy.HostBody, model,63);
0202       imHassy.HostBody[63] = 0;
0203   // fill 'model' with sensor unit data
0204       strncpy(model, tmp_model,63);
0205       model[63] = 0;
0206     }
0207   }
0208 
0209   if (strstr(model, "503CWD")) {
0210     strncpy(imHassy.HostBody, model,63);
0211     imHassy.HostBody[63] = 0;
0212     ilm.CameraFormat = LIBRAW_FORMAT_66;
0213     ilm.CameraMount = LIBRAW_MOUNT_Hasselblad_V;
0214     if (model[6] == 'I' && model[7] == 'I')
0215       strcpy(model, "CFVII");
0216     else strcpy(model, "CFV");
0217   } else if (strstr(model, "Hasselblad") &&
0218              (model[10] != ' ')) {
0219     strcpy(model, "CFV");
0220     ilm.CameraMount = LIBRAW_MOUNT_DigitalBack;
0221   } else {
0222     FORC(int(sizeof Hasselblad_SensorEnclosures / sizeof *Hasselblad_SensorEnclosures)) {
0223       if (strcasestr(model, Hasselblad_SensorEnclosures[c])) {
0224         if (add_MP_toName) strcpy(model, Hasselblad_SensorEnclosures[c]);
0225         ilm.CameraMount = LIBRAW_MOUNT_DigitalBack;
0226         break;
0227       }
0228     }
0229   }
0230 
0231 #define cpynorm(str)                \
0232   if (!norm_model_isSet) {          \
0233     strcpy(normalized_model, str);  \
0234     norm_model_isSet = 1;           \
0235   }
0236 
0237   if ((imHassy.SensorCode == 4) &&
0238       (imHassy.CoatingCode < 2)) {
0239     strcpy(imHassy.Sensor, "-16");
0240     cpynorm("16-Uncoated");
0241 
0242   } else if ((imHassy.SensorCode == 6) &&
0243              (imHassy.CoatingCode < 2)) {
0244     strcpy(imHassy.Sensor, "-22");
0245     cpynorm("22-Uncoated");
0246 
0247   } else if ((imHassy.SensorCode == 8) &&
0248              (imHassy.CoatingCode == 1)) {
0249     strcpy(imHassy.Sensor, "-31");
0250     cpynorm("31-Uncoated");
0251 
0252   } else if ((imHassy.SensorCode == 9) &&
0253              (imHassy.CoatingCode < 2)) {
0254     strcpy(imHassy.Sensor, "-39");
0255     cpynorm("39-Uncoated");
0256 
0257   } else if ((imHassy.SensorCode == 9) &&
0258              (imHassy.CoatingCode == 4)) {
0259     strcpy(imHassy.Sensor, "-39");
0260     strcpy(model, "H3DII");
0261     add_MP_toName = 1;
0262     cpynorm("39-Coated");
0263 
0264   } else if ((imHassy.SensorCode == 13) &&
0265              (imHassy.CoatingCode == 4)) {
0266     strcpy(imHassy.Sensor, "-40");
0267     cpynorm("40-Coated");
0268 
0269   } else if ((imHassy.SensorCode == 13) &&
0270              (imHassy.CoatingCode == 5)) {
0271     strcpy(imHassy.Sensor, "-40");
0272     cpynorm("40-Coated5");
0273 
0274   } else if ((imHassy.SensorCode == 11) &&
0275              (imHassy.CoatingCode == 4)) {
0276     if (!strncmp(model, "H3D", 3))
0277       strcpy(model, "H3DII-50");
0278     else strcpy(imHassy.Sensor, "-50");
0279     cpynorm("50-Coated");
0280 
0281   } else if ((imHassy.SensorCode == 11) &&
0282              (imHassy.CoatingCode == 5)) {
0283     strcpy(imHassy.Sensor, "-50");
0284     cpynorm("50-Coated5");
0285 
0286   } else if ((imHassy.SensorCode == 15) &&
0287              (imHassy.CoatingCode == 5)) {
0288     strcpy(imHassy.Sensor, "-50c");
0289     cpynorm("50-15-Coated5");
0290     if (!strncmp(imHassy.CaptureSequenceInitiator, "CFV II 50C", 10)) {
0291       imHassy.SensorSubCode = 2;
0292       add_MP_toName = 0;
0293       strcat(imHassy.Sensor, " II");
0294       strcpy(model, "CFV II 50C");
0295       strcat(normalized_model, "-II");
0296     } else if (!strncmp(imHassy.CaptureSequenceInitiator, "X1D", 3)) {
0297       imHassy.SensorSubCode = 2;
0298       add_MP_toName = 0;
0299       strcat(imHassy.Sensor, " II");
0300       if (!strncasecmp(imHassy.CaptureSequenceInitiator, "X1D II 50C", 10)) {
0301         strcpy(model, "X1D II 50C");
0302         strcat(normalized_model, "-II");
0303       } else {
0304         strcpy(model, "X1D-50c");
0305       }
0306     }
0307 
0308   } else if ((imHassy.SensorCode == 12) &&
0309              (imHassy.CoatingCode == 4)) {
0310     strcpy(imHassy.Sensor, "-60");
0311     cpynorm("60-Coated");
0312 
0313   } else if ((imHassy.SensorCode == 17) &&
0314              (imHassy.CoatingCode == 5)) {
0315     strcpy(imHassy.Sensor, "-100c");
0316     cpynorm("100-17-Coated5");
0317 
0318   } else if ((raw_width == 4090) || // V96C
0319              ((raw_width == 4096) && (raw_height == 4096)) ||
0320              ((raw_width == 4088) && (raw_height == 4088)) || // Adobe crop
0321              ((raw_width == 4080) && (raw_height == 4080))) { // Phocus crop
0322     strcpy(imHassy.Sensor, "-16");
0323     cpynorm("16-Uncoated");
0324     if (!imHassy.SensorCode) imHassy.SensorCode = 4;
0325 
0326   } else if ((raw_width == 5568) && (raw_height == 3648)) {
0327     strcpy(imHassy.Sensor, "-20c");
0328 
0329   } else if (((raw_width == 4096) && (raw_height == 5456)) ||
0330              ((raw_width == 4088) && (raw_height == 5448)) ||  // Adobe crop
0331              ((raw_width == 4080) && (raw_height == 5440))) {  // Phocus crop
0332     strcpy(imHassy.Sensor, "-22");
0333     cpynorm("22-Uncoated");
0334     if (!imHassy.SensorCode) imHassy.SensorCode = 6;
0335 
0336   } else if (((raw_width == 6542) && (raw_height == 4916)) ||
0337              ((raw_width == 6504) && (raw_height == 4880)) || // Adobe crop
0338              ((raw_width == 6496) && (raw_height == 4872))) { // Phocus crop
0339     strcpy(imHassy.Sensor, "-31");
0340     cpynorm("31-Uncoated");
0341     if (!imHassy.SensorCode) imHassy.SensorCode = 8;
0342 
0343   } else if (((raw_width == 7262) && (raw_height == 5456)) || //
0344              ((raw_width == 7224) && (raw_height == 5420)) || // Adobe crop
0345              ((raw_width == 7216) && (raw_height == 5412)) || // Phocus crop
0346              ((raw_width == 7212) && (raw_height == 5412)) || // CF-39, CFV-39, possibly v.II; Phocus crop
0347 // uncropped, when the exact size is unknown, should be:
0348 // - greater or equal to the smallest Phocus crop for the current size
0349 // - smaller than the smallest Phocus crop for the next size
0350            ((nPix >= 7212*5412) && (nPix < 7304*5478))) {
0351     strcpy(imHassy.Sensor, "-39");
0352     if (!imHassy.SensorCode) imHassy.SensorCode = 9;
0353     if (!strncmp(model, "H3D", 3)) {
0354       if (((imHassy.format == LIBRAW_HF_Imacon) ||
0355           strstr(imgdata.color.UniqueCameraModel, "H3D-39") ||
0356           strstr(imgdata.color.LocalizedCameraModel, "H3D-39") ||
0357           strstr(model, "H3D-39")) &&
0358           !strstr(imgdata.color.UniqueCameraModel, "II") &&
0359           !strstr(imgdata.color.LocalizedCameraModel, "II") &&
0360           !strstr(model, "II")) {
0361         strcpy(model, "H3D-39");
0362         add_MP_toName = 0;
0363         cpynorm("39-Uncoated");
0364 
0365       } else {
0366         strcpy(model, "H3DII-39");
0367         add_MP_toName = 0;
0368         cpynorm("39-Coated");
0369         if (!imHassy.CoatingCode) imHassy.CoatingCode = 4;
0370       }
0371 
0372     } else
0373       cpynorm("39-Uncoated");
0374 
0375   } else if (((raw_width == 7410) && (raw_height == 5586)) || // (H4D-40, H5D-40)
0376              ((raw_width == 7312) && (raw_height == 5486)) || // Adobe crop
0377              ((raw_width == 7304) && (raw_height == 5478))) { // Phocus crop
0378     strcpy(imHassy.Sensor, "-40");
0379     if (!strncmp(model, "H4D", 3)) {
0380       cpynorm("40-Coated");
0381       if (!imHassy.SensorCode) imHassy.SensorCode = 13;
0382       if (!imHassy.CoatingCode) imHassy.CoatingCode = 4;
0383     } else {
0384       cpynorm("40-Coated5");
0385       if (!imHassy.SensorCode) imHassy.SensorCode = 13;
0386       if (!imHassy.CoatingCode) imHassy.CoatingCode = 5;
0387     }
0388 
0389   } else if (((raw_width == 8282) && (raw_height == 6240)) || // (CFV-50, H3DII-50, H5D-50)
0390              ((raw_width == 8184) && (raw_height == 6140)) || // Adobe crop
0391              ((raw_width == 8176) && (raw_height == 6132))) { // Phocus crop
0392     strcpy(imHassy.Sensor, "-50");
0393     if (!strncmp(model, "H5D", 3)) {
0394       cpynorm("50-Coated5");
0395       if (!imHassy.SensorCode) imHassy.SensorCode = 11;
0396       if (!imHassy.CoatingCode) imHassy.CoatingCode = 5;
0397     } else {
0398       cpynorm("50-Coated"); // CFV-50, H3DII-50,
0399       if (!strncmp(model, "H3D", 3)) {
0400         strcpy(model, "H3DII-50");
0401       if (!imHassy.SensorCode) imHassy.SensorCode = 11;
0402       if (!imHassy.CoatingCode) imHassy.CoatingCode = 4;
0403         add_MP_toName = 0;
0404       }
0405     }
0406 
0407   } else if (((raw_width == 8374) && (raw_height == 6304)) ||  // (H5D-50c)
0408              ((raw_width == 8384) && (raw_height == 6304)) ||  // (X1D-50c, "X1D II 50C", "CFV II 50C")
0409              ((raw_width == 8280) && (raw_height == 6208)) ||  // Adobe crop
0410              ((raw_width == 8272) && (raw_height == 6200))) {  // Phocus crop
0411     cpynorm("50-15-Coated5");
0412     if (!imHassy.SensorCode) imHassy.SensorCode = 15;
0413     if (!imHassy.CoatingCode) imHassy.CoatingCode = 5;
0414     strcpy(imHassy.Sensor, "-50c");
0415     if ((raw_width == 8384) ||
0416         !strncmp(imHassy.CaptureSequenceInitiator, "X1D", 3) ||
0417         !strncmp(imHassy.CaptureSequenceInitiator, "CFV II", 6)) {
0418       imHassy.SensorSubCode = 2;
0419       add_MP_toName = 0;
0420       strcat(imHassy.Sensor, " II");
0421       if (strstr(imHassy.CaptureSequenceInitiator, " II ")) {
0422           strcat(normalized_model, "-II");
0423         if (!strncasecmp(imHassy.CaptureSequenceInitiator, "X1D II 50C", 10)) {
0424           strcpy(model, "X1D II 50C");
0425         } else if (!strncasecmp(imHassy.CaptureSequenceInitiator, "CFV II 50C", 10)) {
0426           strcpy(model, "CFV II 50C");
0427         }
0428       } else {
0429         strcpy(model, "X1D-50c");
0430       }
0431     }
0432 
0433   } else if (((raw_width == 9044) && (raw_height == 6732)) ||
0434              ((raw_width == 8964) && (raw_height == 6716)) || // Adobe crop
0435              ((raw_width == 8956) && (raw_height == 6708))) { // Phocus crop
0436     strcpy(imHassy.Sensor, "-60");
0437     cpynorm("60-Coated");
0438     if (!imHassy.SensorCode) imHassy.SensorCode = 12;
0439     if (!imHassy.CoatingCode) imHassy.CoatingCode = 4;
0440 
0441 
0442   } else if (((raw_width == 10320) && (raw_height == 7752)) || // Phocus crop, A5D-80
0443              ((nPix >= 10320*7752) && (nPix < 10520*8000))) {
0444     strcpy(imHassy.Sensor, "-80");
0445     cpynorm("80-Coated");
0446 
0447   } else if (((raw_width == 12000) && (raw_height == 8816)) ||
0448              ((raw_width == 11608) && (raw_height == 8708)) || // Adobe crop
0449              ((raw_width == 11600) && (raw_height == 8700))) {  // Phocus crop
0450     strcpy(imHassy.Sensor, "-100c");
0451     cpynorm("100-17-Coated5");
0452     if (!imHassy.SensorCode) imHassy.SensorCode = 17;
0453     if (!imHassy.CoatingCode) imHassy.CoatingCode = 5;
0454 
0455   }
0456 
0457   if (raw_width == 4090)
0458     strcpy(model, "V96C");
0459 
0460   if (
0461     (raw_width == 4090) ||
0462         ((raw_width ==  4096) && (raw_height ==  4096)) ||
0463         ((raw_width ==  5568) && (raw_height ==  3648)) ||
0464         ((raw_width ==  4096) && (raw_height ==  5456)) ||
0465         ((raw_width ==  6542) && (raw_height ==  4916)) ||
0466         ((raw_width ==  7262) && (raw_height ==  5456)) ||
0467         ((raw_width ==  7410) && (raw_height ==  5586)) ||
0468         ((raw_width ==  8282) && (raw_height ==  6240)) ||
0469         ((raw_width ==  8374) && (raw_height ==  6304)) ||
0470         ((raw_width ==  8384) && (raw_height ==  6304)) ||
0471         ((raw_width ==  9044) && (raw_height ==  6732)) ||
0472         ((raw_width == 10320) && (raw_height ==  7752)) ||
0473         ((raw_width == 12000) && (raw_height ==  8816))
0474     )
0475     imHassy.uncropped = 1;
0476 
0477 
0478   if (model[0] && add_MP_toName)
0479     strcat(model, imHassy.Sensor);
0480   if (imHassy.Sensor[0] == '-')
0481     memmove(imHassy.Sensor, imHassy.Sensor+1, strlen(imHassy.Sensor));
0482 
0483   if (dng_version &&
0484       (imHassy.SensorCode == 13) &&
0485       (imHassy.CoatingCode == 4)) {
0486     c = LIBRAW_HF_AdobeDNG;
0487   } else if ((imHassy.format == LIBRAW_HF_HasselbladDNG) ||
0488              (imHassy.format == LIBRAW_HF_AdobeDNG_fromPhocusDNG)) {
0489     c = LIBRAW_HF_FFF;
0490   } else if (imHassy.format == LIBRAW_HF_Imacon) {
0491     c = LIBRAW_HF_3FR;
0492   } else {
0493     c = imHassy.format;
0494   }
0495   ps = HassyRawFormat_idx2HR(c);
0496   if ((c == LIBRAW_HF_3FR) ||
0497       (c == LIBRAW_HF_FFF))
0498     strcat(normalized_model, ps);
0499 
0500   if (((imHassy.CaptureSequenceInitiator[0] == 'H') &&
0501        (imHassy.CaptureSequenceInitiator[1] != 'a')) ||
0502       ((imHassy.CaptureSequenceInitiator[0] == 'A') &&
0503        isdigit(imHassy.CaptureSequenceInitiator[1]))) {
0504     ilm.CameraFormat = LIBRAW_FORMAT_645;
0505     ilm.CameraMount = LIBRAW_MOUNT_Hasselblad_H;
0506     if (imgdata.lens.Lens[0] == 'H')
0507       process_Hassy_Lens(LIBRAW_MOUNT_Hasselblad_H);
0508   } else if (((imHassy.CaptureSequenceInitiator[0] == 'X') &&
0509               isdigit(imHassy.CaptureSequenceInitiator[1])) ||
0510              !strncmp(imHassy.HostBody, "907", 3)) {
0511     ilm.CameraFormat = LIBRAW_FORMAT_CROP645;
0512     ilm.CameraMount = LIBRAW_MOUNT_Hasselblad_XCD;
0513     if (imgdata.lens.Lens[0] == 'H') {
0514       process_Hassy_Lens(LIBRAW_MOUNT_Hasselblad_H);
0515       strcpy(ilm.Adapter, "XH");
0516     } else {
0517       if (imgdata.lens.Lens[0] == 'X') {
0518         process_Hassy_Lens(LIBRAW_MOUNT_Hasselblad_XCD);
0519       } else if (!imgdata.lens.Lens[0] &&
0520                  (aperture > 1.0f)   &&
0521                  (focal_len > 10.0f)) {
0522         ilm.LensID = focal_len;
0523         if (ilm.LensID == 35) {
0524           ilm.FocalType = LIBRAW_FT_ZOOM_LENS;
0525           ilm.LensID = LIBRAW_MOUNT_Hasselblad_XCD*100000000ULL +
0526                        35*10000ULL + 75*10;
0527         }
0528         else {
0529           ilm.FocalType = LIBRAW_FT_PRIME_LENS;
0530           ilm.LensID = LIBRAW_MOUNT_Hasselblad_XCD*100000000ULL +
0531                        ilm.LensID*10000ULL + ilm.LensID*10;
0532         }
0533       }
0534     }
0535   }
0536   if (normalized_model[0]  && !CM_found)
0537     CM_found = adobe_coeff(maker_index, normalized_model);
0538 }