Coverage Report

Created: 2025-11-14 07:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libraw/src/metadata/olympus.cpp
Line
Count
Source
1
/* -*- C++ -*-
2
 * Copyright 2019-2025 LibRaw LLC (info@libraw.org)
3
 *
4
 LibRaw is free software; you can redistribute it and/or modify
5
 it under the terms of the one of two licenses as you choose:
6
7
1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1
8
   (See file LICENSE.LGPL provided in LibRaw distribution archive for details).
9
10
2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
11
   (See file LICENSE.CDDL provided in LibRaw distribution archive for details).
12
13
 */
14
15
#include "../../internal/dcraw_defs.h"
16
#include "../../internal/libraw_cameraids.h"
17
18
void LibRaw::setOlympusBodyFeatures(unsigned long long id)
19
3.97k
{
20
3.97k
  ilm.CamID = id;
21
22
3.97k
  if ((id == OlyID_E_1)      ||
23
3.96k
      (id == OlyID_E_300)    ||
24
3.96k
      (id == OlyID_AIR_A01)  ||
25
3.96k
      ((id & 0xffff000000ULL) == 0x5330000000ULL))
26
15
  {
27
15
    ilm.CameraFormat = LIBRAW_FORMAT_FT;
28
29
15
    if ((id == OlyID_E_1)   ||
30
10
        (id == OlyID_E_300) ||
31
10
        ((id >= OlyID_E_330) && (id <= OlyID_E_520)) ||
32
5
        (id == OlyID_E_620) ||
33
4
        (id == OlyID_E_450) ||
34
4
        (id == OlyID_E_600) ||
35
3
        (id == OlyID_E_5))
36
13
    {
37
13
      ilm.CameraMount = LIBRAW_MOUNT_FT;
38
13
    }
39
2
    else
40
2
    {
41
2
      ilm.CameraMount = LIBRAW_MOUNT_mFT;
42
2
    }
43
15
  }
44
45
3.95k
  else
46
3.95k
  {
47
3.95k
    if (
48
3.95k
        (id == OlyID_SH_2)  ||
49
3.95k
        (id == OlyID_TG_4)  ||
50
3.95k
        (id == OlyID_TG_5)  ||
51
3.93k
        (id == OlyID_TG_6)  ||
52
3.92k
        (id == OlyID_TG_7)  ||
53
3.90k
        (id == OlyID_XZ_10)
54
3.95k
       ) {
55
51
      ilm.CameraFormat = LIBRAW_FORMAT_1div2p3INCH;
56
51
    }
57
3.90k
    else
58
3.90k
    {
59
3.90k
      if (
60
3.90k
           (id == OlyID_STYLUS_1) ||
61
3.90k
           (id == OlyID_XZ_2)
62
3.90k
         ) {
63
5
        ilm.CameraFormat = LIBRAW_FORMAT_1div1p7INCH;
64
5
      }
65
3.90k
    }
66
3.95k
    ilm.LensMount = ilm.CameraMount = LIBRAW_MOUNT_FixedLens;
67
3.95k
  }
68
3.97k
  return;
69
3.97k
}
70
71
void LibRaw::getOlympus_CameraType2()
72
14.9k
{
73
74
14.9k
  if (OlyID != 0x0ULL)
75
10.9k
    return;
76
77
3.97k
  int i = 0;
78
3.97k
  fread(imOly.CameraType2, 6, 1, ifp);
79
3.97k
  imOly.CameraType2[5] = 0;
80
8.17k
  while ((i < 6) && imOly.CameraType2[i])
81
4.22k
  {
82
4.22k
    OlyID = OlyID << 8 | imOly.CameraType2[i];
83
4.22k
    if (i < 5 && isspace(imOly.CameraType2[i + 1])) {
84
26
      imOly.CameraType2[i + 1] = '\0';
85
26
      break;
86
26
    }
87
4.20k
    i++;
88
4.20k
  }
89
3.97k
  if (OlyID == OlyID_NORMA) {
90
0
    if (strcmp(model, "SP510UZ")) OlyID = OlyID_SP_510UZ;
91
0
    else OlyID = 0x0ULL;
92
0
  }
93
3.97k
  unique_id = OlyID;
94
3.97k
  setOlympusBodyFeatures(OlyID);
95
3.97k
  return;
96
14.9k
}
97
98
void LibRaw::getOlympus_SensorTemperature(unsigned len)
99
2.17k
{
100
2.17k
  if (OlyID != 0x0ULL)
101
1.64k
  {
102
1.64k
    short temp = get2();
103
1.64k
    if ((OlyID == OlyID_E_1)  ||
104
1.63k
        (OlyID == OlyID_E_M5) ||
105
1.63k
        (len != 1))
106
357
      imCommon.SensorTemperature = (float)temp;
107
1.29k
    else if ((temp != -32768) && (temp != 0))
108
632
    {
109
632
      if (temp > 199)
110
244
        imCommon.SensorTemperature = 86.474958f - 0.120228f * (float)temp;
111
388
      else
112
388
        imCommon.SensorTemperature = (float)temp;
113
632
    }
114
1.64k
  }
115
2.17k
  return;
116
2.17k
}
117
118
void LibRaw::parseOlympus_Equipment(unsigned tag, unsigned /*type */, unsigned len,
119
                                    unsigned dng_writer)
