File indexing completed on 2025-01-05 03:57:03

0001 /* -*- C++ -*-
0002  * Copyright 2019-2021 LibRaw LLC (info@libraw.org)
0003  *
0004  LibRaw is free software; you can redistribute it and/or modify
0005  it under the terms of the one of two licenses as you choose:
0006 
0007 1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
0008    (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
0009 
0010 2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
0011    (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
0012 
0013  */
0014 
0015 #include "../../internal/dcraw_defs.h"
0016 #include "../../internal/libraw_cameraids.h"
0017 
0018 void LibRaw::setOlympusBodyFeatures(unsigned long long id)
0019 {
0020   ilm.CamID = id;
0021 
0022   if ((id == OlyID_E_1)   ||
0023       (id == OlyID_E_300) ||
0024       ((id & 0x00ffff0000ULL) == 0x0030300000ULL))
0025   {
0026     ilm.CameraFormat = LIBRAW_FORMAT_FT;
0027 
0028     if ((id == OlyID_E_1)   ||
0029         (id == OlyID_E_300) ||
0030         ((id >= OlyID_E_330) && (id <= OlyID_E_520)) ||
0031         (id == OlyID_E_620) ||
0032         (id == OlyID_E_450) ||
0033         (id == OlyID_E_600) ||
0034         (id == OlyID_E_5))
0035     {
0036       ilm.CameraMount = LIBRAW_MOUNT_FT;
0037     }
0038     else
0039     {
0040       ilm.CameraMount = LIBRAW_MOUNT_mFT;
0041     }
0042   }
0043   else
0044   {
0045     ilm.LensMount = ilm.CameraMount = LIBRAW_MOUNT_FixedLens;
0046   }
0047   return;
0048 }
0049 
0050 void LibRaw::getOlympus_CameraType2()
0051 {
0052 
0053   if (OlyID != 0x0ULL)
0054     return;
0055 
0056   int i = 0;
0057   fread(imOly.CameraType2, 6, 1, ifp);
0058   imOly.CameraType2[5] = 0;
0059   while ((i < 6) && imOly.CameraType2[i])
0060   {
0061     OlyID = OlyID << 8 | imOly.CameraType2[i];
0062     if (i < 5 && isspace(imOly.CameraType2[i + 1])) {
0063       imOly.CameraType2[i + 1] = '\0';
0064       break;
0065     }
0066     i++;
0067   }
0068   if (OlyID == OlyID_NORMA) {
0069     if (strcmp(model, "SP510UZ")) OlyID = OlyID_SP_510UZ;
0070     else OlyID = 0x0ULL;
0071   }
0072   unique_id = OlyID;
0073   setOlympusBodyFeatures(OlyID);
0074   return;
0075 }
0076 
0077 void LibRaw::getOlympus_SensorTemperature(unsigned len)
0078 {
0079   if (OlyID != 0x0ULL)
0080   {
0081     short temp = get2();
0082     if ((OlyID == OlyID_E_1)  ||
0083         (OlyID == OlyID_E_M5) ||
0084         (len != 1))
0085       imCommon.SensorTemperature = (float)temp;
0086     else if ((temp != -32768) && (temp != 0))
0087     {
0088       if (temp > 199)
0089         imCommon.SensorTemperature = 86.474958f - 0.120228f * (float)temp;
0090       else
0091         imCommon.SensorTemperature = (float)temp;
0092     }
0093   }
0094   return;
0095 }
0096 
0097 void LibRaw::parseOlympus_Equipment(unsigned tag, unsigned /*type */, unsigned len,
0098                                     unsigned dng_writer)
0099 {
0100   // uptag 2010
0101 
0102   switch (tag)
0103   {
0104   case 0x0100:
0105     getOlympus_CameraType2();
0106     break;
0107   case 0x0101:
0108     if ((!imgdata.shootinginfo.BodySerial[0]) && (dng_writer == nonDNG))
0109       stmread(imgdata.shootinginfo.BodySerial, len, ifp);
0110     break;
0111   case 0x0102:
0112     stmread(imgdata.shootinginfo.InternalBodySerial, len, ifp);
0113     break;
0114   case 0x0201:
0115   {
0116     unsigned char bits[4];
0117     fread(bits, 1, 4, ifp);
0118     ilm.LensID = (unsigned long long)bits[0] << 16 |
0119                  (unsigned long long)bits[2] << 8 | (unsigned long long)bits[3];
0120     ilm.LensMount = LIBRAW_MOUNT_FT;
0121     ilm.LensFormat = LIBRAW_FORMAT_FT;
0122     if (((ilm.LensID < 0x20000) || (ilm.LensID > 0x4ffff)) &&
0123         (ilm.LensID & 0x10))
0124       ilm.LensMount = LIBRAW_MOUNT_mFT;
0125   }
0126     break;
0127   case 0x0202:
0128     if ((!imgdata.lens.LensSerial[0]))
0129       stmread(imgdata.lens.LensSerial, len, ifp);
0130     break;
0131   case 0x0203:
0132     stmread(ilm.Lens, len, ifp);
0133     break;
0134   case 0x0205:
0135     ilm.MaxAp4MinFocal = libraw_powf64l(sqrt(2.0f), get2() / 256.0f);
0136     break;
0137   case 0x0206:
0138     ilm.MaxAp4MaxFocal = libraw_powf64l(sqrt(2.0f), get2() / 256.0f);
0139     break;
0140   case 0x0207:
0141     ilm.MinFocal = (float)get2();
0142     break;
0143   case 0x0208:
0144     ilm.MaxFocal = (float)get2();
0145     if (ilm.MaxFocal > 1000.0f)
0146       ilm.MaxFocal = ilm.MinFocal;
0147     break;
0148   case 0x020a:
0149     ilm.MaxAp4CurFocal = libraw_powf64l(sqrt(2.0f), get2() / 256.0f);
0150     break;
0151   case 0x0301:
0152     ilm.TeleconverterID = fgetc(ifp) << 8;
0153     fgetc(ifp);
0154     ilm.TeleconverterID = ilm.TeleconverterID | fgetc(ifp);
0155     break;
0156   case 0x0303:
0157     stmread(ilm.Teleconverter, len, ifp);
0158     if (!strlen(ilm.Teleconverter) && strchr(ilm.Lens, '+')) {
0159       if (strstr(ilm.Lens, "MC-20"))
0160         strcpy(ilm.Teleconverter, "MC-20");
0161       else if (strstr(ilm.Lens, "MC-14"))
0162         strcpy(ilm.Teleconverter, "MC-14");
0163       else if (strstr(ilm.Lens, "EC-20"))
0164         strcpy(ilm.Teleconverter, "EC-20");
0165       else if (strstr(ilm.Lens, "EC-14"))
0166         strcpy(ilm.Teleconverter, "EC-14");    }
0167     break;
0168   case 0x0403:
0169     stmread(ilm.Attachment, len, ifp);
0170     break;
0171   }
0172 
0173   return;
0174 }
0175 void LibRaw::parseOlympus_CameraSettings(int base, unsigned tag, unsigned type,
0176                                          unsigned len, unsigned dng_writer)
0177 {
0178   // uptag 0x2020
0179 
0180   int c;
0181   switch (tag)
0182   {
0183   case 0x0101:
0184     if (dng_writer == nonDNG)
0185     {
0186       thumb_offset = get4() + base;
0187     }
0188     break;
0189   case 0x0102:
0190     if (dng_writer == nonDNG)
0191     {
0192       thumb_length = get4();
0193     }
0194     break;
0195   case 0x0200:
0196     imgdata.shootinginfo.ExposureMode = get2();
0197     break;
0198   case 0x0202:
0199     imgdata.shootinginfo.MeteringMode = get2();
0200     break;
0201   case 0x0301:
0202     imgdata.shootinginfo.FocusMode = imOly.FocusMode[0] = get2();
0203     if (len == 2)
0204     {
0205       imOly.FocusMode[1] = get2();
0206     }
0207     break;
0208   case 0x0304:
0209     for (c = 0; c < 64; c++)
0210     {
0211       imOly.AFAreas[c] = get4();
0212     }
0213     break;
0214   case 0x0305:
0215     for (c = 0; c < 5; c++)
0216     {
0217       imOly.AFPointSelected[c] = getreal(type);
0218     }
0219     break;
0220   case 0x0306:
0221     imOly.AFFineTune = fgetc(ifp);
0222     break;
0223   case 0x0307:
0224     FORC3 imOly.AFFineTuneAdj[c] = get2();
0225     break;
0226   case 0x0401:
0227     imCommon.FlashEC = getreal(type);
0228     break;
0229   case 0x0507:
0230     imOly.ColorSpace = get2();
0231     switch (imOly.ColorSpace) {
0232     case 0:
0233       imCommon.ColorSpace = LIBRAW_COLORSPACE_sRGB;
0234       break;
0235     case 1:
0236       imCommon.ColorSpace = LIBRAW_COLORSPACE_AdobeRGB;
0237       break;
0238     case 2:
0239       imCommon.ColorSpace = LIBRAW_COLORSPACE_ProPhotoRGB;
0240       break;
0241     default:
0242       imCommon.ColorSpace = LIBRAW_COLORSPACE_Unknown;
0243       break;
0244     }
0245     break;
0246   case 0x0600:
0247     imgdata.shootinginfo.DriveMode = imOly.DriveMode[0] = get2();
0248     for (c = 1; c < (int)len && c < 5; c++)
0249     {
0250       imOly.DriveMode[c] = get2();
0251     }
0252     break;
0253   case 0x0601:
0254     imOly.Panorama_mode = get2();
0255     imOly.Panorama_frameNum = get2();
0256     break;
0257   case 0x0604:
0258     imgdata.shootinginfo.ImageStabilization = get4();
0259     break;
0260   case 0x0804:
0261     imOly.StackedImage[0] = get4();
0262     imOly.StackedImage[1] = get4();
0263     if (imOly.StackedImage[0] == 3) {
0264       imOly.isLiveND = 1;
0265       imOly.LiveNDfactor = imOly.StackedImage[1];
0266     } else {
0267       imOly.isLiveND = 0;
0268     }
0269     break;
0270   }
0271 
0272   return;
0273 }
0274 
0275 void LibRaw::parseOlympus_ImageProcessing(unsigned tag, unsigned type,
0276                                           unsigned len, unsigned dng_writer)
0277 {
0278   // uptag 0x2040
0279 
0280   int i, c, wb[4], nWB, tWB, wbG;
0281   ushort CT;
0282   short sorder;
0283 
0284   if ((tag == 0x0100) && (dng_writer == nonDNG))
0285   {
0286     cam_mul[0] = get2() / 256.0;
0287     cam_mul[2] = get2() / 256.0;
0288   }
0289   else if ((tag == 0x0101) && (len == 2) &&
0290            ((OlyID == OlyID_E_410) || (OlyID == OlyID_E_510)))
0291   {
0292     for (i = 0; i < 64; i++)
0293     {
0294       icWBCCTC[i][2] = icWBCCTC[i][4] = icWBC[i][1] = icWBC[i][3] = 0x100;
0295     }
0296     for (i = 64; i < 256; i++)
0297     {
0298       icWBC[i][1] = icWBC[i][3] = 0x100;
0299     }
0300   }
0301   else if ((tag > 0x0101) && (tag <= 0x0111))
0302   {
0303     nWB = tag - 0x0101;
0304     tWB = Oly_wb_list2[nWB << 1];
0305     CT = Oly_wb_list2[(nWB << 1) | 1];
0306     wb[0] = get2();
0307     wb[2] = get2();
0308     if (tWB != 0x100)
0309     {
0310       icWBC[tWB][0] = wb[0];
0311       icWBC[tWB][2] = wb[2];
0312     }
0313     if (CT)
0314     {
0315       icWBCCTC[nWB - 1][0] = CT;
0316       icWBCCTC[nWB - 1][1] = wb[0];
0317       icWBCCTC[nWB - 1][3] = wb[2];
0318     }
0319     if (len == 4)
0320     {
0321       wb[1] = get2();
0322       wb[3] = get2();
0323       if (tWB != 0x100)
0324       {
0325         icWBC[tWB][1] = wb[1];
0326         icWBC[tWB][3] = wb[3];
0327       }
0328       if (CT)
0329       {
0330         icWBCCTC[nWB - 1][2] = wb[1];
0331         icWBCCTC[nWB - 1][4] = wb[3];
0332       }
0333     }
0334   }
0335   else if ((tag >= 0x0112) && (tag <= 0x011e))
0336   {
0337     nWB = tag - 0x0112;
0338     wbG = get2();
0339     tWB = Oly_wb_list2[nWB << 1];
0340     if (nWB)
0341       icWBCCTC[nWB - 1][2] = icWBCCTC[nWB - 1][4] = wbG;
0342     if (tWB != 0x100)
0343       icWBC[tWB][1] = icWBC[tWB][3] = wbG;
0344   }
0345   else if (tag == 0x011f)
0346   {
0347     wbG = get2();
0348     if (icWBC[LIBRAW_WBI_Flash][0])
0349       icWBC[LIBRAW_WBI_Flash][1] =
0350           icWBC[LIBRAW_WBI_Flash][3] = wbG;
0351     FORC4 if (icWBC[LIBRAW_WBI_Custom1 + c][0])
0352         icWBC[LIBRAW_WBI_Custom1 + c][1] =
0353         icWBC[LIBRAW_WBI_Custom1 + c][3] = wbG;
0354   }
0355   else if (tag == 0x0121)
0356   {
0357     icWBC[LIBRAW_WBI_Flash][0] = get2();
0358     icWBC[LIBRAW_WBI_Flash][2] = get2();
0359     if (len == 4)
0360     {
0361       icWBC[LIBRAW_WBI_Flash][1] = get2();
0362       icWBC[LIBRAW_WBI_Flash][3] = get2();
0363     }
0364   }
0365   else if ((tag == 0x0200) && (dng_writer == nonDNG) &&
0366            strcmp(software, "v757-71"))
0367   {
0368     for (i = 0; i < 3; i++)
0369     {
0370       if (!imOly.ColorSpace)
0371       {
0372         FORC3 cmatrix[i][c] = ((short)get2()) / 256.0;
0373       }
0374       else
0375       {
0376         FORC3 imgdata.color.ccm[i][c] = ((short)get2()) / 256.0;
0377       }
0378     }
0379   }
0380   else if ((tag == 0x0600) && (dng_writer == nonDNG))
0381   {
0382     FORC4 cblack[RGGB_2_RGBG(c)] = get2();
0383   }
0384   else if ((tag == 0x0611) && (dng_writer == nonDNG))
0385   {
0386      imOly.ValidBits = get2();
0387   }
0388   else if ((tag == 0x0612) && (dng_writer == nonDNG))
0389   {
0390     imgdata.sizes.raw_inset_crops[0].cleft = get2();
0391   }
0392   else if ((tag == 0x0613) && (dng_writer == nonDNG))
0393   {
0394     imgdata.sizes.raw_inset_crops[0].ctop = get2();
0395   }
0396   else if ((tag == 0x0614) && (dng_writer == nonDNG))
0397   {
0398     imgdata.sizes.raw_inset_crops[0].cwidth = get2();
0399   }
0400   else if ((tag == 0x0615) && (dng_writer == nonDNG))
0401   {
0402     imgdata.sizes.raw_inset_crops[0].cheight = get2();
0403   }
0404   else if ((tag == 0x0805) && (len == 2))
0405   {
0406     imOly.SensorCalibration[0] = getreal(type);
0407     imOly.SensorCalibration[1] = getreal(type);
0408     if ((dng_writer == nonDNG) && (OlyID != OlyID_XZ_1))
0409       FORC4 imgdata.color.linear_max[c] = imOly.SensorCalibration[0];
0410   }
0411   else if (tag == 0x1112)
0412   {
0413     sorder = order;
0414     order = 0x4d4d;
0415     c = get2();
0416     order = sorder;
0417     switch (c) {
0418     case 0x0101:
0419     case 0x0901:
0420     case 0x0909:
0421       imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_4to3;
0422       break;
0423     case 0x0104:
0424     case 0x0401:
0425       imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_1to1;
0426       break;
0427     case 0x0201:
0428     case 0x0202:
0429       imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_3to2;
0430       break;
0431     case 0x0301:
0432     case 0x0303:
0433       imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_16to9;
0434       break;
0435     case 0x0404:
0436 //      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_6to6;
0437         imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_1to1;
0438       break;
0439     case 0x0505:
0440       imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_5to4;
0441       break;
0442     case 0x0606:
0443       imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_7to6;
0444       break;
0445     case 0x0707:
0446       imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_6to5;
0447       break;
0448     case 0x0808:
0449       imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_7to5;
0450       break;
0451     default:
0452       imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_OTHER;
0453       break;
0454     }
0455   }
0456   else if (tag == 0x1113)
0457   {
0458     imOly.AspectFrame[0] = get2();
0459     imOly.AspectFrame[1] = get2();
0460     imOly.AspectFrame[2] = get2();
0461     imOly.AspectFrame[3] = get2();
0462   }
0463   else if (tag == 0x1306)
0464   {
0465     c = get2();
0466     if ((c != 0) && (c != 100))
0467     {
0468       if (c < 61)
0469         imCommon.CameraTemperature = (float)c;
0470       else
0471         imCommon.CameraTemperature = (float)(c - 32) / 1.8f;
0472       if ((imCommon.exifAmbientTemperature > -273.15f) &&
0473           ((OlyID == OlyID_TG_5) ||
0474            (OlyID == OlyID_TG_6))
0475       )
0476         imCommon.CameraTemperature += imCommon.exifAmbientTemperature;
0477     }
0478   }
0479 
0480   return;
0481 }
0482 
0483 void LibRaw::parseOlympus_RawInfo(unsigned tag, unsigned /*type */, unsigned len,
0484                                   unsigned dng_writer)
0485 {
0486   // uptag 0x3000
0487 
0488   int wb_ind, c, i;
0489 
0490   if ((tag == 0x0110) && strcmp(software, "v757-71"))
0491   {
0492     icWBC[LIBRAW_WBI_Auto][0] = get2();
0493     icWBC[LIBRAW_WBI_Auto][2] = get2();
0494     if (len == 2)
0495     {
0496       for (i = 0; i < 256; i++)
0497         icWBC[i][1] = icWBC[i][3] = 0x100;
0498     }
0499   }
0500   else if ((((tag >= 0x0120) && (tag <= 0x0124)) ||
0501             ((tag >= 0x0130) && (tag <= 0x0133))) &&
0502            strcmp(software, "v757-71"))
0503   {
0504     if (tag <= 0x0124)
0505       wb_ind = tag - 0x0120;
0506     else
0507       wb_ind = tag - 0x0130 + 5;
0508 
0509     icWBC[Oly_wb_list1[wb_ind]][0] = get2();
0510     icWBC[Oly_wb_list1[wb_ind]][2] = get2();
0511   }
0512   else if ((tag == 0x0200) && (dng_writer == nonDNG))
0513   {
0514     for (i = 0; i < 3; i++)
0515     {
0516       if (!imOly.ColorSpace)
0517       {
0518         FORC3 cmatrix[i][c] = ((short)get2()) / 256.0;
0519       }
0520       else
0521       {
0522         FORC3 imgdata.color.ccm[i][c] = ((short)get2()) / 256.0;
0523       }
0524     }
0525   }
0526   else if ((tag == 0x0600) && (dng_writer == nonDNG))
0527   {
0528     FORC4 cblack[RGGB_2_RGBG(c)] = get2();
0529   }
0530   else if ((tag == 0x0612) && (dng_writer == nonDNG))
0531   {
0532     imgdata.sizes.raw_inset_crops[0].cleft = get2();
0533   }
0534   else if ((tag == 0x0613) && (dng_writer == nonDNG))
0535   {
0536     imgdata.sizes.raw_inset_crops[0].ctop = get2();
0537   }
0538   else if ((tag == 0x0614) && (dng_writer == nonDNG))
0539   {
0540     imgdata.sizes.raw_inset_crops[0].cwidth = get2();
0541   }
0542   else if ((tag == 0x0615) && (dng_writer == nonDNG))
0543   {
0544     imgdata.sizes.raw_inset_crops[0].cheight = get2();
0545   }
0546   return;
0547 }
0548 
0549 
0550 void LibRaw::parseOlympusMakernotes (int base, unsigned tag, unsigned type, unsigned len, unsigned dng_writer) {
0551 
0552   int c;
0553   unsigned a;
0554   if ((tag >= 0x20100000) && (tag <= 0x2010ffff)) {
0555         parseOlympus_Equipment((tag & 0x0000ffff), type, len, dng_writer);
0556 
0557   } else if ((tag >= 0x20200000) && (tag <= 0x2020ffff)) {
0558     parseOlympus_CameraSettings(base, (tag & 0x0000ffff), type, len, dng_writer);
0559 
0560   } else if ((tag >= 0x20400000) && (tag <= 0x2040ffff)) {
0561      parseOlympus_ImageProcessing((tag & 0x0000ffff), type, len, dng_writer);
0562 
0563   } else if ((tag >= 0x30000000) && (tag <= 0x3000ffff)) {
0564         parseOlympus_RawInfo((tag & 0x0000ffff), type, len, dng_writer);
0565 
0566   } else {
0567         switch (tag) {
0568             case 0x0200:
0569               FORC3 if ((imOly.SpecialMode[c] = get4()) >= 0xff) imOly.SpecialMode[c] = 0xffffffff;
0570               break;
0571             case 0x0207:
0572                 getOlympus_CameraType2();
0573                 break;
0574             case 0x0404:
0575             case 0x101a:
0576                 if (!imgdata.shootinginfo.BodySerial[0] && (dng_writer == nonDNG))
0577                     stmread(imgdata.shootinginfo.BodySerial, len, ifp);
0578                 break;
0579             case 0x1002:
0580                 ilm.CurAp = libraw_powf64l(2.0f, getreal(type) / 2);
0581                 break;
0582             case 0x1007:
0583                 imCommon.SensorTemperature = (float)get2();
0584                 break;
0585             case 0x1008:
0586                 imCommon.LensTemperature = (float)get2();
0587                 break;
0588             case 0x100b:
0589                 if (imOly.FocusMode[0] == 0xffff) {
0590                     imgdata.shootinginfo.FocusMode = imOly.FocusMode[0] = get2();
0591                     if (imgdata.shootinginfo.FocusMode == 1)
0592                         imgdata.shootinginfo.FocusMode = imOly.FocusMode[0] = 10;
0593                 }
0594                 break;
0595       case 0x100d:
0596         if (imOly.ZoomStepCount == 0xffff) imOly.ZoomStepCount = get2();
0597         break;
0598       case 0x100e:
0599         if (imOly.FocusStepCount == 0xffff) imOly.FocusStepCount = get2();
0600         break;
0601             case 0x1011:
0602                 if (strcmp(software, "v757-71") && (dng_writer == nonDNG)) {
0603                     for (int i = 0; i < 3; i++) {
0604                         if (!imOly.ColorSpace) {
0605                             FORC3 cmatrix[i][c] = ((short)get2()) / 256.0;
0606                         } else {
0607                             FORC3 imgdata.color.ccm[i][c] = ((short)get2()) / 256.0;
0608                         }
0609                     }
0610                 }
0611                 break;
0612             case 0x1012:
0613               if (dng_writer == nonDNG)
0614                   FORC4 cblack[RGGB_2_RGBG(c)] = get2();
0615                 break;
0616             case 0x1017:
0617                 if (dng_writer == nonDNG)
0618                   cam_mul[0] = get2() / 256.0;
0619                 break;
0620             case 0x1018:
0621                 if (dng_writer == nonDNG)
0622                   cam_mul[2] = get2() / 256.0;
0623                 break;
0624             case 0x102c:
0625                 if (dng_writer == nonDNG)
0626                   imOly.ValidBits = get2();
0627                 break;
0628             case 0x1038:
0629                 imOly.AFResult = get2();
0630                 break;
0631       case 0x103b:
0632         if (imOly.FocusStepInfinity == 0xffff) imOly.FocusStepInfinity = get2();
0633         break;
0634       case 0x103c:
0635         if (imOly.FocusStepNear == 0xffff) imOly.FocusStepNear = get2();
0636         break;
0637             case 0x20300108:
0638             case 0x20310109:
0639                 if (dng_writer == nonDNG) {
0640           imOly.ColorSpace = get2();
0641           switch (imOly.ColorSpace) {
0642           case 0:
0643             imCommon.ColorSpace = LIBRAW_COLORSPACE_sRGB;
0644             break;
0645           case 1:
0646             imCommon.ColorSpace = LIBRAW_COLORSPACE_AdobeRGB;
0647             break;
0648           case 2:
0649             imCommon.ColorSpace = LIBRAW_COLORSPACE_ProPhotoRGB;
0650             break;
0651           default:
0652             imCommon.ColorSpace = LIBRAW_COLORSPACE_Unknown;
0653             break;
0654           }
0655                 }
0656             case 0x20500209:
0657                 imOly.AutoFocus = get2();
0658                 break;
0659             case 0x20500300:
0660               imOly.ZoomStepCount = get2();
0661               break;
0662             case 0x20500301:
0663               imOly.FocusStepCount = get2();
0664               break;
0665             case 0x20500303:
0666               imOly.FocusStepInfinity = get2();
0667               break;
0668             case 0x20500304:
0669               imOly.FocusStepNear = get2();
0670               break;
0671             case 0x20500305:
0672               a = get4();
0673               /*b = */ get4(); // b is not used, so removed
0674               if (a >= 0x7f000000) imOly.FocusDistance = -1.0; // infinity
0675               else imOly.FocusDistance = (double) a / 1000.0;  // convert to meters
0676               break;
0677             case 0x20500308:
0678                 imOly.AFPoint = get2();
0679                 break;
0680             case 0x20501500:
0681                 getOlympus_SensorTemperature(len);
0682                 break;
0683         }
0684   }
0685 }