120
162k
{
121
  // uptag 2010
122
123
162k
  switch (tag)
124
162k
  {
125
2.98k
  case 0x0100:
126
2.98k
    getOlympus_CameraType2();
127
2.98k
    break;
128
2.93k
  case 0x0101:
129
2.93k
    if ((!imgdata.shootinginfo.BodySerial[0]) && (dng_writer == nonDNG))
130
1.19k
      stmread(imgdata.shootinginfo.BodySerial, len, ifp);
131
2.93k
    break;
132
1.51k
  case 0x0102:
133
1.51k
    stmread(imgdata.shootinginfo.InternalBodySerial, len, ifp);
134
1.51k
    break;
135
1.49k
  case 0x0201:
136
1.49k
  {
137
1.49k
    unsigned char bits[4];
138
1.49k
    fread(bits, 1, 4, ifp);
139
1.49k
    ilm.LensID = (unsigned long long)bits[0] << 16 |
140
1.49k
                 (unsigned long long)bits[2] << 8 | (unsigned long long)bits[3];
141
1.49k
    ilm.LensMount = LIBRAW_MOUNT_FT;
142
1.49k
    ilm.LensFormat = LIBRAW_FORMAT_FT;
143
1.49k
    if (((ilm.LensID < 0x20000) || (ilm.LensID > 0x4ffff)) &&
144
1.48k
        (ilm.LensID & 0x10))
145
59
      ilm.LensMount = LIBRAW_MOUNT_mFT;
146
1.49k
  }
147
1.49k
    break;
148
1.37k
  case 0x0202:
149
1.37k
    if ((!imgdata.lens.LensSerial[0]))
150
871
      stmread(imgdata.lens.LensSerial, len, ifp);
151
1.37k
    break;
152
1.31k
  case 0x0203:
153
1.31k
    stmread(ilm.Lens, len, ifp);
154
1.31k
    break;
155
1.21k
  case 0x0205:
156
1.21k
    ilm.MaxAp4MinFocal = libraw_powf64l(sqrt(2.0f), get2() / 256.0f);
157
1.21k
    break;
158
757
  case 0x0206:
159
757
    ilm.MaxAp4MaxFocal = libraw_powf64l(sqrt(2.0f), get2() / 256.0f);
160
757
    break;
161
595
  case 0x0207:
162
595
    ilm.MinFocal = (float)get2();
163
595
    break;
164
729
  case 0x0208:
165
729
    ilm.MaxFocal = (float)get2();
166
729
    if (ilm.MaxFocal > 1000.0f)
167
338
      ilm.MaxFocal = ilm.MinFocal;
168
729
    break;
169
1.37k
  case 0x020a:
170
1.37k
    ilm.MaxAp4CurFocal = libraw_powf64l(sqrt(2.0f), get2() / 256.0f);
171
1.37k
    break;
172
303
  case 0x0301:
173
303
    ilm.TeleconverterID = fgetc(ifp) << 8;
174
303
    fgetc(ifp);
175
303
    ilm.TeleconverterID = ilm.TeleconverterID | fgetc(ifp);
176
303
    break;
177
1.14k
  case 0x0303:
178
1.14k
    stmread(ilm.Teleconverter, len, ifp);
179
1.14k
    if (!strlen(ilm.Teleconverter) && strchr(ilm.Lens, '+')) {
180
235
      if (strstr(ilm.Lens, "MC-20"))
181
0
        strcpy(ilm.Teleconverter, "MC-20");
182
235
      else if (strstr(ilm.Lens, "MC-14"))
183
78
        strcpy(ilm.Teleconverter, "MC-14");
184
157
      else if (strstr(ilm.Lens, "EC-20"))
185
0
        strcpy(ilm.Teleconverter, "EC-20");
186
157
      else if (strstr(ilm.Lens, "EC-14"))
187
71
        strcpy(ilm.Teleconverter, "EC-14");    }
188
1.14k
    break;
189
688
  case 0x0403:
190
688
    stmread(ilm.Attachment, len, ifp);
191
688
    break;
192
162k
  }
193
194
162k
  return;
195
162k
}
196
void LibRaw::parseOlympus_CameraSettings(INT64 base, unsigned tag, unsigned type,
197
                                         unsigned len, unsigned dng_writer)
198
290k
{
199
  // uptag 0x2020
200
201
290k
  int c;
202
290k
  switch (tag)
203
290k
  {
204
1.88k
  case 0x0101:
205
1.88k
    if (dng_writer == nonDNG)
206
602
    {
207
602
      thumb_offset = get4() + base;
208
602
    }
209
1.88k
    break;
210
3.12k
  case 0x0102:
211
3.12k
    if (dng_writer == nonDNG)
212
532
    {
213
532
      thumb_length = get4();
214
532
    }
215
3.12k
    break;
216
1.26k
  case 0x0200:
217
1.26k
    imgdata.shootinginfo.ExposureMode = get2();
218
1.26k
    break;
219
401
  case 0x0202:
220
401
    imgdata.shootinginfo.MeteringMode = get2();
221
401
    break;
222
2.24k
  case 0x0301:
223
2.24k
    imgdata.shootinginfo.FocusMode = imOly.FocusMode[0] = get2();
224
2.24k
    if (len == 2)
225
146
    {
226
146
      imOly.FocusMode[1] = get2();
227
146
    }
228
2.24k
    break;
229
394
  case 0x0304:
230
25.6k
    for (c = 0; c < 64; c++)
231
25.2k
    {
232
25.2k
      imOly.AFAreas[c] = get4();
233
25.2k
    }
234
394
    break;
235
312
  case 0x0305:
236
1.87k
    for (c = 0; c < 5; c++)
237
1.56k
    {
238
1.56k
      imOly.AFPointSelected[c] = getreal(type);
239
1.56k
    }
240
312
    break;
241
297
  case 0x0306:
242
297
    imOly.AFFineTune = fgetc(ifp);
243
297
    break;
244
372
  case 0x0307:
245
1.11k
    FORC3 imOly.AFFineTuneAdj[c] = get2();
246
372
    break;
247
808
  case 0x0401:
248
808
    imCommon.FlashEC = getrealf(type);
249
808
    break;
250
1.88k
  case 0x0507:
251
1.88k
    imOly.ColorSpace = get2();
252
1.88k
    switch (imOly.ColorSpace) {
253
199
    case 0:
254
199
      imCommon.ColorSpace = LIBRAW_COLORSPACE_sRGB;
255
199
      break;
256
250
    case 1:
257
250
      imCommon.ColorSpace = LIBRAW_COLORSPACE_AdobeRGB;
258
250
      break;
259
534
    case 2:
260
534
      imCommon.ColorSpace = LIBRAW_COLORSPACE_ProPhotoRGB;
261
534
      break;
262
906
    default:
263
906
      imCommon.ColorSpace = LIBRAW_COLORSPACE_Unknown;
264
906
      break;
265
1.88k
    }
266
1.88k
    break;
267
1.88k
  case 0x0600:
268
1.18k
    imgdata.shootinginfo.DriveMode = imOly.DriveMode[0] = get2();
269
2.08k
    for (c = 1; c < (int)len && c < 5; c++)
270
895
    {
271
895
      imOly.DriveMode[c] = get2();
272
895
    }
273
1.18k
    break;
274
288
  case 0x0601:
275
288
    imOly.Panorama_mode = get2();
276
288
    imOly.Panorama_frameNum = get2();
277
288
    break;
278
369
  case 0x0604:
279
369
    imgdata.shootinginfo.ImageStabilization = get4();
280
369
    break;
281
2.66k
  case 0x0804:
282
2.66k
    imOly.StackedImage[0] = get4();
283
2.66k
    imOly.StackedImage[1] = get4();
284
2.66k
    if (imOly.StackedImage[0] == 3) {
285
429
      imOly.isLiveND = 1;
286
429
      imOly.LiveNDfactor = imOly.StackedImage[1];
287
2.23k
    } else {
288
2.23k
      imOly.isLiveND = 0;
289
2.23k
    }
290
2.66k
    break;
291
290k
  }
292
293
290k
  return;
294
290k
}
295
296
void LibRaw::parseOlympus_ImageProcessing(unsigned tag, unsigned type,
297
                                          unsigned len, unsigned dng_writer)
298
361k
{
299
  // uptag 0x2040
300
301
361k
  int i, c, wb[4], nWB, tWB, wbG;
302
361k
  ushort CT;
303
361k
  short sorder;
304
305
361k
  if ((tag == 0x0100) && (dng_writer == nonDNG))
306
2.66k
  {
307
2.66k
    cam_mul[0] = float(get2()) / 256.f;
308
2.66k
    cam_mul[2] = float(get2()) / 256.f;
309
2.66k
  }
310
358k
  else if ((tag == 0x0101) && (len == 2) &&
311
1.34k
           ((OlyID == OlyID_E_410) || (OlyID == OlyID_E_510)))
312
0
  {
313
0
    for (i = 0; i < 64; i++)
314
0
    {
315
0
    icWBCCTC[i][2] = icWBCCTC[i][4] = 256.f;
316
0
    icWBC[i][1] = icWBC[i][3] = 0x100;
317
0
    }
318
0
    for (i = 64; i < 256; i++)
319
0
    {
320
0
      icWBC[i][1] = icWBC[i][3] = 0x100;
321
0
    }
322
0
  }
323
358k
  else if ((tag > 0x0101) && (tag <= 0x0111))
324
11.0k
  {
325
11.0k
    nWB = tag - 0x0101;
326
11.0k
    tWB = Oly_wb_list2[nWB << 1];
327
11.0k
    CT = Oly_wb_list2[(nWB << 1) | 1];
328
11.0k
    wb[0] = get2();
329
11.0k
    wb[2] = get2();
330
11.0k
    if (tWB != 0x100)
331
8.51k
    {
332
8.51k
      icWBC[tWB][0] = wb[0];
333
8.51k
      icWBC[tWB][2] = wb[2];
334
8.51k
    }
335
11.0k
    if (CT)
336
3.71k
    {
337
3.71k
      icWBCCTC[nWB - 1][0] = CT;
338
3.71k
      icWBCCTC[nWB - 1][1] = float(wb[0]);
339
3.71k
      icWBCCTC[nWB - 1][3] = float(wb[2]);
340
3.71k
    }
341
11.0k
    if (len == 4)
342
1.60k
    {
343
1.60k
      wb[1] = get2();
344
1.60k
      wb[3] = get2();
345
1.60k
      if (tWB != 0x100)
346
943
      {
347
943
        icWBC[tWB][1] = wb[1];
348
943
        icWBC[tWB][3] = wb[3];
349
943
      }
350
1.60k
      if (CT)
351
665
      {
352
665
        icWBCCTC[nWB - 1][2] = float(wb[1]);
353
665
        icWBCCTC[nWB - 1][4] = float(wb[3]);
354
665
      }
355
1.60k
    }
356
11.0k
  }
357
347k
  else if ((tag >= 0x0112) && (tag <= 0x011e))
358
1.60k
  {
359
1.60k
    nWB = tag - 0x0112;
360
1.60k
    wbG = get2();
361
1.60k
    tWB = Oly_wb_list2[nWB << 1];
362
1.60k
    if (nWB)
363
1.10k
      icWBCCTC[nWB - 1][2] = icWBCCTC[nWB - 1][4] = float(wbG);
364
1.60k
    if (tWB != 0x100)
365
1.08k
      icWBC[tWB][1] = icWBC[tWB][3] = wbG;
366
1.60k
  }
367
345k
  else if (tag == 0x011f)
368
1.25k
  {
369
1.25k
    wbG = get2();
370
1.25k
    if (icWBC[LIBRAW_WBI_Flash][0])
371
321
      icWBC[LIBRAW_WBI_Flash][1] =
372
321
          icWBC[LIBRAW_WBI_Flash][3] = wbG;
373
5.02k
    FORC4 if (icWBC[LIBRAW_WBI_Custom1 + c][0])
374
1.27k
        icWBC[LIBRAW_WBI_Custom1 + c][1] =
375
1.27k
        icWBC[LIBRAW_WBI_Custom1 + c][3] = wbG;
376
1.25k
  }
377
344k
  else if (tag == 0x0121)
378
1.82k
  {
379
1.82k
    icWBC[LIBRAW_WBI_Flash][0] = get2();
380
1.82k
    icWBC[LIBRAW_WBI_Flash][2] = get2();
381
1.82k
    if (len == 4)
382
689
    {
383
689
      icWBC[LIBRAW_WBI_Flash][1] = get2();
384
689
      icWBC[LIBRAW_WBI_Flash][3] = get2();
385
689
    }
386
1.82k
  }
387
342k
  else if ((tag == 0x0200) && (dng_writer == nonDNG) &&
388
1.58k
           strcmp(software, "v757-71"))
389
1.50k
  {
390
6.03k
    for (i = 0; i < 3; i++)
391
4.52k
    {
392
4.52k
      if (!imOly.ColorSpace)
393
3.88k
      {
394
11.6k
        FORC3 cmatrix[i][c] = float((short)get2()) / 256.f;
395
3.88k
      }
396
645
      else
397
645
      {
398
1.93k
        FORC3 imgdata.color.ccm[i][c] = float((short)get2()) / 256.f;
399
645
      }
400
4.52k
    }
401
1.50k
  }
402
341k
  else if ((tag == 0x0600) && (dng_writer == nonDNG))
403
2.24k
  {
404
8.96k
    FORC4 cblack[RGGB_2_RGBG(c)] = get2();
405
2.24k
  }
406
339k
  else if ((tag == 0x0611) && (dng_writer == nonDNG))
407
254
  {
408
254
     imOly.ValidBits = get2();
409
254
  }
410
338k
  else if ((tag == 0x0612) && (dng_writer == nonDNG))
411
379
  {
412
379
    imgdata.sizes.raw_inset_crops[0].cleft = get2();
413
379
  }
414
338k
  else if ((tag == 0x0613) && (dng_writer == nonDNG))
415
642
  {
416
642
    imgdata.sizes.raw_inset_crops[0].ctop = get2();
417
642
  }
418
337k
  else if ((tag == 0x0614) && (dng_writer == nonDNG))
419
202
  {
420
202
    imgdata.sizes.raw_inset_crops[0].cwidth = get2();
421
202
  }
422
337k
  else if ((tag == 0x0615) && (dng_writer == nonDNG))
423
119
  {
424
119
    imgdata.sizes.raw_inset_crops[0].cheight = get2();
425
119
  }
426
337k
  else if ((tag == 0x0640) && (dng_writer == nonDNG))
427
90
  {
428
90
    imOly.tagX640 = get2();
429
90
  }
430
337k
  else if ((tag == 0x0641) && (dng_writer == nonDNG))
431
251
  {
432
251
    imOly.tagX641 = get2();
433
251
  }
434
337k
  else if ((tag == 0x0642) && (dng_writer == nonDNG))
435
765
  {
436
765
    imOly.tagX642 = get2();
437
765
  }
438
336k
  else if ((tag == 0x0643) && (dng_writer == nonDNG))
439
268
  {
440
268
    imOly.tagX643 = get2();
441
268
  }
442
336k
  else if ((tag == 0x0644) && (dng_writer == nonDNG))
443
327
  {
444
327
    imOly.tagX644 = get2();
445
327
  }
446
335k
  else if ((tag == 0x0645) && (dng_writer == nonDNG))
447
256
  {
448
256
    imOly.tagX645 = get2();
449
256
  }
450
335k
  else if ((tag == 0x0646) && (dng_writer == nonDNG))
451
253
  {
452
253
    imOly.tagX646 = get2();
453
253
  }
454
335k
  else if ((tag == 0x0647) && (dng_writer == nonDNG))
455
82
  {
456
82
    imOly.tagX647 = get2();
457
82
  }
458
335k
  else if ((tag == 0x0648) && (dng_writer == nonDNG))
459
82
  {
460
82
    imOly.tagX648 = get2();
461
82
  }
462
335k
  else if ((tag == 0x0649) && (dng_writer == nonDNG))
463
271
  {
464
271
    imOly.tagX649 = get2();
465
271
  }
466
334k
  else if ((tag == 0x0650) && (dng_writer == nonDNG))
467
381
  {
468
381
    imOly.tagX650 = get2();
469
381
  }
470
334k
  else if ((tag == 0x0651) && (dng_writer == nonDNG))
471
262
  {
472
262
    imOly.tagX651 = get2();
473
262
  }
474
334k
  else if ((tag == 0x0652) && (dng_writer == nonDNG))
475
89
  {
476
89
    imOly.tagX652 = get2();
477
89
  }
478
334k
  else if ((tag == 0x0653) && (dng_writer == nonDNG))
479
297
  {
480
297
    imOly.tagX653 = get2();
481
297
  }
482
333k
  else if ((tag == 0x0805) && (len == 2))
483
522
  {
484
522
    imOly.SensorCalibration[0] = int(getreal(type));
485
522
    imOly.SensorCalibration[1] = int(getreal(type));
486
522
    if ((dng_writer == nonDNG) && (OlyID != OlyID_XZ_1))
487
1.26k
      FORC4 imgdata.color.linear_max[c] = imOly.SensorCalibration[0];
488
522
  }
489
333k
  else if (tag == 0x1112)
490
6.15k
  {
491
6.15k
    sorder = order;
492
6.15k
    order = 0x4d4d;
493
6.15k
    c = get2();
494
6.15k
    order = sorder;
495
6.15k
    switch (c) {
496
267
    case 0x0101:
497
585
    case 0x0901:
498
1.31k
    case 0x0909:
499
1.31k
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_4to3;
500
1.31k
      break;
501
503
    case 0x0104:
502
821
    case 0x0401:
503
821
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_1to1;
504
821
      break;
505
231
    case 0x0201:
506
558
    case 0x0202:
507
558
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_3to2;
508
558
      break;
509
252
    case 0x0301:
510
571
    case 0x0303:
511
571
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_16to9;
512
571
      break;
513
332
    case 0x0404:
514
//      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_6to6;
515
332
        imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_1to1;
516
332
      break;
517
290
    case 0x0505:
518
290
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_5to4;
519
290
      break;
520
368
    case 0x0606:
521
368
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_7to6;
522
368
      break;
523
244
    case 0x0707:
524
244
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_6to5;
525
244
      break;
526
298
    case 0x0808:
527
298
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_7to5;
528
298
      break;
529
1.35k
    default:
530
1.35k
      imgdata.sizes.raw_aspect = LIBRAW_IMAGE_ASPECT_OTHER;
531
1.35k
      break;
532
6.15k
    }
533
6.15k
  }
534
327k
  else if (tag == 0x1113)
535
418
  {
536
418
    imOly.AspectFrame[0] = get2();
537
418
    imOly.AspectFrame[1] = get2();
538
418
    imOly.AspectFrame[2] = get2();
539
418
    imOly.AspectFrame[3] = get2();
540
418
  }
541
326k
  else if (tag == 0x1306)
542
2.91k
  {
543
2.91k
    c = get2();
544
2.91k
    if ((c != 0) && (c != 100))
545
2.34k
    {
546
2.34k
      if (c < 61)
547
1.39k
        imCommon.CameraTemperature = (float)c;
548
951
      else
549
951
        imCommon.CameraTemperature = (float)(c - 32) / 1.8f;
550
2.34k
      if ((imCommon.exifAmbientTemperature > -273.15f) &&
551
1.49k
          ((OlyID == OlyID_TG_5) ||
552
1.39k
           (OlyID == OlyID_TG_6) ||
553
1.31k
           (OlyID == OlyID_TG_7))
554
2.34k
      )
555
496
        imCommon.CameraTemperature += imCommon.exifAmbientTemperature;
556
2.34k
    }
557
2.91k
  }
558
559
361k
  return;
560
361k
}
561
562
void LibRaw::parseOlympus_RawInfo(unsigned tag, unsigned /*type */, unsigned len,
563
                                  unsigned dng_writer)
564
105k
{
565
  // uptag 0x3000
566
567
105k
  int wb_ind, c, i;
568
569
105k
  if ((tag == 0x0110) && strcmp(software, "v757-71"))
570
822
  {
571
822
    icWBC[LIBRAW_WBI_Auto][0] = get2();
572
822
    icWBC[LIBRAW_WBI_Auto][2] = get2();
573
822
    if (len == 2)
574
534
    {
575
137k
      for (i = 0; i < 256; i++)
576
136k
        icWBC[i][1] = icWBC[i][3] = 0x100;
577
534
    }
578
822
  }
579
104k
  else if ((((tag >= 0x0120) && (tag <= 0x0124)) ||
580
103k
            ((tag >= 0x0130) && (tag <= 0x0133))) &&
581
2.49k
           strcmp(software, "v757-71"))
582
2.18k
  {
583
2.18k
    if (tag <= 0x0124)
584
940
      wb_ind = tag - 0x0120;
585
1.24k
    else
586
1.24k
      wb_ind = tag - 0x0130 + 5;
587
588
2.18k
    icWBC[Oly_wb_list1[wb_ind]][0] = get2();
589
2.18k
    icWBC[Oly_wb_list1[wb_ind]][2] = get2();
590
2.18k
  }
591
102k
  else if ((tag == 0x0200) && (dng_writer == nonDNG))
592
1.72k
  {
593
6.91k
    for (i = 0; i < 3; i++)
594
5.18k
    {
595
5.18k
      if (!imOly.ColorSpace)
596
3.87k
      {
597
11.6k
        FORC3 cmatrix[i][c] = float((short)get2()) / 256.f;
598
3.87k
      }
599
1.31k
      else
600
1.31k
      {
601
3.95k
        FORC3 imgdata.color.ccm[i][c] = float((short)get2()) / 256.f;
602
1.31k
      }
603
5.18k
    }
604
1.72k
  }
605
100k
  else if ((tag == 0x0600) && (dng_writer == nonDNG))
606
1.71k
  {
607
6.84k
    FORC4 cblack[RGGB_2_RGBG(c)] = get2();
608
1.71k
  }
609
98.8k
  else if ((tag == 0x0612) && (dng_writer == nonDNG))
610
80
  {
611
80
    imgdata.sizes.raw_inset_crops[0].cleft = get2();
612
80
  }
613
98.8k
  else if ((tag == 0x0613) && (dng_writer == nonDNG))
614
422
  {
615
422
    imgdata.sizes.raw_inset_crops[0].ctop = get2();
616
422
  }
617
98.3k
  else if ((tag == 0x0614) && (dng_writer == nonDNG))
618
113
  {
619
113
    imgdata.sizes.raw_inset_crops[0].cwidth = get2();
620
113
  }
621
98.2k
  else if ((tag == 0x0615) && (dng_writer == nonDNG))
622
889
  {
623
889
    imgdata.sizes.raw_inset_crops[0].cheight = get2();
624
889
  }
625
105k
  return;
626
105k
}
627
628
629
1.98M
void LibRaw::parseOlympusMakernotes (INT64 base, unsigned tag, unsigned type, unsigned len, unsigned dng_writer) {
630
631
1.98M
  int c;
632
1.98M
  unsigned a;
633
1.98M
  if ((tag >= 0x20100000) && (tag <= 0x2010ffff)) {
634
162k
        parseOlympus_Equipment((tag & 0x0000ffff), type, len, dng_writer);
635
636
1.82M
  } else if ((tag >= 0x20200000) && (tag <= 0x2020ffff)) {
637
290k
    parseOlympus_CameraSettings(base, (tag & 0x0000ffff), type, len, dng_writer);
638
639
1.53M
  } else if ((tag >= 0x20400000) && (tag <= 0x2040ffff)) {
640
361k
     parseOlympus_ImageProcessing((tag & 0x0000ffff), type, len, dng_writer);
641
642
1.17M
  } else if ((tag >= 0x30000000) && (tag <= 0x3000ffff)) {
643
105k
        parseOlympus_RawInfo((tag & 0x0000ffff), type, len, dng_writer);
644
645
1.06M
  } else {
646
1.06M
    switch (tag) {
647
6.88k
      case 0x0200:
648
20.6k
        FORC3 if ((imOly.SpecialMode[c] = get4()) >= 0xff) imOly.SpecialMode[c] = 0xffffffff;
649
6.88k
        break;
650
11.9k
      case 0x0207:
651
11.9k
        getOlympus_CameraType2();
652
11.9k
        break;
653
1.59k
      case 0x0404:
654
2.07k
      case 0x101a:
655
2.07k
        if (!imgdata.shootinginfo.BodySerial[0] && (dng_writer == nonDNG))
656
847
          stmread(imgdata.shootinginfo.BodySerial, len, ifp);
657
2.07k
        break;
658
1.00k
      case 0x1002:
659
1.00k
        ilm.CurAp = float(libraw_powf64l(2.0f, getrealf(type) / 2.f));
660
1.00k
        break;
661
734
      case 0x1007:
662
734
        imCommon.SensorTemperature = (float)get2();
663
734
        break;
664
326
      case 0x1008:
665
326
        imCommon.LensTemperature = (float)get2();
666
326
        break;
667
902
      case 0x100b:
668
902
        if (imOly.FocusMode[0] == 0xffff) {
669
276
          imgdata.shootinginfo.FocusMode = imOly.FocusMode[0] = get2();
670
276
          if (imgdata.shootinginfo.FocusMode == 1)
671
2
            imgdata.shootinginfo.FocusMode = imOly.FocusMode[0] = 10;
672
276
        }
673
902
        break;
674
1.27k
      case 0x100d:
675
1.27k
        if (imOly.ZoomStepCount == 0xffff) imOly.ZoomStepCount = get2();
676
1.27k
        break;
677
365
      case 0x100e:
678
365
        if (imOly.FocusStepCount == 0xffff) imOly.FocusStepCount = get2();
679
365
        break;
680
2.61k
      case 0x1011:
681
2.61k
        if (strcmp(software, "v757-71") && (dng_writer == nonDNG)) {
682
8.58k
          for (int i = 0; i < 3; i++) {
683
6.44k
            if (!imOly.ColorSpace) {
684
11.5k
              FORC3 cmatrix[i][c] = float((short)get2()) / 256.f;
685
3.84k
            } else {
686
7.78k
              FORC3 imgdata.color.ccm[i][c] = float((short)get2()) / 256.f;
687
2.59k
            }
688
6.44k
          }
689
2.14k
        }
690
2.61k
        break;
691
1.26k
      case 0x1012:
692
1.26k
        if (dng_writer == nonDNG)
693
4.75k
          FORC4 cblack[RGGB_2_RGBG(c)] = get2();
694
1.26k
        break;
695
536
      case 0x1017:
696
536
        if (dng_writer == nonDNG)
697
290
          cam_mul[0] = float(get2()) / 256.f;
698
536
        break;
699
687
      case 0x1018:
700
687
        if (dng_writer == nonDNG)
701
310
          cam_mul[2] = float(get2()) / 256.f;
702
687
        break;
703
231
      case 0x102c:
704
231
        if (dng_writer == nonDNG)
705
100
          imOly.ValidBits = get2();
706
231
        break;
707
526
      case 0x1038:
708
526
        imOly.AFResult = get2();
709
526
        break;
710
744
      case 0x103b:
711
744
        if (imOly.FocusStepInfinity == 0xffff) imOly.FocusStepInfinity = get2();
712
744
        break;
713
1.00k
      case 0x103c:
714
1.00k
        if (imOly.FocusStepNear == 0xffff) imOly.FocusStepNear = get2();
715
1.00k
        break;
716
293
      case 0x20300108:
717
830
      case 0x20310109:
718
830
        if (dng_writer == nonDNG) {
719
775
          imOly.ColorSpace = get2();
720
775
          switch (imOly.ColorSpace) {
721
121
          case 0:
722
121
            imCommon.ColorSpace = LIBRAW_COLORSPACE_sRGB;
723
121
            break;
724
68
          case 1:
725
68
            imCommon.ColorSpace = LIBRAW_COLORSPACE_AdobeRGB;
726
68
            break;
727
169
          case 2:
728
169
            imCommon.ColorSpace = LIBRAW_COLORSPACE_ProPhotoRGB;
729
169
            break;
730
417
          default:
731
417
            imCommon.ColorSpace = LIBRAW_COLORSPACE_Unknown;
732
417
            break;
733
775
          }
734
775
        }
735
1.07k
      case 0x20500209:
736
1.07k
        imOly.AutoFocus = get2();
737
1.07k
        break;
738
554
      case 0x20500300:
739
554
        imOly.ZoomStepCount = get2();
740
554
        break;
741
387
      case 0x20500301:
742
387
        imOly.FocusStepCount = get2();
743
387
        break;
744
2.30k
      case 0x20500303:
745
2.30k
        imOly.FocusStepInfinity = get2();
746
2.30k
        break;
747
1.18k
      case 0x20500304:
748
1.18k
        imOly.FocusStepNear = get2();
749
1.18k
        break;
750
564
      case 0x20500305:
751
564
        a = get4();
752
564
        /*b = */ get4(); // b is not used, so removed
753
564
        if (a >= 0x7f000000) imOly.FocusDistance = -1.0; // infinity
754
258
        else imOly.FocusDistance = (double) a / 1000.0;  // convert to meters
755
564
        break;
756
294
      case 0x20500308:
757
294
        imOly.AFPoint = get2();
758
294
        break;
759
2.17k
      case 0x20501500:
760
2.17k
        getOlympus_SensorTemperature(len);
761
2.17k
        break;
762
1.06M
    }
763
1.06M
  }
764
1.98M
}